This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

USB Bootloader for LPC2148

Hello all, I have programmed LPC2148 for using USB as secondary boot loader. Code was given by NXP only.
It says, when LPC2148 is connected to PC it will open flash memory as mass storage device and flash will be shown in .bin file.
Till this everything is fine.
To update the firmware one should delete that .bin file and copy new one there. I did the same. Code includes simple LED blink. But on giving power cycle code is not working.
If I program BLinkLed code using UART ISP it works correctly.

Document says in USB boot loader's firmware user code start sector should be 2. I did that also.

Do I need to change any settings is my blinkLed firmware so that code will get stored from 2nd sector? or is there any procedure?

Thank you..

  • Two things - one is that the project should specify the relevant start address so the linker places the code at the correct location.

    But the next thing is that the code must remap the interrupt vectors into RAM, since the binary isn't linked for address 0 where the processor expects the interrupt vector table.

  • Hello,
    Thank you. I have changed the starting address to address of sector 2 in Target Option -> IROM1 (start 0x2000 and size 0x7E000).
    While debugging it starts from this address only.

  • Yes, you have already said that. But that is only half of the issue I mentioned in my previous post.

    Have you adapted your code so that it maps the interrupt vector table into RAM? Because you can not get the LPC2148 to look for interrupt vectors in sector 2. But it is possible to remap a part of the RAM to overlay the lowest part of sector 0. Which allows the program to copy the interrupt vector table into this RAM block and have it show up at the start of sector 0 (overlaying the vector table from the NXP-supplied secondary bootloader) where the CPU expects it to be.

  • What I have done is:

    MEMMAP EQU 0xE01FC040 ; Memory Mapping Control

    ;IF :DEF:REMAP LDR R0, =MEMMAP ; IF :DEF:EXTMEM_MODE ; MOV R1, #3 ; ELIF :DEF:RAM_MODE MOV R1, #2 ; ELSE ; MOV R1, #1 ; ENDIF STR R1, [R0] ;ENDIF

    This should work, shouldn't it?

  • What have I done is:

    MEMMAP EQU 0xE01FC040 ; Memory Mapping Control

    ;IF :DEF:REMAP

    LDR R0, =MEMMAP

    ; IF :DEF:EXTMEM_MODE

    ; MOV R1, #3

    ; ELIF :DEF:RAM_MODE

    MOV R1, #2

    ; ELSE

    ; MOV R1, #1

    ; ENDIF

    STR R1, [R0]

    ;ENDIF

    This should work, shouldn't it?

  • That takes care of remapping - assuming that you have actually defined the required symbols - but what about "Which allows the program to copy the interrupt vector table into this RAM block"?

  • This what I done exactly:

    ; Memory Mapping (when Interrupt Vectors are in RAM)

    MEMMAP EQU 0xE01FC040 ; Memory Mapping Control

    IF :DEF:REMAP

    LDR R0, =MEMMAP

    IF :DEF:EXTMEM_MODE

    MOV R1, #3

    ELIF :DEF:RAM_MODE

    MOV R1, #2

    ELSE

    MOV R1, #1

    ENDIF

    STR R1, [R0]

    ENDIF

    ;Copy exception vectors to Internal RAM

    RAM_BASE EQU 0x40000000

    IF :DEF: RAM_INTVEC

    ADR R8, Vectors ; Source

    LDR R9, =RAM_BASE ; Destination

    LDMIA R8!, {R0-R7} ; Load Vectors

    STMIA R9!, {R0-R7} ; Store Vectors

    LDMIA R8!, {R0-R7} ; Load Handler Addresses

    STMIA R9!, {R0-R7} ; Store Handler Addresses

    ENDIF

    I have defined those symbols in option->ASM-> defines as
    REMAP RAM_MODE RAM_INTVEC
    is that right?

    Actually USB boot loader is defined for board MCB2140. I am using same code. They have defined some LEDs to monitor read write and configuration status. I connected the same on my board. Those LEDs glows correctly. Do I need to change anything for my board except LED connections?

  • This what I done exactly:

    ; Memory Mapping (when Interrupt Vectors are in RAM)
    
    MEMMAP EQU 0xE01FC040 ; Memory Mapping Control
    
    IF :DEF:REMAP
    
    LDR R0, =MEMMAP
    
    IF :DEF:EXTMEM_MODE
    
    MOV R1, #3
    
    ELIF :DEF:RAM_MODE
    
    MOV R1, #2
    
    ELSE
    
    MOV R1, #1
    
    ENDIF
    
    STR R1, [R0]
    
    ENDIF
    
    ;Copy exception vectors to Internal RAM
    
    RAM_BASE EQU 0x40000000
    
    IF :DEF: RAM_INTVEC
    
    ADR R8, Vectors ; Source
    
    LDR R9, =RAM_BASE ; Destination
    
    LDMIA R8!, {R0-R7} ; Load Vectors
    
    STMIA R9!, {R0-R7} ; Store Vectors
    
    LDMIA R8!, {R0-R7} ; Load Handler Addresses
    
    STMIA R9!, {R0-R7} ; Store Handler Addresses
    
    ENDIF
    


    I have defined those symbols in option->ASM-> defines as
    REMAP RAM_MODE RAM_INTVEC
    is that right?

    Actually USB boot loader is defined for board MCB2140. I am using same code. They have defined some LEDs to monitor read write and configuration status. I connected the same on my board. Those LEDs glows correctly. Do I need to change anything for my board except LED connections?

  • can you send the USB boot loader code for LPC2148

  • Can anyone give me the source code for USB Bootloader code for LPC2148 ?

  • can you send the USB boot loader code for LPC2148