You would want an absolute location, this should help -
http://www.cypress.com/documentation/application-notes/an89610-psoc-4-and-psoc-5lp-arm-cortex-code-optimization AN89610 - PSoC® 4 and PSoC 5LP ARM Cortex Code Optimization
Is this then what I need to do?...
Place this into my code...
uint16 SerialNum __attribute__ ((section (".SERIALNUM")));
MySerialNumber = SerialNum;
Then place this in linker...
build setting -> linker -> command line
BuildSetting -> Linker -> Command Line -> the custom flags
External programmer writes 2-byte sequential serial number into location0x30000 for each device when programming
and the device can access this number at run time.
I have not done this but sure looks like you could provide a little code in
target to prove this with a couple of test devices, eg. ability to display its
serial number in end application. Or a jumper that is tested on startup that
reveals serial code burned in.....
Would it be easier to place the serial code in an EEPROM location from my programmer? If so, what would be the actual address I would place into my programmer that would put the value into EEPROM location 0? Or does the compiler shift the memory locations allocated for EEPROM?
If you are talking about real EEProm as in PSoC5 devices you are free to choose the place for your serial number.
The em_EEProm as in PSoC4 devices resides in flash and is prone for being overwritten by code. In this case, choose the upper flash locations of your device as storage area.
I was originally aksing about 5LP, however it is the 4200 that I need to get the serial number into from my production programmer.
If I change the serial number back to a fixed const and then use my programmer (without serialization) the code runs fine. When I add this code and use the programmer to place the 2-byte serial number at location 0x1000, the program fails to work. (I selected 0x1000 based on example in documentation)
The code below is what I used and it does not appear to work. (Part is CY8C4245PVI-482)
uint16 SerialNum __attribute__ ((section(".SERIALNUMBER")));
I use the variable like this
buf = high_byte(SerialNum);
buf = lo_byte(SerialNum);
This is compiler directive -Wl,--section-start=.SERIALNUMBER=0x00001000
Attached address map.
Look at your .lst file, look for last code address, and place the address well above that still in flash area.
PSOC 4 Address Map.png 103.5 K
1 of 1 people found this helpful
This is an alternative, from PSOC Programmer user guide -
2.16 Using the Patch Image Option
To use the Patch Image option, select File > Patch Image or press [F12].
You can load a hex file and connect the Miniprog1 to the target devices. PSoC Programmer reads the Flash content on the
target device and compares it with the selected hex file. Then, the PSoC Programmer replaces the Flash blocks that differ.
This feature is useful to replace calibration data or a manufacturing number. See the PSoC Programmer COM User Guide
and code examples in the root installation folder for more information on writing unique applications to complete specific
I have the serialization working ok now