This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/CC1310: CC1310 writing into flash potential problem

Part Number: CC1310

Tool/software: TI-RTOS

Hi,

We have sensors based on cc1310 and we have implemented a custom OTA firmware update solution.

We have done OTA firmware update for more than a year for our sensors. Most of the time is working, but there were some moments when the sensors either were stuck(not responding) or performed a reset after the first OTA firmware packet received.

I know  the write/read flash function are located in ROM. My question is: Is any fault detection in the read/write flash procedure? What would be the action when a fault was detected? Or what would cause the CC1310 to be stuck or doing reset?

Thank you and regards,

Milorad

  • You cannot read flash during flash write, so you'd have to disable all interrupts during write, or move your ISRs (and every function they call) into ram.

    Also ensure that you disable the flash cache first.

    I use the following when writing to flash in my application:

    // from 


    #define FLASH_PAGE_SIZE  4096U
    #define FLASH_START(page) \ int32_t result = 0; \ /* Disable the cache */ \ VIMSModeSet(VIMS_BASE, VIMS_MODE_DISABLED); \ while (VIMSModeGet(VIMS_BASE) != VIMS_MODE_DISABLED); \ \ /* Make sure that sector isn't write protected. */ \ result = FlashProtectionGet((uint32_t) (page)); \ if (result == FLASH_WRITE_PROTECT) \ { \ VIMSModeSet(VIMS_BASE, VIMS_MODE_ENABLED); \ return -1; \ } \ \ /* Disable all interrupts when accessing the flash */ \ CPUcpsid(); #define FLASH_END() \ CPUcpsie(); \ \ /* Re-enable the cache */ \ VIMSModeSet(VIMS_BASE, VIMS_MODE_ENABLED); \ \ return result; int FlashStorage_Erase(FlashPage* page) { FLASH_START(page); /* Erase a flash Page */ result = FlashSectorErase((uint32_t) page); FLASH_END(); } int FlashStorage_Write(uint8_t* buffer, unsigned bufferLength, void* location) { FLASH_START(((uintptr_t) location) & (~(FLASH_PAGE_SIZE - 1))); for (uint8_t i = 0; i < bufferLength; i += 4) { /* Write to flash */ result = FlashProgram(&buffer[i], ((uint32_t) location) + i, 4); if (result != FAPI_STATUS_SUCCESS) break; } FLASH_END(); }

    Also remember that you cannot write a 1 into flash - you can only erase an entire block, or change 1s to 0s.

  • Hi Michael,

    I've analyzed your solution. I didn't put disable/enable interrupt protection. But even with that in place still I have issues.
    I have some question:
    1. Is it necessary to use only 4 bytes for each FlashProgram procedure?
    2. Do the ROM FlashProgram/Erase procedure have disable/enable protection?
    3. What would cause a RESET during flash write?

    Regards,
    Milorad
  • 1. No idea, that's how it was in the linked example. The documentation for FlashProgram doesn't specify a maximum write size but does mention an error code for write size being too large, with no discussion on what conditions might cause the function to return that error code.

    2. Not sure, see the documentation here: software-dl.ti.com/.../group__flash__api.html

    3. If any ISR fires (or anything else that causes a read from flash, eg radio picking up a const command) while the flash is being written, you'll have a hardware fault. Also there can be brownouts or external resets which will put your flash into an unknown state