Building an Embedded Linux Development Environment for RK3399: Practical Experience for Professional Developers

Building an Embedded Linux Development Environment for RK3399: Practical Experience for Professional Developers

Embedded Linux is increasingly applied in high-performance computing, edge computing, and artificial intelligence. The RK3399, as a six-core 64-bit ARM processor, has become an ideal choice for these application scenarios due to its excellent performance and rich peripheral interfaces. This article will provide professional developers with a detailed introduction to the process of setting up the embedded Linux development environment on the RK3399 platform.

Building an Embedded Linux Development Environment for RK3399: Practical Experience for Professional Developers

Hardware and Software Requirements

Hardware Requirements:

  • RK3399 Development Board (2GB RAM/16GB eMMC)
  • 5V/3A Type-C Power Adapter
  • USB to Serial Debugger
  • SD Card (16GB or larger)

Software Requirements:

  • Host Operating System: Ubuntu 22.04 LTS
  • gcc-arm-linux-gnueabihf (>= 9.0)
  • git (>= 2.25.1)
  • repo tool

Overview of the Development Environment

The development environment for RK3399 mainly consists of three core components: the U-Boot bootloader, the Linux kernel, and the root filesystem. We will use the Buildroot build system to manage the entire development environment, which can significantly simplify the configuration of the cross-compilation toolchain and the construction of the root filesystem.

Preparing the Host Development Environment

# Install basic development tools
sudo apt-get update
sudo apt-get install -y git-core gitk git-gui gcc-arm-linux-gnueabihf \
device-tree-compiler lzop libncurses5-dev libssl-dev python3-pip

Source Code Acquisition and Toolchain Configuration

# Configure repo tool
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

# Initialize source repository
mkdir rk3399-linux && cd rk3399-linux
repo init -u https://github.com/rockchip-linux/manifests -b master
repo sync

# Set up cross-compilation environment
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-

Compiling U-Boot and the Kernel

# Compile U-Boot
cd u-boot
make rk3399_defconfig
make -j$(nproc)

# Compile the kernel
cd ../kernel
make rockchip_linux_defconfig
make -j$(nproc) Image dtbs

Building the Root Filesystem

# Install and configure Buildroot
git clone https://github.com/buildroot/buildroot.git
cd buildroot
make rockchip_rk3399_defconfig
make menuconfig  # Configure system components as needed
make -j$(nproc)

System Deployment

Write the compiled image to the SD card:

# Assuming the SD card device is /dev/sdX
sudo dd if=u-boot/idbloader.img of=/dev/sdX seek=64
sudo dd if=u-boot/u-boot.img of=/dev/sdX seek=16384
sudo dd if=buildroot/output/images/rootfs.ext4 of=/dev/sdX seek=32768

Common Issues and Solutions

  1. Compilation Errors: Ensure all dependencies are correctly installed, and if necessary, use <span>make clean</span> to clean and recompile.

  2. Boot Failures: Check if the device tree configuration is correct; serial logs can help locate the issue.

Development Environment Optimization Suggestions

It is recommended to use VSCode with the Remote SSH plugin for development, which allows for efficient development workflows with local editing and remote compilation. Configuring ccls or clangd can provide a better code suggestion experience.

Through the above steps, we have completed the basic setup of the RK3399 development environment. This environment provides a solid foundation for subsequent application development, driver development, and system optimization. It is advisable to further study advanced topics such as device tree configuration, driver development, and system performance tuning.

Leave a Comment