# BananaPi using GENERICSD image



## Phishfry (Jan 15, 2022)

I have FreeBSD 12.3 BananaPi image running and I upgraded to FreeBSD 13-RELEASE-GENERICSD-armv7 image.
Since this is a generic image it must be flashed with uboot after flashing FreeBSD 13-RELEASE to it.

Write FreeBSD image to SD card
dd if=FreeBSD-13.0-RELEASE-arm-armv7-GENERICSD.img of=/dev/da0 bs=1M conv=sync status=progress

You should `make` port sysutils/u-boot-bananapi. Now uboot flash.
`dd if=u-boot-sunxi-with-spl.bin of=/dev/da0 bs=1k seek=8 conv=sync`

After I like to mount EFI partition and add uboot DTB file and delete /dtb and all root files except ubldr.bin

Then copy over the Uboot DTB file from ports to the root of EFI partition:
/usr/ports/sysutils/u-boot-bananapi/work/u-boot-2021.07/arch/arm/dts/sun7i-a20-bananapi.dtb

That's it for EFI partition. Now you can customize root mount.

Now if using an SATA drive you might want root on SATA.
If so don't waste time customizing partition mmcsd0s2a.
You will be flashing the GENERICSD image to the SATA drive.

I first boot up my new FreeBSD-13-RELEASE SD-Card to test and it boots up to login on serial console.


```
U-Boot SPL 2021.07 (Jan 14 2022 - 21:10:47 -0500)
DRAM: 1024 MiB
CPU: 912000000Hz, AXI/AHB/APB: 3/2/2
Trying to boot from MMC1


U-Boot 2021.07 (Jan 14 2022 - 21:10:47 -0500) Allwinner Technology

CPU:   Allwinner A20 (SUN7I)
Model: LeMaker Banana Pi
I2C:   ready
DRAM:  1 GiB
MMC:   mmc@1c0f000: 0
Loading Environment from FAT... Unable to read "uboot.env" from mmc0:1... Setting up a 720x576i composite-pal console (overscan 32x20)
In:    serial
Out:   vidconsole
Err:   vidconsole
Net:   eth0: ethernet@1c50000
starting USB...
Bus usb@1c14000: USB EHCI 1.00
Bus usb@1c14400: USB OHCI 1.0
Bus usb@1c1c000: USB EHCI 1.00
Bus usb@1c1c400: USB OHCI 1.0
scanning bus usb@1c14000 for devices... 1 USB Device(s) found
scanning bus usb@1c14400 for devices... 1 USB Device(s) found
scanning bus usb@1c1c000 for devices... 1 USB Device(s) found
scanning bus usb@1c1c400 for devices... 1 USB Device(s) found
       scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot:  0
```

Now for the SATA drive work.

Return to Uboot by rebooting FreeBSD. Now enter u-boot command prompt on reboot.
We are checking out our devices.

```
=> mmc list
mmc@1c0f000: 0 (SD)
```
OK No eMMC here. Only SD Card.

Lets check out SATA.

```
=> sata
Unknown command 'sata' - try 'help'
```

I see this this board uses SCSI. Lets try that.

```
=> scsi
scsi - SCSI sub-system

Usage:
scsi reset - reset SCSI controller
scsi info  - show available SCSI devices
scsi scan  - (re-)scan SCSI bus
scsi device [dev] - show or set current device
scsi part [dev] - print partition table of one or all SCSI devices
scsi read addr blk# cnt - read `cnt' blocks starting at block `blk#'
     to memory address `addr'
scsi write addr blk# cnt - write `cnt' blocks starting at block
     `blk#' from memory address `addr'
```

Time to hook up the SATA drive to see if it shows...


----------



## Phishfry (Jan 15, 2022)

```
switch to partitions #0, OK
mmc0 is current device
Scanning mmc 0:1...
41178 bytes read in 4 ms (9.8 MiB/s)
Scanning disk mmc@1c0f000.blk...
** Unrecognized filesystem type **
Found 3 disks
No EFI system partition
BootOrder not defined
EFI boot manager: Cannot load any image
Found EFI removable media binary efi/boot/bootarm.efi
1403700 bytes read in 80 ms (16.7 MiB/s)
Booting /efi\boot\bootarm.efi

Consoles: EFI console 
    Reading loader env vars from /efi/freebsd/loader.env
Setting currdev to disk0p1:
FreeBSD/arm EFI loader, Revision 1.1

   Command line arguments: l
   Image base: 0x78df8000
   EFI version: 2.80
   EFI Firmware: Das U-Boot (rev 8225.1792)
   Console: comconsole (0)
   Load Path: /efi\boot\bootarm.efi
   Load Device: /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)/HD(1,0x01,0,0x81f,0x18fa8)
Trying ESP: /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)/HD(1,0x01,0,0x81f,0x18fa8)
Setting currdev to disk0p1:
Trying: /VenHw(e61d73b9-a384-4acc-aeab-82e828f3628b)/SD(0)/SD(0)/HD(2,0x01,0,0x197c7,0x5e6821)
Setting currdev to disk0p2:
Loading /boot/defaults/loader.conf
Loading /boot/defaults/loader.conf
Loading /boot/device.hints
Loading /boot/loader.conf
Loading /boot/loader.conf.local
Loading kernel...
/boot/kernel/kernel text=0x1b4 text=0x6f2fe4 text=0x1831dc data=0xb00b0 data=0x0+0x1e8000 syms=[0x4+0x9e880+0x4+0x1100f4]
Loading configured modules...
/boot/kernel/umodem.ko text=0x1540 text=0xf20 data=0x234+0x4 syms=[0x4+0xe70+0x4+0xa74]
loading required module 'ucom'
/boot/kernel/ucom.ko text=0x1714 text=0x2c7c data=0x484+0x838 syms=[0x4+0x13e0+0x4+0xbac]
/boot/entropy size=0x1000
/etc/hostid size=0x25

Hit [Enter] to boot immediately, or any other key for command prompt.
Booting [/boot/kernel/kernel] in 8 seconds...
```


----------



## Phishfry (Jan 15, 2022)

Phishfry said:


> ```
> switch to partitions #0, OK
> mmc0 is current device
> Scanning mmc 0:1...
> ...


----------



## Phishfry (Jan 15, 2022)

We have SATA drive working. BPi has bad power from board so external power is recommended.

```
=> scsi info
=> scsi scan
scanning bus for devices...
Target spinup took 0 ms.
AHCI 0001.0100 32 slots 1 ports 3 Gbps 0x1 impl SATA mode
flags: ncq stag pm led clo only pmp pio slum part ccc apst
  Device 0: (0:0) Vendor: ATA Prod.: WDC WD1600BEVT-0 Rev: 01.0
            Type: Hard Disk
            Capacity: 152627.8 MB = 149.0 GB (312581808 x 512)
=> scsi info
Device 0: (0:0) Vendor: ATA Prod.: WDC WD1600BEVT-0 Rev: 01.0
            Type: Hard Disk
            Capacity: 152627.8 MB = 149.0 GB (312581808 x 512)
```


----------



## Phishfry (Jan 15, 2022)

I do notice that the drive is not detected unless I do a `scsi scan` in u-boot first. Then boot.


----------



## Phishfry (Jan 25, 2022)

How about some quick numbers for an SATA SSD with FreeBSD 13.0-RELEASE on BPI-M1.
Reads are ok

```
diskinfo -t /dev/ada0
<snip>
Transfer rates:
        outside:       102400 kbytes in   0.532320 sec =   192365 kbytes/sec
        middle:        102400 kbytes in   0.529642 sec =   193338 kbytes/sec
        inside:        102400 kbytes in   0.529961 sec =   193222 kbytes/sec
```
Writes are pretty bad.

```
diskinfo -wS /dev/ada0
/dev/ada0
        512             # sectorsize
        960197124096    # mediasize in bytes (894G)
        1875385008      # mediasize in sectors
        4096            # stripesize
        0               # stripeoffset
        1860501         # Cylinders according to firmware.
        16              # Heads according to firmware.
        63              # Sectors according to firmware.
        MICRON M510DC MTFDDAK960MBP     # Disk descr.
        16311434FEFB    # Disk ident.
        ahcich0         # Attachment
        Yes             # TRIM/UNMAP support
        0               # Rotation rate in RPM
        Not_Zoned       # Zone Mode

Synchronous random writes:
         0.5 kbytes:    157.3 usec/IO =      3.1 Mbytes/s
           1 kbytes:    169.5 usec/IO =      5.8 Mbytes/s
           2 kbytes:    195.1 usec/IO =     10.0 Mbytes/s
           4 kbytes:    235.9 usec/IO =     16.6 Mbytes/s
           8 kbytes:    337.0 usec/IO =     23.2 Mbytes/s
          16 kbytes:    536.3 usec/IO =     29.1 Mbytes/s
          32 kbytes:    937.0 usec/IO =     33.4 Mbytes/s
          64 kbytes:   1747.6 usec/IO =     35.8 Mbytes/s
         128 kbytes:   3357.2 usec/IO =     37.2 Mbytes/s
         256 kbytes:   6501.4 usec/IO =     38.5 Mbytes/s
         512 kbytes:  12763.2 usec/IO =     39.2 Mbytes/s
        1024 kbytes:  25292.9 usec/IO =     39.5 Mbytes/s
        2048 kbytes:  50362.1 usec/IO =     39.7 Mbytes/s
        4096 kbytes: 100505.3 usec/IO =     39.8 Mbytes/s
        8192 kbytes: 200964.0 usec/IO =     39.8 Mbytes/s
```


----------

