SDK Environment Deployment(x86_64 platform)
Omni3576-SDK is primarily developed and tested on the Ubuntu 22.04 LTS system. To minimize potential compilation errors and other issues during the development process, it is recommended that users utilize the same operating system as us to ensure consistency and stability in the development environment. Note: This SDK is limited to compiling Linux systems. The SDK source code for Android 14 has not yet been publicly released. The SDK should run on an X86_64 architecture Ubuntu system; other architectures may lead to compatibility issues.
1. Introduction to Luckfox-Omni3576-SDK
SDK (Software Development Kit) is a collection of tools, libraries, sample code, documentation, and related support files to help developers build applications for specific platforms, operating systems, hardware, or other software. The operating system on the development board is typically customized and developed based on the SDK. The SDK provides the basic software required for the development board (kernel, drivers, Bootloader, etc.), which developers can customize to create the final system firmware that runs on the development board.
1.1 SDK Directory Explanation
The SDK project directory includes directories such as buildroot, debian, yocto, app, kernel, u-boot, device, docs, external, and prebuilts. It uses a manifest to manage the repositories and the repo tool to manage each directory or its corresponding git projects.
SDK Directory Structure.
├── build.sh -> device/rockchip/common/scripts/build.sh ---- SDK compilation script
├── app ----------------------------- Contains upper-layer applications (mainly demo apps)
├── buildroot ----------------------- Root filesystem developed based on Buildroot (2024)
├── debian -------------------------- Root filesystem developed based on Debian Bookworm (12)
├── device ----------------- Contains chip board-level configurations and scripts/files for SDK compilation and firmware packaging
├── docs ---------------------------- Contains general development guidance documents, chip platform-related documents, Linux system development-related documents, and other reference materials
├── external --------------------- Contains third-party related repositories, including display, audio and video, cameras,networking, security, etc.
├── kernel -------------------------- Contains code for Kernel development
├── output -------------------------- Stores information on generated firmware, compilation information, XML files, host environment, etc.
├── prebuilts ----------------------- Contains cross-compilation toolchains
├── rkbin --------------------------- Contains Rockchip-related binaries and tools
├── rockdev ------------------------- Stores compiled output firmware, actually a symlink to output/firmware
├── tools --------------------------- Contains commonly used tools for Linux and Windows operating systems
├── u-boot -------------------------- Contains U-Boot code developed based on version v2017.09
└── yocto --------------------------- Contains root filesystem developed based on Yocto 5.0Image Storage Directory.
rockdev/
├── MiniLoaderAll.bin --------------- SPL bootloader, responsible for initializing the basic hardware and loading subsequent firmware
├── misc.img ------------------------- Compatible with the Android boot process
├── parameter.txt -------------------- Partition table information
├── uboot.img ------------------------ U-Boot image
├── boot.img ------------------------ Kernel image
├── rootfs.img ----------------------- Root filesystem image file
├── update.img ----------------------- Complete image file
└── recovery.img --------------------- System maintenance
1.2 SDK Configuration File Explanation
Omni3576 series SDK configuration files are located in the
device/rockchip/rk3576directory.-rw-rw-r-- 1 xt xt 1673 9月 11 09:37 boot4recovery.its
-rw-rw-r-- 1 xt xt 1430 9月 11 09:37 boot.its
-rwxrwxr-x 1 xt xt 293 9月 11 09:37 luckfox_omni3576_buildroot_defconfig
-rwxrwxr-x 1 xt xt 290 9月 11 09:37 luckfox_omni3576_debian_defconfig
-rw-rw-r-- 1 xt xt 477 9月 11 09:37 parameter-ab.txt
-rwxrwxr-x 1 xt xt 480 9月 11 09:37 parameter.txt
-rw-rw-r-- 1 xt xt 1429 9月 11 09:37 zboot.itsEnvironment variables corresponding to different systems.
RK_ROOTFS_SYSTEM=buildroot # Compile Buildroot system
RK_ROOTFS_SYSTEM=debian # Compile Debian system
2. Compiling Images in Ubuntu 22.04 Environment
1.1 Setting Up the Compilation Environment
Install dependency environments.
sudo apt updatesudo 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 python2Configure the Python environment.
# By default, it links to python3
$ python --version
Python 3.10.12
which python2
sudo ln -sf /usr/bin/python2 /usr/bin/pythonDownload the latest SDK from the cloud link and extract the files (please do not directly copy the extraction command, as the SDK name may change with updates).
mkdir Omni3576-sdk && cd Omni3576-sdk
tar -xzvf luckfox-omni3576-241024.tar.gzUnpack the decompressed files.
.repo/repo/repo sync -lSet environment variables.
export RK_ROOTFS_SYSTEM=buildroot # Compile Buildroot system
export RK_ROOTFS_SYSTEM=debian # Compile Debian systemCompile the Image.
$ ./build.sh lunch
############### Rockchip Linux SDK ###############
Manifest: rk3576_linux6.1_release_v1.0.0_20240620.xml
Log colors: message notice warning error fatal
Parsing supported commands...
Log saved at /home/xt/new3576/output/sessions/2024-10-22_18-00-36
Pick a defconfig:
1. luckfox_omni3576_buildroot_defconfig
2. luckfox_omni3576_debian_defconfig
Which would you like? [1]: 1
Switching to defconfig: /home/xt/new3576/device/rockchip/.chip/luckfox_omni3576_buildroot_defconfig
mkdir -p /home/xt/new3576/output/kconf/lxdialog
make CC="gcc" HOSTCC="gcc" \
obj=/home/xt/new3576/output/kconf -C /home/xt/new3576/device/rockchip/common/kconfig -f Makefile.br conf
make[1]: Entering directory '/home/xt/new3576/device/rockchip/common/kconfig'
gcc -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -DCURSES_LOC="<ncurses.h>" -DNCURSES_WIDECHAR=1 -DLOCALE -I/home/xt/new3576/output/kconf -DCONFIG_=\"\" -MM *.c > /home/xt/new3576/output/kconf/.depend 2>/dev/null || :
gcc -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -DCURSES_LOC="<ncurses.h>" -DNCURSES_WIDECHAR=1 -DLOCALE -I/home/xt/new3576/output/kconf -DCONFIG_=\"\" -c conf.c -o /home/xt/new3576/output/kconf/conf.o
gcc -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -DCURSES_LOC="<ncurses.h>" -DNCURSES_WIDECHAR=1 -DLOCALE -I/home/xt/new3576/output/kconf -DCONFIG_=\"\" -I. -c /home/xt/new3576/output/kconf/zconf.tab.c -o /home/xt/new3576/output/kconf/zconf.tab.o
gcc -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -DCURSES_LOC="<ncurses.h>" -DNCURSES_WIDECHAR=1 -DLOCALE -I/home/xt/new3576/output/kconf -DCONFIG_=\"\" /home/xt/new3576/output/kconf/conf.o /home/xt/new3576/output/kconf/zconf.tab.o -o /home/xt/new3576/output/kconf/conf
rm /home/xt/new3576/output/kconf/zconf.tab.c
make[1]: Leaving directory '/home/xt/new3576/device/rockchip/common/kconfig'
#
# configuration written to /home/xt/new3576/output/.config
#
$ ./build.sh- Note that when compiling for Ubuntu, it is important to use
sudo; otherwise, it may cause filesystem errors. - The following sections will not distinguish between the two command sets; please choose according to your situation.
- Note that when compiling for Ubuntu, it is important to use
1.2 Partial Compilation
Compile U-Boot Separately
./build.sh uboot- Generated image files:
rockdev/MiniLoaderAll.bin,rockdev/uboot.img
- Generated image files:
Compile the Kernel Separately
./build.sh kernel- Generated image file:
rockdev/boot.img
- Generated image file:
Firmware Packaging
./build.sh firmware
3. File Sharing
File transfer between the virtual machine and Windows computer can be achieved using Samba services for file sharing. The virtual machine's filesystem can be easily accessed through the Network Neighborhood in Windows, making it very convenient.
3.1 Ubuntu Environment Configuration
Download and install Samba.
sudo apt-get update
sudo apt-get install samba -yConfigure the Samba service.
sudo vim /etc/samba/smb.conf
# Add the following content at the end of the file
[share]
comment = share folder
browseable = yes
path = /home/luckfox
create mask = 0700
directory mask = 0700
valid users = luckfox
force user = luckfox
force group = luckfox
public = yes
available = yes
writable = yes- Where "luckfox" is the hostname; fill in according to your actual hostname.
Set the sharing account password.
sudo smbpasswd -a luckfoxCheck the IP address of the virtual machine or host.
luckfox@luckfox:~/Luckfox-Pico/luckfox-pico$ ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.10.61 netmask 255.255.252.0 broadcast 192.168.11.255
inet6 fe80::814f:a51e:5f24:f0f7 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:d2:60:b9 txqueuelen 1000 (Ethernet)
RX packets 699559 bytes 754875799 (754.8 MB)
RX errors 0 dropped 4 overruns 0 frame 0
TX packets 53024 bytes 3278048 (3.2 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 190 bytes 24144 (24.1 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 190 bytes 24144 (24.1 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
3.2 Windows Environment
Enter the IP address in the Windows address bar (fill in according to your actual IP address).

The default password for the virtual machine account is "luckfox".

Successfully log in to the virtual machine or host.

4. Loading KO Driver Modules in Linux
4.1 Introduction to KO Files
In the Linux operating system, .ko files are the extension for kernel module files. Kernel modules are pieces of code that can be loaded and unloaded at runtime, allowing for the extension of Linux kernel functionalities without the need to recompile the entire kernel. Each .ko file contains the module's code and metadata, enabling users to add or remove specific functionalities, such as drivers or filesystem support, without rebooting the system.
4.2 Advantages of KO Files
- Dynamic Loading and Unloading: Kernel modules can be dynamically loaded into the kernel at runtime and can be unloaded at any time without rebooting the system. This allows system administrators and developers to add, test, or fix functionalities without interrupting system operations.
- Resource Efficiency: Kernel modules allow less frequently used functionalities to be loaded as modules, thus reducing the overall size of the system kernel and memory usage. This helps improve resource utilization.
- Customizability: Kernel modules allow users to add or remove specific functionalities as needed, facilitating a customized system. This is especially useful for embedded systems, specific hardware support, and particular application scenarios.
- Reduced Compilation Time: Recompiling the entire kernel can be time-consuming, while using kernel modules avoids this issue. Only the required modules need to be compiled and loaded, saving time and resources.
- Rapid Debugging and Development: Kernel modules can be loaded and unloaded without rebooting the system, making debugging and developing drivers and other kernel code more efficient.
- Ease of Maintenance: The independence of kernel modules allows them to be maintained and upgraded separately from the entire kernel, reducing the complexity of system maintenance.
- Increased Compatibility: Kernel modules can support multiple kernel versions as needed, enhancing software compatibility and flexibility.
4.3 Application Example
Download the project files Click to Download. The entire project contains only two files: helloworld.c and a Makefile for controlling the compilation.
Copy the project files to an Ubuntu host or virtual machine where the Luckfox Omni3576 SDK has been successfully installed.
Open and modify the
Makefileso that themakecommand can navigate to the specified kernel source code directory, which is thekernel-6.1directory in the Luckfox Omni3576 SDK. It is recommended to download theMakefiledirectly; if you copy and paste, please adjust the Tab indentation accordingly.obj-m += helloworld.o
KDIR:=/home/xt/zt-ssd/kernel-6.1
PWD?=$(shell pwd)
all:
make -C $(KDIR) M=$(PWD) modules
echo $(PWD)
clean:
rm -f *.ko *.o *.mod *.mod.o *.mod.c *.symvers *.orderCode Section:
#include <linux/module.h>
#include <linux/init.h>
static int helloworld_init(void)
{
printk("helloworld!\n");
return 0;
}
static void helloworld_exit(void)
{
printk("helloworld bye\n");
}
module_init(helloworld_init);
module_exit(helloworld_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Luckfox");
MODULE_VERSION("V1.0");- Module Load Function: When a kernel module is loaded via the
insmodormodprobecommand, the module's load function is automatically executed by the kernel to complete the module's related initialization tasks. Linux kernel module load functions are generally declared with__initand specified in the formatmodule_init(function_name). It returns an integer value, where 0 indicates successful initialization. In case of failure, an error code should be returned. In the Linux kernel, the error code is a negative value close to 0. - Module Unload Function: When a module is unloaded via the
rmmodcommand, the module's unload function is automatically executed by the kernel to perform the reverse of the module load function. Linux kernel module unload functions are generally declared with__exitand are executed during module unloading, returning no value and specified in the formatmodule_exit(function_name). - Module License Declaration (LICENSE): This describes the licensing rights of the kernel module. If LICENSE is not declared, a warning about kernel pollution (Kernel Tainted) will be issued when the module is loaded. Acceptable LICENSEs in the Linux kernel module realm include “GPL,” “GPL v2,” “GPL and additional rights,” “Dual BSD/GPL,” “Dual MPL/GPL,” and “Proprietary” (the use of non-GPL licensing like “Proprietary” is debated in academic and legal circles). In most cases, kernel modules should adhere to GPL-compatible licenses. The most common declaration in Linux kernel modules is
MODULE_LICENSE("GPL v2"). - Module Author and Other Information Declarations:
MODULE_AUTHOR,MODULE_DESCRIPTION,MODULE_VERSION,MODULE_DEVICE_TABLE, andMODULE_ALIASdeclare the module's author, description, version, device table, and alias, respectively.
- Module Load Function: When a kernel module is loaded via the
Navigate to the project folder and execute the following commands (where the address of
CROSS_COMPILEneeds to be filled in according to the actual path of the SDK):export ARCH=arm64 CROSS_COMPILE=/home/xt/zt-ssd/prebuilts/gcc/linux-x86/aarch64/gcc-arm-10.3-2021.07-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-
make
#执行 make 后打印信息
$ make
make -C /home/xt/zt-ssd/kernel-6.1 M=/home/xt/ko-test modules
make[1]: Entering directory '/mnt/zitai-ssd/xt/kernel-6.1'
CC [M] /home/xt/ko-test/helloworld.o
MODPOST /home/xt/ko-test/Module.symvers
CC [M] /home/xt/ko-test/helloworld.mod.o
LD [M] /home/xt/ko-test/helloworld.ko
make[1]: Leaving directory '/mnt/zitai-ssd/xt/kernel-6.1'
echo /home/xt/ko-test
/home/xt/ko-testUpload
helloworld.koto the development board using methods like SCP or ADB.scp helloworld.ko root@192.168.10.188:/Execute the following command for verification.
root@rk3576-buildroot:/# insmod helloworld.ko
[13206.339477] helloworld!
root@rk3576-buildroot:/# rmmod helloworld.ko
[13181.378401] helloworld byeFinally, use
dmesgto check the logs.root@rk3576-buildroot:/# dmesg | grep hello
[13105.396731] helloworld!
[13181.378401] helloworld bye
5. Kernel Configuration
menuconfig is a configuration tool for the Linux kernel that provides a terminal graphical interface, making it easy to intuitively modify configuration files while automatically handling configuration dependencies. Other similar configuration interfaces include nconfig and xconfig. Below is an introduction to the basic functions and operations of menuconfig.
5.1 Configuration Interface
Execute the following commands to open the configuration interface:
cd <SDK Directory>/kernel-6.1
make ARCH=arm64 luckfox_linux_defconfig
make ARCH=arm64 menuconfig
make ARCH=arm64 savedefconfig
cp defconfig arch/arm64/configs/luckfox_linux_defconfig
5.2 Basic Operations
The configuration interface displayed after executing the command is as follows:
From the top of the interface, we can see the basic operations and instructions for menuconfig.
Key Operations:
- ↑↓PgUpPgDn: Browse and select kernel features.
- ←→: Select actions like Select, Exit, etc.
- Enter: Enter submenus.
- Y: Select this feature.
- N: Exclude this feature.
- M: Select as a module.
- Esc: Press Esc twice to return to the previous menu.
- ?: View help information for this feature.
- /: Search.
Legend Explanation:
[*]: Selected item.[ ]: Unselected item.<M>: Selected item (as a module).< >: Unselected item (as a module).
The middle area is where users select various functionalities. You can navigate using the up and down arrow keys and also directly jump to a line by pressing the corresponding colored letter, e.g., the first letter "K" of Kernel Features will jump directly to that line when the "K" key is pressed.
The bottom area includes some commonly used operation options, providing users with important interaction functionalities. Their roles are as follows:
<Select>: Enter the submenu of the currently highlighted configuration item.<Exit>: Exit the current menu and return to the previous level.<Help>: Provide help information for the currently highlighted configuration item.<Save>: Save the current configuration changes without exiting the configuration tool.<Load>: Load a specified configuration file.
5.3 Feature Summary
The middle section of the kernel configuration interface is a multi-level menu system. You can navigate using the up and down arrow keys, press Enter to enter submenus, and press Esc to return to the previous menu. Through this interface, users can flexibly configure the kernel according to system needs, selecting necessary features and drivers to build a customized kernel suitable for specific hardware and purposes. Below are the main items in the Linux kernel configuration interface:
- General setup: Basic runtime configuration.
- Kernel Features: Configuration of core functionalities, such as modularization and block device support.
- CPU Power Management: Configure CPU power management options.
- Enable loadable module support: Whether to support kernel modules.
- IO Schedulers: Configure disk I/O schedulers.
- Networking support: Configure network support, including protocols and devices.
- Device Drivers: Configure various device drivers, such as input devices, USB devices, etc.
- File systems: Configure filesystem support and choose supported filesystem types.
- Security options: Configure kernel security-related options.
- Cryptographic API: Configure support for cryptographic APIs.
6. Buildroot Configuration
Buildroot is a tool specifically designed for embedded systems, aimed at simplifying the build process of embedded Linux systems. By configuring Buildroot, you can customize the software packages and libraries included in the embedded system to meet specific needs.
Open the configuration interface.
cd buildroot
make ARCH=arm64 luckfox_omni3576_defconfig
make ARCH=arm64 menuconfigSave the configuration.
make ARCH=arm64 savedefconfig
cd ..
./build.sh rootfs