FreeBSD, Electronics and more
I've received my C.H.I.P. the day I left for EuroBSDCon. I took it with me to see if I could quickly port FreeBSD on it.
Since there is not SD/MMC on it, I would need to do boot on a usb drive, unfortunatly the U-Boot version that my CHIP came with is very old, it is based on 2015.04 and doesn't support USB. So I just put it in my bag and enjoy the conference.
Last week after unpacking I've given a shot a booting FreeBSD. The first step was compiling a recent U-Boot, and using the ports system for that is quite easy now. The ports will soon be commited, in the meantime your can download the patch here.
Now that we have U-Boot the problem is how to run this one instead of the flashed one. We have two options :
Since I didn't know if the new U-Boot will work correctly I've choose using FEL mode.
FEL mode is a special mode on Allwinner SoC where the BootROM (Stored in the SoC) configure the USB OTG port as a slave device intended for programming and recovery.
An open source tools called (sunxi-tools)[https://github.com/linux-sunxi/sunxi-tools] support most of the Allwinner devices so I've created a port.
Now we can use our customized uboot for FreeBSD which support USB.
We need to enable FEL mode on the CHIP by connecting the FEL pin into GND and connect via UART. The guys at NextThingCo did a good job at writing pin names on the headers.
sudo sunxi-fel uboot /usr/local/share/u-boot/u-boot-chip/u-boot-sunxi-with-spl.bin
U-Boot SPL 2016.09 (Oct 08 2016 - 13:54:13) DRAM: 512 MiB CPU: 1008000000Hz, AXI/AHB/APB: 3/2/2 Trying to boot from FEL U-Boot 2016.09 (Oct 08 2016 - 13:54:13 +0200) Allwinner Technology CPU: Allwinner A13 (SUN5I) Model: NextThing C.H.I.P. I2C: ready DRAM: 512 MiB WARNING: Caches not enabled ** Bad device mmc 0 ** Using default environment Setting up a 720x576i composite-pal console (overscan 32x20) In: serial Out: vga Err: vga Net: No ethernet found. starting USB... USB0: USB EHCI 1.00 USB1: USB OHCI 1.0 scanning bus 0 for devices... 2 USB Device(s) found Hit any key to stop autoboot: 0
Since U-Boot is configured for booting of MMC we need to configure it to boot on the usb drive :
=> env set fatdev usb 0 => boot Booting from: usb 0 ubldr.bin reading ubldr.bin 225908 bytes read in 115 ms (1.9 MiB/s) ## No elf image at address 0x42000000 ## Starting application at 0x42000000 ... Consoles: U-Boot console Compatible U-Boot API signature found @0x5af38b30 FreeBSD/armv6 U-Boot loader, Revision 1.2 (email@example.com, Sat Oct 1 17:45:22 CEST 2016) DRAM: 512MB Number of U-Boot devices: 1 U-Boot env: loaderdev='usb 0' Found U-Boot device: disk Checking unit=0 slice=<auto> partition=<auto>... good. Booting from disk0s2a: /boot/kernel/kernel data=0x620764+0xa789c syms=[0x4+0x89f50+0x4+0x9eef4] Hit [Enter] to boot immediately, or any other key for command prompt.
Nothing fancy on the usb drive, a fat16 partition for U-Boot to load ubldr.bin and a UFS partition for FreeBSD.
For now GPIOs, I2C and USB works among other stuff, I haven't looked at the PocketChip for now but it's on my todo list (like a lot of stuff ...).