|
|
View previous topic :: View next topic |
Author |
Message |
alex Guest
|
C with bootloader software(16f877) |
Posted: Fri May 21, 2004 5:14 am |
|
|
I use the microcode loader software with 18F877 devices having bootloader software inside. Because the loader resides in the upper part of program memory, it needs a way to 'jump' to the start of the bootloader code when power is first applied, or when the microcontroller is reset. To do this, it uses the first four program words (called the reset vector) to execute a jump to the bootloader code. When I program the target microcontroller using MicroCode Loader, program instructions that occupy the first four locations are automatically relocated by the bootloader. If the bootloader did not relocate these instructions, the important 'jump to bootloader' would get overwritten and the bootloader software would not start next time power was applied or the microcontroller was reset. Therefore, my program needs to be modified to support this process.
I am not sure how to achieve this in C, anybody can help me. |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Fri May 21, 2004 6:04 am |
|
|
I like the Jolt bootloader:
http://mdubuc.freeshell.org/Jolt/
On this page, scroll down to 'How to Relocate User Code' for instructions on how to allocate memory for your bootloader and to relocate the interrupt vectors. |
|
|
John P
Joined: 17 Sep 2003 Posts: 331
|
|
Posted: Fri May 21, 2004 7:10 am |
|
|
If you're using a bootloader that somebody else wrote, the loader should take care of relocating your first 4 words. It wouldn't be your job to do that, and if it doesn't work right, you can complain to the vendor/programmer.
If you're writing the bootloader yourself, then yes, you have to do it. The bootloader should test for data being written to an address less than 4, and if found, should place it in a new location to which control branches when the loader decides to start executing user code. But note that the bootloader has to handle the situation where there isn't any user code in the first 4 words--as would apply if user code has never been loaded, or if the first 4 words weren't included. And you also have to deal with user code that doesn't have any interrupts, which would mean that the first 4 bytes are not a jump. So the bootloader would then execute the first 4 instructions in their "new" location and do a jump to location 4 to continue executing user code. It is indeed a little confusing. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|