chapter 5. burn the linux system image into nand flash · 2013-03-07 · 1410 cannon mountain dr...

28
1410 Cannon Mountain Dr Longmont, Co 80503 1 Chapter 5. Burn the Linux system image into nand flash Images of bootloader, kernel and rootfs are all burned into nand flash. So we need to first understand the nand partitions to prevent the overlap of different images: Image Name Address Range Description bootloader 0x00000000-0x0003FFFF Burn Uboot kernel 0x00040000-0x003FFFFF Burn kerne cramfs 0x00400000-0x007FFFFF Burn cramfs file system as backup Ubifs 0x00900000-0x3FFFFFFF Burn ubifs file system a main file system 5.1 Burn bootloader 5.1.1 Burning of uboot for SD boot In the absence of JTAG emulator, for a blank board, you can boot from S3C6410's MMC / SD to burn a usable uboot into nand flash. The procedure is as following: In Windows, use utility “tools/IROM_Fusing_Tool” to burn a uboot of MMC/ SD boot version to SD card.

Upload: others

Post on 15-Apr-2020

11 views

Category:

Documents


0 download

TRANSCRIPT

1410 Cannon Mountain Dr

Longmont, Co 80503

1

Chapter 5. Burn the Linux system image into nand flash

Images of bootloader, kernel and rootfs are all burned into nand flash. So we need to first

understand the nand partitions to prevent the overlap of different images:

Image

Name Address Range Description

bootloader 0x00000000-0x0003FFFF Burn Uboot

kernel 0x00040000-0x003FFFFF Burn kerne

cramfs 0x00400000-0x007FFFFF Burn cramfs file system as

backup

Ubifs 0x00900000-0x3FFFFFFF Burn ubifs file system a main file

system

5.1 Burn bootloader

5.1.1 Burning of uboot for SD boot

In the absence of JTAG emulator, for a blank board, you can boot from S3C6410's MMC /

SD to burn a usable uboot into nand flash.

The procedure is as following:

In Windows, use utility “tools/IROM_Fusing_Tool” to burn a uboot of MMC/ SD boot

version to SD card.

1410 Cannon Mountain Dr

Longmont, Co 80503

2

Please don’t insert SD card directly into your SD card slot in your laptop. In most cases,

this doesn’t work. Please format SD card in FAT32, and insert through a USB card reader

into your PC.

Please note that here we need to choose u-boot_mmc.bin which is for SD boot.

1410 Cannon Mountain Dr

Longmont, Co 80503

3

Remove and insert the SD into the SD slot of the LS6410 development board. Setting the

board's DIP switch to boot from SD card.

Run tools/dnw and configure this tool:

1. Config the serial port that is going to be used.

1410 Cannon Mountain Dr

Longmont, Co 80503

4

2. Connect to this serial device:

1410 Cannon Mountain Dr

Longmont, Co 80503

5

Power on LS6410 development board, DNW will print out the booting information

(please HIT ANY KEY to STOP autoBOOT):

1410 Cannon Mountain Dr

Longmont, Co 80503

6

1.1.2.Burn uboot of NandFlash

When we get SD-uboot, we can use SD-uboot to burn other code into the board's Nandflash.

Here we are going to be show to burn NAND-uboot into NAND. The steps are as follows:

If you cannot use tftp in the Ubuntu so far to download, you can use USB download in the

Windows to download uboot.

Note: If this is the first time to write linux image, it’s recommend to erase the whole

nand flash before writing. The command is: nand erase 0

First step: Use USB download in Windows to download uboot into RAM

Type USB download command in DNW:

1410 Cannon Mountain Dr

Longmont, Co 80503

7

If you are first time to use this function, it will prompt to install USB driver. After install USB

driver,

1410 Cannon Mountain Dr

Longmont, Co 80503

8

Select u-boot.bin, which is the nand boot uboot, do not select SD-u-boot_mmc.bin, which is

for SD boot.

1410 Cannon Mountain Dr

Longmont, Co 80503

9

1410 Cannon Mountain Dr

Longmont, Co 80503

10

Here uboot has been downloaded to RAM 0xC0008000 location.

Second step is to burn uboot to NAND.

Uboot needs to be written to nand addressed starting from 0 and size of 256KB. Before write,

we need to erase the area first:

nand erase 0 40000

1410 Cannon Mountain Dr

Longmont, Co 80503

11

Next is to write uboot in RAM 0xc0008000 to nand 0-256KB.

nand write c0008000 0 40000

1410 Cannon Mountain Dr

Longmont, Co 80503

12

Until here, nand uboot has been written into flash. Set boot DIP to NAND boot, after resetting

the board, the board will output the following information:

1410 Cannon Mountain Dr

Longmont, Co 80503

13

The above process is to use USB to download to the nand. In the following, we are going to

show how to boot from SD uboot, and then use tftp to write nand uboot to nand.

First step is to copy u-boot.bin to tftp’s share directory /tftpboot/.

The second step is to use tftp command to download u-boot.bin to RAM address 0xc0008000:

tftp c0008000 u-boot.bin

1410 Cannon Mountain Dr

Longmont, Co 80503

14

The third step is same as USB download more, i.e., erase nand’s first 256KB:

nand erase 0 40000

The fourth step is to write uboot in RAM 0xc0008000 to nand’s first 256KB:

nand write c0008000 0 40000

5.2 Burn kernel

First step: Download kernel binary to RAM by USB download

dnw

1410 Cannon Mountain Dr

Longmont, Co 80503

15

Open zImage under linux\linux-image, and download the kernel image to the RAM of

LS6410 development board:

1410 Cannon Mountain Dr

Longmont, Co 80503

16

After download is finished:

The second step: Erase the area of the nand where kernel is going to be written:

1410 Cannon Mountain Dr

Longmont, Co 80503

17

nand erase 40000 300000

The third step is to written kernel into the nandflash:

nand write c0008000 40000 300000

1410 Cannon Mountain Dr

Longmont, Co 80503

18

The fourth step is to verify if kernel can boot or not:

After LS6410 development board is reset, copy kernel from nand to RAM 0xC0008000:

nand read c0008000 40000 300000

Next is to boot from the kernel:

bootm c0008000

1410 Cannon Mountain Dr

Longmont, Co 80503

19

When you see the above information, it means that kernel is burned successfully.

5.3 Burn cramfs

Android or the root file system with Qtopia can use the writable file systems such as yaffs or

ubifs. But in our testing process, yaffs is not stable, even with the path from Google. So we

chose to use ubifs, which has much better performance. Ubifs were developed by IBM and

other companies, and were adopted in linux kernel after 2.6.27.

But the nand driver of the current version of uboot has bad support of ubifs/yaffs2. We are

going to use cramfs as intermediate file system to realize ubifs/yaffs2. So we are going to

first introduce how to burn cramfs to the board, and we recommend not to remove cramfs

until the file system is debugged so that we can use it when updating ubifs/yaffs2.

In order not to confuse the user, we emphasize again that ubifs is the final file system and

cramfs is only stepstone. As a follow up, we are going update uboot so that it can direcly

support ubifs.

1410 Cannon Mountain Dr

Longmont, Co 80503

20

Note: if directly burn ubifs/yaffs images under the current uboot, it will

cause large amount of bad blocks in nand. So please DO NOT DO THAT.

android\android-image\rootfs.cramfs is the minimal file system we built to burn ubifs/yaffs.

We will download cramfs to the RAM and then write to cramfs partition of nandflash.

The steps are as follows:

First step is to download cramfs to RAM by USB download:

dnw

The second step is to erase cramfs partition in nand:

1410 Cannon Mountain Dr

Longmont, Co 80503

21

nand erase 400000 400000

The third step is to write cramfs in RAM to cramfs partition in nand flash:

nand write c0008000 400000 400000

The fourth step is to check if cramfs is burned successfully:

setenv bootargs noinitrd root=/dev/mtdblock0 console=ttySAC0 init=/linuxrc

saveenv

1410 Cannon Mountain Dr

Longmont, Co 80503

22

If the kernel has been programmed in the previous step, then reboot after the board

should be able to boot the kernel successfully, and successfully mount the cramfs:

1410 Cannon Mountain Dr

Longmont, Co 80503

23

Till here, the kernel has been successfully launched, and has mounted cramfs.

5.4 Burn ubifs root file system

The previous step is step stone for burning ubifs. It will not be needed after uboot is

updated. Now we proceed to burn ubifs.

First step is to copy qtopia file system 统 linux\linux-image\qtopia.tar.gz to SD card, and

plug in to LS6410 development board. After power cycle the board, kernel will boot and

mount cramfs:

1410 Cannon Mountain Dr

Longmont, Co 80503

24

Here it is prompted to ask if you will format the second partition of nand flash. In the

kernel, there are two partitions in nand, one is cramfs, size is 4MB, ie. Mtdblock0. The

other is ubifs, size: 1G-8G B, ie, mtdblock1.

NoteL: The nand flash space for boot loader, kernel don’t have partition. This is to protect

them from unintended operations.

Press a to format ubifs partition, and after format, the following screen will show up:

1410 Cannon Mountain Dr

Longmont, Co 80503

25

The second step is to choose qtopia root file system or Android root file system. The

difference between linux and android are here.

Here we press b:

1410 Cannon Mountain Dr

Longmont, Co 80503

26

Now ubifs are burned, and we can test if the file system works.

First, we need to reset to enter into uboot’s menu, and change the kernet boot parameters.

Kernel will no longer mount cramfs in mtdblock0, but ubifs in mtdblock1:

setenv bootargs noinitrd console=ttySAC0 init=/init ubi.mtd=1 root=ubi0:rootfs

rootfstype=ubifs

Next we use saveenv command to save these parameters:

1410 Cannon Mountain Dr

Longmont, Co 80503

27

1410 Cannon Mountain Dr

Longmont, Co 80503

28