Hi guys...
I hope you all are enjoying the journey of learning embedded linux compilation and building on the target board.
In my last blog we have discussed how to build hex image of U-boot for our target board that is quite easy steps but any way as a beginner we have to learn and understand each and every steps... =D
So finally we got a hex image of u-boot bootloader so we can flash it on our board... today we will learn how to flash u-boot.hex into our target board and we'll try to explore u-boot environment.
Steps to load u-boot.hex into our board :
1) Start the FlashMagic tool (can be downloaded here). See Figure below for what FlashMagic looks like when it is started.
2) Click the “Browse” button and browse to the location of the u-boot.hex file.
3) Change the COM port to the COM port used by your target. Select baudrate as same as your com port have.
4) Click the “Start” button to download the u-boot.bin file to the target.
Explore the u-boot environment :Now we will see how to connect the board with a terminal application and then explore the u-boot console and environment. You can use a terminal application of your choice. In this example we will use an application which we installed(see here... under the heading Serial line communication program ) already known as PICOCOM.
Connect a Terminal to the Board :
1. Start the PICOCOM application and configure the serial port. Setup Serial port
2. Configure the port to use a baud rate of 115200, 8-bit data, no parity, 1 stop bit and no flow control.
$ picocom -b 115200 /dey/ttyUSB0
3. Press the Reset button on the base board to make sure the board restarts. You should now see output from the u-boot in the terminal, see Figure below. Make sure to hit any key to stop the auto boot procedure in 3 seconds.......
Commands to operate U-boot :
1) help:- List all available commands by using the help command.
# help
? - alias for 'help'
autoscr - run script from memory
base - print or set address offset
bdinfo - print Board Info structure
boot - boot default, i.e., run 'bootcmd'
bootd - boot default, i.e., run 'bootcmd'
...
2) Get specific instructions about a command, the example shows help text for the setenv command.
# help setenv
setenv name value ...
- set environment variable 'name' to 'value ...'
setenv name
- delete environment variable 'name'
3) printenv :- Print the current environment by using the printenv command.
# printenv
bootargs=root=/dev/ram initrd=0xa1800000,4000k console=ttyS0,115200N8
bootcmd=echo ;echo Booting from NAND FLASH (may take some seconds);echo
First loads 'uLinux.bin' and then 'jffs2.img';run nand_boot
bootdelay=3
baudrate=115200
tftp_boot=tftpboot a1500000 uLinux.bin;tftpboot a1800000 romfs.img;bootm
a1500000
nand_boot=nboot a1500000 0;bootm a1500000
nor_boot=bootm 80000000
...
etc.. etc...
This is how you can explore the environment for U-boot which provides you a command interface to give commands & these commands will help you to boot kernel image from different type of storage media that we will discuss later. So now your board is loaded with bootloader which is same as placenta in mother's uterus which loads life or new soul... in our case new soul is OS =D
In my next post we'll load our kernel image into board using usb method and we'll se the different method of loading kernel into board... if u have any queries please post below... hope u all will njoy !! :)
Thats it for today!!
Abhishek Mourya
can u give me more info how to write u-boot for particular os or for processor like ARM or any other
ReplyDeleteHi Madhav... U-boot source code is already implemented and its source code is freely available on internet.... n u-boot source code supports so many architecture which u can see in u-boot source code tree(directory called arch... )... and if the architecture u r using is not already defined in arch directory then u have to write only config file for that architecture...
Deleteand if u want to know about more on u-boot then lots of material is there in web... If any doubt pls comment below :)
Hi Abhi,
ReplyDeletecan you clarify me how device tree is implemented in new kernel versions...with working examples ?
Hi Babu,
DeleteThere are many embedded architectures have a lot of non-discoverable
hardware.So depending on the architecture, such hardware is either
described using C code directly within the kernel, or using a
special hardware description language in a Device Tree.
ARM, PowerPC, OpenRISC, ARC, Microblaze are examples of architectures using the Device Tree.
and a Device Tree Source, written by any kernel developers, is compiled into a binary Device Tree Blob, which passed at boot time to the kernel.
So there is one di fferent Device Tree for each board/platformsupported by the kernel, available in arch/arm/boot/dts/.dtb.
The bootloader must load both the kernel image and the
Device Tree Blob in memory before starting the kernel.
I hope i clarified ur doubt... if any thn plz comment below. :)