Hello all!
I've a project under MCUxpresso that is moved from Code Warrior 10.6 (changed MCU to LPC845 from MCF51QE128 also). The CW10 version we have set up to make s19 image for Cyclone for their Serialize utility to drop in a 3-byte serial number on each flash, works great for multiple projects over past 10 years.
Problem: Since making a new project for ARM LPC parts, I cannot figure out how to allocate these 3 bytes (as we did with older CW10 projects, allocate the whole flash page 0x40 bytes for LPC) for this. Cyclone can program the code and it's fine, but adding in 'PS' command throws B008 error. Seems to indicate there is an overlap of code. For CW10 we edited the .lcf file:
MEMORY {
code (RX) : ORIGIN = 0x00000410, LENGTH = 0x0001E000
#bootcode (RX) : ORIGIN = 0x0001F000, LENGTH = 0x00000FFF // TOP of FLASH for Bootloader code (4K)
keypadOps (RX) : ORIGIN = 0x0001F800, LENGTH = 0x000003FF # TOP of FLASH for Bootloader code (1K)
serialnum (RX) : ORIGIN = 0x0001FC00, LENGTH = 0x000003FF #= READ_ONLY (0x40 is the min range that can be preserved with Multilink)
userram (RWX) : ORIGIN = 0x00800880, LENGTH = 0x00001780
flashsubs (RWX) : ORIGIN = 0x00800800, LENGTH = 0x0000007F
eventrampage (RW) : ORIGIN = 0x00800400, LENGTH = 0x00000400
}
However, with MCUx , allocating it thus (sorry for the XML that it exports):
<memory id="Flash" type="Flash" is_ro="true" can_program="true"/>
<memory id="RAM" type="RAM"/>
<memoryInstance id="PROGRAM_FLASH" derived_from="Flash" location="0x0" size="0xfbc0" driver="LPC84x_64.cfx" edited="true"/>
<memoryInstance id="SERIALNUM_FLASH" derived_from="Flash" location="0xfbc0" size="0x40" driver="LPC84x_64.cfx" edited="true"/>
<memoryInstance id="eeflash_FLASH" derived_from="Flash" location="0xfc00" size="0x400" driver="LPC84x_64.cfx" edited="true"/>
<memoryInstance id="SRAM" derived_from="RAM" location="0x10000000" size="0x1fe0" edited="true"/>
<memoryInstance id="IAP_SRAM" derived_from="RAM" location="0x10001fe0" size="0x20" edited="true"/>
eeflash_FLASH is a page where we do IAP for dynamic settings from the UI of the MCU application.
and of course SERIALNUM_FLASH is the page I am trying to leave available for Cyclone.
Perhaps the issue if that it needs to be at end of flash for this to work?
Asking here and not at PEMicro, as this will be an MCUx setup issue, something I missed. Cannot find an example of this, so please let me know, if you have experience with this.
Cheers
<jeff>
Solved! Go to Solution.
Found it!
Using __NOINIT instead of __RODATA when defining the serialnum[3] solved this. D'oh!
Found it!
Using __NOINIT instead of __RODATA when defining the serialnum[3] solved this. D'oh!
Additional detail - maybe it's "filling in" this area because of how we access it under MCUx?
Here's what worked with CW10 for accessing the sernum:
// 6 digit (3 byte) serial number storage here @ $1FC00
//Serial number will be at 0x1FC00
byte SER_1 @0x1FC00;
byte SER_2 @0x1FC01;
byte SER_3 @0x1FC02;
Here is the code we have to allocate the 3 serialnum bytes, for the program to access them later:
__RODATA(Flash3) const struct kpdopts eeflash;
//https://www.keil.com/support/man/docs/armcc/armcc_chr1359124981436.htm
struct kpdopts eedata __attribute__((aligned (256)));
#if DO_LOCAL_SERIAL
__RODATA(Flash2) const char serialnumber[3] = {0x11 , SER2, SER3};
#else
__RODATA(Flash2) const char serialnumber[3];
#endif
Of course, DO_LOCAL_SERIAL = FALSE for this (I have this in case I want to flash one with Multilink vs. Cyclone, set this to TRUE) - maybe this is the issue?
Stumppppppped!