/* soc */ .equ GPIOA, 0xC80B0000 .equ GPIOD, 0xC80E0000 .equ CGU_PERI, 0xC80F0014 .equ CCU_BASE, 0xC8100000 /* DO NOT TOUCH */ originalentry: .word 0 /* This value is filled in by mkamsboot */ /* enable gpio clock */ ldr r1, =CGU_PERI ldr r2, [r1] mov r0, #0x10000 /* gpio : bit 16 */ orr r2, r2, r0 str r2, [r1] /* check hold button / usb connection */ ldr r1, =GPIOA mov r2, #0 strb r2, [r1, #0x400] /* gpioa_dir */ ldrb r4, [r1, #0x120] /* pin 3 : hold, 6 : usb */ cmp r4, #0 bne resume /* resume OF if set */ /* NOW YOU CAN TOUCH */ /* from here we can run bad code, infinite loops, etc .. */ /* copy the OF from ROM into RAM */ mov r0, #0x20000 /* OF size */ mov r1, #0x81000000 /* RAM */ mov r2, #0x0 /* ROM */ loop_load: subs r0, r0, #4 /* word copy */ ldr r3, [r2, r0] str r3, [r1, r0] bne loop_load ldr r1, =CCU_BASE mov r0, #1 /* ram */ str r0, [r1, #8] /* ccu_memmap */ /* now the RAM is mapped at 0x0 and we continue execution in RAM */ mov sp, #0x30000 /* 64 kB stack */ bl blink b resume /* branch back to RAM */ /* store our functions here */ /* blink : switches the light on/off */ /* void blink(void) */ blink: stmed sp!, {r0,r1,r2,r3,lr} ldr r2, =GPIOD ldrb r0, [r2, #0x400] /* gpiod_dir */ orr r0, r0, #0x80 /* pin7 out */ strb r0, [r2, #0x400] mov r3, #0 /* Start by toggling off */ mov r1, #0x8 /* Let's toggle 8 times (4 on/off cycles) */ toggle_led: strb r3, [r2, #0x200] /* switch pin 7 : led on/off */ /* and prepare for next cycle */ eor r3, r3, #0xff /* toggle value we write into pin 7 */ mov r0, #0x20000 bl sleep /* Let's do 4 on/off cycles */ subs r1, r1, #1 bne toggle_led ldmed sp!, {r0,r1,r2,r3,lr} bx lr /* end of function blink */ /* void sleep(r0) : r0 = 0x100000 ~= 1 second */ sleep: subs r0, r0, #1 bne sleep bx lr /* end of function sleep */ resume: ldr pc, originalentry