Working with AVR GCC on an Atmega1284P, I used to have the following:
#define CMP_START_ADDR 0x18000
static UInt32 loadingAddr = CMP_START_ADDR;
static UInt32 newCmpAddr = CMP_START_ADDR;
Where, e.g. loadingAddr , is used as follows somewhere (as an address):
boot_program_page(loadingAddr,block_page);
and where UInt32 is typedef unsigned long UInt32;
Now I want the same setup but as follows:
#define CMP_START_ADDR ROM_SIZE-RESERVED_CMP_ROM_SPACE
static UInt8 amount_of_files = 0;
static UInt32 loadingAddr = CMP_START_ADDR;
static UInt32 newCmpAddr = CMP_START_ADDR;
Where ROM_SIZE and RESERVED_CMP_ROM_SPACE are respectively defined somewhere as:
#define ROM_SIZE FLASHEND
#define RESERVED_CMP_ROM_SPACE 28000
And FLASHEND is from iom128.h:
#define FLASHEND 0x1FFFF
The new code compiles but does not work. I assume the address goes wrong because I'm using integers and hexadecimals inconsistently. How would I most efficiently resolve this?
RESERVED_CMP_ROM_SPACE 28000
28000 is not page aligned so if your implementation of boot_program_page
is the one here the program will compile and even do something but not write the program you expect.
If you read the memory with a debugger after bootload I think you will observe something like a3a1a2b3b1b2c3c1c2 instead of a1a2a3b1b2b3c1c2c3.
Try with RESERVED_CMP_ROM_SPACE 32768