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..
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:
;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
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)
IF :DEF:REMAP
IF :DEF:EXTMEM_MODE
MOV R1, #3
ELIF :DEF:RAM_MODE
ELSE
MOV R1, #1
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
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?
; 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