uboot 编译
make x6818_config
mkimage 在uboot/tools
cp tools/mkmage /usr/bin #为后续内核生成uimage
**uboot启动zImage(go)和uImage(bootm)分析**
bootm加载linux镜像是加载uImage,uImage是由mkimage制作而来,和zImage的差异是uImage是zImage压缩过的,bootm需要先对uImage解压,解压地址为内核入口地址。当解压完成时uImage和zImage几乎是相同的,具体差异可以论述。uboot目前只能支持uImage启动,不支持zImage启动
uboot 命令行输入
mmc list //mmc设备号
mmc 0 for SD1
mmc 1 for SD2
mmc 2 for emmc
mmc erase 0 1000000 // 擦除0 开始1000000个block (1个block 512byte)
1k=0x400; (2)
1M=0x100000;(5)
1G=0x40000000;(7)
fdisk 2 //分区工具 emmc 是设备号2
Partition Map for MMC device 2 -- Partition Type: DOS
Part Start Sector Num Sectors UUID Type
bad MBR sector signature 0x0000
Vendor: Man 000015 Snr f3e44d3a Rev: 0.6 Prod: 8GTF4R
Type: Removable Hard Disk
Capacity: 7456.0 MB = 7.2 GB (15269888 x 512)
fdisk 2 3 0x100000:0x4000000 0x4100000:0x2f200000 0x33300000:0
#emmc (设备号2)分3个区从1M(1024*1024)开始 1M:64M:(819-64)M:保留
ping 192.168.1.8 #uboot 激活网口 x6816 bug
tftp 48000000 ubootpak.bin # 下载uboot到DDR中
Speed: 100, full duplex
Using dwmac.c0060000 device
TFTP from server 192.168.1.8; our IP address is 192.168.1.165
Filename 'ubootpak.bin'.
Load address: 0x48000000
Loading: ########################
4.7 MiB/s
done
Bytes transferred = 341524 (53614 hex)
update_mmc 2 2ndboot 48000000 0x200 53614 # 0x200 让出空间512字节
update_mmc <dev no> <type> <mem> <addr> <length>
<dev no>:flash设备编号 EMMC:2
<type>:类型 2ndboot --- type : 2ndboot | boot | raw | part
<mem>:uboot在内存中的起始地址,以字节为单位
<addr>:flash的起始地址:以块为单位
<length>:往flash中下载多少块空间
fdisk 2 # 查看分区
Partition Map for MMC device 2 -- Partition Type: DOS
Part Start Sector Num Sectors UUID Type
1 2048 131072 00000000-01 83
2 133120 1544192 00000000-02 83
3 1677312 13592576 00000000-03 83
Vendor: Man 000015 Snr f3e44d3a Rev: 0.6 Prod: 8GTF4R
Type: Removable Hard Disk
Capacity: 7456.0 MB = 7.2 GB (15269888 x 512)
set serverip 192.168.1.8
saveenv
tftp 48000000 uImage
mmc write 0x48000000 0x800 0x3000 # 0x48000000---- DDR 地址(字节) 0x800---emmc地址(扇区)0x300--数量(扇区) 一扇区=512byte 0x十六进制 字节地址(十进制)/512=扇区地址(十进制)
mmc write addr blk# cnt
mmc read 48000000 0x800 0x3000
bootm 48000000 (go 480000000) #bootm 带参数, go不带参数跳转;
以上为手动加载内核
自动:
uboot bootcmd
setenv bootcmd mmc read 48000000 800 3000 \; bootm 48000000 #";" 作用命令分隔 bootcmd uboot启动后自动加载第一条命令;
saveevn
printenv bootcmd
bootcmd=mmc read 48000000 800 3000 ; bootm 48000000 #启动加载命令;
tftp 48000000 rootfs_ext4.img #加载文件系统到DDR
mmc write 0x48000000 0x20800 0x32000 #从DDR写入emmc
setenv bootargs root=/dev/mmcblk0p2 rootfstype=ext4 init=/linuxrc console=ttySAC0 maxcpus=1 lcd=wy070ml tp=gslx680 #bootm 所带的参数bootargs
linux kernel下
login:root
Password:123456
tftp -g -r byna_arm 192.168.1.8 #命令作用 -g 获取get -r 远程remote (与uboot下的tftp命令有所区别)
ifconfig eth0 192.168.1.6 #配置网卡IP地址; 为什么启动时没有配置IP地址?
uboot set bootargs 关键参数
exportfs #查看ubuntu nfs目录
setenv bootargs noinitrd root=/dev/nfs nfsroot=192.168.1.8:/rootfs,v3,nolock rw ip=192.168.1.6:192.168.1.8:192.168.1.1:255.255.255.0::eth0:off init=/linuxrc console=ttySAC0 maxcpus=1 lcd=wy070ml tp=gslx680 # OK
setenv bootargs root=/dev/nfs nfsroot=192.168.1.8:/rootfs,v3,nolock rw ip=192.168.1.6:192.168.1.8:192.168.1.1:255.255.255.0 init=/linuxrc console=ttySAC0 maxcpus=1 lcd=wy070ml tp=gslx680 #also oK without eth0:off
setenv bootargs root=/dev/nfs nfsroot=192.168.1.8:/rootfs,v3 ip=192.168.1.6:192.168.1.8:192.168.1.1:255.255.255.0 init=/linuxrc console=ttySAC0 maxcpus=1 lcd=wy070ml tp=gslx680 #ok without nolock rw
setenv bootargs root=/dev/nfs nfsroot=192.168.1.8:/rootfs ip=192.168.1.6:192.168.1.8:192.168.1.1:255.255.255.0::eth0:off init=/linuxrc console=ttySAC0 maxcpus=1 lcd=wy070ml tp=gslx680 #bad without ,v3,nolock rw
setenv bootargs root=/dev/nfs nfsroot=192.168.1.8:/rootfs,nolock rw ip=192.168.1.6:192.168.1.8:192.168.1.1:255.255.255.0 init=/linuxrc console=ttySAC0 maxcpus=1 lcd=wy070ml tp=gslx680 # bad without v3
more important is (v3)
jffs/jffs2 , nor flash
yaffs/yaffs2 .nandflash
ext4 mmc
fat32 sd window
cramfs: linux readonly for DDR
Symbol: CRAMFS [=y] │
│ Type : tristate │
│ Prompt: Compressed ROM file system support (cramfs) │
│ Defined at fs/cramfs/Kconfig:1 │
│ Depends on: MISC_FILESYSTEMS [=y] && BLOCK [=y] │
│ Location: │
│ -> File systems │
│ -> Miscellaneous filesystems (MISC_FILESYSTEMS [=y]) │
│ Selects: ZLIB_INFLATE [=y]
Read-only file system
#server#
mount rootfs_ext4.img /mnt/
mkfs.cramfs /mnt/ rootfs.cramfs
cp rootfs.cramfs /tftpboot/
#uboot #
tftp 48000000 rootfs.cramfs
mmc write 48000000 20800 11f95
set bootargs root=/dev/mmcblk0p2 rootfstype=cramfs init=/linuxrc console=ttySAC0 maxcpus=1 lcd=wy070ml tp=gslx680
saveenv
tftp 48000000 uImage
Ramdisk filesystem
Prompt: RAM block device support │
│ Defined at drivers/block/Kconfig:368 │
│ Depends on: BLK_DEV [=y] │
│ Location: │
│ -> Device Drivers │
│ -> Block devices (BLK_DEV [=y])
cd /home/busybox
dd if /dev/zero of =rootfs.rmdisk bs=1M count=50
sudo mkfs.ext2 rootfs.ramdisk
sudo mount -t ext2 rootfs.ramdisk /mnt
sudo cp install/* /mmt/ -a
sudo umount /mnt
gzip ramdisk_img
dd if=/dev/zero of=ramdisk_img bs=1M count=30
1156 ls
1157 mke2fs ramdisk_img
1158 mount -o loop ramdisk_img /mnt
1159 cp busybox-1.35.0/_install/* /mnt/ -a
1160 sync
1161 cd /mnt/
1162 ls
1163 cd dev/
1164 ls
1165 cd ..
1166 umount /mnt
1167 ls /mnt
1168 cd /home/byna/busybox1.35/
1169 ls
1170 gzip ramdisk_img
1171 ls
1172 cp ramdisk_img.gz /tftpboot/
tftp 48000000 rootfs.ramdisk
mmc write 48000000 20800 4000
bootcmd mmc read 48000000 800 3000 \;mmc read 49000000 20800 4000 \; bootm 48000000
bootargs root=/dev/ram rw initrd=0x49000000,8M init=/linuxrc console=ttySAC0 maxcpus=1 lcd=wy070ml tp=gslx680