HOWTO: Using U-Boot
By Bill » Sunday, January 17 2010, 17:35
Well you finally have a working U-boot bootloader on your Mini2440 or Micro2440, well here are the instructions for actually flashing kernel images and root filesystems using it...
These instructions assume that you've got a working U-Boot and that you've managed to compile a kernel for U-Boot (uImage), and that you've created a jffs2 filesystem image for your device.
Loading your Kernel Image from the SD Reader:
Step 1: Initialize the SD reader on your device by issuing the mmc command.
MINI2440 # mmc trying to detect SD Card... Manufacturer: 0x03, OEM "SD" Product name: "SD08G", revision 8.0 Serial number: 4392543921 Manufacturing date: 7/2008 CRC: 0x6, b0 = 1 READ_BL_LEN=15, C_SIZE_MULT=0, C_SIZE=365 size = 0 SD Card detected RCA: 0xd555 type: SDHC MINI2440 #
Step 2: Load in to ram, the kernel image from the SD card using the fatload command.
MINI2440 # fatload mmc 0:1 0x32000000 uImage.bin reading uImage.bin
This loads the file uImage from the mmc (SD) Device 0, on parition 1 in to the ram at memory location 0x32000000 (6 zeros)
Step 3: Erase the kernel partition and write the kernel in memory to the kernel partition.
MINI2440# nand erase kernel Erasing....... MINI2440# nand write.e 0x32000000 kernel
This writes using ecc blocks ( the .e part) the kernel that's located in 0x32000000 to the kernel partition.
Loading your Root Filesystem Image from the SD Reader:
Step 1: Initialize the SD reader as we did in step 1 above.
Step 2: Use the fatload command as we did above to load your root filesystem image in to ram.
Step 3: Erase the rootfs partition and write the image you loaded in ram, to NAND.
MINI2440# nand erase rootfs MINI2440# nand write.jffs2 0x32000000 rootfs $(filesize)
This writes a jffs2 filesystem to the rootfs partition. For this command you need to pass the file size of the image in hex, but fortunately u-boot is some what smart here, and has provided us a variable that contains the file size of the last file transferred to ram. So you just use $(filesize) as the size at the end and it knows what to do.
Before you can boot this, you need to set some environment variables in U-Boot.
Setting the Environment Variables for booting
Step 1: Set the bootcmd variable to tell U-Boot what type of kernel image you have and what partition its on.
MINI2440# setenv bootcmd nboot.e kernel \; bootm MINI2440# saveenv
This tells u-boot to read the kernel using ecc blocks from the kernel partition and to use bootm as the type of image (uImage) and saves the environment variables.
Step 2: Set the bootargs variable to tell u-boot what to pass to the kernel command line.
MINI2440# setenv bootargs root=/dev/mtdblock3 rootfstype=jffs2 console=ttySAC0,115200 mini2440=1tb rootwait MINI2440# saveenv
This tells u-boot to tell the kernel that you're booting from mtdblock3 (rootfs partition), your filesystem is jffs2, your console is ttySA0 at 115200 baud, and the last argument tells the kernel what size display you have. 1tb is for the 7" display, and 0tb is for the 3.5" display.
Now assuming everything worked as it should, you can reset your board and it should begin booting linux.
//Bill Sargent
Questions? Comments? Please visit my forum and ask!

Comments
Just small comment:
The instructions above are works fine with te console image.
I have created a bigger image (including Qt 4.6).
I cannot load it with fatload, because the board alvays reseted itself.
Somewhere i have readed that the fatload works with smaller addresses:
I have used
fatload mmc 0:1 0x31000000 rootfs.bin
and it worked.
Hi,Bill.I'm a newbie.May i get the copy of UBOOT as above? I need a UBOOT bin file which support SDHC in mini2440.Thanks alot.
Yes, Marton, I've been meaning to change my instructions to reflect 0x31000000 ... To load larger images in to the boards ram, you must go to a lower address space. Thanks for pointing it out :)
Hello Beebuu,
You should try using my howto on compiling u-boot. It's better if you're able to compile it yourself, as you'll want to be able to update it later should fixes become available. If for some reason you cannot get it compiled, let me know and I can put up a link. But it's really better if you try to compile it. Please visit this link http://bill.station51.net/index.php...
Thanks for your reply.I'm a real newbie,i just want to try mini2440,if i can get a good start,i will get happy to study,hope you can help me,any link is better for me this monment.Thanks tons.
Bill,
Thanks for all these postings. This is really useful to get started.
I was able to get the system up and running for a newbie.
However, I do not find any /dev/led0 etc or any gpio. Do you know if I need to load any driver to be able to use the gpio.
Hi Suni,
Did you use the correct kernel? There is a kernel source tree available via git repo at repo.orz.cz ... You need to use that one. Since I don't mess with LEDs, I don't know for sure if that's all that's needed though. There may be other kernel modules you need. Seems I recall there being some module sources on the CD that came with my Mini2440.
I have a 128Mb board , I was able to compile and install u-boot without any issues. The problem i'm facing is the kernel loads but never boots.
Excerpt
"
## Booting kernel from Legacy Image at 32000000 ...
Image Name:
Created: 2010-02-09 12:25:48 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2041256 Bytes = 1.9 MB
Load Address: 30008000
Entry Point: 30008000
Verifying Checksum ... OK
Loading Kernel Image ... OK
OK
"
How to make the linux kernel boot?
But if I use tftpboot to load the kernel the linux kernel boot and starts loading.
Settings for bootcmd are bootargs
"
bootcmd=nboot.e kernel ; bootm
bootargs=noinitrd console=ttySAC0,115200 root=/dev/mtdblock2 rootfstype=jffs2 rw
mini2440=3tb
"
When the kernel starts booting via tftpboot i get the following errors
"
->read(0x400 bytes from 0x420000) returned ECC error
jffs2_scan_eraseblock(): Node at 0x00420000 {0x1985, 0xe000, 0x00000029) has invalid CRC 0x60046646 (calculated 0x1c7375c8)
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00420004: 0x0029 instead
"
Can anyone explain as to what is going on..
regards
--fatbrain
Hello Fatbrain:
When you flashed u-boot, did you run createbbt? Also, where did you get your kernel from? You should use the kernel from the git repository. You can also try taking out the console option and all the boot up process will display on the LCD panel (assuming you have one) just in case the kernel isnt displaying everything to the port correctly.
Also what command did you use to write the kernel to the boot partition? It has to be nand write.e (the .e skips over the bad blocks)
If you did follow all the directions correctly from the howtos on this blog, my first concern would be that you have a bad Mini.
My MINI2440 is pre-loaded with Win CE 5, how can I load and use U-boot with it..
Hello say2paul,
Use the contact me link on the page and contact me privately. i'll try to help.
Thanks for your excellent input. I've been able to get uboot and a kernel installed on a mini2440. However, the kernel panics when it tries to find the root file system on an SD card.
What can I do to turn the root file system into an image that I can load into flash?
Thanks.
Bill,
I want to be able to switch the display back to the LCD screen (3.5" LCD).
I modified the boot params to a console=tty0
root=/dev/mtdblock3 rootfstype=jffs2 console=ttySAC0,115200 console=tty0 mini2440=0tb
Still I do not see an display on the lcd screen. I read somewhere that if you have 3.5" screen , then mini2440=0tb should be right.
Any thoughts?
@suni : Well you have 2 console parameters on the line. If you want the console on the display, remove the console parameter altogether.
Hello All,
How do i use u-boot with zImage_T35 and root_qtopia-64M.img (i.e. i loaded zImage_T35 and root_qtopia-64M.img but when i reboot, i got error msg "bootcmd: wrong image").
1. fatload mmc 0:1 0x31000000 zImage_T35
2. nand write 0x31000000 kernel
3. nand erase root
4. fatload mmc 0:1 0x31000000 root_qtopia-64M.img
5. nand write 0x31000000 root ${filesize}
6. setenv bootcmd nboot.e kernel \; bootm
7. saveenv
Thanks,
flux000