BL808 Buildroot

From OpenBouffalo
Revision as of 08:27, 14 May 2023 by Gamiee (talk | contribs) (Restoring backup, author: Hunter1753)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Setting up a buildroot environment for the BL808 soc is an essential step for developing custom Linux-based firmware and applications. This guide aims to provide step-by-step instructions on how to set up a buildroot environment tailored specifically for the BL808 chip, including the necessary tools, configurations, and dependencies required for a successful build.

Whether you're a beginner or an experienced developer, this guide will help you get started with building your own firmware for the BL808 RISC-V chip.

Overview

Requirements
Ensure that necessary tools and packages such as git, make, gcc, ncurses, etc. are installed.
Get Buildroot and Setup
Download the Buildroot sources, set up the environment variable for Buildroot to find the overlay, and navigate to the Buildroot directory.
Load Default Configuration
Load the configuration file for the Pine64 Ox64 board into the default '.config' file.
Menuconfig (Optional)
Optionally configure the Buildroot environment using 'make menuconfig'.
Build
Build the Buildroot environment using 'make', which may take some time depending on the system.
Output
After a successful build, the output files will be located in 'buildroot_bouffalo/buildroot/output/images/' directory.

Requirements

In order to set up a buildroot environment for the BL808 RISC-V chip, you will need to ensure that the following tools and packages are installed on your system:

Source Tools

  • git

Build Tools

  • which
  • sed
  • make (version 3.81 or later)
  • binutils
  • build-essential (only for Debian based systems)
  • diffutils
  • gcc (version 4.8 or later)
  • g++ (version 4.8 or later, mostly installed with gcc)
  • bash
  • patch
  • gzip
  • bzip2
  • perl (version 5.8.7 or later)
  • tar
  • cpio
  • unzip
  • rsync
  • file (must be in /usr/bin/file)
  • bc
  • findutils
  • wget

Config Tools

  • ncurses5 (could also be just called ncurses, ncurses-dev, etc.)

Make sure to have all the above tools and packages installed before proceeding with the buildroot setup process.

Get Buildroot and Setup

Download the sources

$ mkdir buildroot_bouffalo && cd buildroot_bouffalo
$ git clone https://github.com/buildroot/buildroot
$ git clone https://github.com/openbouffalo/buildroot_bouffalo

Set the environment variable for buildroot to find our buildroot_bouffalo overlay

$ export BR_BOUFFALO_OVERLAY_PATH=$(pwd)/buildroot_bouffalo

change into the buildroot directory

$ cd buildroot

Load Default Configuration

This loads the configuration file for the Pine64 Ox64 into the default .config file

$ make BR2_EXTERNAL=$BR_BOUFFALO_OVERLAY_PATH pine64_ox64_defconfig

Menuconfig (Optional)

From here you can just skip to the #Build step or configure the buildroot environment how you like with

$ make menuconfig

Build

Now that we have a .config file we can build the buildroot environment with

$ make

this can take from minutes to hours depending on your system (especially downloading the Xuantie compiler as it is ~500MB big)

Note
By default, Buildroot does not support top-level parallel build, so running make -jN is not necessary.
Things in the build that can be parallelized will use all existing cores.

Output

After a successful build we will have the files placed in buildroot_bouffalo/buildroot/output/images

$ cd output/images/
# ls -l
total 210116
-rw-r--r-- 1 root root   13154816 Apr 25 21:33 Image
-rw-r--r-- 1 root root    7340032 Apr 25 21:35 bl808-firmware.bin
-rwxr-xr-x 1 root root       4012 Apr 25 21:33 bl808-pine64-ox64.dtb
-rwxr-xr-x 1 root root       4106 Apr 25 21:33 bl808-sipeed-m1s.dtb
-rw-r--r-- 1 root root        350 Apr 25 21:35 boot-m1s.scr
-rw-r--r-- 1 root root        352 Apr 25 21:35 boot-pine64.scr
-rwxr-xr-x 1 root root        352 Apr 25 21:35 boot.scr
-rw-r--r-- 1 root root  209715200 Apr 25 21:35 boot.vfat
-rwxr-xr-x 1 root root      31360 Apr 25 21:35 d0_lowload_bl808_d0.bin
-rwxr-xr-x 1 root root       4352 Apr 25 21:35 efusedata.bin
-rwxr-xr-x 1 root root        256 Apr 25 21:35 efusedata_mask.bin
-rwxr-xr-x 1 root root        256 Apr 25 21:35 efusedata_raw.bin
drwxr-xr-x 2 root root       4096 Apr 25 21:35 extlinux
-rw-r--r-- 1 root root     109864 Apr 25 21:32 fw_jump.bin
-rw-r--r-- 1 root root    1200416 Apr 25 21:32 fw_jump.elf
-rwxr-xr-x 1 root root      65760 Apr 25 21:35 m0_lowload_bl808_m0.bin
-rw-r--r-- 1 root root  536870912 Apr 25 21:35 rootfs.ext2
lrwxrwxrwx 1 root root         11 Apr 25 21:35 rootfs.ext4 -> rootfs.ext2
-rw-r--r-- 1 root root   50247680 Apr 25 21:35 rootfs.tar
-rw-r--r-- 1 root root 1820364800 Apr 25 21:35 sdcard.img
-rw-r--r-- 1 root root     519746 Apr 25 21:32 u-boot.bin
-rw-r--r-- 1 root root     315597 Apr 25 21:32 u-boot.bin.lz4
-rw-r--r-- 1 root root      14314 Apr 25 21:32 u-boot.dtb

The files we care about are

  • bl808-firmware.bin
  • d0_lowload_bl808_d0.bin
  • m0_lowload_bl808_m0.bin
  • sdcard.img

The other files are just build artifacts

Finish

Congratulations you built buildroot by yourself!

Continuing

All Steps to Achieve a build on Arch

These commands were run in this order on a fresh Arch install

$ cd ~
$ mkdir buildroot_bouffalo && cd buildroot_bouffalo
$ pacman -Syu git which sed make binutils diffutils gcc bash patch gzip bzip2 perl tar cpio unzip rsync file bc findutils wget ncurses
$ git clone https://github.com/buildroot/buildroot
$ git clone https://github.com/openbouffalo/buildroot_bouffalo
$ export BR_BOUFFALO_OVERLAY_PATH=$(pwd)/buildroot_bouffalo
$ cd buildroot
$ make BR2_EXTERNAL=$BR_BOUFFALO_OVERLAY_PATH pine64_ox64_defconfig
$ make menuconfig
$ make
$ cd output/images/
$ ls

All Steps to Achieve a build on Debian

These commands were run in this order on a fresh Debian install

$ cd ~
$ mkdir buildroot_bouffalo && cd buildroot_bouffalo
$ sudo apt update
$ sudo apt install git sed make binutils diffutils gcc g++ bash patch gzip bzip2 perl tar cpio unzip rsync file bc findutils wget libncurses-dev libssl-dev
$ git clone https://github.com/buildroot/buildroot
$ git clone https://github.com/openbouffalo/buildroot_bouffalo
$ export BR_BOUFFALO_OVERLAY_PATH=$(pwd)/buildroot_bouffalo
$ cd buildroot
$ make BR2_EXTERNAL=$BR_BOUFFALO_OVERLAY_PATH pine64_ox64_defconfig
$ make menuconfig
$ make
$ cd output/images/
$ ls