linux系(xi)統(tong)移(yi)植的詳細步驟
時間:2018-08-30 來源:未知
系(xi)統(tong)移植(zhi)(zhi)在學習中是比(bi)較難(nan)的(de)(de),對(dui)于系(xi)統(tong)移植(zhi)(zhi)來說可(ke)以(yi)從4個(ge)方面來了解:環境搭(da)建(jian),u-boot,kernel,rootfs,今天(tian)華清遠見的(de)(de)美女(nv)學霸總結(jie)出來系(xi)統(tong)移植(zhi)(zhi)的(de)(de)相關知(zhi)識及(ji)系(xi)統(tong)移植(zhi)(zhi)的(de)(de)過(guo)程,比(bi)較詳(xiang)細
啟動過程:
BL0 --> BL1 --> BL2 --> u-boot --> kernel --> rootfs iROM iRAM iRAM DRAM DRAM DRAM
Sams Sams
上圖中的u-boot指的是 u-boot.bin
BL1,BL2,u-boot.bin共同組(zu)成 u-boot-fs4412.bin
BL1跟CPU相關
BL2跟板子配置相關,BL2初始(shi)化內(nei)存(cun)一、環(huan)境搭建
交(jiao)叉編譯工具鏈網絡配置
tftp服務器配(pei)置
nfs服務器配置
binutils工(gong)具集,addr2line, strip, ... 二、u-boot
u-boot常(chang)用(yong)命令(ling):
1. help
2. 環境變量相關,print,set,save
3. emmc相關的,movi,mmcinfo
4. 數據傳輸,tftp,loadb
5. 運行相關,run,go,bootm,boot;環境變量:bootcmd, bootargs
配(pei)置 make fs4412_config
指(zhi)定交(jiao)叉編譯(yi)(yi),指(zhi)定平臺,可以通過修改(gai)Makefile來實現編譯(yi)(yi) make -j2
移植(zhi):方法參看README中的U-Boot Porting Guide 三(san)、kernel
配置 make menuconfig
指(zhi)定(ding)交叉編譯,指(zhi)定(ding)平臺,可以(yi)通過修改(gai)Makefile來實現編譯 make uImage -j2
移(yi)植:見招拆招
四、rootfs busybox
配置 make menuconfig
指定(ding)交叉編譯,指定(ding)平臺,可以通過(guo)修改Makefile來實現編譯 make -j2
安(an)裝 make install,默認安(an)裝到 _install目錄五、固(gu)化
farsight@ubuntu:$表示在虛擬(ni)機中的(de)(de)(de)操(cao)作(zuo)FS4412 #表示在板(ban)子上(shang)的(de)(de)(de)u-boot中的(de)(de)(de)操(cao)作(zuo)[root@farsight ]#表示板(ban)子上(shang)shell中的(de)(de)(de)操(cao)作(zuo)
1. 固化u-boot
1. 做一個SD卡啟動(dong)盤(pan)
farsight@ubuntu:$ sudo ./sdfuse.sh /dev/sdb u-boot- fs4412.bin
或(huo) 者 直 接(jie) 用 命(ming) 令 :sudo dd iflag=dsync oflag=dsync if=/home/farsight/u-boot-fs4412.bin of=/dev/sdb seek=1
2. 從(cong)SD卡啟動,通過tftp下載(zai) u-boot-fs4412.bin
FS4412 # tftp 40008000 u-boot-fs4412.bin(要提前把網絡配置(zhi)好(hao)(hao),tftp服務(wu)器配置(zhi)好(hao)(hao),環境變量serverip,ipaddr設置(zhi)好(hao)(hao))
3. 燒寫
FS4412 # movi write u-boot 40008000 (此地(di)址(zhi)要與(yu)第2 步中tftp下(xia)載的地(di)址(zhi)一致)
4. 測試一下:從(cong)emmc啟動(dong),看(kan)u-boot能否(fou)啟動(dong)起來(lai)
2. 固化(hua)kernel和設(she)備樹
1. 通過tftp下載 uImage 并燒寫FS4412 # tftp 40008000 uImage
FS4412 # movi write kernel 40008000
2. 通過tftp下載(zai) exynos4412-fs4412.dtb 并燒寫(xie)FS4412 # tftp 40008000 exynos4412-fs4412.dtb FS4412 # movi write dtb 40008000
3. 固化rootfs(通過文件(jian)復制的(de)方式來(lai)實現)
1. 對eMMC進行分區(兩種方法(fa)) 方法(fa)1. 在u-boot里分區
FS4412 # fdisk -c 0 方法(fa)2. 系統(tong)起來之后分區
[root@farsight ]# fdisk -u /dev/mmcblk0
...... 通過(guo)fdisk實現自己需要的分區(qu)
2. 通過NFS掛載根(gen)文件(jian)系(xi)統(tong)來(lai)啟動系(xi)統(tong)
設(she)置bootargs從NFS掛載(zai)根文件系統FS4412 # set bootargs root=/dev/nfs
nfsroot=192.168.123.123:/home/farsight/busybox-1.22.1/_install rw console=ttySAC2,115200 init=/linuxrc ip=192.168.123.111 clk_ignore_unused=true
設置bootcmd從emmc讀取kernel和設備樹,然后啟動FS4412 # set bootcmd movi read kernel 41000000\;
movi read dtb 42000000\; bootm 41000000 - 42000000
FS4412 # save
3. 格式化
[root@farsight ]# mkfs.ext2 /dev/mmcblk0p1
4. 掛載(zai)格式化好的磁盤(pan)
[root@farsight ]# mount -t ext2 /dev/mmcblk0p1 /mnt
5. 通過NFS掛載做好的根文件系(xi)統[root@farsight ]# mount -t nfs -o nolock
192.168.123.123:/home/farsight/busybox-1.22.1/_install /tmp
6. 燒寫(復(fu)制)根文件系統
[root@farsight ]# cp -a /tmp/* /mnt 啟動配置:
FS4412 # set bootargs root=/dev/mmcblk0p1 rw console=ttySAC2,115200 init=/linuxrc ip=192.168.123.111 clk_ignore_unused=true
root=/dev/mmcblk0p1是指定(ding)從(cong)mmc的第一(yi)個分區去掛載根文件系統
FS4412 # save

