[SOLVED] Reset device from Ozone vs from JLinkExe (JTrace)

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

  • [SOLVED] Reset device from Ozone vs from JLinkExe (JTrace)

    For some time I've been using this to correctly reset device to "boardloader" (first execution stage, we have two additional, bootloader and firmware, each in separate ELF file):

    Source Code

    1. void AfterTargetReset (void) {
    2. unsigned int SP;
    3. unsigned int PC;
    4. unsigned int VectorTableAddr;
    5. VectorTableAddr = 0x8000000; //boardloader vector address
    6. if (VectorTableAddr != 0xFFFFFFFF) {
    7. SP = Target.ReadU32(VectorTableAddr);
    8. Target.SetReg("SP", SP);
    9. } else {
    10. Util.Log("Project file error: failed to get program base");
    11. }
    12. PC = Target.ReadU32(VectorTableAddr + 4);
    13. Target.SetReg("PC", PC);
    14. }
    Display All

    It worked quite well, though for some reason it doesn't anymore (currently Ozone 3.20c). The code jumps at the right address, but it gets stuck on TRNG initialization (STM32F427VI).

    However when resetting from JLinkExe via SYSRESETREQ & VECTRESET bit (or GDB connected to JLink GDB server), it always works.

    Any way how to put this kind of reset into Ozone script?
  • I think I solved it, adding:



    Source Code

    1. void TargetReset (void) {
    2. unsigned int AIRCR;
    3. unsigned int SCB_AIRCR_VECTKEY;
    4. unsigned int SCB_AIRCR_VECTRESET;
    5. AIRCR = 0xE000ED0C;
    6. SCB_AIRCR_VECTKEY = 0x5fa0000;
    7. SCB_AIRCR_VECTRESET = 0x1;
    8. *AIRCR = SCB_AIRCR_VECTRESET | SCB_AIRCR_VECTRESET;
    9. //
    10. // unsigned int SP;
    11. // unsigned int PC;
    12. // unsigned int VectorTableAddr;
    13. //
    14. // VectorTableAddr = Program.GetBaseAddr();
    15. //
    16. // if (VectorTableAddr != 0xFFFFFFFF) {
    17. // SP = Target.ReadU32(VectorTableAddr);
    18. // Target.SetReg("SP", SP);
    19. // } else {
    20. // Util.Log("Project file error: failed to get program base");
    21. // }
    22. //
    23. // PC = Elf.GetEntryPointPC();
    24. //
    25. // if (PC != 0xFFFFFFFF) {
    26. // Target.SetReg("PC", PC);
    27. // } else if (VectorTableAddr != 0xFFFFFFFF) {
    28. // PC = Target.ReadU32(VectorTableAddr + 4);
    29. // Target.SetReg("PC", PC);
    30. }
    Display All
    I have no idea why I can't indent the code or remove the comments, but it just works this way ¯\_(ツ)_/¯

    The post was edited 4 times, last by zamniah: formatting + typo fix ().

  • Hello,

    Thank you for your inquiry.
    Ozone will use the same reset JLinkExe uses as default, so there is probably something else wrong with your project setup.
    For reference here are guides on how to set up Ozone to debug setups with e.g. bootloaders:
    wiki.segger.com/Debug_on_a_Target_with_Bootloader
    wiki.segger.com/Debug_Bootload…ion_in_same_Ozone_project


    We do not recommend to overwrite the TargetReset() function and should only be overwritten where the default reset behaviour is not working and a custom reset must be performed.


    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.