01 September 2014

NetBSD on Banana Pi

The "Banana Pi" is a new(ish) ARM-based board, aimed at being "mostly-compatible" with the Raspberry Pi - which they have accomplished to a degree.  The Banana Pi has a newer, ARMv7-based core, though, so has the potential to be a lot faster.  I'm always looking for new hardware to test NetBSD on, so I thought I'd give it a shot.  At about $65, it's more expensive than the Raspberry Pi, but since it has more on board (SATA, Gigabit Ethernet, dual-core CPU, 1GB RAM), it's a pretty good deal. The one I ordered came yesterday, so I fiddled around with it bit trying to see how fast I could get a kernel booting.  I downloaded the "Bananian" Linux image, booted to make sure it worked, and investigated how the boot process worked.


Like the Raspberry Pi and many other  single-board computers,  it had a small FAT partition from which the kernel is loaded, and a larger partition (ext4 in this case) that's mounted as / upon boot.  The boot partition  is what really interested me - there were only 3 files: uImageuEnv.txt and script.bin .  My first thought was that I could just put a NetBSD kernel and a uEnv.txt with appropriate u-boot commands to load it onto a NetBSD Raspberry Pi SD card and things would Just Work.   Unfortunately, this didn't work, and left me scratching my head until I poked around the Banana Pi wiki and realized that u-boot itself is loaded off the SD card, from a specific location in the first 1MB.  Once I wrote u-boot (and the SPL) to the SD card, voila!


## Booting kernel from Legacy Image at 48000000 ...
   Image Name:   NetBSD/cubie 7.99.1
   Image Type:   ARM NetBSD Kernel Image (uncompressed)
   Data Size:    5129344 Bytes = 4.9 MiB
   Load Address: 40007800
   Entry Point:  40007800
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
## Transferring control to NetBSD stage-2 loader (at address 40007800) ...
Early console started
[ Kernel symbol table missing! ]
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 7.99.1 (CUBIEBOARD.201408302100Z) #0: Sat Aug 30 22:36:41 UTC 2014
 builds@b48.netbsd.org:/home/builds/ab/HEAD/evbarm-earmv7hf/201408302100Z-obj/home/source/ab/HEAD/src/sys/arch/evbarm/compile/CUBIEBOARD
total memory = 1024 MB
avail memory = 1008 MB
sysctl_createv: sysctl_create(machine_arch) returned 17
kern.module.path=/stand/evbarm/7.99.1/modules
mainbus0 (root)
cpu0 at mainbus0 core 0: 960 MHz Cortex-A7 r0p4 (Cortex V7A core)
cpu0: DC enabled IC enabled WB disabled EABT branch prediction enabled
cpu0: 32KB/32B 2-way L1 VIPT Instruction cache
cpu0: 32KB/64B 4-way write-back-locking-C L1 PIPT Data cache
cpu0: 256KB/64B 8-way write-through L2 PIPT Unified cache
vfp0 at cpu0: NEON MPE (VFP 3.0+), rounding, NaN propagation, denormals
armperiph0 at mainbus0
armgic0 at armperiph0: Generic Interrupt Controller, 160 sources (151 valid)
armgic0: 32 Priorities, 128 SPIs, 7 PPIs, 16 SGIs
armgtmr0 at armperiph0: ARMv7 Generic 64-bit Timer (24000 kHz)
armgtmr0: interrupting on irq 27
awinio0 at mainbus0
awingpio0 at awinio0
com0 at awinio0 port 0: ns16550a, working fifo
com0: console
awinwdt0 at awinio0: default period is 10 seconds
awinusb0 at awinio0 port 0
ohci0 at awinusb0: OHCI USB controller
ohci0: OHCI version 1.0
usb0 at ohci0: USB revision 1.0
ohci0: interrupting on irq 96
ehci0 at awinusb0: EHCI USB controller
ehci0: companion controller, 1 port each: ohci0
usb1 at ehci0: USB revision 2.0
ehci0: interrupting on irq 71
awinusb1 at awinio0 port 1
ohci1 at awinusb1: OHCI USB controller
ohci1: OHCI version 1.0
usb2 at ohci1: USB revision 1.0
ohci1: interrupting on irq 97
ehci1 at awinusb1: EHCI USB controller
ehci1: companion controller, 1 port each: ohci1
usb3 at ehci1: USB revision 2.0
ehci1: interrupting on irq 72
awinmmc0 at awinio0 port 0: SD/MMC interface
sdmmc0 at awinmmc0
ahcisata0 at awinio0: AHCI SATA controller
ahcisata0: interrupting on irq 88
ahcisata0: AHCI revision 1.10, 1 port, 32 slots, CAP 0x6724ff80
atabus0 at ahcisata0 channel 0
awiniic0 at awinio0 port 0: Marvell TWSI controller
awiniic0: interrupting on irq 39
iic0 at awiniic0: I2C bus
awe0 at awinio0: 10/100 Ethernet Controller
awe0: interrupting on irq 87
awe0: no PHY found!
sysctl_createv: sysctl_create() returned 22
: could not attach sysctl nodes
gpio0 at awingpio0: 20 pins
gpio1 at awingpio0: 25 pins
gpio2 at awingpio0: 28 pins
gpio3 at awingpio0: 12 pins
gpio4 at awingpio0: 12 pins
gpio5 at awingpio0: 28 pins
gpio6 at awingpio0: 22 pins
ld0 at sdmmc0: <0x03:0x5344:su08g:0x80:0x14590fff:0x0bc>
uhub0 at usb0: Allwinner OHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub1 at usb1: Allwinner EHCI root hub, class 9/0, rev 2.00/1.00, addr 1
uhub2 at usb2: Allwinner OHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub3 at usb3: Allwinner EHCI root hub, class 9/0, rev 2.00/1.00, addr 1
ld0: 7580 MB, 3850 cyl, 64 head, 63 sec, 512 bytes/sect x 15523840 sectors
ld0: 4-bit width, bus clock 50.000 MHz
boot device: 
root device: ld0
dump device (default ld0b):
file system (default generic):
root on ld0a dumps on ld0b
/: replaying log to memory
root file system type: ffs
WARNING: no TOD clock present
WARNING: using filesystem time
WARNING: CHECK AND RESET THE DATE!
init path (default /sbin/init): /rescue/init
init: trying /rescue/init
Sat Aug 23 13:49:59 UTC 2014
Starting root file system check:
/dev/rld0a: file system is journaled; not checking
/: replaying log to disk
swapctl: adding /dev/ld0b as swap device at priority 0
Starting file system checks:
/dev/rld0e: 13 files, 43932 free (10983 clusters)
random_seed: /var/db/entropy-file: Not present
Setting tty flags.
Setting sysctl variables:
ddb.onpanic: 1 -> 0
Starting network.
Hostname: rpi
IPv6 mode: host
Configuring network interfaces:.
Adding interface aliases:.
Waiting for DAD completion for statically configured addresses...
Starting dhcpcd.
panic: kernel diagnostic assertion "ec->ec_mii != NULL" failed: file "/home/source/ab/HEAD/src/sys/dev/mii/mii_ethersubr.c", line 36
cpu0: Begin traceback...
0xbf955c64: netbsd:db_panic+0xc
0xbf955c94: netbsd:vpanic+0x174
0xbf955cac: netbsd:__udivmoddi4
0xbf955ce4: netbsd:ether_mediastatus+0x70
0xbf955d14: netbsd:ifmedia_ioctl+0xf0
0xbf955d3c: netbsd:awin_eth_ifioctl+0xd0
0xbf955e1c: netbsd:doifioctl+0x2b8
0xbf955e44: netbsd:soo_ioctl+0x2b4
0xbf955f0c: netbsd:sys_ioctl+0x274
0xbf955f7c: netbsd:syscall+0x84
0xbf955fac: netbsd:swi_handler+0xa0
cpu0: End traceback...

Looking much better!  That crash at the end is a little worrying, though.  As it turns out, the support for the chipset is not yet complete - the ethernet support doesn't work yet.  (This should be remedied within a next few weeks).  This meant I had to build a new kernel with the ethernet driver removed, to avoid the crash above.  Luckily, I also had a supported USB wifi dongle laying around, and within a few minutes I was up and running!

U-Boot SPL 2014.04-10710-g509d96d (Aug 27 2014 - 17:46:15)
Board: Bananapi
DRAM: 1024 MiB
CPU: 960000000Hz, AXI/AHB/APB: 3/2/2
spl: not an uImage at 1600


U-Boot 2014.04-10710-g509d96d (Aug 27 2014 - 17:46:15) Allwinner Technology

CPU:   Allwinner A20 (SUN7I)
Board: Bananapi
I2C:   ready
DRAM:  1 GiB
MMC:   SUNXI SD/MMC: 0
*** Warning - bad CRC, using default environment

In:    serial
Out:   serial
Err:   serial
Net:   dwmac.1c50000
Hit any key to stop autoboot:  0
reading uEnv.txt
94 bytes read in 18 ms (4.9 KiB/s)
Loaded environment from uEnv.txt
Running uenvcmd ...
reading bananapi.ub
5108736 bytes read in 271 ms (18 MiB/s)
## Booting kernel from Legacy Image at 48000000 ...
   Image Name:   NetBSD/cubie 7.99.1
   Image Type:   ARM NetBSD Kernel Image (uncompressed)
   Data Size:    5108672 Bytes = 4.9 MiB
   Load Address: 40007800
   Entry Point:  40007800
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
## Transferring control to NetBSD stage-2 loader (at address 40007800) ...
Early console started
[ Kernel symbol table missing! ]
Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
    2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014
    The NetBSD Foundation, Inc.  All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
    The Regents of the University of California.  All rights reserved.

NetBSD 7.99.1 (BANANAPI) #0: Sun Aug 31 11:04:16 PDT 2014
 riz@cassava.tastylime.net:/scratch/evbarm7/obj/sys/arch/evbarm/compile/BANANAPI
total memory = 1024 MB
avail memory = 1008 MB
sysctl_createv: sysctl_create(machine_arch) returned 17
kern.module.path=/stand/evbarm/7.99.1/modules
mainbus0 (root)
cpu0 at mainbus0 core 0: 960 MHz Cortex-A7 r0p4 (Cortex V7A core)
cpu0: DC enabled IC enabled WB disabled EABT branch prediction enabled
cpu0: 32KB/32B 2-way L1 VIPT Instruction cache
cpu0: 32KB/64B 4-way write-back-locking-C L1 PIPT Data cache
cpu0: 256KB/64B 8-way write-through L2 PIPT Unified cache
vfp0 at cpu0: NEON MPE (VFP 3.0+), rounding, NaN propagation, denormals
armperiph0 at mainbus0
armgic0 at armperiph0: Generic Interrupt Controller, 160 sources (151 valid)
armgic0: 32 Priorities, 128 SPIs, 7 PPIs, 16 SGIs
armgtmr0 at armperiph0: ARMv7 Generic 64-bit Timer (24000 kHz)
armgtmr0: interrupting on irq 27
awinio0 at mainbus0
awingpio0 at awinio0
com0 at awinio0 port 0: ns16550a, working fifo
com0: console
awinwdt0 at awinio0: default period is 10 seconds
awinusb0 at awinio0 port 0
ohci0 at awinusb0: OHCI USB controller
ohci0: OHCI version 1.0
usb0 at ohci0: USB revision 1.0
ohci0: interrupting on irq 96
ehci0 at awinusb0: EHCI USB controller
ehci0: companion controller, 1 port each: ohci0
usb1 at ehci0: USB revision 2.0
ehci0: interrupting on irq 71
awinusb1 at awinio0 port 1
ohci1 at awinusb1: OHCI USB controller
ohci1: OHCI version 1.0
usb2 at ohci1: USB revision 1.0
ohci1: interrupting on irq 97
ehci1 at awinusb1: EHCI USB controller
ehci1: companion controller, 1 port each: ohci1
usb3 at ehci1: USB revision 2.0
ehci1: interrupting on irq 72
awinmmc0 at awinio0 port 0: SD/MMC interface
sdmmc0 at awinmmc0
ahcisata0 at awinio0: AHCI SATA controller
ahcisata0: interrupting on irq 88
ahcisata0: AHCI revision 1.10, 1 port, 32 slots, CAP 0x6724ff80
atabus0 at ahcisata0 channel 0
awiniic0 at awinio0 port 0: Marvell TWSI controller
awiniic0: interrupting on irq 39
iic0 at awiniic0: I2C bus
gpio0 at awingpio0: 3 pins
gpio1 at awingpio0: 20 pins
gpio2 at awingpio0: 25 pins
gpio3 at awingpio0: 28 pins
gpio4 at awingpio0: 12 pins
gpio5 at awingpio0: 12 pins
gpio6 at awingpio0: 28 pins
gpio7 at awingpio0: 22 pins
ld0 at sdmmc0: <0x03:0x5344:su08g:0x80:0x14590fff:0x0bc>
uhub0 at usb0: Allwinner OHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub1 at usb1: Allwinner EHCI root hub, class 9/0, rev 2.00/1.00, addr 1
uhub2 at usb2: Allwinner OHCI root hub, class 9/0, rev 1.00/1.00, addr 1
uhub3 at usb3: Allwinner EHCI root hub, class 9/0, rev 2.00/1.00, addr 1
ld0: 7580 MB, 3850 cyl, 64 head, 63 sec, 512 bytes/sect x 15523840 sectors
ld0: 4-bit width, bus clock 50.000 MHz
usbd_get_string: getting lang failed, using 0
urtwn0 at uhub3 port 1
urtwn0: Realtek 802.11n WLAN Adapter, rev 2.00/2.00, addr 2
urtwn0: MAC/BB RTL8188CUS, RF 6052 1T1R, address 00:13:ef:70:15:38
urtwn0: 1 rx pipe, 2 tx pipes
urtwn0: 11b rates: 1Mbps 2Mbps 5.5Mbps 11Mbps
urtwn0: 11g rates: 1Mbps 2Mbps 5.5Mbps 11Mbps 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps
boot device: 
root device: ld0
dump device (default ld0b):
file system (default generic):
root on ld0a dumps on ld0b
/: replaying log to memory
root file system type: ffs
WARNING: no TOD clock present
WARNING: using filesystem time
WARNING: CHECK AND RESET THE DATE!
init path (default /sbin/init):
init: trying /sbin/init
Sat Aug 23 13:49:56 UTC 2014
Starting root file system check:
/dev/rld0a: file system is journaled; not checking
/: replaying log to disk
swapctl: adding /dev/ld0b as swap device at priority 0
Starting file system checks:
/dev/rld0e: 18 files, 38924 free (9731 clusters)
random_seed: /var/db/entropy-file: Not present
Setting tty flags.
Setting sysctl variables:
ddb.onpanic: 1 -> 0
Starting network.
Hostname: rpi
IPv6 mode: host
Configuring network interfaces:.
Adding interface aliases:.
Waiting for DAD completion for statically configured addresses...
Starting dhcpcd.
Building databases: dev, utmp, utmpx, services.
wsconscfg: Cannot open `/dev/ttyEcfg': Device not configured
wsconscfg: Cannot open `/dev/ttyEcfg': Device not configured
wsconscfg: Cannot open `/dev/ttyEcfg': Device not configured
wsconscfg: Cannot open `/dev/ttyEcfg': Device not configured
Starting syslogd.
Mounting all file systems...
Clearing temporary files.
Creating a.out runtime link editor directory cache.
Checking quotas: done.
Setting securelevel: kern.securelevel: 0 -> 1
Starting virecover.
Checking for core dump...
savecore: no core dump
Starting devpubd.
Starting local daemons:.
Updating motd.
Generating public/private rsa1 key pair.
Your identification has been saved in /etc/ssh/ssh_host_key.
Your public key has been saved in /etc/ssh/ssh_host_key.pub.
The key fingerprint is:
72:34:87:47:60:f1:94:ca:44:95:38:58:1a:00:d8:f2 root@rpi
The key's randomart image is:
+--[RSA1 2048]----+
| o.....+*=+o     |
|o .   .++=o      |
| o    .o+o+      |
|  E    .o+       |
|      . S        |
|       o         |
|                 |
|                 |
|                 |
+-----------------+
Generating public/private dsa key pair.
Your identification has been saved in /etc/ssh/ssh_host_dsa_key.
Your public key has been saved in /etc/ssh/ssh_host_dsa_key.pub.
The key fingerprint is:
79:68:e0:4e:75:32:c7:29:23:11:42:0b:35:d6:06:35 root@rpi
The key's randomart image is:
+--[ DSA 1024]----+
|  .oB+E.         |
|   o +oo . .     |
|    ..o * =      |
|     . + X       |
|      o S .      |
|     o . .       |
|      .          |
|                 |
|                 |
+-----------------+
Generating public/private ecdsa key pair.
Your identification has been saved in /etc/ssh/ssh_host_ecdsa_key.
Your public key has been saved in /etc/ssh/ssh_host_ecdsa_key.pub.
The key fingerprint is:
ec:f8:70:40:8c:72:d9:0b:f0:ce:76:29:f3:a1:a8:fc root@rpi
The key's randomart image is:
+--[ECDSA  521]---+
|  .              |
|   o =           |
|  . * +          |
|   = o +         |
|    * * S        |
|   o * =         |
|  . . + o        |
|..     +         |
|...E    .        |
+-----------------+
Generating public/private rsa key pair.
Your identification has been saved in /etc/ssh/ssh_host_rsa_key.
Your public key has been saved in /etc/ssh/ssh_host_rsa_key.pub.
The key fingerprint is:
80:34:2d:ac:be:fd:88:ef:3f:e3:c1:01:03:ab:69:1c root@rpi
The key's randomart image is:
+--[ RSA 2048]----+
|  ..o.           |
|   +oo.          |
| E..+..          |
|.oo  o .         |
|o+    . S        |
|. .  . .         |
|   o  o          |
|  ....o.         |
|  .o+++o         |
+-----------------+
Starting sshd.
postfix: rebuilding /etc/mail/aliases (missing /etc/mail/aliases.db)
Aug 23 13:50:43 rpi postfix/master[3626]: fatal: cannot update lock file /var/db/postfix/master.lock: No space left on device
Aug 23 13:50:44 rpi postfix/master[3619]: fatal: daemon initialization failure
Aug 23 13:50:46 rpi postfix/postfix-script[4019]: fatal: mail system startup failed
rpi#

There are still a few rough spots;  the aforementioned ethernet driver problems, and the fact that multiprocessor support for the Cortex A-7 core doesn't quite work yet - but even without that, this is a speedy little board!  I'm looking forward to putting it through its paces over the next few weeks.  With any luck, we'll be able to get full support for the Banana Pi (and its Cubieboard cousins) into NetBSD 7.0 when it comes out later this year.

2 comments:

  1. have you tried to install netbsd 7.0 on banana pi?

    ReplyDelete