Allwinner D1 Nezha - n-hys/illumos-gate GitHub Wiki
The following development boards are supported.
- Allwinner D1 Nezha ($112.00 on sipeed Store)
- Dongshan Nezha STU ($11.56 on DongshanPI Store)
Currently, GbE, uSD and UART are supported on OpenSolaris.
git clone -b osport/v2022.08 https://github.com/n-hys/opensbi.git
git clone -b osport/d1-2022-05-26 https://github.com/n-hys/u-boot.git
git clone https://github.com/n-hys/sun20i_d1_spl.git
Before building firmware, you must build OpenSolaris first.
The following additional packages are required to build firmware on openSUSE Leap 15.4.
zypper install mtools dosfstools swig python3-devel python3-setuptools util-linux gptfdisk
Refer to the following for building firmware and flashing.
You should change the "/dev/sdx" to your uSD drive.
build.sh
DISK=/dev/sdx
base_dir=$(cd $(dirname $0); pwd)
illumos_dir=${base_dir}/illumos-gate
opensbi_dir=${base_dir}/opensbi
uboot_dir=${base_dir}/u-boot
spl_dir=${base_dir}/sun20i_d1_spl
platform_dir=/data/proto/root_riscv64/platform/SUNW,sun20i
toc_cfg=${base_dir}/toc1.cfg
toc=${base_dir}/u-boot.toc1
# sun20i_d1_spl
CROSS_COMPILE=${illumos_dir}/usr/src/cross/bin/riscv64-solaris2.11- \
make -C ${spl_dir} p=sun20iw1p1 mmc
# oepnsbi
CROSS_COMPILE=${illumos_dir}/usr/src/cross/bin/riscv64-solaris2.11- \
make -C ${opensbi_dir} PLATFORM=generic FW_PIC=y
# u-boot
CROSS_COMPILE=${illumos_dir}/usr/src/cross/bin/riscv64-solaris2.11- \
ARCH=riscv \
make -C ${uboot_dir} nezha_defconfig || exit 1
CROSS_COMPILE=${illumos_dir}/usr/src/cross/bin/riscv64-solaris2.11- \
ARCH=riscv \
make -C ${uboot_dir} -j || exit 1
cat > ${toc_cfg} << EOF
[opensbi]
file = ${opensbi_dir}/build/platform/generic/firmware/fw_dynamic.bin
addr = 0x40000000
[dtb]
file = ${uboot_dir}/u-boot.dtb
addr = 0x44000000
[u-boot]
file = ${uboot_dir}/u-boot-nodtb.bin
addr = 0x4a000000
EOF
${uboot_dir}/tools/mkimage -T sunxi_toc1 -d ${toc_cfg} ${toc}
# flash
SPL=982C4951-91B1-415B-9222-4EE311C95CF0
UBOOT_TOC=C8BC265D-8165-4876-B1CF-021CA10923F3
VFAT=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7
SOLARIS=6A85CF4D-1DD2-11B2-99A6-080020736631
SPL_START=256
SPL_END=2047
spl_img=${spl_dir}/nboot/boot0_sdcard_sun20iw1p1.bin
VFAT_START=2048
VFAT_END=24575
VFAT_SIZE=$(expr ${VFAT_END} - ${VFAT_START} + 1)
TOC0_START=24576
TOC0_END=32799
TOC1_START=32800
TOC1_END=36863
SOLARIS_START=36864
vfat_img=${base_dir}/vfat.img
sgdisk -g -e --clear --set-alignment=2 \
--new=1:${VFAT_START}:${VFAT_END} --change-name=1:vfat --typecode=1:${VFAT} \
--new=2:${SPL_START}:${SPL_END} --change-name=2:spl --typecode=2:${SPL} \
--new=3:${TOC0_START}:${TOC0_END} --change-name=3:toc0 --typecode=3:${UBOOT_TOC} \
--new=4:${TOC1_START}:${TOC1_END} --change-name=4:toc1 --typecode=4:${UBOOT_TOC} \
--new=5:${SOLARIS_START}: --change-name=5:solaris --typecode=5:${SOLARIS} \
${DISK}
dd if=/dev/zero of=${vfat_img} bs=512 count=${VFAT_SIZE}
/sbin/mkfs.vfat ${vfat_img}
MTOOLS_SKIP_CHECK=1 mcopy -i ${vfat_img} ${platform_dir}/inetboot ::inetboot
dd conv=notrunc if=${spl_img} of=${DISK} bs=512 seek=${SPL_START}
dd conv=notrunc if=${toc} of=${DISK} bs=512 seek=${TOC0_START}
dd conv=notrunc if=${toc} of=${DISK} bs=512 seek=${TOC1_START}
dd conv=notrunc if=${vfat_img} of=${DISK} bs=512 seek=${VFAT_START}
sync
rm ${vfat_img} ${toc} ${toc_cfg}
In U-Boot, run run enet_boot
command.
When booting from network, some errors occurr but you can ignore errors.
You can login as root without using password.
boot.log
[37]HELLO! BOOT0 is starting!
[40]BOOT0 commit : 882671f
[42]set pll start
[44]periph0 has been enabled
[47]set pll end
[48]board init ok
[50]DRAM only have internal ZQ!!
[53]get_pmu_exist() = -1
[55]ddr_efuse_type: 0x0
[58][AUTO DEBUG] two rank and full DQ!
[62]ddr_efuse_type: 0x0
[65][AUTO DEBUG] rank 0 row = 15
[68][AUTO DEBUG] rank 0 bank = 8
[71][AUTO DEBUG] rank 0 page size = 2 KB
[75][AUTO DEBUG] rank 1 row = 15
[78][AUTO DEBUG] rank 1 bank = 8
[81][AUTO DEBUG] rank 1 page size = 2 KB
[84]rank1 config same as rank0
[87]DRAM BOOT DRIVE INFO: V0.24
[90]DRAM CLK = 792 MHz
[92]DRAM Type = 3 (2:DDR2,3:DDR3)
[95]DRAMC ZQ value: 0x7b7bfb
[98]DRAM ODT value: 0x42.
[100]ddr_efuse_type: 0x0
[103]DRAM SIZE =1024 M
[107]DRAM simple test OK.
[109]dram size =1024
[111]card no is 0
[113]sdcard 0 line count 4
[115][mmc]: mmc driver ver 2021-04-2 16:45
[125][mmc]: Wrong media type 0x0
[128][mmc]: ***Try SD card 0***
[149][mmc]: HSSDR52/SDR25 4 bit
[151][mmc]: 50000000 Hz
[154][mmc]: 30436 MB
[156][mmc]: ***SD/MMC 0 init OK!!!***
[204]Loading boot-pkg Succeed(index=1).
[207]Entry_name = opensbi
[210]Entry_name = dtb
[213]Entry_name = u-boot
[216]Adding DRAM info to DTB.
[222]Jump to second Boot.
OpenSBI v0.9-334-gf5a2eb8
____ _____ ____ _____
/ __ \ / ____| _ \_ _|
| | | |_ __ ___ _ __ | (___ | |_) || |
| | | | '_ \ / _ \ '_ \ \___ \| _ < | |
| |__| | |_) | __/ | | |____) | |_) || |_
\____/| .__/ \___|_| |_|_____/|____/_____|
| |
|_|
Platform Name : Allwinner D1 Nezha
Platform Features : medeleg
Platform HART Count : 1
Platform IPI Device : aclint-mswi
Platform Timer Device : aclint-mtimer @ 24000000Hz
Platform Console Device : uart8250
Platform HSM Device : sun20i-d1-ppu
Platform Reboot Device : sunxi-wdt-reset
Platform Shutdown Device : ---
Firmware Base : 0x40000000
Firmware Size : 288 KB
Runtime SBI Version : 1.0
Domain0 Name : root
Domain0 Boot HART : 0
Domain0 HARTs : 0*
Domain0 Region00 : 0x0000000014008000-0x000000001400bfff (I)
Domain0 Region01 : 0x0000000014000000-0x0000000014007fff (I)
Domain0 Region02 : 0x0000000040000000-0x000000004007ffff ()
Domain0 Region03 : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address : 0x000000004a000000
Domain0 Next Arg1 : 0x0000000044000000
Domain0 Next Mode : S-mode
Domain0 SysReset : yes
Boot HART ID : 0
Boot HART Domain : root
Boot HART Priv Version : v1.11
Boot HART Base ISA : rv64imafdcvx
Boot HART ISA Extensions : time
Boot HART PMP Count : 8
Boot HART PMP Granularity : 2048
Boot HART PMP Address Bits: 38
Boot HART MHPM Count : 0
Boot HART MIDELEG : 0x0000000000000222
Boot HART MEDELEG : 0x000000000000b109
U-Boot 2022.07-rc3-02057-g46551acba8 (Aug 16 2022 - 10:34:40 +0900)
CPU: rv64imafdc
Model: Allwinner D1 Nezha
DRAM: 1 GiB
sunxi_set_gate: (CLK#24) unhandled
Core: 66 devices, 24 uclasses, devicetree: board
WDT: Started watchdog@6011000 with servicing (16s timeout)
MMC: mmc@4020000: 0, mmc@4021000: 1
Loading Environment from FAT... OK
In: serial@2500000
Out: serial@2500000
Err: serial@2500000
Net: eth0: ethernet@4500000
=> run enet_boot
BOOTP broadcast 1
DHCP client bound to address 192.168.5.60 (1 ms)
Using ethernet@4500000 device
TFTP from server 192.168.5.35; our IP address is 192.168.5.60
Filename '/root_riscv64/platform/SUNW,sun20i/inetboot'.
Load address: 0x40080000
Loading: ###########################################
11.4 MiB/s
done
Bytes transferred = 621288 (97ae8 hex)
## Booting kernel from Legacy Image at 40080000 ...
Image Name: OpenSolaris
Image Type: RISC-V Linux Kernel Image (uncompressed)
Data Size: 621224 Bytes = 606.7 KiB
Load Address: 40080000
Entry Point: 40080000
Verifying Checksum ... OK
## Flattened Device Tree blob at 41800000
Booting using the fdt blob at 0x41800000
Loading Kernel Image
Loading Device Tree to 0000000042ded000, end 0000000042dfffff ... OK
Starting kernel ...
phys memory add 0000000040000000 - 000000007fffffff
memory resv 0000000040000000 - 000000004007ffff
bootargs=-D /soc/ethernet@4500000
bootpath=/soc/ethernet@4500000
MAC 02:00:2c:57:1e:8b
mfg_name=SUNW,sun20i
vdev_probe error
mfg_name=SUNW,sun20i
bop_init
done
Opening /boot/solaris/bootenv.rc
fd is 1
WARNING: cannot open system file: /etc/system
illumos Version SunOS_Development 64-bit
DEBUG enabled
rootnex_map_regspec: 4500000 -> ffffffc004500000
WARNING: Cannot mount /system/boot
rootnex_map_regspec: 2500000 -> ffffffc002500000
cpu0: RISC-V 64bit hart=0
Loading smf(5) service descriptions: 138/138
ERROR: svc:/system/filesystem/usr:default failed to mount remount (see 'svcs -x' for details)
Nov 10 07:06:25 svc.startd[100003]: svc:/system/filesystem/usr:default: Method "/lib/svc/method/fs-usr" failed with exit status 95.
Nov 10 07:06:26 svc.startd[100003]: system/filesystem/usr:default failed fatally: transitioned to maintenance (see 'svcs -xv' for details)
Requesting System Maintenance Mode
(See /lib/svc/share/README for more information.)
Console login service(s) cannot run
Enter user name for system maintenance (control-d to bypass): root
Enter root password (control-d to bypass):
single-user privilege assigned to root on /dev/console.
Entering System Maintenance Mode
Hostname: nezha
Nov 10 07:06:40 su: 'su root' succeeded for root on /dev/console
The illumos Project SunOS Development Aug. 16, 2022
illumos development build: naoyuki
root@nezha:~#
The solaris root partition will probably be /dev/dsk/c1t0d0s4.
To create a storage pool:
devfsadm
zpool create -f -o altroot=/mnt rpool /dev/dsk/c1t0d0s4
In U-Boot, run run mmc_boot
command.
boot.log
[37]HELLO! BOOT0 is starting!
[40]BOOT0 commit : 882671f
[42]set pll start
[44]periph0 has been enabled
[47]set pll end
[48]board init ok
[50]DRAM only have internal ZQ!!
[53]get_pmu_exist() = -1
[55]ddr_efuse_type: 0x0
[58][AUTO DEBUG] two rank and full DQ!
[62]ddr_efuse_type: 0x0
[65][AUTO DEBUG] rank 0 row = 15
[68][AUTO DEBUG] rank 0 bank = 8
[71][AUTO DEBUG] rank 0 page size = 2 KB
[75][AUTO DEBUG] rank 1 row = 15
[78][AUTO DEBUG] rank 1 bank = 8
[81][AUTO DEBUG] rank 1 page size = 2 KB
[84]rank1 config same as rank0
[87]DRAM BOOT DRIVE INFO: V0.24
[90]DRAM CLK = 792 MHz
[92]DRAM Type = 3 (2:DDR2,3:DDR3)
[95]DRAMC ZQ value: 0x7b7bfb
[98]DRAM ODT value: 0x42.
[100]ddr_efuse_type: 0x0
[104]DRAM SIZE =1024 M
[107]DRAM simple test OK.
[109]dram size =1024
[111]card no is 0
[113]sdcard 0 line count 4
[115][mmc]: mmc driver ver 2021-04-2 16:45
[125][mmc]: Wrong media type 0x0
[128][mmc]: ***Try SD card 0***
[147][mmc]: HSSDR52/SDR25 4 bit
[150][mmc]: 50000000 Hz
[152][mmc]: 30436 MB
[154][mmc]: ***SD/MMC 0 init OK!!!***
[202]Loading boot-pkg Succeed(index=1).
[206]Entry_name = opensbi
[209]Entry_name = dtb
[211]Entry_name = u-boot
[215]Adding DRAM info to DTB.
[220]Jump to second Boot.
OpenSBI v0.9-334-gf5a2eb8
____ _____ ____ _____
/ __ \ / ____| _ \_ _|
| | | |_ __ ___ _ __ | (___ | |_) || |
| | | | '_ \ / _ \ '_ \ \___ \| _ < | |
| |__| | |_) | __/ | | |____) | |_) || |_
\____/| .__/ \___|_| |_|_____/|____/_____|
| |
|_|
Platform Name : Allwinner D1 Nezha
Platform Features : medeleg
Platform HART Count : 1
Platform IPI Device : aclint-mswi
Platform Timer Device : aclint-mtimer @ 24000000Hz
Platform Console Device : uart8250
Platform HSM Device : sun20i-d1-ppu
Platform Reboot Device : sunxi-wdt-reset
Platform Shutdown Device : ---
Firmware Base : 0x40000000
Firmware Size : 288 KB
Runtime SBI Version : 1.0
Domain0 Name : root
Domain0 Boot HART : 0
Domain0 HARTs : 0*
Domain0 Region00 : 0x0000000014008000-0x000000001400bfff (I)
Domain0 Region01 : 0x0000000014000000-0x0000000014007fff (I)
Domain0 Region02 : 0x0000000040000000-0x000000004007ffff ()
Domain0 Region03 : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address : 0x000000004a000000
Domain0 Next Arg1 : 0x0000000044000000
Domain0 Next Mode : S-mode
Domain0 SysReset : yes
Boot HART ID : 0
Boot HART Domain : root
Boot HART Priv Version : v1.11
Boot HART Base ISA : rv64imafdcvx
Boot HART ISA Extensions : time
Boot HART PMP Count : 8
Boot HART PMP Granularity : 2048
Boot HART PMP Address Bits: 38
Boot HART MHPM Count : 0
Boot HART MIDELEG : 0x0000000000000222
Boot HART MEDELEG : 0x000000000000b109
U-Boot 2022.07-rc3-02057-g46551acba8 (Aug 16 2022 - 10:34:40 +0900)
CPU: rv64imafdc
Model: Allwinner D1 Nezha
DRAM: 1 GiB
sunxi_set_gate: (CLK#24) unhandled
Core: 66 devices, 24 uclasses, devicetree: board
WDT: Started watchdog@6011000 with servicing (16s timeout)
MMC: mmc@4020000: 0, mmc@4021000: 1
Loading Environment from FAT... OK
In: serial@2500000
Out: serial@2500000
Err: serial@2500000
Net: eth0: ethernet@4500000
=> run mmc_boot
621288 bytes read in 109 ms (5.4 MiB/s)
## Booting kernel from Legacy Image at 40080000 ...
Image Name: OpenSolaris
Image Type: RISC-V Linux Kernel Image (uncompressed)
Data Size: 621224 Bytes = 606.7 KiB
Load Address: 40080000
Entry Point: 40080000
Verifying Checksum ... OK
## Flattened Device Tree blob at 41800000
Booting using the fdt blob at 0x41800000
Loading Kernel Image
Loading Device Tree to 0000000042ded000, end 0000000042dfffff ... OK
Starting kernel ...
phys memory add 0000000040000000 - 000000007fffffff
memory resv 0000000040000000 - 000000004007ffff
bootargs=-D /soc/mmc@4020000
bootpath=/soc/mmc@4020000
vdev_probe error
mfg_name=SUNW,sun20i
bop_init
done
Opening /boot/solaris/bootenv.rc
fd is 1
WARNING: cannot open system file: /etc/system
illumos Version SunOS_Development 64-bit
DEBUG enabled
rootnex_map_regspec: 4020000 -> ffffffc004020000
WARNING: Cannot mount /system/boot
rootnex_map_regspec: 2500000 -> ffffffc002500000
cpu0: RISC-V 64bit hart=0
Loading smf(5) service descriptions: 138/138
Hostname: unknown
WARNING: Reboot required.
The system has updated the cache of files (boot archive) that
is used during the early boot sequence. To avoid booting and
running the system with the previously out-of-sync version of
these files, the system will be restarted.
syncing file systems... done
[37]HELLO! BOOT0 is starting!
[40]BOOT0 commit : 882671f
[42]set pll start
[44]periph0 has been enabled
[47]set pll end
[48]board init ok
[50]DRAM only have internal ZQ!!
[53]get_pmu_exist() = -1
[55]ddr_efuse_type: 0x0
[58][AUTO DEBUG] two rank and full DQ!
[62]ddr_efuse_type: 0x0
[65][AUTO DEBUG] rank 0 row = 15
[68][AUTO DEBUG] rank 0 bank = 8
[71][AUTO DEBUG] rank 0 page size = 2 KB
[75][AUTO DEBUG] rank 1 row = 15
[78][AUTO DEBUG] rank 1 bank = 8
[81][AUTO DEBUG] rank 1 page size = 2 KB
[84]rank1 config same as rank0
[87]DRAM BOOT DRIVE INFO: V0.24
[90]DRAM CLK = 792 MHz
[92]DRAM Type = 3 (2:DDR2,3:DDR3)
[95]DRAMC ZQ value: 0x7b7bfb
[98]DRAM ODT value: 0x42.
[100]ddr_efuse_type: 0x0
[103]DRAM SIZE =1024 M
[107]DRAM simple test OK.
[109]dram size =1024
[111]card no is 0
[113]sdcard 0 line count 4
[115][mmc]: mmc driver ver 2021-04-2 16:45
[125][mmc]: Wrong media type 0x0
[128][mmc]: ***Try SD card 0***
[147][mmc]: HSSDR52/SDR25 4 bit
[150][mmc]: 50000000 Hz
[152][mmc]: 30436 MB
[154][mmc]: ***SD/MMC 0 init OK!!!***
[202]Loading boot-pkg Succeed(index=1).
[206]Entry_name = opensbi
[209]Entry_name = dtb
[211]Entry_name = u-boot
[215]Adding DRAM info to DTB.
[220]Jump to second Boot.
OpenSBI v0.9-334-gf5a2eb8
____ _____ ____ _____
/ __ \ / ____| _ \_ _|
| | | |_ __ ___ _ __ | (___ | |_) || |
| | | | '_ \ / _ \ '_ \ \___ \| _ < | |
| |__| | |_) | __/ | | |____) | |_) || |_
\____/| .__/ \___|_| |_|_____/|____/_____|
| |
|_|
Platform Name : Allwinner D1 Nezha
Platform Features : medeleg
Platform HART Count : 1
Platform IPI Device : aclint-mswi
Platform Timer Device : aclint-mtimer @ 24000000Hz
Platform Console Device : uart8250
Platform HSM Device : sun20i-d1-ppu
Platform Reboot Device : sunxi-wdt-reset
Platform Shutdown Device : ---
Firmware Base : 0x40000000
Firmware Size : 288 KB
Runtime SBI Version : 1.0
Domain0 Name : root
Domain0 Boot HART : 0
Domain0 HARTs : 0*
Domain0 Region00 : 0x0000000014008000-0x000000001400bfff (I)
Domain0 Region01 : 0x0000000014000000-0x0000000014007fff (I)
Domain0 Region02 : 0x0000000040000000-0x000000004007ffff ()
Domain0 Region03 : 0x0000000000000000-0xffffffffffffffff (R,W,X)
Domain0 Next Address : 0x000000004a000000
Domain0 Next Arg1 : 0x0000000044000000
Domain0 Next Mode : S-mode
Domain0 SysReset : yes
Boot HART ID : 0
Boot HART Domain : root
Boot HART Priv Version : v1.11
Boot HART Base ISA : rv64imafdcvx
Boot HART ISA Extensions : time
Boot HART PMP Count : 8
Boot HART PMP Granularity : 2048
Boot HART PMP Address Bits: 38
Boot HART MHPM Count : 0
Boot HART MIDELEG : 0x0000000000000222
Boot HART MEDELEG : 0x000000000000b109
U-Boot 2022.07-rc3-02057-g46551acba8 (Aug 16 2022 - 10:34:40 +0900)
CPU: rv64imafdc
Model: Allwinner D1 Nezha
DRAM: 1 GiB
sunxi_set_gate: (CLK#24) unhandled
Core: 66 devices, 24 uclasses, devicetree: board
WDT: Started watchdog@6011000 with servicing (16s timeout)
MMC: mmc@4020000: 0, mmc@4021000: 1
Loading Environment from FAT... OK
In: serial@2500000
Out: serial@2500000
Err: serial@2500000
Net: eth0: ethernet@4500000
=> run mmc_boot
621288 bytes read in 109 ms (5.4 MiB/s)
## Booting kernel from Legacy Image at 40080000 ...
Image Name: OpenSolaris
Image Type: RISC-V Linux Kernel Image (uncompressed)
Data Size: 621224 Bytes = 606.7 KiB
Load Address: 40080000
Entry Point: 40080000
Verifying Checksum ... OK
## Flattened Device Tree blob at 41800000
Booting using the fdt blob at 0x41800000
Loading Kernel Image
Loading Device Tree to 0000000042ded000, end 0000000042dfffff ... OK
Starting kernel ...
phys memory add 0000000040000000 - 000000007fffffff
memory resv 0000000040000000 - 000000004007ffff
bootargs=-D /soc/mmc@4020000
bootpath=/soc/mmc@4020000
vdev_probe error
mfg_name=SUNW,sun20i
bop_init
done
Opening /boot/solaris/bootenv.rc
fd is 1
WARNING: cannot open system file: /etc/system
illumos Version SunOS_Development 64-bit
DEBUG enabled
rootnex_map_regspec: 4020000 -> ffffffc004020000
WARNING: Cannot mount /system/boot
rootnex_map_regspec: 2500000 -> ffffffc002500000
cpu0: RISC-V 64bit hart=0
Hostname: unknown
unknown console login: root
rootnex_map_regspec: 2500400 -> ffffffc002500400
rootnex_map_regspec: 4500000 -> ffffffc004500000
Nov 10 07:04:52 unknown login: Solaris_audit getaddrinfo(unknown) failed[node name or service name not known]: Error 0
Nov 10 07:04:53 unknown login: Solaris_audit adt_get_local_address failed, no Audit IP address available, faking loopback and error: Network is down
Nov 10 07:04:53 unknown login: pam_unix_cred: cannot load ttyname: Network is down, continuing.
Nov 10 07:04:54 unknown login: ROOT LOGIN /dev/console
The illumos Project SunOS Development Aug. 16, 2022
illumos development build: naoyuki
root@unknown:~#