Allwinner D1
FreeBSD Support
Driver support status
Device/Feature |
Status |
Commits |
Notes |
UART |
Done |
|
|
PLIC |
Done |
|
|
clk/reset |
Done |
d1-r-ccu not implemented; unclear who is/will be the consumer of these clocks |
|
RTC |
Done |
aw_rtc(4), changes required |
|
Timer |
In-progress |
|
a10_timer(4), needed because SBI timer interface is not implemented |
MMC |
In-progress |
|
aw_mmc(4), changes required |
Ethernet |
In-progress |
|
if_awg(4) |
GPIO |
In-progress |
|
aw_gpio(4) |
USB |
In-progress |
|
aw_usbphy(4), generic_fdt_ehci(4), generic_fdt_ohci(4) |
USB OTG |
In-progress |
|
musbotg(4) |
SPI |
Unknown |
|
Untested, supported by aw_spi(4) |
I2C |
Unknown |
|
Untested, supported by a10_twsi(4) |
Crypto Engine |
Unsupported |
|
No existing driver for allwinner crypto engine, sun20i-d1-crypto |
Power domain |
Unsupported |
|
No existing driver for sun20i-d1-ppu |
CPU support status
T-HEAD C906 WIP
Development branch
Available at https://github.com/mhorne/freebsd/tree/d1-dev.
The branch contains changes necessary to boot FreeBSD. It may be updated (force-push'd) without notice.
Firmware
Support for the T-HEAD C906 SoC is present upstream in OpenSBI. Install the sysutils/opensbi port or package.
u-boot support for the Nezha board is available in a custom fork, but has not been upstreamed. It is unclear if this will ever happen. https://github.com/smaeul/u-boot/tree/d1-wip
Build u-boot:
# Install prerequisites pkg install opensbi riscv64-none-elf-gcc # Clone repo git clone https://github.com/smaeul/u-boot/tree/d1-wip u-boot-d1 cd u-boot-d1 # Configure + build gmake nezha_defconfig gmake -j8 CROSS_COMPILE=riscv64-none-elf- OPENSBI=/usr/local/share/opensbi/lp64/generic/firmware/fw_dynamic.bin
Note: configs for other boards are dongshan_nezha_stu_defconfig, lichee_rv_86_panel_defconfig, lichee_rv_dock_defconfig, and mangopi_mq_pro_defconfig.
Prepare SD Card
Fetch the latest GENERICSD image from https://download.freebsd.org/snapshots/riscv/riscv64/ISO-IMAGES/
Copy it to your drive:
# Extract it. xz --decompress FreeBSD-GENERICSD.img.xz # Copy using dd(1) to your SD device. The example is /dev/da0, but CHECK BEFORE YOU WRITE! dd if=/path/to/FreeBSD-GENERICSD.img of=/dev/da0 bs=2m conv=sync status=progress
Inspect the result and delete unneeded firmware partitions:
# List the new partition table gpart show da0 => 40 12582832 da0 GPT (30G) [CORRUPT] 40 4056 - free - (2.0M) 4096 4096 1 hifive-fsbl (2.0M) 8192 8192 2 hifive-bbl (4.0M) 16384 110592 3 efi (54M) 126976 12455808 4 freebsd-ufs (5.9G) 12582784 88 - free - (44K) # Rewrite the backup GPT table gpart recover da0 # Delete partitions (optional, but 'correct') gpart delete -i 1 da0 gpart delete -i 2 da0 # Result: gpart show da0 => 40 62333872 da0 GPT (30G) 40 16344 - free - (8.0M) 16384 110592 3 efi (54M) 126976 12455808 4 freebsd-ufs (5.9G) 12582784 49751128 - free - (24G)
Copy the u-boot firmware file, built previously.
dd if=/path/to/u-boot/u-boot-sunxi-with-spl.bin of=/dev/da0 bs=1k seek=128 conv=sync
Finally, install the custom kernel built from the dev branch:
mount /dev/da0p4 /mnt cd /path/to/freebsd-src make DESTDIR=/mnt TARGET=riscv installkernel umount /mnt
You can make any other desired tweaks to the system before unmounting.
Upon first boot, the root partition will be automatically resized to fill the remaining space, and a swap partition will be added.
... Starting file system checks: /dev/ufs/rootfs: FILE SYSTEM CLEAN; SKIPPING CHECKS /dev/ufs/rootfs: clean, 569155 free (1147 frags, 71001 blocks, 0.1% fragmentation) Growing root partition to fill device Adding swap partition mmcsd0 recovering is not needed mmcsd0p1 added mmcsd0p4 resized super-block backups (for fsck_ffs -b #) at: 12804672, 14085120, 15365568, 16646016, 17926464, 19206912, 20487360, 21767808, 23048256, 24328704, 25609152, 26889600, 28170048, 29450496, 30730944, 32011392, 33291840, 34572288, 35852736, 37133184, 38413632, 39694080, 40974528, 42254976, 43535424, 44815872, 46096320, 47376768, 48657216, 49937664, 51218112, 52498560, 53779008, 55059456, 56339904, 57620352 Metadata value stored on mmcsd0p1. Done. ... root@generic:~ # gpart show => 40 62333872 mmcsd0 GPT (30G) 40 16344 - free - (8.0M) 16384 110592 3 efi (54M) 126976 58077184 4 freebsd-ufs (28G) 58204160 4128768 1 freebsd-swap (2.0G) 62332928 984 - free - (492K)
Notes
Apparently the hardware does not have a static MAC address written in ROM; or u-boot doesn't know how to find it:
Warning: ethernet@4500000 (eth0) using random MAC address - 8e:e7:ab:cb:e0:fe
Each boot will generate a new MAC address, which is problematic when trying to netboot. The solution is to execute the saveenv command. After this, u-boot will use the saved address every time.