Emulated EEPROM Component

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

Moderator: ericb

Emulated EEPROM Component

Postby KennyMillar » Fri Sep 27, 2013 1:11 am

About a month or so ago I reported a fault with the Emulated EEPROM component whereby it would write to the wrong areas of flash, if the destination was not in array 0.
This was verified as a bug by Cypress and it'll be fixed in the next release of the component.

Now I have discovered a new bug in the same component.
It helps if you know a little about how the flash in PSoC3/5/5LP works, so forgive me for this little lesson...
The flash is stored in 'arrays' (Which I would have called 'banks') of 256 Rows. Each 'row' is 256 Bytes long. You must erase an entire row at a time before writing to it, and so if you wish to write to only part of a row you must first read the row into a buffer, erase the row, then write the new data to the correct place in the buffer and then write the entire row back again.

So given any address in flash you must calculate:
1. The array (or bank) number.
2. The row number within the array.
3. The offset within the row.

If the data you wish to store is longer than 1 row or happens to span across a row-row boundary then you must make 2 (or more) passes of the read-erase-write cycle.
This is all very normal for writing to flash. The Cypress libraries which have shipped with Creator have always had the methods for doing this in code.
The emulated eeprom component is nothing more than a small conveniece wrapper around existing code library calls.

A month or so ago I reported an error where the Array number is wrongly calculated, affecting everything except array-0.
Now I've discovered that the array number is also incorrectly calculated when the destination address is in the last row of an array.

It is very simple maths to break up any given address into array/row/offset. Yet the emulated eeprom component makes (at least) two very basic maths errors which have very serious consequences. It will overwrite code and configuration areas and cause your system to fail. If your system has a bootloader, then it can be overwritten (which happened in my case) and you will not be able to recover by re-flashing with a bootloader. You'll need to dig out your SWD or JTAG programmer and do a complete re-program. You can't do that on 1000 end-user sites!

Now, I understand that errors creep into code, but this should't really have been released, because even the most basic of tests would have revealed that the component fails at the edge-cases (writing to last row of flash) and normal use cases (writing to bank 1 or above). The wheels at Cypress are moving very slowly over this.

I reported this further fault to Cypress some time ago, but they have not replied. At the very least they need to put a notice on the 'start page' that the Emulated EEPROM component should not be used. There are serious consequences for using it and since it's not possible to know at design time if the area of flash you are using is in array 0 or uses the last row of an array, then it's not suitable for use. For safe use at the moment your destination address MUST be in array 0 and must NOT use row 255. Which limits you to the first 255 rows (0-254) of bank-0, and of course your program lives in bank-0!!!

Of course you could easily just write your own wrapper around the library calls. That's what I'll be doing.
KennyMillar
Cheese Wheel
Cheese Wheel
 
Posts: 60
Joined: Mon Jan 17, 2011 7:34 am

Re: Emulated EEPROM Component

Postby bobmarlowe » Fri Sep 27, 2013 1:48 am

Thank you, Kenny to point us to this issue, which did not (yet) come to my knowledge although I frequently used the emulated EEProm usermodule.
The reason could be that I used the mudule differently from your approach:
For some reasons (Ease of access, readability :mrgreen: and independence of memory layout) I declared a structure to describe my flash data and declared
a variable of that structure in flash (unsing the "const" - class) and (when amount of memory allowed) a similar variable in memory that was used to program the flash from.
So I did not have to care for the layout of "Blocks" in flash. Probably this was Cypress's test-environment which does not reveil any bug in flash-code at once.

I agree with you that Cypress ought to alert us users at least by applying a note in one of their forums which are frequently visited.


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

Re: Emulated EEPROM Component

Postby KennyMillar » Fri Sep 27, 2013 1:57 am

Hi Bob

I do exactly the same thing as you - the problem is that your 'const' structure in flash may just happen to live in array-1 (ie any address above 0x0000ffff) or it may just happen to occupy the last row of an array (an address from 0xnnnnnnF0 to 0xnnnnnnFF) and you would not know about it.

Worse still, it might work for a long time with no problem because it just happens to avoid these addresses, but then you make a small change anywhere in your code which pushes the address of your flash const array into the danger zone. Your program will misbehave (at best) or even die completely. It might lead you to make the wrong assumption about why it is not working. You might even think the hardware had failed (program refuses to boot for example).
KennyMillar
Cheese Wheel
Cheese Wheel
 
Posts: 60
Joined: Mon Jan 17, 2011 7:34 am

Re: Emulated EEPROM Component

Postby danadak » Fri Sep 27, 2013 3:06 am

Kenny, just a suggestion. PSOC 3.0 is close to release, maybe with a little
more attention called out to this we can get a near term fix. Can you post
this in the Cypress.com Creator forum, with links there to the threads here in
posocdeveloper.com ?

Maybe title "EEPROM component 2 BUGS affect BOOT applications",
something that catches the eye.

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: Emulated EEPROM Component

Postby bobmarlowe » Fri Sep 27, 2013 3:41 am

Or email directly to Robyn Weil (rbyn@cypress.com) together with an example of your code and a link to this thread. Date for releasing 3.0 is drawing near, so time is short...

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

Re: Emulated EEPROM Component

Postby KennyMillar » Fri Sep 27, 2013 3:52 am

bobmarlowe wrote:Or email directly to Robyn Weil (rbyn@cypress.com) together with an example of your code and a link to this thread. Date for releasing 3.0 is drawing near, so time is short...

Bob


Yes I will do that, but I Cypress already know about this, and already have two sample projects I have sent them which demonstrate the problem.
I was told that 'Manesh' was working on it, but have not heard anything for a while.
KennyMillar
Cheese Wheel
Cheese Wheel
 
Posts: 60
Joined: Mon Jan 17, 2011 7:34 am

Re: Emulated EEPROM Component

Postby bobmarlowe » Fri Sep 27, 2013 5:07 am

There is a difference obviously between Cypress engineers maniging MyCases and the department creating Creator 3.0 which leader is Robyn Weil. Give it a try.

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

Re: Emulated EEPROM Component

Postby KennyMillar » Fri Sep 27, 2013 5:10 am

bobmarlowe wrote:There is a difference obviously between Cypress engineers maniging MyCases and the department creating Creator 3.0 which leader is Robyn Weil. Give it a try.

Bob

Thanks Bob,

I have emailed Robyn :-)

-Kenny
KennyMillar
Cheese Wheel
Cheese Wheel
 
Posts: 60
Joined: Mon Jan 17, 2011 7:34 am

Re: Emulated EEPROM Component

Postby danadak » Fri Sep 27, 2013 3:35 pm

Looks like we missed Creator 3.0 release cycle -

http://www.cypress.com/?app=forum&id=2492&rID=86164&message=posted

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


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

Who is online

Users browsing this forum: No registered users and 1 guest

cron