Difference between revisions of "User:Mjb/FreeBSD on BeagleBone Black"

From Offset
Jump to navigationJump to search
(Install MySQL)
(Fetch system source code)
Line 505: Line 505:
 
==Fetch system source code==
 
==Fetch system source code==
  
Since I installed FreeBSD from a snapshot, it doesn't include <code>/usr/src</code>. It's handy to have the base system source code, though, because you need it in order to apply security patches and rebuild components as needed.
+
Since I installed FreeBSD from a snapshot, it doesn't include /usr/src</code>, the usual home of the base system sources and docs. It's handy to at least have the base system source code, though, because you need it in order to apply security patches and to rebuild components.
  
Obtaining the code for the first time:
+
Obtaining the code for the first time (probably clobbers any existing /usr/src content):
* <code>mkdir /usr/src</code> (I'm not sure this is strictly necessary)
+
* <code>env TMPDIR=/var/tmp svnlite checkout https://svn.freebsd.org/base/stable/10 /usr/src</code>
* <code>svnlite checkout https://svn.freebsd.org/base/stable/10</code> (this is for 10-STABLE, of course)
+
 
 +
This URL is for 10-STABLE, of course.
 +
 
 +
The reason for setting TMPDIR to /var/tmp is because svnlite defaults to using /tmp, which on the snapshots for the BeagleBone is configured (in <code>/etc/fstab</code>) to use a memory file system of only 30 MB, too small to support a checkout of the base system.

Revision as of 08:41, 18 September 2015

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. They said 10.2-STABLE should be usable in the next snapshot. I put it off until September and used the Sep. 3rd snapshot of 10.2, which worked fine.
  1. Uncompress it (e.g., with 7-Zip).
  2. 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.
  3. With power off, insert the micro SD card in the BBB.
  4. Attach the LAN cable.
  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. (The procedure is to boot into the built-in drive and rename the MLO file. Thereafter, the firmware will boot from the SD card. I don't know how to get back into the built-in drive, though.)

This is what I got the first time I booted 10.2-STABLE:

U-Boot SPL 2014.10 (Sep 04 2015 - 06:57:44)
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 (Sep 04 2015 - 06:57:44)

       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
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
252090 bytes read in 18 ms (13.4 MiB/s)
## Starting application at 0x88000054 ...
Consoles: U-Boot console
Compatible U-Boot API signature found @9e731510

FreeBSD/armv6 U-Boot loader, Revision 1.2
(root@releng1.nyi.freebsd.org, Fri Sep  4 07:06:47 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=0x5942cc+0x2fd34 syms=[0x4+0x6ec20+0x4+0x58920]

Hit [Enter] to boot immediately, or any other key for command prompt.
Booting [/boot/kernel/kernel]...
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 10.2-STABLE #0 r287435: Fri Sep  4 07:10:27 UTC 2015
    root@releng1.nyi.freebsd.org:/usr/obj/arm.armv6/usr/src/sys/BEAGLEBONE arm
FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
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 = 515833856 (491 MB)
Texas Instruments AM335x Processor, Revision ES1.2
random device not loaded; using insecure entropy
random: <Software, Yarrow> initialized
ofwbus0: <Open Firmware Device Tree>
simplebus0: <Flattened device tree simple bus> on ofwbus0
aintc0: <TI AINTC Interrupt Controller> mem 0x48200000-0x48200fff on simplebus0
aintc0: Revision 5.0
ti_scm0: <TI Control Module> mem 0x44e10000-0x44e11fff on simplebus0
am335x_prcm0: <AM335x Power and Clock Management> mem 0x44e00000-0x44e012ff on simplebus0
am335x_prcm0: Clocks: System 24.0 MHz, CPU 1000 MHz
am335x_dmtimer0: <AM335x DMTimer> mem 0x44e05000-0x44e05fff,0x44e31000-0x44e31fff,0x48040000-0x48040fff,0x48042000-0x48042fff,0x48044000-0x48044fff,0x48046000-0x48046fff,0x48048000-0x48048fff,0x4804a000-0x4804afff irq 66,67,68,69,92,93,94,95 on simplebus0
am335x_dmtimer0: No DMTimer found with capture pin configured as input; PPS driver disabled.
Timecounter "AM335x Timecounter" frequency 24000000 Hz quality 1000
Event timer "AM335x Eventtimer" frequency 24000000 Hz quality 1000
am335x_rtc0: <AM335x RTC (power management mode)> mem 0x44e3e000-0x44e3efff irq 75,76 on simplebus0
am335x_rtc0: AM335X RTC v1.0.6
ti_adc0: <TI ADC controller> mem 0x44e0d000-0x44e0efff irq 16 on simplebus0
ti_adc0: scheme: 0x1 func: 0x730 rtl: 0 rev: 0.1 custom rev: 0
ti_wdt0: <TI Watchdog Timer> mem 0x44e35000-0x44e35fff irq 91 on simplebus0
gpio0: <TI General Purpose I/O (GPIO)> mem 0x44e07000-0x44e07fff,0x4804c000-0x4804cfff,0x481ac000-0x481acfff,0x481ae000-0x481aefff irq 96,97,98,99,32,33,62,63 on simplebus0
gpioc0: <GPIO controller> on gpio0
gpiobus0: <OFW GPIO bus> on gpio0
gpioled0: <GPIO led> at pin(s) 53 on gpiobus0
gpioled1: <GPIO led> at pin(s) 54 on gpiobus0
gpioled2: <GPIO led> at pin(s) 55 on gpiobus0
gpioled3: <GPIO led> at pin(s) 56 on gpiobus0
uart0: <TI UART (16550 compatible)> mem 0x44e09000-0x44e09fff irq 72 on simplebus0
uart0: console (115384,n,8,1)
ti_edma30: <TI EDMA Controller> mem 0x49000000-0x490fffff,0x49800000-0x498fffff,0x49900000-0x499fffff,0x49a00000-0x49afffff irq 12,13,14 on simplebus0
ti_edma30: EDMA revision 40014c00
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
cpsw0: <3-port Switch Ethernet Subsystem> mem 0x4a100000-0x4a103fff irq 40,41,42,43 on simplebus0
cpsw0: CPSW SS Version 1.12 (0)
cpsw0: Initial queue size TX=128 RX=384
miibus0: <MII bus> on cpsw0
smscphy0: <SMC LAN8710A 10/100 interface> PHY 0 on miibus0
smscphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
cpsw0: Ethernet address: 84:eb:18:e2:8e:56
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 0x48 on iicbus0
iichb1: <TI I2C Controller> mem 0x4802a000-0x4802afff irq 71 on simplebus0
iichb1: I2C revision 4.0 FIFO size: 32 bytes
iicbus1: <OFW I2C bus> on iichb1
iic1: <I2C generic I/O> on iicbus1
iichb2: <TI I2C Controller> mem 0x4819c000-0x4819cfff irq 30 on simplebus0
iichb2: I2C revision 4.0 FIFO size: 32 bytes
iicbus2: <OFW I2C bus> on iichb2
iic2: <I2C generic I/O> on iicbus2
am335x_pwm0: <AM335x PWM> mem 0x48300000-0x483000ff,0x48300100-0x4830017f,0x48300180-0x483001ff,0x48300200-0x4830025f irq 86,58 on simplebus0
am335x_pwm1: <AM335x PWM> mem 0x48302000-0x483020ff,0x48302100-0x4830217f,0x48302180-0x483021ff,0x48302200-0x4830225f irq 87,59 on simplebus0
am335x_pwm2: <AM335x PWM> mem 0x48304000-0x483040ff,0x48304100-0x4830417f,0x48304180-0x483041ff,0x48304200-0x4830425f irq 88,60 on simplebus0
musbotg0: <TI AM33xx integrated USB OTG controller> mem 0x47400000-0x47400fff,0x47401000-0x474012ff,0x47401300-0x474013ff,0x47401400-0x474017ff,0x47401800-0x47401aff,0x47401b00-0x47401bff,0x47401c00-0x47401fff irq 17,18,19 on simplebus0
musbotg0: TI AM335X USBSS v0.0.13
usbus0: Dynamic FIFO sizing detected, assuming 16Kbytes of FIFO RAM
usbus0 on musbotg0
usbus1: Dynamic FIFO sizing detected, assuming 16Kbytes of FIFO RAM
usbus1 on musbotg0
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
uugen1.1: <Mentor Graphics> at usbus1
uhub0: <Mentor Graphics OTG Root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus1
gen0.1: <Mentor Graphics> at usbus0
uhub1: <Mentor Graphics OTG Root HUB, class 9/0, rev 2.00/1.00, addr 1> on usbus0
mmcsd0: 64GB <SDHC 00000 1.0 SN 0A1806A0 MFG 02/2015 by 27 SM> at mmc0 48.0MHz/4bit/65535-block
uhub1: 1 port with 1 removable, self powered
uhub0: 1 port with 1 removable, self powered
mmc1: CMD6 failed, RESULT: 1
mmcsd1: 4GB <MMCHC S10004 0.8 SN 34D2DDBF MFG 02/1999 by 112 0x0000> at mmc1 48.0MHz/8bit/65535-block
am335x_pmic0: TPS65217C ver 1.2 powered by AC
random: unblocking device.
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:
 979136, 1223872, 1468608, 1713344, 1958080, 2202816, 2447552, 2692288,
 2937024, 3181760, 3426496, 3671232, 3915968, 4160704, 4405440, 4650176,
 4894912, 5139648, 5384384, 5629120, 5873856, 6118592, 6363328, 6608064,
 6852800, 7097536, 7342272, 7587008, 7831744, 8076480, 8321216, 8565952,
 8810688, 9055424, 9300160, 9544896, 9789632, 10034368, 10279104, 10523840,
 10768576, 11013312, 11258048, 11502784, 11747520, 11992256, 12236992,
 12481728, 12726464, 12971200, 13215936, 13460672, 13705408, 13950144,
 14194880, 14439616, 14684352, 14929088, 15173824, 15418560, 15663296,
 15908032, 16152768, 16397504, 16642240, 16886976, 17131712, 17376448,
 17621184, 17865920, 18110656, 18355392, 18600128, 18844864, 19089600,
 19334336, 19579072, 19823808, 20068544, 20313280, 20558016, 20802752,
 21047488, 21292224, 21536960, 21781696, 22026432, 22271168, 22515904,
 22760640, 23005376, 23250112, 23494848, 23739584, 23984320, 24229056,
 24473792, 24718528, 24963264, 25208000, 25452736, 25697472, 25942208,
 26186944, 26431680, 26676416, 26921152, 27165888, 27410624, 27655360,
 27900096, 28144832, 28389568, 28634304, 28879040, 29123776, 29368512,
 29613248, 29857984, 30102720, 30347456, 30592192, 30836928, 31081664,
 31326400, 31571136, 31815872, 32060608, 32305344, 32550080, 32794816,
 33039552, 33284288, 33529024, 33773760, 34018496, 34263232, 34507968,
 34752704, 34997440, 35242176, 35486912, 35731648, 35976384, 36221120,
 36465856, 36710592, 36955328, 37200064, 37444800, 37689536, 37934272,
 38179008, 38423744, 38668480, 38913216, 39157952, 39402688, 39647424,
 39892160, 40136896, 40381632, 40626368, 40871104, 41115840, 41360576,
 41605312, 41850048, 42094784, 42339520, 42584256, 42828992, 43073728,
 43318464, 43563200, 43807936, 44052672, 44297408, 44542144, 44786880,
 45031616, 45276352, 45521088, 45765824, 46010560, 46255296, 46500032,
 46744768, 46989504, 47234240, 47478976, 47723712, 47968448, 48213184,
 48457920, 48702656, 48947392, 49192128, 49436864, 49681600, 49926336,
 50171072, 50415808, 50660544, 50905280, 51150016, 51394752, 51639488,
 51884224, 52128960, 52373696, 52618432, 52863168, 53107904, 53352640,
 53597376, 53842112, 54086848, 54331584, 54576320, 54821056, 55065792,
 55310528, 55555264, 55800000, 56044736, 56289472, 56534208, 56778944,
 57023680, 57268416, 57513152, 57757888, 58002624, 58247360, 58492096,
 58736832, 58981568, 59226304, 59471040, 59715776, 59960512, 60205248,
 60449984, 60694720, 60939456, 61184192, 61428928, 61673664, 61918400,
 62163136, 62407872, 62652608, 62897344, 63142080, 63386816, 63631552,
 63876288, 64121024, 64365760, 64610496, 64855232, 65099968, 65344704,
 65589440, 65834176, 66078912, 66323648, 66568384, 66813120, 67057856,
 67302592, 67547328, 67792064, 68036800, 68281536, 68526272, 68771008,
 69015744, 69260480, 69505216, 69749952, 69994688, 70239424, 70484160,
 70728896, 70973632, 71218368, 71463104, 71707840, 71952576, 72197312,
 72442048, 72686784, 72931520, 73176256, 73420992, 73665728, 73910464,
 74155200, 74399936, 74644672, 74889408, 75134144, 75378880, 75623616,
 75868352, 76113088, 76357824, 76602560, 76847296, 77092032, 77336768,
 77581504, 77826240, 78070976, 78315712, 78560448, 78805184, 79049920,
 79294656, 79539392, 79784128, 80028864, 80273600, 80518336, 80763072,
 81007808, 81252544, 81497280, 81742016, 81986752, 82231488, 82476224,
 82720960, 82965696, 83210432, 83455168, 83699904, 83944640, 84189376,
 84434112, 84678848, 84923584, 85168320, 85413056, 85657792, 85902528,
 86147264, 86392000, 86636736, 86881472, 87126208, 87370944, 87615680,
 87860416, 88105152, 88349888, 88594624, 88839360, 89084096, 89328832,
 89573568, 89818304, 90063040, 90307776, 90552512, 90797248, 91041984,
 91286720, 91531456, 91776192, 92020928, 92265664, 92510400, 92755136,
 92999872, 93244608, 93489344, 93734080, 93978816, 94223552, 94468288,
 94713024, 94957760, 95202496, 95447232, 95691968, 95936704, 96181440,
 96426176, 96670912, 96915648, 97160384, 97405120, 97649856, 97894592,
 98139328, 98384064, 98628800, 98873536, 99118272, 99363008, 99607744,
 99852480, 100097216, 100341952, 100586688, 100831424, 101076160, 101320896,
 101565632, 101810368, 102055104, 102299840, 102544576, 102789312, 103034048,
 103278784, 103523520, 103768256, 104012992, 104257728, 104502464, 104747200,
 104991936, 105236672, 105481408, 105726144, 105970880, 106215616, 106460352,
 106705088, 106949824, 107194560, 107439296, 107684032, 107928768, 108173504,
 108418240, 108662976, 108907712, 109152448, 109397184, 109641920, 109886656,
 110131392, 110376128, 110620864, 110865600, 111110336, 111355072, 111599808,
 111844544, 112089280, 112334016, 112578752, 112823488, 113068224, 113312960,
 113557696, 113802432, 114047168, 114291904, 114536640, 114781376, 115026112,
 115270848, 115515584, 115760320, 116005056, 116249792, 116494528, 116739264,
 116984000, 117228736, 117473472, 117718208, 117962944, 118207680, 118452416,
 118697152, 118941888, 119186624, 119431360, 119676096, 119920832, 120165568,
 120410304, 120655040, 120899776, 121144512, 121389248, 121633984, 121878720,
 122123456, 122368192, 122612928, 122857664, 123102400, 123347136, 123591872,
 123836608, 124081344, 124326080, 124570816, 124815552

There was a very long delay at this point, over 5 minutes! But then it continued...

Setting hostuuid: 5ea8c19a-52d6-11e5-b87f-84eb18e28e56.
Setting hostid: 0x835fb287.
Entropy harvesting: interrupts ethernet point_to_point swi.
Starting file system checks:
/dev/ufs/rootfs: FILE SYSTEM CLEAN; SKIPPING CHECKS
/dev/ufs/rootfs: clean, 15022057 free (297 frags, 1877720 blocks, 0.0% fragmentation)
Mounting local file systems:.
Writing entropy file:.
Setting hostname: beaglebone.
cpsw0: link state changed to UP
Starting Network: lo0 cpsw0.
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 0x2
        inet 127.0.0.1 netmask 0xff000000
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
cpsw0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=8000b<RXCSUM,TXCSUM,VLAN_MTU,LINKSTATE>
        ether 84:eb:18:e2:8e:56
        media: Ethernet autoselect (100baseTX <full-duplex>)
        status: active
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
Starting devd.
Starting dhclient.
DHCPDISCOVER on cpsw0 to 255.255.255.255 port 67 interval 4
DHCPOFFER from 10.0.1.1
DHCPREQUEST on cpsw0 to 255.255.255.255 port 67
DHCPACK from 10.0.1.1
bound to 10.0.1.12 -- renewal in 43200 seconds.
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.
ELF ldconfig path: /lib /usr/lib /usr/lib/compat
Clearing /tmp (X related).
Updating motd:.
Mounting late file systems:.
Generating RSA1 host key.
2048 f1:53:3e:f9:74:fb:bb:08:14:d6:57:94:4e:aa:36:ae  root@beaglebone (RSA1)
Generating RSA host key.
2048 47:21:62:69:62:1f:df:ed:ec:6f:e8:7b:85:d1:6b:09  root@beaglebone (RSA)
Generating DSA host key.
1024 fb:4e:ce:a7:bc:13:ca:4d:70:ca:c8:c4:67:89:fe:bb  root@beaglebone (DSA)
Generating ECDSA host key.
256 ea:7c:5d:06:ae:c8:cc:03:09:4d:50:3c:54:f2:d4:a5  root@beaglebone (ECDSA)
Generating ED25519 host key.
256 18:25:25:36:1e:5c:c6:cc:a3:58:84:6a:cd:d2:17:db  root@beaglebone (ED25519)
Performing sanity check on sshd configuration.
Starting sshd.
Starting cron.
Starting background file system checks in 60 seconds.

Fri Sep  4 07:27:53 UTC 2015

FreeBSD/arm (beaglebone) (ttyu0)

login:

The default username and password are root and root.

Networking

You won't be able to do much else if you're not connected to the Internet. The network interface needs to be up and you need to be able to reach remote hosts on the Internet.

DHCP

DHCP is enabled by default (/etc/rc.conf contains ifconfig_DEFAULT="DHCP") so it should just work if you boot while connected (by Ethernet cable) to a DHCP-enabled router.

The boot log of my July attempt to run 10.x 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 BeagleBone's 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. It also worked after I installed the September 3 snapshot of 10.2.

/etc/resolv.conf will be automatically rewritten by dhclient as needed, so if you have some preferred nameservers, you need to put that into /etc/dhclient.conf. See [User:Mjb/FreeBSD#Enable a caching DNS server] for details.

Unbound

Unbound is the BIND replacement in FreeBSD 10 and up. It is a caching nameserver that you can enable, but don't do this yet:

  • Add local_unbound_enable="YES" to /etc/rc.conf
  • service local_unbound start

The first time you start local_unbound, it runs resolvconf -u.

Some useful commands:

  • resolvconf -u – regenerate config files in /var/unbound and update /etc/resolv.conf as needed.
  • service local_unbound reload – pick up any changes made to the config files.
  • host freebsd.org – see if freebsd.org resolves
  • host -v freebsd.org – see if freebsd.org resolves (more detailed; shows what IP address was queried)

I'm still trying to figure it out. There are problems that make it impractical to run Unbound at this time:

I saw a note that Unbound must not be started until the system clock is correctly set. This is going to be a problem! As one commenter pointed out, there's a circular dependency: You need DNS to be working in order to set the clock via NTP, but Unbound will ignore info it gets from upstream DNS servers because it thinks those servers are giving it bogus DNSSEC responses from far in the future.

Also, Unbound requires that any upstream resolvers it talks to are DNSSEC-capable. Because of this, I am having trouble my DHCP-supplied resolver, which is an Apple AirPort Time Capsule. It apparently does not support DNSSEC, so I get SERVFAIL responses when using Unbound with the router's IP address as the forwarder(s) in /etc/unbound/forward.conf (as generated by resolvconf).

Initial time set

Login as root (pw: root). The clock will be totally wrong because the BeagleBone Black has no clock battery. So, assuming you have Internet access, you can (on this first boot) run ntpdate to set the clock. Also symlink the appropriate timezone file to /etc/localtime:

  • ntpdate pool.ntp.org
  • ln -s /usr/share/zoneinfo/MST7MDT /etc/localtime

Now check the date and time and make sure it's right:

  • date

FreeBSD's stock ntpd is not set up to run automatically, and I prefer OpenNTPD, so the ports collection has to be installed.

After installing OpenNTPD, it will not be necessary to set the clock unless networking is not available at boot time. I haven't figured out what to do in that situation.

Customize .cshrc & .login

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

Don't install pkg

If you try to run pkg, it will install an old version. The better option is to install the ports collection, then install portmaster (see next section). It will install pkg from the ports collection.

Install the ports collection

This will take forever.

  • portsnap fetch extract

If you are using FreeBSD-CURRENT, 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...
[huge list of ports folders trimmed]
Building new INDEX files... done.

Install portmaster

  • cd /usr/ports/ports-mgmt/portmaster
  • make install

At this point it probably tells you to switch to the new pkg format:

  • echo WITH_PKGNG=yes >> /etc/make.conf

make.conf might not exist, so you might have to change the >> to just one >.

This is probably needed if you're using tcsh:

  • rehash

Now set up pkg; it only takes a second since nothing else is installed:

  • pkg2ng

Set build options in /etc/make.conf

Settings in make.conf affect everything built with make, including software in the ports collection. The make.conf(5) manual page explains some of the options available for building kernel and world, but you can also include anything specific to ports, such as to provide default answers to things you would set in the 'make configure' stage. See the ports(7) man page and /usr/ports/Mk/bsd.options.desc.mk for common options (minus the WITH_ or WITHOUT_ prefix, in the latter). Unfortunately, many other options are buried in the individual port Makefiles, not documented anywhere.

## 'make buildworld' options:

# when building top(1), only allocate enough space it to handle 151 users, rather than 10000
TOP_TABLE_SIZE=151

## ports building options:

# I am using the new package system (required now)
WITH_PKGNG=yes

# my non-Intel CPU (armv6) does not support SSE or MMX
WITHOUT_MMX=yes
WITHOUT_SSE=yes

# support IPv6 and HTTPS
WITH_HTTPS=yes
WITH_IPV6=yes

# don't build or install GUIs, including X11 libraries
WITHOUT_GUI=yes
WITHOUT_X11=yes
OPTIONS_UNSET=X11

# don't waste time on tests when building ImageMagick
WITHOUT_IMAGEMAGICK_TESTS=yes

# when building FreeType, enable subpixel rendering capability (disabled by default due to patent issues)
WITH_LCD_FILTERING=yes

Install nano

  • portmaster editors/nano

Install OpenNTPD

See instructions at User:Mjb/FreeBSD#OpenNTPD.

As mentioned above, what do I do if networking is not available at boot time? And does the clock reset only when power is cut? (in which case not having networking after a soft boot would not be a problem)

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
  • cp /usr/local/etc/mail/smtpd.conf.sample /usr/local/etc/mail/smtpd.conf

Edit smtpd.conf to your liking, and then:

  • service smtpd start

Starting the service may fail 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. getaddrinfo() is 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. However, it seems to work after you add beaglebone as another 127.0.0.1 and ::1 hostname in /etc/hosts. You should do this anyway because /etc/rc.conf says hostname="beaglebone" and you want this name to resolve.

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.

Distributed computing projects

TL;DR: none of the projects supported by BOINC have native support for armv6 processors. This includes my longtime favorite, distributed.net. So it's not an option to run these on the BeagleBone Black right now.

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.

I later filed a freebsd-armv6 client port request at distributed.net.

Install MySQL

Ensure the ports collection is up-to-date. There was a fix on 2015-09-15 which affects the ability to build the MySQL ports, among others.

  • portmaster databases/mysql56-server

This will install mysql56-client, cmake, perl, and libedit. cmake has many dependencies, including Python (py-sphinx), curl, expat, jsoncpp, libarchive. Depending on whether you've got Perl and Python already (and up-to-date), this will take roughly 3 to 6 hours.

  • Create /var/db/mysql/my.cnf and put the following in it so that when you start the MySQL server, it's only accessible from localhost:
    [mysqld]

bind-address=127.0.0.1

Fetch system source code

Since I installed FreeBSD from a snapshot, it doesn't include /usr/src, the usual home of the base system sources and docs. It's handy to at least have the base system source code, though, because you need it in order to apply security patches and to rebuild components.

Obtaining the code for the first time (probably clobbers any existing /usr/src content):

This URL is for 10-STABLE, of course.

The reason for setting TMPDIR to /var/tmp is because svnlite defaults to using /tmp, which on the snapshots for the BeagleBone is configured (in /etc/fstab) to use a memory file system of only 30 MB, too small to support a checkout of the base system.