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.

CC3220: How to read internal Flash from CC3220?

Part Number: CC3220
Other Parts Discussed in Thread: UNIFLASH

Hi,

As per CC3220 SDK, "flash" files in "simplelink_cc32xx_sdk_2_30_00_05\source\ti\devices\cc32xx\driverlib" I found API's only to Program. But no API's to read the same data from the internal Flash of CC3220SF, can I know any alternative way to read data by pointing address and length. 

Thank you

  • Hi,

    Internal flash (XIP) is mapped into address space of chip. In case of you want read content of XIP flash you can use pointer. This is same as any part of address space. Alternate you can create dedicated section by linker file. But I think this is not much helpful.

    Jan
  • Dear Jan,

    Thanks for the response, I am planning to store some data in to flash to keep it permanent and read on every power on.

    In case of you want read content of XIP flash you can use pointer

    In runtime I wan to read it, can you please brief this. I taught reading by pointing to address may read from RAM.

  • Hi,

    For this purpose you should use sl_ Filesystem API and save your data into Flash. XIP flash is not a best place to store permanent data. Content of XIP flash is erased at some cases by ROM bootloader (e.g. e2e.ti.com/.../747150 ).

    To read content you can use something like that:

    char* xip = 0x01000000; /* 0x01000000 - beginning of XIP flash*/
    printf("%2x", *xip);

    Jan
  • How to do using sl_ Filesystem API ? Is there any examples available.
  • Hi,

    Please see chapter 7 at www.ti.com/.../swru455e.pdf or dev.ti.com/.../

    Jan
  • I tried the same already, I am getting  error code to open new file. I did

    char file[8] = "testfile";
    OpenNewFile(file);

    FileHdl = sl_FsOpen((unsigned char *)DeviceFileName,\
                SL_FS_CREATE|SL_FS_CREATE_SECURE | SL_FS_CREATE_NOSIGNATURE | SL_FS_CREATE_MAX_SIZE( MaxSize ),\
                &MasterToken);
    UART_PRINT("OpenNewFile %d",FileHdl);
        if(FileHdl < 0 )
        {
            /*error */
            }

    Getting error code -2018

    It seem's error SL_RET_CODE_DEV_NOT_STARTED and device not started yet.

    Can you please brief how it works,

    Do I need to store any files during flash in Uniflash or what?

    Thank you

  • Hi,

    You need to enable NWP by sl_Start() before usage any sl_ API.

    Jan
  • Dear Jan,
    I am doing this in OOB project after the initialization of all the tasks. sl_Start() is calling before sl_FS_open();
  • Hi,

    You need to have something else wrong inside your project. I am pretty sure that error code is returned because NWP is not started. Can you show exact place where did you place sl_ Filesystem API?

    Jan
  • void * mainThread(void *arg)
    {
        int32_t RetVal;
        pthread_attr_t pAttrs;
        pthread_attr_t pAttrs_spawn;
        struct sched_param priParam;
        struct timespec ts = {0};
    
        GPIO_init();
        SPI_init();
        I2C_init();
    
        /* init Terminal, and print App name */
        InitTerm();
    
        /* initialize the realtime clock */
        clock_settime(CLOCK_REALTIME, &ts);
    
        InitializeAppVariables();
    
        /* Switch off all LEDs on boards */
        GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_OFF);
    
        /* initializes signals for all tasks */
        sem_init(&Provisioning_ControlBlock.connectionAsyncEvent, 0, 0);
        sem_init(&Provisioning_ControlBlock.provisioningDoneSignal, 0, 0);
        sem_init(&Provisioning_ControlBlock.provisioningConnDoneToOtaServerSignal,
                 0,
                 0);
        sem_init(&LinkLocal_ControlBlock.otaReportServerStartSignal, 0, 0);
        sem_init(&LinkLocal_ControlBlock.otaReportServerStopSignal, 0, 0);
    
        /* create the sl_Task */
        pthread_attr_init(&pAttrs_spawn);
        priParam.sched_priority = SPAWN_TASK_PRIORITY;
        RetVal = pthread_attr_setschedparam(&pAttrs_spawn, &priParam);
        RetVal |= pthread_attr_setstacksize(&pAttrs_spawn, TASK_STACK_SIZE);
    
        RetVal = pthread_create(&gSpawnThread, &pAttrs_spawn, sl_Task, NULL);
    
        if(RetVal)
        {
            /* Handle Error */
            UART_PRINT("Unable to create sl_Task thread \n");
            while(1)
            {
                ;
            }
        }
        mode = sl_Start(0, 0, 0);
        if(mode >= 0)
        {
            DisplayBanner(APPLICATION_NAME, APPLICATION_VERSION);
            mode = sl_Stop(SL_STOP_TIMEOUT);
            if(mode < 0)
            {
                /* Handle Error */
                UART_PRINT("\n sl_Stop failed\n");
                while(1)
                {
                    ;
                }
            }
        }
        else if((mode < 0) && (mode != SL_ERROR_RESTORE_IMAGE_COMPLETE))
        {
            /* Handle Error */
            UART_PRINT("\n sl_Start failed\n");
            UART_PRINT("\n %s Example Ver. %s\n",APPLICATION_NAME,
                       APPLICATION_VERSION);
            while(1)
            {
                ;
            }
        }
    
        pthread_attr_init(&pAttrs);
        priParam.sched_priority = 1;
        RetVal = pthread_attr_setschedparam(&pAttrs, &priParam);
        RetVal |= pthread_attr_setstacksize(&pAttrs, LINKLOCAL_STACK_SIZE);
    
        if(RetVal)
        {
            /* Handle Error */
            UART_PRINT("Unable to configure linkLocalTask thread parameters \n");
            while(1)
            {
                ;
            }
        }
    
        RetVal = pthread_create(&gLinklocalThread, &pAttrs, linkLocalTask, NULL);
    
        if(RetVal)
        {
            /* Handle Error */
            UART_PRINT("Unable to create linkLocalTask thread \n");
            while(1)
            {
                ;
            }
        }
    
            pthread_attr_init(&pAttrs);
            priParam.sched_priority = 1;
            RetVal = pthread_attr_setschedparam(&pAttrs, &priParam);
            RetVal |= pthread_attr_setstacksize(&pAttrs, TASK_STACK_SIZE);
    
            if(RetVal)
            {
                // Handle Error //
                UART_PRINT("Unable to configure provisioningTask thread parameters \n");
                while(1)
                {
                    ;
                }
            }
    
            RetVal = pthread_create(&gProvisioningThread, &pAttrs, provisioningTask,
                                    NULL);
    
            if(RetVal)
            {
                // Handle Error //
                UART_PRINT("Unable to create provisioningTask thread \n");
                while(1)
                {
                    ;
                }
            }
    
        pthread_attr_init(&pAttrs);
        priParam.sched_priority = 1;
        RetVal = pthread_attr_setschedparam(&pAttrs, &priParam);
        RetVal |= pthread_attr_setstacksize(&pAttrs, CONTROL_STACK_SIZE);
    
        if(RetVal)
        {
            /* Handle Error */
            UART_PRINT("Unable to configure controlTask thread parameters \n");
            while(1)
            {
                ;
            }
        }
    
        RetVal = pthread_create(&gControlThread, &pAttrs, controlTask, NULL);
    
        if(RetVal)
        {
            /* Handle Error */
            UART_PRINT("Unable to create controlTask thread \n");
            while(1)
            {
                ;
            }
        }
    
        pthread_attr_init(&pAttrs);
        priParam.sched_priority = 5;
        RetVal = pthread_attr_setschedparam(&pAttrs, &priParam);
        RetVal |= pthread_attr_setstacksize(&pAttrs, TASK_STACK_SIZE);
    
        if(RetVal)
        {
            /* Handle Error */
            UART_PRINT("Unable to configure otaTask thread parameters \n");
            while(1)
            {
                ;
            }
        }
    
        RetVal = pthread_create(&gOtaThread, &pAttrs, otaTask, NULL);
    
        if(RetVal)
        {
            /* Handle Error */
            UART_PRINT("Unable to create otaTask thread \n");
            while(1)
            {
                ;
            }
        }
    
            char testfileName[8] = "testfile";
            OpenNewFile(testfileName);
    
        return(0);
    }

  • Hi,

    You call API in moment when NWP is stopped, see code:

        mode = sl_Start(0, 0, 0);
        if(mode >= 0)
        {
            DisplayBanner(APPLICATION_NAME, APPLICATION_VERSION);
            mode = sl_Stop(SL_STOP_TIMEOUT);
            if(mode < 0)
            {
                /* Handle Error */
                UART_PRINT("\n sl_Stop failed\n");
                while(1)
                {
                    ;
                }
            }
        }
        else if((mode < 0) && (mode != SL_ERROR_RESTORE_IMAGE_COMPLETE))
        {
            /* Handle Error */
            UART_PRINT("\n sl_Start failed\n");
            UART_PRINT("\n %s Example Ver. %s\n",APPLICATION_NAME,
                       APPLICATION_VERSION);
            while(1)
            {
                ;
            }
        }
    

    Jan