1 /* Author: Domen Puncer Kugler <domen@cba.si>. License: WTFPL, see file LICENSE */
10 #include <endianess.h>
12 #include <interrupt.h>
13 #include <mach/lpc13xx_interrupt.h>
14 #include <mach/lpc13xx_regs.h>
15 #include <mach/LPC13xx.h>
18 #define DEVICE_ID ((u32*)0x400483f4)
20 void print_hex(unsigned base
, const u8
*buf
, unsigned len
)
27 printf("%08x: ", base
);
30 printf("%02x ", buf
[p
++]);
38 __attribute__ ((section(".data"))) void copy_secret_flash(int addr
)
40 u32
*reg
= (u32
*)0x4003c000;
43 u32
*src
= (u32
*)addr
;
44 asm volatile ("":::"memory");
46 for (i
=0; i
<sizeof(buf
)/sizeof(buf
[0]); i
++)
52 __attribute__ ((section(".data"))) u32
copy_one_secret_flash(int addr
)
54 u32
*reg
= (u32
*)0x4003c000;
57 u32
*src
= (u32
*)addr
;
58 asm volatile ("":::"memory");
60 asm volatile ("":::"memory");
62 asm volatile ("":::"memory");
64 asm volatile ("":::"memory");
73 printf("%s: enter\n", __func__
);
74 print_hex(0x10000000, (u8
*)0x10000000, 0x200);
76 printf("%s: dumping bootloader for device %08x\n", __func__
, *DEVICE_ID
);
77 print_hex(0x1fff0000, (u8
*)0x1fff0000, 0x4000);
79 for (i
=0; i
<sizeof(buf
)/sizeof(buf
[0]); i
++)
81 printf("%s: copy_secret_flash\n", __func__
);
83 print_hex(0x0, (u8
*)buf
, sizeof(buf
));
85 for (i
=0; i
<sizeof(buf
)/sizeof(buf
[0]); i
++)
87 printf("%s: copy_ one by one\n", __func__
);
88 for (i
=0; i
<sizeof(buf
)/sizeof(buf
[0]); i
++)
89 buf
[i
] = copy_one_secret_flash(i
*4);
90 print_hex(0x0, (u8
*)buf
, sizeof(buf
));