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: Packet two applications as a firmware

Part Number: CC3220

Hi Ti:

    I am using CC3220S,usually we use uniflash to download the firmware to a 2MB flash.

    But in my case,since more simple for the factory testing,we design the use case like this:
    We burned a firmware which support OTA(we called it FW-A),then we use OTA to update to a non OTA feature firmware(call it FW-B,after OTA the FW-A still saved on flash as a original version),this new firmware is used for the factory testing(means when finished all the test in factory,the tester will long press a button then trigger reset to the  FW-A).

     My questions is: dose it possible to generate a packet could include the FW-A and the FW-B,and let the FW-B as the boot firmware?

     So that could let me just burn this packet(FW-B + FW-A)  using flash programmer.

 Jon

Thanks

  • Hi Jon,

    Just a quick comment. In case of that you have enough space inside your sFlash, best way sounds me.
    Fw-A ... your standard firmware image file (your production firmware with all functionality + feature which allows load and execute other firmware)
    Fw-B ... your testing image file (with all testing procedures, etc.)
    Fw-A + Fw-B will be at one image (download by Uniflash or Gang programming)

    After startup is loaded your Fw-A. After trigger (e.g. button) your firmware halt and load and execute your testing firmware Fw-B.

    Here is example how to load and execute firmware e2e.ti.com/.../2662274

    Jan
  • Hi Jan:

        Thanks for your reply.

        My question:

    1. How to packet Fw-A and Fw-B into one image? I have tried Uniflash,but this tools don't allow me to packet two Fw together. And the 1st bootloader will automic know to loaded Fw-A,and running it?

    2. If Fw-B have some issues,and i want to use OTA to update the Fw-B+Fw-A to a new version,is it possbile?

    Jon

    Thanks 

  • Hi Jon,

    1. Fw-A will be standard firmware file /sys/mcuimg.bin. Firmware Fw-B will be any other file in sFlash filesystem. ROM bootlaoder can execute only file /sys/mcuimg.bin. Inside you Fw-A you will have functionality to load Fw-B into RAM and execute it. All management will be up to you.

    2. As you can update any other file in sFlash by OTA, you can update Fw-B as well. Fw-B is just a standerd file in filesystem.

    Jan
  • Hi Jan:

          How could i config the Fw-B about the certification and signature?

    Thanks

  • Hi,

    Because you load this file (Fw-B) by yourself, you do not deal with that. Certificate and signature is important only for your Fw-A (which is loaded by ROM bootlaoder).

    Jan
  • Hi Jan:

         The Ram maybe is not enough for load Fw-A and Fw-B.

    Fw-A:

    MEMORY CONFIGURATION

             name            origin    length      used     unused   attr    fill
    ----------------------  --------  ---------  --------  --------  ----  --------
      SRAM2                 20000000   00004000  0000070c  000038f4  RW X
      SRAM                  20004000   0003c000  0003baa2  0000055e  RW X


    SEGMENT ALLOCATION MAP

    run origin  load origin   length   init length attrs members
    ----------  ----------- ---------- ----------- ----- -------
    20003c00    20003c00    00000400   00000000    rw-
      20003c00    20003c00    00000400   00000000    rw- .stack
    20004000    20004000    00025f3c   00025f3c    r-x
      20004000    20004000    00000040   00000040    r-- .resetVecs
      20004040    20004040    00025efc   00025efc    r-x .text
    2002a000    2002a000    00014494   00000000    rw-
      2002a000    2002a000    00010cec   00000000    rw- .bss
      2003acf0    2003acf0    000037a4   00000000    rw- .data
    2003e494    2003e494    000014ae   000014ae    r--
      2003e494    2003e494    000014ae   000014ae    r-- .const
    2003f948    2003f948    00000228   00000228    r--
      2003f948    2003f948    00000228   00000228    r-- .cinit

    Fw-B:

    MEMORY CONFIGURATION

             name            origin    length      used     unused   attr    fill
    ----------------------  --------  ---------  --------  --------  ----  --------
      SRAM2                 20000000   00004000  0000090c  000036f4  RW X
      SRAM                  20004000   0003c000  0003867c  00003984  RW X


    SEGMENT ALLOCATION MAP

    run origin  load origin   length   init length attrs members
    ----------  ----------- ---------- ----------- ----- -------
    20003a00    20003a00    00000600   00000000    rw-
      20003a00    20003a00    00000600   00000000    rw- .stack
    20004000    20004000    00028300   00028300    r-x
      20004000    20004000    00000040   00000040    r-- .resetVecs
      20004040    20004040    00028064   00028064    r-x .text
      2002c0a8    2002c0a8    00000258   00000258    r-- .cinit
    2002c400    2002c400    0000f190   00000000    rw-
      2002c400    2002c400    000085a2   00000000    rw- .bss
      200349a4    200349a4    00006bec   00000000    rw- .data
    2003b590    2003b590    000011f2   000011f2    r--
      2003b590    2003b590    000011f2   000011f2    r-- .const

    Thanks,

    Jon

  • Hi Jon,

    In case of that your RAM is not big enough to contain both codes, it make sense use small bootloader, which will be loaded after start-up. According some external conditions (pin state, file in sFlash) will determine whether to loaded Fw-A or Fw-B int RAM.

    As reference of bootloader you can take bootloader linked above. You need link this bootlaoder code to 0x20004000 (entry point in ROM bootlaoder). And Fw-A and Fw-B should be linked at another RAM place (e.g. 0x20008000 or above).

    Jan
  • Hi Jan:

       Thanks for your patient explanation.

       I download your bootloader demo,it seems for cc3220sf not cc3220s. and i changed the link file to make it working on cc3220s,but the bootloader seems need around 25Kb RAM,you see my main application need 0003baa2  RAM, 

       So the bootloader + main application already exceed the RAM size.

       Is it possbile to re-use the  0x20000000 - 0x20004000?

    Jon

  • Hi Jon,

    It it not much important whether S or SF device is used. Architecture of both devices is same. SF device only have XIP flash.

    Yes, you can reuse fist 16kB of RAM. First 16kB or RAM is a perfect place to .stack section and other small sections. You cannot place code sections into this place in case of code is called by ROM bootloader. How to use first 16KB or RAM is described at www.ti.com/.../swru369d.pdf chapter 6.1.2 (yes I know that document is for CC3200, but this chapter can be also applied to CC3220; from unknown reasons "CC3220 Programmer's Guide" SWRU464 is not available at TI sites).

    btw ... there can be a alternative in case you have not enough RAM. At CC3200 SDK is example "dynamic_lib_loader". This example demonstrate how can by dynamically loaded parts of code into RAM. It can be a good inspiration for you.

    Jan
  • Hi Jon,

    Can you provide here output from Memory allocation tool from CCS (I am to lazy to count it from memory map :))?

    ... I could give you advice how to map your RAM for apps. and bootlaoder.

    Jan

  • Hi Jan:

     Fw-A:

    Fw-B(Factory test):

    Bootloader:

    Jon

    Thanks

  • Hi Jan:

     Fw-A:

    Fw-B(Factory test):

    Bootloader:

    jon

    Thanks

  • Hi Jon,

    Linker file for Fw-A and Fw-B could look like:

    #define SRAM_BASE 0x20013000  /* your application starts at this address */
    
    MEMORY
    {
        SRAM_DATA (RWX) : origin = 0x20000000, length = 0x13000  /* 76kB for RAM stuff */
        SRAM_CODE (RWX) : origin = 0x20013000, length = 0x2D000  /* 180kB for code in RAM */
    }
    
    SECTIONS
    {
        .text       : > SRAM_CODE
        .TI.ramfunc : > SRAM_CODE
        .const      : > SRAM_CODE
        .cinit      : > SRAM_CODE
        .pinit      : > SRAM_CODE
        .init_array : > SRAM_CODE
    
        .data       : > SRAM_DATA
        .bss        : > SRAM_DATA
        .sysmem     : > SRAM_DATA
        .stack      : > SRAM_DATA(HIGH)
    
        /* these sections are used by FreeRTOS */
        .resetVecs  : > SRAM_BASE
        .ramVecs    : > SRAM_DATA, type=NOLOAD
    }
    

    Linker file for boorloader:

    #define RAM_BASE 0x20004000
    
    MEMORY
    {
        SRAM_CODE (RWX) : origin = 0x20004000, length = 0x8000
        SRAM_DATA (RWX) : origin = 0x20000000, length = 0x4000
    }
    
    /* Section allocation in memory */
    
    SECTIONS
    {
        .intvecs:   > RAM_BASE
        .init_array : > SRAM_CODE
        .vtable :   > SRAM_CODE
        .text   :   > SRAM_CODE
        .const  :   > SRAM_CODE
        .cinit  :   > SRAM_CODE
        .pinit  :   > SRAM_CODE
        .data   :   > SRAM_DATA
        .bss    :   > SRAM_DATA
        .sysmem :   > SRAM_DATA
        .stack  :   > SRAM_DATA(HIGH)
    }

    ... bootlaoder will read content of file in sFlash and upload it to RAM beginning from 0x20013000 and execute it. I did not tested this linker files and I missed something maybe. But it illustrate how can be changed linker file to be used with bootloader and save some valuable RAM space.

    Jan

  • Hi Jan:

    Bootloader:

    Fw-A:

    Fw-B(Factory test):

         Also,another question,if i want to put a bootmode.bin file under the root filesystem packet,when the bootloader find this 'bootmode.bin' file,it will load the Fw-B to the RAM. And after factory testing,the 'bootmode.bin' will be deleted by the Fw-B. I know there is a initialize image packet concept,would the 'bootmode.bin' file be recovered when i do the restore the initial state operation?

    Jon

    Thanks

  • Hi Jon,

    In case of 'bootmode.bin' will be part of factory image and factory restore feature will be used, file 'bootmode.bin will be restored. If this behaviour is not intended, you should consider to add feature to create this file in Fw-A.

    BTW ... was you able manage bootloader and your code with linker files above?

    Jan