Ranfo
Joined: 08 Sep 2008 Posts: 38
|
Questions about 18F4525 WIFI Bootloader |
Posted: Fri Jun 10, 2016 7:16 am |
|
|
My WIFI bootloader works, but I do have some concerns. It would be great if someone could look at my #build and #org settings and offer any suggestions since I am not clear on how these directives are to be used. My fear is that although it is working now, at some point if settings are incorrect the bootloader will be damaged by an upload.
This is my header that locates the bootloader in upper memory.
Code: | #define LOADER_ADDR 0xB200
#define FLASH_SIZE getenv("FLASH_ERASE_SIZE") // Smallest number of bytes that can be erased in FLASH
#define LOADER_END ((LOADER_ADDR + FLASH_SIZE - (LOADER_ADDR % FLASH_SIZE)) - 1)
#build(reset=LOADER_END+1, interrupt=LOADER_END + 9)
#org 0, LOADER_END {} |
When HEX file data starts arriving over the WIFI a routine is called indirectly. Examples show using an #org directive here, but I cannot without getting an illegal range error. The code works without the #org as shown. What would be the correct way?
Code: | // #ORG LOADER_ADDR // LOADER_ADDR, LOADER_ADDR + 9
void load_program () {
hv_loadProgram();
} |
This was added after the main function, but I am not sure what it does or if it is correct. The code works with or without it.
Code: | #ORG default
#int_global
void isr () {
jump_to_isr(LOADER_END+5*(getenv("BITS_PER_INSTRUCTION")/8));
} |
|
|