Linux6.1.14_User’s Compilation Manual_V1.0

Document classification: □ Top secret □ Secret □ Internal information ■ Open

Application Scope

This software manual is designed for the OK3576-UP5 platform running Linux6.1. While other platforms may also reference this manual, there could be differences that require adjustments for the specific use.

Revision History

Date

Version

SoM Version

Carrier Board Version

Revision History

09/10/2026

V1.0

V1.1

V1.2 and above

OK3576-UP5 Linux6.1 User’s Compilation Manual Initial Version

This manual is intended to help you quickly understand the software compilation process and become familiar with the relevant compilation procedures. Before applications can be run on the development board, they must first be cross-compiled on a Linux operating system. By following the instructions and completing the hands-on exercises provided in this manual, you will learn how to compile your own software.

This manual also describes how to set up the required development environment. Since unexpected issues may arise during the setup process, beginners are encouraged to use the pre-configured development environment provided by Forlinx. This approach allows you to get started quickly while minimizing setup time and potential troubleshooting efforts.

There are three common ways to install Ubuntu: dual-boot installation on a physical machine, single-boot installation on a physical machine, and installation in a virtual machine. Each approach has its own advantages and disadvantages. This manual focuses exclusively on installing Ubuntu in a virtual machine.

Hardware Requirements:

A minimum of 6 GB of RAM is recommended. This allows you to allocate at least 2 GB of memory to the virtual machine while keeping sufficient resources available for other tasks in Windows. Using a system with less RAM may affect overall Windows performance and result in a less responsive development environment.

This manual consists of five chapters:

  • Chapter 1: Installing VMware

    This chapter describes how to install VMware, specifically VMware® Workstation 17 Pro (Version 17.0.0). VMware must be installed before proceeding with the Ubuntu development environment setup.

  • Chapter 2: Loading the Pre-configured Ubuntu Development Environment

    This chapter explains how to load the Ubuntu development environment provided by Forlinx. The pre-configured environment is based on 64-bit Ubuntu 22.04.

  • Chapter 3: Setting Up a New Ubuntu Development Environment

    This chapter describes the process of setting up a new Ubuntu development environment, using 64-bit Ubuntu 22.04 as an example. It provides step-by-step instructions for completing the setup. Since computer hardware configurations vary, unexpected issues may arise during the installation and configuration process. Therefore, beginners are encouraged to use the pre-configured development environment provided by Forlinx to get started quickly and improve development efficiency.

  • Chapter 4: Compiling Source Code for the Development Board

    This chapter explains how to compile source code for the target development board.

  • Chapter 5: Compiling C and Qt Applications

    This chapter focuses on compiling C and Qt applications for the development board.

Additionally, the manual includes explanations of some symbols and formats.

Format

Meaning

Note

Note or information that requires special attention, be sure to read carefully

📚

Relevant notes on the test chapters

️️🛤️ ️

Indicates the related path.

Blue font on gray background

Refers to commands entered at the command line(Manual input required).

Black font

Serial port output message after entering a command

Bold black

Key information in the serial port output message

//

Interpretation of input instructions or output information

Username@Hostname

root@OK3576-buildroot:~# : Development board serial port and network login account information, Ubuntu account information.
You can use this information to determine the functional operating environment.

Example: After packaging the file system, use the ls command to view the generated files.

forlinx@ubuntu:~/3576$ ls   //List the files in this directory
OK3576-linux-source.tar.bz2 OK3576-linux-source.tar.bz2.00 OK3576-linux-source.tar.bz2.01 OK3576-linux-source.tar.bz2.02 OK3576-linux-source.tar.bz2.03 OK3576-linux-source.tar.bz2.04 OK3576-linux-source.tar.bz2.05
  • forlinx@ubuntu: The username is forlinx, and the hostname is ubuntu, indicating that the operation is being performed in the development environment on Ubuntu.

  • //: Explanation of the command. No need to enter this when typing the command.

  • For detailed information, please refer to the OK3576-UP5 User Materials. All file paths for user materials mentioned in this document are relative to the root directory of the OK3576-UP5 User Materials.

1. Installing VMware

This chapter mainly introduces the installation of the VMware virtual machine, using VMware Workstation 17 Pro v17.0.0 as an example to demonstrate the operating system installation and configuration process.

1.1 Downloading and Purchasing VMware Software

After registering for and logging into your BROADCOM website account, visit https://support.broadcom.com/group/ecx/downloads to download VMware workstation pro.

Image

Enter “VMware Workstation” to search, then click on the VMware Workstation Pro that appears in the search results.

Image

Download the corresponding version of VMware Workstation Pro.

Image

Image

Click “Yes”, fill in your personal information, then click “Submit”.

Image

1.2 VMware Software Installation

Double-click the downloaded VMware Workstation Pro to enter the installation wizard. When the following interface pops up, click “Next”.

Image

Check “I accept the terms in the license agreement” and click “Next.”

Image

Change the installation location — you can customize the installation path, then click “Next”.

Image

Check the options for product updates and the “Customer Experience Improvement Program”, then click “Next”.

Image

Check the option to create a shortcut, then click “Next”.

Image

Click “Install.”

Image

Wait for the installation to complete.

Image

When the installation is complete, click “Finish”; or click “License” to enter the license key.

Image

2. Loading the Pre-configured Ubuntu Development Environment

2.1 Downloading and Verifying The Development Environment

Note:

  • It is recommended that beginners directly use the virtual machine environment pre-configured by Forlinx, which already has the cross-compiler and Qt environment installed. After reviewing this chapter, you can skip directly to the compilation chapters;

  • The regular user account for the development environment is: “forlinx”, and the corresponding password is: “forlinx”;

  • You can access software and hardware documentation, source code, and the development environment via the cloud storage link provided by Forlinx. Please ask your sales representative for the download link.

Development Environment Compatibility Note: The development environment described in this manual (based on Ubuntu 22.04) is highly versatile.

There are two methods for using a virtual machine environment in VMware: you can either load an existing development environment or create a new one.

First, download the development environment provided by Forlinx. The development environment package includes an MD5 checksum file. After downloading the package, you should verify the integrity of the compressed file by performing an MD5 checksum check. You can either use an online MD5 verification tool or download a dedicated MD5 verification tool, depending on your preference. Compare the checksum that you generate with the one listed in the checksum file. If they match, the downloaded file is intact. If they do not match, the file may be corrupted, and you will need to download it again.

Image

Press and hold the Shift key, then right-click the blank area and select “Open PowerShell window here” to bring up the following interface:

Image

Enter the command certutil -hashfile [file name] md5 to verify each archive package one by one, and compare the generated value with the MD5 checksum recorded in the checksums.md5 file. If any checksum does not match, re-download it (please ask your sales representative for the download link).

Image

Once all archive packages pass the verification, select all, right-click and extract them to the current folder. After the extraction completes, you will obtain the 3576 development environment.

Image

2.2 Launching the Development Environment

Open the VMware Workstation software and click “Open Virtual Machine”.

Image

Navigate to the directory where the newly extracted OK35XX-linux6.1-VM17-ubuntu22.04 virtual machine files are stored, select the OK35XX.vmx file, then click “Open”.

Image

Once the loading is complete”, click “Power on this virtual machine”.

Image

Select the option “I copied this virtual machine” when prompted.

The default login credentials for the development environment are:

Username: forlinx

Password: forlinx

Image

The system will display the following interface after successful boot:

Image

3. Setting Up a New Ubuntu Development Environment

Note: It is not recommended for beginners to build the system by themselves. It is recommended to use the existing virtual machine environment. This section can be skipped if there is no need to build the environment.

3.1 Ubuntu System Setup

3.1.1 Creating an Ubuntu Virtual Machine

Open VMware Workstation software and click “Create New Virtual Machine”.

Image

When you enter the following interface, select “Custom (Advanced)”, then click “Next”.

Set the hardware compatibility to “Workstation 17.x”, then click “Next”

Image

Select “I will install the operating system later”, then click “Next”.

Image

For guest operating system selection, pick “Linux”, set the version to “Ubuntu 64-bit”, then click “Next”

Image

You can customize the virtual machine name and its installation storage path, then click “Next”.

Image

Set the number of processors to 4, and the number of cores per processor to 1, then click “Next”.

Image

Allocate the virtual machine memory to 16384MB, then click “Next”.

Image

Select “Use network address translation (NAT)”, then click “Next”.

Image

Select “LSI Logic” as the virtual disk adapter, then click “Next”.

Image

Set the virtual disk type to “SCSI”, then click “Next”.

Image

Select “Create a new virtual disk”, then click “Next”.

Image

Set the maximum disk size to 200GB, check the option “Split virtual disk into multiple files”, then click “Next”.

Image

Keep the default disk file name, then click “Next”.

Image

Click “Finish”.

Image

You can see the basic configuration of the current Ubuntu development environment on the left side of VMware Workstation.

At this point, the virtual machine creation is complete.

The installation process on a physical machine is similar to the one on a virtual machine, but here we will focus on installing Ubuntu in the virtual machine. Here’s how to install Ubuntu in a virtual machine

3.1.2 System Installation

3.1.2.1 Downloading the Image

The selected Ubuntu version for installation is 22.04. Please contact your sales representative to obtain the download link. Download the exact version named ubuntu-22.04.5-desktop-amd64.iso.

Image

3.1.2.2 Installing the Image

After downloading the image, click “Edit Virtual Machine Settings”.

Image

The pop-up Virtual Machine Settings menu is shown in the figure below:

Image

Click “CD/DVD (SATA)”, select the option “Use ISO image file”, browse and select the previously downloaded ubuntu-22.04.5-desktop-amd64.iso image, then click “OK”.

Image

After mounting the image, ensure the network connection is available, then click “Power on this virtual machine” to start the Ubuntu image installation process.

Image

Click “Yes”.

After the virtual machine boots up, wait for the installation interface to appear, then click “Install Ubuntu” on the right side.

Image

The default language of Ubuntu is English, but you can also select other languages. Note that the selected language can still be reconfigured later in the system. After making your selection, click “Continue”.

Image

Select “Normal installation” (corrected the original typo installtation), then click “Continue”.

ImageSelect “Erase disk and install Ubuntu”, then click “Install Now”.

Image

Click “Continue”.

Image

Click the territory of your country or enter city to set the time zone, then click “Continue”.

Image

Set your full name, computer name, user account and password (then confirm the password), then click “Continue”.

Image

After the installation finishes, the system interface shown below will appear. Click the account forlinx and enter the password forlinx to log in.

Image

You will then enter the system desktop interface:

Image

3.1.3 Basic Configuration of Ubuntu

After installing the Ubuntu 22.04 operating system, some configurations need to be done.

3.1.3.1 Installing open-vm-tools

Next, install open-vm-tools. If this utility is not installed, copy-paste and file drag-and-drop functions cannot be used between the Windows host machine and the virtual machine. Right-click on the desktop and select “Open in Terminal”.

forlinx@ubuntu:~$ sudo apt-get update                        //Update the download source information
forlinx@ubuntu:~$ sudo apt-get install open-vm-tools open-vm-tools-desktop //Install open-vm-tools

After installing the open-vm-tools, restart the virtual machine. Then click “View” on the menu bar, select Auto-Resize, and click “Fit Guest Now” to enable full-screen display of the virtual machine interface.

Image

3.1.3.2 Basic Configuration

Most system settings can be configured in the location shown in the figure. Many settings requirements on Ubuntu can be completed here.

Image

3.1.4 Network Configuration of Ubuntu

3.1.4.1 NAT Mode

Before using the network, first confirm that the virtual machine can access the Internet by clicking “Edit Virtual Machine Settings”.

Change the network mode of the Network Adapter to “NAT Mode”:

Image

In the virtual machine, when the VMware virtual network adapter is set to NAT mode, the network in the Ubuntu environment should be set to dynamic IP. In this mode, the virtual NAT device and the host network card are connected. This is the most commonly used method to connect the virtual machine to the external network. This is the most commonly used method for the virtual machine to access the external network.

Open “Settings”:

Image

Set the Internet:

Image

Set the network to obtain an IP address automatically, and configure the DNS as 8.8.8.8, then click “Apply” to save the settings.

Image

3.1.4.2 Bridge Mode

If using servers like TFTP or SFTP, you need to set the virtual machine’s network connection to Bridged Mode. When Vmware virtual network card is set to bridged mode, the host network card and the virtual machine network card communicate through a virtual bridge, and you need to ensure that the IP address of Ubuntu is in the same subnet as the host machine.

Change the network bridging mode in the network adapter to “Bridge Mode”:

Image

Open “Settings”:

Image

Set the Internet:

Image

Setting a Static IP Address

When configuring a static IP, the Ubuntu IP must be set in the same subnet as the host machine’s IP.

Image

Note: The IP and DNS settings mentioned in the network configuration section should be configured based on the user’s actual environment. The manual provides examples for illustration.

3.1.5 USB Device Loading

Open the virtual machine settings, go to USB Controller, and in the compatibility section, choose USB 3.1, then click “OK”. As shown below, most modern computers support USB 3.1 ports. If not configured, the USB 3.1 device will not be connected to the virtual machine when inserted. As shown in the figure:

Image

After the virtual machine starts, insert the USB drive. An icon resembling a “USB drive” will appear in the lower-right corner of the virtual machine. Right-click it –> select “Connect”, then you can see the USB drive icon in the taskbar, as shown in the figure below:

Image

Image

Click the USB drive icon to enter its internal directory.

Image

3.1.6 Basic Library Installation for the Virtual Machine

Before development, some other necessary libraries need to be installed. Use the following commands to install them one by one. Make sure the network is functioning properly and can connect to the internet before installing.

forlinx@ubuntu:~$ sudo apt-get update                        // Update download source information
forlinx@ubuntu:~$ sudo apt-get install build-essential            // Provide the list information of necessary software packages for compiling programs
forlinx@ubuntu:~$ sudo apt-get install libncurses*               // Used to generate text-based user interfaces
forlinx@ubuntu:~$ sudo apt-get install lzop                     // Compression and decompression tool based on the Lzo library
forlinx@ubuntu:~$ sudo apt-get install net-tools                 // Network configuration tools

3.1.7 Installation of Necessary Libraries for Compiling OK3576 Linux Source Code

forlinx@ubuntu:~$ sudo apt-get update                                  //Updated apt-get download source
forlinx@ubuntu:~$ sudo apt-get install openssh-server vim git fakeroot libsqlite3-dev     
# Necessary toolkit installation
forlinx@ubuntu:~$ 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 gettext scons

These libraries are required when setting up the 3576 Linux compilation environment and preparing to compile the Linux source code. If you’re not setting up the OK3576 Linux development environment, you can skip this step.

3.2 Installing the Cross-compilation Toolchain

Path: User profile/2-source code and image/2-cross-compiler/aarch64-buildroot-linux-gnu_sdk-buildroot.tar.gz

Copy the above compressed file to the directory in the development environment /home/forlinx/, and extract it there:

forlinx@ubuntu:~$ tar -zvxf aarch64-buildroot-linux-gnu_sdk-buildroot.tar.gz

Enteraarch64-buildroot-linux-gnu_sdk-buildroot directory to execute relocate-sdk.sh

forlinx@ubuntu:~/aarch64-buildroot-linux-gnu_sdk-buildroot$ ./relocate-sdk.sh

3.3 Qt Creator Installation

Copy the file qt-creator-opensource-linux-x86_64-4.7.0.run to any directory in the current user’s home directory and execute the following command.

Path:User profile\3-tools\qt-creator-opensource-linux-x86_64-4.7.0.run

forlinx@ubuntu:~$ chmod +x qt-creator-opensource-linux-x86_64-4.7.0.run
forlinx@ubuntu:~$ ./qt-creator-opensource-linux-x86_64-4.7.0.run                   

Then a graphical installation window will pop up, click “Next”.

Image

If you already have a Qt account, enter your account and password in the Login input field; if you do not have a Qt account, fill in your account email, password and confirm password in the Sign-up section, check the terms of service, and click “Next”.

Image

Click “Next”:

Image

You can set the installation path according to your preferences; here, we’ll use the default settings and click “Next”.

Image

Installation finishes, click “Next”.

Image

Choose “I agree to the License Agreement” and click “Next”.

Image

Click “Install” to start the installation.

Image

Launch Qt Creator and click “Finish”.

Image

The Qt interface will automatically open, or you can launch it from the command line. To open Qt Creator in the background, use the following command, replacing it with your actual installation path:

forlinx@ubuntu:~$ cd /home/forlinx/qtcreator-4.7.0/bin
forlinx@ubuntu:~$ ./qtcreator &

Interface:

Image

4. Compiling Source Code for the Development Board

4.1 Preparation Before Compilation

4.1.1 Environment Description

  • Development OS: Ubuntu22.04 64 bit

  • Qt Creator: Qt Creator 4.7.0 Based on Qt 5.15.11

  • Cross-Toolchain: aarch64-linux-gnu

  • Bootloader Version for Development Board: u-boot-2017.09

  • Kernel Version for Development Board: Linux-6.1

  • Qt Version Ported to Development Board: qt5.15.11

4.1.2 Copying the Source Code

Program source code:

Create Working Directory:

forlinx@ubuntu:~$ cd /home/forlinx/work
                                    //Switch to the working directory

forlinx@ubuntu:~/work$ cat OK3576-linux-source.tar.bz2.* > OK3576-linux-source.tar.bz2

forlinx@ubuntu:~/work$ tar -xvf OK3576-linux-source.tar.bz2
                                    //Unzip the compressed file at the current location

Wait for the copy process to complete after running the command.

4.1.3 Directory Structure

forlinx@ubuntu:~/work/OK3576-linux-source$ tree -L 1
.
├── app
├── buildroot                    // Related to the buildroot system
├── build.sh -> device/rockchip/common/scripts/build.sh
│                                // Compilation script
├── common -> device/rockchip/common
├── debian                       // Related to the debian system
├── device
├── docs                         // Rockchip development documents
├── external                     // Third-party libraries and external components
├── hal
├── kernel -> kernel-6.1
├── kernel-6.1                   // Kernel source code
├── Makefile -> device/rockchip/common/Makefile
├── prebuilts                    // Precompilation
├── README.md -> device/rockchip/common/README.md
│                                // Project description file
├── rkbin                        // DDR initialization code
├── rkflash.sh -> device/rockchip/common/scripts/rkflash.sh
├── rtos                         // Related to the rtos system
├── tools                        // Tools
├── u-boot                       // U-Boot source code
└── yocto                        // Related to the yocto system

4.1.4 Common Source Code File Paths

File

Path

U-Boot Default Configuration File:

OK3576-linux-source/u-boot/configs/OK3576-C_defconfig

Camera Configuration Device Tree File:

OK3576-linux-source/kernel-6.1/arch/arm64/boot/dts/rockchip/OK3576-UP5-cam.dtsi

Configuration Device Tree File:

OK3576-linux-source/kernel-6.1/arch/arm64/boot/dts/rockchip/OK3576-UP5-common.dtsi

Top-level Device Tree File:

OK3576-linux-source/kernel-6.1/arch/arm64/boot/dts/rockchip/OK3576-UP5-linux.dts

Kernel Configuration File

OK3576-linux-source/kernel-6.1/arch/arm64/configs/OK3576-UP5-linux_defconfig

Buildroot Configuration File:

OK3576-linux-source/buildroot/configs/rockchip_ok3576-up5_defconfig

Partition table configuration file

OK3576-linux-source/device/rockchip/rk3576/parameter.txt

4.2 Source Code Compilation

Note:

  • After extracting the kernel source code for the first time, you need to perform a full compilation of the source code;

  • After the initial full compilation, you can proceed with individual compilations based on the actual situation;

  • This source code compilation requires at least 8GB of RAM in the development environment. Please do not modify the provided VM configuration.

4.2.1 Full Compilation

In the source code directory there is a compilation script named build.sh. Running this script will compile the entire source code. You need to switch to the extracted source code path in the terminal and locate the build.sh file..

forlinx@ubuntu:~$ cd /home/forlinx/work/OK3576-linux-source

The following operations need to be operated in the source code directory. Full compilation method:

forlinx@ubuntu:~/work/OK3576-linux-source$ ./build.sh

**The precompiled file system used by default in the SDK is located at the path:

OK3576-linux-source/prebuilts/forlinx/rk3576/buildroot/rootfs.ext4

If you need to compile the file system on your own, simply delete or move this file out of the directory.**

Image

After successful compilation, the system image will be generated under the path OK3576-linux-source/output/update/Image/, as shown below:

Image

Description of Generated Files:

File

Description

boot.img

Consists of resource.img and kernel.img, and contains the device tree and the kernel

env.img

Environment variable image file

MiniLoaderAll.bin

Miniloader image file

misc.img

Miscellaneous image files

parameter.txt

Partition table configuration file

recovery.img

System recovery image file

rootfs.img

File system image files

uboot.img

uboot image files

update.img

Complete image file

userdata.img

User data partition image

Note: update.img is a pre-packaged file intended for full flashing via OTG or a TF card; the other files are for step-by-step flashing.

4.2.2 Image Flashing File

update.img is packaged for full flashing using OTG or TF card.
Other files are for step-by-step flashing. The Image file generated from separate compilation will not be updated in update.img. Use step-by-step flashing (refer to the OTG flashing section in the user manual).

4.2.3 Cleaning up Generated Files

Note: Please be careful. This operation will delete the compiled intermediate files and generated image files.

Compile the script to operate under the source code path.

forlinx@ubuntu: ~/work/OK3576-linux-source$ ./build.sh cleanall

Image

This operation deletes all temporary files, but does not affect the source files, including those that have already been modified.

4.3 User-defined Configuration and Compilation

4.3.1 Configuring and Compiling U-boot

Commands for compiling u-boot separately:

forlinx@ubuntu:~/work/OK3576-linux-source$ ./build.sh uboot

Please follow the step-by-step instructions to flash the Ok3576-linux-source/u-boot/uboot.img file.

4.3.2 Configuring and Compiling the Kernel (Example: Adding the ch341.c Driver)

Method 1: Configuring the graphical interface

Keyboard Shortcuts:

Button

Function

↑ ↓

Move up and down

← →

Bottom buttons for switching between left and right

Enter

Enter the sub-menu

Esc

Back to previous level / Exit

Y

Select (compile into the kernel); the symbol is [*]or[*].

N

Unselected; symbol is [ ]or< >

M

Select (compile into the kernel); the symbol is [M]or<M>.

Space

Cycle through Y/N/M

/

Search configuration options:

?

Show Help

Z

Show/Hide Options (Unmet Dependencies)

Meaning of Symbols:

Symbols

Meaning

Description

[ ]

Not Selected

Do not compile this feature

[*]

Built-in

Compiled into the kernel (bool type)

< >

Not Selected

Can be compiled as a module (tristate type)

<*>

Built-in

Compiled into the kernel (tristate type)

<M>

Module

Compiled as .ko module

(value)

String/Number

Configuration values that can be entered

--->

Sub-menu

Press Enter

---

Not available

Unfulfilled dependencies or mandatory selections

Main Menu Categories:

General setup                    # Kernel general configuration (version, compression, namespaces)
Processor type and features      # CPU architecture, SMP, NUMA, memory model
Power management options         # Power management
CPU Power Management			 # CPU frequency and idle management
Executable file formats          # ELF, script support
Memory Management options        # Memory management, huge pages, swap
Networking support               # Network protocol stack, netfilter
Device Drivers                   # Device drivers (the largest category)
  ├─ Block devices               # Hard disk, loop devices
  ├─ Network device support      # Network card drivers
  ├─ Input device support        # Keyboard, mouse, touchscreen
  ├─ Graphics support            # GPU, DRM, Framebuffer
  ├─ USB support                 # USB host/device drivers
  └─ ...
File systems                     # ext4, btrfs, NFS, FUSE
Kernel hacking                   # Debugging options, kernel log level
Security options                 # SELinux, AppArmor, kernel hardening
Cryptographic API                # Cryptographic algorithm support
Library routines                 # CRC, compression libraries

Before modifying the default configuration, you should back up the old configuration, as the old xxx_defconfig file will be modified directly.

forlinx@ubuntu:~/work/OK3576-linux-source$ cp kernel/arch/arm64/configs/OK3576-UP5-linux_defconfig kernel/arch/arm64/configs/OK3576-UP5-linux_defconfig-backup

If you wish to configure the kernel, you must first complete a full compilation; then, in the source code directory, carry out the following steps.

forlinx@ubuntu:~/work/OK3576-linux-source$ ./build.sh kconfig

After adding and modifying the configuration, save and exit, and then you can compile directly.

Image

Image

Press the / key to activate the quick search function. After entering USB_SERIAL_CH341 and pressing Enter, the option information corresponding to CH341 will be displayed.

Image

Image

Press 1 to access the specific configuration menu:

Image

You can see that this driver is not selected in the current configuration. Move the cursor to the CH341 item and press the Space key to complete the selection. The configuration is successful when the item is marked with<*>or<M>. Here,<*>means the driver is compiled directly into the kernel and cannot be unloaded after system startup;<M>means it is compiled as a kernel module, which is loaded dynamically at system power-on, and users can also manually unload the module driver.

Image

At this point, the CH341 configuration is completed. Move the cursor left and right to select “Ok”, press Enter to confirm saving and exit the menu.

Image

Method 2: Modify the default configuration file

Add “USB_SERIAL_CH341” to the kernel configuration on the development board.

forlinx@ubuntu:~/work/OK3576-linux-source$ vi kernel/arch/arm64/configs/OK3576-UP5-linux_defconfig 

Image

Add the USB_SERIAL_CH341 configuration directly to the configuration file:

Image

After adding the configuration via either of the two methods above, you need to separately compile the device tree and kernel to generate the new Image file. The modification will take effect after you replace the corresponding Image file on the development board.

forlinx@ubuntu:~/work/OK3576-linux-source$ ./build.sh kernel

Please flash the OK3576-linux-source/kernel/boot.img file in steps.

4.3.3 Configuring and Compiling Buildroot (Example: Adding gdbserver)

Note: The source code comes with a pre-compiled filesystem image:

  • OK3576-linux-source/prebuilts/forlinx/rk3576/buildroot/rootfs.ext4, using this image can significantly reduce the time for creating a system image. If you need to modify the contents or configuration of the file system (rootfs), you must remove this rootfs.ext4 image file. After removal, execute the compilation script; Buildroot will then recompile and generate a new root filesystem image;

  • Before adding the required features, you need to first determine the name of the corresponding feature macro in buildroot. There are two methods: one is to find it layer by layer according to the structure of buildroot, and the other is to directly search for the corresponding name of the feature on-line. For the gdbserver feature, first search for the macro corresponding to the GDB feature, which is BR2_PACKAGE_GDB. Search for BR2_PACKAGE_GDB in Buildroot, and enable GDBSERVER in this configuration.

Method 1: Configuring the graphical interface

Interface Operation:

Button

Function

Direction keys ↑↓

Move the cursor up and down

Enter

Enter submenu / Select item

Space

Toggle option status ([ ] → [*] → < > → ``)

Esc Esc

Return to upper menu / Exit

/

Search configuration items (enter keywords)

?

Display help information for the current option

Tab

Switch between bottom buttons (Select / Exit / Help / Save / Load)

Meaning of Symbols

Symbols

Meaning

[ ]

Unselected (not compiled)

[*]

Selected (compiled into the system)

(value)

String/number configuration item

--->

With sub-menu

(NEW)

Newly added configuration item:

Menu Categories:

Target options          # Target architecture (ARM/x86/MIPS, etc.), CPU model
Build options           # Compilation options, download path, number of parallel compilations
Toolchain              # Toolchain selection (internal/external), C library type (glibc/musl/uclibc)
System configuration   # Host name, root password, init system, /dev management
Kernel # Kernel configuration (use custom kernel or Buildroot built-in)
Target packages        # Application software packages (busybox/network tools/libraries/GUI, etc.)
  ├─ Audio and video applications   # ffmpeg, gstreamer, alsa-utils
  ├─ Networking applications        # openssh, iperf3, nginx
  ├─ Debugging, profiling and benchmark       # gdb, strace
  └─ ...
Filesystem images      # Output format (ext4/squashfs/tar/cpio/initramfs)
Bootloaders            # U-Boot/Grub configuration
Host utilities         # Host-side tools (genimage/mtools, etc.)
Legacy config          # Obsolete old configuration items

Before modifying the default configuration, you should back up the old configuration, as the old xxx_defconfig file will be modified directly.

forlinx@ubuntu:~/work/OK3576-linux-source$ cp buildroot/configs/rockchip_ok3576-up5_defconfig buildroot/configs/rockchip_ok3576-up5_defconfig-backup

If you want to configure buildroot, you must first complete a full compilation, and perform the following operations in the source code directory.

forlinx@ubuntu:~/work/OK3576-linux-source$ ./build.sh bconfig

Image

After execution, the following page appears.

Image

Press / to perform a quick search, enter BR2_PACKAGE_GDB and press Enter, then the option information corresponding to GDB will be displayed.

Image

Image

Press 1 to access the specific configuration menu:

Image

You can see that the current configuration is not selected. Press the space bar at the gdb position to select it. When it becomes[*], the selection is successfulImage

It can be seen that when gdb becomes[*], gdbserver will automatically become below-*-. At this time, the gdbserver selection is successful. Move the cursor to< Save>, press Enter to select Ok, save and exit.

Image

Method 2: Modify the default configuration file

Add the GDB configuration BR2_PACKAGE_GDB to the buildroot configuration of the development board

forlinx@ubuntu:~/work/OK3576-linux-source$ vi buildroot/configs/rockchip_ok3576-up5_defconfig

ImageOpen the configuration file and add the GDB configuration. After adding the GDB configuration, the GDBSERVER feature will automatically be available.
Image

After selecting the features, compile buildroot separately.

forlinx@ubuntu:~/work/OK3576-linux-source$ ./build.sh buildroot

Please flash the OK3576-linux-source/buildroot/output/rockchip_ok3576-up5/images/rootfs.ext4 file in steps.

4.3.4 Customization of System Partition Size

Partition table configuration file path: OK3576-linux-source/device/rockchip/rk3576/parameter.txt

The contents of the document are as follows:

FIRMWARE_VER: 1.0
MACHINE_MODEL: RK3576
MACHINE_ID: 007
MANUFACTURER: RK3576
MAGIC: 0x5041524B
ATAG: 0x00200800
MACHINE: 0xffffffff
CHECK_MASK: 0x80
PWR_HLD: 0,0,A,0,1
TYPE: GPT
GROW_ALIGN: 0
CMDLINE: mtdparts=:0x00002000@0x00004000(uboot),0x00002000@0x00006000(env),0x00002000@0x00008000(misc),0x00020000@0x0000a000(boot),0x00080000@0x0002a000(recovery),0x00010000@0x000aa000(logo),0x00400000@0x000ba000(userdata),-@0x004ba000(rootfs:grow)
uuid:rootfs=614e0000-0000-4b53-8000-1d28000054a9
uuid:boot=7A3F0000-0000-446A-8000-702F00006273

Example for uboot:

The part before @ is the partition size, and the part after @ is the starting address. The starting address of the next partition equals the starting address of the previous partition plus the partition size. Each block of the partition is 512 bytes.

0x00002000 *512byte = 8192 * 512byte = 4,194,304byte

4,194,304÷1024 = 4096KB

4096÷1024=4MB

So the size set for the uboot partition is 4MB.

Note: After adjusting the size of a certain partition, the starting addresses of subsequent partitions must be adjusted in sequence. After the configuration is completed, execute the full compilation or the complete image packaging command.

4.3.5 Complete Image Packaging

How to take effect: Package update.img

forlinx@ubuntu:~/work/OK3576-linux-source$ ./build.sh updateimg

Please completely flash the OK3576-linux-source/output/update/Image/update.img file.

5. Compiling C and Qt Applications

5.1 Redirection of the Cross Compiler

Notes: Ensure that the Ubuntu host and the development board are on the same network and can communicate with each other.

️Cross-compiler path:User Profile \ 2-Sources and Images \ 2-Cross Compiler\aarch64-buildroot-linux-gnu_sdk-buildroot.tar.gz

Copy the cross-compiler to the /home/forlinx directory.

forlinx@ubuntu:~$ ls
aarch64-buildroot-linux-gnu_sdk-buildroot.tar.gz

First extract the compressed package, then execute the following command to redirect the cross-compiler:

forlinx@ubuntu:~/aarch64-buildroot-linux-gnu_sdk-buildroot$ ./relocate-sdk.sh

5.2 C Application Program Compilation, Operation and Debugging

5.2.1 Compiling and Operation C Language Applications via Command Line

This section uses the watchdog test programme; by default, the source code is copied to the /home/forlinx/work directory.

Use the cd command to navigate to the test source code directory;.

forlinx@ubuntu:~$ cd /home/forlinx/work/OK3576-linux-source/app/forlinx/forlinx_cmd/fltest_watchdog

Set the environment variables of the cross-compilation toolchain and use the cross-compiler for cross-compilation.

forlinx@ubuntu:~/work/OK3576-linux-source/app/forlinx/forlinx_cmd/fltest_watchdog$ source /home/forlinx/aarch64-buildroot-linux-gnu_sdk-buildroot/environment-setup
forlinx@ubuntu:~/work/OK3576-linux-source/app/forlinx/forlinx_cmd/fltest_watchdog$ aarch64-linux-gcc watchdog.c -o fltest_watchdog

Use the file command to view the generated file information.

forlinx@ubuntu:~/work/OK3576-linux-source/app/forlinx/forlinx_cmd/fltest_watchdog$ /usr/bin/file fltest_watchdog 
fltest_watchdog: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, not stripped

From the result, you can see that the compiled file is for 64-bit ARM architecture.

Copy the fltest _ watchdog generated by compiling to the board through U disk or FTP, for example, under the/root path. Take U disk as an example, copy it to the development board and run the test.

root@OK3576-buildroot:~# cp /run/media/sda1/fltest_watchdog /root/
root@OK3576-buildroot:~# ./fltest_watchdog
Watchdog Ticking Away!

5.2.2 Debugging C Language Applications via Command Line

GDB implements remote debugging in embedded systems through gdbserver (target board) + gdb (host). It can set breakpoints, execute step by step, view variables and call stacks, directly read and write hardware registers and memory addresses, analyze multi-thread status and crash scenes, and locate bugs and debug driver programs without modifying the code.

Write the demo and compile it on Ubuntu.

forlinx@ubuntu:~$ cat demo.c 
#include <stdio.h>

int add(int a, int b) {
    int result = a + b;
    return result;
}

int main() {
    int x = 5;
    int y = 10;
    int sum;

    printf("x = %d, y = %d\n", x, y);

    sum = add(x, y);

    printf("sum = %d\n", sum);

    return 0;
}

Add the cross-compiler path and execute the following command to generate the binary demo file.

Notes: The -g parameter needs to be added during the compilation process to retain debugging information.

forlinx@ubuntu:~$ export PATH=/home/forlinx/aarch64-buildroot-linux-gnu_sdk-buildroot/bin/:$PATH
forlinx@ubuntu:~$ aarch64-linux-gcc -g demo.c -o demo
forlinx@ubuntu:~$ ls demo
demo

Image

Environment Setup:

Ensure that the Ubuntu host and the development board are on the same network and can communicate with each other.

Host:

Set the host IP according to 3.1.4 of the compilation manual.

Image

Development board IP Settings:

root@OK3576-UP5-buildroot:~# ifconfig eth0 172.20.0.145

Debugging:

Development Board:

Put the test demo on the development board, and execute gdbserver in the corresponding path. At this time, it will monitor the host end.

root@OK3576-UP5-buildroot:~# gdbserver 172.20.0.176:1234 demo

Image

Host:

Use the gdb of the cross-compilation toolchain for debugging.

forlinx@ubuntu:~$ aarch64-linux-gdb demo
GNU gdb (GDB) 13.2
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-pc-linux-gnu --target=aarch64-buildroot-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from demo...
(gdb) 

Connect to the development board end.

(gdb) target remote 172.20.0.145:1234

Image

After the connection is successful, you can start debugging officially.

Quick Commands:

File

Select the debugging file

list(l)

List source code

break(b)

Set breakpoint

info breakpoints(info b)

List breakpoints

continue(c)

Resume program execution until a breakpoint is triggered or the program ends

print(p)

Print a variable or variable address

quit(q)

Exit GDB mode

Select the debugging file.

(gdb) file demo

Image

View the file content.

(gdb) l

Image

Insert breakpoints and view breakpoints.

(gdb) b main
Breakpoint 1 at 0x55555557d4: file demo.c, line 9.
(gdb) b 13
Breakpoint 2 at 0x55555557e4: file demo.c, line 13.
(gdb) b 17
Breakpoint 3 at 0x5555555808: file demo.c, line 17.
(gdb) info b
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x00000055555557d4 in main at demo.c:9
2       breakpoint     keep y   0x00000055555557e4 in main at demo.c:13
3       breakpoint     keep y   0x0000005555555808 in main at demo.c:17

Image

Enter c to execute to the breakpoint until the execution ends.

Image

Print on the development board end:

Image

5.3 Qt Creator Environment Configuration

Qt is a cross-platform graphics development library that supports multiple operating systems. Before compilation, you need to configure the Qt Creator environment for cross-compilation.

5.3.1 Configuration of the Cross Compiler

Navigation to Qt Creator via its installation directory:

forlinx@ubuntu:~/qtcreator-4.7.0/bin$ ./qtcreator

Access to Tools – Options on the Qt Creator menu bar (as shown in the figure below):

Image

Selection of Kits, Compilers, followed by Add – GCC – C (as shown in the figure below):

Image

Input of “GCC” in the Name field, input of the following path in the Compiler path field, and click on “Apply”.

Path:/home/forlinx/aarch64-buildroot-linux-gnu_sdk-buildroot/bin/aarch64-linux-gcc

Image

Selection of Kits, Compilers, followed by Add – GCC – C++:

Image

Input of “G++” in the Name field, input of the following path in the Compiler path field, and click on “Apply”:

Path:/home/forlinx/aarch64-buildroot-linux-gnu_sdk-buildroot/bin/aarch64-linux-g++

Image

5.3.2 Configuration of Qt Versions

Selection of kits and qt versions, followed by the add operation:

Image

Selection of /home/forlinx/aarch64-buildroot-linux-gnu_sdk-buildroot/bin/qmake in the pop-up dialog box and click on “Open”.

Image

Input of QMAKE in the Version name field within the Qt Versions configuration box, then click “Apply”.

Image

5.3.3 Configuration of Kits

Kits are a set of build tools used to configure and select development environments. They are particularly useful for projects that involve multiple Qt libraries. Integrate the previously added cross-compiler and Qt Version into the Kits to build a compilation environment suitable for the development board.

Click “Kits” and then the “Add” to bring up the configuration section.

Image

Self-modification of the Name; selection of GCC and G++ for the Compiler; selection of QMAKE for Qt Version; followed by the clicks on “Apply” and “OK”

Image

5.4 Compilation, Operation and Debugging of Qt Projects

5.4.1 Command-Line Compilation and Operation of Qt Applications

Switching to the path of Qt source codes:

forlinx@ubuntu:~$ cd /home/forlinx/work/OK3576-linux-source/app/forlinx/flapp/src/watchdog							

Configuration of environment variables:

forlinx@ubuntu:~/work/OK3576-linux-source/app/forlinx/flapp/src/watchdog$ source /home/forlinx/aarch64-buildroot-linux-gnu_sdk-buildroot/environment-setup		

Configuration of the project:

forlinx@ubuntu:~/work/OK3576-linux-source/app/forlinx/flapp/src/watchdog$ qmake	

Compilation of the project:

forlinx@ubuntu:~/work/OK3576-linux-source/app/forlinx/flapp/src/watchdog$ make	

Path of the generated executable file:

forlinx@ubuntu:~$ cd /home/forlinx/work/OK3576-linux-source/app/forlinx/flapp_out/release/bin		

Operations: Copy the compiled executable file to the development board via a USB flash drive, FTP or other methods, then conduct operation and testing.

forlinx@ubuntu:~/work/OK3576-linux-source/app/forlinx/flapp_out/release/bin$ ls
fltest_qt_watchdog					

5.4.2 Compilation and Operation of Qt Applications via Qt Creator

Opening of Qt Creator in the development environment (please open it according to your actual paths)

forlinx@ubuntu:~$ cd qtcreator-4.7.0/bin/
forlinx@ubuntu~/qtcreator-4.7.0/bin$ ./qtcreator &

Click on File – Open File or Project in Qt Creator

Image

Selection of the watchdog.pro project in the pop-up window and click on “Open”.

Image

Configuration of the project suite: Select 35XXLinux and click on Configure Project.

Image

The project interface is displayed as shown in the figure below:

Image

Click on Build – Clean All to clean the project.

Image

Click on Projects and Build, then deselect Shadow build.

Image

Click on the “hammer icon” to start compilation.

Image

Once the Build progress bar in the bottom-right corner has completed, this indicates that the compilation is finished. At this point, you will see the newly generated binary files in the specified directory, as shown below:

forlinx@ubuntu:~/work/OK3576-linux-source/app/forlinx/flapp_out/debug/bin $ ls
total 64
-rwxrwxr-x 1 forlinx forlinx 63120 11月 4 19:15 fltest_qt_watchdog

Copy the compiled executable file to the board via a USB drive, FTP, or other methods. Once copied to the development board, run the test.

5.4.3 Remote Debugging of Qt Applications

Note: Configure the Ubuntu virtual machine in bridged mode to ensure that the Ubuntu virtual machine and the development board are on the same network for mutual communication.

Set development board ssh password.

root@OK3576-UP5-buildroot:~# passwd root
Changing password for root
New password:							# Input password "root"
Bad password: too short
Retype password:						# Confirm password "root"
passwd: password for root changed by root

If there is no password, leave it blank. However, note that some platforms do not allow SSH login with a blank password. It is recommended to set a password before performing operations.

Install debugging software in Ubuntu virtual machine.

forlinx@ubuntu:~$ sudo apt-get install gdb-multiarch

Add the gdb tool.

Access to Tools – Options on the Qt Creator menu bar (as shown in the figure below):

Image

Click Kits–>Debuggers–>Add.Image

Configuration of “GDB” as the Name, configuration of “/usr/bin/gdb-multiarch” as the Path, and click on “Apply”

Image

Configure devices.

Tools->options->Devices->Devices->Add

Image

Select “Generic Linux Device” and click on “Start Wizard”.

Image

Input “Generic Linux Device”, the IP address of the development board, and the SSH account and password of the development board, then click on “Next”.

Image

Click “Finish”.

ImageThe figure below indicates the normal connection between the Ubuntu virtual machine and the development board, then click on “Close”

Image

Click “Apply”.

Image

Configure the Kit Suite.

Open the project file and select the Kit package you set up earlier.

Image

Open the project.

Click “File” and select “Open File or Project”.

Image

Select the watchdog. pro project and click “Open”.

Image

Select the 35XX Linux suite to configure the project.

Image

Note: To compile and debug this demo remotely, please make modifications to the source code.

Edit the “watchdog.pro” file and add the following content:

target.path = /var/run
QMAKE_CXXFLAGS += -g
QMAKE_CXXFLAGS_DEBUG += -O0

Image

Comment out the following content in buildout.pri:

#appdata.files = $$PWD/../resource/*

Image

Save the file.

Configuration of the project:

Image

Compiling and run the application:

Click on the “hammer icon” to compile the project, then click on the “triangle icon” to run the program on the development board.

Image

The corresponding Qt demo will be displayed after the operation on the development board.
Image

root@OK3576-UP5-buildroot:~# cd /var/run
root@OK3576-UP5-buildroot:/var/run# ls
fltest_qt_watchdog									# The virtual machine copies the executable file to the specified path via SSH

Close the application:

Click on the cross icon to close the application.

Image

Click on “Force Quit”.

Image

Remote Debugging the Application:

Set a breakpoint at the line number on the left side of the codes:

Image

Click on the triangle-and-bug icon to start code debugging:

Image

Click on the icon below to proceed with breakpoint debugging:

Image

Click on the button below to stop debugging:

Image