跳到主要内容

RT-Thread 开发

1. 准备工作

  1. 开发环境:
    • Ubuntu 22.04 虚拟机或主机
    • Luckfox_Lyra_SDK_250815.tar.gz
  2. 硬件准备:
    • Luckfox Lyra 系列主板
    • USB 转 TTL 串口模块 x2
    • USB Type-A to Type-C 数据线
    • 100M/1000M 以太网线
    • 路由器,用于开发板网络连接

2. Cortex-A7 RT-Thread 测试

本章节介绍如何编译并运行 Cortex-A7 RT-Thread。编译完成后,可将生成的固件烧录到开发板。

2.1 修改配置文件并编译

  1. 进入板级配置文件目录:

    cd {SDK}/device/rockchip/rk3506
  2. 修改 amp_linux_mcu.its 配置文件,指定需要编译的 CPU 类型,可以选择 AP 或 MCU:

    configurations {
    default = "conf";
    conf {
    description = "Rockchip AMP images";
    rollback-index = <0x0>;
    loadables = "amp2"; // 使用 amp2 运行 RT-Thread
    //loadables = "mcu"; // 使用 mcu 运行 Baremetal

    signature {
    algo = "sha256,rsa2048";
    padding = "pss";
    key-name-hint = "dev";
    sign-images = "loadables";
    };

    /* - run linux on cpu0
    * - it is brought up by amp(that run on U-Boot)
    * - it is boot entry depends on U-Boot
    */
    linux {
    description = "linux-os";
    arch = "arm";
    cpu = <0xf00>;
    thumb = <0>;
    hyp = <0>;
    load = <0x00900000>;
    udelay = <0>;
    };
    };
    };
  3. 返回 SDK 根目录,选择对应板级配置文件并执行编译。以下以 Luckfox Lyra Plus 为例:

    ./build.sh lunch

    ############### Rockchip Linux SDK ###############

    Manifest: luckfox_linux6.1_rk3506_release_v1.4_20250620.xml

    Log colors: message notice warning error fatal

    Log saved at /home/ubuntu/Luckfox/rk3506/250815/output/sessions/2026-05-19_20-11-23
    You're building on Linux
    Lunch menu...pick the Luckfox Lyra hardware version:
    选择 Luckfox Lyra 硬件版本:
    [0] RK3506G_Luckfox_Lyra
    [1] RK3506G_Luckfox_Lyra_Plus
    [2] RK3506B_Luckfox_Lyra_Ultra
    [3] RK3506B_Luckfox_Lyra_Ultra_W
    [4] RK3506B_Luckfox_Lyra_Zero_W
    [5] RK3506B_Luckfox_Lyra_Pi
    [6] RK3506B_Luckfox_Lyra_Pi_W
    [7] custom
    Which would you like? [0~7][default:0]: 7
    Pick a defconfig:

    1. luckfox_lyra_buildroot_sdmmc_defconfig
    2. luckfox_lyra_buildroot_spinand_defconfig
    3. luckfox_lyra_pi-w_buildroot_emmc_defconfig
    4. luckfox_lyra_pi-w_buildroot_sdmmc_defconfig
    5. luckfox_lyra_pi_buildroot_emmc_defconfig
    6. luckfox_lyra_pi_buildroot_sdmmc_defconfig
    7. luckfox_lyra_plus_buildroot_sdmmc_defconfig
    8. luckfox_lyra_plus_buildroot_spinand_defconfig
    9. luckfox_lyra_ultra-w_buildroot_emmc_defconfig
    10. luckfox_lyra_ultra_buildroot_emmc_defconfig
    11. luckfox_lyra_zero-w_buildroot_sdmmc_defconfig
    12. luckfox_lyra_zero-w_buildroot_spinand_defconfig
    13. rk3506b_buildroot_emmc_amp_defconfig
    14. rk3506b_buildroot_spinand_amp_defconfig
    15. rk3506g_buildroot_spinand_amp_defconfig
    Which would you like? [1]: 15
    Switching to defconfig: /home/ubuntu/Luckfox/rk3506/250815/device/rockchip/.chip/rk3506g_buildroot_spinand_amp_defconfig
    #
    # configuration written to /home/ubuntu/Luckfox/rk3506/250815/output/.config
    #
    Using last kernel version(6.1)
  4. 首次编译需要执行完整编译:

    ./build.sh
  5. 完整编译成功后,后续开发可只编译指定模块:

    ./build.sh amp
    ./build.sh firmware
  6. 编译完成后,将生成的镜像重新烧录到开发板。

2.2 RT-Thread 终端

  1. 连接子系统 UART。使用 RX: GPIO0_A3TX: GPIO0_A2,并将串口波特率设置为 1500000。子系统 UART 引脚位置如下:

  2. 开发板上电后,子系统 UART 会输出 msh 终端信息。

  3. msh 终端中执行 help 命令,可以查看所有可用命令。