首先获取uboot源码

git clone https://github.com/Lichee-Pi/u-boot.git -b v3s-current
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LicheePi_Zero_800x480LCD_defconfig
make ARCH=arm menuconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-  -j16

根据自己的屏幕去选择配置文件 我这里是5寸RGB屏幕
选择了 LicheePi_Zero_800x480LCD_defconfig
另外还有
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LicheePi_Zero480x272LCD_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LicheePi_Zero_defconfig

全志方案 怎样导出镜像 制作_全志方案 怎样导出镜像 制作


最后生成了bin文件

到此为止 U-BOOT准备完成了

下面开始编译Linux

Linux

首先获取Linux源码

git clone -b zero-5.2.y --depth 1 https://github.com/Lichee-Pi/linux.git
make licheepi_zero_defconfig
make menuconfig
make -j16
make -j16 INSTALL_MOD_PATH=out modules
make -j16 INSTALL_MOD_PATH=out modules_install
make dtbs

编译完成后,zImage在**arch/arm/boot/**下,驱动模块在out/下。

全志方案 怎样导出镜像 制作_ci_02


设备树文件在arch/arm/boot/dts/

我使用的事5寸屏幕
使用使用的设备树文件是
sun8i-v3s-licheepi-zero-with-800x480-lcd.dtb

buildroot

下面开始编译buildroot-
首先获取buildroot源码

wget https://buildroot.org/downloads/buildroot-2021.02.4.tar.gz

然后解压

全志方案 怎样导出镜像 制作_ci_03


配置

make menuconfig

全志方案 怎样导出镜像 制作_运维_04


修改如下图所示

全志方案 怎样导出镜像 制作_arm开发_05


设置编译链

全志方案 怎样导出镜像 制作_arm开发_06


接着要查看编译器的版本

全志方案 怎样导出镜像 制作_arm开发_07

cat version.h

全志方案 怎样导出镜像 制作_全志方案 怎样导出镜像 制作_08


263680的二进制为0x40A03,则对应的内核版本号为4.10.3。

然后我们选择这个版本

全志方案 怎样导出镜像 制作_运维_09


同时这几个也勾上

全志方案 怎样导出镜像 制作_arm开发_10


还可以设置主机名,root密码,配置自己需要的软件包等

下面开始编译

make

如果编译失败请检查交叉编译器的路径然后出现编译

或者尝试make clean后再重新编译

在这个过程中比较漫长 因为需要下载一些软件包,慢慢等待吧!!!

全志方案 怎样导出镜像 制作_运维_11

到此为止
U-BOOT Linux 文件系统都准备好了 下面开始烧录

在烧录之前我们需要准备一张SD卡
然后下载一个工具

GParted分区工具

全志方案 怎样导出镜像 制作_全志方案 怎样导出镜像 制作_12

这个软件去Ubuntu应用商店直接下载即可
打开软件后把右上角切换成当前的SD卡 注意 这里千万别搞错了

全志方案 怎样导出镜像 制作_运维_13


然后卸载掉当前的分区

全志方案 怎样导出镜像 制作_linux_14


然后删除分区

全志方案 怎样导出镜像 制作_linux_15


然后添加分区

全志方案 怎样导出镜像 制作_arm开发_16


全志方案 怎样导出镜像 制作_linux_17


然后再添加一个ext4分区 如下图所示

全志方案 怎样导出镜像 制作_ci_18


然后如下图所示 点√进行保存操作然后完成分区

全志方案 怎样导出镜像 制作_运维_19


下面开始烧写U-Boot然后查看SD卡看到了有3个分区

全志方案 怎样导出镜像 制作_运维_20


下面开始烧录uboot

sudo dd if=u-boot-sunxi-with-spl.bin of=/dev/sdb bs=1024 seek=8

要注意bin文件的路径

全志方案 怎样导出镜像 制作_运维_21


Uboot 烧录完成

下面就是zImage和dtb了

把Linux编译好的zImage复制到BOOT分区

cp arch/arm/boot/zImage  /media/dwh/BOOT

把Linux编译好的dtb复制到BOOT分区
我这个是5寸800x480屏幕

cp arch/arm/boot/dts/sun8i-v3s-licheepi-zero-with-800x480-lcd.dtb  /media/dwh/BOOT

这时候 zImage 和 dtb就复制好了

下面开始复制rootfs

首先进入该目录

buildroot-2021.02.4/output/images

这里的rootfs文件

全志方案 怎样导出镜像 制作_linux_22


解压到 rootfs分区

sudo tar -xvf ./rootfs.tar -C /media/dwh/rootfs/

下面就全部搞定了

这个时把SD卡插上去就可以跑起来了 但是 进入文件系统后串口可能无法使用 这时候我们还需要在文件系统的

cd etc/ inittab 
sudo vim inittab

打开后加入

ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100

全志方案 怎样导出镜像 制作_运维_23

保存退出!!!

下面把卡插入板子

然后使用一个CH340串口调试工具连接板子的uart0

打开xshell

全志方案 怎样导出镜像 制作_ci_24

全志方案 怎样导出镜像 制作_ci_25


可以看到U-BOOT已经启动了

这时候我们需要设置一下启动参数

setenv bootcmd 'load mmc 0:1 0x41000000 zImage;load mmc 0:1 0x41800000 sun8i-v3s-licheepi-zero-with-800x480-lcd.dtb;bootz 0x41000000 - 0x41800000;'
setenv bootargs console=ttyS0,115200 panic=5 console=tty0 rootwait root=/dev/mmcblk0p2 earlyprintk rw vt.global_cursor_default=0
saveenv

全志方案 怎样导出镜像 制作_全志方案 怎样导出镜像 制作_26


然后重启板子

全志方案 怎样导出镜像 制作_arm开发_27


最后成功进入文件系统

输入用户名 root

全志方案 怎样导出镜像 制作_运维_28


同时板子也成功显示

全志方案 怎样导出镜像 制作_运维_29


最后附上Log

U-Boot 2017.01-rc2-00057-g32ab180 (May 31 2022 - 21:56:37 +0800) Allwinner Technology

CPU:   Allwinner V3s (SUN8I 1681)
Model: Lichee Pi Zero
DRAM:  64 MiB
MMC:   SUNXI SD/MMC: 0
Setting up a 800x480 lcd console (overscan 0x0)
dotclock: 33000kHz = 33000kHz: (1 * 3MHz * 66) / 6
In:    serial@01c28000
Out:   serial@01c28000
Err:   serial@01c28000
Net:   No ethernet found.
starting USB...
No controllers found
Hit any key to stop autoboot:  0 
reading zImage
4179416 bytes read in 218 ms (18.3 MiB/s)
reading sun8i-v3s-licheepi-zero-with-800x480-lcd.dtb
11757 bytes read in 29 ms (395.5 KiB/s)
## Flattened Device Tree blob at 41800000
   Booting using the fdt blob at 0x41800000
   Loading Device Tree to 42dfa000, end 42dffdec ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 5.2.0-licheepi-zero+ (dwh@dwh) (gcc version 7.2.1 20171011 (Linaro GCC 7.2-2017.11)) #2 SMP Mon May 30 23:29:23 CST 2022
[    0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt: Machine model: Lichee Pi Zero
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] percpu: Embedded 16 pages/cpu s34508 r8192 d22836 u65536
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 15883
[    0.000000] Kernel command line: console=ttyS0,115200 panic=5 console=tty0 rootwait root=/dev/mmcblk0p2 earlyprintk rw vt.global_cursor_default=0
[    0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes, linear)
[    0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 53548K/64036K available (6144K kernel code, 301K rwdata, 1676K rodata, 1024K init, 252K bss, 10488K reserved, 0K cma-reserved, 0K highmem)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] rcu: Hierarchical RCU implementation.
[    0.000000] rcu: 	RCU event tracing is enabled.
[    0.000000] rcu: 	RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=1.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
[    0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000000] random: get_random_bytes called from start_kernel+0x2f8/0x484 with crng_init=0
[    0.000000] arch_timer: cp15 timer(s) running at 24.00MHz (virt).
[    0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x588fe9dc0, max_idle_ns: 440795202592 ns
[    0.000008] sched_clock: 56 bits at 24MHz, resolution 41ns, wraps every 4398046511097ns
[    0.000020] Switching to timer-based delay loop, resolution 41ns
[    0.000208] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[    0.000450] Console: colour dummy device 80x30
[    0.000741] printk: console [tty0] enabled
[    0.000799] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=240000)
[    0.000830] pid_max: default: 32768 minimum: 301
[    0.001001] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.001034] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.001865] CPU: Testing write buffer coherency: ok
[    0.002398] /cpus/cpu@0 missing clock-frequency property
[    0.002444] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[    0.003269] Setting up static identity map for 0x40100000 - 0x40100060
[    0.003521] rcu: Hierarchical SRCU implementation.
[    0.004087] smp: Bringing up secondary CPUs ...
[    0.004130] smp: Brought up 1 node, 1 CPU
[    0.004146] SMP: Total of 1 processors activated (48.00 BogoMIPS).
[    0.004161] CPU: All CPU(s) started in SVC mode.
[    0.005282] devtmpfs: initialized
[    0.008768] VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5
[    0.009105] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.009154] futex hash table entries: 256 (order: 2, 16384 bytes, linear)
[    0.009429] pinctrl core: initialized pinctrl subsystem
[    0.010650] NET: Registered protocol family 16
[    0.011209] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.012492] hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.
[    0.012537] hw-breakpoint: maximum watchpoint size is 8 bytes.
[    0.036364] SCSI subsystem initialized
[    0.036583] usbcore: registered new interface driver usbfs
[    0.036653] usbcore: registered new interface driver hub
[    0.036767] usbcore: registered new device driver usb
[    0.037013] mc: Linux media interface: v0.10
[    0.037069] videodev: Linux video capture interface: v2.00
[    0.037316] Advanced Linux Sound Architecture Driver Initialized.
[    0.038681] clocksource: Switched to clocksource arch_sys_counter
[    0.051059] NET: Registered protocol family 2
[    0.051924] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 6144 bytes, linear)
[    0.051995] TCP established hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.052035] TCP bind hash table entries: 1024 (order: 1, 8192 bytes, linear)
[    0.052066] TCP: Hash tables configured (established 1024 bind 1024)
[    0.052229] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.052294] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.052617] NET: Registered protocol family 1
[    0.054550] Initialise system trusted keyrings
[    0.054959] workingset: timestamp_bits=30 max_order=14 bucket_order=0
[    0.099130] Key type asymmetric registered
[    0.099175] Asymmetric key parser 'x509' registered
[    0.099290] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 250)
[    0.099315] io scheduler mq-deadline registered
[    0.099329] io scheduler kyber registered
[    0.100405] sun4i-usb-phy 1c19400.phy: Couldn't request ID GPIO
[    0.104247] sun8i-v3s-pinctrl 1c20800.pinctrl: initialized sunXi PIO driver
[    0.104710] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pb not found, using dummy regulator
[    0.105503] pwm-backlight backlight: backlight supply power not found, using dummy regulator
[    0.172473] Serial: 8250/16550 driver, 8 ports, IRQ sharing disabled
[    0.175838] printk: console [ttyS0] disabled
[    0.196177] 1c28000.serial: ttyS0 at MMIO 0x1c28000 (irq = 34, base_baud = 1500000) is a U6_16550A
[    0.718984] printk: console [ttyS0] enabled
[    0.724911] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pe not found, using dummy regulator
[    0.759463] panel-simple panel: panel supply power not found, using dummy regulator
[    0.768918] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    0.775482] ehci-platform: EHCI generic platform driver
[    0.781052] ehci-platform 1c1a000.usb: EHCI Host Controller
[    0.786685] ehci-platform 1c1a000.usb: new USB bus registered, assigned bus number 1
[    0.794712] ehci-platform 1c1a000.usb: irq 26, io mem 0x01c1a000
[    0.828685] ehci-platform 1c1a000.usb: USB 2.0 started, EHCI 1.00
[    0.835916] hub 1-0:1.0: USB hub found
[    0.839905] hub 1-0:1.0: 1 port detected
[    0.844555] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    0.850902] ohci-platform: OHCI generic platform driver
[    0.856466] ohci-platform 1c1a400.usb: Generic Platform OHCI controller
[    0.863208] ohci-platform 1c1a400.usb: new USB bus registered, assigned bus number 2
[    0.871213] ohci-platform 1c1a400.usb: irq 27, io mem 0x01c1a400
[    0.943790] hub 2-0:1.0: USB hub found
[    0.947663] hub 2-0:1.0: 1 port detected
[    0.955001] usbcore: registered new interface driver usb-storage
[    0.962652] sun6i-rtc 1c20400.rtc: registered as rtc0
[    0.967739] sun6i-rtc 1c20400.rtc: RTC enabled
[    0.972484] i2c /dev entries driver
[    0.977415] input: ns2009_ts as /devices/platform/soc/1c2ac00.i2c/i2c-0/0-0048/input/input0
[    0.987129] sunxi-wdt 1c20ca0.watchdog: Watchdog enabled (timeout=16 sec, nowayout=0)
[    0.995861] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pf not found, using dummy regulator
[    1.031344] sunxi-mmc 1c0f000.mmc: initialized, max. request size: 16384 KB
[    1.038955] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pg not found, using dummy regulator
[    1.050406] usbcore: registered new interface driver usbhid
[    1.056009] usbhid: USB HID core driver
[    1.062645] Initializing XFRM netlink socket
[    1.066983] NET: Registered protocol family 17
[    1.072179] Registering SWP/SWPB emulation handler
[    1.078074] Loading compiled-in X.509 certificates
[    1.088212] simple-framebuffer 43e89000.framebuffer: framebuffer at 0x43e89000, 0x177000 bytes, mapped to 0x(ptrval)
[    1.098927] simple-framebuffer 43e89000.framebuffer: format=x8r8g8b8, mode=800x480x32, linelength=3200
[    1.115186] Console: switching to colour frame buffer device 100x30
[    1.131419] simple-framebuffer 43e89000.framebuffer: fb0: simplefb registered!
[    1.143764] sun8i-v3s-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pe not found, using dummy regulator
[    1.163874] sun4i-drm display-engine: bound 1100000.mixer (ops 0xc0746880)
[    1.175437] sun4i-drm display-engine: bound 1c0c000.lcd-controller (ops 0xc0743b7c)
[    1.187164] [drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[    1.197760] [drm] No driver support for vblank timestamp query.
[    1.207638] fb0: switching to sun4i-drm-fb from simple
[    1.217627] Console: switching to colour dummy device 80x30
[    1.224361] [drm] Initialized sun4i-drm 1.0.0 20150629 for display-engine on minor 0
[    1.261570] mmc0: host does not support reading read-only switch, assuming write-enable
[    1.263571] mmc0: new high speed SDHC card at address 0001
[    1.265408] mmcblk0: mmc0:0001 SD4GB 3.72 GiB 
[    1.267525]  mmcblk0: p1 p2
[    1.284589] Console: switching to colour frame buffer device 100x30
[    1.349751] sun4i-drm display-engine: fb0: sun4i-drmdrmfb frame buffer device
[    1.360891] usb_phy_generic usb_phy_generic.0.auto: usb_phy_generic.0.auto supply vcc not found, using dummy regulator
[    1.378883] musb-hdrc musb-hdrc.1.auto: MUSB HDRC host driver
[    1.387917] musb-hdrc musb-hdrc.1.auto: new USB bus registered, assigned bus number 3
[    1.400407] hub 3-0:1.0: USB hub found
[    1.407576] hub 3-0:1.0: 1 port detected
[    1.416048] sun6i-rtc 1c20400.rtc: setting system clock to 1970-01-01T00:02:28 UTC (148)
[    1.427906] vcc3v0: disabling
[    1.434245] vcc5v0: disabling
[    1.440462] ALSA device list:
[    1.446502]   No soundcards found.
[    1.467990] random: fast init done
[    1.475910] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    1.487383] VFS: Mounted root (ext4 filesystem) on device 179:2.
[    1.497881] devtmpfs: mounted
[    1.505222] Freeing unused kernel memory: 1024K
[    1.512920] Run /sbin/init as init process
[    1.638954] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
[    1.853875] random: dd: uninitialized urandom read (512 bytes read)

Welcome to Buildroot
buildroot login: root
# ls
# cd /
# ls
bin         lib         lost+found  opt         run         tmp
dev         lib32       media       proc        sbin        usr
etc         linuxrc     mnt         root        sys         var
# [   80.558876] random: crng init done