1. Experience with bare-metal development environment (Redhat 6.4 + vbox)
I. General process for bare metal development
Note: This assumes that you have built a bare-metal development environment
Our bare-metal general development process: Figure 1-1:
Figure 1-1 Bare Metal development process
Since we are experiencing bare metal programs in this article, we skipped 1 or 2 steps. Start directly from the third step:
Second, the installation of cross-tool chain:
Here, the program we write is going to run on the Development Board, not on the PC, so the PC's GCC and other compilers no longer apply, we have to follow the cross tool chain. Because our program is going to run in the arm architecture. So the tool chain installed is the arm-linux-* tool chain.
Our toolchain is placed in the/home/arm-tools: arm-linux-gcc-4.3.2.tgz. 1-2:
Figure 1-2
Next is the decompression, is the installation, we unzip it into the/usr/local directory: The command used is:
TAR-ZXVF arm-linux-gcc-4.3.2.tgz-c/
The command means that the toolkit is extracted to the root directory. Because it is pressurized open folder is/usr/local/arm/4.3.2 ... So when we unzip, we will see a new folder under/usr/local/arm:1-3:
Decompression command:
Enter:
Figure 1-3 Installation Kit
We see from the above echo that the installed directory is really/usr/local/arm.
Once installed, we will see the 4.3.2 Toolchain folder in the/usr/local/arm directory, which is the toolset we cross-compile. There are many compilers in the arm-linux-beginning, including arm-linux-gcc,arm-linux-g++. These two are tools for cross-compiling C and C + +. 1-4:
Figure 1-4 Cross Tool chain
Three, cross-tool chain configuration:
We just unpacked the crossover tool chain, and we can't use these cross-tool chains now, because we haven't configured the environment yet. If we are executing at the command line now: ARM-LINUX-GCC will error: Figure 1-5:
Figure 1-5
Next we configure these toolchain so that we can use them at the command line. The configured file is in/etc/profile. Open the file and add the path to the toolchain:
Export path= $PATH:/usr/local/arm/4.3.2/bin/
Then save to enable the environment we just configured: Source/etc/profile
This allows us to configure the cross-tool chain. such as 1-6:
Figure 1-6 Enabling cross-tool chain environment
Test the Environment: installation is successful, figure 1-7:
Figure 1-7
Four, bare metal experience:
The next step is to test our cross-tool chain with a well-written bare-metal program.
Here we provide a program to light up the LED assembly file: Figure 1-8:
Figure 1-8
Here our source program is two, one is led.lds link script file, a assembly file Led.s.
Compile the assembly file to produce a binary. o file, figure 1-9:
Figure 1-9 Compiling
Link the file, generate the. elf file, figure 1-10:
Figure 1-10 Link File
However, the resulting file is in elf format and is not an executable binary file. We need to convert the elf file to a. bin file that can be executed on the Development Board. Figure 1-11:
Figure 1-11 Generating the bin executable file
Above, we finally programmed a file. The executable file is the. bin file. But the steps are a bit cumbersome, and when we need to change a file, we have to recompile it once again. So, we had to write our makefile file.
?
As we are now just experiencing bare-metal programs burned to the Development Board. So it will be explained in the following:
- Use of cross tool chains
- The writing of linker scripts
- Makefile's writing.
?
Now we burn the generated bin executable bare-metal program to the Development Board to see the effect:
Note we burn writing to the nandflash of the Development Board.
Burn and write bare metal programs:
1, the first is to insert our SD card into the SD card reader, and plug into the computer's USB port. Figure 2-1:
?
Figure 2-1 SD Card
2. Open My Computer, right-click SD card letter, select Format SD card, click Start, there will be a warning prompt, select OK to format the SD card. Formatting is complete and the format is complete, so you can click OK. Figure 2-2:
Figure 2-2 Formatting the SD card
Figure 2-2 Formatting the SD card
3. Format the SD card, is to burn write our SD card boot program. The first is to open the burn-write software. Mine is in F:\forfish. \ok6410-a basic Information -256 (H) \linux-3.0.1\linux Burn write tool catalog: Figure 2-3:
Figure 2-3
Double-clicking on the Sd_writer.exe software above will appear 2-4.
Figure 2-4
4. Then click the Scan button in the upper right corner of the interface to automatically detect our SD card, and the SD volume will display the drive letter of your SD card. The Board model is 6410 (mine is 6410). SD type Select auto by default. OS type is also the default linux| | Android. Then click Select Boot in the lower left corner. An interface will appear to find the SD card burning program Mmc_ram256.bin (mine is 256), click to select. Finally, click Program to burn the write. It is ok! the success of Burning writes. Figure 2-5:
?
Figure 2-5
This shows that we have written the SD program.
?
?
?
?
?
5. Exit the USB, unplug the SD card, and insert the SD card slot into the development Board. Figure 2-6:
Figure 2-6
6. Before we give the board power, we need to set up the port of our PC, we use serial port software SecureCRT.exe. After opening the software, create a new serial port with the following parameters, name COM1. Figure 2-7.
Click New, and then select Serial.
?
Port selection COM1, baud rate 115200, data bit 8 bit, parity none, stop bit 1. Cancels the selection of the flow control. Then click Next.
?
Click OK.
?
?
?
?
?
?
?
So we've created the port COM1:
As above, we choose COM1, point connection, you can connect the development Board via serial port:
Figure 2-7 Port
?
?
?
?
7. The next step is to set up the Development Board from the SD card. Figure 2-8:
1---8 good switch pin: off-off-off-on-on-on-on-on:
Figure 2-8
8. Finally to the Development Board power, serial port display: Figure 2-9:
Figure 2-9 Serial Port display information
9. Select 1 Format the NAND flash. Format NAND Flash Figure 2-10:
?
Then select y:
?
Select 3 Burn image from USB.
Select 1 Flash u-boot:
Figure 2-10 Burn Write
10. The next step is to burn the Led.bin led program that we created earlier.
The first is to pull the USB from Windows 7 to the Redhat 6.4 of the virtual machine. Right-click on the vbox in the lower right corner of the USB, you will see figure 2-11: Then click on the mouse to select the USB, select, see again, you will find this USB front more than a tick. This way USB is pulled from Windows 7 by me to Redhat 6.4. So we can do led.bin burn.
Figure 2-11 USB Connection
12. Before burning the program, install the USB burning driver: Dnw_usb.ko. installation command:
Insmod Dnw_usb.ko
Installation 2-12:
Figure 2-12
As above we have installed the USB burn-write driver. The next step is to actually burn and write the Led.bin program.
?
13. Copy the generated led.bin to the directory where DNW is located, which is the 2-12 directory. Then execute:
./DNW Led.bin 50008000
The results of the execution, such as 2-13:
?
?
?
?
?
Copy:
Perform:
Figure 2-13 Execution Results
The feedback information of the serial port figure 2-14:
Figure 2-14 Burn Write
We can see that we burned 1032192bytes into the memory.
?
14. Check whether the program has successfully run on the Development Board. We set up the Development Board to boot from NAND flash and then reboot.
Nand Flash Boot: 1-8:off-off-off-on-on-off-off-on. Then press the restart key. such as 2-15:
Figure 2-15 setting NAND flash boot, light LED
Let's take a look at the program:
We see that we give the first lamp a value of 0 in the assembly, because 0xe=0b1110 is the first light. It means that we have succeeded in burning the book.
Whistling, and finally burning to finish, the sound of ........ .......
1. Experience with bare-metal development environment (Redhat 6.4 + vbox)