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.

cc2530 Bootloader and app entry point

Other Parts Discussed in Thread: CC2530, Z-STACK

Hello,

I am using the ZStack Bootloader for the cc2530 and it is working ok but there something that I don't understand. I had to write in bootloader code the entry point of my application (that I got from .map) so when bootloader ends, it jumps to this location but...what if the next applicaction that I want to load throught bootloader has a different entry point? Is there any way to force the entry point? Have I to modify the bootloader every time ?(it would be a nonsense)

Best regards,

Victor

  • Hi Victor,

    we designed the serial bootloader 'system' as a couple of images: the bootloader code and the 'stack' image.

    The bootloader code is confined in the first page of the flash, where the ISR vector resides.

    Once the bootloader has downloaded a valid image, it jumps to the stack image. 

    The stack "portion" (which is where the ISR vector gets relocated) starts at a predefined address as set in the linker command file. This address is sync'd with the one where the bootloader jumps to and therefore even if the stack code changes, there's no need to change the jump address.

    Please see the Serial Bootloader for CC2530 document, chapter 8.2 for a description of the design and guidance.

    Thanks,

    TheDarkSide

  • Hi TheDarkSide,

    I understand your response but I suspect that something wrong in my side because it's not working. The explanation:

     First I did a really simple App test that switch on/off a led. I saw the .map file that the linker generate and I saw this:

    <CSTART,NEAR_CODE> 1 (was NEAR_CODE)
      Relative segment, address: CODE 00002003 - 0000202F (0x2d bytes), align: 0
      Segment part 11.
               ENTRY                   ADDRESS         REF BY
               =====                   =======         ======
               main                    00002003        ?call_main (?cmain)

    So I modify the bootloader to jump to this location of this way:

    static void sblJump(void)
    {
      SB_TURN_OFF_ADHOC();
      asm("LJMP 0x2003\n");  // Immediate jump to run-code.
      HAL_SYSTEM_RESET();
    }

    I test the application load by bootloader and it's works. After this test I compile and link my end application with the same linker file (sb-boot.xcl). The sending procedure to the bootloader is ok (included CRC) but the application never run. I saw the map file and I found this:

    <CODE_C,CSTART,NEAR_CODE,RCODE> 1 (was NEAR_CODE)
      Relative segment, address: CODE 00005877 - 00005883 (0xd bytes), align: 0
      Segment part 462.
               ENTRY                   ADDRESS         REF BY
               =====                   =======         ======
               main                    00005877        ?call_main (?cmain)
                   calls direct

    So I don't undestand why the address is different. Is it ok? What's wrong?

    Thanks a lot in advance,

    Victor

  • Hi Victor,

    It seems that your main function is located at 0x5877 but the boot loader jumps to 0x2003. Try to revise the linker script to make your main function fixed at 0x2003.

  • How I can force it?

    Thanks,

    Victor

  • Hi Victor,

    Sorry, It is nothing to do with the address of main function. You need to set -D_CODE_START=0x2003 in you application xcl file.

  • Hi Yikai,

    as I understand, the  -D_CODE_START command, only fix where start allocated the code, not the entry point.

    Victor

  • Hi Victor,


    My application is based on OTA. You can have a look at OTA boot in Z-Stack Home 1.2.0 (C:\Texas Instruments\Z-Stack Home 1.2.0\Projects\zstack\OTA\Boot\CC2530DB) and you can see it use "asm("LJMP 0x800\n");" in main function. In your OTA image, you need to assign -D_CODE_START=0x0800 in ota.xcl file. You can refer to SampleSwitchOta (C:\Texas Instruments\Z-Stack Home 1.2.0\Projects\zstack\HomeAutomation\SampleSwitchOta).