Difference between revisions of "Ox64"

From PINE64
Jump to navigation Jump to search
Line 334: Line 334:
  D0 Group[group0] Image Addr [0x58100000] [PATH to d0_lowload_bl808_d0.bin]
  D0 Group[group0] Image Addr [0x58100000] [PATH to d0_lowload_bl808_d0.bin]
  Interface: Uart
  Interface: Uart
  Port/SN: /dev/ttyACM1 (make sure you don't use busy ACM0 from minicom console)
  Port/SN: /dev/ttyACM1 (make sure you don't use ACM0, it's used by minicom console)
  Uart rate 2000000
  Uart rate 2000000
  UART TX is physical pin 1/GPIO 14.
  UART TX is physical pin 1/GPIO 14.
Line 343: Line 343:


  Enable 'Single Download', set Address with 0x800000, choose [PATH to bl808-firmware.bin]
  Enable 'Single Download', set Address with 0x800000, choose [PATH to bl808-firmware.bin]
Port/SN: /dev/ttyACM1 (make sure you don't use ACM0, it's used by minicom console)
  Click 'Create & Download' again and wait until it's done
  Click 'Create & Download' again and wait until it's done
  Close DevCube
  Close DevCube

Revision as of 18:14, 3 January 2024

The Ox64
Pinout of the production version
Powered by RISC-V

The Ox64 is a RISC-V based single-board computer based on the Bouffalo Lab BL808 RISC-V SoC with C906 64-bit and E907/E902 32-bit CPU cores supported by 64 MB of embedded PSRAM memory, and with built-in WiFi, Bluetooh and Zigbee radio interfaces. The Ox64 comes in a breadboard-friendly form-factor, has a microSD card slot, a USB 2.0 Type-C port, and many other peripheral interfaces for makers to integrate with sensors and other devices.

Software Releases

Quick Links to the Source of OS Images Build

There is a community effort to bring updated kernels, peripherals and buildroot - Lots of communication happening in the #ox64-nutcracker channel.

  • buildroot bringing all the work below together with a bootable kernel and updated filesystem images for SD cards
  • U-Boot and OpenSBI work by Smauel
  • Kernel IRQChip, SDCard, and (WIP) USB by arm000, Alexander Horner and others
  • OpenBouffalo Firmware low_load drivers by Fishwaldo and others

Original Linux Images provided by Bouffalo - Very basic alpha build which are only fit for board bring up and testing purposes.

Toolchain:

  • elf_newlib_toolchain/bin/riscv64-unknown-elf-gcc (Xuantie-900 elf newlib gcc Toolchain V2.2.5 B-20220323) 10.2.0
  • linux_toolchain/bin/riscv64-unknown-linux-gnu-gcc (Xuantie-900 linux-5.10.4 glibc gcc Toolchain V2.2.4 B-20211227) 10.2.0
  • cmake version 3.19.3

Software Development Kits

SoC and Memory Specification

Bouffalo Lab icon.png

Based on the Bouffalo Lab BL808

BL808 Block Diagram.jpg

CPU Architecture

T-Head.png

T-Head C906 480 MHz 64-bit RISC-V CPU:

  • Supports RISC-V RV64IMAFCV instruction architecture
  • Five-stage single-issue sequentially executed pipeline
  • Level-1 instruction and data cache of Harvard architecture, with a size of 32 KB and a cache line of 64B
  • Sv39 memory management unit, realizing the conversion of virtual and real addresses and memory management
  • jTLB that supports 128 entries
  • Supports AXI 4.0 128-bit master interface
  • Supports core local interrupt (CLINT) and platform-level interrupt controller (PLIC)
  • With 80 external interrupt sources, 3 bits for configuring interrupt priority
  • Supports BHT (8K) and BTB
  • Compatible with RISC-V PMP, 8 configurable areas
  • Supports hardware performance monitor (HPM) units
  • See here

T-Head E907 320 MHz 32-bit RISC-V CPU:

  • Supports RISC-V RV32IMAFCP instruction set
  • Supports RISC-V 32-bit/16-bit mixed instruction set
  • Supports RISC-V machine mode and user mode
  • Thirty-two 32-bit integer general purpose registers (GPR) and thirty-two 32-bit/64-bit floating-point GPRs
  • Integer (5-stage)/floating-point (7-stage), single-issue, sequentially executed pipeline
  • Supports AXI 4.0 main device interface and AHB 5.0 peripheral interface
  • 32K instruction cache, two-way set associative structure
  • 16K data cache, two-way set associative structure
  • See here

T-Head E902 150 MHz 32-bit RISC-V CPU:

System Memory

  • Embedded 64MB PSRAM

Board Features

Network

  • 2.4 GHz 1T1R WiFi 802.11 b/g/n
  • Bluetooth 5.2
  • Zigbee
  • 10/100 Mbit/s Ethernet (optional, on expansion board)

Storage

  • On-board 16 Mbit (2 MB) or 128 Mbit (16 MB) XSPI NOR flash memory
  • MicroSD, supports SDHC and SDXC (only on the 128 Mbit version)

Expansion Ports

  • USB 2.0 OTG port
  • 26 GPIO pins, including SPI, I2C and UART functionality, possible I2S and GMII expansion
  • Dual-lane MiPi CSI port, located at USB-C port, for camera module

Audio

  • Microphone (optional, on the camera module)
  • Speaker (optional, on the camera module)

Board Information, Schematics and Certifications

Pinout for wiring ethernet PHY to EMAC
  • Baseboard dimensions: 51 mm x 21 mm x 19 mm x 3.5 mm (breadboard friendly)
  • Input power: 5 V, 0.5 A through the microUSB or USB-C ports

Production version schematic:

Prototype (dispatched to developers) schematic:

Certifications:

  • Disclaimer: Please note that PINE64 SBC is not a "final" product and in general certification is not necessary.
  • Not yet available

Datasheets for Components and Peripherals

Bouffalo BL808 SoC information:

SPI NOR Flash information:

Power Regulator information:

MicroSD socket information:

Compatible UARTs when in bootloader mode

When the Ox64 is in bootloader mode, some UARTs are unable to communicate with it. When this is the case, utilities such as BLDevCube are unable to actually program the device. If you see "Shake hand fail" and an empty ack, and your device is in bootloader mode, then it is likely an incompatible UART.

The below devices have been tested and verified as working:

  • Raspberry Pi Pico - running the following UART firmware (GP4 and GP5 are used for port 0, GP12 and GP13 for port 1)
  • Compiled binary for Pi Pico and connectivity diagram is here
  • ESP32 with CP210x - bridge the EN pin to ground to disable the ESP32 itself, and then connect the TX on the esp32 to 14 on the Ox64 and RX to pin 15. Note that only baud rate 115200 works, and this doesn't seem to work for everyone)
  • Stand-alone CP2102 dongle works at 115200 baud. Brand used was HiLetgo.
  • STM32F401 BlackPill - running the Black Magic Debug firmware
  • STM32F103C8T6 BluePill - running Black Magic Debug.
  • Some UART adapters based on the FT232H (note that the FT232RL does not work, and neither does the Pine 64 JTAG)
  • Some CH340G based adapters work and some don't.

Resources and Articles

Ox64 BL808 RISC-V SBC articles by Lup Yuen LEE:

Git repositories:

Development Efforts

Build

Open the terminal and create a new directory for the build:

mkdir buildroot_bouffalo && cd buildroot_bouffalo

Clone the primary Buildroot repository and the specific Buildroot Bouffalo repository:

git clone https://github.com/buildroot/buildroot
git clone https://github.com/openbouffalo/buildroot_bouffalo

Define an environment variable for the Buildroot Bouffalo overlay path:

export BR_BOUFFALO_OVERLAY_PATH=$(pwd)/buildroot_bouffalo

Change directory into the cloned Buildroot folder:

cd buildroot

Apply the default configuration for Pine64 Ox64:

make BR2_EXTERNAL=$BR_BOUFFALO_OVERLAY_PATH pine64_ox64_defconfig

Use the menuconfig tool to adjust build settings:

make menuconfig
target ABI setting
toolchain setting

Note: Within menuconfig:

  • Navigate to Target Architecture
  • Enable Integer Multiplication and Division (M)
  • Enable Atomic Instructions (A)
  • Enable Single-precision Floating-point (F)
  • Enable Double-precision Floating-point (D)
  • Set Target ABI to lp64d
  • Under Toolchain, enable Fortran support and OpenMP support

Initiate the build process:

make

Note: Before executing the make command, ensure your PATH variable doesn't have spaces.


Flashing Ox64 SBC and SD Card for Newbies

This section explains how to flash Ox64 board and the SD card to boot the system. The required skills are very basic and fit for newbies.

Prepare the Environment

You need a Linux machine, a Raspberry Pi Pico to act as a UART adapter, the Ox64 board, and a microSD card.

Start a terminal session and set the working directory to download some files

cd ~/Downloads
mkdir ox64 ox64/pico
cd ~/Downloads/ox64/pico
wget https://github.com/Kris-Sekula/Pine64_Ox64_SBC/blob/main/uart/picoprobe.uf2
cd ~/Downloads/ox64
mkdir ox64/devcube183
cd ~/Downloads/ox64/devcube183

Get the DevCube 1.8.3 flasher from one of mirrored servers, verify the hashes listed below, and decompress it:

  • SHA1: 0f2619e87d946f936f63ae97b0efd674357b1166
  • SHA256: e6e6db316359da40d29971a1889d41c9e97d5b1ff1a8636e9e6960b6ff960913
wget https://openbouffalo.org/static-assets/bldevcube/BouffaloLabDevCube-v1.8.3.zip
unzip BouffaloLabDevCube-v1.8.3.zip
chmod u+x BLDevCube-ubuntu

Download compressed file from https://github.com/openbouffalo/buildroot_bouffalo/releases/ and decompress it.

(You can also get the compressed the file from https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz)

cd ~/Downloads/ox64
mkdir openbouffalo && cd openbouffalo
wget https://github.com/openbouffalo/buildroot_bouffalo/releases/download/v1.0.1/bl808-linux-pine64_ox64_full_defconfig.tar.gz
tar -xvzf bl808-linux-pine64_ox64_full_defconfig.tar.gz

You'll get the following file and directory structure:

  |_ firmware/
  |_ firmware/m0_lowload_bl808_m0.bin
  |_ firmware/bl808-firmware.bin
  |_ firmware/d0_lowload_bl808_d0.bin
  |_ firmware/sdcard-pine64_ox64_full_defconfig.img.xz

Set Serial UART Communication from PC to Pi Pico and Ox64

Open a terminal and check the connected USB serial devices:

ls /dev/ttyACM*

Set the Raspberry Pi Pico board into programming mode:

  • Press the BootSel button
  • Apply power by plugging the USB cable to PC
  • Release the BootSel button

Note: you could also ground pin28 to TP6 while powering.

Copy picoprobe.uf2 file into the new device /media/<user>/RPI-RP2:

cp ~/Downloads/ox64/pico/picoprobe.uf2 /media/<user>/RPI-RP2

After flashing, the device will auto-set in serial UART communication mode according to the following wiring diagram.

Wiring Raspberry Pi Pico to Pine64 Ox64 SBC
ox64_pin1   <0rx-0tx>  pico_pin17
ox64_pin2   <0tx-0rx>  pico_pin16
ox64_pin31  <1tx-1rx>  pico_pin6
ox64_pin32  <1rx-1tx>  pico_pin7 
ox64_pin38  <-gnd->    pico_pin38/3    
ox64_pin40  <-vBus5v-> pico_pin40

Flash Your Ox64

There are two new ports to choose from, /dev/ttyACM0 and /dev/ttyACM1, use the lower number to monitor the serial console.

minicom -b 2000000 -D /dev/ttyACM0

Set the Ox64 board into programming mode:

  • Press the BOOT button
  • Apply power or re-plug the USB cable
  • Release the BOOT button

Close minicom. Open a new terminal window to run the DevCube flasher:

cd ~/Downloads/ox64/devcube183
./BLDevCube-ubuntu

Select chip [BL808], press Finish and switch to [MCU] tab

M0 Group[group0] Image Addr [0x58000000] [PATH to m0_lowload_bl808_m0.bin]
D0 Group[group0] Image Addr [0x58100000] [PATH to d0_lowload_bl808_d0.bin]
Interface: Uart
Port/SN: /dev/ttyACM1 (make sure you don't use ACM0, it's used by minicom console)
Uart rate 2000000
UART TX is physical pin 1/GPIO 14.
UART RX is physical pin 2/GPIO 15.
Click 'Create & Download' and wait until it's done

Switch to [IOT] tab:

Enable 'Single Download', set Address with 0x800000, choose [PATH to bl808-firmware.bin]
Port/SN: /dev/ttyACM1 (make sure you don't use ACM0, it's used by minicom console)
Click 'Create & Download' again and wait until it's done
Close DevCube

Open-Source Flashing via CLI

For those who do not want to use the DevCube, BouffaloLab provides open-source flashing packages bflb-iot-tool and bflb-mcu-tool.

Note: While these packages do contain binaries in addition to the Python source code, those binaries do not appear to be used for UART flashing.

Execute the following commands to flash the BL808. Note that the addresses are different to the ones you would use in the DevCube.

Reminder: UART TX is physical pin 1/GPIO 14, UART RX is physical pin 2/GPIO 15.

sudo pip install bflb-iot-tool --break-system-packages # we are *not* using bflb-mcu-tool

sudo bflb-iot-tool --chipname bl808 --interface uart --port /dev/ttyUSB0 --addr 0x000000 --firmware ~/Downloads/ox64/firmware/m0_lowload_bl808_m0.bin --single
sudo bflb-iot-tool --chipname bl808 --interface uart --port /dev/ttyUSB0 --addr 0x100000 --firmware ~/Downloads/ox64/firmware/d0_lowload_bl808_d0.bin --single
sudo bflb-iot-tool --chipname bl808 --interface uart --port /dev/ttyUSB0 --addr 0x800000 --firmware ~/Downloads/ox64/firmware/bl808-firmware.bin --single


Flash Your SD Card

Insert microSD card into PC, locate its device file (/dev/sdb, for example), erase the start of the card, and flash the SD card xxx.img file:

cd ~/Downloads/ox64/openbouffalo/firmware
xz -v -d -k sdcard-pine64_ox64_full_defconfig.img.xz
sudo dd if=/dev/zero of=/dev/sdb count=1 bs=32768 
sudo dd if=~/Downloads/ox64/openbouffalo/firmware/sdcard-pine64_ox64_full_defconfig.img of=/dev/sdb bs=1M status=progress conv=fsync

First Booting

Insert SD card into Ox64 and set a UART connection to the Ox64 board:

  • Serial console access:
  • UART TX is physical pin 32/GPIO 16.
  • UART RX is physical pin 31/GPIO 17.
  • Baud 2000000.

Choose from serial devices /dev/ttyACM0 and /dev/ttyACM1, using the higher number.

minicom -b 2000000 -D /dev/ttyACM1

Re-apply power to the Ox64 and enjoy the booting!