Banana PI BPI-P2 Zero Buildroot Support with Kernel 5.6.4

Hi everyone, I added buildroot support for Banana Pi P2 Zero board with ethernet and eMMC working in uboot and kernel. This is not a final, ready to use image. If you never heard of buildroot, please refer to this page. This work is based on Sinovoip Buildroot and Avafinger Ubuntu Base Minimal Image total image size is only ~77MB with really basic functionality. The goal is, enabling community to build and custom their own linux on Banana Pi P2 Zero.

How to build:

$ git clone https://github.com/xqdzn/buildroot.git
$ cd buildroot
$ make bananapi_p2_zero_defconfig
$ make

Then burn the image in output/images/sdcard.img to your sdcard:

sudo dd if=output/images/sdcard.img of=/dev/sdX

Do not forget to replace X with your drive, please be careful while dd-ing image. You can accidentally format your PC

For those who not bothered to compile and just want to try the image, you can download compiled image here

dd log:

$sudo dd if=sdcard.img of=/dev/sda status=progress 
69014016 bytes (69 MB, 66 MiB) copied, 11 s, 6.3 MB/s
141312+0 records in
141312+0 records out
72351744 bytes (72 MB, 69 MiB) copied, 11.9292 s, 6.1 MB/s

Boot only took ~3 seconds:


U-Boot 2020.04 (Apr 17 2020 - 13:03:20 +0700) Allwinner Technology

CPU:   Allwinner H3 (SUN8I 1680)
Model: Banana Pi BPI-P2-Zero
DRAM:  512 MiB
MMC:   Device 'mmc@1c11000': seq 1 is in use by 'mmc@1c10000'
mmc@1c0f000: 0, mmc@1c10000: 2, mmc@1c11000: 1
Loading Environment from FAT... Unable to use mmc 1:1... In:    serial
Out:   vidconsole
Err:   vidconsole
Net:   phy interface0
eth0: ethernet@1c30000
starting USB...
Bus usb@1c1a000: USB EHCI 1.00
scanning bus usb@1c1a000 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
Found U-Boot script /boot.scr
710 bytes read in 1 ms (693.4 KiB/s)
## Executing script at 43100000
21905 bytes read in 3 ms (7 MiB/s)
4750480 bytes read in 219 ms (20.7 MiB/s)
## Flattened Device Tree blob at 43000000
   Booting using the fdt blob at 0x43000000
EHCI failed to shut down host controller.
   Loading Device Tree to 49ff7000, end 49fff590 ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 5.6.4 (me@nvm) (gcc version 8.4.0 (Buildroot 2020.05-git-00902-g3ea2ca8d8b-dirty)) #1 SMP PREEMPT Fri Apr 17 13:05:44 WIB 2020
[    0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt: Machine model: Banana Pi BPI-P2-Zero
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] cma: Reserved 16 MiB at 0x5cc00000
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: Using PSCI v0.1 Function IDs from DT
[    0.000000] percpu: Embedded 15 pages/cpu s30924 r8192 d22324 u61440
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 121920
[    0.000000] Kernel command line: console=ttyS0,115200 earlyprintk root=/dev/mmcblk0p2 rootfstype=ext4 rw rootwait fsck.repair=yes panic=10 consoleblank=0 hdmi.audio=EDID:0 disp.screen0_output_mode=1280x720p60 sunxi_ve_mem_reserve=0 sunxi_g2d_mem_reserve=0 sunxi_fb_mem_reserve=16
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes, linear)
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 459556K/491520K available (7168K kernel code, 451K rwdata, 1840K rodata, 1024K init, 256K bss, 15580K reserved, 16384K cma-reserved, 0K highmem)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
[    0.000000] rcu: Preemptible hierarchical RCU implementation.
[    0.000000]  Tasks RCU enabled.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000000] GIC: Using split EOI/Deactivate mode
[    0.000000] random: get_random_bytes called from start_kernel+0x2b8/0x458 with crng_init=0
[    0.000000] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[    0.000000] arch_timer: cp15 timer(s) running at 24.00MHz (phys).
[    0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x588fe9dc0, max_idle_ns: 440795202592 ns
[    0.000008] sched_clock: 56 bits at 24MHz, resolution 41ns, wraps every 4398046511097ns
[    0.000020] Switching to timer-based delay loop, resolution 41ns
[    0.000213] Console: colour dummy device 80x30
[    0.000260] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=240000)
[    0.000274] pid_max: default: 32768 minimum: 301
[    0.000425] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.000438] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes, linear)
[    0.001232] CPU: Testing write buffer coherency: ok
[    0.001681] /cpus/cpu@0 missing clock-frequency property
[    0.001703] /cpus/cpu@1 missing clock-frequency property
[    0.001721] /cpus/cpu@2 missing clock-frequency property
[    0.001739] /cpus/cpu@3 missing clock-frequency property
[    0.001752] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
[    0.060106] Setting up static identity map for 0x40100000 - 0x40100060
[    0.080075] rcu: Hierarchical SRCU implementation.
[    0.120132] smp: Bringing up secondary CPUs ...
[    0.210611] CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
[    0.300748] CPU2: thread -1, cpu 2, socket 0, mpidr 80000002
[    0.390889] CPU3: thread -1, cpu 3, socket 0, mpidr 80000003
[    0.390986] smp: Brought up 1 node, 4 CPUs
[    0.391006] SMP: Total of 4 processors activated (192.00 BogoMIPS).
[    0.391013] CPU: All CPU(s) started in HYP mode.
[    0.391018] CPU: Virtualization extensions available.
[    0.391595] devtmpfs: initialized
[    0.396927] VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5
[    0.397317] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.397342] futex hash table entries: 1024 (order: 4, 65536 bytes, linear)
[    0.398244] pinctrl core: initialized pinctrl subsystem
[    0.398847] thermal_sys: Registered thermal governor 'step_wise'
[    0.399653] NET: Registered protocol family 16
[    0.401611] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.402829] hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.
[    0.402840] hw-breakpoint: maximum watchpoint size is 8 bytes.
[    0.424335] SCSI subsystem initialized
[    0.424820] usbcore: registered new interface driver usbfs
[    0.424869] usbcore: registered new interface driver hub
[    0.424974] usbcore: registered new device driver usb
[    0.425205] pps_core: LinuxPPS API ver. 1 registered
[    0.425213] pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
[    0.425233] PTP clock support registered
[    0.425447] Advanced Linux Sound Architecture Driver Initialized.
[    0.426570] clocksource: Switched to clocksource arch_sys_counter
[    0.434567] NET: Registered protocol family 2
[    0.435168] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 6144 bytes, linear)
[    0.435197] TCP established hash table entries: 4096 (order: 2, 16384 bytes, linear)
[    0.435240] TCP bind hash table entries: 4096 (order: 3, 32768 bytes, linear)
[    0.435303] TCP: Hash tables configured (established 4096 bind 4096)
[    0.435438] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.435486] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.435688] NET: Registered protocol family 1
[    0.436318] RPC: Registered named UNIX socket transport module.
[    0.436331] RPC: Registered udp transport module.
[    0.436336] RPC: Registered tcp transport module.
[    0.436342] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.438143] hw perfevents: enabled with armv7_cortex_a7 PMU driver, 5 counters available
[    0.439243] Initialise system trusted keyrings
[    0.439458] workingset: timestamp_bits=30 max_order=17 bucket_order=0
[    0.446447] NFS: Registering the id_resolver key type
[    0.446488] Key type id_resolver registered
[    0.446496] Key type id_legacy registered
[    0.482771] Key type asymmetric registered
[    0.482785] Asymmetric key parser 'x509' registered
[    0.482867] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 248)
[    0.482879] io scheduler mq-deadline registered
[    0.482887] io scheduler kyber registered
[    0.483693] sun4i-usb-phy 1c19400.phy: Couldn't request ID GPIO
[    0.487860] sun8i-h3-pinctrl 1c20800.pinctrl: initialized sunXi PIO driver
[    0.489583] sun8i-h3-r-pinctrl 1f02c00.pinctrl: initialized sunXi PIO driver
[    0.539244] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
[    0.540473] sun8i-h3-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pa not found, using dummy regulator
[    0.541423] printk: console [ttyS0] disabled
[    0.541541] 1c28000.serial: ttyS0 at MMIO 0x1c28000 (irq = 35, base_baud = 1500000) is a 16550A
[    1.172723] printk: console [ttyS0] enabled
[    1.177361] sun8i-h3-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pg not found, using dummy regulator
[    1.188025] 1c28400.serial: ttyS1 at MMIO 0x1c28400 (irq = 36, base_baud = 1500000) is a 16550A
[    1.201563] libphy: Fixed MDIO Bus: probed
[    1.205666] CAN device driver interface
[    1.210028] dwmac-sun8i 1c30000.ethernet: IRQ eth_wake_irq not found
[    1.216378] dwmac-sun8i 1c30000.ethernet: IRQ eth_lpi not found
[    1.222411] dwmac-sun8i 1c30000.ethernet: PTP uses main clock
[    1.228209] dwmac-sun8i 1c30000.ethernet: No regulator found
[    1.234193] dwmac-sun8i 1c30000.ethernet: Current syscon value is not the default 148000 (expect 58000)
[    1.243613] dwmac-sun8i 1c30000.ethernet: No HW DMA feature register supported
[    1.250843] dwmac-sun8i 1c30000.ethernet: RX Checksum Offload Engine supported
[    1.258068] dwmac-sun8i 1c30000.ethernet: COE Type 2
[    1.263027] dwmac-sun8i 1c30000.ethernet: TX Checksum insertion supported
[    1.269820] dwmac-sun8i 1c30000.ethernet: Normal descriptors
[    1.275472] dwmac-sun8i 1c30000.ethernet: Chain mode enabled
[    1.281641] libphy: stmmac: probed
[    1.285612] dwmac-sun8i 1c30000.ethernet: Found internal PHY node
[    1.292140] libphy: mdio_mux: probed
[    1.295734] dwmac-sun8i 1c30000.ethernet: Switch mux to internal PHY
[    1.302108] dwmac-sun8i 1c30000.ethernet: Powering internal PHY
[    1.309282] libphy: mdio_mux: probed
[    1.313327] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    1.319875] ehci-platform: EHCI generic platform driver
[    1.325303] ehci-platform 1c1a000.usb: EHCI Host Controller
[    1.330915] ehci-platform 1c1a000.usb: new USB bus registered, assigned bus number 1
[    1.349249] ehci-platform 1c1a000.usb: irq 28, io mem 0x01c1a000
[    1.376579] ehci-platform 1c1a000.usb: USB 2.0 started, EHCI 1.00
[    1.383510] hub 1-0:1.0: USB hub found
[    1.387323] hub 1-0:1.0: 1 port detected
[    1.391773] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    1.397988] ohci-platform: OHCI generic platform driver
[    1.403429] ohci-platform 1c1a400.usb: Generic Platform OHCI controller
[    1.410072] ohci-platform 1c1a400.usb: new USB bus registered, assigned bus number 2
[    1.418034] ohci-platform 1c1a400.usb: irq 29, io mem 0x01c1a400
[    1.491235] hub 2-0:1.0: USB hub found
[    1.495026] hub 2-0:1.0: 1 port detected
[    1.503322] sun6i-rtc 1f00000.rtc: registered as rtc0
[    1.508399] sun6i-rtc 1f00000.rtc: RTC enabled
[    1.513107] i2c /dev entries driver
[    1.517774] sunxi-wdt 1c20ca0.watchdog: Watchdog enabled (timeout=16 sec, nowayout=0)
[    1.525978] sun8i-h3-r-pinctrl 1f02c00.pinctrl: 1f02c00.pinctrl supply vcc-pl not found, using dummy regulator
[    1.536582] sun8i-h3-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pf not found, using dummy regulator
[    1.547191] sunxi-mmc 1c0f000.mmc: Got CD GPIO
[    1.577003] sunxi-mmc 1c0f000.mmc: initialized, max. request size: 16384 KB
[    1.584984] sunxi-mmc 1c10000.mmc: allocated mmc-pwrseq
[    1.614221] sunxi-mmc 1c10000.mmc: initialized, max. request size: 16384 KB
[    1.621488] sun8i-h3-pinctrl 1c20800.pinctrl: 1c20800.pinctrl supply vcc-pc not found, using dummy regulator
[    1.641899] mmc0: host does not support reading read-only switch, assuming write-enable
[    1.654498] mmc1: queuing unknown CIS tuple 0x80 (2 bytes)
[    1.660140] mmc0: new high speed SDHC card at address aaaa
[    1.662523] sunxi-mmc 1c11000.mmc: initialized, max. request size: 16384 KB
[    1.666858] mmc1: queuing unknown CIS tuple 0x80 (3 bytes)
[    1.674118] usbcore: registered new interface driver usbhid
[    1.678619] mmcblk0: mmc0:aaaa SC16G 14.8 GiB
[    1.683705] usbhid: USB HID core driver
[    1.689792] mmc1: queuing unknown CIS tuple 0x80 (3 bytes)
[    1.695627] NET: Registered protocol family 17
[    1.700242] mmc1: queuing unknown CIS tuple 0x80 (7 bytes)
[    1.701975] can: controller area network core (rev 20170425 abi 9)
[    1.710744] mmc1: queuing unknown CIS tuple 0x81 (9 bytes)
[    1.713737] NET: Registered protocol family 29
[    1.719223]  mmcblk0: p1 p2
[    1.723575] can: raw protocol (rev 20170425)
[    1.730633] can: broadcast manager protocol (rev 20170425 t)
[    1.736311] can: netlink gateway (rev 20190810) max_hops=1
[    1.742101] Key type dns_resolver registered
[    1.746695] Registering SWP/SWPB emulation handler
[    1.751757] Loading compiled-in X.509 certificates
[    1.766972] random: fast init done
[    1.769177] simple-framebuffer 5e000000.framebuffer: framebuffer at 0x5e000000, 0x384000 bytes, mapped to 0x(ptrval)
[    1.781016] simple-framebuffer 5e000000.framebuffer: format=x8r8g8b8, mode=1280x720x32, linelength=5120
[    1.805690] Console: switching to colour frame buffer device 160x45
[    1.814195] mmc1: new high speed SDIO card at address 0001
[    1.832001] simple-framebuffer 5e000000.framebuffer: fb0: simplefb registered!
[    1.840968] usb_phy_generic usb_phy_generic.1.auto: usb_phy_generic.1.auto supply vcc not found, using dummy regulator
[    1.852610] musb-hdrc musb-hdrc.2.auto: MUSB HDRC host driver
[    1.858440] musb-hdrc musb-hdrc.2.auto: new USB bus registered, assigned bus number 3
[    1.867243] mmc2: new DDR MMC card at address 0001
[    1.872917] mmcblk2: mmc2:0001 8GTF4R 7.28 GiB
[    1.877977] mmcblk2boot0: mmc2:0001 8GTF4R partition 1 4.00 MiB
[    1.884375] mmcblk2boot1: mmc2:0001 8GTF4R partition 2 4.00 MiB
[    1.890545] hub 3-0:1.0: USB hub found
[    1.894381] hub 3-0:1.0: 1 port detected
[    1.900932] sun6i-rtc 1f00000.rtc: setting system clock to 1970-01-01T00:00:07 UTC (7)
[    1.909150] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[    1.919107]  mmcblk2: p1
[    1.926246] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[    1.932989] platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
[    1.936776] ALSA device list:
[    1.941617] cfg80211: failed to load regulatory.db
[    1.944555]   No soundcards found.
[    1.964587] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    1.972796] VFS: Mounted root (ext4 filesystem) on device 179:2.
[    1.982300] devtmpfs: mounted
[    1.986442] Freeing unused kernel memory: 1024K
[    2.036738] Run /sbin/init as init process
[    2.048755] process '/bin/busybox' started with executable stack
[    2.122280] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
Starting syslogd: OK
Starting klogd: OK
Running sysctl: OK
Saving random seed: [    2.226292] random: dd: uninitialized urandom read (512 bytes read)
OK
Starting network: [    2.316051] dwmac-sun8i 1c30000.ethernet eth0: PHY [0.1:01] driver [Generic PHY] (irq=POLL)
[    2.325999] dwmac-sun8i 1c30000.ethernet eth0: No Safety Features support found
[    2.333352] dwmac-sun8i 1c30000.ethernet eth0: No MAC Management Counters available
[    2.341092] dwmac-sun8i 1c30000.ethernet eth0: PTP not supported by HW
[    2.347638] dwmac-sun8i 1c30000.ethernet eth0: configuring for phy/mii link mode
OK

buildroot login: [    2.586638] usb 2-1: new low-speed USB device number 2 using ohci-platform
[    2.899101] input:   USB Keyboard as /devices/platform/soc/1c1a400.usb/usb2/2-1/2-1:1.0/0003:04D9:1702.0001/input/input0
[    2.977073] hid-generic 0003:04D9:1702.0001: input: USB HID v1.10 Keyboard [  USB Keyboard] on usb-1c1a400.usb-1/input0
[    3.006999] input:   USB Keyboard System Control as /devices/platform/soc/1c1a400.usb/usb2/2-1/2-1:1.1/0003:04D9:1702.0002/input/input1
[    3.086905] input:   USB Keyboard Consumer Control as /devices/platform/soc/1c1a400.usb/usb2/2-1/2-1:1.1/0003:04D9:1702.0002/input/input2
[    3.099424] hid-generic 0003:04D9:1702.0002: input: USB HID v1.10 Device [  USB Keyboard] on usb-1c1a400.usb-1/input1

buildroot login: root
# [   32.486597] vcc3v0: disabling
[   32.489582] vcc5v0: disabling

Wlan support:


buildroot login: root
# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq qlen 1000
    link/ether 02:42:e0:c5:61:b6 brd ff:ff:ff:ff:ff:ff
# modprobe brcmfmac
# [   24.392114] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43430-sdio for chip BCM43430/1
[   24.426701] brcmfmac mmc1:0001:1: Direct firmware load for brcm/brcmfmac43430-sdio.sinovoip,bpi-p2-zero.txt failed with error -2
[   24.572188] brcmfmac: brcmf_fw_alloc_request: using brcm/brcmfmac43430-sdio for chip BCM43430/1
[   24.581048] brcmfmac: brcmf_c_process_clm_blob: no clm_blob available (err=-2), device may have limited channels available
[   24.592805] brcmfmac: brcmf_c_preinit_dcmds: Firmware: BCM43430/1 wl0: Oct 23 2017 03:55:53 version 7.45.98.38 (r674442 CY) FWID 01-e58d219f

# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq qlen 1000
    link/ether 02:42:e0:c5:61:b6 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop qlen 1000
    link/ether 18:93:7f:35:78:36 brd ff:ff:ff:ff:ff:ff
#
# [   32.487082] vcc3v0: disabling
[   32.490066] vcc5v0: disabling

#

Shout out to @avaf and @sinovoip

1 Like

I have not tested your image yet, but booting in ~3 secs is very impressive. Is this the reason you choose to use FAT and not to load wifi at boot time and authenticate?

I am not a buildroot user and have few resources on my linux box so i can have a hard time to catch up and learn the build process and would like to customize it my way.

A newbie question, say…can i use the buildroot to build the image on board? (no cross-compiling)

It’s not only the WiFi and FAT. I decided not to load so many kernel modules to speed up boot and let you guys load only what important to speed up boot and efficiency.

The goal of buildroot tools is to build rootfs, kernel, and driver in bigger PC with cross compiler, so you don’t have to include compiler, kernel header, and many stuff on target board. Save up size and optimisation. Since I can build rootfs in buildroot under x86_64 for x86_64 device. I think it is possibile to use buildroot on target arm device. The thing is, you will need another same board as target while the current one is used for building. Or at least, different SDCard so you can flash compiled rootfs,kernel, and stuff in target SDCard instead of current live system.