Commit 582517d2 authored by carbon's avatar carbon

Using Docker compilation environment

parent 35f9a798
......@@ -32,43 +32,44 @@ Milk-V DuoはCV1800Bをベースにした超小型の組み込みプラットフ
# クイックスタート
## コンパイル環境の準備
Prepare the Compilation Environment. Using a local Ubuntu system, the officially supported compilation environment is `Ubuntu Jammy 22.04.x amd64` only!
- 公式にサポートされているコンパイル環境は、`Ubuntu Jammy 22.04.x amd64` のみです。
- `mobaXterm`とか`Xshell`のようなシリアルポートツールをインストールしてください
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.
### Ubuntu 22.04 LTSに必要なツール
The following describes the compilation methods in the two environments.
依存関係をコンパイルするためにインストールするもの
## 1. Compiled using Ubuntu 20.04
### Packages to be installed
Install the packages that compile dependencies:
```bash
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
```
## イメージのコンパイル
### SDKのソースコードをダウンロード
### Get SDK Source Code
```bash
git clone https://github.com/milkv-duo/duo-buildroot-sdk.git --depth=1
```
### 自動コンパイル
### <1>. One-click Compilation
- 自動コンパイルスクリプト`build_milkv.sh`を実行
- Execute the one-click compilation script `build_milkv.sh`:
```
cd duo-buildroot-sdk/
./build_milkv.sh
```
- 正常にコンパイルされるとSDカード用イメージ`milkv-duo-*-*.img``out`ディレクトリの中に出てきます。
- After a successful compilation, you can find the generated SD card burning image `milkv-duo-*-*.img` in the `out` directory.
*注意:最初のコンパイル時に必要なツールチェーン(およそ840MB)が自動でダウンロードされます。一度ダウンロードされると`host-tools`内に自動で展開されます。以後のコンパイルでは`host-tools`ディレクトリがある場合再びダウンロードはされません。*
*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 wish to perform step-by-step compilation, you can enter the following commands sequentially:
```bash
export MILKV_BOARD=milkv-duo
......@@ -81,7 +82,150 @@ build_all
pack_sd_image
```
生成されたイメージは`install/soc_cv1800b_milkv_duo_sd/milkv-duo.img`に出てきます。
Location of the generated image: `install/soc_cv1800b_milkv_duo_sd/milkv-duo.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](https://docs.docker.com/) 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.
### Pull SDK code on Linux host
```
git clone https://github.com/milkv-duo/duo-buildroot-sdk.git --depth=1
```
### Enter the SDK code directory
```
cd duo-buildroot-sdk
```
### Pull the Docker image and run
```
docker run -itd --name duodocker -v $(pwd):/home/work milkvtech/milkv-duo:latest /bin/bash
```
Description of some parameters in the command:
- `duodocker` Docker name, you can use the name you want to use.
- `$(pwd)` The current directory, here is the duo-buildroot-sdk directory that was 'cd' to in the previous step.
- `-v $(pwd):/home/work` Bind the current code directory to the /home/work directory in the Docker image.
- `milkvtech/milkv-duo:latest` The Docker image provided by Milk-V will be automatically downloaded from hub.docker.com for the first time.
After Docker runs successfully, you can use the `docker ps -a` command to view the running status:
```
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8edea33c2239 milkvtech/milkv-duo:latest "/bin/bash" 2 hours ago Up 2 hours duodocker
```
### <1>. One-click compilation using Docker
```
docker exec duodocker /bin/bash -c "cd /home/work && cat /etc/issue && ./build_milkv.sh"
```
Description of some parameters in the command:
- `duodocker` The name of the running Docker must be consistent with the name set in the previous step.
- `"*"` In quotes is the shell command to be run in the Docker image.
- `cd /home/work` Switch to the /home/work directory. Since this directory has been bound to the host's code directory during runtime, the /home/work directory in Docker is the source code directory of the SDK.
- `cat /etc/issue` Displays the version number of the image used by Docker. It is currently Ubuntu 22.04.3 LTS and is used for debugging.
- `./build_milkv.sh` Execute one-click compilation script.
After successful compilation, you can see the generated SD card burning image `milkv-duo-*-*.img` in the `out` directory.
### <2>. Compile step by step using Docker
Step-by-step compilation requires logging into Docker to operate. Use the command `docker ps -a` to view and record the ID number of the container, such as 8edea33c2239.
Enter Docker:
```
docker exec -it 8edea33c2239 /bin/bash
```
Enter the code directory bound in Docker:
```
root@8edea33c2239:/# cd /home/work/
```
Compile step by step:
```bash
export MILKV_BOARD=milkv-duo
source milkv/boardconfig-milkv-duo.sh
source build/milkvsetup.sh
defconfig cv1800b_milkv_duo_sd
clean_all
build_all
pack_sd_image
```
Generated firmware location: `install/soc_cv1800b_milkv_duo_sd/milkv-duo.img`.
After compilation is completed, you can use the `exit` command to exit the Docker environment:
```
root@8edea33c2239:/home/work# exit
```
The generated firmware can also be seen in the host code directory.
### Stop Docker
After compilation is completed, if the above Docker running environment is no longer needed, you can stop it first and then delete it:
```
docker stop 8edea33c2239
docker rm 8edea33c2239
```
## Other compilation considerations
If you want to try to compile this SDK in an environment other than the above two environments, the following are things you may need to pay attention to, for reference only.
### cmake version
Note:`cmake` minimum version requirement is `3.16.5`.
Check the version of `cmake` in the system:
```bash
cmake --version
```
For example, the version of `cmake` installed using apt in the `Ubuntu 20.04` is:
```
cmake version 3.16.3
```
The minimum requirement of this SDK is not met. Manual installation of the latest version `3.27.6` is needed:
```bash
wget https://github.com/Kitware/CMake/releases/download/v3.27.6/cmake-3.27.6-linux-x86_64.sh
chmod +x cmake-3.27.6-linux-x86_64.sh
sudo sh cmake-3.27.6-linux-x86_64.sh --skip-license --prefix=/usr/local/
```
When manually installed, `cmake` is located in `/usr/local/bin`. To check its version, use the command `cmake --version`, which should display:
```
cmake version 3.27.6
```
### Compiling with Windows Linux Subsystem (WSL)
If you wish to perform the compilation with WSL, there's an small issue building the image.
The $PATH, due Windows interoperability, has Windows environment variables which include some spaces between the paths.
To solve this problem you need to change the `/etc/wsl.conf` file and add the following lines:
```
[interop]
appendWindowsPath = false
```
After that, you need to reboot the WSL with `wsl.exe --reboot`. Then you able to run the `./build_milkv.sh` script or the `build_all` line in the step-by-step compilation method.
To rollback this change in `/etc/wsl.conf` file set `appendWindowsPath` as true. To reboot the WSL, can you use the Windows PowerShell command `wsl.exe --shutdown` then `wsl.exe`, after that the Windows environment variables become avaliable again in $PATH.
## SDカードへの書き込み
......@@ -98,7 +242,7 @@ pack_sd_image
- Milk-V DuoのmicroSDカードスロットにmicroSDカードを挿入します。
- シリアルケーブルを接続します。(必ずしも必要ではありません)
- 電源に接続するとシステムが立ち上がります。
- シリアルケーブルが接続されている場合、ブートログをシリアルコンソールから見ることができます。システムが立ち上がればコンソールからログインしてLinuxコマンドを実行できます。
- シリアルケーブルが接続されている場合、ブートログをシリアルコンソールから見ることができます(`mobarXterm``Xshell` など)。システムが立ち上がればコンソールからログインしてLinuxコマンドを実行できます。
### Duoのターミナルに入る方法
......
......@@ -3,7 +3,7 @@
# 项目简介
Milk-V Duo是一个基于CV1800B芯片的超紧凑嵌入式开发平台。它可以运行Linux和RTOS,为专业人士、工业ODM厂商、AIoT爱好者、DIY爱好者和创作者提供了一个可靠、低成本和高性能的平台。
Milk-V Duo 是一个基于 CV1800B 芯片的超紧凑嵌入式开发平台。它可以运行 Linux 和RTOS,为专业人士、工业 ODM 厂商、AIoT 爱好者、DIY 爱好者和创作者提供了一个可靠、低成本和高性能的平台。
## 硬件参数
......@@ -16,59 +16,138 @@ Milk-V Duo是一个基于CV1800B芯片的超紧凑嵌入式开发平台。它可
```text
├── build // 编译目录,存放编译脚本以及各board差异化配置
├── build_milkv.sh // Milk-V Duo 一键编译脚本
├── buildroot-2021.05 // buildroot开源工具
├── freertos // freertos系统
├── fsbl // fsbl启动固件,prebuilt形式存在
├── install // 执行一次完整编译后,临时存放各image路径
├── buildroot-2021.05 // buildroot 开源工具
├── freertos // freertos 系统
├── fsbl // fsbl启动固件,prebuilt 形式存在
├── install // 执行一次完整编译后,临时存放各 image 路径
├── isp_tuning // 图像效果调试参数存放路径
├── linux_5.10 // 开源linux内核
├── middleware // 自研多媒体框架,包含so与ko
├── linux_5.10 // 开源 linux 内核
├── middleware // 自研多媒体框架,包含 so 与 ko
├── milkv // 存放 Milk-V Duo 相关配置及脚本文件的目录
├── opensbi // 开源opensbi
├── out // Milk-V Duo 最终生成的SD卡烧录镜像所在目录
├── ramdisk // 存放最小文件系统的prebuilt目录
└── u-boot-2021.10 // 开源uboot代码
├── opensbi // 开源 opensbi
├── out // Milk-V Duo 最终生成的 SD 卡烧录镜像所在目录
├── ramdisk // 存放最小文件系统的 prebuilt 目录
└── u-boot-2021.10 // 开源 uboot 代码
```
# 快速开始
## 准备编译环境
准备编译环境,使用本地的 Ubuntu 系统,官方支持的编译环境为 `Ubuntu Jammy 22.04.x amd64`
- 使用本地的Ubuntu系统,官方支持的编译环境是 `Ubuntu Jammy 22.04.x amd64`
- 安装串口工具: `mobarXterm` 或者 `Xshell` 或者其他。
如果您使用的是其他的 Linux 发行版,我们强烈建议您使用 Docker 环境来编译,以降低编译出错的概率。
### Ubuntu 22.04 LTS 下需要安装的工具包
以下分别介绍两种环境下的编译方法。
安装编译依赖的工具包:
## 一、使用 Ubuntu 20.04 编译
### 安装编译依赖的工具包
```bash
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
```
## 编译
### 获取SDK
### 获取 SDK
```
git clone https://github.com/milkv-duo/duo-buildroot-sdk.git --depth=1
```
### 一键编译
### 1、一键编译
- 执行一键编译脚本`build_milkv.sh`
- 执行一键编译脚本 `build_milkv.sh`
```bash
cd duo-buildroot-sdk/
./build_milkv.sh
```
- 编译成功后可以在 `out` 目录下看到生成的SD卡烧录镜像 `milkv-duo-*-*.img`
- 编译成功后可以在 `out` 目录下看到生成的SD卡烧录镜像 `milkv-duo-*-*.img`
*注: 第一次编译会自动下载所需的工具链,大小为 840M 左右,下载完会自动解压到 SDK 目录下的 `host-tools` 目录,下次编译时检测到已存在 `host-tools` 目录,就不会再次下载了*
### 2、分步编译
可依次输入如下命令:
```bash
export MILKV_BOARD=milkv-duo
source milkv/boardconfig-milkv-duo.sh
source build/milkvsetup.sh
defconfig cv1800b_milkv_duo_sd
clean_all
build_all
pack_sd_image
```
生成的固件位置: `install/soc_cv1800b_milkv_duo_sd/milkv-duo.img`
## 二、使用 Docker 编译
需要在运行 Linux 系统的主机上支持 Docker。 Docker 的使用方法请参考[官方文档](https://docs.docker.com/)或其他教程。
我们将 SDK 代码放在 Linux 主机系统上,调用 Milk-V 提供的 Docker 镜像环境来编译。
### 在 Linux 主机上拉 SDK 代码
```
git clone https://github.com/milkv-duo/duo-buildroot-sdk.git --depth=1
```
### 进入 SDK 代码目录
```
cd duo-buildroot-sdk
```
### 拉取 Docker 镜像并运行
```
docker run -itd --name duodocker -v $(pwd):/home/work milkvtech/milkv-duo:latest /bin/bash
```
命令中部分参数说明:
- `duodocker` docker 运行时名字,可以使用自己想用的名字
- `$(pwd)` 当前目录,这里是上一步 cd 到的 duo-buildroot-sdk 目录
- `-v $(pwd):/home/work` 将当前的代码目录绑定到 Docker 镜像里的 /home/work 目录
- `milkvtech/milkv-duo:latest` Milk-V 提供的 Docker 镜像,第一次会自动从 hub.docker.com 下载
Docker 运行成功后,可以用 `docker ps -a` 命令查看运行状态:
```
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8edea33c2239 milkvtech/milkv-duo:latest "/bin/bash" 2 hours ago Up 2 hours duodocker
```
*注: 第一次编译会自动下载所需的工具链,大小为 840M 左右,下载完会自动解压到 SDK 目录下的`host-tools`目录,下次编译时检测到已存在`host-tools`目录,就不会再次下载了*
### 1. 使用 Docker 一键编译
### 分步编译
```
docker exec duodocker /bin/bash -c "cd /home/work && cat /etc/issue && ./build_milkv.sh"
```
命令中部分参数说明:
- `duodocker` 运行的 Docker 名字, 与上一步中设置的名字要保持一致
- `"*"` 双引号中是要在 Docker 镜像中运行的 Shell 命令
- `cd /home/work` 是切换到 /home/work 目录,由于运行时已经将该目录绑定到主机的代码目录,所以在 Docker 中 /home/work 目录就是该 SDK 的源码目录
- `cat /etc/issue` 显示 Docker 使用的镜像的版本号,目前是 Ubuntu 22.04.3 LTS,调试用
- `./build_milkv.sh` 执行一键编译脚本
编译成功后可以在 `out` 目录下看到生成的SD卡烧录镜像 `milkv-duo-*-*.img`
### 2. 使用 Docker 分步编译
可依次输入如下命令
分步编译需要登陆到 Docker 中进行操作,用命令 `docker ps -a` 查看并记录容器的 ID 号,比如 8edea33c2239。
登陆到 Docker 中:
```
docker exec -it 8edea33c2239 /bin/bash
```
进入 Docker 中绑定的代码目录:
```
root@8edea33c2239:/# cd /home/work/
```
分步编译:
```bash
export MILKV_BOARD=milkv-duo
source milkv/boardconfig-milkv-duo.sh
......@@ -80,31 +159,78 @@ build_all
pack_sd_image
```
生成的固件位置: `install/soc_cv1800b_milkv_duo_sd/milkv-duo.img`
生成的固件位置: `install/soc_cv1800b_milkv_duo_sd/milkv-duo.img`
编译完成后可以用 `exit` 命令退出 Docker 环境:
```
root@8edea33c2239:/home/work# exit
```
在主机代码目录中同样也可以看到生成的固件。
### 停用 Docker
编译完成后,如果不再需要以上的 Docker 运行环境,可先将其停止,再删除:
```
docker stop 8edea33c2239
docker rm 8edea33c2239
```
## 其他编译注意事项
如果您想尝试在以上两种环境之外的环境下编译本 SDK,下面是可能需要注意的事项,仅供参考。
### cmake 版本号
注意:`cmake` 版本最低要求 `3.16.5`
查看系统中 `cmake` 的版本号
```bash
cmake --version
```
比如在`Ubuntu 20.04`中用 apt 安装的 cmake 版本号为
```text
cmake version 3.16.3
```
不满足此SDK最低要求,需要手动安装目前最新的 `3.27.6` 版本
```
wget https://github.com/Kitware/CMake/releases/download/v3.27.6/cmake-3.27.6-linux-x86_64.sh
chmod +x cmake-3.27.6-linux-x86_64.sh
sudo sh cmake-3.27.6-linux-x86_64.sh --skip-license --prefix=/usr/local/
```
手动安装的 `cmake``/usr/local/bin` 中,此时用 `cmake --version` 命令查看其版本号, 应为
```
cmake version 3.27.6
```
## SD卡烧录
> 注意: 将镜像写入TF卡会擦除卡中原有数据,记得在烧录前备份重要的数据!!!
- Window下使用`balenaEtcher`或者`Rufus`或者`Win32 Disk Imager`等工具将生成的镜像写入TF卡中
- Linux下使用`dd`命令将生成的镜像写入TF卡中,**请务必仔细确认`of`设备`/dev/sdX`为要烧录的TF卡**
> 注意: 将镜像写入 TF 卡会擦除卡中原有数据,记得在烧录前备份重要的数据!!!
- Window 下使用 `balenaEtcher` 或者 `Rufus` 或者 `Win32 Disk Imager` 等工具将生成的镜像写入 TF 卡中
- Linux 下使用 `dd` 命令将生成的镜像写入 TF 卡中,**请务必仔细确认 `of` 设备 `/dev/sdX` 为要烧录的 TF 卡**
```bash
sudo dd if=milkv-duo-XXX.img of=/dev/sdX
```
## 开机
- 将烧录好镜像的TF卡插入 Milk-V Duo 的TF卡槽中
- 将烧录好镜像的 TF 卡插入 Milk-V Duo 的 TF 卡槽中
- 接好串口线(可选)
- 将平台上电,Duo会正常开机进入系统
- 如有接串口线,在串口工具中可以看到开机日志,进系统后可通过串口登入终端,执行Linux下的相关命令
- 将平台上电,Duo 会正常开机进入系统
- 如有接串口线,在串口工具(`mobarXterm`, `Xshell` 或者其他)中可以看到开机日志,进系统后可通过串口登入终端,执行 Linux 下的相关命令
### 登陆到 Duo 终端的方法
- 通过串口线
- 通过USB网卡(RNDIS)方式
- 通过 USB 网卡 (RNDIS) 方式
- 通过以太网接口(需要扩展板支持)
登陆Duo终端的用户名和密码分别为
登陆 Duo 终端的用户名和密码分别为:
```
root
......@@ -118,48 +244,48 @@ milkv
```bash
mv /mnt/system/blink.sh /mnt/system/blink.sh_backup && sync
```
也就是将 LED 闪烁脚本改名,重启 Duo 后,LED 就不闪了
也就是将 LED 闪烁脚本改名,重启 Duo 后,LED 就不闪了
如果需要恢复 LED 闪烁,再将其名字改回来,重启即可
如果需要恢复 LED 闪烁,再将其名字改回来,重启即可
```bash
mv /mnt/system/blink.sh_backup /mnt/system/blink.sh && sync
```
### 使用 IO Board 底板
注意,使用 IO Board 底板时,USB网卡(RNDIS)不可用,如需使用网络功能,请使用底板上的以太网接口
注意,使用 IO Board 底板时,USB 网卡 (RNDIS) 不可用,如需使用网络功能,请使用底板上的以太网接口。
使用底板上的4个USB口,需要修改一下配置,将默认固件中的`usb-rndis`功能修改为`usb-host`
使用底板上的 4 个 USB 口,需要修改一下配置,将默认固件中的 `usb-rndis` 功能修改为 `usb-host`
```bash
rm /mnt/system/usb.sh
ln -s /mnt/system/usb-host.sh /mnt/system/usb.sh
sync
```
修改完,重启或重新上电即可生效
修改完,重启或重新上电即可生效
比如底板USB口接入U盘后,可以用`ls /dev/sd*`查看是否有检测到设备
比如底板 USB 口接入 U 盘后,可以用 `ls /dev/sd*` 查看是否有检测到设备。
挂载到系统中查看U盘中的内容(以/dev/sda1为例):
挂载到系统中查看U盘中的内容(以 `/dev/sda1` 为例):
```bash
mkdir /mnt/udisk
mount /dev/sda1 /mnt/udisk
```
查看`/mnt/udisk`目录中的内容是否符合预期
查看 `/mnt/udisk` 目录中的内容是否符合预期:
```bash
ls /mnt/udisk
```
卸载U盘的命令
卸载U盘的命令
```bash
umount /mnt/udisk
```
不使用底板时,恢复USB网卡(RNDIS)的方法
不使用底板时,恢复 USB 网卡 (RNDIS) 的方法:
```bash
rm /mnt/system/usb.sh
......@@ -167,17 +293,17 @@ ln -s /mnt/system/usb-rndis.sh /mnt/system/usb.sh
sync
```
修改完,需要重启或重新上电生效
修改完,需要重启或重新上电生效
# 常见问题解答
1. 为什么只显示单核?
CV1800B芯片采用双核设计,当前Linux系统运行在其中的一个核上,另外一个核用来运行实时系统,这个核的SDK尚未公布,待后续更新
CV1800B 芯片采用双核设计,当前 Linux 系统运行在其中的一个核上,另外一个核用来运行实时系统,这个核的 SDK 尚未公布,待后续更新。
2. 为什么查看RAM只显示28M?
2. 为什么查看 RAM 只显示 28M?
因为有一部分RAM被分配绐了 [ION](https://github.com/milkv-duo/duo-buildroot-sdk/blob/develop/build/boards/default/dts/cv180x/cv180x_default_memmap.dtsi#L15),是在使用摄像头跑算法时需要占用的内存。如果不使用摄像头,您可以修改这个 [ION_SIZE](https://github.com/milkv-duo/duo-buildroot-sdk/blob/develop/build/boards/cv180x/cv1800b_milkv_duo_sd/memmap.py#L43) 的值为`0`然后重新编译生成固件。
因为有一部分RAM被分配绐了 [ION](https://github.com/milkv-duo/duo-buildroot-sdk/blob/develop/build/boards/default/dts/cv180x/cv180x_default_memmap.dtsi#L15),是在使用摄像头跑算法时需要占用的内存。如果不使用摄像头,您可以修改这个 [ION_SIZE](https://github.com/milkv-duo/duo-buildroot-sdk/blob/develop/build/boards/cv180x/cv1800b_milkv_duo_sd/memmap.py#L43) 的值为 `0` 然后重新编译生成固件。
## 芯片原厂一些资料的链接
......
......@@ -32,12 +32,15 @@ Milk-V Duo is an ultra-compact embedded development platform based on the CV1800
# Quick Start
## Prepare the Compilation Environment
Prepare the Compilation Environment. Using a local Ubuntu system, the officially supported compilation environment is `Ubuntu Jammy 22.04.x amd64` only!
- Using a local Ubuntu system, the officially supported compilation environment is `Ubuntu Jammy 22.04.x amd64` only!
- Install a serial port tool: `mobaXterm` or `Xshell` or others.
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.
### Packages to be installed on Ubuntu 22.04 LTS
The following describes the compilation methods in the two environments.
## 1. Compiled using Ubuntu 20.04
### Packages to be installed
Install the packages that compile dependencies:
......@@ -45,46 +48,109 @@ 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
```
### Compiling with Windows Linux Subsystem (WSL)
### Get SDK Source Code
If you wish to perform the compilation with WSL, there's an small issue building the image.
The $PATH, due Windows interoperability, has Windows environment variables which include some spaces between the paths.
```bash
git clone https://github.com/milkv-duo/duo-buildroot-sdk.git --depth=1
```
To solve this problem you need to change the `/etc/wsl.conf` file and add the following lines:
### <1>. One-click Compilation
```bash
[interop]
appendWindowsPath = false
- Execute the one-click compilation script `build_milkv.sh`:
```
cd duo-buildroot-sdk/
./build_milkv.sh
```
After that, you need to reboot the WSL with `wsl.exe --reboot`. Then you able to run the `./build_milkv.sh` script or the `build_all` line in the step-by-step compilation method.
To rollback this change in `/etc/wsl.conf` file set `appendWindowsPath` as true. To reboot the WSL, can you use the Windows PowerShell command `wsl.exe --shutdown` then `wsl.exe`, after that the Windows environment variables become avaliable again in $PATH.
- After a successful compilation, you can find the generated SD card burning image `milkv-duo-*-*.img` in the `out` directory.
## Compile the Image
*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*.
### Get SDK Source Code
### <2>. Step-by-step Compilation
If you wish to perform step-by-step compilation, you can enter the following commands sequentially:
```bash
export MILKV_BOARD=milkv-duo
source milkv/boardconfig-milkv-duo.sh
source build/milkvsetup.sh
defconfig cv1800b_milkv_duo_sd
clean_all
build_all
pack_sd_image
```
Location of the generated image: `install/soc_cv1800b_milkv_duo_sd/milkv-duo.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](https://docs.docker.com/) 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.
### Pull SDK code on Linux host
```
git clone https://github.com/milkv-duo/duo-buildroot-sdk.git --depth=1
```
### One-click Compilation
### Enter the SDK code directory
- Execute the one-click compilation script `build_milkv.sh`
```
cd duo-buildroot-sdk
```
### Pull the Docker image and run
```
cd duo-buildroot-sdk/
./build_milkv.sh
docker run -itd --name duodocker -v $(pwd):/home/work milkvtech/milkv-duo:latest /bin/bash
```
Description of some parameters in the command:
- `duodocker` Docker name, you can use the name you want to use.
- `$(pwd)` The current directory, here is the duo-buildroot-sdk directory that was 'cd' to in the previous step.
- `-v $(pwd):/home/work` Bind the current code directory to the /home/work directory in the Docker image.
- `milkvtech/milkv-duo:latest` The Docker image provided by Milk-V will be automatically downloaded from hub.docker.com for the first time.
After Docker runs successfully, you can use the `docker ps -a` command to view the running status:
```
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8edea33c2239 milkvtech/milkv-duo:latest "/bin/bash" 2 hours ago Up 2 hours duodocker
```
### <1>. One-click compilation using Docker
```
docker exec duodocker /bin/bash -c "cd /home/work && cat /etc/issue && ./build_milkv.sh"
```
Description of some parameters in the command:
- `duodocker` The name of the running Docker must be consistent with the name set in the previous step.
- `"*"` In quotes is the shell command to be run in the Docker image.
- `cd /home/work` Switch to the /home/work directory. Since this directory has been bound to the host's code directory during runtime, the /home/work directory in Docker is the source code directory of the SDK.
- `cat /etc/issue` Displays the version number of the image used by Docker. It is currently Ubuntu 22.04.3 LTS and is used for debugging.
- `./build_milkv.sh` Execute one-click compilation script.
After successful compilation, you can see the generated SD card burning image `milkv-duo-*-*.img` in the `out` directory.
- After a successful compilation, you can find the generated SD card burning image `milkv-duo-*-*.img` in the `out` directory
### <2>. Compile step by step using Docker
*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*
Step-by-step compilation requires logging into Docker to operate. Use the command `docker ps -a` to view and record the ID number of the container, such as 8edea33c2239.
### Step-by-step Compilation
Enter Docker:
```
docker exec -it 8edea33c2239 /bin/bash
```
If you wish to perform step-by-step compilation, you can enter the following commands sequentially
Enter the code directory bound in Docker:
```
root@8edea33c2239:/# cd /home/work/
```
Compile step by step:
```bash
export MILKV_BOARD=milkv-duo
source milkv/boardconfig-milkv-duo.sh
......@@ -96,29 +162,92 @@ build_all
pack_sd_image
```
Location of the generated image: `install/soc_cv1800b_milkv_duo_sd/milkv-duo.img`
Generated firmware location: `install/soc_cv1800b_milkv_duo_sd/milkv-duo.img`.
After compilation is completed, you can use the `exit` command to exit the Docker environment:
```
root@8edea33c2239:/home/work# exit
```
The generated firmware can also be seen in the host code directory.
### Stop Docker
After compilation is completed, if the above Docker running environment is no longer needed, you can stop it first and then delete it:
```
docker stop 8edea33c2239
docker rm 8edea33c2239
```
## Other compilation considerations
If you want to try to compile this SDK in an environment other than the above two environments, the following are things you may need to pay attention to, for reference only.
### cmake version
Note:`cmake` minimum version requirement is `3.16.5`.
Check the version of `cmake` in the system:
```bash
cmake --version
```
For example, the version of `cmake` installed using apt in the `Ubuntu 20.04` is:
```
cmake version 3.16.3
```
The minimum requirement of this SDK is not met. Manual installation of the latest version `3.27.6` is needed:
```bash
wget https://github.com/Kitware/CMake/releases/download/v3.27.6/cmake-3.27.6-linux-x86_64.sh
chmod +x cmake-3.27.6-linux-x86_64.sh
sudo sh cmake-3.27.6-linux-x86_64.sh --skip-license --prefix=/usr/local/
```
When manually installed, `cmake` is located in `/usr/local/bin`. To check its version, use the command `cmake --version`, which should display:
```
cmake version 3.27.6
```
### Compiling with Windows Linux Subsystem (WSL)
If you wish to perform the compilation with WSL, there's an small issue building the image.
The $PATH, due Windows interoperability, has Windows environment variables which include some spaces between the paths.
To solve this problem you need to change the `/etc/wsl.conf` file and add the following lines:
```
[interop]
appendWindowsPath = false
```
After that, you need to reboot the WSL with `wsl.exe --reboot`. Then you able to run the `./build_milkv.sh` script or the `build_all` line in the step-by-step compilation method.
To rollback this change in `/etc/wsl.conf` file set `appendWindowsPath` as true. To reboot the WSL, can you use the Windows PowerShell command `wsl.exe --shutdown` then `wsl.exe`, after that the Windows environment variables become avaliable again in $PATH.
## SD card burning
> Note: Writing the image to the microSD card will erase the existing data on the card. Remember to back up important data before burning!!!
- To write the generated image to a microSD card on Windows, you can use tools like `balenaEtcher`, `Rufus`, or `Win32 Disk Imager`
- To write the generated image to a microSD card on Linux, use the `dd` command. **Please make sure to carefully confirm that the `of` device `/dev/sdX` corresponds to the microSD card you want to burn**
- To write the generated image to a microSD card on Windows, you can use tools like `balenaEtcher`, `Rufus`, or `Win32 Disk Imager`.
- To write the generated image to a microSD card on Linux, use the `dd` command. **Please make sure to carefully confirm that the `of` device `/dev/sdX` corresponds to the microSD card you want to burn**:
```
sudo dd if=milkv-duo-*-*.img of=/dev/sdX
```
## Power ON
- Insert the microSD card into the microSD card slot of the Milk-V Duo
- Connect the serial cable (optional)
- Power on, the Duo will boot up and enter the system normally
- If a serial cable is connected, you can view the boot logs in the serial console. After entering the system, you can use the serial console to log in to the terminal and execute relevant Linux commands
- Insert the microSD card into the microSD card slot of the Milk-V Duo.
- Connect the serial cable (optional).
- Power on, the Duo will boot up and enter the system normally.
- If a serial cable is connected, you can view the boot logs in the serial console (`mobarXterm`, `Xshell` or others). After entering the system, you can use the serial console to log in to the terminal and execute relevant Linux commands.
### The method to log in to the Duo terminal
- Using a serial cable
- Using a USB network (RNDIS)
- Using the Ethernet interface (requires the IO-Board)
- Using a serial cable.
- Using a USB network (RNDIS).
- Using the Ethernet interface (requires the IO-Board).
The username and password for logging into the Duo terminal are as follows:
......@@ -137,7 +266,7 @@ mv /mnt/system/blink.sh /mnt/system/blink.sh_backup && sync
This means renaming the LED blinking script, and after restarting the Duo, the LED will no longer blink.
If you want to restore LED blinking, rename it back to its original name and restart the device.
If you want to restore LED blinking, rename it back to its original name and restart the device:
```bash
mv /mnt/system/blink.sh_backup /mnt/system/blink.sh && sync
......@@ -145,15 +274,15 @@ mv /mnt/system/blink.sh_backup /mnt/system/blink.sh && sync
### Using the IO-Board baseboard
Note that when using the IO-Board, the USB network (RNDIS) is not available, Please use the Ethernet interface on the IO-Board
Note that when using the IO-Board, the USB network (RNDIS) is not available, Please use the Ethernet interface on the IO-Board.
If you need to assign a fixed MAC address to the Ethernet port of the IO-Board, please execute the following command(**Replace the MAC address in the command with the MAC address you want to set, and please note that MAC addresses of different devices within the same network segment must not be duplicated**)
If you need to assign a fixed MAC address to the Ethernet port of the IO-Board, please execute the following command(**Replace the MAC address in the command with the MAC address you want to set, and please note that MAC addresses of different devices within the same network segment must not be duplicated**):
```bash
echo "pre-up ifconfig eth0 hw ether 78:01:B3:FC:E8:55" >> /etc/network/interfaces
```
then reboot the board
then reboot the board.
Enable the 4 USB ports on the IO-Board:
......@@ -163,9 +292,9 @@ ln -s /mnt/system/usb-host.sh /mnt/system/usb.sh
sync
```
then reboot the board
then reboot the board.
For example, if a USB flash drive is connected to the USB port on the IO-Board, you can use the command `ls /dev/sd*` to check if the device is detected
For example, if a USB flash drive is connected to the USB port on the IO-Board, you can use the command `ls /dev/sd*` to check if the device is detected.
To mount the USB drive and view its contents in the system (taking /dev/sda1 as an example):
......@@ -174,19 +303,19 @@ mkdir /mnt/udisk
mount /dev/sda1 /mnt/udisk
```
Verify if the contents in the `/mnt/udisk` directory match the expectations
Verify if the contents in the `/mnt/udisk` directory match the expectations:
```bash
ls /mnt/udisk
```
The command to unmount a USB flash drive
The command to unmount a USB flash drive:
```bash
umount /mnt/udisk
```
To restore the functionality of the USB network (RNDIS) when not using the IO-Board, you can follow these steps
To restore the functionality of the USB network (RNDIS) when not using the IO-Board, you can follow these steps:
```bash
rm /mnt/system/usb.sh
......@@ -194,22 +323,22 @@ ln -s /mnt/system/usb-rndis.sh /mnt/system/usb.sh
sync
```
then reboot the board
then reboot the board.
# FAQs
1. Why is only a single core being displayed?
The CV1800B chip adopts a dual-core design. Currently, the Linux system runs on one of the cores, while the other core is used for running a real-time system. The SDK for this core has not been released yet and will be updated in the future
The CV1800B chip adopts a dual-core design. Currently, the Linux system runs on one of the cores, while the other core is used for running a real-time system. The SDK for this core has not been released yet and will be updated in the future.
2. Why does it only show 28M when viewing the RAM?
Because a portion of the RAM is allocated to [ION](https://github.com/milkv-duo/duo-buildroot-sdk/blob/develop/build/boards/default/dts/cv180x/cv180x_default_memmap.dtsi#L15), which is the memory used when running algorithms with the camera. If you're not using the camera, you can modify the value of this [ION_SIZE](https://github.com/milkv-duo/duo-buildroot-sdk/blob/develop/build/boards/cv180x/cv1800b_milkv_duo_sd/memmap.py#L43) to 0 and then recompile to generate the image
Because a portion of the RAM is allocated to [ION](https://github.com/milkv-duo/duo-buildroot-sdk/blob/develop/build/boards/default/dts/cv180x/cv180x_default_memmap.dtsi#L15), which is the memory used when running algorithms with the camera. If you're not using the camera, you can modify the value of this [ION_SIZE](https://github.com/milkv-duo/duo-buildroot-sdk/blob/develop/build/boards/cv180x/cv1800b_milkv_duo_sd/memmap.py#L43) to 0 and then recompile to generate the image.
## Links to some documentation from the chip manufacturer
- CV181x/CV180x MMF SDK Development Documents (English and Chinese): [MultiMedia Framework Software Development Document](https://developer.sophgo.com/thread/471.html)
- CV Series Chip TPU SDK Development Documentation Compilation (Chinese): [CV series chip TPU SDK development data summary](https://developer.sophgo.com/thread/473.html)
- CV181x/CV180x MMF SDK Development Documents (English and Chinese): [MultiMedia Framework Software Development Document](https://developer.sophgo.com/thread/471.html).
- CV Series Chip TPU SDK Development Documentation Compilation (Chinese): [CV series chip TPU SDK development data summary](https://developer.sophgo.com/thread/473.html).
# About Milk-V
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment