CC3235SF: CC3235SF program image auto-deletion

Part Number: CC3235SF


I have a CC3235SF device. It had been working in the field for a week. Then, communication with the device was lost. The user LED flashes once every time the device is turned on. When I unplugged the device and plugged it back in, I noticed that this LED was not on.
Later, when I connected the device via unpluggable, I noticed that the program image had been deleted. It said 0KB. What is the reason for this? What causes this? Why does the program image auto-delete?

  • Hi Mehmet,

    Programs don't normally delete themselves. This is likely either:

    • A catastrophic memory failure
    • A security feature triggering (intentional wipe)
    • File system corruption making the image unreadable

    Based on your description with the CC3235SF device, this appears to be a classic case of flash memory corruption or failure. Here are the most likely explanations:

    1. Power-related issues:

      • Unstable power supply or sudden power loss during a critical write operation
    2. Flash wear-out (maybe unlikely after a week, but worth considering):

      • The CC3235SF uses internal flash memory that has limited write cycles
      • If your application frequently writes to non-volatile storage, it may have exhausted cell endurance
    3. Hardware watchdog reset:

      • The CC3235SF has security features that can trigger memory wipes if certain conditions are detected
      • Repeated crashes or lockups might have triggered a factory reset condition
    4. File system corruption:

      • The SimpleLink file system may have become corrupted, making the program image inaccessible
    5. MCU secure boot verification failure:

      • If secure boot is enabled, a verification failure could prevent the application from loading
      • This can appear as if the program is deleted when it's actually being rejected

    To prevent this in the future, consider implementing power monitoring, reducing write cycles to flash, and ensuring proper error handling in your application.

  • 1-) I'm creating the following blocks and running the code. I'm writing to flash during STA/AP mode transitions, and I'm reading the saved Wi-Fi information at every startup. I'm not interfering with the flash storage where the program is stored. Do you think the program image file is being deleted or damaged at this point?

    int fs_writeFile(const char *fileName, const void *data, uint32_t length)
    {
    _i32 fileHandle;
    _u32 maxFileSize = length;
    _u32 token = 0;
    int status = 0;

    // Dosya oluşturulmamışsa oluştur, varsa üstüne yaz
    fileHandle = sl_FsOpen((unsigned char *)fileName,
    SL_FS_CREATE | SL_FS_OVERWRITE | SL_FS_CREATE_MAX_SIZE(maxFileSize),
    &token);

    if (fileHandle < 0) {
    return fileHandle; // Hata kodunu döndür
    }

    // Dosyaya veri yaz
    status = sl_FsWrite(fileHandle, 0, (_u8 *)data, length);
    if (status < 0) {
    sl_FsClose(fileHandle, 0, (unsigned char *)"A", 1); // Yazma hatası varsa abort ile kapat
    return status;
    }

    // Dosyayı düzgün şekilde kapat
    status = sl_FsClose(fileHandle, 0, 0, 0);
    return status;
    }

    /**
    * @brief Belirtilen dosyadan veri okur (tüm içeriği buffer'a kopyalar).
    *
    * @param[in] fileName Okunacak dosya adı (ör: "/wifi_config.txt")
    * @param[out] buffer Okunan verinin kopyalanacağı buffer
    * @param[in] length Okunacak maksimum byte sayısı (buffer boyutu)
    * @return 0: Başarılı, <0: Hata kodu (sl_Fs* fonksiyonlarından döner)
    */
    int fs_readFile(const char *fileName, void *buffer, uint32_t length)
    {
    _i32 fileHandle;
    _u32 token = 0;
    int status = 0;

    // Dosyayı oku modunda aç
    fileHandle = sl_FsOpen((unsigned char *)fileName, SL_FS_READ, &token);
    if (fileHandle < 0) {
    return fileHandle; // Hata kodunu döndür (ör: dosya yok)
    }

    // Dosyadan oku
    status = sl_FsRead(fileHandle, 0, (_u8 *)buffer, length);
    if (status < 0) {
    sl_FsClose(fileHandle, 0, (unsigned char *)"A", 1); // Okuma hatası varsa abort ile kapat
    return status;
    }

    // Dosyayı düzgün şekilde kapat
    status = sl_FsClose(fileHandle, 0, 0, 0);
    return status;
    }

    /**
    * @brief Eğer dosya mevcut değilse belirtilen boyutta boş bir dosya oluşturur.
    *
    * @param[in] fileName Kontrol edilecek/oluşturulacak dosya adı
    * @param[in] length Oluşturulacak dosyanın maksimum boyutu
    */
    void ensureFileExists(const char *fileName, uint32_t length) {
    _i32 fileHandle;
    _u32 token = 0;
    // Dosya var mı kontrol et
    fileHandle = sl_FsOpen((unsigned char *)fileName, SL_FS_READ, &token);
    if (fileHandle < 0) {
    // Dosya yoksa, boş şekilde oluştur
    fileHandle = sl_FsOpen((unsigned char *)fileName,
    SL_FS_CREATE | SL_FS_OVERWRITE | SL_FS_CREATE_MAX_SIZE(length),
    &token);
    if (fileHandle >= 0) {
    sl_FsClose(fileHandle, 0, 0, 0); // Oluşturulan dosyayı hemen kapat
    }
    } else {
    // Dosya varsa kapat
    sl_FsClose(fileHandle, 0, 0, 0);
    }
    }

    // --------------------------------------------------------------------------
    // Test fonksiyonu: Dosya yazma/okuma örneği (debug amaçlı)
    // --------------------------------------------------------------------------
    char myData[] = "deneme!";
    char readBuffer[64] = {0};

    /**
    * @brief Dosya sistemi ile yazma/okuma işlemini test eder. (Yaz → Oku → Logla)
    */
    void flashFileTest() {
    ensureFileExists("wifi_config.txt", sizeof(readBuffer)); // Dosya mevcut değilse oluştur

    // Yaz
    int writeRes = fs_writeFile("wifi_config.txt", myData, strlen(myData));
    if (writeRes == 0) {
    Display_printf(display, 0, 0, "Dosya başarıyla yazıldı.");
    } else {
    Display_printf(display, 0, 0, "Yazma hatası: %d", writeRes);
    }

    // Oku
    memset(readBuffer, 0, sizeof(readBuffer));
    int readRes = fs_readFile("wifi_config.txt", readBuffer, sizeof(readBuffer) - 1);
    if (readRes == 0) {
    Display_printf(display, 0, 0, "Okunan veri: %s", readBuffer);
    } else {
    Display_printf(display, 0, 0, "Okuma hatası: %d", readRes);
    }
    }

    /**
    * @brief Wi-Fi konfigürasyonunu (SSID, password, security, username) tek satır halinde dosyaya kaydeder.
    *
    * @param[in] ssid Wi-Fi SSID
    * @param[in] password Wi-Fi password
    * @param[in] security Güvenlik tipi (ör: "2" veya string olarak)
    * @param[in] username (isteğe bağlı) Kullanıcı adı (Enterprise için)
    * @return 0: Başarılı, <0: Hata kodu
    */
    int saveWifiConfig(const char *ssid, const char *password, const char *security, const char *username) {
    char buffer[256] = {0};
    snprintf(buffer, sizeof(buffer), "%s|%s|%s|%s", ssid, password, security, username); // Tüm alanları | ile birleştir
    return fs_writeFile("wifi_config.txt", buffer, strlen(buffer));
    }

    /**
    * @brief Dosyadan Wi-Fi konfigürasyonunu okur ve dört ayrı alana böler.
    *
    * @param[out] ssid Okunan SSID (buffer, min 64 byte)
    * @param[out] password Okunan password (buffer, min 64 byte)
    * @param[out] security Okunan security (buffer, min 16 byte)
    * @param[out] username Okunan username (buffer, min 32 byte)
    * @return 0: Başarılı, <0: Hata (okuma veya parse hatası)
    */
    int loadWifiConfig(char *ssid, char *password, char *security, char *username) {
    char buffer[256] = {0};
    if (fs_readFile("wifi_config.txt", buffer, sizeof(buffer)-1) != 0)
    return -1;

    // Dosya satırını | ile parçala ve sırayla alanlara kopyala
    char *ptr = strtok(buffer, "|");
    if (ptr) strncpy(ssid, ptr, 63); else return -2;
    ptr = strtok(NULL, "|");
    if (ptr) strncpy(password, ptr, 63); else return -2;
    ptr = strtok(NULL, "|");
    if (ptr) strncpy(security, ptr, 15); else return -2;
    ptr = strtok(NULL, "|");
    if (ptr) strncpy(username, ptr, 31); else username[0] = 0; // Kullanıcı adı olmayabilir

    return 0;
    }

    The device calls this every time it boots. // Reading the Wi-Fi configuration file after sl_Start
    ensureFileExists("wifi_config.txt", 256); // Create the file if it doesn't exist

    int configLoadStatus = loadWifiConfig(ssid, password, security, username);

    saveCounterValue(1);
    Task_sleep(1000);
    apmodeaktif=0;
    deviceReset(); This way, after changing the mode, I save the value and reset the system.


    2-) MCU secure boot verification error: What do you mean? Where can I check this setting in CCS Studio?
    3-) File system corruption: What could be causing this? Under what circumstances?
    4-) My field devices have an SOP value of 010. Could this be why they're being deleted?

    Additional information: When I re-enable the devices, they work fine. However, even if I unplug and replug the device without re-enrolling, it doesn't work and doesn't respond at all.

  • Hi,

    How your code was uploaded into device. Using UART (image creator) or JTAG (run from IDE)?

    Jan

  • I'm installing from CCS Studio via UART. I'll be updating later via OTA.

  • Hi,

    Do you call sl_Stop() inside your function deviceReset()?

    Your symptoms looks like damaged SPI flash. Do you write into SPI flash somewhere else that is stated at code above? How often do you write into SPI flash? If you exchange SPI flash chip does it solve your issue?

    Jan


  • void deviceReset(void)
    {
    /* 1) Ağ alt sistemini durdur – açık soket/scan vs. olmasın */
    sl_Stop(SL_STOP_TIMEOUT);

    /* 2) Kısa bir nefes: NWP stop’un tamamlanması için 20–50 ms */
    ClockP_usleep(50000);

    /* 3) Tüm kesmeleri kapat – yarış koşullarını kes */
    Hwi_disable(); // veya HwiP_disable()

    /* 4) (İsteğe bağlı) watchdog'u kapat ya da beklenen reset nedeni olarak ayarla */
    /* ... */

    UART_PRINT("[Common] CC32xx MCU reset\r\n");

    /* 5) Hibernate reset – TI’nin önerdiği “temiz reboot” */
    MAP_PRCMHibernateCycleTrigger();

    /* Buraya düşmemeli */
    while (1) { ; }

    My devicereset function is like this

    I don't write to SPI flash all the time, I write it when the situation changes and reset it with devicereset.

    We are writing to the external SPI flash. It is the same as the flash integrated in the Launchpad.

  • Hi,

    Another thing which can kill SPI flash is if you often call sl_ APIs which are persistent. These sl_ APIs write at the background into SPI flash. Another thing which can corrupt content in SPI flash can be issue with SPI itself (e.g. wrong signal integrity) or power outage during write. Do you have more hardware with same symptoms?

    I think you should exchange SPI flash chip and check if issue persist. 

    Jan

  • I've had this problem on almost all of my devices at different times. It works when I reload the code without changing the flash chip. I'm having a huge problem.

  • Hi,

    If you think that your SPI flash chip is not damaged by excessive number of write cycles and exact same code works at LaunchPad there is not much options than your have design issue with your hardware.

    How many layer does have your board? Do you use QFN package not a MOD package, right?

    Jan

  • I'm using a qfn 4-layer PCB. I can re-code my broken device. And it works. But why does the flash drive get corrupted or the code deleted in the field? Is it because it's SOP 010, or is it because I'm writing to the flash? I write to the flash, but not to the mcuflash.bin area. I don't understand why.

  • Hi,

    SOP mode 0-1-0 is not issue. Writing into SPI flash is not a issue unless you write too often of there is power outage during SPI flash write cycle. If you have wrong SPI design or insufficient power source this can cause corruption of SPI flash content.

    I think crucial is to determine if exact same code run at LaunchPad without any issue. If so, there is no other option than your hardware design is wrong.

    Jan

  • The devices don't cause problems in a lab environment. I'm experiencing these issues in the field. Another device I had was frequently switching to UARTboot mode. I set the SOP value to 000, and it was fine for now. Therefore, I suspected the SOP pins.

  • Hi,

    Have you device tested for EMC immunity? What standards and levels you tested?

    What is your filed environment? Are the EM interferences like from power inverters, high voltage, etc.

    Jan

  • No, but we used the Launchpad design as a reference. The device also communicates constantly with another processor via UART. It uses the same UART as the programming UARTs.

  • Hi,

    Usage UART at such configuration should not be a factor. 

    That you designed your hardware according to LaunchPad it does not mean anything. Even one different trace at PCB can cause different behaviour in case of EMC immunity. Put device into filed without proper EMC testing may to have bad consequences not only legal but functional as well.

    Do you even know how looks EMC environment a field where devices failed?

    Jan

  • Actually, desktop testing is usually done. I don't think there will be high EMC interference.

  • The device is reset by another processor under certain conditions. If another processor resets the device while the flash reset button is pressed or held down, will there be a permanent situation, such as a program deletion, if that reset occurs?

  • Hi,

    Sorry I don't undescended your question (flash reset button...).

    But if you restart CC3235 during writing into SPI flash, it may to cause corruption of SPI flash content.

    Jan

  • Isn't the sector I'm writing to damaged? I'm not writing to the area where the program is located, so the program shouldn't be deleted. Am I wrong?

  • Hi,

    sl_ Filesystem have something like "FAT" and depending of type write is FAT updated. And when sectors with FAT are corrupted you have a problem.

    Jan


  • int fs_writeFile(const char *fileName, const void *data, uint32_t length)
    {
    _i32 fileHandle;
    _u32 token = 0;
    int status;

    if (!fileName || !data || length == 0) {
    return SL_ERROR_BSD_EINVAL;
    }

    /* 1) Önce mevcut dosyayı yazma modunda açmayı dene
    * (örneğin wifi_config.txt daha önce failsafe/create ile açılmış olabilir).
    */
    fileHandle = sl_FsOpen((unsigned char *)fileName, SL_FS_WRITE, &token);

    if (fileHandle < 0) {
    /* 2) Dosya yoksa veya açılamıyorsa: FAILSAFE olarak oluştur.
    *
    * Burada maxFileSize olarak "length" kullanıyoruz; kritik config dosyaları
    * için zaten sabit/üst limit bir uzunlukla çağırman ideal (örn. 256).
    */
    _u32 maxFileSize = length;

    fileHandle = sl_FsOpen((unsigned char *)fileName,
    SL_FS_CREATE |
    SL_FS_OVERWRITE |
    SL_FS_CREATE_MAX_SIZE(maxFileSize) |
    SL_FS_CREATE_FAILSAFE,
    &token);
    if (fileHandle < 0) {
    return (int)fileHandle; // Açma/oluşturma hatası
    }
    }

    /* 3) Dosyaya baştan itibaren yaz */
    status = sl_FsWrite(fileHandle, 0, (_u8 *)data, length);
    if (status < 0) {
    /* Yazma hatası → abort signature ile kapat, hatayı geri döndür */
    (void)sl_FsClose(fileHandle, 0, (unsigned char *)"A", 1);
    return status;
    }

    /* 4) Düzgün şekilde kapat (commit) */
    status = sl_FsClose(fileHandle, 0, 0, 0);
    if (status < 0) {
    return status;
    }

    return 0;
    }

    /**
    * @brief Belirtilen dosyadan veri okur (tüm içeriği buffer'a kopyalar).
    *
    * @param[in] fileName Okunacak dosya adı (ör: "/wifi_config.txt")
    * @param[out] buffer Okunan verinin kopyalanacağı buffer
    * @param[in] length Okunacak maksimum byte sayısı (buffer boyutu)
    * @return 0: Başarılı, <0: Hata kodu (sl_Fs* fonksiyonlarından döner)
    */
    int fs_readFile(const char *fileName, void *buffer, uint32_t length)
    {
    _i32 fileHandle;
    _u32 token = 0;
    int status;

    if (!fileName || !buffer || length == 0) {
    return SL_ERROR_BSD_EINVAL;
    }

    // Dosyayı oku modunda aç
    fileHandle = sl_FsOpen((unsigned char *)fileName, SL_FS_READ, &token);
    if (fileHandle < 0) {
    return (int)fileHandle; // Hata kodunu döndür (ör: dosya yok)
    }

    // Dosyadan oku
    status = sl_FsRead(fileHandle, 0, (_u8 *)buffer, length);
    if (status < 0) {
    (void)sl_FsClose(fileHandle, 0, (unsigned char *)"A", 1); // Okuma hatası varsa abort ile kapat
    return status;
    }

    // Dosyayı düzgün şekilde kapat
    int closeStatus = sl_FsClose(fileHandle, 0, 0, 0);
    if (closeStatus < 0) {
    return closeStatus;
    }

    return 0;
    }

    /**
    * @brief Eğer dosya mevcut değilse belirtilen boyutta boş bir FAILSAFE dosya oluşturur.
    *
    * @param[in] fileName Kontrol edilecek/oluşturulacak dosya adı
    * @param[in] length Oluşturulacak dosyanın maksimum boyutu
    */
    void ensureFileExists(const char *fileName, uint32_t length)
    {
    _i32 fileHandle;
    _u32 token = 0;

    if (!fileName || length == 0) {
    return;
    }

    // Dosya var mı kontrol et
    fileHandle = sl_FsOpen((unsigned char *)fileName, SL_FS_READ, &token);
    if (fileHandle >= 0) {
    // Dosya varsa kapatıp çık
    (void)sl_FsClose(fileHandle, 0, 0, 0);
    return;
    }

    // Dosya yoksa, FAILSAFE boş dosya olarak oluştur
    fileHandle = sl_FsOpen((unsigned char *)fileName,
    SL_FS_CREATE |
    SL_FS_OVERWRITE |
    SL_FS_CREATE_MAX_SIZE(length) |
    SL_FS_CREATE_FAILSAFE,
    &token);
    if (fileHandle >= 0) {
    (void)sl_FsClose(fileHandle, 0, 0, 0); // Oluşturulan dosyayı hemen kapat
    }
    }   Do these codes to the FAT system?

  • Hi,

    If you create file, fat is updates as far I know. Because I don't have access to NWP code, can't confirm that.

    Jan