Introduction
Buildroot SDK V1
Duo's default SDK is built based on buildroot and is used to generate Duo's firmware. The SDK mainly contains the following parts:
- u-boot: 2021.10
- linux kernel: 5.10.4
- buildroot: 2021.05
- opensbi: 89182b2
Source code: https://github.com/milkv-duo/duo-buildroot-sdk
SDK Directory Structure
├── build // compilation scripts and board configs
├── build.sh // one-click compilation script
├── buildroot-2021.05 // buildroot source code
├── freertos // freertos system
├── fsbl // fsbl firmware in prebuilt form
├── install // temporary images stored here
├── isp_tuning // camera effect parameters
├── linux_5.10 // linux kernel
├── middleware // self-developed multimedia framework
├── device // configuration files for milkv
├── opensbi // opensbi library
├── out // final image for SD card
├── ramdisk // prebuilt ramdisk
└── u-boot-2021.10 // u-boot source code
The V1 version of SDK does not support the ARM core of Duo256M and DuoS. If you need to use the ARM core, please use the V2 version of SDK.
Buildroot SDK V2
The V2 version SDK adds support for Duo256M and DuoS ARM cores, and the compilation method is basically the same as the V1 version SDK.
Source code: https://github.com/milkv-duo/duo-buildroot-sdk-v2
Build image
Prepare the Compilation Environment. Using a local Ubuntu system, the officially supported compilation environment is Ubuntu Jammy 22.04.x amd64
only!
If you are using other Linux distributions, we strongly recommend that you use the Docker environment to compile to reduce the probability of compilation errors.
The following describes the compilation methods in the two environments.
1. Compiled using Ubuntu 22.04
Packages to be installed
Install the packages that compile dependencies:
sudo apt install -y pkg-config build-essential ninja-build automake autoconf libtool wget curl git gcc libssl-dev bc slib squashfs-tools android-sdk-libsparse-utils jq python3-distutils scons parallel tree python3-dev python3-pip device-tree-compiler ssh cpio fakeroot libncurses5 flex bison libncurses5-dev genext2fs rsync unzip dosfstools mtools tcl openssh-client cmake expect python-is-python3
For duo-buildroot-sdk-v2, you also need to install the following tool packages:
sudo pip install jinja2
Get SDK Source Code
git clone https://github.com/milkv-duo/duo-buildroot-sdk.git --depth=1
1). One-click Compilation
Execute one-click compilation script build.sh
:
cd duo-buildroot-sdk/
./build.sh
You will see tips on how to use the compiled script:
# ./build.sh
Usage:
./build.sh - Show this menu
./build.sh lunch - Select a board to build
./build.sh [board] - Build [board] directly, supported boards asfollows:
milkv-duo-sd
milkv-duo-spinand
milkv-duo-spinor
milkv-duo256m-sd
milkv-duo256m-spinand
milkv-duo256m-spinor
milkv-duos-emmc
milkv-duos-sd
Listed at the bottom is the list of currently supported target versions.
As shown in the prompt, there are two ways to compile the target version.
The first method is to execute ./build.sh lunch
to bring up the interactive menu, select the version number to be compiled, and press Enter:
# ./build.sh lunch
Select a target to build:
1. milkv-duo-sd
2. milkv-duo-spinand
3. milkv-duo-spinor
4. milkv-duo256m-sd
5. milkv-duo256m-spinand
6. milkv-duo256m-spinor
7. milkv-duos-emmc
8. milkv-duos-sd
Which would you like:
The second method is to put the name of the target version after the script and compile it directly. For example, if you need to compile the image of milkv-duo-sd
, the command is as follows:
# ./build.sh milkv-duo-sd
After a successful compilation, you can find the generated SD card burning image milkv-duo-sd-*-*.img
in the out
directory.
Note: The first compilation will automatically download the required toolchain, which is approximately 840MB in size. Once downloaded, it will be automatically extracted to the host-tools
directory in the SDK directory. For subsequent compilations, if the host-tools
directory is detected, the download will not be performed again.
2). Step-by-step Compilation
If you have not executed the one-click compilation script, you need to manually download the toolchain host-tools and extract it to the SDK root directory:
tar -xf host-tools.tar.gz -C /your/sdk/path/
Then enter the following commands in sequence to complete the step-by-step compilation. Replace [board]
and [config]
in the command with the version that needs to be compiled. The currently supported board
and corresponding config
are as follows:
milkv-duo-sd cv1800b_milkv_duo_sd
milkv-duo-spinand cv1800b_milkv_duo_spinand
milkv-duo-spinor cv1800b_milkv_duo_spinor
milkv-duo256m-sd cv1812cp_milkv_duo256m_sd
milkv-duo256m-spinand cv1812cp_milkv_duo256m_spinand
milkv-duo256m-spinor cv1812cp_milkv_duo256m_spinor
milkv-duos-emmc cv1813h_milkv_duos_emmc
milkv-duos-sd cv1813h_milkv_duos_sd
source device/[board]/boardconfig.sh
source build/milkvsetup.sh
defconfig [config]
clean_all
build_all
pack_sd_image
For example, if you need to compile the image of milkv-duo-sd
, the step-by-step compilation command is as follows:
source device/milkv-duo-sd/boardconfig.sh
source build/milkvsetup.sh
defconfig cv1800b_milkv_duo_sd
clean_all
build_all
pack_sd_image
Generated firmware location:
Duo: install/soc_cv1800b_milkv_duo_sd/[board].img
Duo256M: install/soc_cv1812cp_milkv_duo256m_sd/[board].img
2. Compiled using Docker
Docker support is required on hosts running Linux systems. For how to use Docker, please refer to the official documentation or other tutorials.
We put the SDK source code on the Linux host system and call the Docker image environment provided by Milk-V to compile it.