-
Notifications
You must be signed in to change notification settings - Fork 6
/
step-by-step-note
160 lines (158 loc) · 8.21 KB
/
step-by-step-note
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
1.Try out the original code
# make with the default config
cp arch/arm/configs/friendlyarm_tiny210_defconfig .config
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- menuconfig
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi-
# write image to SD card, and boot from SD
sudo dd if=./barebox.s5p of=/dev/sdb bs=512 seek=1
2.Add dm9000 network support
# set ipaddress on your target board
eth0.ipaddr=192.168.0.100
eth0.netmask=255.255.255.0
# ping your laptop
ping 192.168.0.10
=>host 192.168.0.10 is alive
3.Switch to new environment
# ipaddress is set in arch/arm/boards/friendlyarm-tiny210/env/network/eth0
# tftp file system is auto mounted under /mnt/tftp, you can't ls that dir or use tab to auto complete file names
# on your laptop, echo 'hello world!'> ~/tftp/hello.txt
# on the target board, cat /mnt/tftp/hello.txt
=>hello world!
4.Support skip lowlevel init
# by disable "General settings -> run machine low-level init", you can skip lowlevel init
# then the barebox.bin can be used as a second stage bootloader
# put barebox.bin into ~/tftp/ on your laptop
# on the target boared: cp /mnt/tftp/barebox.bin /dev/ram0 && go /dev/ram0
5.Add SLC NAND support
# BUG in function mtdraw_read_unaligned() in file drivers/mtd/mtdraw.c
# INIT ops.ooboffs to zero, to slove nand_transfer_oob() issue in file drivers/mtd/nand/nand_base.c
# BUG in function mtd_ioctl() in file drivers/mtd/mtdraw.c
# CHANGE mtd_ioctl(), to slove ioctl function problem in mtdraw & mtdoob devices
# ADD SLC driver for both 1-bit & 8-bit ECC, select 8-bit ECC by define CONFIG_S3C_NAND_USE_8BIT_ECC in nand_s5vp210.c
# ADD nanddump command to read & print 1 page nand data, see commands/nanddump.c for more
# TO test the nand driver, make and load barebox.bin to sdram, then use nandtest & nanddump commands
# write random data to the 17th (0x220000 / 0x20000) block, then read out and check if it's right
nandtest -o 0x220000 -l 0x20000 -s 2 -t dev/nand0
# Read out the 17th block with ecc check
nanddump -b 17 -d /dev/nand0
# Read out the oob data of the 17th block
nanddump -b 17 -o
# Read out the raw data of the 17th block
nanddump -b 17 -r
6.Boot the kernel
# increase the heap size to 8MB as the bootm command will copy uImage form tftp server to ramfs, which uses the heap
# add script for basic config: has something to do with the bootargs (commandline)
# add script for nand mtdparts: has something to do with nand booting
# add script for net booting: boot uImage from tftpserver & mount rootfs from nfsserver
# modify the low level serial code of the FriendlyARM kernel so that it can boot from barebox
--- arch/arm/mach-s5pv210/include/mach/uncompress.h.old 2013-04-10 21:59:24.065238578 +0800
+++ arch/arm/mach-s5pv210/include/mach/uncompress.h 2013-04-10 18:07:08.395060709 +0800
@@ -18,7 +18,12 @@
static void arch_detect_cpu(void)
{
- /* we do not need to do any cpu detection here at the moment. */
+ /*
+ * For preventing FIFO overrun or infinite loop of UART console,
+ * fifo_max should be the minimum fifo size of all of the UART channels
+ */
+ fifo_mask = S5PV210_UFSTAT_TXMASK;
+ fifo_max = 15 << S5PV210_UFSTAT_TXSHIFT;
}
--- .config.old 2013-04-10 21:55:24.364049956 +0800
+++ .config 2013-04-10 21:55:07.887968266 +0800
@@ -278,7 +278,7 @@
#
# CONFIG_S3C_BOOT_WATCHDOG is not set
# CONFIG_S3C_BOOT_ERROR_RESET is not set
-CONFIG_S3C_BOOT_UART_FORCE_FIFO=y
+# CONFIG_S3C_BOOT_UART_FORCE_FIFO is not set
CONFIG_S3C_LOWLEVEL_UART_PORT=0
CONFIG_SAMSUNG_CLKSRC=y
CONFIG_SAMSUNG_IRQ_VIC_TIMER=y
# to test net booting, first make the uImage & put it into the tftp dir
make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- uImage && cp arch/arm/boot/uImage ~/tftp/
# and put the rootfs files into the nfs dir (/home/doudou/nfsroot/tiny210)
# install & configure nfs server
sudo apt-get install nfs-kernel-server
sudo vi /etc/exports (add a new line)
/home/doudou/nfsroot/tiny210 192.168.0.*(rw,sync,no_root_squash)
sudo /etc/init.d/portmap restart && sudo /etc/init.d/nfs-kernel-server restart
sudo mount -t nfs 192.168.0.10:/home/doudou/nfsroot/tiny210 /mnt/nfs/ && sudo umount /mnt/nfs
# to test nand booting, first write the uImage into nand flash
erase /dev/nand0.kernel && cp /mnt/tftp/uImage /dev/nand0.kernel
# and configure the root bootarg
global linux.bootargs.dyn.root="root=/dev/nfs nfsroot=192.168.0.10:/home/doudou/nfsroot/tiny210 ip=192.168.0.100:192.168.0.10:192.168.1.1:255.255.255.0::eth0"
# boot from the kernel partition
bootm /dev/nand0.kernel
7.Saving ENV in NAND
The original ENV is generated from the ENV scripts in the defaultenv-2 & $(BOARD)/env directories
Modify ENV scripts in /env/ directory with edit command
Save ENV to /dev/env0 (also /dev/nand0.bareboxenv.bb) with saveenv command
Load ENV from /dev/env0 (also /dev/nand0.bareboxenv.bb) with loadenv command
Updating barebox doesn't change the ENV as it's not in the same partition
You may want to erase /dev/env0 or load env.bin to update it
8.Basic support for NAND BOOT
Disable "System Type --->S3C Features --->[ ] Booting from NAND" feature, make, dd barebox.s5p to SD card
Enable "System Type --->S3C Features --->[*] Booting from NAND" feature, make, copy barebox.s5p to tftp directory
Boot from SD card, erase /dev/nand0.barebox.bb & cp /mnt/tftp/barebox.nand /dev/nand0.barebox.bb
Boot from NAND
9.UBI ROOTFS
Enable "UBI" & "UBIFS" feature, recompile Kernel
Update Barebox & Kernel in the nand flash, boot from nand, update the envfs
Attach UBI device on /dev/nand0.system (on the target)
erase /dev/nand0.system && ubiattach /dev/nand0.system
Skipping bad block at 0x011a0000
Skipping bad block at 0x05040000
Skipping bad block at 0x07180000
Skipping bad block at 0x08840000
Skipping bad block at 0x08ae0000
Skipping bad block at 0x0a880000
Skipping bad block at 0x0fae0000
UBI: attaching mtd0 to ubi0
UBI: physical eraseblock size: 131072 bytes (128 KiB)
UBI: logical eraseblock size: 129024 bytes
UBI: smallest flash I/O unit: 2048
UBI: sub-page size: 512
UBI: VID header offset: 512 (aligned 512)
UBI: data offset: 2048
UBI: empty MTD device detected
UBI: create volume table (copy #1)
UBI: create volume table (copy #2)
registering /dev/ubi0
UBI: attached mtd0 to ubi0
UBI: MTD device name: "nand0.system"
UBI: MTD device size: 242 MiB
UBI: number of good PEBs: 1929
UBI: number of bad PEBs: 7
UBI: max. allowed volumes: 128
UBI: wear-leveling threshold: 4096
UBI: number of internal volumes: 1
UBI: number of user volumes: 0
UBI: available PEBs: 1906
UBI: total number of reserved PEBs: 23
UBI: number of PEBs reserved for bad PEB handling: 19
UBI: max/mean erase counter: 1/0
Make UBI Volume for ROOTFS (on the target)
ubimkvol /dev/ubi0 root 0
Make UBI ROOTFS image (on the laptop)
sudo apt-get install mtd-utils
sudo mkfs.ubifs -r ~/rootfs -m 2048 -e 129024 -c 1906 -o ~/tftp/ubifs.img
-m smallest flash I/O unit (page size)
-e logical eraseblock size
-c available PEBs
-r directory containing rootfs source files
Write ubifs.img into nand flash (on the target)
cp /mnt/tftp/ubifs.img /dev/ubi0.root
Boot from nand flash (on the target)
boot ubi
10.Basic support for MLC NAND
# CHANGE nanddump.c to support mtdraw & mtdoob devices
# CHANGE nand_base.c to support 512/640 byte oob
# CHANGE the size of mtdraw/mtdoob write buffer size to support 8kB large page
# ADD support for mlc nand, according to the ecc layout of the kernel
# ADD support for mlc nand boot, according to the ecc layout of the iROM loader
# ADD support for automatic nand type recognition while nand booting
Disable "System Type --->S3C Features --->[ ] Booting from NAND", this is SD boot version
Enable "System Type --->S3C Features --->[*] Booting from NAND", this is nand boot version
# The SD boot version uses a spical methord to access nand flash, it's only used to update the bootloader in the nand flash
# The nand boot version can not be used to update the bootloader in the nand flash