OpenBSD on APU4

Today I got an APU.4B4

This is how I got OpenBSD installed on it.

0. Re-install

If there already is an OpenBSD running on the device, there is a shorter path
to do a re-install:

- Download a bsd.rd,
- Place it in the device's root file system,
- Connect a serial console (see below),
- Reboot
- In the boot prompt, type

  boot bsd.rd

Answer "yes" to change the default boot console.
Then continue at step 4. "Installation" below.

If there is no OpenBSD on the device yet, follow these steps:

1. Serial Console

Plug a USB-to-serial converter (Sub-D9 analog, not TTL) converter to my laptop,
plug a Null-modem cable from converter to APU.

  $ screen /dev/ttyUSB0 115200

Powering on the APU should then show something like

  PC Engines apu4
  coreboot build 20171130
  BIOS version v4.6.4
  4080 MB ECC DRAM

  SeaBIOS (version rel-1.11.0.1-0-g90da88d)

  Press F10 key now for boot menu

(There is a TTL Serial on the board at COM2 at J4, pin2=Tx,3=Rx,4=GND, but the
boot does not come up there.)

2. Installation medium

Write an install fs to a USB stick, from OpenBSD's Download page:

(on my debian laptop:)

  $ wget https://cdn.openbsd.org/pub/OpenBSD/6.3/amd64/install63.fs
  $ wget https://cdn.openbsd.org/pub/OpenBSD/6.3/amd64/SHA256.sig
  $ sudo apt-get install signify-openbsd signify-openbsd-keys
  $ signify-openbsd -Cp /usr/share/signify-openbsd-keys/openbsd-63-base.pub -x SHA256.sig install63.fs
  Signature Verified
  install63.fs: OK

  $ sudo dd if=install63.fs of=/dev/sdX bs=1M
  360+1 records in
  360+1 records out
  377978880 bytes (378 MB, 360 MiB) copied, 52.8627 s, 7.2 MB/s

(I have an mSATA hard disk in the APU, but no mSATA adapter towards my laptop
that would allow me to install a system ahead of time.)

3. Boot from the USB stick

Plug:

- the Serial cable
- the USB stick
- ethernet cable to the first ethernet port (closest to the serial)

and power up the APU. In the serial console, hit F10 to enter the boot menu.
Pick the USB stick:

  Press F10 key now for boot menu

  Select boot device:

  1. USB MSC Drive OCZ RALLY2 0.00
  2. ata0-0: Samsung SSD 860 EVO mSATA 250GB ATA-11 Hard-Disk (232 GiBytes)
  3. Payload [memtest]
  4. Payload [setup]

  <1>

  Booting from Hard Disk...
  Using drive 0, partition 3.
  Loading......
  probing: pc0 com0 com1 com2 com3 mem[639K 3326M 752M a20=on]
  disk: hd0+ hd1+*
  >> OpenBSD/amd64 BOOT 3.34
  boot> help

At this point I type 'help' to prevent automatic booting and give me some time
to set up the TTY.

By default, OpenBSD boots on the VGA device, and since there is none on the
APU, it will just fail and reboot. Hence setup the boot TTY. Set the correct
baud rate for the APU and then switch to com0:

  boot> stty com0 115200
  boot> set tty com0
  switching console to com>> OpenBSD/amd64 BOOT 3.34
  boot>

Now just hit enter and it should boot.

  0
  cannot open hd0a:/etc/random.seed: No such file or directory
  booting hd0a:/6.3/amd64/bsd.rd: 3418091+1467392+3891704+0+598016 [363465+90+433440+288010]=0x9fc160
  entry point at 0x1000158
  Copyright (c) 1982, 1986, 1989, 1991, 1993
          The Regents of the University of California.  All rights reserved.
  Copyright (c) 1995-2018 OpenBSD. All rights reserved.  https://www.OpenBSD.org

  OpenBSD 6.3 (RAMDISK_CD) #98: Sat Mar 24 14:26:39 MDT 2018
      deraadt@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/RAMDISK_CD
  real mem = 4261007360 (4063MB)
  avail mem = 4128083968 (3936MB)
  mainbus0 at root
  bios0 at mainbus0: SMBIOS rev. 2.7 @ 0xcff9e020 (7 entries)
  bios0: vendor coreboot version "v4.6.4" date 20171130
  bios0: PC Engines PC Engines apu4
  acpi0 at bios0: rev 2
  acpi0: tables DSDT FACP SSDT TCPA APIC HEST SSDT SSDT HPET
  acpimadt0 at acpi0 addr 0xfee00000: PC-AT compat
  cpu0 at mainbus0: apid 0 (boot processor)
  cpu0: AMD GX-412TC SOC, 998.24 MHz
  cpu0: FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,PCLMUL,MWAIT,SSSE3,CX16,SSE4.1,SSE4.2,MOVBE,POPCNT,AES,XSAVE,AVX,F16C,NXE,MMXX,FFXSR,PAGE1GB,RDTSCP,LONG,LAHF,CMPLEG,SVM,EAPICSP,AMCR8,ABM,SSE4A,MASSE,3DNOWP,OSVW,IBS,SKINIT,TOPEXT,DBKP,PERFTSC,PCTRL3,ITSC,BMI1
  cpu0: 32KB 64b/line 2-way I-cache, 32KB 64b/line 8-way D-cache, 2MB 64b/line 16-way L2 cache
  cpu0: ITLB 32 4KB entries fully associative, 8 4MB entries fully associative
  cpu0: DTLB 40 4KB entries fully associative, 8 4MB entries fully associative
  cpu0: apic clock running at 99MHz
  cpu0: mwait min=64, max=64, IBE
  cpu at mainbus0: not configured
  cpu at mainbus0: not configured
  cpu at mainbus0: not configured
  ioapic0 at mainbus0: apid 4 pa 0xfec00000, version 21, 24 pins
  ioapic1 at mainbus0: apid 5 pa 0xfec20000, version 21, 32 pins
  , remapped to apid 5
  acpiprt0 at acpi0: bus 0 (PCI0)
  acpiprt1 at acpi0: bus 1 (PBR4)
  acpiprt2 at acpi0: bus 2 (PBR5)
  acpiprt3 at acpi0: bus 3 (PBR6)
  acpiprt4 at acpi0: bus 4 (PBR7)
  acpiprt5 at acpi0: bus -1 (PBR8)
  acpicpu at acpi0 not configured
  "PNP0C0C" at acpi0 not configured
  "BOOT0000" at acpi0 not configured
  pci0 at mainbus0 bus 0
  pchb0 at pci0 dev 0 function 0 "AMD AMD64 16h Root Complex" rev 0x00
  pchb1 at pci0 dev 2 function 0 "AMD AMD64 16h Host" rev 0x00
  ppb0 at pci0 dev 2 function 1 "AMD AMD64 16h PCIE" rev 0x00: msi
  pci1 at ppb0 bus 1
  em0 at pci1 dev 0 function 0 "Intel I211" rev 0x03: msi, address 00:0d:b9:4a:dc:20
  ppb1 at pci0 dev 2 function 2 "AMD AMD64 16h PCIE" rev 0x00: msi
  pci2 at ppb1 bus 2
  em1 at pci2 dev 0 function 0 "Intel I211" rev 0x03: msi, address 00:0d:b9:4a:dc:21
  ppb2 at pci0 dev 2 function 3 "AMD AMD64 16h PCIE" rev 0x00: msi
  pci3 at ppb2 bus 3
  em2 at pci3 dev 0 function 0 "Intel I211" rev 0x03: msi, address 00:0d:b9:4a:dc:22
  ppb3 at pci0 dev 2 function 4 "AMD AMD64 16h PCIE" rev 0x00: msi
  pci4 at ppb3 bus 4
  em3 at pci4 dev 0 function 0 "Intel I211" rev 0x03: msi, address 00:0d:b9:4a:dc:23
  "AMD CCP" rev 0x00 at pci0 dev 8 function 0 not configured
  xhci0 at pci0 dev 16 function 0 "AMD Bolton xHCI" rev 0x11: msi
  usb0 at xhci0: USB revision 3.0
  uhub0 at usb0 configuration 1 interface 0 "AMD xHCI root hub" rev 3.00/1.00 addr 1
  ahci0 at pci0 dev 17 function 0 "AMD Hudson-2 SATA" rev 0x39: msi, AHCI 1.3
  ahci0: port 0: 6.0Gb/s
  scsibus0 at ahci0: 32 targets
  sd0 at scsibus0 targ 0 lun 0:  SCSI3 0/direct fixed naa.5002538e402f3b91
  sd0: 238475MB, 512 bytes/sector, 488397168 sectors, thin
  ehci0 at pci0 dev 19 function 0 "AMD Hudson-2 USB2" rev 0x39: apic 4 int 18
  usb1 at ehci0: USB revision 2.0
  uhub1 at usb1 configuration 1 interface 0 "AMD EHCI root hub" rev 2.00/1.00 addr 1
  "AMD Hudson-2 SMBus" rev 0x42 at pci0 dev 20 function 0 not configured
  "AMD Hudson-2 LPC" rev 0x11 at pci0 dev 20 function 3 not configured
  sdhc0 at pci0 dev 20 function 7 "AMD Bolton SD/MMC" rev 0x01: apic 4 int 16
  sdhc0: SDHC 2.0, 63 MHz base clock
  sdmmc0 at sdhc0: 4-bit, sd high-speed, mmc high-speed, dma
  pchb2 at pci0 dev 24 function 0 "AMD AMD64 16h Link Cfg" rev 0x00
  pchb3 at pci0 dev 24 function 1 "AMD AMD64 16h Address Map" rev 0x00
  pchb4 at pci0 dev 24 function 2 "AMD AMD64 16h DRAM Cfg" rev 0x00
  pchb5 at pci0 dev 24 function 3 "AMD AMD64 16h Misc Cfg" rev 0x00
  pchb6 at pci0 dev 24 function 4 "AMD AMD64 16h CPU Power" rev 0x00
  pchb7 at pci0 dev 24 function 5 "AMD AMD64 16h Misc Cfg" rev 0x00
  isa0 at mainbus0
  com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
  com0: console
  com1 at isa0 port 0x2f8/8 irq 3: ns16550a, 16 byte fifo
  com2 at isa0 port 0x3e8/8 irq 5: ns16550a, 16 byte fifo
  umass0 at uhub0 port 4 configuration 1 interface 0 "ITE Technology USB Mass Storage Device" rev 2.00/1.00 addr 2
  umass0: using SCSI over Bulk-Only
  scsibus1 at umass0: 2 targets, initiator 0
  sd1 at scsibus1 targ 1 lun 0:  SCSI2 0/direct removable serial.048d1167000000000210
  sd1: 3853MB, 512 bytes/sector, 7892040 sectors
  uhub2 at uhub1 port 1 configuration 1 interface 0 "vendor 0x0438 product 0x7900" rev 2.00/0.18 addr 2
  softraid0 at root
  scsibus2 at softraid0: 256 targets
  root on rd0a swap on rd0b dump on rd0b
  erase ^?, werase ^W, kill ^U, intr ^C, status ^T

  Welcome to the OpenBSD/amd64 6.3 installation program.
  (I)nstall, (U)pgrade, (A)utoinstall or (S)hell?

Hit i to install.

4. Installation

Hit enter except for the various points listed below.

  System hostname? myhostname

Upon DHCP, for convenience note the IP address given:

  em0: bound to 192.168.0.11 from 192.168.0.1 (dc:53:12:34:56:78)

Users:

  Password for root account?
  Setup a user? myusername
  Password for user myusername?

I have an SSD mSATA in it, so I choose

  Which disk is the root disk? sd0
  Use (W)hole disk MBR, whole disk (G)PT, (O)penBSD area or (E)dit? w
  Use (A)uto layout, (E)dit auto layout, or create (C)ustom layout? c

I don't want a /tmp mountpoint: I am planning to have a ramdisk instead of
trashing the SSD with /tmp writes.

I don't want a /usr/X11R6 mountpoint: no graphics hence no X server.

In the end my layout looks like:

  > p g
  OpenBSD area: 64-488392065; size: 232.9G; free: 0.0G
  #                size           offset  fstype [fsize bsize   cpg]
    a:             1.0G               64  4.2BSD   2048 16384     1 # /
    b:             4.2G          2097216    swap
    c:           232.9G                0  unused
    d:            12.0G         10943808  4.2BSD   2048 16384     1 # /var
    e:             2.0G         36114112  4.2BSD   2048 16384     1 # /usr
    f:            10.0G         40307072  4.2BSD   2048 16384     1 # /usr/local
    g:             2.0G         61271904  4.2BSD   2048 16384     1 # /usr/src
    h:           195.0G         65464896  4.2BSD   4096 32768     1 # /home
    i:             6.7G        474399424  4.2BSD   2048 16384     1 # /usr/obj

Then

  > w
  > x

Hit enter until

  HTTP Server?

Pick one from https://www.openbsd.org/ftp.html -- since I am in Berlin, I
entered:

  HTTP Server? ftp.spline.de

And deselect the X-server and games sets:

  Set name(s)? -x*
  Set name(s)? -game*
      [X] bsd           [X] base63.tgz    [ ] game63.tgz    [ ] xfont63.tgz
      [X] bsd.mp        [X] comp63.tgz    [ ] xbase63.tgz   [ ] xserv63.tgz
      [X] bsd.rd        [X] man63.tgz     [ ] xshare63.tgz

Some download is going on ... then:

  What timezone are you in? ('?' for list) [Canada/Mountain] Europe
  What sub-timezone of 'Europe' are you in? ('?' for list) Berlin

To add the temp-fs for /tmp, first look at the current fstab:

  Exit to (S)hell, (H)alt or (R)eboot? [reboot] s
  # cd mnt/etc
  # cat fstab
  585e0fccb0738bda.b none swap sw
  585e0fccb0738bda.a / ffs rw 1 1
  585e0fccb0738bda.h /home ffs rw,nodev,nosuid 1 2
  585e0fccb0738bda.e /usr ffs rw,nodev 1 2
  585e0fccb0738bda.f /usr/local ffs rw,wxallowed,nodev 1 2
  585e0fccb0738bda.i /usr/obj ffs rw,nodev,nosuid 1 2
  585e0fccb0738bda.g /usr/src ffs rw,nodev,nosuid 1 2
  585e0fccb0738bda.d /var ffs rw,nodev,nosuid 1 2

Append to the fstab by entering

  # cat >> fstab
  swap /tmp mfs rw,nodev,nosuid,-s=500M 0 0

and then hit ctrl-d to exit the 'cat'. Finally:

  # reboot

Now the APU should come up and open an sshd on the local network. Notably, root
login has been switched off by default:

  laptop$ ssh myusername@192.168.0.11
  # su
  Password:...

My APU will be reachable by the public internet, I want to only permit ssh
public/private key login:

  # vi /etc/ssh/sshd_config
  PermitRootLogin no
  PubkeyAuthentication yes
  PasswordAuthentication no
  ChallengeResponseAuthentication no

Check that the tmpfs worked out:

  # mount
  sub# mount
  /dev/sd0a on / type ffs (local)
  /dev/sd0h on /home type ffs (local, nodev, nosuid)
  /dev/sd0e on /usr type ffs (local, nodev)
  /dev/sd0f on /usr/local type ffs (local, nodev, wxallowed)
  /dev/sd0i on /usr/obj type ffs (local, nodev, nosuid)
  /dev/sd0g on /usr/src type ffs (local, nodev, nosuid)
  /dev/sd0d on /var type ffs (local, nodev, nosuid)
  mfs:91979 on /tmp type mfs (asynchronous, local, nodev, nosuid, size=1024000 512-blocks)

Install full vim:

  # pkg_add vim
  Ambiguous: choose package for vim
  a       0: 
          1: vim-8.0.1589-gtk2
          2: vim-8.0.1589-gtk2-lua
          3: vim-8.0.1589-gtk2-perl-python-ruby
          4: vim-8.0.1589-gtk2-perl-python3-ruby
          5: vim-8.0.1589-no_x11
          6: vim-8.0.1589-no_x11-lua
          7: vim-8.0.1589-no_x11-perl-python-ruby
          8: vim-8.0.1589-no_x11-perl-python3-ruby
          9: vim-8.0.1589-no_x11-python
          10: vim-8.0.1589-no_x11-python3
          11: vim-8.0.1589-no_x11-ruby
  Your choice: 5
  vim-8.0.1589-no_x11:libiconv-1.14p3: ok
  vim-8.0.1589-no_x11:gettext-0.19.8.1p1: ok
  vim-8.0.1589-no_x11: ok

And the rest is an exercise for the reader...

Unfortunately I haven't found out yet how to enable the TTL serial console on
J4. If you know how, drop me a note. Thanks!
login 2020-01-14 18:50