milkv-duo启动流程分析:手动构建boot.sd

上电测试

在上一篇,我们构建了fip.bin。让我们继续用以前的boot.sd。我们插上电源,

U-Boot 2021.10 (Oct 15 2023 - 14:17:51 +0800)cvitek_cv180x

DRAM:  63.3 MiB
gd->relocaddr=0x82435000. offset=0x2235000
MMC:   cv-sd@4310000: 0
Loading Environment from <NULL>... OK
In:    serial
Out:   serial
Err:   serial
Net:
Warning: ethernet@4070000 (eth0) using random MAC address - 56:01:b8:60:16:bc
eth0: ethernet@4070000
cv180x_c906#

并没有进入linux系统。这是因为我们没有设置好bootargs。手动输入

set bootargs root=/dev/mmcblk0p2 rootwait rw console=ttyS0,115200 earlycon=sbi loglevel=9 riscv.fwsz=0x80000
printenv # 验证bootargs是否设置好
mmc dev 0
fatload mmc 0 0x81400000 boot.sd
bootm 0x81400000#config-cv1800b_milkv_duo_sd

此时,成功加载linux内核。输出如下:

cv180x_c906# set bootargs root=/dev/mmcblk0p2 rootwait rw console=ttyS0,115200 earlycon=sbi loglevel=9 riscv.fwsz=0x80000
cv180x_c906# printenv
baudrate=115200
bootargs=root=/dev/mmcblk0p2 rootwait rw console=ttyS0,115200 earlycon=sbi loglevel=9 riscv.fwsz=0x80000
bootdelay=1
fdtcontroladdr=81beee70
gatewayip=192.168.0.11
ipaddr=192.168.0.3
netmask=255.255.255.0
serverip=192.168.56.101
stderr=serial
stdin=serial
stdout=serial

Environment size: 287/131068 bytes
cv180x_c906# mmc dev 0
switch to partitions #0, OK
mmc0 is current device
cv180x_c906# fatload mmc 0 0x81400000 boot.sd
2748016 bytes read in 123 ms (21.3 MiB/s)
cv180x_c906# bootm 0x81400000#config-cv1800b_milkv_duo_sd
## Loading kernel from FIT Image at 81400000 ...
   Using 'config-cv1800b_milkv_duo_sd' configuration
   Trying 'kernel-1' kernel subimage
   Verifying Hash Integrity ... crc32+ OK
## Loading fdt from FIT Image at 81400000 ...
   Using 'config-cv1800b_milkv_duo_sd' configuration
   Trying 'fdt-cv1800b_milkv_duo_sd' fdt subimage
   Verifying Hash Integrity ... sha256+ OK
   Booting using the fdt blob at 0x81699d8c
   Uncompressing Kernel Image
   Decompressing 6128640 bytes used 1022ms
   Loading Device Tree to 0000000081be5000, end 0000000081becb80 ... OK

Starting kernel ...

[    0.000000] Linux version 5.10.4-tag- (ubuntu@linux) (riscv64-unknown-linux-musl-gcc (Xuantie-900 linux-5.10.4 musl gcc Toolchain V2.6.1 B-20220906) 10.2.0, GNU ld (GNU Binutils) 2.35) #1 PREEMPT Fri Sep 8 17:23:15 CST 2023
[    0.000000] earlycon: sbi0 at I/O port 0x0 (options '')
[    0.000000] printk: bootconsole [sbi0] enabled
[    0.000000] efi: UEFI not found.
[    0.000000] Ion: Ion memory setup at 0x0000000082473000 size 26 MiB
[    0.000000] OF: reserved mem: initialized node ion, compatible id ion-region
[    0.000000] Zone ranges:
[    0.000000]   DMA32    [mem 0x0000000080000000-0x0000000083f3ffff]
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000080000000-0x0000000083f3ffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000080000000-0x0000000083f3ffff]
[    0.000000] On node 0 totalpages: 16192
[    0.000000]   DMA32 zone: 222 pages used for memmap
[    0.000000]   DMA32 zone: 0 pages reserved
[    0.000000]   DMA32 zone: 16192 pages, LIFO batch:3
[    0.000000] SBI specification v0.3 detected
[    0.000000] SBI implementation ID=0x1 Version=0x9
[    0.000000] SBI v0.2 TIME extension detected
[    0.000000] SBI v0.2 IPI extension detected
[    0.000000] SBI v0.2 RFENCE extension detected
[    0.000000] riscv: ISA extensions acdfimsuv
[    0.000000] riscv: ELF capabilities acdfimv
[    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000] pcpu-alloc: [0] 0
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 15970
[    0.000000] Kernel command line: root=/dev/mmcblk0p2 rootwait rw console=ttyS0,115200 earlycon=sbi loglevel=9 riscv.fwsz=0x80000
[    0.000000] Dentry cache hash table entries: 8192 (order: 4, 65536 bytes, linear)
[    0.000000] Inode-cache hash table entries: 4096 (order: 3, 32768 bytes, linear)
[    0.000000] Sorting __ex_table...
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 29360K/64768K available (3671K kernel code, 457K rwdata, 1651K rodata, 144K init, 195K bss, 35408K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] rcu: Preemptible hierarchical RCU implementation.
[    0.000000] rcu:     RCU event tracing is enabled.
[    0.000000]  Trampoline variant of Tasks RCU enabled.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
[    0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[    0.000000] riscv-intc: 64 local interrupts mapped
[    0.000000] plic: interrupt-controller@70000000: mapped 101 interrupts with 1 handlers for 2 contexts.
[    0.000000] random: get_random_bytes called from start_kernel+0x2e0/0x41c with crng_init=0
[    0.000000] riscv_timer_init_dt: Registering clocksource cpuid [0] hartid [0]
[    0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x5c40939b5, max_idle_ns: 440795202646 ns
[    0.000009] sched_clock: 64 bits at 25MHz, resolution 40ns, wraps every 4398046511100ns
[    0.008426] Calibrating delay loop (skipped), value calculated using timer frequency.. 50.00 BogoMIPS (lpj=100000)
[    0.019130] pid_max: default: 4096 minimum: 301
[    0.024024] Mount-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.031443] Mountpoint-cache hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.041123] ASID allocator initialised with 65536 entries
[    0.046851] rcu: Hierarchical SRCU implementation.
[    0.052224] EFI services will not be available.
[    0.057315] devtmpfs: initialized
[    0.066811] early_time_log: do_initcalls: 213042185us
[    0.072655] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.082707] futex hash table entries: 16 (order: -4, 384 bytes, linear)
[    0.089676] pinctrl core: initialized pinctrl subsystem
[    0.095592] NET: Registered protocol family 16
[    0.100657] DMA: preallocated 128 KiB GFP_KERNEL pool for atomic allocations
[    0.107988] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations
[    0.116886] thermal_sys: Registered thermal governor 'step_wise'
[    0.132712] OF: /gpio@03020000/gpio-controller@0: could not find phandle
[    0.145927] OF: /gpio@03021000/gpio-controller@1: could not find phandle
[    0.152921] OF: /gpio@03022000/gpio-controller@2: could not find phandle
[    0.159909] OF: /gpio@03023000/gpio-controller@3: could not find phandle
[    0.166896] OF: /gpio@05021000/gpio-controller@4: could not find phandle
[    0.175708] clk reset: nr_reset=64 resource_size=8
[    0.181298] get audio clk=24576000
[    0.184841] cvitek-i2s-subsys 4108000.i2s_subsys: Set clk_sdma_aud0~3 to 24576000
[    0.205583] dw_dmac 4330000.dma: CVITEK DMA Controller, 8 channels, probe done!
[    0.213990] SCSI subsystem initialized
[    0.218421] usbcore: registered new interface driver usbfs
[    0.224202] usbcore: registered new interface driver hub
[    0.229820] usbcore: registered new device driver usb
[    0.238579] Ion: ion_parse_dt_heap_common: id 0 type 2 name carveout align 1000
[    0.246526] Ion: rmem_ion_device_init: heap carveout base 0x0000000082473000 size 0x0000000001acd000 dev (____ptrval____)
[    0.257809] ion_carveout_heap_create, size=0x1acd000
[    0.263119] cvi_get_rtos_ion_size, rtos ion_size get:0x0
[    0.398492] platform carveout: [ion] add heap id 0, type 2, base 0x82473000, size 0x1acd000
[    0.407494] Advanced Linux Sound Architecture Driver Initialized.
[    0.415155] clocksource: Switched to clocksource riscv_clocksource
[    0.423753] NET: Registered protocol family 2
[    0.429400] tcp_listen_portaddr_hash hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.438104] TCP established hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.445895] TCP bind hash table entries: 512 (order: 0, 4096 bytes, linear)
[    0.453168] TCP: Hash tables configured (established 512 bind 512)
[    0.459775] UDP hash table entries: 128 (order: 0, 4096 bytes, linear)
[    0.466543] UDP-Lite hash table entries: 128 (order: 0, 4096 bytes, linear)
[    0.474011] NET: Registered protocol family 1
[    0.479224] RPC: Registered named UNIX socket transport module.
[    0.485337] RPC: Registered udp transport module.
[    0.490220] RPC: Registered tcp transport module.
[    0.495154] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.504431] Initialise system trusted keyrings
[    0.509347] workingset: timestamp_bits=62 max_order=13 bucket_order=0
[    0.524247] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.531525] jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
[    0.538720] Key type asymmetric registered
[    0.542935] Asymmetric key parser 'x509' registered
[    0.554266] Serial: 8250/16550 driver, 5 ports, IRQ sharing disabled
[    0.562885] printk: console [ttyS0] disabled
[    0.567417] 4140000.serial: ttyS0 at MMIO 0x4140000 (irq = 15, base_baud = 15[    0.576454] printk: console [ttyS0] enabled
[    0.576454] printk: console [ttyS0] enabled
[    0.585055] printk: bootconsole [sbi0] disabled
[    0.585055] printk: bootconsole [sbi0] disabled
[    0.595433] 41c0000.serial: ttyS4 at MMIO 0x41c0000 (irq = 16, base_baud = 1562500) is a 16550A
[    0.608002] cvi-spif 10000000.cvi-spif: unrecognized JEDEC id bytes: 00 00 00 00 00 00
[    0.616235] cvi-spif 10000000.cvi-spif: device scan failed
[    0.621961] cvi-spif 10000000.cvi-spif: unable to setup flash chip
[    0.635279] libphy: Fixed MDIO Bus: probed
[    0.640124] bm-dwmac 4070000.ethernet: IRQ eth_wake_irq not found
[    0.646491] bm-dwmac 4070000.ethernet: IRQ eth_lpi not found
[    0.652473] bm-dwmac 4070000.ethernet: Hash table entries set to unexpected value 0
[    0.660549] bm-dwmac 4070000.ethernet: no reset control found
[    0.666794] bm-dwmac 4070000.ethernet: User ID: 0x10, Synopsys ID: 0x37
[    0.673715] bm-dwmac 4070000.ethernet:       DWMAC1000
[    0.678616] bm-dwmac 4070000.ethernet: DMA HW capability register supported
[    0.685834] bm-dwmac 4070000.ethernet: RX Checksum Offload Engine supported
[    0.693053] bm-dwmac 4070000.ethernet: COE Type 2
[    0.697941] bm-dwmac 4070000.ethernet: TX Checksum insertion supported
[    0.704712] bm-dwmac 4070000.ethernet: Normal descriptors
[    0.710317] bm-dwmac 4070000.ethernet: Ring mode enabled
[    0.715834] bm-dwmac 4070000.ethernet: Enable RX Mitigation via HW Watchdog Timer
[    0.723595] bm-dwmac 4070000.ethernet: device MAC address 56:01:b8:60:16:bc
[    0.758313] libphy: stmmac: probed
[    0.763720] bm-dwmac 4070000.ethernet: Cannot get clk_500m_eth!
[    0.769982] bm-dwmac 4070000.ethernet: Cannot get gate_clk_axi4!
[    0.777363] dwc2 4340000.usb: axi clk installed
[    0.782155] dwc2 4340000.usb: apb clk installed
[    0.786903] dwc2 4340000.usb: 125m clk installed
[    0.791711] dwc2 4340000.usb: 33k clk installed
[    0.796423] dwc2 4340000.usb: 12m clk installed
[    0.801230] dwc2 4340000.usb: EPs: 8, dedicated fifos, 3072 entries in SPRAM
[    0.809139] dwc2 4340000.usb: DWC OTG Controller
[    0.814015] dwc2 4340000.usb: new USB bus registered, assigned bus number 1
[    0.821287] dwc2 4340000.usb: irq 36, io mem 0x04340000
[    0.827744] hub 1-0:1.0: USB hub found
[    0.831771] hub 1-0:1.0: 1 port detected
[    0.837606] usbcore: registered new interface driver usb-storage
[    0.844292] i2c /dev entries driver
[    0.850052] sdhci: Secure Digital Host Controller Interface driver
[    0.856505] sdhci: Copyright(c) Pierre Ossman
[    0.861032] sdhci-pltfm: SDHCI platform and OF driver helper
[    0.867205] cvi:sdhci_cvi_probe
[    0.915179] mmc0: SDHCI controller on 4310000.cv-sd [4310000.cv-sd] using ADMA 64-bit
[    0.923348] cvi_proc_init cvi_host 0x(____ptrval____)
[    0.929361] usbcore: registered new interface driver usbhid
[    0.939183] usbhid: USB HID core driver
[    0.945143] cvitek-i2s 4100000.i2s: cvi_i2s_probe
[    0.955416] cvitek-i2s 4130000.i2s: cvi_i2s_probe
[    0.961140] cviteka-adc sound_adc: cviteka_adc_probe, dev name=sound_adc
[    0.968253] cviteka-adc sound_adc: cviteka_adc_probe start devm_snd_soc_register_card
[    0.976859] cvitekaadc 300a100.adc: cvitekaadc_probe
[    0.987836] cviteka-dac sound_dac: cviteka_dac_probe, dev name=sound_dac
[    0.995305] cvitekadac 300a000.dac: cvitekadac_probe
[    1.000899] cvitekadac_probe gpio_is_valid mute_pin_l
[    1.006798] NET: Registered protocol family 17
[    1.011688] Loading compiled-in X.509 certificates
[    1.054102] cviteka-adc sound_adc: cviteka_adc_probe, dev name=sound_adc
[    1.067170] cviteka-adc sound_adc: cviteka_adc_probe start devm_snd_soc_register_card
[    1.075319] mmc0: new high speed SDHC card at address b36a
[    1.087409] mmcblk0: mmc0:b36a SDABC 14.7 GiB
[    1.092645] cviteka-dac sound_dac: cviteka_dac_probe, dev name=sound_dac
[    1.102016]  mmcblk0: p1 p2 p3
[    1.112630] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[    1.123713] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[    1.130791] cfg80211: failed to load regulatory.db
[    1.136015] ALSA device list:
[    1.139519] dw-apb-uart 4140000.serial: forbid DMA for kernel console
[    1.171230] random: fast init done
[    1.934313] EXT4-fs (mmcblk0p2): warning: maximal mount count reached, running e2fsck is recommended
[    1.945590] EXT4-fs (mmcblk0p2): recovery complete
[    1.951468] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    1.959947] VFS: Mounted root (ext4 filesystem) on device 179:2.
[    1.967336] devtmpfs: mounted
[    1.970578] Freeing unused kernel memory: 144K
[    1.975218] Kernel memory protection not selected by kernel config.
[    1.981737] Run /sbin/init as init process
[    1.986002]   with arguments:
[    1.989097]     /sbin/init
[    1.991923]   with environment:
[    1.995197]     HOME=/
[    1.997639]     TERM=linux
[    2.000464] early_time_log: run_init_process: 214975847us
INIT: version  booting
INIT: No inittab.d directory found
[    2.163881] EXT4-fs (mmcblk0p2): re-mounted. Opts: errors=remount-ro
INIT: Entering runlevel: 3
Starting syslogd: OK
Starting klogd: OK
Running sysctl: OK
Seeding 2048 bits without crediting
Saving 2048 bits of non-creditable seed for next boot
Starting network: OK
Starting dhcpcd...
dhcpcd-10.0.1 starting
[    2.735438] random: dhcpcd: uninitialized urandom read (112 bytes read)
DUID 00:01:00:01:c7:92:bc:82:9a:7d:37:16:00:d6
dhcp_vendor: Invalid argument
forked to background, child pid 148
[    2.917729] bm-dwmac 4070000.ethernet eth0: PHY [stmmac-0:00] driver [Generic PHY] (irq=POLL)
[    2.943246] dwmac1000: Master AXI performs any burst length
Starting ntpd: [    2.951530] bm-dwmac 4070000.ethernet eth0: No Safety Features support found
[    2.962794] bm-dwmac 4070000.ethernet eth0: IEEE 1588-2002 Timestamp supported
[    2.972006] bm-dwmac 4070000.ethernet eth0: configuring for phy/rmii link mode
OK
Starting dropbear sshd: OK
Starting dnsmasq: [    8.231807] random: dnsmasq: uninitialized urandom read (128 bytes read)
[    8.238854] random: dnsmasq: uninitialized urandom read (48 bytes read)
OK
init mpp system...
Starting app...

Welcome to Milk-V
milkv-duo login: [    8.548591] using random self ethernet address
[    8.553351] using random host ethernet address
[    8.559771] dwc2 4340000.usb: new device is high-speed
[    8.672669] usb0: HOST MAC 42:df:56:b5:0c:15
[    8.683692] usb0: MAC fa:94:99:e0:c3:8a
[    8.691332] dwc2 4340000.usb: bound driver configfs-gadget
[    8.919691] dwc2 4340000.usb: new device is high-speed
[    8.953863] dwc2 4340000.usb: new address 32

制作boot.sd

编译Linux内核

首先先把defconfig复制过去。修改向量指令的设置。

CONFIG_VECTOR=n
CONFIG_VECTOR_0_7=n

终端执行

cp build/boards/cv180x/cv1800b_milkv_duo_sd/linux/cvitek_cv1800b_milkv_duo_sd_defconfig linux_5.10/.config
export ARCH=riscv
export CROSS_COMPILE=riscv64-buildroot-linux-musl-
make menuconfig
make -j64

遇到报错

riscv64-unknown-linux-gnu-gcc: error: unrecognized command-line option '-mno-ldd'
riscv64-unknown-linux-gnu-gcc: error: unrecognized command-line option '-mno-ldd'
make[1]: *** [scripts/Makefile.build:279: scripts/mod/empty.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [scripts/Makefile.build:117: scripts/mod/devicetable-offsets.s] Error 1
make: *** [Makefile:1205: prepare0] Error 2

找到linux_5.10/arch/riscv/Makefile,删掉:

# workaround for C906 ldd performance issue
ifeq ($(CONFIG_ARCH_CVITEK),y)
	KBUILD_CFLAGS += -mno-ldd
endif

又遇到报错:

./arch/riscv/include/asm/vdso/gettimeofday.h: Assembler messages:
./arch/riscv/include/asm/vdso/gettimeofday.h:71: Error: unrecognized opcode `csrr a5,0xc01', extension `zicsr' required
./arch/riscv/include/asm/vdso/gettimeofday.h:71: Error: unrecognized opcode `csrr a5,0xc01', extension `zicsr' required
make[1]: *** [scripts/Makefile.build:279: arch/riscv/kernel/vdso/vgettimeofday.o] Error 1
make: *** [arch/riscv/Makefile:103: vdso_prepare] Error 2

修改上一个makefile:

# ISA string setting
riscv-march-cflags-$(CONFIG_ARCH_RV32I)		:= rv32ima
riscv-march-cflags-$(CONFIG_ARCH_RV64I)		:= rv64ima
riscv-march-cflags-$(CONFIG_RISCV_ISA_C)	:= $(riscv-march-cflags-y)c

riscv-march-aflags-$(CONFIG_ARCH_RV32I)		:= rv32ima
riscv-march-aflags-$(CONFIG_ARCH_RV64I)		:= rv64ima
riscv-march-aflags-$(CONFIG_FPU)		:= $(riscv-march-aflags-y)fd
riscv-march-aflags-$(CONFIG_RISCV_ISA_C)	:= $(riscv-march-aflags-y)c
riscv-march-aflags-$(CONFIG_VECTOR_1_0)		:= $(riscv-march-aflags-y)v
riscv-march-aflags-$(CONFIG_VECTOR_0_7)		:= $(riscv-march-aflags-y)v0p7
riscv-march-aflags-$(CONFIG_RISCV_ISA_THEAD)	:= $(riscv-march-aflags-y)xthead

riscv-march-cflags-y	:= $(riscv-march-cflags-y)_zicsr_zifencei
riscv-march-aflags-y	:= $(riscv-march-aflags-y)_zicsr_zifencei

此时,内核成功编译。

GEN     modules.builtin
  LD      .tmp_vmlinux.kallsyms1
  KSYMS   .tmp_vmlinux.kallsyms1.S
  AS      .tmp_vmlinux.kallsyms1.S
  LD      .tmp_vmlinux.kallsyms2
  KSYMS   .tmp_vmlinux.kallsyms2.S
  AS      .tmp_vmlinux.kallsyms2.S
  LD      vmlinux
  SYSMAP  System.map
  MODPOST Module.symvers
  OBJCOPY arch/riscv/boot/Image
  CC [M]  drivers/staging/fbtft/fb_ssd1306.mod.o
  CC [M]  drivers/thermal/cv180x_thermal.mod.o
  CC [M]  drivers/video/fbdev/core/cfbcopyarea.mod.o
  CC [M]  drivers/video/fbdev/core/cfbfillrect.mod.o
  CC [M]  drivers/video/fbdev/core/cfbimgblt.mod.o
  CC [M]  fs/efivarfs/efivarfs.mod.o
  GZIP    arch/riscv/boot/Image.gz
  LD [M]  drivers/staging/fbtft/fb_ssd1306.ko
  LD [M]  drivers/video/fbdev/core/cfbfillrect.ko
  LD [M]  drivers/thermal/cv180x_thermal.ko
  LD [M]  fs/efivarfs/efivarfs.ko
  LD [M]  drivers/video/fbdev/core/cfbcopyarea.ko
  LD [M]  drivers/video/fbdev/core/cfbimgblt.ko
  Kernel: arch/riscv/boot/Image.gz is ready

multi.its

编译好内核后,我们得到了gzip压缩过的内核映像Image.gz。要生成boot.sd,前置条件是multi.its,因为有命令:

$(COMMON_TOOLS_PATH)/prebuild/mkimage -f ${RAMDISK_PATH}/${RAMDISK_OUTPUT_FOLDER}/multi.its -k $(RAMDISK_PATH)/keys -r $(OUTPUT_DIR)/ramboot.itb

正是通过mkimage命令,才生成了boot.sd文件。

有这样一个文件ramdisk/configs/cv180x/multi.its,但是这个文件并不能给我们提供任何有用的信息。我们从RT-Thread的源码中找到了对于我们来说有用的描述:

/*
 * U-Boot uImage source file with multiple kernels, ramdisks and FDT blobs
 */
/dts-v1/;
/ {
  description = "Various kernels, ramdisks and FDT blobs";
  #address-cells = <2>;
  images {
    kernel-1 {
      description = "cvitek kernel";
      data = /incbin/("./Image.gz");
      type = "kernel";
      arch = "riscv";
      os = "linux";
      compression = "gzip";
      load = <0x0 0x80200000>;
      entry = <0x0 0x80200000>;
      hash-2 {
        algo = "crc32";
      };
    };
    /*FDT*/
    fdt-cv1800b_milkv_duo_sd {
        description = "cvitek device tree - cv1800b_milkv_duo_sd";
        data = /incbin/("./cv1800b_milkv_duo_sd.dtb");
        type = "flat_dt";
        arch = "riscv";
        compression = "none";
        hash-1 {
            algo = "sha256";
        };
    };
  };
  /*CFG*/
    configurations {   
        config-cv1800b_milkv_duo_sd {
            description = "boot cvitek system with board cv1800b_milkv_duo_sd";
            kernel = "kernel-1";
            fdt = "fdt-cv1800b_milkv_duo_sd";
        };
    };
};

此时,我们只需要在目录下准备好Image.gzcv1800b_milkv_duo_sd.dtb,就可以生成boot.sd了。

$ mkimage -f multi.its boot.sd
FIT description: Various kernels, ramdisks and FDT blobs
Created:         Mon Oct 16 14:34:14 2023
 Image 0 (kernel-1)
  Description:  cvitek kernel
  Created:      Mon Oct 16 14:34:14 2023
  Type:         Kernel Image
  Compression:  gzip compressed
  Data Size:    3631893 Bytes = 3546.77 KiB = 3.46 MiB
  Architecture: RISC-V
  OS:           Linux
  Load Address: 0x80200000
  Entry Point:  0x80200000
  Hash algo:    crc32
  Hash value:   4db6697f
 Image 1 (fdt-cv1800b_milkv_duo_sd)
  Description:  cvitek device tree - cv1800b_milkv_duo_sd
  Created:      Mon Oct 16 14:34:14 2023
  Type:         Flat Device Tree
  Compression:  uncompressed
  Data Size:    23473 Bytes = 22.92 KiB = 0.02 MiB
  Architecture: RISC-V
  Hash algo:    sha256
  Hash value:   227f94b627feee0b26eef20a03f15a00bd9facbe99c2e7d366cbcac7089aaa94
 Configuration 0 (config-cv1800b_milkv_duo_sd)
  Description:  boot cvitek system with board cv1800b_milkv_duo_sd
  Kernel:       kernel-1
  FDT:          fdt-cv1800b_milkv_duo_sd
$ ls
bl2.bin  chip_conf.bin             ddr_param.bin  fiptool.py      Image.gz   u-boot.bin
boot.sd  cv1800b_milkv_duo_sd.dtb  fip.bin        fw_dynamic.bin  multi.its

成功生成boot.sd

热门相关:名门盛婚:首席,别来无恙!   网游三国之城市攻略   魔神狂后   精灵掌门人   精灵掌门人