Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
CrDe_3090586
Level 1
Level 1
5 sign-ins First like received First reply posted

I'm trying to initialize a new sflash chip on an ISM43340. I was able to determine how to add the flash chip and size to the Wiced configuration. However, determining how to initialize the sflash chip took several days of digging.

=== Solution ?? ===
Eventually, the line below was added to initialize the sflash when running the make: snip.sflash_write-.
- Is this the correct change? Is this the correct placement?

../43xxx_Wi-Fi/platforms/ISM43340_M4G_L44/ISM43340_M4G_L44.mk
RESOURCES_LOCATION ?= RESOURCES_IN_WICEDFS

=== Diagnostic History ===
The first attempt was to run snip.ota_fr-ISM43340_M4G_L44 because that's what the documentation suggests to use to flash a new OTA app file. However, that failed because the wiced_apps_common.c / wiced_apps_get_size code isn't designed to detect an uninitialized sflash chip. 

When building the sflash_write, the filesystem.bin file wasn't being generated nor was the sflash being initialized. See below for the missing messages.  It took a couple of days to root cause the problem and find a possible solution. BTW, this sflash init worked fine out of the box for the eval board: CYW943907AEVAL1F, but not for the ISM43340.

===wiced_apps_common.c / wiced_apps_get_size issue ===
The wiced_apps_get_size() code essentially went into a nearly infinite loop when run with the uninitialized sflash chip.  It seems feasible to add a check. The chip being used was (MX25U1633FM2I) apparently factory initialized to all 1s, because the error eventually found in debugging that (wiced_apps_get_size) method was reading all 1s for the app_header.count field. That is, under the assumption that all sflash chips are either factory initialized to all 1s or all zeros.... perhaps a code check would be helpful.

===wiced_apps_common.c / wiced_apps_get_size code suggested change ===

wiced_result_t wiced_apps_get_size( const image_location_t* app_header_location, uint32_t* size ) {
...

   WICED_VERIFY( init_sflash( &sflash_handle, PLATFORM_SFLASH_PERIPHERAL_ID, ...));
    WICED_VERIFY( sflash_read( &sflash_handle, app_header_location->detail.external_fixed.location, .......));
    // code change here suggested checking for 255 or 0, which will be an error 99.999999% of the time
    if (app_header.count > 254 || app_header.count == 0) return ERR_CODE_SFLASH_NOT_INITIALIZED; 

=== The messages below would NOT appear in the make/build log until after adding the make file line as mentioned above
     (RESOURCES_LOCATION ?= RESOURCES_IN_WICEDFS) ==== 

16:20:54.367 -> NO Support Range Erase Command!!
16:21:05.562 -> Waiting for command
16:21:05.562 -> Received command: POST_WRITE_VERIFY WRITE_ERASE_IF_NEEDED
16:21:05.562 -> Destination address: 4096
16:21:05.562 -> Size: 16384
16:21:05.562 -> Initialising serial flash
16:21:05.598 -> Done initialising
16:21:05.598 ->
16:21:05.598 ->
16:21:05.598 -> SFLASH Device ID1 ( 0xc22015)
16:21:05.598 -> SFLASH Size1 ( 0x200000)
16:21:05.598 ->
16:21:05.598 -> Verifying existing data!
16:21:05.635 -> Verifying after write
16:21:05.742 -> Going back to idle
16:21:05.742 -> Waiting for command
16:21:06.119 -> Received command: POST_WRITE_VERIFY WRITE_ERASE_IF_NEEDED
16:21:06.119 -> Destination address: 20480
16:21:06.152 -> Size: 16384
16:21:06.152 -> Initialising serial flash
16:21:06.152 -> Done initialising
16:21:06.152 ->............

 

0 Likes
1 Solution
GauravS_31
Moderator
Moderator
Moderator
10 questions asked 250 solutions authored 250 sign-ins

Sorry for the late reply. Yes, RESOURCES_LOCATION ?= RESOURCES_IN_WICEDFS in your platform makefile is required to generate filesystem.bin, which will be loaded in external sflash. Also the sflash part id should be listed in libraries/drivers/spi_flash/spi_flash_internal.h. This will be required while reading the sflash id. From the logs, i see that the chip id is 0xc22015 which corresponds to MX25L1606E in spi_flash_internal.h. If that is not the correct chip id for your sflash part, kindly refer to this link https://community.cypress.com/t5/Resource-Library/SFLASH-support-addition-in-WICED/ta-p/246316 to add support for this part.

View solution in original post

0 Likes
1 Reply
GauravS_31
Moderator
Moderator
Moderator
10 questions asked 250 solutions authored 250 sign-ins

Sorry for the late reply. Yes, RESOURCES_LOCATION ?= RESOURCES_IN_WICEDFS in your platform makefile is required to generate filesystem.bin, which will be loaded in external sflash. Also the sflash part id should be listed in libraries/drivers/spi_flash/spi_flash_internal.h. This will be required while reading the sflash id. From the logs, i see that the chip id is 0xc22015 which corresponds to MX25L1606E in spi_flash_internal.h. If that is not the correct chip id for your sflash part, kindly refer to this link https://community.cypress.com/t5/Resource-Library/SFLASH-support-addition-in-WICED/ta-p/246316 to add support for this part.

0 Likes