嵌入式Linux(一):东山派壹号 ubuntu开发环境配置
前言
最近要學嵌入式Linux,網上查了下,被價格嚇死了,基本上都是四五百或以上。終于找到了東山派壹號這塊板子。主板和底板加起來兩百多。本文,主要介紹這塊板子 嵌入式linux開發環境的搭建,包括相關資料鏈接,交叉編譯環境,tftp上傳程序到板子。買板子的時候,建議主板底板都買,因為在上傳程序時,需要底板的網路接口。
嵌入式Linux(一):東山派壹號 ubuntu開發環境配置
- 前言
- (一)相關資料鏈接
- (二)上電連接
- 1. 安裝 MobaXterm
- 2. 使用Type-C線連接板子一電腦
- 3.使用Mobaxterm登錄串口
- 4.成功界面
- 5.ubuntu minicom 連接開發板
- (三)ubuntu 交叉環境配置
- 1.安裝編譯需要的lib & tool
- 2.獲取源碼
- 3.添加環境變量
- 4.測試編譯環境
- (四)通過網線連接板子和電腦
- 1.接線
- 2.設置windows 路由 IP
- 3.設置板子路由 IP
- 4.測試網絡連通狀態
- (五)安裝TFTP
- 1.ubuntu 端
- 2.板子端 文件上傳下載
- (六)helloworld
- 1.編譯hello.c
- 2.ubuntu 測試編譯
- 3.交叉編譯
- 4.板子通過tftp獲取編譯后的程序
- 結語
(一)相關資料鏈接
(二)上電連接
1. 安裝 MobaXterm
在連接電腦前,需要安裝MobaXterm串口訪問軟件,可以到https://mobaxterm.mobatek.net/ 下載安裝。
2. 使用Type-C線連接板子一電腦
參考
3.使用Mobaxterm登錄串口
打開MobaXterm,點擊左上角的“Session”,在彈出的界面選中“Serial”,如下圖所示選擇端口號(前面設備管理器顯示的端口號COM21)、波特率(Speed 115200)、流控(Flow Control: none),最后點擊“OK”即可。步驟如下圖所示。 注意:流控(Flow Control)一定要選擇none,否則你將無法在MobaXterm中向串口輸入數據 連接
4.成功界面
5.ubuntu minicom 連接開發板
直接參考:ubuntu minicom使用USB串口連接shell(ubuntu下的xshell)
//安裝 sudo apt-get install minicom //修改serial串口 sudo minicom -s //我的電腦ubuntu18.04,串口號是 /dev/ttyACM0(三)ubuntu 交叉環境配置
在進行環境配置之前,需要有一個ubuntu18.04的系統環境,可以用VMWARE來跑雙系統,也可以安裝win10下的ubuntu18.04子系統,我這里使用的是win10的ubuntu子系統。
配置win10 ubuntu子系統 可以參考 https://blog.csdn.net/liangzc1124/article/details/108952232
參考
1.安裝編譯需要的lib & tool
book@100ask:~$ sudo apt-get install libc6-dev-i386 book@100ask:~$ sudo apt-get install lib32z1 lib32ncurses5 book@100ask:~$ sudo apt-get install libuuid1:i386 book@100ask:~$ sudo apt-get install cmake book@100ask:~$ sudo apt-get install libncurses5-dev libncursesw5-dev book@100ask:~$ sudo apt install bc book@100ask:~$ sudo apt-get install xz-utils book@100ask:~$ sudo apt-get install automake book@100ask:~$ sudo apt-get install libtool book@100ask:~$ sudo apt-get install libevdev-dev book@100ask:~$ sudo apt-get install pkg-config book@100ask:~$ sudo apt-get install openssh-server book@100ask:~$ sudo apt-get install repo //改sh為bash book@100ask:~$ sudo rm /bin/sh book@100ask:~$ sudo ln -s /bin/bash /bin/sh2.獲取源碼
book@100ask:~$ git clone https://e.coding.net/codebug8/repo.git book@100ask:~$ mkdir DongshanPiOne-TAKOYAKI && cd DongshanPiOne-TAKOYAKI book@100ask:~/DongshanPiOne-TAKOYAKI$ ../repo/repo init -u https://gitee.com/weidongshan/manifests.git -b linux-sdk -m SSD202D/dongshanpi-one_takoyaki_dlc00v030.xml --no-repo-verify book@100ask:~/DongshanPiOne-TAKOYAKI$ ../repo/repo sync -j43.添加環境變量
//打開環境變量文件 book@100ask:~$ vim ~/.bashrc //在行尾添加或修改,加上下面幾行: export ARCH=arm export CROSS_COMPILE=arm-linux-gnueabihf- export PATH=$PATH:/home/book/DongshanPiOne-TAKOYAKI/gcc-arm-8.2-2018.08-x86_64-arm-linux-gnueabihf/bin //執行 source ~/.bashrc 命令使其生效 source ~/.bashrc4.測試編譯環境
book@100ask:~$ arm-linux-gnueabihf-gcc -v Using built-in specs. COLLECT_GCC=arm-linux-gnueabihf-gcc COLLECT_LTO_WRAPPER=/home/book/DongshanPiOne-TAKOYAKI/gcc-arm-8.2-2018.08-x86_64-arm-linux-gnueabihf/bin/../libexec/gcc/arm-linux-gnueabihf/8.2.1/lto-wrapper Target: arm-linux-gnueabihf Configured with: /tmp/dgboter/bbs/bc-b1-2-11--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/src/gcc/configure --target=arm-linux-gnueabihf --prefix= --with-sysroot=/arm-linux-gnueabihf/libc --with-build-sysroot=/tmp/dgboter/bbs/bc-b1-2-11--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/build-arm-linux-gnueabihf/install//arm-linux-gnueabihf/libc --enable-gnu-indirect-function --enable-shared --disable-libssp --disable-libmudflap --disable-libsanitizer --enable-checking=release --enable-languages=c,c++,fortran --with-gmp=/tmp/dgboter/bbs/bc-b1-2-11--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/build-arm-linux-gnueabihf/host-tools --with-mpfr=/tmp/dgboter/bbs/bc-b1-2-11--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/build-arm-linux-gnueabihf/host-tools --with-mpc=/tmp/dgboter/bbs/bc-b1-2-11--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/build-arm-linux-gnueabihf/host-tools --with-isl=/tmp/dgboter/bbs/bc-b1-2-11--rhe6x86_64/buildbot/rhe6x86_64--arm-linux-gnueabihf/build/build-arm-linux-gnueabihf/host-tools --with-arch=armv7-a --with-fpu=neon --with-float=hard --with-arch=armv7-a --with-pkgversion='GNU Toolchain for the A-profile Architecture 8.2-2018-08 (arm-rel-8.23)' Thread model: posix gcc version 8.2.1 20180802 (GNU Toolchain for the A-profile Architecture 8.2-2018-08 (arm-rel-8.23)) book@100ask:~$(四)通過網線連接板子和電腦
1.接線
若你的電腦有RJ45接口,可以用兩頭RJ45接口的將板子連接電腦,若沒有,可以使用USB轉RJ45接口來連接電腦。
2.設置windows 路由 IP
ubuntu&windows:192.168.5.10
板子:192.168.5.10
物理連接到板子后,在windows上查看網絡連接,
右鍵,點擊狀態,然后按下圖順序,設置IP,mask
3.設置板子路由 IP
通過MobaXterm 連接板子,通過下面命令設置IP
//設置 ifconfig eth0 192.168.5.9 //測試 ifconfig4.測試網絡連通狀態
在測試之前需要保證,防火墻是關閉的
在板子上輸入命令:ping 192.168.5.10
在ubuntu上輸入命令:ping 192.168.5.9
(五)安裝TFTP
1.ubuntu 端
//安裝軟件 sudo apt-get install tftp-hpa tftpd-hpa //然后,創建 TFTP 服務器工作目錄,并打開 TFTP 服務配置文件,如下: mkdir -p /home/book/tftpboot sudo chmod 777 /home/book/tftpboot sudo vim /etc/default/tftpd-hpa //在配置文件/etc/default/tftpd-hpa 中,添加以下字段: TFTP_DIRECTORY="/home/book/tftpboot" TFTP_OPTIONS="-l -c -s" //最后,重啟 TFTP 服務: sudo service tftpd-hpa restart //查看 tftp 服務是否在運行,運行如下命令,即可查看是否在后臺運行。 ps -aux | grep "tftp"2.板子端 文件上傳下載
//嵌入式開發板下載 ubuntu端的 tftp -g -r hello 192.168.5.10//嵌入式開發板發送 tftp -p -l note.txt 192.168.5.10
(六)helloworld
1.編譯hello.c
/*hello.c*/ /* 執行命令: ./hello weidongshan* argc = 2* argv[0] = ./hello* argv[1] = weidongshan*/ #include <stdio.h> int main(int argc, char **argv) {if (argc >= 2)printf("Hello, %s!\n", argv[1]);elseprintf("Hello, world!\n");return 0; }2.ubuntu 測試編譯
gcc hello.c -o hello ./hello lingcb3.交叉編譯
//交叉編譯 arm-linux-gnueabihf-gcc hello.c -o hello //移動到ubuntu tftp服務器根目錄/home/book/tftpboot cp hello /home/book/tftpboot ls /home/book/tftpboot4.板子通過tftp獲取編譯后的程序
/home # tftp -g -r hello 192.168.5.10 hello 100% |*******************************| 12052 0:00:00 ETA /home # chmod 777 ./hello /home # ./hello Hello, world!結語
終于是完成了入門,這些資料主要是參考韋東山老師的視頻,文檔等資料的,有看不懂的,可以到B站搜索,韋東山linux嵌入式應用。下面是一些資料
【1】嵌入式Linux應用開發完全手冊_韋東山全系列視頻文檔全集V2.4 鏈接:https://pan.baidu.com/s/1qS0Mo5YVS43wYGZdWq1MmA?pwd=w23p 提取碼:w23p
【2】嵌入式Linux教程_韋東山手把手教你嵌入式Linux快速入門到精通https://www.bilibili.com/video/BV1w4411B7a4?spm_id_from=333.337.search-card.all.click
【3】東山Pi壹號-開發板官方文檔 https://dongshanpi.com/DongshanPi-One/01-BoardIntroduction/
總結
以上是生活随笔為你收集整理的嵌入式Linux(一):东山派壹号 ubuntu开发环境配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: BZOJ震波
- 下一篇: 劳易测测距传感器ODS9L2.8/LAK