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.

ZStack OTA CC2530 on WaveShare platform

Other Parts Discussed in Thread: CC2530

Hello,

I bought the Open2530 platform by Waveshare Electronics (the link here), after some general tests, I want to test now OTA functionality. 

I created a new HalOTAWrite and a new HalOTARead to access to the new external memory (AT45DB041D) correctly: I tested these two functions and they work properly.

So I began to download the new firmware over the air through the "OTA Console" and everything went fine:  download completed successfully.

In spite of the successful message, the device restarts with the "old" firmware without installing the newer in the external NV memory; of course I modified also the OTA Boot with the new functions. 

I don't understand why it doesn't install the new firmware, could anyone help me? 

  • After having a look at the link, I do not see there is external flash on open2530. I doubt that you can use OTA on it. Please make sure open2530 has external flash on it first.

  • The package contains a DataFlash board which is connected via SPI to the main board. (here the link)

    Obviously I changed the ZStack SPI settings for the AT45DB041D's connection: the tests work properly. 

    I think there is a problem in the code after the download or in the Boot code, but I haven't found it yet.

  • If you new FW image is download successfully, you need to have an approach to notify boot loader there is a new FW download to external flash before the device restarts. In my case, I use NV RAM to notify boot loader, which means that I write a special byte to NV RAM and the boot loader reads this after the device restarts. If there exists this special byte, the boot loader will copy new FW from external flash in flash of CC2530, runs it and remove the special byte.

  • I tested OTA functionality with the ZStack's sample "In Premise Display - End Device - OTA" and "OTA-Boot".

    So, in the ipd.c code, the function called "HalOTAInvRC" performs exactly what you said:

    void HalOTAInvRC(void)
    {
    uint16 crc[2] = {0,0xFFFF};
    HalFlashWrite((HAL_OTA_CRC_ADDR / HAL_FLASH_WORD_SIZE), (uint8 *)crc, 1);
    }

    And in the Boot code, the first instruction is:

    HalFlashRead(HAL_OTA_CRC_ADDR / HAL_FLASH_PAGE_SIZE, HAL_OTA_CRC_ADDR % HAL_FLASH_PAGE_SIZE, (uint8 *)&OTA_crcControl, sizeof(OTA_crcControl));

    The only thing I changed is the boot-code size, because the new functions, OTARead and OTAWrite, are bigger: I modified in ota.xcl

     -D_CODE_START=0x0800  in  -D_CODE_START=0x0C00 

    and of course in hal_ota.h

    HAL_OTA_CRC_ADDR 0x0888 to HAL_OTA_CRC_ADDR 0x0C88


    I think there is a problem with the Boot-Code. For example, in my last test, I added in the boot-code a print on the screen: this print appears, executing the boot-code only, but it doesn't appear, executing the full code.  

  • Since you said you changed the boot-code size, is it large enough to change it from 0x0800 to 0x0C00? By the way, you should trace why your printf not showing first to make it work properly. 

  • I think (and I am quite certain) that the program code overwrites the boot code.
    My last test was the following: I inserted a flashing of the three leds for five seconds at the beginning of the boot code. If I download the boot code only, I see the flashing; in the other hand, if I download also the program code, the flashing is not visible. (I eliminated the "printf")
    I wrote the changes that I made also in another post, but I rewrite them hoping for a your reply: 

    - in ota-boot.xcl: -D_CODE_END=0x07FF 0x0BFF

    - in interrupt_stubs.s51: OFFSET   EQU    0x800 0xC00

    - in hal_ota.h: #define HAL_OTA_RC_START 0x0800 0x0C00

                          #define HAL_OTA_CRC_ADDR 0x0888 0x0C88

    - in hal_ota.c: asm("LJMP 0x800 0xC00\n");

    - in ota.xcl: -D_CODE_START=0x0800 0x0C00

                      -Z(CODE)CRC=0x0888-0x088B 0x0C88-0x0C8B

                      -Z(CODE)PREAMBLE=0x088C-0x0897 0x0C8C-0x0C97

                      -P(CODE)BANKED_CODE=0x08000x0C00-0x7FFF,0x18000-0x1FFFF,0x28000-0x2FFFF,0x38000-0x3FFFF,0x48000-0x4FFFF,\
                      0x58000-0x5FFFF,0x68000-0x6FFFF,0x78000-0x7C7FF