The following APIs, imported within bleappfwu.h, can be used to write/read/erase SFLASH:
/// Reads len bytes from readFrom into buf (a caller owned buffer).
/// Bitwise OR in INDIRECT_MEM_MAP_SF the offset to read. For ex.
/// if you want to read from address 0x100, readFrom = (INDIRECT_MEM_MAP_SF | 0x100)
BOOL32 readMem(UINT8* buf, UINT32 readFrom, INT32 len);
/// Writes len bytes to writeTo from buf (a caller owned buffer).
/// Bitwise OR in INDIRECT_MEM_MAP_SF the offset to write. For ex.
/// if you want to write to address 0x100, writeTo = (INDIRECT_MEM_MAP_SF | 0x100)
BOOL32 writeMem(const UINT8* buf, UINT32 writeTo, INT32 len);
/// Erases len bytes starting from eraseAddr.
/// Bitwise OR in INDIRECT_MEM_MAP_SF the address to erase. For ex.
/// if you want to erase 4K starting from 0x1000, eraseAddr = (INDIRECT_MEM_MAP_SF | 0x1000).
/// Note that len will be rounded up to a sector boundary.
BOOL32 eraseMem(UINT32 eraseAddr, INT32 len);
Please refer to WICED Smart BCM92073X EEPROM and SFLASH Layout for further information on memory allocation/layout when designing your OTA.
Thanks for the your responses.
Now am able to access the entire flash (read/write/erase). With the APIs I can access above 64KB (Tested only with 128KB sflash).
One other issue what I can observe is that the static segment data remains unchanged after API call bleappfwu_eraseMem().
Reading the erased area with API bleappfwu_readMem() shows the data remains unchanged.
Does there need any waiting time after flash erase?
Thanks and regards
There shouldn't be any need for a delay between erasing and writing SFLASH. In my test app I used the two API calls back to back with no problems.
Are you writing to SFLASH after booting from it? Or booting from EEPROM and writing SFLASH? It's possible that some sections are not accessible if you've booted from SFLASH.
I have booted from SFLASH and try to modify the same active Static Segment. But the same active static segment (40 bytes from 0x0000) is found not erased. The Same time i can see that the other Static segment got erased and written as expected.
I recommend testing this after booting from EEPROM. If it works after booting from EEPROM, you're likely being blocked by something internal to the API that restricts you from overwriting the source from which it booted.
I cannot be sure whether or not this can be worked around. One surefire way would be to write your own driver for the SFLASH. Or if you were able to write the SS after booting from EEPROM, you could always have both attached to your chip and OTA upgrade back and forth between EEPROM and SFLASH and dynamically switch each on and off during boot using a switch.