版本比较

标识

  • 该行被添加。
  • 该行被删除。
  • 格式已经改变。
Sv translation
languagezh_CN

开发环境搭建分服务器直接搭建和Docker编译环境搭建,推荐使用Docker编译!

1  

...

服务器开发环境搭建

1.1 准备开发环境

我们推荐使用 Ubuntu 22.04 或更高版本的系统进行编译。其他的 Linux 版本可能需要对软件包做相应调

整。除了系统要求外,还有其他软硬件方面的要求。

硬件要求:64 位系统,硬盘空间大于 40G。如果您进行多个构建,将需要更大的硬盘空间。

软件要求:Ubuntu 22.04 或更高版本系统。

1.2 安装库和工具集

使用命令行进行设备开发时,可以通过以下步骤安装编译SDK需要的库和工具。

使用如下apt-get命令安装后续操作所需的库和工具:

代码块
languageshell
titlebash
sudo apt-get update && sudo apt-get install git ssh make gcc libssl-dev \
liblz4-tool expect expect-dev g++ patchelf chrpath gawk texinfo chrpath \
diffstat binfmt-support qemu-user-static live-build bison flex fakeroot \
cmake gcc-multilib g++-multilib unzip device-tree-compiler ncurses-dev \
libgucharmap-2-90-dev bzip2 expat gpgv2 cpp-aarch64-linux-gnu libgmp-dev \
libmpc-dev bc python-is-python3 python2

说明:

安装命令适用于Ubuntu22.04,其他版本请根据安装包名称采用对应的安装命令,若编译遇到报

错,可以视报错信息,安装对应的软件包。其中:

  • python要求安装python 3.6及以上版本,此处以python 3.6为例。
  • make要求安装 make 4.0及以上版本,此处以 make 4.2为例。
  • lz4要求安装 lz4 1.7.3及以上版本。
  • 编译Yocto需要VPN网络,git没有CVE-2022-39253安全检测补丁。

1.2.1 检查和升级主机的python版本

检查和升级主机的python版本方法如下:

  • 检查主机python版本
代码块
languageshell
titlebash
python3 --version
Python 3.10.6

如果不满足python>=3.6版本的要求, 可通过如下方式升级:

  • 升级python 3.6.15新版本
代码块
languageshell
titlebash
PYTHON3_VER=3.6.15
echo "wget
https://www.python.org/ftp/python/${PYTHON3_VER}/Python-${PYTHON3_VER}.tgz"
echo "tar xf Python-${PYTHON3_VER}.tgz"
echo "cd Python-${PYTHON3_VER}"
echo "sudo apt-get install libsqlite3-dev"
echo "./configure --enable-optimizations"
echo "sudo make install -j8"

1.2.2 检查和升级主机的make版本

检查和升级主机的make版本方法如下:

  • 检查主机make版本
代码块
languageshell
titlebash
$ make -v
GNU Make 4.2
Built for x86_64-pc-linux-gnu


  • 升级make 4.2新版本
代码块
languageshell
titlebash
$ sudo apt update && sudo apt install -y autoconf autopoint
git clone https://gitee.com/mirrors/make.git
cd make
git checkout 4.2
git am $BUILDROOT_DIR/package/make/*.patch
autoreconf -f -i
./configure
make make -j8
sudo install -m 0755 make /usr/bin/make

1.2.3 检查和升级主机的lz4版本

检查和升级主机的lz4版本方法如下:

  • 检查主机lz4版本
代码块
languageshell
titlebash
$ lz4 -v
*** LZ4 command line interface 64-bits v1.9.3, by Yann Collet ***
  • 升级lz4新版本
代码块
languageshell
titlebash
git clone https://gitee.com/mirrors/LZ4_old1.git
cd LZ4_old1
make
sudo make install
sudo install -m 0755 lz4 /usr/bin/lz4

1.2.4 检查和升级主机的git版本

  • 检查主机git版本
代码块
languageshell
titlebash
$ git -v
git version 2.38.0
  • 升级git新版本
代码块
languageshell
titlebash
$ sudo apt update && sudo apt install -y libcurl4-gnutls-dev
git clone https://gitee.com/mirrors/git.git --depth 1 -b v2.38.0
cd git
make git -j8
make install
sudo install -m 0755 git /usr/bin/git

2. Docker编译环境搭建

2.1 系统环境说明

  • Docker 版本要求:10.10 或更高版本
  • Docker Compose:推荐使用 Docker Compose V2
  • 容器资源分配:确保为 Docker 分配足够的系统资源(CPU、内存)

注意:确保您的设备已经安装了Docker程序

 操作系统

操作系统

最低内存要求

推荐内存配置

Linux(非图形化环境)

16GB

32GB 或更高

2.2  在SDK根目录构建Dockerfile镜像

代码块
languageshell
titlebash
mkdir -p docker
cat > docker/Dockerfile << EOF
# Use ubuntu base
FROM ubuntu:22.04 

# Prevent dpkg interactive dialogues
ENV DEBIAN_FRONTEND=noninteractive

# Install required packages
RUN apt-get update && apt-get install -y \
    bc \
    binfmt-support \
    bison \
    build-essential \
    cpio \
    debootstrap \
    debhelper \
    device-tree-compiler \
    dosfstools \
    fakeroot \
    fdisk \
    flex \
    gcc-aarch64-linux-gnu \
    git-lfs \
    kmod \
    libssl-dev \
    parted \
    python-is-python3 \
    python2 \
    python3 \
    qemu-efi \
    qemu-system-arm \
    qemu-user-static \
    rsync \
    u-boot-tools \
    udev \
    uuid-runtime \
    xz-utils \
    libelf-dev \
    dwarves \
    && rm -rf /var/lib/apt/lists/*

# Set the working directory
WORKDIR /opt
EOF

2.2 构建编译脚本

代码块
languageshell
titlebash
cat > docker_build.sh << EOF
#!/bin/bash -e

#Configure operational parameters
DOCKER="docker run --privileged --network=host --rm -it \
    --user $(id -u):$(id -g) \
    -v \"$(pwd)\":/opt ubuntu-rockchip-build /bin/bash"

echo "Docker run build.sh!!!!"
docker build -t ubuntu-rockchip-build docker
eval "${DOCKER}" ./build.sh "$1" "$2" "$3"
EOF

3.3 Docker编译方法

同rockchip正常的编译方法,如:

代码块
languageshell
titlebash
#正常编译方法
./build.sh kernel
#Docker编译方法
./docker_build.sh kernel




Sv translation
languageen

Development environment setup is divided into direct server setup and Docker compilation environment setup. Docker compilation is recommended!

1 Server Development Environment Setup

1.1 Prepare Development Environment

We recommend using Ubuntu 22.04 or higher for compilation. Other Linux versions may require corresponding adjustments to software packages. In addition to system requirements, there are other hardware and software requirements.

Hardware Requirements: 64-bit system, disk space greater than 40GB. If you perform multiple builds, you will need more disk space.

Software Requirements: Ubuntu 22.04 or higher system.

1.2 Install Libraries and Toolsets

When using the command line for device development, you can install the libraries and tools required for compiling the SDK through the following steps.

Use the following apt-get command to install the libraries and tools required for subsequent operations:

代码块
languageshell
titlebash
sudo apt-get update && sudo apt-get install git ssh make gcc libssl-dev \
liblz4-tool expect expect-dev g++ patchelf chrpath gawk texinfo chrpath \
diffstat binfmt-support qemu-user-static live-build bison flex fakeroot \
cmake gcc-multilib g++-multilib unzip device-tree-compiler ncurses-dev \
libgucharmap-2-90-dev bzip2 expat gpgv2 cpp-aarch64-linux-gnu libgmp-dev \
libmpc-dev bc python-is-python3 python2

Notes:

The installation command applies to Ubuntu 22.04. For other versions, please use the corresponding installation command based on the package names. If compilation errors occur, you can install the corresponding software packages based on the error messages. Among them:

  • Python requires Python 3.6 or higher. Python 3.6 is used here as an example.
  • Make requires Make 4.0 or higher. Make 4.2 is used here as an example.
  • LZ4 requires LZ4 1.7.3 or higher.
  • Compiling Yocto requires VPN network. Git should not have CVE-2022-39253 security patch.

1.2.1 Check and Upgrade Host Python Version

Methods to check and upgrade the host Python version are as follows:

  • Check host Python version
代码块
languageshell
titlebash
python3 --version
Python 3.10.6

If Python >= 3.6 requirement is not met, you can upgrade as follows:

  • Upgrade to Python 3.6.15 new version
代码块
languageshell
titlebash
PYTHON3_VER=3.6.15
echo "wget https://www.python.org/ftp/python/${PYTHON3_VER}/Python-${PYTHON3_VER}.tgz"
echo "tar xf Python-${PYTHON3_VER}.tgz"
echo "cd Python-${PYTHON3_VER}"
echo "sudo apt-get install libsqlite3-dev"
echo "./configure --enable-optimizations"
echo "sudo make install -j8"

1.2.2 Check and Upgrade Host Make Version

Methods to check and upgrade the host Make version are as follows:

  • Check host Make version
代码块
languageshell
titlebash
$ make -v
GNU Make 4.2
Built for x86_64-pc-linux-gnu
  • Upgrade to Make 4.2 new version
代码块
languageshell
titlebash
$ sudo apt update && sudo apt install -y autoconf autopoint
git clone https://gitee.com/mirrors/make.git
cd make
git checkout 4.2
git am $BUILDROOT_DIR/package/make/*.patch
autoreconf -f -i
./configure
make make -j8
sudo install -m 0755 make /usr/bin/make

1.2.3 Check and Upgrade Host LZ4 Version

Methods to check and upgrade the host LZ4 version are as follows:

  • Check host LZ4 version
代码块
languageshell
titlebash
$ lz4 -v
*** LZ4 command line interface 64-bits v1.9.3, by Yann Collet ***
  • Upgrade to LZ4 new version
代码块
languageshell
titlebash
git clone https://gitee.com/mirrors/LZ4_old1.git
cd LZ4_old1
make
sudo make install
sudo install -m 0755 lz4 /usr/bin/lz4

1.2.4 Check and Upgrade Host Git Version

  • Check host Git version
代码块
languageshell
titlebash
$ git -v
git version 2.38.0
  • Upgrade to Git new version
代码块
languageshell
titlebash
$ sudo apt update && sudo apt install -y libcurl4-gnutls-dev
git clone https://gitee.com/mirrors/git.git --depth 1 -b v2.38.0
cd git
make git -j8
make install
sudo install -m 0755 git /usr/bin/git

...


2. Docker Compilation Environment Setup

2.1 System Environment Requirements

  • Docker version requirement: 10.10 or higher
  • Docker Compose: Docker Compose V2 is recommended
  • Container resource allocation: Ensure sufficient system resources (CPU, memory) are allocated for Docker

Note: Ensure your device has Docker installed

Operating System

Minimum Memory Requirement

Recommended Memory Configuration

Linux (Non-graphical environment)

16GB

32GB or higher

2.2 Build Dockerfile Image in SDK Root Directory

代码块
languageshell
titlebash
mkdir -p docker
cat > docker/Dockerfile << EOF
# Use ubuntu base
FROM ubuntu:22.04 

# Prevent dpkg interactive dialogues
ENV DEBIAN_FRONTEND=noninteractive

# Install required packages
RUN apt-get update && apt-get install -y \
    bc \
    binfmt-support \
    bison \
    build-essential \
    cpio \
    debootstrap \
    debhelper \
    device-tree-compiler \
    dosfstools \
    fakeroot \
    fdisk \
    flex \
    gcc-aarch64-linux-gnu \
    git-lfs \
    kmod \
    libssl-dev \
    parted \
    python-is-python3 \
    python2 \
    python3 \
    qemu-efi \
    qemu-system-arm \
    qemu-user-static \
    rsync \
    u-boot-tools \
    udev \
    uuid-runtime \
    xz-utils \
    libelf-dev \
    dwarves \
    && rm -rf /var/lib/apt/lists/*

# Set the working directory
WORKDIR /opt
EOF

2.3 Build Compilation Script

代码块
languageshell
titlebash
cat > docker_build.sh << EOF
#!/bin/bash -e

#Configure operational parameters
DOCKER="docker run --privileged --network=host --rm -it \
    --user $(id -u):$(id -g) \
    -v \"$(pwd)\":/opt ubuntu-rockchip-build /bin/bash"

echo "Docker run build.sh!!!!"
docker build -t ubuntu-rockchip-build docker
eval "${DOCKER}" ./build.sh "$1" "$2" "$3"
EOF

2.4 Docker Compilation Method

Same as Rockchip normal compilation method, for example:

代码块
languageshell
titlebash
#Normal compilation method
./build.sh kernel
#Docker compilation method
./docker_build.sh kernel