Skip to main content

SDK Environment Deployment(on the PC)

The Luckfox Pico-SDK is primarily developed and tested on the Ubuntu LTS system, with a focus on supporting the Ubuntu 22.04 version. If your system is Ubuntu 22.04, you only need to install the corresponding dependencies and compile. To ensure compatibility with different versions of Ubuntu, a convenient Docker environment is also provided for users.Note: Following the steps in the documentation will allow you to successfully compile the image. If errors occur, please check your environment. For example, if you encounter environment variable errors while compiling with WSL2, such as Your PATH contains spaces, TABs, and/or newline (\n) characters. This doesn't work. Fix your PATH, you will need to remove spaces, tabs, and newlines.

export PATH=$(echo "$PATH" | tr -d ' \t\n')

1. Building Images in Ubuntu 22.04 Environment

1.1 Setting up the Compilation Environment

  1. Install dependencies:

    sudo apt update

    sudo apt-get install -y git ssh make gcc gcc-multilib g++-multilib module-assistant expect g++ gawk texinfo libssl-dev bison flex fakeroot cmake unzip gperf autoconf device-tree-compiler libncurses5-dev pkg-config bc python-is-python3 passwd openssl openssh-server openssh-client vim file cpio rsync
  2. Obtain the latest SDK:

    git clone https://github.com/LuckfoxTECH/luckfox-pico.git
  3. Compile SDK

    luckfox@luckfox:~$ ./build.sh lunch
    You're building on Linux
    Lunch menu...pick the Luckfox Pico hardware version:
    选择 Luckfox Pico 硬件版本:
    [0] RV1103_Luckfox_Pico
    [1] RV1103_Luckfox_Pico_Mini_A
    [2] RV1103_Luckfox_Pico_Mini_B
    [3] RV1103_Luckfox_Pico_Plus
    [4] RV1106_Luckfox_Pico_Pro_Max
    [5] RV1106_Luckfox_Pico_Ultra
    [6] RV1106_Luckfox_Pico_Ultra_W
    [7] custom
    Which would you like? [0~7][default:0]: 3
    Lunch menu...pick the boot medium:
    选择启动媒介:
    [0] SD_CARD
    [1] SPI_NAND
    Which would you like? [0~1][default:0]: 1
    Lunch menu...pick the system version:
    选择系统版本:
    [0] Buildroot(Support Rockchip official features)
    Which would you like? [0~1][default:0]: 0
    [build.sh:info] Lunching for Default BoardConfig_IPC/BoardConfig-SPI_NAND-Buildroot-RV1103_Luckfox_Pico_Plus-IPC.mk boards...
    [build.sh:info] Running build_select_board succeeded.

    luckfox@luckfox:~$ ./build.sh

1.2 SDK Directory Structure

  1. SDK directory structure:

    ├── build.sh -> project/build.sh ---- SDK compilation script
    ├── media --------------------------- Multimedia encoding/decoding, ISP, etc. (can be independently compiled)
    ├── sysdrv -------------------------- U-Boot, kernel, rootfs directory (can be independently compiled)
    ├── project ------------------------- Reference applications, compilation configurations, and script directory
    ├── output -------------------------- Directory for storing image files after SDK compilation
    └── tools --------------------------- Image burning and burning tools
  2. Image storage directory:

    output/
    ├── image
    │ ├── download.bin ---------------- Device-side program for upgrading communication of burning tools, only downloaded to the board's memory
    │ ├── env.img --------------------- Includes partition table and boot parameters
    │ ├── uboot.img ------------------- U-Boot image
    │ ├── idblock.img ----------------- Loader image
    │ ├── boot.img -------------------- Kernel image
    │ ├── rootfs.img ------------------ Kernel image
    │ └── userdata.img ---------------- Userdata image
    └── out
    ├── app_out --------------------- Files compiled after reference application compilation
    ├── media_out ------------------- Files compiled after media-related compilation
    ├── rootfs_xxx ------------------ File system packaging directory
    ├── S20linkmount ---------------- Partition mounting script
    ├── sysdrv_out ------------------ Files compiled after sysdrv compilation
    └── userdata -------------------- Userdata

1.3 SDK Configuration File Explanation

  1. Luckfox-Pico series SDK configuration files are located in the project/cfg/BoardConfig_IPC directory.

    BoardConfig-EMMC-Buildroot-RV1106_Luckfox_Pico_Ultra-IPC.mk
    BoardConfig-EMMC-Buildroot-RV1106_Luckfox_Pico_Ultra_W-IPC.mk
    BoardConfig-EMMC-Ubuntu-RV1106_Luckfox_Pico_Ultra-IPC.mk
    BoardConfig-EMMC-Ubuntu-RV1106_Luckfox_Pico_Ultra_W-IPC.mk
    BoardConfig-SD_CARD-Buildroot-RV1103_Luckfox_Pico-IPC.mk
    BoardConfig-SD_CARD-Buildroot-RV1103_Luckfox_Pico_Mini_A-IPC.mk
    BoardConfig-SD_CARD-Buildroot-RV1103_Luckfox_Pico_Mini_B-IPC.mk
    BoardConfig-SD_CARD-Buildroot-RV1103_Luckfox_Pico_Plus-IPC.mk
    BoardConfig-SD_CARD-Buildroot-RV1106_Luckfox_Pico_Pro_Max-IPC.mk
    BoardConfig-SD_CARD-Ubuntu-RV1103_Luckfox_Pico-IPC.mk
    BoardConfig-SD_CARD-Ubuntu-RV1103_Luckfox_Pico_Mini_A-IPC.mk
    BoardConfig-SD_CARD-Ubuntu-RV1103_Luckfox_Pico_Mini_B-IPC.mk
    BoardConfig-SD_CARD-Ubuntu-RV1103_Luckfox_Pico_Plus-IPC.mk
    BoardConfig-SD_CARD-Ubuntu-RV1106_Luckfox_Pico_Pro_Max-IPC.mk
    BoardConfig-SPI_NAND-Buildroot-RV1103_Luckfox_Pico_Mini_B-IPC.mk
    BoardConfig-SPI_NAND-Buildroot-RV1103_Luckfox_Pico_Plus-IPC.mk
    BoardConfig-SPI_NAND-Buildroot-RV1106_Luckfox_Pico_Pro_Max-IPC.mk
    rv1103-spi_nor-post.sh
    rv1106-spi_nor-post.sh
  2. Taking 'BoardConfig-EMMC-Ubuntu-RV1106_Luckfox_Pico_Pro_Max-IPC.mk' as an example, key file configurations are explained.

    # Config CMA size in environment
    export RK_BOOTARGS_CMA_SIZE="66M"

    # Kernel dts
    export RK_KERNEL_DTS=rv1106g-luckfox-pico-pro-max.dts

    # Target boot medium: emmc/spi_nor/spi_nand
    export RK_BOOT_MEDIUM=emmc

    export RK_PARTITION_CMD_IN_ENV="32K(env),512K@32K(idblock),256K(uboot),32M(boot),512M(oem),256M(userdata),6G(rootfs),-(media)"

    # Target rootfs : ubuntu(only emmc)/buildroot/busybox
    export LF_TARGET_ROOTFS=ubuntu

    # SUBMODULES : gitee/gitee
    export LF_SUBMODULES_BY=gitee

    # Buildroot defconfig
    export RK_BUILDROOT_DEFCONFIG=luckfox_pico_defconfig
    • RK_BOOTARGS_CMA_SIZE: Allocate memory for the camera; if not using the camera, modify it to 1M.
    • RK_KERNEL_DTS: Specify the device tree file.
    • RK_BOOT_MEDIUM: Specify the target boot medium, which can be emmc (SD card), spi_nor (SPI NOR Flash), or spi_nand (SPI NAND Flash).
    • RK_PARTITION_CMD_IN_ENV:This information is used for configuring the partition table. If you need to match the storage space with the SD card, you can modify the rootfs partition.
    • LF_TARGET_ROOTFS: Specify the target root file system (Root File System).
    • LF_SUBMODULES_BY: Specify the source of submodules.
    • RK_BUILDROOT_DEFCONFIG: Specify the Buildroot configuration file.

1.4 Compiling Images

From "1.3 SDK Configuration File Explanation," it can be seen that the Ubuntu image only supports SD card boot, while the Buildroot image supports both TF card and SPI NAND FLASH boot.

  1. If you need to compile the Ubuntu system and use the gitee source, modify the corresponding board-type mk file to change LF_SUBMODULES_BY to gitee, like this:

    LF_SUBMODULES_BY=gitee
  2. Install the cross-compilation toolchain:

    cd {SDK_PATH}/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/
    source env_install_toolchain.sh
  3. Compile all images:

    cd luckfox-pico

    # Compile busybox/buildroot
    ./build.sh lunch
    ./build.sh

    # Compile ubuntu
    sudo ./build.sh lunch
    sudo ./build.sh
    • Note: When compiling Ubuntu, be sure to use sudo to avoid file system errors.
    • The following instructions will not distinguish between the two, please choose according to your situation.

1.4.1 Partial Compilation

  1. Compile U-Boot separately:

    ./build.sh clean uboot
    ./build.sh uboot
    • Generated image files: output/image/MiniLoaderAll.bin and output/image/uboot.img
  2. Compile the kernel separately:

    ./build.sh clean kernel
    ./build.sh kernel
    • Generated image file: output/image/boot.img
  3. Compile rootfs separately:

    ./build.sh clean rootfs
    ./build.sh rootfs
    • Note: After compilation, use the ./build.sh firmware command to repack.
  4. Compile media separately:

    ./build.sh clean media
    ./build.sh media
    • Files are stored in the directory: output/out/media_out. After compilation, use the ./build.sh firmware command to repack.
  5. Compile reference applications separately:

    ./build.sh clean app
    ./build.sh app
    • Note 1: app depends on media.
    • Note 2: After compilation, use the ./build.sh firmware command to repack.
  6. Firmware packaging:

    ./build.sh firmware

2. Docker Environment

2.1 Introduction to Docker

Docker is a lightweight containerization platform used for packaging, distributing, and running applications and their dependencies. It utilizes container technology to encapsulate applications and their entire runtime environment in a portable container. This enables applications to run consistently in any Docker-supported environment, improving efficiency in development, deployment, and scalability. Docker defines applications and environments using images, allowing containers to run seamlessly on different operating systems and cloud platforms.

2.2 Docker Concepts

Container: Docker uses containers to encapsulate applications and all their dependencies, including code, runtime, system tools, and libraries. Containers provide a lightweight, consistent, and portable way for applications to run in different environments.

Image: An image is the foundation of a container, containing all the information needed to run the container, such as the file system, libraries, configuration, etc. Images can be shared, stored in repositories, and transferred over the network.

Repository: A repository is a place for storing and organizing Docker images. Public repositories like Docker Hub provide many common images, and users can also create private repositories

2.3 Docker Download

  1. Download and install the Docker container:

    sudo apt install docker.io -y

2.4 Add User to Docker Group

On Ubuntu systems, running Docker commands with sudo is necessary because the Docker daemon runs with root user privileges by default. Docker performs some operations that require privileged access, such as accessing system resources, managing containers, building images, and mounting file systems, to ensure security and system stability. If you wish to run Docker commands without sudo every time, you can add the current user to the docker group.

  1. Run the following command to add the current user to the docker group:

    sudo usermod -aG docker $USER
  2. Log out and log back in, or run the following commands to apply the changes:

    sudo service docker restart
    newgrp docker
  3. Ensure that the user "luckfox" has been successfully added to the docker group. You can use the following command to check:

    id luckfox

2.5 Common Docker Commands

Here are some Docker commands. For a complete list and help information, run docker --help.

  1. Image-related commands:

    docker pull luckfoxtech/luckfox_pico:1.0      # Download an image from Docker Hub.
    docker images # List all local images.
    docker rmi luckfoxtech/luckfox_pico:1.0 # Delete one or more local images.
    docker search [image] # Search for an image on Docker Hub.
  2. 容器相关命令:

    docker ps                                     # List currently running containers.
    docker ps -a # List all containers, including stopped ones.

    luckfox@luckfox:~$ docker ps -a
    CONTAINER ID IMAGE COMMAND CREATED STATUS
    1758ef6954f6 luckfoxtech/luckfox_pico:1.0 "/bin/bash" 2 weeks ago Exited (137) 39 minutes ago
  3. 容器操作:

    docker start 1758                            # Start a stopped container.
    docker stop 1758 # Stop a running container.
    docker restart 1758 # Restart a container.
    docker exec -it 1758 ls # Execute a command in a running container.
    docker exec -it 1758 bash # Enter a running container.
    exit # Exit
    docker rm 1758 # Remove one or more containers.
  4. Run a container:

    sudo docker run -it --name luckfox --privileged -v /home/ubuntu/luckfox-pico:/home luckfoxtech/luckfox_pico:1.0 /bin/bash
    • -it runs an interactive container.
    • --name specifies a name for the container, making it easier to identify and manage.
    • -v option mounts a directory or file from the host to the container's internal directory. In the example, the /home/ubuntu/luckfox-pico directory is mounted to the /home directory inside the container.
  5. System information:

    docker logs 1758                             # View the logs of a container.
    docker inspect 1758 # View detailed information about a container.
    docker top 1758 # View the processes running in a container.
    • Note: Usually, you only need to provide the first few characters of the container ID, as Docker container IDs are unique. The first few characters are usually enough to uniquely identify a container. Replace the container ID with your actual container ID when using the commands.

2.6 Compile SDK

  1. Get the pre-configured official Docker image.

    sudo docker pull luckfoxtech/luckfox_pico:1.0
  2. Get the latest SDK using the following command.

    git clone https://github.com/LuckfoxTECH/luckfox-pico.git
    cd luckfox-pico
  3. Start an interactive container, named "luckfox," and map the SDK directory on the local host to the /home directory inside the container. Run Bash shell.

    # First time running the docker environment
    sudo docker run -it --name luckfox --privileged -v /home/ubuntu/luckfox-pico:/home luckfoxtech/luckfox_pico:1.0 /bin/bash

    # Second time running the docker environment
    sudo docker start -ai luckfox

    # Exit
    exit
  4. Install cross-compilation toolchain.

    cd tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/
    source env_install_toolchain.sh
  1. Navigate to the /home directory and clean the compilation.

    root@b165d8d4c29b:# cd /home
    root@b165d8d4c29b:/home# ./build.sh clean
  2. Choose a branch to compile, such as LuckFox Pico, LuckFox Pico Mini A, LuckFox Pico Mini B, LuckFox Pico Plus, or LuckFox Pico Pro/Max.

    root@22259b5440c0:/home# ./build.sh lunch
    You're building on Linux
    Lunch menu...pick the Luckfox Pico hardware version:
    选择 Luckfox Pico 硬件版本:
    [0] RV1103_Luckfox_Pico
    [1] RV1103_Luckfox_Pico_Mini_A
    [2] RV1103_Luckfox_Pico_Mini_B
    [3] RV1103_Luckfox_Pico_Plus
    [4] RV1106_Luckfox_Pico_Pro_Max
    [5] RV1106_Luckfox_Pico_Ultra
    [6] RV1106_Luckfox_Pico_Ultra_W
    [7] custom
    Which would you like? [0~7][default:0]: 3
    Lunch menu...pick the boot medium:
    选择启动媒介:
    [0] SD_CARD
    [1] SPI_NAND
    Which would you like? [0~1][default:0]: 1
    Lunch menu...pick the system version:
    选择系统版本:
    [0] Buildroot(Support Rockchip official features)
    Which would you like? [0~1][default:0]: 0
    [build.sh:info] Lunching for Default BoardConfig_IPC/BoardConfig-SPI_NAND-Buildroot-RV1103_Luckfox_Pico_Plus-IPC.mk boards...
    [build.sh:info] Running build_select_board succeeded.
  3. Compile all images.

    root@b165d8d4c29b:/home# ./build.sh  
    ....
    Make firmware OK!
    ------ OK ------
    ********rkImageMaker ver 2.2********
    Generating new image, please wait...
    Writing head info...
    Writing boot file...
    Writing firmware...
    Generating MD5 data...
    MD5 data generated successfully!
    New image generated successfully!
    [mk-update_pack.sh:info] Making -RK1106 update.img OK.
    [build.sh:info] Running build_updateimg succeeded.
    [build.sh:info] Running build_firmware succeeded.
    [build.sh:info] Running build_all succeeded.
    save to /home/luckfox/Luckfox-Pico/luckfox-pico/IMAGE/SPI_NAND_RV1103G-LUCKFOX-PICO-PLUS.DTS_20230816.1811_RELEASE_TEST
    [build.sh:info] Running build_save succeeded.
    [build.sh:info] Running build_allsave succeeded.
  4. After successful compilation, the firmware is stored in the SDK directory/output/image directory.

  5. Clean files for easy recompilation. Some configuration changes may require executing this command before recompiling.

    ./build.sh clean             

3. File Sharing

File transfer between the virtual machine and a Windows computer can be achieved using the Samba service for file sharing. In the Windows Network Neighborhood, accessing the virtual machine's file system becomes convenient.

3.1 Ubuntu Environment Configuration

  1. Download and install Samba.

    sudo apt-get update
    sudo apt-get install samba -y
  2. Configure 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
    • Replace "luckfox" with the actual hostname.
  3. Set up the shared account password.

    sudo smbpasswd -a luckfox
  4. Find 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

  1. In the Windows address bar, enter the IP address (replace with the actual IP address).

  2. Enter the virtual machine account password (default is luckfox).

  3. Successfully log in to the virtual machine or host.

4. Modifying Device Tree

Users of the Luckfox Pico and Luckfox Mini series development boards, if they have upgraded the hardware themselves to support Ethernet functionality, they also need to manually configure the device tree to enable wired networking for normal usage.

  1. Navigate to the /luckfox/luckfox-pico/sysdrv/source/kernel/arch/arm/boot/dts directory to modify the device tree file.

    $ ls | grep luckfox*
    rv1103g-luckfox-pico.dts
    rv1103g-luckfox-pico-mini-a.dts
    rv1103g-luckfox-pico-mini-b.dts
    rv1103g-luckfox-pico-plus.dts
    rv1103-luckfox-pico-ipc.dtsi
    rv1106g-luckfox-pico-pro-max.dts
    rv1106g-luckfox-pico-ultra.dts
    rv1106g-luckfox-pico-ultra-w.dts
    rv1106-luckfox-pico-pro-max-ipc.dtsi
    rv1106-luckfox-pico-ultra-ipc.dtsi
  2. Open the rv1103g-luckfox-pico.dts device tree file and change "disable" under gmac to "okay", then save and exit.

  3. Recompile the firmware after making these changes.

    ./build.sh clean  
    ./build.sh

5. Load ko Driver Module on Linux

5.1 ko File Format Overview

In the Linux operating system, the .ko file is the extension used for kernel module files. Kernel modules are pieces of code that can be dynamically loaded and unloaded at runtime to extend the functionality of the Linux kernel without needing to recompile the entire kernel. Each .ko file contains the module's code and metadata, allowing users to add or remove specific features such as drivers or filesystem support without rebooting the system.

5.2 Advantages of ko Files

  1. Dynamic Loading and Unloading: Kernel modules can be loaded into and unloaded from the kernel at runtime without requiring a system reboot. This enables system administrators and developers to add, test, or fix functionalities without disrupting system operation.
  2. Resource Efficiency: Kernel modules allow less frequently used features to be loaded as needed, reducing the size of the system kernel and memory footprint. This improves overall resource utilization.
  3. Customizability: Kernel modules enable users to add or remove specific features as required, facilitating customized system configurations. This is especially useful for embedded systems, specific hardware support, and specialized use cases.
  4. Reduced Compilation Time: Recompiling the entire kernel can be time-consuming, whereas using kernel modules avoids this issue. Only the necessary modules need to be compiled and loaded, saving time and resources.
  5. Rapid Debugging and Development: Kernel modules can be loaded and unloaded without system restarts, making debugging and development of drivers and other kernel code more efficient.
  6. Ease of Maintenance: The modularity of kernel modules allows them to be maintained and upgraded independently of the entire kernel. This helps reduce the complexity of system maintenance.
  7. Increased Compatibility: Kernel modules can be designed to support multiple kernel versions as needed, enhancing software compatibility and flexibility.

5.3 Application Example

Download the project file Poke me to download, the whole project has only two files, one helloworld.c, one with To control the compiled Makefile.

  1. Copy the project files to a Ubuntu host or virtual machine that has the Luckfox Pico SDK already installed and successfully compiled.

  2. Open and modify the Makefile to direct the make command to the specified kernel source code directory, which is the Luckfox Pico SDK's kernel path. (The provided virtual machine image directory is /home/luckfox/Luckfox-Pico/luckfox-pico/sysdrv/source/kernel.)

    obj-m += helloworld.o
    KDIR:=/home/luckfox/Luckfox-Pico/luckfox-pico/sysdrv/source/kernel
    PWD?=$(shell pwd)
    all:
    make -C $(KDIR) M=$(PWD) modules
    echo $(PWD)
    clean:
    rm -f *.ko *.o *.mod *.mod.o *.mod.c *.symvers *.order
  3. Code 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 Loading Function: When a kernel module is loaded using insmod or modprobe commands, the module's loading function is automatically executed by the kernel to perform relevant initialization tasks. In the Linux kernel, module loading functions are generally marked with __init and specified in the form of module_init(function_name). It returns an integer value, where 0 indicates successful initialization, and negative values indicate errors.
    • Module Unloading Function: When a module is unloaded using the rmmod command, the module's unloading function is automatically executed by the kernel to perform functions opposite to those of the loading function. Module unloading functions are typically marked with __exit, and they are executed when the module is being unloaded. They do not return any value and are specified in the form of module_exit(function_name).
    • Module License Declaration: This describes the licensing permissions for the kernel module. Not declaring a license will result in a kernel tainted warning upon loading the module. Acceptable licenses for Linux kernel modules include "GPL", "GPL v2", "GPL and additional rights", "Dual BSD/GPL", "Dual MPL/GPL", and "Proprietary" (the use of non-GPL licenses like "Proprietary" is a topic of debate in academia and law). In most cases, kernel modules should follow GPL-compatible licenses. The most common license declaration is MODULE_LICENSE("GPL v2").
    • Module Author and Information Declarations: MODULE_AUTHOR, MODULE_DESCRIPTION, MODULE_VERSION, MODULE_DEVICE_TABLE, and MODULE_ALIAS are used to declare the module's author, description, version, device table, and aliases.
  4. Inside the project directory, execute the following command (replace CROSS_COMPILE with the actual SDK path):

    export ARCH=arm

    export CROSS_COMPILE=/home/luckfox/Luckfox-Pico/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-

    make
    • The effect is as follows:
  1. Upload the helloworld.ko file to the development board using methods like TFTP or ADB:

    tftp 192.168.10.127 -g -r helloworld.ko
  2. Execute the above command for validation.

    # insmod helloworld.ko
    [ 200.330884] helloworld!
    # rmmod helloworld.ko
    [ 218.624421] helloworld bye
  3. Finally, use “dmesg” to view the logs.

    # dmesg | grep hello
    [ 200.330884] helloworld!
    [ 218.624421] helloworld bye

6. Kernel Configuration

menuconfig is a configuration tool for the Linux kernel that provides a terminal-based graphical interface for intuitively modifying configuration files while automatically handling configuration item dependencies. Other similar configuration interfaces include nconfig and xconfig. Below are the basic functions and operations of menuconfig.

6.1 Configuration Interface

Execute the following command to open the configuration interface:

cd <SDK directory>/sysdrv/source/kernel
cp ./arch/arm/configs/luckfox_rv1106_linux_defconfig .config
make ARCH=arm menuconfig

6.2 Basic Operations

The configuration interface displayed after executing the command is as follows:

From the top of the interface, you can see the basic operations and explanations of menuconfig.

Key operations:

  • PgUpPgDn: Browse and select kernel features
  • : Select operations such as Select, Exit, etc.
  • Enter: Enter submenu
  • Y: Select this feature
  • N: Exclude this feature
  • M: Select as a module
  • Esc: Double-click Esc to return to the previous menu
  • ?: View help information for this feature
  • /: Search

Legend:

  • [*]: Selected item
  • [ ]: Unselected item
  • <M>: Selected item (as a module)
  • < >: Unselected item (as a module)

The middle area is where you select various features. You can navigate using the up and down arrow keys, and you can also directly press the first letter of the colored text at the beginning of a line to jump to that line, such as the letter "K" in "Kernel Features." Pressing the "K" key will directly jump to the "Kernel Features" line.

The bottom area contains some commonly used operation options, providing important interactive functions for users. Their functions 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.

6.3 Function Overview

The middle part 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 a submenu, and press Esc to return to the previous menu.

Through this interface, users can flexibly configure the kernel based on system requirements, select required features and drivers, and build a customized kernel suitable for specific hardware and purposes. The following are the main items in the Linux kernel configuration interface:

  • General setup: Basic runtime configuration.
  • Kernel Features: Configuration of core features such as modularity, block device support, etc.
  • CPU Power Management: Configuration of CPU power management options.
  • Enable loadable module support: Whether to support kernel modules.
  • IO Schedulers: Configuration of disk I/O schedulers.
  • Networking support: Configuration of network support, including protocols, devices, etc.
  • Device Drivers: Configuration of various device drivers, such as input devices, USB devices, etc.
  • File systems: Configuration of file system support, selecting supported file system types.
  • Security options: Configuration of kernel security-related options.
  • Cryptographic API: Configuration of cryptographic API support.

6.4 Modifying Configuration

Here, we use enabling DHT11 as an example. Press / key, enter "dht11," and press Enter to search.

After the search, there is only one result. Press 1 to jump to it.

After jumping to the DHT11 configuration item, press Y to enable it and complete the configuration.

6.5 Saving Configuration

After completing the configuration in menuconfig, you can save your configuration using the following steps:

  1. Navigate to the < Save > option at the bottom using the left and right arrow keys.
  2. Press Enter to switch to the save interface.
  3. Enter the save file name; it will default to saving to the .config file.

In addition to this method, you can also exit by continuously pressing the Esc key. Upon exit, the system will ask whether to save the configuration file. If you want to save the current configuration, choose "Yes," which will update the .config file. Choosing "No" will not save your configuration changes. If you want to continue modifying the configuration without exiting, you can press the Esc key twice to return to the menuconfig interface and continue making modifications.

Execute the command after exiting the configuration interface:

make ARCH=arm savedefconfig
cp defconfig ./arch/arm/configs/luckfox_rv1106_linux_defconfig

6.6 Reburn Firmware

  1. Compile by selecting the branch and specifying the development board model:

    luckfox@luckfox:~/luckfox-pico$ ./build.sh lunch
  2. Compile:

    luckfox@luckfox:~/Luckfox-Pico/luckfox-pico$ ./build.sh
  3. Reflash the firmware:

    After compiling, reflash the firmware.

7. Buildroot Configuration

Buildroot is a tool designed specifically for embedded systems with the goal of simplifying the construction process of embedded Linux systems. By configuring Buildroot, you can customize the software packages and libraries included in the embedded system to meet specific requirements. This article will demonstrate how to add the packages for iftop and minicom, as well as the python-arrow library, through Buildroot configuration.

7.1 Add Packages

7.1.1 Open Configuration Interface

cd <SDK directory>/sysdrv/source/buildroot/buildroot-2023.02.6/
make luckfox_pico_defconfig
make menuconfig

Please note that the "buildroot-2023.02.6" directory is not present immediately after downloading the SDK. It is necessary to compile the SDK once before this directory becomes available.

luckfox@luckfox:~/luckfox-pico$ ./build.sh lunch
luckfox@luckfox:~/luckfox-pico$ ./build.sh

7.1.2 iftop

  1. Introduction

    iftop is a real-time network traffic monitoring tool that displays the real-time traffic situation of various network connections on the system through a graphical interface. It can sort by traffic size and display detailed information for each connection, helping users quickly identify network bottlenecks or abnormal traffic.

  2. Modify Configuration

    Press /, enter "iftop", and press Enter to search. With only one search result, press 1 to navigate to it.

    Press Y to enable the iftop package

7.1.3 minicom

  1. Introduction

    Minicom is a serial communication tool, similar to the HyperTerminal in Windows. It is mainly used for communication with serial devices, such as debugging switches and modems. It provides a simple yet effective command-line interface, supporting the configuration of serial parameters and file transfer protocols (such as XMODEM, YMODEM). Minicom is a lightweight tool suitable for embedded system development and debugging scenarios involving serial communication.

  2. Modify Configuration

    Press /, enter "minicom", and press Enter to search. With only one search result, press 1 to navigate to it.

    Press Y to enable the minicom package

7.1.4 Save Configuration

After configuration, press Esc continuously. When prompted to save, choose "Yes," save, and then proceed to recompile.

make savedefconfig 
make

7.2 Add Python Libraries

Not only can we add packages by configuring Buildroot, but we can also add the required Python libraries to the system. Below is an example of adding the python-arrow library.

7.2.1 Open Configuration Interface

cd <SDK directory>/sysdrv/source/buildroot/buildroot-2023.02.6/
make luckfox_pico_defconfig
make menuconfig

7.2.2 Modify configuration

In the configuration menu, find and select Target packages, then select Interpreter languages and scripting, and finally select External python modules

Find the required library and press Y to enable

2.3 Save configuration

After configuration, press Esc continuously. When prompted to save, choose "Yes," save, and then proceed to recompile.

make savedefconfig 
make

7.3 Reburn Firmware

  1. Compile by selecting the branch and specifying the development board model:

    luckfox@luckfox:~/luckfox-pico$ ./build.sh lunch
  2. Compile:

    luckfox@luckfox:~/Luckfox-Pico/luckfox-pico$ ./build.sh
  3. Reflash the firmware:

    After compiling, reflash the firmware.

7.4 Running Results

7.4.1 iftop

  1. Execute the command

    iftop -i eth0 -P -nNB -m 15M
  2. Parameter breakdown

    • -i eth0: Specifies the network interface to monitor, here it is eth0. You can change it to the name of other network interfaces as needed.
    • -P: Display port numbers.
    • -n: Display host addresses in numeric form instead of domain names.
    • -N: Display port numbers in the host and service columns, without showing the corresponding service names.
    • -B: Display traffic in bytes.
    • -m 15M: Limit the maximum bandwidth displayed to 15 megabits per second (Mbps).
  3. Running results, press "L" to display the progress bar

7.4.2 minicom

  1. Execute the command

    minicom -s
  2. After executing the command, the minicom configuration interface is displayed. Select "Serial port setup"

  3. After selecting "Serial port setup," press Enter to enter the setup menu

  4. There are 14 items in the menu, corresponding to A, B...N, the first one is to choose the serial port device. Here, we take UART3 as an example. The device file for UART3 is /dev/ttyS3, so set the serial device to /dev/ttyS3. The method is to first press the "A" key, then enter /dev/ttyS3, and press Enter to confirm. At the same time, you can also set other configuration items, such as E to set the baud rate, data bits, and stop bits, F to set hardware flow control. Here, we press "F" to turn off hardware flow control.

  5. After setting, press Enter to confirm and return to the configuration interface

  6. Press "Esc" to exit the configuration interface and enter the serial debugging interface. You can see that the current serial file is /dev/ttyS3

  7. Open sscom on the computer, set the baud rate to 115200, and connect to UART3 of Luckfox Pico to send data

  8. Luckfox Pico successfully receives data

  9. Press "CTRL+A" and then press "Z" to open the minicom help information interface. From the figure below, we can see that minicom has many functions. The echo function of minicom is turned off by default, and the corresponding configuration item is "local Echo on/off...E". We can press the "E" key to turn on/off the echo function.

  10. In the minicom communication interface, press "CTRL+A" and then press "X" to close minicom

7.4.3 python-arrow

  1. Execute the command

    python3
    import arrow
  2. Successfully import the arrow library