Discussion Forum

LPC2368 bootloader and RL-ARM

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
julien M
Posted
29-Aug-2008 16:03 GMT
Toolset
ARM
New! LPC2368 bootloader and RL-ARM

Hello,

I developped an usb bootloader which works perfectly when I use an simple firmware, but which doesn't works with an firmware using RTX kernel.

Anyone can help me ?

Thanks

Read-Only
Author
Per Westermark
Posted
29-Aug-2008 17:17 GMT
Toolset
ARM
New! RE: LPC2368 bootloader and RL-ARM

You need to supply more information.

Are interrupts enabled/disabled when you start your application?

Are you in supervisor mode or user mode when you start your application?

Exactly what happens/doesn't happen?

Does the RTX application work ok if linked to start address 0, i.e. used without a boot loader?

Read-Only
Author
julien M
Posted
8-Sep-2008 10:25 GMT
Toolset
ARM
New! RE: LPC2368 bootloader and RL-ARM

Hello,

My RTX application works perfectly, it's the RTX_Blinky demo project.

Exactly what happens/doesn't happen?
It goes to the SWI_Handler

 SWI_Handler     B       SWI_Handler

Thanks for your help.

Read-Only
Author
Moshe Tal
Posted
10-Sep-2008 17:18 GMT
Toolset
ARM
New! RE: LPC2368 bootloader and RL-ARM

The problem is that the default LPC2368 behavior is to look for interrupt vectors table in the start of the flash (0x40000000).
Specific, The RTX application go there every OS switching (to SWI_handler).

But in your case the vectors table that reside in flash beginning is the bootloader one, not the one of RTX Application.

To resolve this problem, you have to add the following options to the Startup File (LPC2300.S) of your application, in Options - Asm - Define :
RAM_INTVEC REMAP RAM_MODE

Now the startup procedure will copy the interrupt vectors table to the RAM and will look for it there.
(I hope that your startup file version recognize all these options, if not I copy that in message end).

Additionally, you have to change memory area for application in Options for Target -> Target -> Read\Write memory area to start from 0x40000100 and contain only 0x7F00 (possible lower, but this for safty).
So, the application will leave the vectors table RAM untouchable.

Code for LPC2368.S
Insert if not exist before stack setup for each mode:

; Copy Exception Vectors to Internal RAM ---------------------------------------

                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


; 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
Read-Only
Author
julien M
Posted
11-Sep-2008 14:43 GMT
Toolset
ARM
New! RE: LPC2368 bootloader and RL-ARM

Ok, it works now.
Thank you very much

Read-Only
Author
Mark Lambert
Posted
19-Nov-2008 19:09 GMT
Toolset
ARM
New! RE: LPC2368 bootloader and RL-ARM

This is strange, I still dont understand why this is occurring.

1. The new code that I download (using my bootloader via USB) is built with the RTX kernal.

2. If my bootloader is built with an RTX then I can boot the new code correctly.

3. If my bootloader is built without an RTX then Im unable to boot the new code.

4. Both bootloaders (with or without an RTX) will execute code (that contains no RTX) correctly.

In both cases the new code starts at address 0x5000 and has the correct options in the startup file.

Any ideas why?

Read-Only
Author
Tamir Michael
Posted
9-Feb-2009 13:20 GMT
Toolset
ARM
New! RE: LPC2368 bootloader and RL-ARM

Mark,
I have the same issue. Have you managed to solve the problem?

Read-Only
Author
noom noise
Posted
2-Dec-2008 08:58 GMT
Toolset
ARM
New! RE: LPC2368 bootloader and RL-ARM

I used the code USB secondary ISP bootloader for LPC23xx from NXP, it does not work with RTX os.

How I can fix? please help.

Read-Only
Author
Tamir Michael
Posted
23-Jan-2009 22:29 GMT
Toolset
ARM
New! RE: LPC2368 bootloader and RL-ARM

Moshe,
I am working on a USB bootloader not operating with the presence of RTX. Please see here for a short description of my problem:
http://www.keil.com/forum/docs/thread14069.asp
I don't understand why using on chip peripherals prevents the application code from being interrupted. I see that the jump to application works, but if I dare to do it with a timer running of USB - the application will not get interrupted. the weird thing is that older revision of the code did not have that, but I don't see how a simple change in startup in main() can give me such a headache. Any ideas?

Read-Only
Author
Moshe Tal
Posted
18-Feb-2009 10:23 GMT
Toolset
ARM
New! RE: LPC2368 bootloader and RL-ARM

There is more problem (with ARM modes stacks setup) in startup file after bootloader.

You can to change the bootloader, so program user code will called in Supervisor mode or to add the following code to startup file (LPC2300.S) in the user program:

; Setup Stack for each mode ----------------------------------------------------

; Stack setup code will not run when MCU in User mode
; as occur when this code run after secondary boot loader
; The following code will do fake calling to Software interrupt to enter Supervisor mode
; so stacks init code will work properly.

SWI_RAM_ADDR    EQU             0x40000028
                                LDR             R8, =SWI_RAM_ADDR         ;
                                LDR             R7, [R8]                          ;Save SWI_Handler address
                                LDR             R9, =Stack_Set_Addr
                                STR             R9, [R8]                          ;Replace SWI_Handler (for next command) with Stack_Set_Addr
                                SWI             11                                        ;Just jump to Stack_Set_Addr in Supervisor mode

Stack_Set_Addr  DCD             Stack_Setup

Stack_Setup             STR             R7, [R8]                          ;Restore SWI_Handler address
;End of edit
                        LDR     R0, =Stack_Top

For detailes look in the dicussion in http://www.keil.com/forum/docs/thread13707.as

Next Thread | Thread List | Previous Thread Start a Thread | Settings