VisionFive2 - 03

VisionFive2 has been talked twice recently: - VisionFive2 - 01 - VisionFive2 - 02

Today, we're going to follow U-Boot VisionFive2 and demonstrate the MOST up-to-date U-Boot, Linux kernel, and OpenSBI.

1. Building

1.1 OpenSBI

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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
➜  opensbi git:(master) make PLATFORM=generic FW_TEXT_START=0x40000000 FW_OPTIONS=0
CC lib/sbi/riscv_asm.o
CC lib/sbi/riscv_atomic.o
AS lib/sbi/riscv_hardfp.o
CC lib/sbi/riscv_locks.o
CC lib/sbi/sbi_ecall.o
CC lib/sbi/sbi_ecall_exts.o
CC lib/sbi/sbi_ecall_time.o
CC lib/sbi/sbi_ecall_rfence.o
CC lib/sbi/sbi_ecall_ipi.o
CC lib/sbi/sbi_ecall_base.o
CC lib/sbi/sbi_ecall_hsm.o
CC lib/sbi/sbi_ecall_srst.o
CC lib/sbi/sbi_ecall_susp.o
CC lib/sbi/sbi_ecall_pmu.o
CC lib/sbi/sbi_ecall_dbcn.o
CC lib/sbi/sbi_ecall_cppc.o
CC lib/sbi/sbi_ecall_legacy.o
CC lib/sbi/sbi_ecall_vendor.o
CC lib/sbi/sbi_bitmap.o
CC lib/sbi/sbi_bitops.o
CC lib/sbi/sbi_console.o
CC lib/sbi/sbi_domain.o
CC lib/sbi/sbi_emulate_csr.o
CC lib/sbi/sbi_fifo.o
CC lib/sbi/sbi_hart.o
CC lib/sbi/sbi_heap.o
CC lib/sbi/sbi_math.o
AS lib/sbi/sbi_hfence.o
CC lib/sbi/sbi_hsm.o
CC lib/sbi/sbi_illegal_insn.o
CC lib/sbi/sbi_init.o
CC lib/sbi/sbi_ipi.o
CC lib/sbi/sbi_irqchip.o
CC lib/sbi/sbi_misaligned_ldst.o
CC lib/sbi/sbi_platform.o
CC lib/sbi/sbi_pmu.o
CC lib/sbi/sbi_scratch.o
CC lib/sbi/sbi_string.o
CC lib/sbi/sbi_system.o
CC lib/sbi/sbi_timer.o
CC lib/sbi/sbi_tlb.o
CC lib/sbi/sbi_trap.o
CC lib/sbi/sbi_unpriv.o
AS lib/sbi/sbi_expected_trap.o
CC lib/sbi/sbi_cppc.o
AR lib/libsbi.a
CC platform/generic/lib/utils/timer/aclint_mtimer.o
CC platform/generic/lib/utils/timer/andes_plmt.o
CC platform/generic/lib/utils/timer/fdt_timer.o
CC platform/generic/lib/utils/timer/fdt_timer_drivers.o
CC platform/generic/lib/utils/timer/fdt_timer_mtimer.o
CC platform/generic/lib/utils/timer/fdt_timer_plmt.o
CC platform/generic/lib/utils/sys/htif.o
CC platform/generic/lib/utils/sys/atcsmu.o
CC platform/generic/lib/utils/serial/fdt_serial.o
CC platform/generic/lib/utils/serial/fdt_serial_drivers.o
CC platform/generic/lib/utils/serial/fdt_serial_cadence.o
CC platform/generic/lib/utils/serial/fdt_serial_gaisler.o
CC platform/generic/lib/utils/serial/fdt_serial_htif.o
CC platform/generic/lib/utils/serial/fdt_serial_renesas_scif.o
CC platform/generic/lib/utils/serial/fdt_serial_shakti.o
CC platform/generic/lib/utils/serial/fdt_serial_sifive.o
CC platform/generic/lib/utils/serial/fdt_serial_litex.o
CC platform/generic/lib/utils/serial/fdt_serial_uart8250.o
CC platform/generic/lib/utils/serial/fdt_serial_xlnx_uartlite.o
CC platform/generic/lib/utils/serial/cadence-uart.o
CC platform/generic/lib/utils/serial/gaisler-uart.o
CC platform/generic/lib/utils/serial/renesas_scif.o
CC platform/generic/lib/utils/serial/shakti-uart.o
CC platform/generic/lib/utils/serial/sifive-uart.o
CC platform/generic/lib/utils/serial/litex-uart.o
CC platform/generic/lib/utils/serial/uart8250.o
CC platform/generic/lib/utils/serial/xlnx-uartlite.o
CC platform/generic/lib/utils/serial/semihosting.o
CC platform/generic/lib/utils/reset/fdt_reset.o
CC platform/generic/lib/utils/reset/fdt_reset_drivers.o
CC platform/generic/lib/utils/reset/fdt_reset_atcwdt200.o
CC platform/generic/lib/utils/reset/fdt_reset_gpio.o
CC platform/generic/lib/utils/reset/fdt_reset_htif.o
CC platform/generic/lib/utils/reset/fdt_reset_sunxi_wdt.o
CC platform/generic/lib/utils/reset/fdt_reset_syscon.o
CC platform/generic/lib/utils/regmap/fdt_regmap.o
CC platform/generic/lib/utils/regmap/fdt_regmap_drivers.o
CC platform/generic/lib/utils/regmap/fdt_regmap_syscon.o
CC platform/generic/lib/utils/regmap/regmap.o
CC platform/generic/lib/utils/libfdt/fdt.o
CC platform/generic/lib/utils/libfdt/fdt_addresses.o
CC platform/generic/lib/utils/libfdt/fdt_check.o
CC platform/generic/lib/utils/libfdt/fdt_empty_tree.o
CC platform/generic/lib/utils/libfdt/fdt_ro.o
CC platform/generic/lib/utils/libfdt/fdt_rw.o
CC platform/generic/lib/utils/libfdt/fdt_strerror.o
CC platform/generic/lib/utils/libfdt/fdt_sw.o
CC platform/generic/lib/utils/libfdt/fdt_wip.o
CC platform/generic/lib/utils/irqchip/fdt_irqchip.o
CC platform/generic/lib/utils/irqchip/fdt_irqchip_drivers.o
CC platform/generic/lib/utils/irqchip/fdt_irqchip_aplic.o
CC platform/generic/lib/utils/irqchip/fdt_irqchip_imsic.o
CC platform/generic/lib/utils/irqchip/fdt_irqchip_plic.o
CC platform/generic/lib/utils/irqchip/aplic.o
CC platform/generic/lib/utils/irqchip/imsic.o
CC platform/generic/lib/utils/irqchip/plic.o
CC platform/generic/lib/utils/ipi/aclint_mswi.o
CC platform/generic/lib/utils/ipi/andes_plicsw.o
CC platform/generic/lib/utils/ipi/fdt_ipi.o
CC platform/generic/lib/utils/ipi/fdt_ipi_drivers.o
CC platform/generic/lib/utils/ipi/fdt_ipi_mswi.o
CC platform/generic/lib/utils/ipi/fdt_ipi_plicsw.o
CC platform/generic/lib/utils/i2c/i2c.o
CC platform/generic/lib/utils/i2c/fdt_i2c.o
CC platform/generic/lib/utils/i2c/fdt_i2c_adapter_drivers.o
CC platform/generic/lib/utils/i2c/fdt_i2c_sifive.o
CC platform/generic/lib/utils/i2c/fdt_i2c_dw.o
CC platform/generic/lib/utils/i2c/dw_i2c.o
CC platform/generic/lib/utils/gpio/fdt_gpio.o
CC platform/generic/lib/utils/gpio/fdt_gpio_drivers.o
CC platform/generic/lib/utils/gpio/fdt_gpio_designware.o
CC platform/generic/lib/utils/gpio/fdt_gpio_sifive.o
CC platform/generic/lib/utils/gpio/fdt_gpio_starfive.o
CC platform/generic/lib/utils/gpio/gpio.o
CC platform/generic/lib/utils/fdt/fdt_domain.o
CC platform/generic/lib/utils/fdt/fdt_pmu.o
CC platform/generic/lib/utils/fdt/fdt_helper.o
CC platform/generic/lib/utils/fdt/fdt_fixup.o
CC platform/generic/thead/thead_c9xx_pmu.o
AS platform/generic/thead/thead_c9xx_tlb_trap_handler.o
CC platform/generic/thead/thead_c9xx_errata_tlb_flush.o
CC platform/generic/thead/thead-generic.o
CC platform/generic/starfive/jh7110.o
CC platform/generic/sophgo/sg2042.o
CC platform/generic/sifive/fu540.o
CC platform/generic/sifive/fu740.o
CC platform/generic/renesas/rzfive/rzfive.o
CC platform/generic/platform.o
CC platform/generic/platform_override_modules.o
CC platform/generic/andes/ae350.o
AS platform/generic/andes/sleep.o
CC platform/generic/andes/andes45-pma.o
CC platform/generic/andes/andes_sbi.o
CC platform/generic/andes/andes_pmu.o
CC platform/generic/allwinner/sun20i-d1.o
AR platform/generic/lib/libplatsbi.a
AS platform/generic/firmware/payloads/test_head.o
CC platform/generic/firmware/payloads/test_main.o
MERGE platform/generic/firmware/payloads/test.o
ELF platform/generic/firmware/payloads/test.elf
OBJCOPY platform/generic/firmware/payloads/test.bin
AS platform/generic/firmware/fw_dynamic.o
ELF platform/generic/firmware/fw_dynamic.elf
OBJCOPY platform/generic/firmware/fw_dynamic.bin
AS platform/generic/firmware/fw_jump.o
ELF platform/generic/firmware/fw_jump.elf
OBJCOPY platform/generic/firmware/fw_jump.bin
AS platform/generic/firmware/fw_payload.o
ELF platform/generic/firmware/fw_payload.elf
OBJCOPY platform/generic/firmware/fw_payload.bin

1.2 U-Boot

1
2
3
4
5
6
7
8
9
10
➜  u-boot git:(master) ✗ make starfive_visionfive2_defconfig
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
YACC scripts/kconfig/zconf.tab.c
LEX scripts/kconfig/zconf.lex.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
#
# configuration written to .config
#
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
38
39
40
41
42
43
44
➜  u-boot git:(master) ✗ make OPENSBI=$OPENSBI
scripts/kconfig/conf --syncconfig Kconfig
UPD include/config.h
CFG spl/u-boot.cfg
GEN spl/include/autoconf.mk
CFG u-boot.cfg
GEN include/autoconf.mk
GEN include/autoconf.mk.dep
UPD include/generated/timestamp_autogenerated.h
ENVC include/generated/env.txt
ENVP include/generated/env.in
ENVT include/generated/environment.h
CC lib/asm-offsets.s
CC arch/riscv/lib/asm-offsets.s
PYMOD rebuild
/home/lvision/Desktop/VisionFive/u-boot/scripts/dtc/pylibfdt/setup.py:40: SyntaxWarning: invalid escape sequence '\w'
RE_KEY_VALUE = re.compile('(?P<key>\w+) *(?P<plus>[+])?= *(?P<value>.*)$')
HOSTCC scripts/dtc/dtc.o
HOSTCC scripts/dtc/flattree.o
......
AR spl/drivers/spi/built-in.o
CC spl/drivers/timer/timer-uclass.o
CC spl/drivers/timer/riscv_timer.o
CC spl/drivers/timer/riscv_aclint_timer.o
AR spl/drivers/timer/built-in.o
AR spl/drivers/built-in.o
AR spl/dts/built-in.o
CC spl/fs/fs_internal.o
AR spl/fs/built-in.o
LDS spl/u-boot-spl.lds
LD spl/u-boot-spl
OBJCOPY spl/u-boot-spl-nodtb.bin
mkdir -p spl/dts/
FDTGREP spl/dts/dt-spl.dtb
COPY spl/u-boot-spl.dtb
CAT spl/u-boot-spl-dtb.bin
COPY spl/u-boot-spl.bin
SYM spl/u-boot-spl.sym
MKIMAGE u-boot.img
COPY u-boot.dtb
MKIMAGE u-boot-dtb.img
BINMAN .binman_stamp
OFCHK .config
➜ u-boot git:(master) ✗

1.3 Linux Kernel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
➜  linux make defconfig
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
HOSTCC scripts/kconfig/confdata.o
HOSTCC scripts/kconfig/expr.o
LEX scripts/kconfig/lexer.lex.c
YACC scripts/kconfig/parser.tab.[ch]
HOSTCC scripts/kconfig/lexer.lex.o
HOSTCC scripts/kconfig/menu.o
HOSTCC scripts/kconfig/parser.tab.o
HOSTCC scripts/kconfig/preprocess.o
HOSTCC scripts/kconfig/symbol.o
HOSTCC scripts/kconfig/util.o
HOSTLD scripts/kconfig/conf
*** Default configuration is based on 'defconfig'
#
# No change to .config
#
1
2
3
4
5
6
7
8
9
10
11
12
13
➜  linux make menuconfig
HOSTCC scripts/kconfig/mconf.o
HOSTCC scripts/kconfig/lxdialog/checklist.o
HOSTCC scripts/kconfig/lxdialog/inputbox.o
HOSTCC scripts/kconfig/lxdialog/menubox.o
HOSTCC scripts/kconfig/lxdialog/textbox.o
HOSTCC scripts/kconfig/lxdialog/util.o
HOSTCC scripts/kconfig/lxdialog/yesno.o
HOSTLD scripts/kconfig/mconf


*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.

By configuring menuconfig, we ignore building ALL other SoCs but tick VisionFive ONLY.

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
38
39
40
41
42
43
44
45
➜  linux make -j16
HOSTCC scripts/basic/fixdep
HOSTCC scripts/dtc/flattree.o
HOSTCC scripts/dtc/dtc.o
HOSTCC scripts/dtc/fstree.o
HOSTCC scripts/dtc/livetree.o
HOSTCC scripts/dtc/data.o
HOSTCC scripts/dtc/treesource.o
HOSTCC scripts/dtc/srcpos.o
HOSTCC scripts/dtc/util.o
HOSTCC scripts/dtc/checks.o
YACC scripts/dtc/dtc-parser.tab.[ch]
LEX scripts/dtc/dtc-lexer.lex.c
HOSTCC scripts/dtc/libfdt/fdt.o
HOSTCC scripts/dtc/libfdt/fdt_ro.o
HOSTCC scripts/dtc/libfdt/fdt_wip.o
HOSTCC scripts/dtc/libfdt/fdt_sw.o
HOSTCC scripts/dtc/libfdt/fdt_rw.o
HOSTCC scripts/dtc/libfdt/fdt_strerror.o
HOSTCC scripts/dtc/libfdt/fdt_empty_tree.o
HOSTCC scripts/dtc/libfdt/fdt_addresses.o
HOSTCC scripts/dtc/libfdt/fdt_overlay.o
HOSTCC scripts/dtc/fdtoverlay.o
HOSTCC scripts/dtc/dtc-lexer.lex.o
HOSTCC scripts/dtc/dtc-parser.tab.o
HOSTLD scripts/dtc/fdtoverlay
HOSTLD scripts/dtc/dtc
......
LD [M] net/8021q/8021q.ko
LD [M] net/bridge/br_netfilter.ko
LD [M] net/llc/llc.ko
LD [M] net/bridge/bridge.ko
NM .tmp_vmlinux.kallsyms1.syms
KSYMS .tmp_vmlinux.kallsyms1.S
AS .tmp_vmlinux.kallsyms1.S
LD .tmp_vmlinux.kallsyms2
NM .tmp_vmlinux.kallsyms2.syms
KSYMS .tmp_vmlinux.kallsyms2.S
AS .tmp_vmlinux.kallsyms2.S
LD vmlinux
NM System.map
SORTTAB vmlinux
OBJCOPY arch/riscv/boot/Image
GZIP arch/riscv/boot/Image.gz
Kernel: arch/riscv/boot/Image.gz is ready

1.4 Busybox

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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
➜  busybox make CROSS_COMPILE=riscv64-linux-gnu- ARCH=riscv defconfig
scripts/kconfig/conf -d Config.in
*
* Busybox Configuration
*
*
* Settings
*
Enable compatibility for full-blown desktop systems (8kb) (DESKTOP) [Y/n/?] (NEW) y
Provide compatible behavior for rare corner cases (bigger code) (EXTRA_COMPAT) [N/y/?] (NEW) n
Building for Fedora distribution (FEDORA_COMPAT) [N/y/?] (NEW) n
Enable obsolete features removed before SUSv3 (INCLUDE_SUSv2) [Y/n/?] (NEW) y
Support --long-options (LONG_OPTS) [Y/?] (NEW) y
Show applet usage messages (SHOW_USAGE) [Y/n/?] (NEW) y
Show verbose applet usage messages (FEATURE_VERBOSE_USAGE) [Y/n/?] (NEW) y
Store applet usage messages in compressed form (FEATURE_COMPRESS_USAGE) [Y/n/?] (NEW) y
Support files > 2 GB (LFS) [Y/n/?] (NEW) y
Support 64bit wide time types (TIME64) [Y/n/?] (NEW) y
Support PAM (Pluggable Authentication Modules) (PAM) [N/y/?] (NEW) n
Use the devpts filesystem for Unix98 PTYs (FEATURE_DEVPTS) [Y/n/?] (NEW) y
Support utmp file (FEATURE_UTMP) [Y/n/?] (NEW) y
Support wtmp file (FEATURE_WTMP) [Y/n/?] (NEW) y
Support writing pidfiles (FEATURE_PIDFILE) [Y/n/?] (NEW) y
Directory for pidfiles (PID_FILE_PATH) [/var/run] (NEW) /var/run
Include busybox applet (BUSYBOX) [Y/n/?] (NEW) y
Support --show SCRIPT (FEATURE_SHOW_SCRIPT) [Y/n] (NEW) y
Support --install [-s] to install applet links at runtime (FEATURE_INSTALLER) [Y/n/?] (NEW) y
Don't use /usr (INSTALL_NO_USR) [N/y/?] (NEW) n
Drop SUID state for most applets (FEATURE_SUID) [Y/n/?] (NEW) y
Enable SUID configuration via /etc/busybox.conf (FEATURE_SUID_CONFIG) [Y/n/?] (NEW) y
Suppress warning message if /etc/busybox.conf is not readable (FEATURE_SUID_CONFIG_QUIET) [Y/n/?] (NEW) y
exec prefers applets (FEATURE_PREFER_APPLETS) [N/y/?] (NEW) n
Path to busybox executable (BUSYBOX_EXEC_PATH) [/proc/self/exe] (NEW) /proc/self/exe
Support NSA Security Enhanced Linux (SELINUX) [N/y/?] (NEW) n
Clean up all memory before exiting (usually not needed) (FEATURE_CLEAN_UP) [N/y/?] (NEW) n
Support LOG_INFO level syslog messages (FEATURE_SYSLOG_INFO) [Y/n/?] (NEW) y
*
*
* Build Options
*
......
......
......
*
* Options common to all shells
*
POSIX math support (FEATURE_SH_MATH) [Y/n/?] (NEW) y
Extend POSIX math support to 64 bit (FEATURE_SH_MATH_64) [Y/n/?] (NEW) y
Support BASE#nnnn literals (FEATURE_SH_MATH_BASE) [Y/n] (NEW) y
Hide message on interactive shell startup (FEATURE_SH_EXTRA_QUIET) [Y/n/?] (NEW) y
Standalone shell (FEATURE_SH_STANDALONE) [N/y/?] (NEW) n
Run 'nofork' applets directly (FEATURE_SH_NOFORK) [N/y/?] (NEW) n
read -t N.NNN support (+110 bytes) (FEATURE_SH_READ_FRAC) [Y/n/?] (NEW) y
Use $HISTFILESIZE (FEATURE_SH_HISTFILESIZE) [Y/n/?] (NEW) y
Embed scripts in the binary (FEATURE_SH_EMBEDDED_SCRIPTS) [Y/n/?] (NEW) y
*
* System Logging Utilities
*
klogd (6.2 kb) (KLOGD) [Y/n/?] (NEW) y
*
* klogd should not be used together with syslog to kernel printk buffer
*
Use the klogctl() interface (FEATURE_KLOGD_KLOGCTL) [Y/n/?] (NEW) y
logger (6.5 kb) (LOGGER) [Y/n/?] (NEW) y
logread (5 kb) (LOGREAD) [Y/n/?] (NEW) y
Double buffering (FEATURE_LOGREAD_REDUCED_LOCKING) [Y/n/?] (NEW) y
syslogd (14 kb) (SYSLOGD) [Y/n/?] (NEW) y
Rotate message files (FEATURE_ROTATE_LOGFILE) [Y/n/?] (NEW) y
Remote Log support (FEATURE_REMOTE_LOG) [Y/n/?] (NEW) y
Support -D (drop dups) option (FEATURE_SYSLOGD_DUP) [Y/n/?] (NEW) y
Support syslog.conf (FEATURE_SYSLOGD_CFG) [Y/n/?] (NEW) y
Include milliseconds in timestamps (FEATURE_SYSLOGD_PRECISE_TIMESTAMPS) [N/y/?] (NEW) n
Read buffer size in bytes (FEATURE_SYSLOGD_READ_BUFFER_SIZE) [256] (NEW) 256
Circular Buffer support (FEATURE_IPC_SYSLOG) [Y/n/?] (NEW) y
Circular buffer size in Kbytes (minimum 4KB) (FEATURE_IPC_SYSLOG_BUFFER_SIZE) [16] (NEW) 16
Linux kernel printk buffer support (FEATURE_KMSG_SYSLOG) [Y/n/?] (NEW) y
➜ busybox
1
2
3
4
5
6
7
8
9
➜  busybox make CROSS_COMPILE=riscv64-linux-gnu- ARCH=riscv menuconfig
scripts/kconfig/mconf Config.in
#
# using defaults found in .config
#


*** End of configuration.
*** Execute 'make' to build the project or try 'make help'.
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
➜  busybox make CROSS_COMPILE=riscv64-linux-gnu- ARCH=riscv -j8       
LD archival/built-in.o
CC archival/bzip2.o
CC archival/bbunzip.o
CC archival/chksum_and_xwrite_tar_header.o
CC archival/dpkg.o
CC archival/cpio.o
CC archival/dpkg_deb.o
LD archival/libarchive/built-in.o
CC archival/gzip.o
CC archival/libarchive/common.o
CC archival/lzop.o
CC archival/libarchive/data_align.o
LD console-tools/built-in.o
CC console-tools/chvt.o
CC console-tools/clear.o
CC console-tools/deallocvt.o
CC archival/libarchive/data_extract_all.o
LD coreutils/built-in.o
CC coreutils/basename.o
CC coreutils/cat.o
CC console-tools/dumpkmap.o
archival/libarchive/data_extract_all.c: In function ‘data_extract_all’:
archival/libarchive/data_extract_all.c:235:25: warning: ignoring return value of ‘chown’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
235 | chown(dst_name, uid, gid);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
LD coreutils/libcoreutils/built-in.o
CC archival/libarchive/data_extract_to_command.o
CC archival/libarchive/data_extract_to_stdout.o
CC coreutils/libcoreutils/cp_mv_stat.o
LD debianutils/built-in.o
CC debianutils/pipe_progress.o
console-tools/dumpkmap.c: In function ‘dumpkmap_main’:
......
......
......
CC libbb/verror_msg.o
util-linux/mkfs_minix.c: In function ‘get_list_blocks’:
util-linux/mkfs_minix.c:532:17: warning: ignoring return value of ‘fscanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
532 | fscanf(listfile, "%lu\n", &blockno);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CC libbb/vfork_daemon_rexec.o
CC libbb/warn_ignoring_args.o
CC util-linux/mkswap.o
CC util-linux/more.o
CC libbb/wfopen.o
CC util-linux/mount.o
CC libbb/wfopen_input.o
CC libbb/write.o
CC util-linux/mountpoint.o
CC libbb/xatonum.o
CC util-linux/nsenter.o
CC util-linux/pivot_root.o
CC util-linux/rdate.o
CC libbb/xconnect.o
CC util-linux/rdev.o
CC libbb/xfunc_die.o
CC util-linux/readprofile.o
CC libbb/xfuncs.o
CC util-linux/renice.o
CC libbb/xfuncs_printf.o
CC util-linux/rev.o
CC libbb/xgetcwd.o
CC util-linux/rtcwake.o
CC util-linux/script.o
CC libbb/xgethostbyname.o
CC libbb/xreadlink.o
CC libbb/xrealloc_vector.o
CC util-linux/scriptreplay.o
CC util-linux/setarch.o
CC libbb/xregcomp.o
CC util-linux/setpriv.o
CC util-linux/setsid.o
CC util-linux/swaponoff.o
CC util-linux/switch_root.o
CC util-linux/taskset.o
CC util-linux/uevent.o
CC util-linux/umount.o
AR libbb/lib.a
CC util-linux/unshare.o
CC util-linux/wall.o
util-linux/unshare.c: In function ‘unshare_main’:
util-linux/unshare.c:295:25: warning: ignoring return value of ‘read’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
295 | read(fdp.rd, ns_ctx_list, 1); /* ...using bogus buffer */
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
AR util-linux/lib.a
LINK busybox_unstripped
Trying libraries: m resolv rt
Library m is needed, can't exclude it (yet)
Library resolv is needed, can't exclude it (yet)
Library rt is not needed, excluding it
Library m is needed, can't exclude it (yet)
Library resolv is needed, can't exclude it (yet)
Final link with: m resolv
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
➜  busybox make CONFIG_PREFIX=./../busybox_rootfs install
./../busybox_rootfs//bin/arch -> busybox
./../busybox_rootfs//bin/ash -> busybox
./../busybox_rootfs//bin/base32 -> busybox
./../busybox_rootfs//bin/base64 -> busybox
./../busybox_rootfs//bin/cat -> busybox
./../busybox_rootfs//bin/chattr -> busybox
./../busybox_rootfs//bin/chgrp -> busybox
./../busybox_rootfs//bin/chmod -> busybox
./../busybox_rootfs//bin/chown -> busybox
./../busybox_rootfs//bin/conspy -> busybox
./../busybox_rootfs//bin/cp -> busybox
./../busybox_rootfs//bin/cpio -> busybox
./../busybox_rootfs//bin/cttyhack -> busybox
./../busybox_rootfs//bin/date -> busybox
......
......
......
./../busybox_rootfs//usr/sbin/ubirmvol -> ../../bin/busybox
./../busybox_rootfs//usr/sbin/ubirsvol -> ../../bin/busybox
./../busybox_rootfs//usr/sbin/ubiupdatevol -> ../../bin/busybox
./../busybox_rootfs//usr/sbin/udhcpd -> ../../bin/busybox


--------------------------------------------------
You will probably need to make your busybox binary
setuid root to ensure all configured applets will
work properly.
--------------------------------------------------
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
➜  busybox mkdir -p initramfs/{bin,dev,etc,home,mnt,proc,sys,usr}
➜ busybox cd initramfs/dev
➜ dev sudo mknod sda b 8 0
[sudo] password for lvision:
mknod: sda: File exists
➜ dev sudo mknod console c 5 1
mknod: console: File exists
➜ dev cd ..
➜ initramfs cp -r ../../busybox_rootfs/* ./
➜ initramfs ll
total 2.3M
drwxrwxr-x 2 lvision lvision 4.0K Dec 16 02:59 bin
drwxrwxr-x 2 lvision lvision 4.0K Dec 16 02:57 dev
drwxrwxr-x 2 lvision lvision 4.0K Dec 16 02:56 etc
drwxrwxr-x 2 lvision lvision 4.0K Dec 16 02:56 home
-rwxrwxr-x 1 lvision lvision 73 Dec 16 03:00 init
lrwxrwxrwx 1 lvision lvision 11 Dec 16 02:59 linuxrc -> bin/busybox
drwxrwxr-x 2 lvision lvision 4.0K Dec 16 02:56 mnt
drwxrwxr-x 2 lvision lvision 4.0K Dec 16 02:56 proc
drwxrwxr-x 2 lvision lvision 4.0K Dec 16 02:59 sbin
drwxrwxr-x 2 lvision lvision 4.0K Dec 16 02:56 sys
drwxrwxr-x 4 lvision lvision 4.0K Dec 16 02:59 usr
➜ initramfs
1
➜  initramfs vim init

and put

1
2
3
4
#!/bin/sh
mount -t proc none /proc
mount -t sysfs none /sys
exec /bin/sh

in file init.

1
2
3
4
5
6
➜  initramfs cat init 
#!/bin/sh
mount -t proc none /proc
mount -t sysfs none /sys
exec /bin/sh
➜ initramfs chmod +x init
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
➜  initramfs find . -print0 | cpio --null -ov --format=newc > initramfs.cpio 
.
./etc
./init
./busybox_rootfs
./busybox_rootfs/bin
./busybox_rootfs/bin/cpio
./busybox_rootfs/bin/ln
./busybox_rootfs/bin/su
./busybox_rootfs/bin/pwd
./busybox_rootfs/bin/gzip
./busybox_rootfs/bin/link
./busybox_rootfs/bin/lzop
./busybox_rootfs/bin/nice
./busybox_rootfs/bin/makemime
./busybox_rootfs/bin/fatattr
./busybox_rootfs/bin/busybox
......
......
......
./usr/sbin/sendmail
./usr/sbin/rtcwake
./usr/sbin/ftpd
./usr/sbin/adduser
./usr/sbin/nbd-client
./usr/sbin/dhcprelay
./usr/sbin/brctl
./usr/sbin/mim
./usr/sbin/udhcpd
./usr/sbin/nologin
./usr/sbin/ubidetach
./usr/sbin/addgroup
./usr/sbin/fdformat
./usr/sbin/crond
./sys
11511 blocks
➜ initramfs gzip ./initramfs.cpio
➜ initramfs ll
total 1.4M
drwxrwxr-x 2 lvision lvision 4.0K Dec 16 03:58 bin
drwxrwxr-x 2 lvision lvision 4.0K Dec 16 02:57 dev
drwxrwxr-x 2 lvision lvision 4.0K Dec 16 02:56 etc
drwxrwxr-x 2 lvision lvision 4.0K Dec 16 02:56 home
-rwxrwxr-x 1 lvision lvision 73 Dec 16 03:55 init
-rw-rw-r-- 1 lvision lvision 1.4M Dec 16 04:01 initramfs.cpio.gz
lrwxrwxrwx 1 lvision lvision 11 Dec 16 03:58 linuxrc -> bin/busybox
drwxrwxr-x 2 lvision lvision 4.0K Dec 16 02:56 mnt
drwxrwxr-x 2 lvision lvision 4.0K Dec 16 02:56 proc
drwxrwxr-x 2 lvision lvision 4.0K Dec 16 03:58 sbin
drwxrwxr-x 2 lvision lvision 4.0K Dec 16 02:56 sys
drwxrwxr-x 4 lvision lvision 4.0K Dec 16 02:59 usr

2. Flashing

2.1 Prepare SD Disk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
➜  VisionFive sudo sgdisk --clear \
--set-alignment=2 \
--new=1:4096:8191 --change-name=1:spl --typecode=1:2E54B353-1271-4842-806F-E436D6AF6985\
--new=2:8192:16383 --change-name=2:uboot --typecode=2:BC13C2FF-59E6-4262-A352-B275FD6F7172 \
--new=3:16384:1654784 --change-name=3:system --typecode=3:EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 \
/dev/sdb

Setting name!
partNum is 0
Setting name!
partNum is 1
Setting name!
partNum is 2
The operation has completed successfully.

2.2 Flash the SD Card

Including ALL the above, say: - U-Boot - Linux Kernel - Busybox

1
2
3
4
5
6
7
8
9
10
11
12
13
14
➜  VisionFive sudo dd if=./u-boot/spl/u-boot-spl.bin.normal.out of=/dev/sdb1
275+1 records in
275+1 records out
140919 bytes (141 kB, 138 KiB) copied, 0.111194 s, 1.3 MB/s
➜ VisionFive sudo dd if=./u-boot/u-boot.itb of=/dev/sdb2
1994+1 records in
1994+1 records out
1020947 bytes (1.0 MB, 997 KiB) copied, 0.0101341 s, 101 MB/s
➜ VisionFive sudo mount /dev/sdb3 /mnt/
➜ VisionFive sudo cp ./u-boot/spl/u-boot-spl.bin.normal.out /mnt
➜ VisionFive sudo cp ./u-boot/u-boot.itb /mnt
➜ VisionFive sudo cp ./linux/arch/riscv/boot/Image.gz /mnt
➜ VisionFive sudo cp ./busybox/initramfs/initramfs.cpio.gz /mnt
➜ VisionFive sudo cp ./linux/arch/riscv/boot/dts/starfive/jh7110-starfive-visionfive-2-v1.3b.dtb /mnt

Then, we take a look at our built system currently under folder /mnt

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
➜  VisionFive ll /mnt
total 9.2M
lrwxrwxrwx 1 root root 7 Dec 15 00:10 bin -> usr/bin
drwxr-xr-x 3 root root 4.0K Dec 15 03:38 boot
drwxr-xr-x 4 root root 4.0K Dec 15 00:10 dev
drwxr-xr-x 84 root root 4.0K Dec 15 00:26 etc
drwxr-xr-x 3 root root 4.0K Dec 15 00:26 home
-rw-r--r-- 1 root root 6.6M Dec 16 04:12 Image.gz
-rw-r--r-- 1 root root 1.4M Dec 16 04:13 initramfs.cpio.gz
-rw-r--r-- 1 root root 30K Dec 16 04:14 jh7110-starfive-visionfive-2-v1.3b.dtb
lrwxrwxrwx 1 root root 7 Dec 15 00:10 lib -> usr/lib
drwx------ 2 root root 16K Dec 15 03:38 lost+found
drwxr-xr-x 2 root root 4.0K Dec 15 00:10 media
drwxr-xr-x 2 root root 4.0K Dec 15 00:10 mnt
drwxr-xr-x 3 root root 4.0K Dec 15 00:26 opt
drwxr-xr-x 2 root root 4.0K Jul 27 22:43 proc
drwx------ 3 root root 4.0K Dec 15 00:12 root
drwxr-xr-x 2 root root 4.0K Jul 27 22:43 run
lrwxrwxrwx 1 root root 8 Dec 15 00:10 sbin -> usr/sbin
drwxr-xr-x 2 root root 4.0K Dec 15 00:10 srv
drwxr-xr-x 2 root root 4.0K Jul 27 22:43 sys
drwxrwxrwt 2 root root 4.0K Dec 15 00:25 tmp
-rw-r--r-- 1 root root 998K Dec 16 04:11 u-boot.itb
-rw-r--r-- 1 root root 138K Dec 16 04:11 u-boot-spl.bin.normal.out
drwxr-xr-x 11 root root 4.0K Dec 15 00:10 usr
drwxr-xr-x 12 root root 4.0K Dec 15 00:21 var