樹莓派3b 移植RT-Thread 64位操作系統
一、資源准備
1、系統要求
本方法使用的是Linux (Ubuntu16.04) 系統。
2、硬件資源
- 樹莓派3b
- sd卡
- ttl轉usb模塊
3、軟件資源
-
樹莓派原生系統鏡像
[[Raspberry Pi Imager for Windows]:https://downloads.raspberrypi.org/raspios_armhf_latest
-
RT-Thread源碼
-
gcc-arm-8.3-2019.03-x86_64-aarch64-elf 交叉編譯工具
二、燒錄樹莓派原生系統
1、格式化SD卡
有時使用windows進行格式化可能會導致后續的燒錄操作失敗,推薦使用SD Card Formatter進行格式化。
2、燒錄系統鏡像
將下載的系統鏡像壓縮包進行解壓得到img文件,使用balenaEtcher將鏡像燒錄到sd卡中,顯示如下畫面即為燒錄成功。
三、移植RT-Thread
1、工具鏈及源代碼准備
將下載下來的 gcc-arm-8.3-2019.03-x86_64-aarch64-elf.tar.xz 文件放在系統opt/
目錄下進行解壓
若官網下載速度過慢可通過下方鏈接進行下載
鏈接:https://pan.baidu.com/s/1rroD0IqHPnBOXcE_NeVQ6g
提取碼:hv3i
使用如下指令下載RTT源碼:
git clone git@github.com:RT-Thread/rt-thread.git
注:使用git指令進行下載需要先在系統中使用sudo apt-get install git
指令來安裝git,並對github進行配置,配置過程可參考下方鏈接博文。
[[Ubuntu Github基本使用方法]: https://blog.csdn.net/weixin_43793181/article/details/103111290
或可直接從github下載源碼並解壓到系統某處。
2、下載scons
scons為Python編寫的自動化構建工具,我們使用此工具編譯RTT源代碼並生成系統鏡像。使用如下指令安裝scons:
sudo apt-get install scons
3、編譯源碼
打開Terminal進入RTT源碼rt-thread-master\bsp\raspberry-pi\raspi3-64
目錄下,輸入指令scons
進行編譯,並得到系統鏡像文件 kernal8.img,將此文件拷入sd卡,完成移植。
【注1】:若在輸入scons
指令后出現 scons sh: 1: aarch64-elf-gcc: not found
報錯,請檢查 gcc-arm-8.3-2019.03-x86_64-aarch64-elf 是否在opt/
目錄下,或將rt-thread-master\bsp\raspberry-pi\raspi3-64
下的rtconfig.py
文件中
EXEC_PATH = r'/opt/gcc-arm-8.3-2019.03-x86_64-aarch64-elf/bin/'
/bin/
之前的部分改為編譯工具的實際路徑。
【注2】:若在輸入scons
指令后出現形如以下的錯誤
In file included from /home/matassos/Desktop/rt-thread-master/include/libc/libc_signal.h:71,
from /home/matassos/Desktop/rt-thread-master/include/rtlibc.h:21,
from /home/matassos/Desktop/rt-thread-master/include/rtdef.h:1024,
from /home/matassos/Desktop/rt-thread-master/include/rtthread.h:23,
from applications/main.c:27:
/opt/riscv/riscv64-unknown-elf/include/sys/signal.h:42:7: error: redefinition of 'union sigval'
union sigval {
^~~~~~
In file included from /home/matassos/Desktop/rt-thread-master/include/rtlibc.h:21,
from /home/matassos/Desktop/rt-thread-master/include/rtdef.h:1024,
from /home/matassos/Desktop/rt-thread-master/include/rtthread.h:23,
from applications/main.c:27:
/home/matassos/Desktop/rt-thread-master/include/libc/libc_signal.h:31:7: note: originally defined here
union sigval
^~~~~~
In file included from /home/matassos/Desktop/rt-thread-master/include/rtlibc.h:21,
from /home/matassos/Desktop/rt-thread-master/include/rtdef.h:1024,
from /home/matassos/Desktop/rt-thread-master/include/rtthread.h:23,
from applications/main.c:27:
/home/matassos/Desktop/rt-thread-master/include/libc/libc_signal.h:39:8: note: originally defined here
struct sigevent
^~~~~~~~
In file included from /home/matassos/Desktop/rt-thread-master/include/libc/libc_signal.h:71,
from /home/matassos/Desktop/rt-thread-master/include/rtlibc.h:21,
from /home/matassos/Desktop/rt-thread-master/include/rtdef.h:1024,
from /home/matassos/Desktop/rt-thread-master/include/rtthread.h:23,
from applications/main.c:27:
/opt/riscv/riscv64-unknown-elf/include/sys/signal.h:72:3: error: conflicting types for 'siginfo_t'
} siginfo_t;
^~~~~~~~~
請使用指令scons -c
之后再次進行嘗試。
四、驗證
使用杜邦線將ttl轉usb模塊連接樹莓派,接線方式如圖所示。
連接電腦后,打開串口工具連接串口,波特率115200,停止位1,數據位8,樹莓派上電后串口打印如下信息即為移植成功。