User:Mjb/FreeBSD on BeagleBone Black

From Offset
< User:Mjb
Revision as of 05:10, 19 July 2015 by Mjb (talk | contribs) (Install the ports collection)
Jump to navigationJump to search

I'm experimenting with running FreeBSD on a BeagleBone Black (revision C).

See also my BeagleBone Black notes.

Initial installation

  1. Get a compressed snapshot (.img.xz file) from FreeBSD's ARMv6 snapshots on ftp.freebsd.org. At the beginning of July 2015, when the latest production version was 10.1-RELEASE, I first tried a 10.1 snapshot. However, it was unable to fully boot and mount the root file system. I asked about it on Freenode IRC (channel #freebsd-embedded) and was advised that 11-CURRENT was the better choice for ARM support, at the moment. Indeed, the June 30th 11.0-CURRENT snapshot works like a charm...except for networking. 10.2-STABLE should be usable in the next snapshot.
  2. Uncompress it (e.g., with 7-Zip).
  3. Use a disk image writing program (e.g. Win32DiskImager, or 'dd' on BSD/Linux) to write the image to a micro SD card. I use a 64 GB card via a USB adapter in my PC.
  4. With power off, insert the micro SD card in the BBB.
  5. Hold the boot button (it's the button near the card) and plug in the BBB. Keep holding the boot button for a few seconds to be sure it boots from the micro SD card. It will remember to boot from the card until the power is cut. Don't worry, there's a way to make it always boot from the SD card, but you don't want to do that until you're sure the OS on the SD card is working.

This is what I got the first time I booted 11-CURRENT:

-Boot SPL 2014.10 (Jul 01 2015 - 02:18:55)
MMC: block number 0x100 exceeds max(0x0)
MMC: block number 0x200 exceeds max(0x0)
*** Error - No Valid Environment Area found
Using default environment

reading u-boot.img
reading u-boot.img


U-Boot 2014.10 (Jul 01 2015 - 02:18:55)

       Watchdog enabled
I2C:   ready
DRAM:  512 MiB
MMC:   OMAP SD/MMC: 0, OMAP SD/MMC: 1
reading u-boot.env

** Unable to read "u-boot.env" from mmc0:1 **
Using default environment

Net:   <ethaddr> not set. Validating first E-fuse MAC
Phy not found
cpsw, usb_ether
reading uEnv.txt
** Unable to read file uEnv.txt **
Hit any key to stop autoboot:  0
Booting from: mmc 0 ubldr
reading ubldr
260690 bytes read in 19 ms (13.1 MiB/s)
## Starting application at 0x88000094 ...
Consoles: U-Boot console
Compatible U-Boot API signature found @9e731510

FreeBSD/armv6 U-Boot loader, Revision 1.2
(root@releng2.nyi.freebsd.org, Wed Jul  1 02:37:43 UTC 2015)

DRAM: 512MB
Number of U-Boot devices: 3
U-Boot env: loaderdev='mmc 0'
Found U-Boot device: disk
  Checking unit=0 slice=<auto> partition=<auto>... good.
/
/boot/kernel/kernel data=0x56cf58+0x10f0a8 syms=[0x4+0x670b0+0x4+0x6b377]
Hit [Enter] to boot immediately, or any other key for command prompt.
Booting [/boot/kernel/kernel]...
/boot/dtb/beaglebone-black.dtb size=0x7a86
Loaded DTB from file 'beaglebone-black.dtb'.
Kernel entry at 0x88200100...
Kernel args: (null)
KDB: debugger backends: ddb
KDB: current backend: ddb
Copyright (c) 1992-2015 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 11.0-CURRENT #0 r284969: Wed Jul  1 02:43:13 UTC 2015
    root@releng2.nyi.freebsd.org:/usr/obj/arm.armv6/usr/src/sys/BEAGLEBONE arm
FreeBSD clang version 3.6.1 (tags/RELEASE_361/final 237755) 20150525
WARNING: WITNESS option enabled, expect reduced performance.
VT: init without driver.
CPU: Cortex A8-r3 rev 2 (Cortex-A core)
 Supported features: ARM_ISA THUMB2 JAZELLE THUMBEE ARMv4 Security_Ext
 WB disabled EABT branch prediction enabled
LoUU:2 LoC:3 LoUIS:1
Cache level 1:
 32KB/64B 4-way data cache WT WB Read-Alloc
 32KB/64B 4-way instruction cache Read-Alloc
Cache level 2:
 256KB/64B 8-way unified cache WT WB Read-Alloc Write-Alloc
real memory  = 536870912 (512 MB)
avail memory = 512057344 (488 MB)
Texas Instruments AM335x Processor, Revision ES1.2
random: entropy device external interface
kbd0 at kbdmux0
ofwbus0: <Open Firmware Device Tree>
simplebus0: <Flattened device tree simple bus> on ofwbus0
ti_scm0: <TI Control Module> mem 0x44e10000-0x44e107fb on ofwbus0
ti_pinmux0: <TI Pinmux Module> mem 0x44e10800-0x44e10a37 on ofwbus0
am335x_prcm0: <AM335x Power and Clock Management> mem 0x44e00000-0x44e03fff on simplebus0
am335x_prcm0: Clocks: System 24.0 MHz, CPU 1000 MHz
ti_scm_probe: multiple SCM modules in device tree data, ignoring
aintc0: <TI AINTC Interrupt Controller> mem 0x48200000-0x48200fff on simplebus0
aintc0: Revision 5.0
ti_edma30: <TI EDMA Controller> mem 0x49000000-0x4900ffff,0x44e10f90-0x44e10fcf irq 12,13,14 on simplebus0
ti_edma30: EDMA revision 40014c00
gpio0: <Ti AM335x General Purpose I/O (GPIO)> mem 0x44e07000-0x44e07fff irq 96 on simplebus0
gpiobus0: <OFW GPIO bus> on gpio0
gpioc0: <GPIO controller> on gpio0
gpio1: <Ti AM335x General Purpose I/O (GPIO)> mem 0x4804c000-0x4804cfff irq 98 on simplebus0
gpiobus1: <OFW GPIO bus> on gpio1
gpioled0: <GPIO led> at pin(s) 21 on gpiobus1
gpioled1: <GPIO led> at pin(s) 22 on gpiobus1
gpioled2: <GPIO led> at pin(s) 23 on gpiobus1
gpioled3: <GPIO led> at pin(s) 24 on gpiobus1
gpioc1: <GPIO controller> on gpio1
gpio2: <Ti AM335x General Purpose I/O (GPIO)> mem 0x481ac000-0x481acfff irq 32 on simplebus0
gpiobus2: <OFW GPIO bus> on gpio2
gpioc2: <GPIO controller> on gpio2
gpio3: <Ti AM335x General Purpose I/O (GPIO)> mem 0x481ae000-0x481aefff irq 62 on simplebus0
gpiobus3: <OFW GPIO bus> on gpio3
gpioc3: <GPIO controller> on gpio3
uart0: <TI UART (16550 compatible)> mem 0x44e09000-0x44e0afff irq 72 on simplebus0
uart0: console (115384,n,8,1)
iichb0: <TI I2C Controller> mem 0x44e0b000-0x44e0bfff irq 70 on simplebus0
iichb0: I2C revision 4.0 FIFO size: 32 bytes
iicbus0: <OFW I2C bus> on iichb0
iic0: <I2C generic I/O> on iicbus0
am335x_pmic0: <TI TPS65217 Power Management IC> at addr 0x24 irq 7 on iicbus0
tda0 at addr 0x70 on iicbus0
sdhci_ti0: <TI MMCHS (SDHCI 2.0)> mem 0x48060000-0x48060fff irq 64 on simplebus0
mmc0: <MMC/SD bus> on sdhci_ti0
sdhci_ti1: <TI MMCHS (SDHCI 2.0)> mem 0x481d8000-0x481d8fff irq 28 on simplebus0
mmc1: <MMC/SD bus> on sdhci_ti1
ti_wdt0: <TI Watchdog Timer> mem 0x44e35000-0x44e35fff irq 91 on simplebus0
ti_mbox0: <TI System Mailbox> mem 0x480c8000-0x480c81ff irq 77 on simplebus0
ti_mbox0: revision 4.0
am335x_dmtimer0: <AM335x DMTimer> mem 0x44e31000-0x44e313ff irq 67 on simplebus0
am335x_dmtimer1: <AM335x DMTimer> mem 0x48040000-0x480403ff irq 68 on simplebus0
Timecounter "AM335x Timecounter" frequency 24000000 Hz quality 1000
am335x_dmtimer2: <AM335x DMTimer> mem 0x48042000-0x480423ff irq 69 on simplebus0
Event timer "AM335x Eventtimer" frequency 24000000 Hz quality 1000
am335x_dmtimer3: <AM335x DMTimer> mem 0x48044000-0x480443ff irq 92 on simplebus0
am335x_dmtimer4: <AM335x DMTimer> mem 0x48046000-0x480463ff irq 93 on simplebus0
am335x_dmtimer5: <AM335x DMTimer> mem 0x48048000-0x480483ff irq 94 on simplebus0
am335x_dmtimer6: <AM335x DMTimer> mem 0x4804a000-0x4804a3ff irq 95 on simplebus0
am335x_rtc0: <AM335x RTC (power management mode)> mem 0x44e3e000-0x44e3efff irq 75,76 on simplebus0
am335x_rtc0: AM335X RTC v1.0.6
usbss0: <TI AM33xx integrated USB OTG controller> mem 0x47400000-0x47400fff on simplebus0
usbss0: TI AM335X USBSS v0.0.13
musbotg0: <TI AM33xx integrated USB OTG controller> mem 0x47401400-0x474017ff,0x47401000-0x474011ff irq 18 on usbss0
usbus0: Dynamic FIFO sizing detected, assuming 16Kbytes of FIFO RAM
usbus0 on musbotg0
musbotg1: <TI AM33xx integrated USB OTG controller> mem 0x47401c00-0x47401fff,0x47401800-0x474019ff irq 19 on usbss0
usbus1: Dynamic FIFO sizing detected, assuming 16Kbytes of FIFO RAM
usbus1 on musbotg1
cpsw0: <3-port Switch Ethernet Subsystem> mem 0x4a100000-0x4a1007ff,0x4a101200-0x4a1012ff irq 40,41,42,43 on simplebus0
cpsw0: CPSW SS Version 1.12 (0)
cpsw0: Initial queue size TX=128 RX=384
cpsw0: Failed to read from PHY.
cpsw0: attaching PHYs failed
device_attach: cpsw0 attach returned 6
fb0: <AM335x LCD controller> mem 0x4830e000-0x4830efff irq 36 on simplebus0
ti_adc0: <TI ADC controller> mem 0x44e0d000-0x44e0dfff irq 16 disabled on simplebus0
ti_adc0: scheme: 0x1 func: 0x730 rtl: 0 rev: 0.1 custom rev: 0
ti_pruss0: <TI Programmable Realtime Unit Subsystem> mem 0x4a300000-0x4a37ffff irq 20,21,22,23,24,25,26,27 on simplebus0
ti_pruss0: AM33xx PRU-ICSS
Timecounters tick every 10.000 msec
usbus0: 480Mbps High Speed USB v2.0
usbus1: 480Mbps High Speed USB v2.0
am335x_pmic0: TPS65217C ver 1.2 powered by AC
tda0: TDA19988
ugen1.1: <Mentor Graphics> at usbus1
uhub0: <Mentor Graphics OTG Root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus1
ugen0.1: <Mentor Graphics> at usbus0
uhub1: <Mentor Graphics OTG Root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus0
uhub0: 1 port with 1 removable, self powered
uhub1: 1 port with 1 removable, self powered
tda0: failed to read EDID
mmc0: CMD7 failed, RESULT: 1
mmcsd0: 64GB <SDHC 00000 1.0 SN 0A1806A0 MFG 02/2015 by 27 SM> at mmc0 48.0MHz/4bit/65535-block
mmcsd1: 4GB <MMCHC S10004 0.8 SN 34D2DDBF MFG 02/1999 by 112 0x0000> at mmc1 48.0MHz/8bit/65535-block
WARNING: WITNESS option enabled, expect reduced performance.
Trying to mount root from ufs:/dev/ufs/rootfs [rw]...
warning: no time-of-day clock registered, system time will not be set accurately
Growing root partition to fill device
GEOM_PART: mmcsd0s2 was automatically resized.
  Use `gpart commit mmcsd0s2` to save changes or `gpart undo mmcsd0s2` to revert them.
mmcsd0s2 resized
mmcsd0s2a resized
super-block backups (for fsck_ffs -b #) at:
 2093248, 2616512, 3139776, 3663040, 4186304, 4709568, 5232832, 5756096,
 6279360, 6802624, 7325888, 7849152, 8372416, 8895680, 9418944, 9942208,
 10465472, 10988736, 11512000, 12035264, 12558528, 13081792, 13605056,
 14128320, 14651584, 15174848, 15698112, 16221376, 16744640, 17267904,
 17791168, 18314432, 18837696, 19360960, 19884224, 20407488, 20930752,
 21454016, 21977280, 22500544, 23023808, 23547072, 24070336, 24593600,
 25116864, 25640128, 26163392, 26686656, 27209920, 27733184, 28256448,
 28779712, 29302976, 29826240, 30349504, 30872768, 31396032, 31919296,
 32442560, 32965824, 33489088, 34012352, 34535616, 35058880, 35582144,
 36105408, 36628672, 37151936, 37675200, 38198464, 38721728, 39244992,
 39768256, 40291520, 40814784, 41338048, 41861312, 42384576, 42907840,
 43431104, 43954368, 44477632, 45000896, 45524160, 46047424, 46570688,
 47093952, 47617216, 48140480, 48663744, 49187008, 49710272, 50233536,
 50756800, 51280064, 51803328, 52326592, 52849856, 53373120, 53896384,
 54419648, 54942912, 55466176, 55989440, 56512704, 57035968, 57559232,
 58082496, 58605760, 59129024, 59652288, 60175552, 60698816, 61222080,
 61745344, 62268608, 62791872, 63315136, 63838400, 64361664, 64884928,
 65408192, 65931456, 66454720, 66977984, 67501248, 68024512, 68547776,
 69071040, 69594304, 70117568, 70640832, 71164096, 71687360, 72210624,
 72733888, 73257152, 73780416, 74303680, 74826944, 75350208, 75873472,
 76396736, 76920000, 77443264, 77966528, 78489792, 79013056, 79536320,
 80059584, 80582848, 81106112, 81629376, 82152640, 82675904, 83199168,
 83722432, 84245696, 84768960, 85292224, 85815488, 86338752, 86862016,
 87385280, 87908544, 88431808, 88955072, 89478336, 90001600, 90524864,
 91048128, 91571392, 92094656, 92617920, 93141184, 93664448, 94187712,
 94710976, 95234240, 95757504, 96280768, 96804032, 97327296, 97850560,
 98373824, 98897088, 99420352, 99943616, 100466880, 100990144, 101513408,
 102036672, 102559936, 103083200, 103606464, 104129728, 104652992, 105176256,
 105699520, 106222784, 106746048, 107269312, 107792576, 108315840, 108839104,
 109362368, 109885632, 110408896, 110932160, 111455424, 111978688, 112501952,
 113025216, 113548480, 114071744, 114595008, 115118272, 115641536, 116164800,
 116688064, 117211328, 117734592, 118257856, 118781120, 119304384, 119827648,
 120350912, 120874176, 121397440, 121920704, 122443968, 122967232, 123490496,
 124013760, 124537024
random: unblocking device.
/etc/rc: WARNING: hostid: unable to figure out a UUID from DMI data, generating a new one
Setting hostuuid: 95d0873f-1f9c-11e5-b260-0d8dd5fe3433.
Setting hostid: 0x66ac9b5e.
No suitable dump device was found.
Starting file system checks:
/dev/ufs/rootfs: FILE SYSTEM CLEAN; SKIPPING CHECKS
/dev/ufs/rootfs: clean, 15017884 free (28 frags, 1877232 blocks, 0.0% fragmentation)
Mounting local file systems:.
Setting hostname: beaglebone.
Setting up harvesting:[HIGH_PERFORMANCE],[FS_ATIME],SWI,INTERRUPT,NET_NG,NET_ETHER,NET_TUN,MOUSE,KEYBOARD,ATTACH,CACHED
Feeding entropy:.
Starting Network: lo0.
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
        inet6 ::1 prefixlen 128
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
        inet 127.0.0.1 netmask 0xff000000
        groups: lo
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
ELF ldconfig path: /lib /usr/lib /usr/lib/compat
Starting devd.
add net fe80::: gateway ::1
add net ff02::: gateway ::1
add net ::ffff:0.0.0.0: gateway ::1
add net ::0.0.0.0: gateway ::1
Generating host.conf.
Creating and/or trimming log files.
Starting syslogd.
Starting casperd.
Clearing /tmp (X related).
Updating motd:.
Mounting late file systems:.
Generating RSA1 host key.
2048 00:0b:b2:0e:b6:35:58:e2:c9:4e:b0:45:b4:1b:6b:0b  root@beaglebone (RSA1)
Generating RSA host key.
2048 d7:01:ce:25:45:b4:5d:61:69:e4:81:b3:e5:fc:b5:bf  root@beaglebone (RSA)
Generating DSA host key.
1024 9d:54:fd:dd:6e:1e:76:71:be:5e:03:49:f6:4c:1c:3c  root@beaglebone (DSA)
Generating ECDSA host key.
256 bc:27:e2:e1:dd:06:33:b3:95:f0:26:85:9d:40:15:cf  root@beaglebone (ECDSA)
Generating ED25519 host key.
256 a8:13:f1:f0:70:84:85:8f:72:63:a3:af:a3:dd:cd:e5  root@beaglebone (ED25519)
Performing sanity check on sshd configuration.
Starting sshd.
Starting cron.
Starting background file system checks in 60 seconds.

Wed Jul  1 02:56:01 UTC 2015

FreeBSD/arm (beaglebone) (ttyu0)

login:

The default username and password are root and root.

Networking

The boot log showed cpsw0 as the network interface, but there's no sign of it when running ifconfig. I asked about it on the freebsd-arm list. Someone said via email that the NIC fails at random on startup, for reasons unknown. I set it aside and waited for a new snapshot.

After I installed the July 16 snapshot of 11.0, it worked on first boot.

Initial time set

Login as root (pw: root). Of course the clock is wrong. Just run ntpdate pool.ntp.org to get it right before doing anything else.

ntpd is not set up to run, and I prefer openntpd, so the ports collection has to be installed.

Customize .cshrc & .login

Now is a good time to scp my fancy .cshrc and .login from my other servers.

Install pkg

If you try to run pkg, it will install an old version.

  • pkg info -aoq
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]: y
Bootstrapping pkg from pkg+http://pkg.FreeBSD.org/FreeBSD:11:armv6/latest, please wait...
Verifying signature with trusted certificate pkg.freebsd.org.2013102301... done
Installing pkg-1.5.2...
Extracting pkg-1.5.2: 100%
Message for pkg-1.5.2:
If you are upgrading from the old package format, first run:

  # pkg2ng
ports-mgmt/pkg

(That last line is the output of the pkg info command you first tried to run.)

I think it might be better to just let pkg get installed later when needed(?)

Install the ports collection

This will take forever.

  • portsnap fetch extract

Several lock order reversal messages with stack traces come up. These are normal and are for debugging FreeBSD-CURRENT. See https://www.freebsd.org/doc/faq/troubleshoot.html#idp59162064

root@beaglebone:~ # portsnap fetch extract
Looking up portsnap.FreeBSD.org mirrors... 7 mirrors found.
Fetching public key from isc.portsnap.freebsd.org... done.
Fetching snapshot tag from isc.portsnap.freebsd.org... done.
Fetching snapshot metadata... done.
Fetching snapshot generated at Sat Jul 18 00:01:57 UTC 2015:
0254d062f604bc2ee66614ff8a9f9158847d0dea1cb903100% of   75 MB  863 kBps 01m30s
Extracting snapshot... done.
Verifying snapshot integrity...
[...lots of stuff trimmed...]
/usr/ports/x11/xzoom/
/usr/ports/x11/yad/
/usr/ports/x11/yakuake-kde4/
/usr/ports/x11/yalias/
/usr/ports/x11/yeahconsole/
/usr/ports/x11/yelp/
/usr/ports/x11/zenity/
Building new INDEX files... done.

Install portmaster

  • cd /usr/ports/ports-mgmt/portmaster
  • make install
  • echo WITH_PKGNG=yes >> /etc/make.conf
  • pkg2ng

I don't know if the last two lines are still necessary, but portmaster says to do it.

Install nano

  • portmaster editors/nano

Install OpenNTPD

See instructions at User:Mjb/FreeBSD#OpenNTPD.

Mail

The Sendmail daemon is apparently disabled by default, so immediately some emails from root to root start backing up in the queue. From the messages in /var/log/maillog it looks like the client supports STARTTLS without having to be custom built with SASL2 like in FreeBSD 8.

However, I am going to try OpenSMTPD now.

  • portmaster mail/opensmtpd – also installs various dependencies
  • echo smtpd_enable="YES" >> /etc/rc.conf
  • service smtpd start

For some reason, starting the service failed at first:

Performing sanity check on smtpd configuration:
invalid hostname: getaddrinfo() failed: hostname nor servname provided, or not known
/usr/local/etc/rc.d/smtpd: WARNING: failed precmd routine for smtpd

It's just trying to run smtpd -n at this point. I don't know why getaddrinfo() fails here. That's a hostname/IP address lookup function that first tries /etc/hosts and then tries DNS, but it seems like it's not even being called properly. After poking around a bit and trying to add beaglebone as another 127.0.0.1 hostname in /etc/hosts, I decided to just reboot and see if it worked then. It did; smtpd started up no problem, and subsequent runs of smtpd -n result in "configuration OK".

OpenSSL

When building OpenSSL from the ports collection, I chose these 'make config' options: SHARED, THREADS, SCTP, RC5, DOCS. I disabled SSE2, SSLv2, SSLv3, MD2.

BOINC

I like to run the distributed.net client on all my machines, but it is not open-source, and there are no builds for ARMv6 on FreeBSD.

Ordinarily you can run it through BOINC with the Moo! Wrapper but this doesn't work either. Here's the general idea with BOINC though:

Install BOINC and start the client:

  • portmaster net/boinc – this will install several dependencies, including Perl. In the 'make config' screens for those, I generally disable docs & examples, X11, NLS (for now), and IPv6 (for now). When installing Perl, I chose to disable 64bit_int because it says "on i386".
  • echo boinc_client_enable="YES" >> /etc/rc.conf
  • service boinc-client start — there's a bug in the port; it writes the wrong pid to the pidfile, so subsequent 'service' commands will fail
  • Create account on the BOINC project page you're interested in
  • Go to your account info on that page and click on Account Keys
  • Create ~boinc/account_whatever.xml as instructed. Put the account key (not weak key) in a file, e.g. ~boinc/whatever.key.
  • boinccmd --project_attach http://moowrap.net/ `cat ~boinc/whatever.key`
  • tail -f ~boinc/stdoutdae.txt — this is the log

Blast! Look what comes up in the log: This project doesn't support computers of type armv6-pc-freebsd

None of the projects I tried (Moo!, SETI@Home, Enigma@Home) are supported. So I went ahead and commented out the boinc_client_enable line in /etc/rc.conf and manually killed the boinc-client process.