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.

带有SBL功能的zigbee程序的复位问题

Other Parts Discussed in Thread: CC2530

使用芯片:CC2530

协议栈:ZHA1.2.2a

设备类型:协调器

需求:linux网关通过串口与协调器相连,进行在线升级

程序状态:参照文档《Serial_Boot_Loader_for_CC253x》,程序能够正常烧录和运行;

问题:

         1、运行中想进行在线升级,网关给协调器发送一个复位命令,让协调器进入BOOT状态,但是发现程序没有进入BOOT程序,还是进入到协调器程序的开始端;

         2、我看协议栈中有两个复位函数:SystemReset()和SystemResetSoft(),其中SystemReset()用的是看门狗复位,SystemResetSoft()用的是一个长跳转(asm("LJMP 0x0");)。

         3、对这两个复位函数分别进行了测试:

               1)、SystemReset()再任何情况下,程序都执行到应用程序;

               2)、SystemResetSoft()只在上电后的第一次能执行到BOOT程序,以后就都执行到应用程序;

               3)、上电或者人为拉低芯片的rest引脚,都是从BOOT执行的。

           4、现在的问题是进行协调器程序升级时,无法对2530芯片进行断电,也没有专门的复位按钮,只能在软件中进行重启复位,请问需要做什么修改能让程序复位到BOOT程序中,然后进行升级操作?

  • cc2530的程序升级建议使用OTA,操作文档请看下边:

    Z-Stack OTA Upgrade User's Guide.pdf

  • 您好,要升级的是协调器,正常工作的时候就是与网关串口连接的,因此考虑的升级方式还是SBL
  • 参考Serial_Boot_Loader_for_CC253x第11章

    11. Forcing boot-mode or early jump to Application code.

    The SBL receives control from the reset vector and verifies whether valid Application code is present. If so, then the SBL gives the bus master a window in which to force boot mode or an immediate jump to Application code.

    1. If the CRC is not 0x0000 or 0xFFFF and the CRC-shadow is identical, then the Application code is valid.

    2. If the CRC is not 0x0000 of 0xFFFF and the CRC-shadow is 0xFFFF, then the CRC is calculated over the Application code image area (this will take over a minute.) a. If the calculated CRC matches the read CRC, program the CRC-shadow to this identical value to speed-up future power-ups.

    3. If the Application code is valid, wait for the bus master to send a 0xF8 to force boot-mode or an 0x07 to force an immediate jump to the Application code. a. The default wait for UART and USB transport is 1 minute. b. The default wait for SPI is 50 milliseconds.

    4. If the Application code is valid and the wait expires, jump to the Application code.

    5. If the Application code is not valid, immediately jump to the boot-code without waiting as described above.
  • 谢谢答复,这部分内容都是BOOT程序中的流程,我这边测试也都是没有问题的。

    我这边的需求是:

    在应用程序已经启动的情况下,不断电重启,怎么能够使程序跳转到BOOT程序中?

    协议栈中的两个重启的函数SystemReset()与SystemResetSoft(),调用后,还是在应用程序中跳转,没法跳到BOOT程序中。

  • 这个我跟同事讨论了一下,回复如下:

    For SBL-enabled devices, SBL code executes after any reset.

    If SBL detects that application image is valid (correct CRC) AND the reset was caused by watchdog, then SBL will jump to application code immediately. 
    The SystemReset causes a watchdog reset.

    SystemResetSoft is a soft reset, whose purpose is to start application code from beginning.

    Since the intent is for the host to write a new application image to CC2530, modify the application image CRC to indicate this.
    The example of the OTA can be used: 

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

    Except for SBL, the address of the CRC will be different. Use HAL_SB_CRC_ADDR == 0x2090 (defined in hal_board_cfg.h).
    Then the CC2530 can call SystemReset. Afterwards, the host may write the new application image.