run from LPC-E2214 onchip SRAM

Hi,

I’ve been trying to run a home-grown code on LPC-E2214 onchip SRAM and keep failing. I found one anomaly so far. When tried to “Run from Address” &H40000000 button of LPC 2000 Flash Utility RAM Buffer Operations window, the processor starts code stored in on-chip flash as if PC register was address 0.

  • on-chip flash contains “H2214_Board_Test.hex” It runs just fine and responds to B1 and B2 buttons.

  • BSL jumper is kept closed (tied) when Run from Address button is depressed.

What I expect is my code turns on Num LCD backlight first and then emits some messages on UART1. But, the processor starts BOARD TEST instead. It might be a possible reasoning my code gets failure very early before MEMMAP register is switched to onchip SRAM and jumps to address 0, then kick-starts BOARD TEST. I’m not sure about how to run downloaded code in onchip SRAM. Any comments?

Here goes the very beginning of my code;

e22lpc.elf:     file format elf32-littlearm

Disassembly of section .text:

40000000 <_start>:
40000000:       e59ff018        ldr     pc, [pc, #24]   ; 40000020 <Lexcpt>
40000004:       e59ff018        ldr     pc, [pc, #24]   ; 40000024 <Lexcpt+0x4>
40000008:       e59ff018        ldr     pc, [pc, #24]   ; 40000028 <Lexcpt+0x8>
4000000c:       e59ff018        ldr     pc, [pc, #24]   ; 4000002c <Lexcpt+0xc>
40000010:       e59ff018        ldr     pc, [pc, #24]   ; 40000030 <Lexcpt+0x10>
40000014:       e1a00000        nop                     (mov r0,r0)
40000018:       e59ff018        ldr     pc, [pc, #24]   ; 40000038 <Lexcpt+0x18>
4000001c:       e59ff018        ldr     pc, [pc, #24]   ; 4000003c <Lexcpt+0x1c>

40000020 <Lexcpt>:
40000020:       40000200        andmi   r0, r0, r0, lsl #4
40000024:       40000258        andmi   r0, r0, r8, asr r2
40000028:       40000258        andmi   r0, r0, r8, asr r2
4000002c:       40000258        andmi   r0, r0, r8, asr r2
40000030:       40000258        andmi   r0, r0, r8, asr r2
40000034:       00000000        andeq   r0, r0, r0
40000038:       40000258        andmi   r0, r0, r8, asr r2
4000003c:       40000258        andmi   r0, r0, r8, asr r2
        ...

40000200 <Lreset>:
40000200:       e28f0078        add     r0, pc, #120    ; 0x78
40000204:       e890001e        ldmia   r0, {r1, r2, r3, r4}
40000208:       e321f0d1        msr     CPSR_c, #209    ; 0xd1
4000020c:       e1a0d001        mov     sp, r1
; ...
; assign values to stack pointer registers, clear BSS and start C code.

While I have some ARM9 experience including home-made bootloader and NetBSD porting for it, this is a very first time encounter with ARM7/LPC SoC.


God, I, a poor programmer, confess I’m always silly and miserable about crafting a program. I found E2214 Num LCD backlight LED useful as a crude debug’ng clue to gauge and measure how far my code could run. My program now can reach to main() and detect B1/B2 button depressed. I removed countable errors made by me so far. Although I’m still failing to emit characters on UART1, I’m confident I will soon.

Now I can guess the reason why starting my program in internal SRAM ends up with kickstarting program stored in flash. My code contains lines to set LPC watchdog timer to expire immediately (== suicidal action) as panic sequence. So, jump’ng to address 0 (== starting flash proram) was a proof that my code could work a while and then hit hard with the panic sequence…