1. Startup mode of PC and embedded Linux:
Pc:bios----> Boot operating system----> Identify partitions----> applications
Embedded Linux:bootloader----> Boot Linux operating system----> Mount file system----> launch app
From the above comparison we can find that theLinux bootloader is similar to the PC BIOS. So what is bootloader? Bootloader is our bare-metal program.
2, the development of bare Board program
Under Windows we use the integrated development environment (IDE): ADS, IAR, Keil, and so on. not recommended.
Under Linux we use: Gcc,gnu tool chain. Recommended.
2.1 Development process of bare Board program:
I edit source code files
II Compile/LINK
III Burn-Write test
In this step of writing a program, we need to be aware of the differences between bare Board program development and application development .
In the process of application development, we generally write only the main function. So what was the main function we wrote and when was it called? Our main function is called by the initiator, but it is not necessary for us to write our own program when we develop the application.
In developing the bare board program, we are divided into two steps: The first step is to write our startup code, and the second step is to write our C function.
In the startup code, we need: 1, hardware setup and related initialization 2, call the C function we wrote.
In the hardware setup we mainly have to do the following two things: set up the CPU, tell the CPU peripheral base address and off the watchdog
The CPU access address in OK6410 is divided into the following two sections:
Memory Address: 0~0X6FFF FFFF
Peripheral address: 0x7000 0000 ~0x7fff FFFF Total 256MB
Let's analyze a startup code:
1 /* tells CPU peripheral base address */ 2 Ldr r0,=0x7000 0000 3 4 orr r0,r0, #0x13 5 6 mcr p15,0 , R0,c15,c2,4 7 8 /* off watchdog */ 9 10 ldr r0,=0x7e00 4000 11 mov r1,#0 12 str R1,[r0]
Obviously, the above code is divided into two parts, we first look at line 2nd.
LDR r0,=0x7000 0000
Because there is ' = ' In this code, this is a pseudo-directive. It means transferring the 0x7000 0000 to the r0. 0x7000 0000 is the base address for our peripherals.
Line 4th
Orr R0,r0, #0x13
This code means that the value inside the R0 is 0x13 or manipulated with the immediate number, and then the resulting value is transferred to the register R0. Why do you want to talk about the values in R0 and 0x13? We'll talk about it right back.
And look at line 6th.
MCR p15,0,r0,c15,c2,4
See "ARM1176JZFS kernel Reference" p3-130~p3-132. We can see these pages detailing the meaning of each bit of the peripheral Port Memory Remap Register and how to do it.
This register is translated: The peripheral port stores the remap register. That means we're going to write the base address of our peripherals into this register. So let's take a look at the bit definition of the register.
[31:12] Base Address
[11:5] Unp/sbz
[4:0] SIZE. where b010011 represents 256MB
Well, now we understand why we have to do or operate the base site of our peripherals with 0x13. This means that when the base address is written to this register, it has to be written to the size of our peripherals. Our 6410 is 256MB, so or
On 0x13.
So what does this line of code mean, and everybody knows? The ARM1176JZFS Core reference includes the following:
MRC P15, 0, <rd>, C15, C2, 4; Read peripheral Port Memory Remap Register
MCR P15, 0, <rd>, C15, C2, 4; Write peripheral Port Memory Remap Register
OK, next we'll see how to turn off the watchdog.
Line 10th of the code.
LDR r0,=0x7e000400
The meaning of this code is not to be mentioned. The key is what 0x7e00 0400 means. Refer to s3c6410 User manual we can find the following:
Wtcon 0x7e004000 Read/write watchdog Timer control register.
So we understand that the 10th line of code is to transfer the address of our watchdog control register to our R0
Let's take a look at the next piece of code:
mov r1, #0
That's what everyone understands, is to transfer the number 0 immediately to the Register R1
Next we look at the following code:
STR R1 [R0]
The meaning of this code is to place the value inside the R1 into the address pointed to by R0. STR can be understood as the store.
This means that the three code above implements the operation of clearing all bits of our watchdog control register by 0. Refer to the manual below, the No. 0 bit of the control register is the bit that controls the watchdog timer enable and disable. The watchdog timer can be disable with this position 0.
2015-10-29 Vedon OK6410 First day course notes