Step 2: Replacing vivi by u-boot
The mini2440 comes with two flashes, the NOR flash and the NAND flash. The NOR flash stores vivi by default. So I am NOT gonna overwrite it, in case I need it. I am gonna overwrite the NAND flash by u-boot, Linux kernel 2.6.31 and GPE.
I will boot the board from NOR flash, using vivi in it to write u-boot into NAND flash. And then, I will reboot the board from NAND flash, and use u-boot to finish all the rest.
Turn the boot selection switch to NOR flash on the board. Connect mini2440 with PC using minicom via RS232. Power on the board and you shall see this boot-up menu:
##### FriendlyARM BIOS for 2440 #####
[x] bon part 0 320k 2368k
[v] Download vivi
[k] Download linux kernel
[y] Download root_yaffs image
[c] Download root_cramfs image
[a] Absolute User Application
[n] Download Nboot
[e] Download Eboot
[i] Download WinCE NK.nb0
[w] Download WinCE NK.bin
[d] Download & Run
[f] Format the nand flash
[p] Partition for Linux
[b] Boot the system
[s] Set the boot parameters
[t] Print the TOC struct of wince
[u] Backup NAND Flash to HOST through USB(upload)
[r] Restore NAND Flash from HOST through USB
[q] Goto shell of vivi
Enter your selection: q
Press q and Enter at the prompt and switch to vivi promp.
Now connect PC with mini2440's USB device port, via a USB cable. Make the compiled u-boot image handy. Tell vivi that you need 239016 Bytes space in the RAM to load something from the USB, starting at 0x31000000
Supervivi> load ram 0x31000000 239016 u
USB host is connected. Waiting a download.
On another shell window, use following command to download u-boot into the RAM of mini2440
$ sudo ./s3c2410_boot_usb u-boot.bin
Enter root password when prompted, and you shall see this output on the shell
csum = 0xd542
send_file: addr = 0x33f80000, len = 0x0003a5a8
Error downloading program
Please ignore the error.
Now go back to vivi. You shall see follows
Now, Downloading [ADDRESS:31000000h,TOTAL:239026]
RECEIVED FILE SIZE: 239026 (233KB/S, 1S)
Downloaded file at 0x31000000, size = 239016 bytes
Now we are ready to write u-boot from the RAM to NAND flash. Execute the code starting at RAM location 0x31000000:
Supervivi> go 0x31000000
go to 0x31000000
argument 0 = 0x00000000
argument 1 = 0x00000000
argument 2 = 0x00000000
argument 3 = 0x00000000
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
Found Environment offset in OOB..
USB: S3C2410 USB Deviced
In: serial
Out: serial
Err: serial
MAC: 08:08:11:18:12:27
Hit any key to stop autoboot: 0
When seeing "Hit any key to stop autoboot," press any key on the keyboard. The prompt shall change from
Supervivi>
to MINI2440 #
. Get the information about the NAND flash:
MINI2440 # nand info
Device 0: NAND 64MiB 3,3V 8-bit, page size 512, sector size 16 KiB
Erase everything on the NAND flash:
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
Please enter a lower case y and press Enter when prompted.
Now create a new partition table
MINI2440 # nand createbbt
Create BBT and erase everything ?
Skipping bad block at 0x03ff0000
Skipping bad block at 0x03ff4000
Skipping bad block at 0x03ff8000
Skipping bad block at 0x03ffc000
Creating BBT. Please wait ...Bad block table not found for chip 0
Bad block table not found for chip 0
Bad block table written to 0x03ffc000, version 0x01
Bad block table written to 0x03ff8000, version 0x01
and partition the NAND flash using u-boot default configuration. Each partition shall be given a name.
MINI2440 # mtdparts
device nand0 <mini2440-nand>, # parts = 4
#: name size offset mask_flags
0: u-boot 0x00040000 0x00000000 0
1: env 0x00020000 0x00040000 0
2: kernel 0x00500000 0x00060000 0
3: root 0x03aa0000 0x00560000 0
active partition: nand0,0 - (u-boot) 0x00040000 @ 0x00000000
defaults:
mtdids : nand0=mini2440-nand
mtdparts: <NULL>
Now write u-boot to NAND flash
MINI2440 # nand write 0x31000000 u-boot
NAND write: device 0 offset 0x0, size 0x40000
262144 bytes written: OK
Reset the on-board switch to NAND flash and reboot mini2440
Step 3: Downloading Linux Kernel
Now you shall see all u-boot informations on the minicom window. Hit any key when you see the promption "Hit any key to stop autoboot."
Now set a NAND flash offset since later you won't want to write stuffs on the area that contains u-boot.
MINI2440 # dynenv set 40000
device 0 offset 0x40000, size 0x3fc0000
45 4e 56 30 - 00 00 04 00
MINI2440 # nand erase kernel
NAND erase: device 0 offset 0x60000, size 0x500000
Erasing at 0x55c000 -- 100% complete.
OK
Copy the Linux kernel image onto an SD card and insert the SD card to the card reader of mini2440. Now initialize the SD card.
MINI2440 # mmcinit
trying to detect SD Card...
Manufacturer: 0x02, OEM "TM"
Product name: "SD01G", revision 2.3
Serial number: 2486075243
Manufacturing date: 1/2002
CRC: 0x72, b0 = 1
READ_BL_LEN=15, C_SIZE_MULT=7, C_SIZE=365
size = 1642070016
Suppose the Linux kernel image has the filename "uImage." Now load it to the RAM first.
MINI2440 # fatload mmc 0:1 0x31000000 uImage
reading uImage
1945804 bytes read
Write the Linux kernel from RAM to the NAND flash partition called "kernel."
MINI2440 # nand write 0x31000000 kernel
NAND write: device 0 offset 0x60000, size 0x500000
5242880 bytes written: OK
Step 4: Downloading GPE Embedded Graphic Environment
Well, at this step, you have plenty of choices. You can try Qtopia, etc. But I prefer GPE, which is GPL'ed and small. Things like GPE are called Root Filesystems. You can follow the same steps that you did for downloading Linux kernel. Just write to NAND partition "root" instead of "kernel."
Initialize SD card
MINI2440 # nand erase root
MINI2440 # mmcinit
trying to detect SD Card...
Manufacturer: 0x02, OEM "TM"
Product name: "SD01G", revision 2.3
Serial number: 2486075243
Manufacturing date: 1/2002
CRC: 0x72, b0 = 1
READ_BL_LEN=15, C_SIZE_MULT=7, C_SIZE=365
size = 1642070016
Load GPE image to RAM, supposing the filename is gpe-image-micro2440.jffs2.
MINI2440 # fatload mmc 0:1 0x31000000 gpe-image-micro2440.jffs2
reading gpe-image-micro2440.jffs2
39239680 bytes read
Since the GPE image is compiled in JFFS2 filesystem, you need to write it as a JFFS2 image.
MINI2440 # nand write.jffs2 0x31000000 root ${filesize}
NAND write: device 0 offset 0x560000, size 0x256c000
Writing data at 0x2acbe00 -- 100% complete.
39239680 bytes written: OK
Finalization
Now you are pretty much done. Just do the two last things as follows
MINI2440 # setenv bootcmd nboot.e kernel \; bootm
MINI2440 # saveenv
Saving Environment to NAND...
Erasing Nand...Writing to Nand... done
Now reset your mini2440 and enjoy!