this the start_kboot.c:
static const unsigned char buf={ /*the buf is the image of blink_led*/
0x03,0x00,0x00,0xea,0x00,0x00,0xf8,0x33,0x00,0x00,0x00,0x00,0x38,0x03,0x00,0x00,
0x38,0x03,0x00,0x00,0x00,0x00,0x0f,0xe1,0x1f,0x00,0xc0,0xe3,0xd3,0x00,0x80,0xe3,
0x00,0xf0,0x29,0xe1,0x53,0x04,0xa0,0xe3,0x00,0x10,0xa0,0xe3,0x00,0x10,0x80,0xe5,
0x00,0x10,0xe0,0xe3,0x20,0x01,0x9f,0xe5,0x00,0x10,0x80,0xe5,0x1c,0x11,0x9f,0xe5,
0x1c,0x01,0x9f,0xe5,0x00,0x10,0x80,0xe5,0x18,0x01,0x9f,0xe5,0x00,0x10,0xa0,0xe3,
0x00,0x10,0x80,0xe5,0x10,0x1f,0x11,0xee,0x03,0x11,0x81,0xe3,0x10,0x1f,0x01,0xee,
0x13,0x03,0xa0,0xe3,0xff,0x14,0xe0,0xe3,0x00,0x10,0x80,0xe5,0xf8,0x00,0x9f,0xe5,
0xf8,0x10,0x9f,0xe5,0x00,0x10,0x80,0xe5,0x00,0x00,0xa0,0xe1,0x00,0x00,0xa0,0xe1,
0x00,0x00,0xa0,0xe1,0x00,0x00,0xa0,0xe1,0x00,0x00,0xa0,0xe1,0x00,0x00,0xa0,0xe1,
0x00,0x00,0xa0,0xe1,0xd8,0x00,0x9f,0xe5,0xd8,0x10,0x9f,0xe5,0x00,0x10,0x80,0xe5,
0xd4,0x00,0x9f,0xe5,0x07,0x10,0xa0,0xe3,0x00,0x10,0x80,0xe5,0xcc,0x00,0x9f,0xe5,
0xcc,0x10,0x9f,0xe5,0x00,0x10,0x80,0xe5,0xc8,0x00,0x9f,0xe5,0xaa,0x10,0xa0,0xe3,
0x00,0x10,0x80,0xe5,0x05,0x02,0xa0,0xe3,0x03,0x10,0xa0,0xe3,0x00,0x10,0x80,0xe5,
0xb4,0x10,0x9f,0xe5,0x04,0x10,0x80,0xe5,0x01,0x10,0xa0,0xe3,0x08,0x10,0x80,0xe5,
0x00,0x10,0xa0,0xe3,0x0c,0x10,0x80,0xe5,0x1a,0x10,0xa0,0xe3,0x28,0x10,0x80,0xe5,
0x0c,0x00,0x00,0xeb,0xf8,0x00,0x1f,0xe5,0x80,0x00,0x40,0xe2,0x03,0x0a,0x40,0xe2,
0x0c,0xd0,0x40,0xe2,0x00,0x01,0x1f,0xe5,0x00,0x11,0x1f,0xe5,0x00,0x20,0xa0,0xe3,
0x00,0x20,0x80,0xe5,0x04,0x00,0x80,0xe2,0x01,0x00,0x50,0xe1,0xfb,0xff,0xff,0xda,
0x04,0xf0,0x1f,0xe5,0x14,0x03,0x00,0x00,0x00,0x00,0xa0,0xe3,0x17,0x0f,0x07,0xee,
0x17,0x0f,0x08,0xee,0x10,0x0f,0x11,0xee,0x23,0x0c,0xc0,0xe3,0x87,0x00,0xc0,0xe3,
0x02,0x00,0x80,0xe3,0x01,0x0a,0x80,0xe3,0x10,0x0f,0x01,0xee,0x0e,0xc0,0xa0,0xe1,
0x0f,0x00,0x00,0xeb,0x0c,0xe0,0xa0,0xe1,0x0e,0xf0,0xa0,0xe1,0x08,0x00,0x00,0x4a,
0xff,0xff,0x00,0x00,0x1c,0x00,0x00,0x4a,0x18,0x00,0x00,0x4c,0x08,0x00,0x00,0x4c,
0x82,0x80,0x05,0x00,0x04,0x00,0x00,0x4c,0x71,0xe0,0x08,0x00,0x14,0x00,0x00,0x4c,
0x0c,0x00,0x00,0x4c,0xf0,0xff,0x07,0x00,0x70,0x00,0x00,0x56,0x45,0x02,0x00,0x00,
0x00,0x00,0xf8,0x33,0x40,0x00,0x8f,0xe2,0x12,0x13,0xa0,0xe3,0x34,0x20,0x80,0xe2,
0x04,0x30,0x90,0xe4,0x04,0x30,0x81,0xe4,0x00,0x00,0x52,0xe1,0xfb,0xff,0xff,0x1a,
0x10,0x1f,0x11,0xee,0x03,0x11,0x81,0xe3,0x10,0x1f,0x01,0xee,0x56,0x04,0xa0,0xe3,
0xd0,0x10,0x90,0xe5,0x01,0x18,0x81,0xe3,0xd0,0x10,0x80,0xe5,0xd4,0x10,0x90,0xe5,
0x01,0x1c,0x81,0xe3,0xd4,0x10,0x80,0xe5,0x0e,0xf0,0xa0,0xe1,0xd0,0xd1,0x11,0x22,
0x00,0x07,0x00,0x00,0xc0,0x1b,0x00,0x00,0x00,0x07,0x00,0x00,0x4c,0x1f,0x00,0x00,
0x00,0x07,0x00,0x00,0x00,0x07,0x00,0x00,0x05,0x80,0x01,0x00,0x05,0x80,0x01,0x00,
0xe5,0x03,0x9e,0x00,0xb1,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x30,0x00,0x00,0x00,
0x0d,0xc0,0xa0,0xe1,0x00,0xd8,0x2d,0xe9,0x04,0xb0,0x4c,0xe2,0x10,0xd0,0x4d,0xe2,
0x18,0x00,0x0b,0xe5,0x00,0x30,0xa0,0xe3,0x10,0x30,0x0b,0xe5,0x00,0x30,0xa0,0xe3,
0x10,0x30,0x0b,0xe5,0x02,0x00,0x00,0xea,0x10,0x30,0x1b,0xe5,0x01,0x30,0x83,0xe2,
0x10,0x30,0x0b,0xe5,0x10,0x20,0x1b,0xe5,0x18,0x30,0x1b,0xe5,0x03,0x00,0x52,0xe1,
0xf8,0xff,0xff,0xba,0x00,0x30,0xa0,0xe3,0x03,0x00,0xa0,0xe1,0x0c,0xd0,0x4b,0xe2,
0x00,0x68,0x9d,0xe8,0x1e,0xff,0x2f,0xe1,0x0d,0xc0,0xa0,0xe1,0x00,0xd8,0x2d,0xe9,
0x04,0xb0,0x4c,0xe2,0x84,0x20,0x9f,0xe5,0x05,0x30,0xa0,0xe3,0x00,0x30,0x82,0xe5,
0x7c,0x20,0x9f,0xe5,0x7c,0x30,0x9f,0xe5,0x00,0x30,0x82,0xe5,0x78,0x20,0x9f,0xe5,
0x74,0x30,0x9f,0xe5,0x00,0x30,0x93,0xe5,0x01,0x30,0xc3,0xe3,0x00,0x30,0x82,0xe5,
0x68,0x00,0x9f,0xe5,0xd9,0xff,0xff,0xeb,0x5c,0x20,0x9f,0xe5,0x58,0x30,0x9f,0xe5,
0x00,0x30,0x93,0xe5,0x01,0x30,0x83,0xe3,0x00,0x30,0x82,0xe5,0x4c,0x00,0x9f,0xe5,
0xd2,0xff,0xff,0xeb,0x40,0x20,0x9f,0xe5,0x3c,0x30,0x9f,0xe5,0x00,0x30,0x93,0xe5,
0x02,0x30,0xc3,0xe3,0x00,0x30,0x82,0xe5,0x30,0x00,0x9f,0xe5,0xcb,0xff,0xff,0xeb,
0x24,0x20,0x9f,0xe5,0x20,0x30,0x9f,0xe5,0x00,0x30,0x93,0xe5,0x02,0x30,0x83,0xe3,
0x00,0x30,0x82,0xe5,0x14,0x00,0x9f,0xe5,0xc4,0xff,0xff,0xeb,0xe2,0xff,0xff,0xea,
0x10,0x00,0x00,0x56,0x18,0x00,0x00,0x56,0xff,0xff,0x00,0x00,0x14,0x00,0x00,0x56,
0xff,0xff,0x0f,0x00,0x0d,0xc0,0xa0,0xe1,0x00,0xd8,0x2d,0xe9,0x04,0xb0,0x4c,0xe2,
0xd0,0xff,0xff,0xeb,0x00,0x30,0xa0,0xe3,0x03,0x00,0xa0,0xe1,0x0c,0xd0,0x4b,0xe2,
0x00,0x68,0x9d,0xe8,0x1e,0xff,0x2f,0xe1};
#define ADDR (*(volatile unsigned *)buf)
int start_kboot()
{
/* nand_read_ll(buf, 0, sizeof(buf));
void (*fp)(void)=(void (*)(void))&buf;
(fp)();
*/
asm volatile("mov pc, %0\n"
: /* output */
:"r"(ADDR) /* input */
);
return 0;
}
i use arm- arm-angstrom-linux-gnueabi-gcc -Wall -S start_kboot.c create
the .s file
.file "start_kboot.c"
.section .rodata
.type buf, %object
.size buf, 1
buf:
.byte 3
.text
.align 2
.global start_kboot
.type start_kboot, %function
start_kboot:
@ Function supports interworking.
@ args = 0, pretend = 0, frame = 0
@ frame_needed = 1, uses_anonymous_args = 0
mov ip, sp
stmfd sp!, {fp, ip, lr, pc}
sub fp, ip, #4
ldr r3, .L3
ldrb r3, [r3, #0] @ zero_extendqisi2 --i don't know the three
line why here is ldrb rc,[r3,#0],is there something wrong?
ldr r3, [r3, #0]
#APP
mov pc, r3
mov r3, #0
mov r0, r3
sub sp, fp, #12
ldmfd sp, {fp, sp, lr}
bx lr
.L4:
.align 2
.L3:
.word buf
.size start_kboot, .-start_kboot
.ident "GCC: (GNU) 4.1.2"
Andy Green wrote:
Thinking about what you're trying to do here, executing code from NAND
will be hard to debug. If it got the wrong code, you will just crash.
It will be easier to understand what the NAND code is doing if you set
up console serial port now and you can "debug with printf".
i think we set up the uart in start.S, but i don't know how to out put
something use UART
http://git.openmoko.org/?p=kboot-stage1.git;a=blob;f=src/start.S;h=bf1a7f5630265201b8bd9373e36d139e220ceb47;hb=c3cb5b083217efecfe130ebc360ee5d74b9eb244
line 121
/* gpio UART0 init */
ldr r0, =0x56000070
mov r1, #0xaa
str r1, [r0]
/* init uart */
ldr r0, =0x50000000
mov r1, #0x03
str r1, [r0]
ldr r1, =0x245
str r1, [r0, #0x04]
mov r1, #0x01
str r1, [r0, #0x08]
mov r1, #0x00
str r1, [r0, #0x0c]
mov r1, #0x1a
str r1, [r0, #0x28]
I found the minimum low level initialization for s3c24xx serial port in
a patch I wrote a few weeks ago.
First you must enable UART clocks in CLKCON so UARTs can work. Then
this shows the steps to configure and transmit:
+ /* 8 N 1 */
+ wr_regl(port, S3C2410_ULCON, (rd_regl(port, S3C2410_ULCON)) | 3);
+ /* polling mode */
+ wr_regl(port, S3C2410_UCON, (rd_regl(port, S3C2410_UCON) &
~0xc0f) | 5);
+ /* disable FIFO */
+ wr_regl(port, S3C2410_UFCON, (rd_regl(port, S3C2410_UFCON) &
~0x01));
+ /* fix baud rate */
+ wr_regl(port, S3C2410_UBRDIV, 26);
+
+ while (*sz) {
+ int timeout = 10000000;
+
+ /* spin on it being busy */
+ while ((!(rd_regl(port, S3C2410_UTRSTAT) & 2)) &&
timeout--)
+ ;
+
+ /* transmit register */
+ wr_regl(port, S3C2410_UTXH, *sz);
+
+ sz++;
+ }
- -Andy