EEPROM variable declaition and Initialisation

Discussion of the PSoC Creator Integrated Development Environment for PSoC3 & PSoC5 devices.

Moderator: ericb

EEPROM variable declaition and Initialisation

Postby yogeshys » Sat Apr 13, 2013 4:27 am

Hi All,

I am new to the PSoC world. Please correct my mistakes if any. I am trying to initialize the EEPROM(0x40008000 - 0x400087FF) at the start up.
So, following is the code snippet for the same,

Code: Select all
#pragma abs_address: 0x40008000
uint8 test = 0xAA;
#pragma end_abs_address


After i clean and build the project, build will be successfully completed. But the address of the test variable will be something else in map file,
it appears in .rodata section, as shown below,

Code: Select all
.rodata         0x00001844       0xa4
 *(.rodata .rodata.* .gnu.linkonce.r.*)
 .rodata        0x00001844       0x14 .\ARM_GCC_441\Debug\main.o
                0x00001854                test1


Please help me figure out the problem ,like, why isn't test variable given a proper address in map file.

Any help is highly appreciated,

Thanks in advance,
Yogesh
yogeshys
Newbie
Newbie
 
Posts: 5
Joined: Wed Apr 03, 2013 3:30 am

Re: EEPROM variable declaition and Initialisation

Postby danadak » Sat Apr 13, 2013 2:45 pm

Field Application Engineer
KB1RHB Mostly listen :)
Semi Retired
User avatar
danadak
The Big Cheese
The Big Cheese
 
Posts: 2008
Joined: Thu Dec 27, 2007 8:42 am
Location: New Hampshire

Re: EEPROM variable declaition and Initialisation

Postby bobmarlowe » Sun Apr 14, 2013 1:28 am

You have to use the APIs to program eeprom, a simple assign to an eeprom address will not work. Please study the Datasheet, page 2 shows the pointer to access EEPRom for read and there is a list of APIs for programming rows of data.

Bob
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany

Re: EEPROM variable declaition and Initialisation

Postby yogeshys » Sun Apr 14, 2013 10:06 pm



Hi all,

Thanks for the reply. Dana, can you please explain more on how can i achive initializing the EEPROM by the modified bootloader method.
Also, How to merge the eeprom data into the application HEX file. SO that while flashing the target, EEPROM section also can be updated?

Thanks in advance,
Yogesh
yogeshys
Newbie
Newbie
 
Posts: 5
Joined: Wed Apr 03, 2013 3:30 am

Re: EEPROM variable declaition and Initialisation

Postby danadak » Mon Apr 15, 2013 3:52 am

A bootloader is a kernel of code programmed into a processor, that is used
primarily for loading and programming the main application. So you could
modify a boot loader to handle the EEPROM initialize task.

http://www.cypress.com/?rID=50230

Regards, Dana.
Field Application Engineer
KB1RHB Mostly listen :)
Semi Retired
User avatar
danadak
The Big Cheese
The Big Cheese
 
Posts: 2008
Joined: Thu Dec 27, 2007 8:42 am
Location: New Hampshire

Re: EEPROM variable declaition and Initialisation

Postby yogeshys » Mon Apr 15, 2013 8:25 pm

Thank you Dana.

I still have few queries,
1. Should I place my application code in the same bootloader workspace?
2. Isit like,
a. Bootloader should be flashed using the bootloader HOST application
b. Bootloadable project should contain the main application. But we cannot debug this kind of project?
3. Any advantage of using the modified bootloader method over using the standard EEPROM APIs to initialise the same.

Thanks in advance,
Yogesh
yogeshys
Newbie
Newbie
 
Posts: 5
Joined: Wed Apr 03, 2013 3:30 am

Re: EEPROM variable declaition and Initialisation

Postby danadak » Tue Apr 16, 2013 2:04 am

These may help -

http://www.cypress.com/?rID=41002

http://www.cypress.com/?rID=57561

http://www.cypress.com/?rID=50230

1. Should I place my application code in the same bootloader workspace?


Bootloaders come in many varieties, ones that run load kernel from FLASH into SRAM, then
run out of SRAM, allowing kernel to be overwritten, to ones that always maintain the kernel
for future field upgrades. You could place init code in either kernel or application workspace.
My instinct tells me keep the kernel intact, and inits for EEPROM in application workspace.
But I am no expert on BLs.

3. Any advantage of using the modified bootloader method over using the standard EEPROM APIs to initialise the same.


Not sure I can answer this for you, other than to say bootloader allows field upgrade capability,
at the expense of some FLASH.

b. Bootloadable project should contain the main application. But we cannot debug this kind of project?


Ap Notes discuss debugging.

Regards, Dana.
Field Application Engineer
KB1RHB Mostly listen :)
Semi Retired
User avatar
danadak
The Big Cheese
The Big Cheese
 
Posts: 2008
Joined: Thu Dec 27, 2007 8:42 am
Location: New Hampshire

Re: EEPROM variable declaition and Initialisation

Postby yogeshys » Thu Apr 18, 2013 7:14 pm

Many thanks Dana.

I am successfull in modifying the BL with the EEPROM init. Thanks for your inputs.
Although I am still working on the alternative for the same by modifying the linker file(.ld).

Please let me know if you have any inputs regarding modifying the ld file to
1. Create a section for EEPROM.
2. Create a new output section and declare the .o file name in which the variables are initialised with the values which are supposed tobe written into the EEPROM.

E.g.:
eeprom (rwx) : ORIGIN = 0x40008000, LENGTH = 0x800
output :
{
sample.o
} >eeprom


Thanks and Regards,
Yogesh
yogeshys
Newbie
Newbie
 
Posts: 5
Joined: Wed Apr 03, 2013 3:30 am

Re: EEPROM variable declaition and Initialisation

Postby danadak » Fri Apr 19, 2013 4:16 am

yogeshys, I am not very knowledgeable on GCC Linker, maybe Bob Marlowe
can tackle this question. You could send him a message on this forum, and
point him to this thread.

http://www.psocdeveloper.com/forums/memberlist.php?mode=viewprofile&u=7333


Regards, Dana.
Field Application Engineer
KB1RHB Mostly listen :)
Semi Retired
User avatar
danadak
The Big Cheese
The Big Cheese
 
Posts: 2008
Joined: Thu Dec 27, 2007 8:42 am
Location: New Hampshire

Re: EEPROM variable declaition and Initialisation

Postby bobmarlowe » Fri Apr 19, 2013 4:41 am

I am regularily watching every thread in this forum and so did I read all posts of this one. When I'm not able to talk about a subject I try to keep my mouth shut.

Regarding your needs: I suspect that the EEProm area is seen as a device when written to, so it might be not possible to have the eeprom area pre-set to given values.
I think a technical case could clear that.

When it is not possible there are only a few ways left:

1)Setting initial EEProm-data programatically
2)Programming the EEProm area out of flash.
3)Programming the EEProm with data from a communication interface. This looks a bit like the Boot-Loader solution.

Programming effort 1- lowest, 3 highest
elegance and universality 3 highest 1 lowest

so I would vote at first for number 2.

Bob
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany

Re: EEPROM variable declaition and Initialisation

Postby danadak » Fri Apr 19, 2013 6:41 am

To post a tech case at -

www.cypress.com
“Support”
“Technical Support”
“Create a Case”

Regards, Dana.
Field Application Engineer
KB1RHB Mostly listen :)
Semi Retired
User avatar
danadak
The Big Cheese
The Big Cheese
 
Posts: 2008
Joined: Thu Dec 27, 2007 8:42 am
Location: New Hampshire

Re: EEPROM variable declaition and Initialisation

Postby yogeshys » Fri Apr 19, 2013 7:02 am

Thank you bobmarlowe and dana.

I have already created a case,

http://secure.cypress.com/myaccount/?id ... 2049455846

The option 2 posted by bobmarlowe seems tobe a wise option to go ahead with. Although i have to make a bit of research on it,
beeing a wise option, I will try working on the same.

Again many thanks to both of you senior members.


Thanks and Regards,
Yogesh
yogeshys
Newbie
Newbie
 
Posts: 5
Joined: Wed Apr 03, 2013 3:30 am

Re: EEPROM variable declaition and Initialisation

Postby bobmarlowe » Fri Apr 19, 2013 7:07 am

You are always welcome!

Bob
User avatar
bobmarlowe
The Big Cheese
The Big Cheese
 
Posts: 1490
Joined: Thu Oct 06, 2011 2:03 am
Location: Germany


Return to “%s” PSoC Creator (PSoC3 & PSoC5 IDE)

Who is online

Users browsing this forum: No registered users and 1 guest