This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
FLASH API/driver V2 erase operation
- From: Iris Lindner <ilindner at logopak dot de>
- To: ecos-discuss at ecos dot sourceware dot org
- Date: Wed, 14 Oct 2009 10:01:39 +0200
- Subject: [ECOS] FLASH API/driver V2 erase operation
Hi everybody,
to solve some conflicts between interrupts and flash operations I try to
switch from version 1 to version 2 FLASH API and device driver
(packages/devs/flash/amd/am29xxxxxv2) - and found some new problems.
Finally I was able to read from flash properly but erase operation can't be
done. Digging deeper into driver routines I found out that V2 driver writes
the following erase sequence (in devs/flash/amd/am29xxxxxv2/current/src/):
------------>8---------------------------
static int AM29_FNNAME(am29_hw_erase)(volatile AM29_TYPE* addr)
{
[...]
// Start the erase operation
addr[AM29_OFFSET_COMMAND] = AM29_COMMAND_SETUP1;
HAL_MEMORY_BARRIER();
addr[AM29_OFFSET_COMMAND2] = AM29_COMMAND_SETUP2;
HAL_MEMORY_BARRIER();
addr[AM29_OFFSET_COMMAND] = AM29_COMMAND_ERASE;
HAL_MEMORY_BARRIER();
addr[AM29_OFFSET_COMMAND] = AM29_COMMAND_SETUP1;
HAL_MEMORY_BARRIER();
addr[AM29_OFFSET_COMMAND2] = AM29_COMMAND_SETUP2;
HAL_MEMORY_BARRIER();
addr[AM29_OFFSET_COMMAND] = AM29_COMMAND_ERASE_SECTOR;
HAL_MEMORY_BARRIER();
[...]
------------>8---------------------------
As far as I understood the offsets are always added to the actual block
address to be erased (addr). But in the chip documentation (we use a Spansion
S29GL256P) it says that offsets have to be added to base address of flash
range.
Accordingly I found in V1 driver erase routine:
------------>8---------------------------
int flash_erase_block(void* block, unsigned int size)
{
[...]
f_s1 = FLASH_P2V(BANK + FLASH_Setup_Addr1);
f_s2 = FLASH_P2V(BANK + FLASH_Setup_Addr2);
[...]
// Send erase block command - six step sequence
*f_s1 = FLASH_Setup_Code1;
*f_s2 = FLASH_Setup_Code2;
*f_s1 = FLASH_Setup_Erase;
*f_s1 = FLASH_Setup_Code1;
*f_s2 = FLASH_Setup_Code2;
*b_v = FLASH_Block_Erase;
------------>8---------------------------
...where bank is the actual flash base address and b_v the address of the
block to be erased.
Is the version 2 driver no longer suitable for a Spansion S29GL256P? Or do I
have to add something?
How could I switch back to the old driver with V2 API? (Enabling "Provide the
legacy user API" in eCos config tool seems not being sufficient.)
Thanks again in advance for any comment!
Kind regards,
Iris
--
Iris Lindner
Software Development
Industrial Print and Apply Labelling
www.Logopak.com
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss