全志D1 主线U-Boot
发表于:2022-05-10 | 分类: Linux

D1 上的引导固件由三部分组成

  • boot0 或 U-Boot SPL(辅助程序加载器),负责初始化 DRAM 并从存储中加载更多固件。
  • OpenSBI,它在机器模式下运行,并为特权较低的模式提供标准的“SBI”接口。这类似于ARM的 TF-A。
  • U-Boot ,它初始化附加硬件并从存储或网络加载 Linux。

boot0 SPL

1
2
3
4
5
git clone https://github.com/smaeul/sun20i_d1_spl -b mainline
pushd sun20i_d1_spl
make CROSS_COMPILE=riscv64-linux-gnu- p=sun20iw1p1 mmc
sudo dd if=nboot/boot0_sdcard_sun20iw1p1.bin of=/dev/sdX bs=8192 seek=16

将sd卡插入开发板

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
[28]HELLO! BOOT0 is starting!
[31]BOOT0 commit : 882671f
[34]set pll start
[35]periph0 has been enabled
[38]set pll end
[40]board init ok
[42]DRAM only have internal ZQ!!
[45]get_pmu_exist() = -1
[47]ddr_efuse_type: 0x0
[50][AUTO DEBUG] single rank and full DQ!
[54]ddr_efuse_type: 0x0
[57][AUTO DEBUG] rank 0 row = 15
[60][AUTO DEBUG] rank 0 bank = 8
[63][AUTO DEBUG] rank 0 page size = 2 KB
[66]DRAM BOOT DRIVE INFO: V0.24
[69]DRAM CLK = 792 MHz
[71]DRAM Type = 3 (2:DDR2,3:DDR3)
[74]DRAMC ZQ value: 0x7b7bfb
[77]DRAM ODT value: 0x42.
[80]ddr_efuse_type: 0x0
[83]DRAM SIZE =512 M
[86]DRAM simple test OK.
[88]dram size =512
[90]card no is 0
[91]sdcard 0 line count 4
[94][mmc]: mmc driver ver 2021-04-2 16:45
[103][mmc]: Wrong media type 0x0
[106][mmc]: ***Try SD card 0***
[115][mmc]: HSSDR52/SDR25 4 bit
[118][mmc]: 50000000 Hz
[120][mmc]: 7460 MB
[122][mmc]: ***SD/MMC 0 init OK!!!***
[171]Loading boot-pkg Succeed(index=1).
[174]Entry_name = opensbi
[177]Entry_name = u-boot
[181]Entry_name = dtb

主线u-boot引导

下载打好补丁的u-boot源码

1
2
3
git clone https://github.com/smaeul/u-boot -b d1-wip 
make CROSS_COMPILE=riscv64-unknown-linux-gnu- nezha_defconfig
make CROSS_COMPILE=riscv64-unknolinux-gnu-

创建一个文件配置mkimage

1
2
touch tocl.cfg
vim tocl.cfg

写进如下内容

1
2
3
4
5
6
7
8
9
[opensbi]
file = ../opensbi/build/platform/generic/firmware/fw_dynamic.bin
addr = 0x40000000
[dtb]
file = arch/riscv/dts/sun20i-d1-nezha.dtb
addr = 0x44000000
[u-boot]
file = u-boot-nodtb.bin
addr = 0x4a000000

编译

1
tools/mkimage -T sunxi_toc1 -d toc1.cfg u-boot.toc1

写入SD卡

1
sudo dd if=u-boot.toc1 of=/dev/sdX bs=512 seek=32800
上一篇:
FBTFT st7789v
下一篇:
Bulidroot构建QT5