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.

CCS/LAUNCHXL-CC1312R1: Firmware Error? Flashprogram

Part Number: LAUNCHXL-CC1312R1
Other Parts Discussed in Thread: CC1310

Tool/software: Code Composer Studio

Hi!

one of my lib functions, that are working fine on the CC1310 fail on the CC1312R1. I tried get closer to the error, but it seems to appear often, but randomly:

The routine uses the flash-driver from the driverlib and the latest releases of everything.
The routines from the CC1312R1 driverlib: FlashSectorErase() and FlashProgram() often return an error (although they did what I want, but not always)...

Thanks for your assistance,
Jo

(Btw.: D02/03 RX/TX are changed on the Launchpad-CC1312 to CC1310 ?? )

int16_t writeToCPUFlash(uint32_t dest_adr, uint8_t *psrc, uint32_t size, uint8_t flags){
    int16_t result=0;   // Assume OK

    if(size && !memcmp((uint8_t*)dest_adr,psrc,size)){
        return 0;   // Already OK (makes sense e.g. if only FF is written an empty sector
    }

    if(AONBatMonBatteryVoltageGet()< MIN_VDD_CPU_FLASH) return -138;  // Voltage too low!
    VIMSLineBufDisable(VIMS_BASE);
    VIMSModeSet(VIMS_BASE, VIMS_MODE_DISABLED);
    while(VIMSModeGet(VIMS_BASE) != VIMS_MODE_DISABLED);
    CPUcpsid();

    for(;;){    // dummy loop for cleanup
        if(FlashProtectionGet(dest_adr)==FLASH_WRITE_PROTECT){  // Make sure that sector isn't write protected.
            result = -102;  // Write portected
#ifndef DEBUG_M
            break;
#endif
        }

        /* Optionally Erase a flash Page */
        if(flags & CFLASH_FLAG_ERASE){
            if(dest_adr&(CFLASH_SECTOR_SIZE-1)){
                result = -105;  // Illegal Adr
                break;
            }
            if(FlashSectorErase(dest_adr)!= FAPI_STATUS_SUCCESS){
                result = -136;  // Erase failed
#ifndef DEBUG_M
                break;
#endif
            }
        }

        /* Optionally Write to flash */
        if(flags & CFLASH_FLAG_WRITE){
            if(FlashProgram(psrc, dest_adr, size) != FAPI_STATUS_SUCCESS){
                result = -137;  // Write failed
#ifndef DEBUG_M
                break;
#endif
            }
        }
        /* Optionally verify, saves ca. 30 Bytes if not used  */
        if(flags & CFLASH_FLAG_VERIFY){
            if(memcmp((uint8_t*)dest_adr,psrc,size)){
                result = -138;  // Verify failed
                break;
            }
        }
        break;
    }
    CPUcpsie();
    VIMSModeSet(VIMS_BASE, VIMS_MODE_ENABLED);
    VIMSLineBufEnable(VIMS_BASE);

#ifdef DEBUG_M
if(result){
    my_printf("A:%x F%d: L:%d Res:%d\n",dest_adr,flags,size,result);
    result=0;   // ignore!
}
#endif

    return result; // 0: OK
}

  • Any reason you are not using the NVS driver?

    - Try to us the NVS driver and see if you get the same issue.
    - If not, and if you have to use your own function, compare the NVS implementation with your own and see if the differences gives a clue.
    - I assume that you have taken the different page size between CC1310 and CC1312 into account?
  • Hi TER,

    thanks for your reply. Yes, you are right, the CC1312 has 8k sectors, I did not recognise this, in the used "NVSCC26XX.c and .h" there were some comments with 4k, so I did not think about a change...

    The reason for not using the NVS driver is, that the routines are used in a secure bootloader. Hence it must be as small as possible.
    On the CC1310 the bootloader already works perfectly and uses less than 8kb of code and it is able
    to boot from (AES encrypted) files on my file system on the serial SPI memory.

    My customer wants to use the CPU in a system, that gets firmware updates (AES encrypted) over Mobile Internet (2G/3G) as well as via 868/915MHz radio or a via WiFi (for this I am using an ESP8285, that can make a local WiFi hotspot). The product itself is a scientific sensor application for use in nature and is designed to work up to 10 years with one battery and daily data transfer over 2G/3G.

    So I have (CC1310) 120kB of code left (and hopefully 344kB on the CC1312), that can be changed (secured) from "everywhere".

    Best regards,
    Jo

    Btw.: Maybe the (secure) bootloader might be interesting for other users too. I have published the underlying file system completely on Github:  github.com/.../JesFs

    *

  • Thank you for the details. Does that mean changing to 8 k pages fixed the issue?
  • Hi TER,

    in the first tests I would say with 8kb sectors everything is runnung fine.

    Thanks and with kind regards,

    Jo