Menu:

Micro2440 with Linux and U-Boot

Micro2440 Instructions for U-Boot and Linux

A brief introduction about how to get started with the Micro2440 boards and u-boot.
We are going to replace all contents of the NAND flash - so make sure to have a backup if there is any valuable data on your device.

What we need

Replacing the Bootloader

We are going to use the bootloader in NOR flash for booting preparing the whole boot environment in NAND flash. Doing so we can create a new bad block table for the NAND flash which seems to be necessary for most of the board shipped.
We are going to copy u-boot into the RAM of the board and execute it there. u-boot will provide us all necessary features to prepare nand flash and copy itself there.

1. Use your preferred serial terminal application and connect to the micro2440 SDK board "COM-0" port. The u-boot serial console communication parameters are 115200,8,n,1. Connect the USB client (B) plug of the board with an USB port of your PC. Make sure to set the boot selection switch to the 'NOR' position before you power on the board.

2. No need to build anything from source, the binaries are provided in the support kit linked here. Download and unpack this file.

3. When you turn on the board you should see a list of options from the Vivi bootloader the board is shipped with.

##### FriendlyARM BIOS for 2440 #####
[x] bon part 0 320k 2368k
[v] Download vivi 
...

Press 'q' to enter the Vivi shell.

4. Now you can enter the command to download the u-boot bootlader via USB.

Supervivi> load ram 0x31000000 239016 u
USB host is connected. Waiting a download. 

The second number is the length of the file in bytes. The number in this description is an example and needs to replaced with the correct length of the file you are actually uploading.

Upload the file from your PC. Note that you need to have root privileges to do this.

$ sudo ./s3c2410_boot_usb u-boot.bin

Ususally you get an error message before the program terminates. This can be ignored. At the Vivi shell you should see something like this:

Now, Downloading [ADDRESS:31000000h,TOTAL:239026]                               
RECEIVED FILE SIZE:  239026 (116KB/S, 2S)                                       
Downloaded file at 0x31000000, size = 239016 bytes

5. Now we are going to jump to u-boot and prepare the NAND flash

go 0x31000000

You should see u-boot starting:

U-Boot 1.3.2-dirty-moko12 (Apr 16 2009 - 18:14:52)                              
                                                                                
I2C:   ready                                                                    
DRAM:  64 MB                                                                    
Flash:  2 MB                                                                    
NAND:  Bad block table not found for chip 0                                     
Bad block table not found for chip 0                                            
64 MiB                                                                          
*** Warning - bad CRC or NAND, using default environment                        
                                                                                
USB:   S3C2410 USB Deviced                                                      
In:    serial                                                                   
Out:   serial                                                                   
Err:   serial                                                                   
MAC: 08:08:11:18:12:27                                                          
Hit any key to stop autoboot:  0

Now we can prepare the NAND slash:

MINI2440 # nand scrub
NAND scrub: device 0 whole chip                                                 
Warning: scrub option will erase all factory set bad blocks!                    
         There is no reliable way to recover them.                              
         Use this command only for testing purposes if you                      
         are sure of what you are doing!                                        
                                                                                
Really scrub this NAND flash? <y/N>                                             
Erasing at 0x3ffc000 -- 100% complete.                                          
Bad block table not found for chip 0                                            
Bad block table not found for chip 0                                            
OK

and

MINI2440 # nand createbbt
Create BBT and erase everything ? <y/N>                                         
Skipping bad block at  0x03ff0000                                               
Skipping bad block at  0x03ff4000                                               
Skipping bad block at  0x03ff8000                                               
Skipping bad block at  0x03ffc000                                               
                                                                                
Creating BBT. Please wait ...

6. We copy u-boot to NAND

MINI2440 # nand write 0x31000000 u-boot                                         
NAND write: device 0 offset 0x0, size 0x40000                                   
 262144 bytes written: OK                                                       

7. Reset
Return the boot selection switch to the NAND setting and try your new installed u-boot. Right after reset the u-boot console should appear again.

Working with U-Boot

1. Create a dynamic environment:

MINI2440 # dynenv set 40000

2. Copy the *.jffs2 and the uImage file to the SD/MMC card and put it into the card slot of the Micro2440 SDK.

3. Populate the kernel partiton in NAND flash
At the u-boot prompt enter the following commands

MINI2440 # nand erase kernel
MINI2440 # mmcinit
MINI2440 # fatload mmc 0:1 0x31000000 uImage
MINI2440 # nand write 0x31000000 kernel 

4. Populate the filesystem partition in NAND flash
The 'filesize' environment variable holds the size of the last file read by the fatload command. Because its padded to a erase block boundary we can use this knowledge to deal with root filesystems of multiple size easily.

MINI2440 # nand erase root
MINI2440 # mmcinit
MINI2440 # fatload mmc 0:1 0x31000000 gpe-image-micro2440.jffs2
MINI2440 # nand write.jffs2 0x31000000 root ${filesize}

5. Set the boot command and save the environment settings

MINI2440 # setenv bootcmd nboot.e kernel \; bootm
MINI2440 # saveenv

If you have a board with 7" LCD you need to set (and save) this parameter:

MINI2440 # setenv bootargs root=/dev/mtdblock3 rootfstype=jffs2 console=ttySAC0,
115200 mini2440=1tb

6. Reset and boot the device

MINI2440 # reset

Some additional information

U-Boot partition layout

nr  name    size        offset
 0  u-boot  0x00040000  0x00000000
 1  env     0x00020000  0x00040000
 2  kernel  0x00500000  0x00060000
 3  root    0x03aa0000  0x00560000

OpenOCD configuration

You can use this configuration to access your Micro2440 using the parallel port JTAG that comes with it.

interface parport
parport_port 0x378
parport_cable triton
jtag_speed 0

source [find target/samsung_s3c2440.cfg]

telnet_port 4444
gdb_port 3333

reset_config trst_and_srst

Bootstrapping without a working bootloader

If you have a device without valid bootloader you can bootstrap it by running u-boot from ram. This procedure is a little bit tricky since the CPU needs some initialisation before you can write an u-boot executable to the RAM.
You will need the JTAG cable, OpenOCD 1.x and the lowlevel_foo.bin image included in the support kit.

At the OpenOCD prompt follow this sequence:
Reset the CPU and let it wait

> reset halt

Now we bring out initialisation commands in place.

> load_image /path/to/lowlevel_foo.bin 0
downloaded 332 byte in 0s 21899us

We set a breakpoint at the address in RAM the initialisation code jumps to after successful execution.

> bp 0x33f80000 4 hw
breakpoint added at address 0x33f80000

Now let the CPU run. It will go through the initialisation and finally jump to our breakpoint.

> resume
Target 0 resumed
> Target 0 halted
target halted in ARM state due to breakpoint, current mode: Supervisor
cpsr: 0x600000d3 pc: 0x33f80000
MMU: disabled, D-Cache: disabled, I-Cache: enabled

Now that we have initialised RAM we can bring our bootloader in place. We copy it to the address where the CPU is waiting due to the breakpoint.

> load_image /path/to/u-boot.bin 0x33f80000

And we allow it continue execution...

resume 

You should get an u-boot console on the serial port now.
Write the u-boot binary to the "u-boot" partition now. (Same commands like for the kernel, but
use the existing address 0x33f80000 and "u-boot" for the partition name.

There is a screencast [4] available that is based on this decription.

References

[1] LinuxMCE Wiki: http://wiki.linuxmce.org/index.php/Mini2440
[2] OpenMoko Wiki: http://wiki.openmoko.org/wiki/Bootloader#Using_JTAG_to_boot_from_RAM
[3] Mini Bringup Guide: http://code.google.com/p/mini2440/wiki/MiniBringup
[4] mini2440 screencast: http://www.youtube.com/watch?v=oi66srITOcA