problems with secondary bootloader on LPC1768 with MCP1700

I'm using µVision 4.50.0.0 with Keil MCB1700 with LPC1768.

I wrote a secondary boot-loader, that reads srecord file from usb and writes that into flash starting 0x20000.
The AN10866.pdf from NXP helped a lot.

The application itself is built with following changes:
Target Options IROM1 Start 0x20000 Size 0x60000
Asm options Define NO_CRP.

The following code should start my application after
successful update/validating the present firmware:

#define APPL_RUN_ADDR           0x00020000

__asm void boot_jump(U32 address)
{
    LDR SP, [R0]
    LDR PC, [R0, #4]
}


void run_appl()
{
     SCB->VTOR = APPL_RUN_ADDR & 0x1FFFF80;

    boot_jump(APPL_RUN_ADDR);
}


This code snippet is copied from nxp's AN10866.pdf, too.

But the firmware doesn't start reliable. Where do I stuck?

APPL_RUN_ADDR is defined to 0x20000

at 0x20004 there's 00020229 (this is the Reset_Handler fro my application, which I checked in the map file).

Unfortunately I don't find the AN10866.zip example files, to see how nxp's bootloader was built exactly.

What else have I forgotten to do?

Thanks in advance
Hubert

Parents
  • You should check a CRC or equivalent prior to loading and attempting to run ANY code downloaded. Insofaras the code to re-startup the processor, this works on 1768:

    
    void __SWI_0(void *(fp)())
    {
            UINT32 RegTemp;
    
            // Reset PCONP to RESET conditions
            PCONP = 0x001817BE;
    
            // Restore VIC slots to RESET conditions
            UninstallIrq(SPI1_INT);
    
            __asm
            {
                    MRS RegTemp, CPSR
                    ORR RegTemp, RegTemp, #0xC0       // Only in supv mode - disable interrupts
                    MSR CPSR_c, RegTemp
                    MRS RegTemp, SPSR
                    AND RegTemp, RegTemp, #0x1F       // Only in supv mode - set to RESET conditions
                    MSR SPSR_cxsf, RegTemp
            }
    
            (*fp)();
    }
    

    Disable interrupts and jump to the start of program code. This sequence MUST be accomplished while the processor is in the 'Supervisory Mode' of operation so that the program stacks and restricted registers can all be accessed and properly initialized by the main program startup code when it executes. HTH.

Reply
  • You should check a CRC or equivalent prior to loading and attempting to run ANY code downloaded. Insofaras the code to re-startup the processor, this works on 1768:

    
    void __SWI_0(void *(fp)())
    {
            UINT32 RegTemp;
    
            // Reset PCONP to RESET conditions
            PCONP = 0x001817BE;
    
            // Restore VIC slots to RESET conditions
            UninstallIrq(SPI1_INT);
    
            __asm
            {
                    MRS RegTemp, CPSR
                    ORR RegTemp, RegTemp, #0xC0       // Only in supv mode - disable interrupts
                    MSR CPSR_c, RegTemp
                    MRS RegTemp, SPSR
                    AND RegTemp, RegTemp, #0x1F       // Only in supv mode - set to RESET conditions
                    MSR SPSR_cxsf, RegTemp
            }
    
            (*fp)();
    }
    

    Disable interrupts and jump to the start of program code. This sequence MUST be accomplished while the processor is in the 'Supervisory Mode' of operation so that the program stacks and restricted registers can all be accessed and properly initialized by the main program startup code when it executes. HTH.

Children
More questions in this forum