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.

HAL_SYSTEM_RESET() reset was not happening properly

Other Parts Discussed in Thread: CC2540

Hi All,

          I am working on OAD. I was able to flash Image A and threw BLE Device Monitor I was able to send second image Image B. Once transformation completed we are able to jump into Image B. After that in Image B I have implemented characteristic profile to invalidate the second image when new image is available.


This is the code I was using to invalidate the second image .

      uint16_t crc[2] = {0x0000, 0x0000};
      
      // Invalidate the image.
      OADTarget_writeFlash(OAD_IMG_R_PAGE, OAD_IMG_R_OSET + OAD_IMG_CRC_OSET,
                           (uint8_t *)crc, 4);
      // Reset.
      HAL_SYSTEM_RESET();

I was able to invalidate the image and board reset was happening. But after that my bootloader is not jumping into Image A. It is in non responding state. But if I do hardware reset then it is jumping into Image A Application.

Can anyone faced this kind of issue? Why we need hardware reset to jump into Image A. Do I am doing anything wrong here.

Thanks for your help in advance.

Thanks,

Siva.

  • Hi Siva,

    From your description it seems that, you are trying to invalidate the Image-B. So have you make sure that 'HAL_SYSTEM_RESET()' is actually getting called? You can do this by putting breakpoint or by turning on some LED after writing to the flash!

    Thanks,
    Dhaval
  • Hello,

    I agree with Dhaval. Please use the CC Debugger to confirm the logic workflow in the BIM. You can also use the debugger to confirm you are writing to the expected flash header areas.

    Best wishes
  • Hello Dhaval and JXS,
    If I put debug mode and check reset was happening properly. But the problem is after reset actually Image B I was invalidating so BIM has to jump to IMAGE A But it was not happening. It is in unknown state. If I do hard reset then BIM is jumping into IMAGE A. So why after HAL_SYSTEM_RESET() api BIM is not jumping into IMAGE A this is my question. I have used the provided sample application for OAD from BLE Stack 2.1 and used IAR workbench to compile.

    Thanks,
    Siva.

  • Hi Siva,

    Yes I get your question. And that is why I suggest you that verify whether the HAL_SYSTEM_RESET() is getting called or not. It seems that your code hangs while invalidating the image B and when you are giving hard reset at that time device boots with Image A as Image B is invalid.

    Thanks,

    Dhaval

  • Hi Dhaval,
    If I am putting breakpoint and running then it was jumping into the IMAGE A properly and it was able to advertise. But if I am not doing any debugging and If I am invalidating Image B but it is not jumping into Image A automatically. I took example application as you provided. Can you please tell me what will be the reason for this behaviour. Because I have tried lot of times still I am getting the same behaviour.


    Thanks for your support in advance.

    Thanks,
    Siva.
  • Hi Siva,

    If things are working fine, if you are putting breakpoint then I think it is something related to timing. You can try by putting some delay between Flash write and system reset call.

    Thanks,
    Dhaval
  • Hi Dhaval,
    another doubt i have is we are writing the data into flash and reset is happening from the WriteCharacteristic function. So because of that only bluetooth is hanging to advertise and when we do reset again it is working fine. So I was checking in that. If you found any solution please let me know.

    Thanks for your support.

    Thanks,
    Siva.
  • I don't think it is because of that, but still you can try one thing. First disconnect from the central device and then reset the device.
  • Hi Dhaval,
    I have tried different scenarios like keeping more delay, after that doing reset. I have tried calling api from that to reset the device. Still I am facing the same problem. But if I am doing hardreset I was able to jump into Application/ Image A. So my doubt will be if BLE is not doing hardreset may be because of that system is behaving like this. So can we have an API's which will do hardreset so that may be by doing it Image B will be invalidated and it will be jump into Image A. Please provide information on this.

    Thanks for your support in advance.

    Thanks,
    Siva.
  • Hi Siva,

    The reset done by calling any API is called Soft Reset, not Hard Reset. Thus there is nothing like a API to do Hard Reset.

    Can you please try by 'HalFlashWrite' instead of 'OADTarget_writeFlash'? Also, are you writing at the correct address, where CRC has been stored?

    Thanks,

    Dhaval

  • Hi Dhaval,

                           Let me explain you how I have tried now.

    1. I have written only crc and shadow crc into 0x6000 - 0x6004 location and not doing any soft reset. So My Device is running in Current Image. I have read 10 bytes of memory location from flash programmer then I was able to see, in this memory locations 00,00,00,00 has been written. After that If I do hard reset then BIM is jumping into Image A.

    2. I have taken HAL_SYSTEM_RESET() function alone and I have kept in my application api and through UART messages I have checked whether reset was happening or not. Reset was happening.

    So both functions are working fine if I am checking independently but If I am adding both then problem is coming.

    Thanks,

    Siva.

  • Hi Siva,

    This is really weird. I am not sure then what is going wrong!

    But the function I have suggested you in my last reply that is working fine at my end followed by HAL_SYSTEM_RESET().

    Thanks,

    Dhaval

  • Hi Dhaval,
    After your suggestion I have made code like this.

    uint8_t crc[5] = {0x00,0x00,0x00,0x00};

    FlashProgram((uint8_t *)&crc, 0x6000,4);

    HAL_SYSTEM_RESET();

    Still I am facing the same problem. If I do reset then only application is jumping into the Image A or else it is not in the discoverable state.
    Can you please tell me if I am doing anything wrong.

    Thanks for your support in advance.

    Thanks,
    Siva.
  • Hi Siva,

    How did you derive address as 0x6000? Is it valid address? You can check the code of Image-A, where it is writing valid CRC value after successful completion of OAD.

    Thanks,
    Dhaval
  • Hi Siva,

    Did you find the solution for this problem? We are having the same issue.

    Regards
  • Ya It got solved. Will you please describe the procedure what you have followed with the output, then I can help you where is the problem.
  • hi, I'm glad to hear the issue is solved.

    The problem is when we are using the RESET profile , sometimes the device is stop functioning and we can't see "OAD Target A" (same problems you described). until an hardware reset.

    can you explain what you did to make it work?

    THANKS A LOT!

  • Ya Can you please explain the problem clearly. Because I have done this On Chip OAD with the stack of 2.0 But now the stack is 2.2.1 and 3.0.0

    So there is a chance of missing some configuration.

    For my case at that time

    uint8_t crc[5] = {0x00,0x00,0x00,0x00};

    FlashProgram((uint8_t *)&crc, 0x6000,4);

    HAL_SYSTEM_RESET();

    I done this changes and Done FOTA through CC2540 dongle and reset happened. Started working.

    So instead of flashing manually Do through BLE dongle it may help.

    Thanks,
    Siva.