Hot!Harmony 2.04 Bootloader - Wont' work for real application.

Page: 12 > Showing page 1 of 2
Author
mrpackethead
packet mangler
  • Total Posts : 845
  • Reward points : 0
  • Joined: 2007/04/01 23:33:39
  • Location: 0
  • Status: online
2017/11/13 17:57:16 (permalink)
0

Harmony 2.04 Bootloader - Wont' work for real application.

I've created from  scratch, my 2.04 app, its compiled with xc1.44 for a PIC32MZ2048EFM064   i have used MHC to add the applicaiton linker file to the application.  Without the linker file the applicaton runs just fine.
 
Ive used the basic bootloader example app, and made a couple of modifications to it for on my board. No changes however it its linker file.. This is using the UDP bootloader.

The bootloader loads and runs. I'm able to connect to it with the bootloader client,  it shows the version,  I'm able to load the hex file,  Erase / Program and Verify successfully.  If i Tell it to run the Application the bootloader just restarts. 
 
My application has a web server, but its pages in flash are located well above the reset location.

The bootloaders linker file is here.  https://pastebin.com/DMfHfDwL
The applications linker file is here. https://pastebin.com/WrnzY2Xt
 
 
 
 
 



 
 
 
 
 
 
 
 
#1

28 Replies Related Threads

    mrpackethead
    packet mangler
    • Total Posts : 845
    • Reward points : 0
    • Joined: 2007/04/01 23:33:39
    • Location: 0
    • Status: online
    Re: Harmony 2.04 Bootloader - Wont' work for real application. 2017/11/13 17:59:23 (permalink)
    0
    Srry about the 2nd post.  Forum issues.     What is happening here.
    #2
    friesen
    Super Member
    • Total Posts : 1744
    • Reward points : 0
    • Joined: 2008/05/08 05:23:35
    • Location: Indiana, USA
    • Status: offline
    Re: Harmony 2.04 Bootloader - Wont' work for real application. 2017/11/13 19:45:03 (permalink)
    0
    Did you compile you application using the right linker script? Select bootloader and check application.

    Erik Friesen
    #3
    mrpackethead
    packet mangler
    • Total Posts : 845
    • Reward points : 0
    • Joined: 2007/04/01 23:33:39
    • Location: 0
    • Status: online
    Re: Harmony 2.04 Bootloader - Wont' work for real application. 2017/11/13 20:04:53 (permalink)
    0
    Yes, double checked that i've used the correct linker files.
     
     
    post edited by mrpackethead - 2017/11/13 22:07:03
    #4
    mrpackethead
    packet mangler
    • Total Posts : 845
    • Reward points : 0
    • Joined: 2007/04/01 23:33:39
    • Location: 0
    • Status: online
    Re: Harmony 2.04 Bootloader - Wont' work for real application. 2017/11/14 01:27:21 (permalink)
    3 (1)
    I'm going to take a wild guess that i've got an interupt problem.     I joined the bootloader And app ( using a loadable project ),  and debugged it.   after the jump to the applicaiton,  the code starts running, but gets caught up in in my intialisation,  ( Note, it runs fine as standalone )..  Its trying to get the IP stack up, but never quite gets there..

    How do i deal to the interupts.


    #5
    qhb
    Superb Member
    • Total Posts : 6257
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: Harmony 2.04 Bootloader - Wont' work for real application. 2017/11/14 03:36:14 (permalink)
    3 (1)
    The bootloader should disable all interrupts before jumping to the app, as the app will be assuming it is freshly coming out of a reset.
     
    #6
    moser
    Super Member
    • Total Posts : 278
    • Reward points : 0
    • Joined: 2015/06/16 02:53:47
    • Location: 0
    • Status: offline
    Re: Harmony 2.04 Bootloader - Wont' work for real application. 2017/11/14 04:36:55 (permalink)
    0
    I agree with qhb. Disable interrupts globally and also each single interrupt which is used in the bootloader.
     
    If the correct handling of the interrupts doesn't help you, then maybe you should inspect the RCON register, to get the information what is causing the reset. If the reason was DMTO or WDTO and your application is using the deadman timer (DMT) or watchdog timer (WDT) then try to disable those, just to see if those are causing the issue.
     
    Also you could try to implement the error handlers (e.g. _general_exception_handler() _simple_tlb_refill_exception_handler() _cache_err_exception_handler() _bootstrap_exception_handler() _DefaultInterrupt() ...) for both bootloader and application and set break points there, to see if those are called.
    post edited by moser - 2017/11/14 04:42:18
    #7
    NKurzman
    A Guy on the Net
    • Total Posts : 15081
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: Harmony 2.04 Bootloader - Wont' work for real application. 2017/11/14 07:02:13 (permalink)
    0
    They had priviously not disabled all the interupt flags the enabled. I thought they fixed it. Check that all the IE registers are zero or clear them. The master interrupt is no enough.
    #8
    aschen0866
    Super Member
    • Total Posts : 4175
    • Reward points : 0
    • Joined: 2006/01/08 22:18:32
    • Location: San Diego
    • Status: offline
    Re: Harmony 2.04 Bootloader - Wont' work for real application. 2017/11/14 08:23:14 (permalink)
    4 (1)
    One could do is to define a persistent/coherent word, write a special value to it, issue a soft reset (to reset all SFRs to their reset values). After the CPU restarts, it sees this special value then jump to the application immediately without doing anything else.
    #9
    mrpackethead
    packet mangler
    • Total Posts : 845
    • Reward points : 0
    • Joined: 2007/04/01 23:33:39
    • Location: 0
    • Status: online
    Re: Harmony 2.04 Bootloader - Wont' work for real application. 2017/11/14 12:49:01 (permalink)
    0
    I've confirmed this morning that with the 'standard' linker files that Harmony uses in 2.04, that the bootloader will jump to the application. I'm able to debug it and see where it gets up to.  That is a good start.

    I was pretty confident that the bootloader in 2.03 had fixed the interupt problem ( i have got it working and did'tn need to change anything ). It looks like in 2.04 this problem is back.
     
     
    #10
    mrpackethead
    packet mangler
    • Total Posts : 845
    • Reward points : 0
    • Joined: 2007/04/01 23:33:39
    • Location: 0
    • Status: online
    Re: Harmony 2.04 Bootloader - Wont' work for real application. 2017/11/14 13:48:46 (permalink)
    0
    this is a snippet from harmony 2.03b's bootloader.c  ( line 529 ) where the bootloader jumps to the applicaiton
     
      case BOOTLOADER_ENTER_APPLICATION:
    #if(BOOTLOADER_STATE_SAVE == 1)
                SYS_DEVCON_InstructionCacheFlush();
                SwapFlashPanels();
    #else
                /* Do a soft reset in order to reset peripherals */
                /* Disable Global Interrupts */
                PLIB_INT_Disable(INT_ID_0);
                if (bootloaderData.StartAppFunc != NULL)
                    bootloaderData.StartAppFunc();
                fptr = (void (*)(void))BOOTLOADER_RESET_ADDRESS;
                fptr();
    #endif
                break;

     
    Is this enough?
    post edited by mrpackethead - 2017/11/14 13:58:41
    #11
    mrpackethead
    packet mangler
    • Total Posts : 845
    • Reward points : 0
    • Joined: 2007/04/01 23:33:39
    • Location: 0
    • Status: online
    Re: Harmony 2.04 Bootloader - Wont' work for real application. 2017/11/14 14:03:16 (permalink)
    0
    Version 2.04 is different;   It  calls another function ( Enter_Applicaiton() ).  It is however seemingly disabling the globl interupts.
     
            case BOOTLOADER_ENTER_APPLICATION:
    #if(BOOTLOADER_LIVE_UPDATE_STATE_SAVE != 1)
                Enter_Application();
    #endif
                break;

    static void Enter_Application(void)
    {
        void (*fptr)(void);

        /* Set default to APP_RESET_ADDRESS */
        fptr = (void (*)(void))APP_RESET_ADDRESS;

    #if(BOOTLOADER_LIVE_UPDATE_SWITCHER == 1)
        T_FLASH_ID *lower_flash_id = LOWER_FLASH_ID_READ;
        T_FLASH_ID *upper_flash_id = UPPER_FLASH_ID_READ;

        SYS_DEVCON_InstructionCacheFlush();

        /* Application has been programmed first time into flash panel 1 by the bootloader */
        if( *(uint32_t *)LOWER_FLASH_ID_READ == FLASH_ID_CHECKSUM_CLR &&
            *(uint32_t *)UPPER_FLASH_ID_READ == FLASH_ID_CHECKSUM_CLR)
        {
            /* Program Checksum and initial ID's for both panels*/
            T_FLASH_ID low_flash_id = { 0 };
            T_FLASH_ID up_flash_id = { 0 };
     
            low_flash_id.flash_id = 1;
            low_flash_id.checksum_start = FLASH_ID_CHECKSUM_START;
            low_flash_id.checksum_end = FLASH_ID_CHECKSUM_END;

            up_flash_id.flash_id = 0;
            up_flash_id.checksum_start = FLASH_ID_CHECKSUM_START;
            up_flash_id.checksum_end = FLASH_ID_CHECKSUM_END;
            
            APP_NVMQuadWordWrite((void *)LOWER_FLASH_ID_BASE_ADDRESS, (uint32_t *)&low_flash_id);
            APP_NVMQuadWordWrite((void *)UPPER_FLASH_ID_BASE_ADDRESS, (uint32_t *)&up_flash_id);
        }
        /* If both the panels have proper checksum*/
        else if((lower_flash_id->checksum_start == FLASH_ID_CHECKSUM_START) &&
                (lower_flash_id->checksum_end == FLASH_ID_CHECKSUM_END) &&
                (upper_flash_id->checksum_start == FLASH_ID_CHECKSUM_START) &&
                (upper_flash_id->checksum_end == FLASH_ID_CHECKSUM_END))
        {
            if(upper_flash_id->flash_id > lower_flash_id->flash_id)
            {
                SwapFlashPanels();
            }
        }
        /* Fallback Cases when either of Panels checksum is corrupted*/
        else if((upper_flash_id->checksum_start == FLASH_ID_CHECKSUM_START) &&
                (upper_flash_id->checksum_end == FLASH_ID_CHECKSUM_END))
        {
            SwapFlashPanels();
        }
    #endif // BOOTLOADER_LIVE_UPDATE_SWITCHER == 1
        /* Disable Global Interrupts and Jump to Application*/
        PLIB_INT_Disable(INT_ID_0);
        if (bootloaderData.StartAppFunc != NULL)
            bootloaderData.StartAppFunc();
        fptr();
    }



    #12
    mrpackethead
    packet mangler
    • Total Posts : 845
    • Reward points : 0
    • Joined: 2007/04/01 23:33:39
    • Location: 0
    • Status: online
    Re: Harmony 2.04 Bootloader - Wont' work for real application. 2017/11/14 14:36:25 (permalink)
    0
    Debugging the bootloader is hard work, as you can't get it to compile unoptimized,     However this is what i have found. Just after the Global interupts are disabled, all of the IE registers are zero.

    the if registers are not all zero..    
     
     
    post edited by mrpackethead - 2017/11/14 14:48:09

    Attached Image(s)

    #13
    mrpackethead
    packet mangler
    • Total Posts : 845
    • Reward points : 0
    • Joined: 2007/04/01 23:33:39
    • Location: 0
    • Status: online
    Re: Harmony 2.04 Bootloader - Wont' work for real application. 2017/11/14 14:41:49 (permalink)
    0
    moser
    If the correct handling of the interrupts doesn't help you, then maybe you should inspect the RCON register, to get the information what is causing the reset. If the reason was DMTO or WDTO and your application is using the deadman timer (DMT) or watchdog timer (WDT) then try to disable those, just to see if those are causing the issue.



    The DMTO / and WDTO are not being used, and not being called.    I'm also not 
    #14
    mrpackethead
    packet mangler
    • Total Posts : 845
    • Reward points : 0
    • Joined: 2007/04/01 23:33:39
    • Location: 0
    • Status: online
    Re: Harmony 2.04 Bootloader - Wont' work for real application. 2017/11/14 15:45:09 (permalink)
    0
    The only two interupts are the timer and the ethernet, and i've tryed disabling them and clearing the flags...  makes no difference.



    #endif // BOOTLOADER_LIVE_UPDATE_SWITCHER == 1
        /* Disable Global Interrupts and Jump to Application*/
        PLIB_INT_SourceDisable(INT_ID_0,INT_SOURCE_TIMER_1);
        PLIB_INT_SourceDisable(INT_ID_0,INT_SOURCE_ETH_1);
        PLIB_INT_Disable(INT_ID_0);
        PLIB_INT_SourceFlagClear(INT_ID_0,INT_SOURCE_TIMER_1);
        PLIB_INT_SourceFlagClear(INT_ID_0,INT_SOURCE_ETH_1);
               
        if (bootloaderData.StartAppFunc != NULL)
            bootloaderData.StartAppFunc();
        fptr();
    }

    #15
    NKurzman
    A Guy on the Net
    • Total Posts : 15081
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: Harmony 2.04 Bootloader - Wont' work for real application. 2017/11/14 15:49:25 (permalink)
    0
    Disabling the Global Interrupt Enable is not enough.  Harmony assumes the reset values and enables the gloabla flag before all of the interrupts have been configured. ALL the IE Registers must be cleared IF the Harmony Bootloader is not doing it.
    #16
    mrpackethead
    packet mangler
    • Total Posts : 845
    • Reward points : 0
    • Joined: 2007/04/01 23:33:39
    • Location: 0
    • Status: online
    Re: Harmony 2.04 Bootloader - Wont' work for real application. 2017/11/14 16:07:41 (permalink)
    0
    NKurzman
    Disabling the Global Interrupt Enable is not enough.  Harmony assumes the reset values and enables the gloabla flag before all of the interrupts have been configured. ALL the IE Registers must be cleared IF the Harmony Bootloader is not doing it.



    How do I  clear these IE registers? I'm   assuming this is done on the bootloader before it jumps to the applicaiton?
     
     



    #17
    NKurzman
    A Guy on the Net
    • Total Posts : 15081
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: offline
    Re: Harmony 2.04 Bootloader - Wont' work for real application. 2017/11/14 16:15:19 (permalink)
    0
    PLIB_INT_Disable(INT_ID_0); // Disable Global Interrupts
    IEC0 = 0x0000; // Disable All individual interrupts
    IEC1 = 0x0000;
    IEC2 = 0x0000;
    IEC3 = 0x0000;
    IEC4 = 0x0000;
    IEC5 = 0x0000;
     
    If you are debugging you can see if any of these are nonzero.  The should all be cleared.  If not it is a Bug.
    There should be a  PLIB_INT_SourceDisable(INT_ID_0,??? for each interrupt enabled.)
    #18
    mrpackethead
    packet mangler
    • Total Posts : 845
    • Reward points : 0
    • Joined: 2007/04/01 23:33:39
    • Location: 0
    • Status: online
    Re: Harmony 2.04 Bootloader - Wont' work for real application. 2017/11/14 16:30:01 (permalink)
    0
    Thanks, however unfortunately that didn't make any difference.
     
    I'd already debugged it and had been checkign that the IE registers where clear..    
    #19
    mrpackethead
    packet mangler
    • Total Posts : 845
    • Reward points : 0
    • Joined: 2007/04/01 23:33:39
    • Location: 0
    • Status: online
    Re: Harmony 2.04 Bootloader - Wont' work for real application. 2017/11/15 01:04:10 (permalink)
    0
    I checked the state of the interupt flags when it jumps to the applciaiton ( at the start of main() ) and they are all clear.        The applicaiton is running. It does get there.  It just cant seem to bring up the ethernet stack at all.
     
    #20
    Page: 12 > Showing page 1 of 2
    Jump to:
    © 2017 APG vNext Commercial Version 4.5