💾 Archived View for gemini.circumlunar.space › users › kraileth › neunix › eerie › 2019 › freebsd_on… captured on 2022-07-16 at 14:19:23. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-12-05)

-=-=-=-=-=-=-

Here I'm republishing an old blog post of mine originally from May 2019. The article has been slightly improved.

ARM'd and dangerous pt. 2: FreeBSD on the Pinebook (aarch64)

In February I wrote about real _aarch64 server hardware_. My interest in the ARM platform has not decreased - and this month I finally got my Pinebook shipped.

ARM'd and dangerous: FreeBSD on Cavium ThunderX (aarch64)

Aarch64

I've always been interested in alternatives to common solutions - not just with open source operating systems, but also with architectures. Sure, ARM is pretty much ubiquitous when it comes to mobile devices. But when it comes to servers or PCs, there's a total dominance of the amd64 ("x86_64") architecture. However in times of Meltdown, Spectre, Zombie Load and such it might well be worth to take a closer look at alternative platforms, even if it's not your primary interest.

_Arm Holdings_ is a UK-based company that designs processors and licenses them. There have been multiple revisions of the architecture, like ARMv6 and ARMv7. Both are 32-bit architectures used e.g. in the popular Raspberry Pi and Raspberry Pi 2. ARMv8 is the first 64-bit version and is available in form of the Raspberry Pi 3 among others. The incredible success of those small single-board computers lead to a whole lot of spin-offs.

Pine64

While a lot of the competitors specialize in extremely cheap Pi clones with a few improvements (and too often with their own problems), one of the better alternatives comes from Pine64. They don't just sell hardware that works with one custom-compiled Linux kernel which rarely (or never) gets any upgrades. On the contrary: They are trying to _build a community_ around the hardware dedicated to do cool things with it and eventually blaze a trail for high-quality ARM-based alternative hardware.

Pine64 community website

One really compelling offer is that of the *Pinebook*. While it's nothing special to use one of the little single-board computers for a media station or things like that, a real laptop is something way different. Especially as the company behind Pine64 decided to sell it at cost to people of the Linux and *BSD communities! It really is a $99 (plus shipping) 11.6" laptop. Definitely a nice idea to steer the community! Especially since they announced a _Pinebook Pro_, a _tablet_, a _phone_ and so on during this year's FOSDEM. I'm not sure when those will be available, though.

There's only one "problem" with the Pinebook: You cannot buy it regularly. If you are interested in purchasing one, you need to register on the site and when a new batch is to be made, you get a coupon code that can be used to actually place an order. Sometime last year I decided that this sounded pretty interesting and requested a coupon. I got notified in February or so and eventually the laptop was shipped in May.

Pinebook

Here's some info on the specs:

Website with full specs

Also they offered a 1366×768 display. When my Pinebook arrived, I was in for a surprise, though: They had upgraded this model to use an 1920×1080 IPS which is really nice! The low resolution of the original model was one of the things that made me think twice before buying. Glad that I chose to go ahead.

A Pinebook 1080p (PNG)

The Pinebook comes with _KDE Neon_ preinstalled. It's apparently a Debian-based distro with the latest Plasma Workspaces desktop. I opened Firefox and was able to browse the net - but I didn't buy this laptop to use boring Linux. 😉 Let's try something more exciting where not all the devices work, yet!

Preparations

The Pinebook is new enough that it's not supported with any FreeBSD release at this time. So you have to use the development branch known as _-CURRENT_. Right now it's 13-CURRENT and it's the exciting branch where all the latest features, fixes and improvements go. The FreeBSD project provides snapshots for developers or people who are willing to test bleeding edge code. Needless to say that by doing this you install an OS that is not at all meant for daily usage. It should not hold important data or anything. This is tinkering with some cool stuff - no more no less.

You need a computer that can make use of micro SD cards (or SD cards by using an adapter that usually comes with micro SDs). A 4 GB card suffices but anything bigger is also fine.

Get a snapshot and the checksum file from here (e.g. CHECKSUM.SHA512-FreeBSD-13.0-CURRENT-arm64-aarch64-PINEBOOK-20190531-r348447 and FreeBSD-13.0-CURRENT-arm64-aarch64-PINEBOOK-20190531-r348447.img.xz):

https://download.freebsd.org/ftp/snapshots/arm64/aarch64/ISO-IMAGES/13.0

Since there are differences with the various ARM-based platforms, make sure you get the right one for the Pinebook. Each file contains a date (2019-05-31 in this case) and a revision number (r348447) so you know when the snapshot was created and what version of the code in Subversion it was built from.

Once you downloaded both files, verify the checksum and decompress the archive:

% shasum -c CHECKSUM.SHA512-FreeBSD-13.0-CURRENT-arm64-aarch64-PINEBOOK-20190531-r348447
% xz -dvv FreeBSD-13.0-CURRENT-arm64-aarch64-PINEBOOK-20190531-r348447.img.xz

Now _dd_ the image onto a micro SD card. Be absolutely sure that you dd over the right device - if you don't, you can easily lose data that you wanted to keep! In my case the right device is _mmcsd0_, substitute it for yours. Get the image written with the following command (FreeBSD versions before 12.0 do not support the "progress" option - leave out the "status=progress" in this case):

# dd if=FreeBSD-13.0-CURRENT-arm64-aarch64-PINEBOOK-20190531-r348447.img of=/dev/mmcsd0 bs=1m status=progress

FreeBSD

Now insert the micro SD card into your Pinebook and turn it on. It should boot off of the card and right into FreeBSD. You might see some scary looking messages like _lock order reversals_ and things like that which you are probably not used too. Welcome to _-CURRENT_! Since you are testing a development snapshot, this version of FreeBSD has some diagnostic features enabled that are helpful in pinning down bugs (and eventually fixing them). If you're just an advanced user (like me) and not a developer, ignore them.

Log in as _root_ with the password _root_. Take a look around and if everything seems to work, power the device off again:

# shutdown -p now

On first boot, the partition holding the primary filesystem is grown to the maximum available space and the filesystem is, too. Let's put the card back into the other computer and have a look at the partitions:

# gpart show mmcsd0
=> 63 15493057 mmcsd0 MBR (7.4G)
63 2016 - free - (1.0M)
2079 110502 1 fat32lba [active] (54M)
112581 15378491 2 freebsd (7.3G)
15491072 2048 - free - (1.0M)
# gpart show mmcsd0s2
=> 0 15378491 mmcsd0s2 BSD (7.3G)
0 59 - free - (30K)
59 15378432 1 freebsd-ufs (7.3G)

As you can see, the FreeBSD slice is now > 7 GB in size, even though the original image was a lot smaller to fit onto a 4 GB card. Now that we have enough usable space, let's mount the filesystem (the only one on the second slice) and copy the image over:

# mount /dev/mmcsd0s2a /mnt
# cp FreeBSD-13.0-CURRENT-arm64-aarch64-PINEBOOK-20190531-r348447.img /mnt
# umount /mnt

Putting FreeBSD on the Pinebook

Put the micro SD card back into the Pinebook and boot off of it. Let's see how many storage devices there are:

# geom disk list
Geom name: mmcsd0
Providers:
1. Name: mmcsd0
Mediasize: 7932477440 (7.4G)
Sectorsize: 512
Stripesize: 4194304
Stripeoffset: 0
[...]
Geom name: mmcsd1
Providers:
1. Name: mmcsd1
Mediasize: 15518924800 (14G)
Sectorsize: 512
Stripesize: 512
Stripeoffset: 0
[...]

Alright, _mmcsd0_ is the SD card and _mmcsd1_ is the internal eMMC, which is a bit bigger. To "install" FreeBSD on the device (and erase Linux) just _dd_ the image onto the internal storage, shut down the system and eject the card:

# cd /
# dd if=FreeBSD-13.0-CURRENT-arm64-aarch64-PINEBOOK-20190531-r348447.img of=/dev/mmcsd1 status=progress
# shutdown -p now

Congrats, the _depenguinization_ of your device is complete! 😉 Power it on again and it'll boot FreeBSD off the eMMC.

If you get tired of this system, try another. Go to the pine64 website and browse through the "Partner Projects" tab. You'll certainly find other interesting operating systems or distributions to install.

Pine64 community website

Status of FreeBSD on the Pinebook

So what works on FreeBSD currently and what doesn't? I've read about screen flickering on the console and things like that. But from what I can say, those issues are gone. The console works well even on my 1080p model. X11 works as well and I've tested various desktop environments. Building packages from ports works, but of course this is not the kind of hardware that's best fit for that.

What did *NOT* work is e.g. Firefox - it crashes. Also sound is not working, yet.

I didn't test WLAN or Bluetooth since I'm using a USB to LAN adapter to access the net. For the _dmesg_ output see the end of this post.

What's next?

I'll stick to FreeBSD on the Pinebook and if that is your special interest, too, feel free to contact me. My current plan is to write about configuring a fresh systems, packages and a project that I started for the Pinebook (_lite packages_ and the corresponding "ports options light") [no longer available; there has been no interest in this].

dmesg.boot

------
KDB: debugger backends: ddb
KDB: current backend: ddb
Copyright (c) 1992-2019 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 13.0-CURRENT r348447 GENERIC arm64
FreeBSD clang version 8.0.0 (tags/RELEASE_800/final 356365) (based on LLVM 8.0.0)
WARNING: WITNESS option enabled, expect reduced performance.
VT(efifb): resolution 1920x1080
KLD file umodem.ko is missing dependencies
Starting CPU 1 (1)
Starting CPU 2 (2)
Starting CPU 3 (3)
FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs
arc4random: WARNING: initial seeding bypassed the cryptographic random device because it was not yet seeded and the knob 'bypass_before_seeding' was enabled.
random: entropy device external interface
MAP 47ef4000 mode 2 pages 24
MAP b8f2f000 mode 2 pages 1
MAP b8f31000 mode 2 pages 1
MAP bdf50000 mode 2 pages 16
kbd0 at kbdmux0
ofwbus0:
clk_fixed0: on ofwbus0
clk_fixed1: on ofwbus0
simplebus0: on ofwbus0
rtc0: mem 0x1f00000-0x1f003ff irq 52,53 on simplebus0
rtc0: registered as a time-of-day clock, resolution 1.000000s
regfix0: on ofwbus0
regfix1: on ofwbus0
ccu_a64ng0: mem 0x1c20000-0x1c203ff on simplebus0
ccu_sun8i_r0: mem 0x1f01400-0x1f014ff on simplebus0
psci0: on ofwbus0
aw_sid0: mem 0x1c14000-0x1c143ff on simplebus0
iichb0: mem 0x1f03400-0x1f037ff irq 57 on simplebus0
iicbus0: on iichb0
gic0: mem 0x1c81000-0x1c81fff,0x1c82000-0x1c83fff,0x1c84000-0x1c85fff,0x1c86000-0x1c87fff irq 49 on simplebus0
gic0: pn 0x2, arch 0x2, rev 0x1, implementer 0x43b irqs 224
gpio0: mem 0x1c20800-0x1c20bff irq 23,24,25 on simplebus0
gpiobus0: on gpio0
aw_nmi0: mem 0x1f00c00-0x1f00fff irq 54 on simplebus0
iichb1: mem 0x1f02400-0x1f027ff irq 55 on simplebus0
iicbus1: on iichb1
gpio1: mem 0x1f02c00-0x1f02fff irq 56 on simplebus0
gpiobus1: on gpio1
axp8xx_pmu0: at addr 0x746 irq 59 on iicbus0
gpiobus2: on axp8xx_pmu0
generic_timer0: irq 4,5,6,7 on ofwbus0
Timecounter "ARM MPCore Timecounter" frequency 24000000 Hz quality 1000
Event timer "ARM MPCore Eventtimer" frequency 24000000 Hz quality 1000
a10_timer0: mem 0x1c20c00-0x1c20c2b irq 8,9 on simplebus0
Timecounter "a10_timer timer0" frequency 24000000 Hz quality 2000
aw_syscon0: mem 0x1c00000-0x1c00fff on simplebus0
awusbphy0: mem 0x1c19400-0x1c19413,0x1c1a800-0x1c1a803,0x1c1b800-0x1c1b803 on simplebus0
cpulist0: on ofwbus0
cpu0: on cpulist0
cpufreq_dt0: on cpu0
cpu1: on cpulist0
cpu2: on cpulist0
cpu3: on cpulist0
aw_thermal0: mem 0x1c25000-0x1c250ff irq 10 on simplebus0
a31dmac0: mem 0x1c02000-0x1c02fff irq 11 on simplebus0
aw_mmc0: mem 0x1c0f000-0x1c0ffff irq 15 on simplebus0
mmc0: on aw_mmc0
aw_mmc1: mem 0x1c10000-0x1c10fff irq 16 on simplebus0
mmc1: on aw_mmc1
aw_mmc2: mem 0x1c11000-0x1c11fff irq 17 on simplebus0
mmc2: on aw_mmc2
ehci0: mem 0x1c1a000-0x1c1a0ff irq 19 on simplebus0
usbus0: EHCI version 1.0
usbus0 on ehci0
ohci0: mem 0x1c1a400-0x1c1a4ff irq 20 on simplebus0
usbus1 on ohci0
ehci1: mem 0x1c1b000-0x1c1b0ff irq 21 on simplebus0
usbus2: EHCI version 1.0
usbus2 on ehci1
ohci1: mem 0x1c1b400-0x1c1b4ff irq 22 on simplebus0
usbus3 on ohci1
gpioc0: on gpio0
uart0: mem 0x1c28000-0x1c283ff irq 31 on simplebus0
uart0: console (115384,n,8,1)
pwm0: mem 0x1c21400-0x1c217ff on simplebus0
pwmbus0: on pwm0
pwmc0: on pwm0
iic0: on iicbus1
gpioc1: on gpio1
gpioc2: on axp8xx_pmu0
iic1: on iicbus0
aw_wdog0: mem 0x1c20ca0-0x1c20cbf irq 58 on simplebus0
cryptosoft0:
Timecounters tick every 1.000 msec
usbus0: 480Mbps High Speed USB v2.0
usbus1: 12Mbps Full Speed USB v1.0
ugen0.1: at usbus0
ugen1.1: at usbus1
uhub0: on usbus1
uhub1: on usbus0
usbus2: 480Mbps High Speed USB v2.0
usbus3: 12Mbps Full Speed USB v1.0
ugen2.1: at usbus2
uhub2: on usbus2
ugen3.1: at usbus3
uhub3: on usbus3
AW_MMC_INT_RESP_TIMEOUT
uhub0: 1 port with 1 removable, self powered
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
uhub3: 1 port with 1 removable, self powered
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
mmc0: No compatible cards found on bus
aw_mmc0: Spurious interrupt - no active request, rint: 0x00000004
aw_mmc1: Cannot set vqmmc to 33000003300000
uhub1: 1 port with 1 removable, self powered
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
uhub2: 1 port with 1 removable, self powered
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
mmc1: No compatible cards found on bus
aw_mmc1: Spurious interrupt - no active request, rint: 0x00000004
aw_mmc2: Cannot set vqmmc to 33000003300000
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_DATA_END_BIT_ERR
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
AW_MMC_INT_RESP_TIMEOUT
mmcsd0: 16GB at mmc2 52.0MHz/8bit/4096-block
mmcsd0boot0: 4MB partion 1 at mmcsd0
mmcsd0boot1: 4MB partion 2 at mmcsd0
mmcsd0rpmb: 4MB partion 3 at mmcsd0
Release APs...done
CPU 0: ARM Cortex-A53 r0p4 affinity: 0
Trying to mount root from ufs:/dev/ufs/rootfs [rw]...
Instruction Set Attributes 0 =
Instruction Set Attributes 1 =
Processor Features 0 =
Processor Features 1 =
Memory Model Features 0 =
Memory Model Features 1 =
Memory Model Features 2 =
Debug Features 0 =
Debug Features 1 =
Auxiliary Features 0 =
Auxiliary Features 1 =
CPU 1: ARM Cortex-A53 r0p4 affinity: 1
CPU 2: ARM Cortex-A53 r0p4 affinity: 2
CPU 3: ARM Cortex-A53 r0p4 affinity: 3
WARNING: WITNESS option enabled, expect reduced performance.
ugen2.2: at usbus2
uhub4: on usbus2
random: randomdev_wait_until_seeded unblock wait
uhub4: 4 ports with 1 removable, self powered
ugen2.3: at usbus2
ukbd0 on uhub4
ukbd0: on usbus2
kbd1 at ukbd0
hid_get_item: Number of items(1039) truncated to 1024
hid_get_item: Number of items(1039) truncated to 1024
hid_get_item: Number of items(1039) truncated to 1024
ums0 on uhub4
ums0: on usbus2
hid_get_item: Number of items(1039) truncated to 1024
hid_get_item: Number of items(1039) truncated to 1024
hid_get_item: Number of items(1039) truncated to 1024
hid_get_item: Number of items(1039) truncated to 1024
hid_get_item: Number of items(1039) truncated to 1024
ums0: 5 buttons and [XYZT] coordinates ID=1
hid_get_item: Number of items(1039) truncated to 1024
hid_get_item: Number of items(1039) truncated to 1024
hid_get_item: Number of items(1039) truncated to 1024
hid_get_item: Number of items(1039) truncated to 1024
hid_get_item: Number of items(1039) truncated to 1024
hid_get_item: Number of items(1039) truncated to 1024
hid_get_item: Number of items(1039) truncated to 1024
hid_get_item: Number of items(1039) truncated to 1024
hid_get_item: Number of items(1039) truncated to 1024
ugen2.4: at usbus2
random: randomdev_wait_until_seeded unblock wait
random: unblocking device.
GEOM_PART: mmcsd0s2 was automatically resized.
Use `gpart commit mmcsd0s2` to save changes or `gpart undo mmcsd0s2` to revert them.
lock order reversal:
1st 0xffff000040a26ff8 bufwait (bufwait) @ /usr/src/sys/kern/vfs_bio.c:3904
2nd 0xfffffd00011a1400 dirhash (dirhash) @ /usr/src/sys/ufs/ufs/ufs_dirhash.c:289
stack backtrace:
#0 0xffff0000004538a0 at witness_debugger+0x64
#1 0xffff0000003f7f9c at _sx_xlock+0x7c
#2 0xffff00000068879c at ufsdirhash_add+0x38
#3 0xffff00000068b0d8 at ufs_direnter+0x3c4
#4 0xffff000000691b14 at ufs_rename+0xb7c
#5 0xffff000000755b60 at VOP_RENAME_APV+0x90
#6 0xffff0000004c1678 at kern_renameat+0x304
#7 0xffff000000718448 at do_el0_sync+0x4fc
#8 0xffff0000006ff200 at handle_el0_sync+0x84
lo0: link state changed to UP

BACK TO 2019 OVERVIEW