- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
In PSoC4 we have to use emulated EEPROM component to use flash portion as EEPROM area. One limitation of the Em_EEPROM component of PSoC4 is, it automatically places EEPROM space in flash. This location may changes with different build cycle. This may create an tricky issue during security protection of flash (usually employed for IP protection of your firmware).
As you have to get the address of flash area allocated after a new build and change Flash Security file flags appropriately to allow Em_EEPROM to work within otherwise protected flash area. This is a tedious task and not intuitive as PSoC1 EEPOM component.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is a FAQ answer here: http://www.cypress.com/?id=4&rID=57109 , which leads to you here http://www.cypress.com/?rid=91945 for the PSoC5LP / PSoC4 (see page 30).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
HLI,
Thanks for pointing AN89610.
I have got the initial idea of modifying linker script file after reading AN89610 itself.
After re-reading AN89610, (specially around page 23), My another work around solution is, copy generated linker script file, modify it to add custom EEPROM section at needed address. Rename the linker file. Store it in project source root folder and add it back to project. As mentioned in AN89610 :
"Note Linker script files are automatically generated by
PSoC Creator at project build time, and changes that you
make to those files may be overwritten on the next build.
You can instruct PSoC Creator to use a custom script file,
using the PSoC Creator menu Project > Build Settings >
Linker > General > Custom Linker Script.
If you use a custom linker script file, it is a best practice to
add it to the project (menu Project > Existing Item…) and
save it in the project folder."
This solves issue of over written linker script file.
But I am not a GCC expert. And reading GCC documentation and creating fully custom linker script file is not easy. I would request experienced people to validate my solution, though it is working with this project.
Regards,
Vinay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oh now I see the mistake I made 😞
The solution I thought was so neat only works for the MDK compiler, not for gcc. There the one you are looking at seems to be the only solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oh, Google gave me a better answer after looking around. Its possible to set symbol addresses via the command line, see e.g. https://stackoverflow.com/questions/495262/linking-symbols-to-fixed-addresses-on-linux
So you can use e.g.
extern struct FooBar foobar;
in your code, the then call gcc with
gcc -Wl,--defsym,foobar=0x76543210 file.c
Or you use a so-called symbol file, storing the addresses of the variables you need placed (see the same link). Both should work without modifying the linker file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
HLI,
Thanks, for giving a nice tip.
I will try it out and post my result to complete the solution.
Regards,
Vinay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
--defsym defines sysmbol as specified address value.
But linker does not allocate the eeprom flash locations at that address.
--section commands works well.
example as:
-Wl,--section-start=.EEPROMDATA=0x00007f80
I am repeating the solution of defining Em_EEPROM allocation at user specified location on flash memory with out modifying
linker script file as below:
1) In global section define a variable to store emulated EEPROM data in flash as,
static const uint8 eepStrg[6] __attribute__ ((section (".EEPROMDATA"))) = {0,0,0,0,0,0} ;
Here, const ensures that variable will be allocated in ROM area.
section directive will create a separate section name to be allocated.
Note, it is must to initialize the EEPROM area with some data, for Em_EEPROM component to be allocated properly.
2) specify custom linker flag on command line as
-Wl,--section-start=.EEPROMDATA=0x00007f80
(Address 0x00007f80 is selected since it is last block of Flash - but can be other address not used by your firmware code.
)
Go to Project->Build Settings->ARM GCC x.x.x->Linker->Command Line->Custom Flags->add -Wl,--section-
start=.EEPROMDATA=0x00007f80
You can verify .EEPROMDATA section allocated at 0x7f70 flash location in project's map file.
Also attaching a sample project for the same.
You can step through the code using MiniProg3 on a CY8CKit-049-42xx
Hope this may be useful towards IP protecting flash while keeping Em_EEPROM area seperate as unproteced block using Flash
Security file.
Regards,
Vinay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Glad you got this working. And thanks for reporting back!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello
Can someone please explain the EM_EEPROM to me. All the exemples work well untill I unpleg and replug my dev kit. The data I saved is then lost , yet the datasheet states
"The Emulated EEPROM component should be used when:
Data needs to be preserved across power cycles, and the target device does not have
dedicated EEPROM memory."
but I loose all my data at each power cycle.
Help please
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Some questions -
1) What dev kit are you using ?
2) How are you powering the devkit ?
3) How are you debugging, what interface are you using ?
You are not reprogramming the part and expecting the data to still
reside ? Like a build / program / debug cycle ?
Some considerations -
Regards, Dana.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>> Can someone please explain the EM_EEPROM to me. All the exemples work well untill I unpleg and replug my dev kit. The >> data I saved is then lost , yet the datasheet states
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@it
Can you post your actual complete project, so that we all can have a look at all of your settings? To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Problem solved, Thanks all for your pointers. I forgot that when you debug it reprograms the whole device as hinted by Dana.
new to PSOC and loving it so far.