View previous topic :: View next topic |
Author |
Message |
georpo
Joined: 18 Nov 2008 Posts: 281 Location: Athens, Greece.
|
pcd bootloader |
Posted: Thu Feb 20, 2020 5:57 am |
|
|
Hello all!
I tried the pcd bootloader example and it works just fine.
I can update various simple "Hello world" programs with Tera Term. (Siow shows Timeout error).
Now, I have a big and complex program with timer interrupts, spi interrupts etc which works normally. Will this work if I update through the bootloader? I am asking because I see interrupts in the bootloader code and I do not know what will happen.
Thanks. _________________ George. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Thu Feb 20, 2020 8:23 am |
|
|
In the program you load with the bootloader, this line in pcd_bootloader.h:
#build (reset=APPLICATION_START,interrupt=APPLICATION_ISR_START)
Relocates the interrupt table for this code. Note the 'interrupt=' part.
It's placed at the same location inside the new 'loaded' code, that it would
normally be at the bottom of memory outside the bootloader. PCD allows the
actual interrupt table to be moved, so none of the need to 're-vector' the
interrupts that applies with the PIC16/18. |
|
|
georpo
Joined: 18 Nov 2008 Posts: 281 Location: Athens, Greece.
|
|
Posted: Thu Feb 20, 2020 10:54 am |
|
|
Thanks Ttelmah.
So it will work. Right? _________________ George. |
|
|
georpo
Joined: 18 Nov 2008 Posts: 281 Location: Athens, Greece.
|
|
Posted: Fri Feb 21, 2020 1:43 am |
|
|
Hello!!!
I am modifying the example to read the firmware from external flash
but I get out of ROM error. How can I increase the bootloader size?
Thanks. _________________ George. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Fri Feb 21, 2020 1:58 am |
|
|
Just define LOADER_PAGES before you load pcd_bootloader.h (both
in the bootloader, and in the main application). The default is 19 pages
for chips that have a 128byte page size, and 2 pages for the ones that
have a 2K page size. Check the data sheet for your chip for the flash
erase size, and either take the number of pages up to 3, or possibly up
to something like 28 if yours is one of the chips with the smaller erase
size.
So for the bootloader, on a chip with the larger pages:
Code: |
//processor stuff
//clock stuff
#define _bootloader
#define LOADER_PAGES 3
#include <pcd_bootloader.h>
//rest of code
|
Setting this automatically adjusts everything else (loader end, the load
address etc. etc..). |
|
|
georpo
Joined: 18 Nov 2008 Posts: 281 Location: Athens, Greece.
|
|
Posted: Fri Feb 21, 2020 2:03 am |
|
|
Thanks again!!
So can I set the loader pages to anything that will fit my code?
Or it must be multiple of something etc? _________________ George. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Fri Feb 21, 2020 3:28 am |
|
|
LOADER_PAGES can be 'anything you want'.
The loader has to occupy a multiple of the erase block size. This is handled
for you by the .h file which multiplies LOADER_PAGES by the chip's
erase block size to calculate the size to reserve for the loader.
However (obviously) on chips where the block size is 4KB, using a large
value gives an enormous amount of space reserved for the loader.
You don't want to set it any larger than is needed. |
|
|
georpo
Joined: 18 Nov 2008 Posts: 281 Location: Athens, Greece.
|
|
Posted: Fri Feb 21, 2020 4:05 am |
|
|
Ttelmah, thanks a million!!! _________________ George. |
|
|
|