[SOLVED]Cortex-M0+ does not reset via NVIC_SystemReset()when Jlink is connected

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED]Cortex-M0+ does not reset via NVIC_SystemReset()when Jlink is connected

    Dear Segger,

    I am using a Segger Link Plus and would like to use the Cortex-M NVIC feature to reset the firmware by itself. Unfortunately the Cortex-M0+ (ATSAMD21G18) does not reset when the JLink is connected.
    No Jlink related software is running. When I disconnect the Segger from target reset works fine.


    The reset function used looks like:

    Source Code

    1. __STATIC_INLINE void NVIC_SystemReset(void)
    2. {
    3. __DSB(); /* Ensure all outstanding memory accesses included
    4. buffered write are completed before reset */
    5. SCB->AIRCR = ((0x5FA << SCB_AIRCR_VECTKEY_Pos) |
    6. SCB_AIRCR_SYSRESETREQ_Msk);
    7. __DSB(); /* Ensure completion of memory access */
    8. while(1); /* wait until reset */
    9. }



    OS:
    MacOS 10.12.6

    Segger Software: Latest V6.18c

    JLink Version:
    Firmware: J-Link V10 compiled Jul 28 2017 08:59:01
    Hardware version: V10.10


    Any hint?

    regards

    SPR
  • Hi again,

    I found a probably interesting pattern:

    1) Flash with JLinkExe my target
    2) Reset by firmware does not work
    3) Remove the JLink form USB and plugin again (target reboots)
    4) Reset by firmware does work now
  • Hello Stefan,

    Thank you for your inquiry.

    Are you using a eval board or custom hardware?
    Is some kind of bootloader part of your application?

    Best regards,
    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hello Stefan,

    Unfortunately that particular target device has a hardware bug which halts the device after each reset.
    To release it from reset the easiest thing to do is to turn the target device off and on again.

    More information can be found in the latest SAMD21 datasheet in chapter 40.1.1.2

    Best regards,
    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi Nino,

    this is great news, not because of the D21 is buggy but now I know why the issue happens. Many, many thanks for pointing me to the errata. Great support from Segger!

    I assume that I cannot supply the workaroud noted in the datasheet in my firmware itself. At least I tried and it does not work.



    Fix/workaround:
    The CPU must be released from the ""CPU Reset Extension"" either by writing a one in the DSU STATUSA.


    Source Code

    1. Dsu* pDsu = DSU;
    2. pDsu->STATUSA.bit.CRSTEXT = 1;


    So I really have to un- and re-plug the Segger JLink after flashing to get the reset by firmware work.

    regards

    SPR
  • Hi Stefan,

    Many, many thanks for pointing me to the errata. Great support from Segger!

    Thank you for the flowers ;)

    I assume that I cannot supply the workaroud noted in the datasheet in my firmware itself. At least I tried and it does not work.

    Unfortunately this "workaround" is only available through the debug interface. The J-Link debugger has the workaround implemented, that is why the firmware reset works while debugging, but the J-Link does not know that you issued a reset with your application when not debugging so the chip stays in the "reset loop".

    So I really have to un- and re-plug the Segger JLink after flashing to get the reset by firmware work.

    It should be enough to power cycle your target device. The J-Link can stay connected.

    Best regards,
    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.