• AVR Freaks

Hot!EZBL Is there a way to delay the reset after the termination message?

Author
thoraz
Junior Member
  • Total Posts : 117
  • Reward points : 0
  • Joined: 2013/06/01 18:37:43
  • Location: 0
  • Status: offline
2020/10/01 08:22:27 (permalink)
0

EZBL Is there a way to delay the reset after the termination message?

On my PIC24FJ128GB406 I'm using the EZBL library and it works fine. But I want to know if there is the possibility to delay the reset after the firmware transmission. Is it possible?
#1

10 Replies Related Threads

    Jim Nickerson
    User 452
    • Total Posts : 6797
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: EZBL Is there a way to delay the reset after the termination message? 2020/10/01 09:08:50 (permalink)
    5 (1)
    YesSmile: Smile
    #2
    thoraz
    Junior Member
    • Total Posts : 117
    • Reward points : 0
    • Joined: 2013/06/01 18:37:43
    • Location: 0
    • Status: offline
    Re: EZBL Is there a way to delay the reset after the termination message? 2020/10/02 06:55:00 (permalink)
    0
    ...aaaaand...how I should do it?
    #3
    Jim Nickerson
    User 452
    • Total Posts : 6797
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: EZBL Is there a way to delay the reset after the termination message? 2020/10/02 06:57:08 (permalink)
    0
    Which version of EZBL ( the down load link ) are you using ?
    What is your development environment ( tool versions, PC, OS ) ?
     
    #4
    thoraz
    Junior Member
    • Total Posts : 117
    • Reward points : 0
    • Joined: 2013/06/01 18:37:43
    • Location: 0
    • Status: offline
    Re: EZBL Is there a way to delay the reset after the termination message? 2020/10/02 07:04:21 (permalink)
    0
    The EZBL version is the 2.11 (here the link). I'm using MPLAB X v5.30 with XC16 v1.50 in Windows 10 OS. The microcontroller is the PIC24FJ128GB406.
    #5
    Jim Nickerson
    User 452
    • Total Posts : 6797
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: EZBL Is there a way to delay the reset after the termination message? 2020/10/02 07:36:13 (permalink)
    0
    Which of the examples are you using ?
    #6
    thoraz
    Junior Member
    • Total Posts : 117
    • Reward points : 0
    • Joined: 2013/06/01 18:37:43
    • Location: 0
    • Status: offline
    Re: EZBL Is there a way to delay the reset after the termination message? 2020/10/02 08:02:48 (permalink)
    0
    I started from the ex_boot_uart example and then I wrote my application.
    #7
    Jim Nickerson
    User 452
    • Total Posts : 6797
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: EZBL Is there a way to delay the reset after the termination message? 2020/10/02 09:19:34 (permalink)
    0
    I notice MCC ( Mplab Code Configurator ) handles this processor and has a boot loader.
    Is there some reason you are not using it ?
    If you were using the MCC version the reset happens here and this would be the place to add your delay.
    I presume your system also has a reset command sent to the bootloader.

    case RESET_DEVICE:
       ResetDevice();
       return BOOT_COMMAND_SUCCESS;

    #8
    Jim Nickerson
    User 452
    • Total Posts : 6797
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: EZBL Is there a way to delay the reset after the termination message? 2020/10/02 09:33:19 (permalink)
    0
    In ex_boot_uart, main.c I see this code
    The formatting sucks as it is a copy paste from the source.
    It seems "EZBL_StartAppIfPresent()" actually starts the code
    Does your code look like this ????

    if(now - appLaunchTimer > EZBL_bootCtx.timeout)
    {
        // If auto-baud is used, automatically reset the UART back to
        // auto-baud mode while idle for longer than the timeout.
        if((EZBL_COMBaud <= 0) && (EZBL_COM_RX == 0))
            EZBL_FIFOSetBaud(EZBL_COMBootIF, EZBL_COMBaud); // This will set EZBL_COMBootIF->activity.other,
            //so appLaunchTimer will also be reset on next loop iteration
        if(EZBL_IsAppPresent())
       {
            LEDOff(0xFF);

    // Optionally turn off all Bootloader ISRs and forward the
    // interrupts to the Application so we become a passive classic
    // bootloader.
    // NOTE: You are giving up useful timing and communications APIs
    // if you do this. Also, the automatic bootloader wakeup upon
    // .bl2 file presentation won't work. To minimize flash, the
    // App can just reuse the bootloader APIs as is, keeping the
    // NOW Timer interrupt and communications ISRs active in the
    // background (which have minimal run-time execution cost).
    //EZBL_RAMSet((void*)&IEC0, 0x00, (unsigned int)&IPC0 - (unsigned int)&IEC0); // Clear every bit in all IECx Interrupt Enable registers
    //EZBL_ForwardAllIntToApp(); // Forward all Interrupts to the Application
    //NOW_EndAllTasks(); // Terminates the EZBL_BootloaderTask() from executing via background NOW ISR and when a NOW_32() or NOW_64() call is made which indirectly needs the timer ISR to execute and perform a carry propagation.
     
    EZBL_StartAppIfPresent(); // Sets EZBL_appIsRunning = 0xFFFF and temporarily disables IPL6 and lower interrupts before launching Application
     
    }
    }

     
    #9
    thoraz
    Junior Member
    • Total Posts : 117
    • Reward points : 0
    • Joined: 2013/06/01 18:37:43
    • Location: 0
    • Status: offline
    Re: EZBL Is there a way to delay the reset after the termination message? 2020/10/05 01:05:20 (permalink)
    0
    JANickerson
    I notice MCC ( Mplab Code Configurator ) handles this processor and has a boot loader.
    Is there some reason you are not using it ?
    If you were using the MCC version the reset happens here and this would be the place to add your delay.
    I presume your system also has a reset command sent to the bootloader.

     
    case RESET_DEVICE:
       ResetDevice();
       return BOOT_COMMAND_SUCCESS;
     





    Thanks for the advice, but actually I wrote my own GUI for my system with the part to update the firmware (I recreated the flashing tool ezbl_comm in Labview following its comunication protocol) so I hanven't time now to change the bootloader and recreate the application. But in the future, for my new applications, I'll keep in mind your advice. Thanks.
     
    JANickerson
    In ex_boot_uart, main.c I see this code
    The formatting sucks as it is a copy paste from the source.
    It seems "EZBL_StartAppIfPresent()" actually starts the code
    Does your code look like this ????

     
    if(now - appLaunchTimer > EZBL_bootCtx.timeout)
    {
        // If auto-baud is used, automatically reset the UART back to
        // auto-baud mode while idle for longer than the timeout.
        if((EZBL_COMBaud <= 0) && (EZBL_COM_RX == 0))
            EZBL_FIFOSetBaud(EZBL_COMBootIF, EZBL_COMBaud); // This will set EZBL_COMBootIF->activity.other,
     
            //so appLaunchTimer will also be reset on next loop iteration
     
        if(EZBL_IsAppPresent())
       {
            LEDOff(0xFF);

    // Optionally turn off all Bootloader ISRs and forward the
    // interrupts to the Application so we become a passive classic
    // bootloader.
    // NOTE: You are giving up useful timing and communications APIs
    // if you do this. Also, the automatic bootloader wakeup upon
    // .bl2 file presentation won't work. To minimize flash, the
    // App can just reuse the bootloader APIs as is, keeping the
    // NOW Timer interrupt and communications ISRs active in the
    // background (which have minimal run-time execution cost).
    //EZBL_RAMSet((void*)&IEC0, 0x00, (unsigned int)&IPC0 - (unsigned int)&IEC0); // Clear every bit in all IECx Interrupt Enable registers
    //EZBL_ForwardAllIntToApp(); // Forward all Interrupts to the Application
    //NOW_EndAllTasks(); // Terminates the EZBL_BootloaderTask() from executing via background NOW ISR and when a NOW_32() or NOW_64() call is made which indirectly needs the timer ISR to execute and perform a carry propagation.
     
     
     
    EZBL_StartAppIfPresent(); // Sets EZBL_appIsRunning = 0xFFFF and temporarily disables IPL6 and lower interrupts before launching Application
     
     
     
    }
    }
     

     




    In this example EZBL_StartAppIfPresent() is a function that runs my application but when the bootloader is already started. My question is different:

    When I flash my new firmware to my device, after I sent all the firmware's packets, the bootloader tell me that the whole process is terminated successfully with the status code 0x0000 and 0x0001, indicating the final disposition of the firmware update (Phase 4 in the EZBL Communication Protocol pdf). After about 300us of this response, the CPU restarts.
    I want know if is possible delay that time (300us) between the final status code response (0x0000 0x0001) from bootloader anche the CPU restart.
    #10
    Jim Nickerson
    User 452
    • Total Posts : 6797
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: EZBL Is there a way to delay the reset after the termination message? 2020/10/05 07:19:45 (permalink)
    0
    Maybe you could add a line of code to turn on a Led just before "EZBL_StartAppIfPresent()" is called so you might see if this line of code is what starts your code after the final response.
    I must ask why is it you want to add such a delay ?
    #11
    Jump to:
    © 2020 APG vNext Commercial Version 4.5