当前位置:网站首页>【无标题】
【无标题】
2022-06-29 16:16:00 【weixin_45747542】
嵌入式linux及交叉编译练习
一、树莓派嵌入式linux环境配置
1.下载相关工具及系统镜像
前往树莓派官网下载适合当前系统的烧录器,根据提示安装好该烧录器,然后启动。选择所需操作系统,在弹出界面中选择的二项,根据需要选择所需系统。
2.格式化sd卡并将系统镜像烧录至该sd卡
- 将SD插入到读卡器中,接着将读卡器插到电脑上。
- 打开sd卡格式化工具
- 选择需要格式化的SD卡,将该sd卡格式化
- 在烧录器中选择sd卡,开始烧录
3.配置网络
本次使用手机热点,主要步骤如下
1.在电脑上,打开刚才烧录镜像的SD卡
2.在boot目录下,建立一个ssh的空文件
3.在boot目录下,建立文件,文件名命名为wpa_supplicant.conf
country=CN
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="无线网名称"
psk="无线网密码"
key_mgmt=WPA-PSK
priority=1
}
4.将SD卡插入树莓派中,同时打开手机热点和给树莓派接上电源
可以在手机上查看得到树莓派的ip地址
二、assert断言练习
1.编写代码
通过ssh登录Linux,通过nano编写代码如下
通过gcc -o hello hello.c编译该文件,然后执行该文件。
2.测试使用
当断言为假时,结果如下
当断言为假时,程序会直接报错退出,后续不会执行。如果断言为真,则后续代码会正常执行
assert断言只在软件的debug中生效,在其他版本中不会生效。合理使用assert可以使得代码更容易调试。
三.交叉编译
1.在github上下载相关工具,下载zip,将其传输至linux或树莓派上,通过unzip命令解压该压缩包。此时进入./tools-master/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin,该目录下有我们需要的交叉编译gcc文件。在通过nano ~/.bashrc,在其最后添加PATH=$PATH:~/tools-master/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin~处为文件该tools-master文件夹所在目录,然后使用source ~/.bashrc使更改生效。
2.通过ln -s a b创建软连接,a为原文件,b为目标文件,我们需要将树莓派中的wiringpi库在当前系统中的/usr/local/lib/中创建软连接供交叉编译工具使用。
3.通过交叉编译工具编译源文件,通过scp /path/to/source/file [email protected]:/path/to/destination/directory命令将该文件上传至树莓派上运行.
总结
本次主要练习了嵌入式linux的配置及linux相关命令的使用以及交叉编译和assert断言的基本知识。通过本次练习,提高了我对相关知识的熟练程度。
边栏推荐
- MySQL进阶——存储引擎
- Cv5200 ad hoc network remote WiFi module, UAV wireless image transmission application, HD low delay scheme
- 关于组织开展2022年南京市创新产品(第一批)申报工作的通知
- 图文带你彻底弄懂MySQL事务原子性之UndoLog
- Notice on organizing the declaration of Nanjing innovative products (the first batch) in 2022
- Cerebral cortex: predicting children's mathematical skills from task state and resting state brain function connections
- 迪赛智慧数——其他图表(基本旭日图):毕业演讲高频词
- 全面剖析Seata 分布式事务 AT 与XA
- Sophon CE社区版上线,免费Get轻量易用、高效智能的数据分析工具
- 数学知识复习:第一型曲线积分
猜你喜欢

Small programs have a "big" role in the industrial Internet

连续10年霸榜第一?程序员「最常用」的编程语言是它?

DAP large screen theme development description

Summary of common MySQL statements and commands

稳定币风险状况:USDT 和 USDC 安全吗?

数学知识复习:第一型曲线积分

To solve the stubborn problem of Lake + warehouse hybrid architecture, Star Ring Technology launched an independent controllable cloud native Lake warehouse integrated platform

STM32按键消抖——入门状态机思维

MySQL基础——多表查询

Cv5200 ad hoc network remote WiFi module, UAV wireless image transmission application, HD low delay scheme
随机推荐
leetcode:139. Word splitting [DFS + memory]
我,大厂测试员,降薪50%去国企,后悔了...
Notice on organizing the declaration of Nanjing innovative products (the first batch) in 2022
Tool chain empowers hundreds of companies, horizon opens the "Matthew effect" of mass production of intelligent driving
Key sprite fighting monsters - window binding skill
What are the financial products suitable for the poor in 2022?
Cerebral cortex: predicting children's mathematical skills from task state and resting state brain function connections
华夏基金:基金行业数字化转型实践成果分享
毕业生迷茫,中年人焦虑,职场路怎么越走越宽?
实战 | 神奇的 conic-gradient 圆锥渐变
Blue bridge cup several full array questions
如何配置 logback?30分钟让你彻底学会代码熬夜敲
MySQL基础——事务
Privacy computing helps secure data circulation and sharing
【Proteus仿真】数码管递加/递减带闪烁消隐显示
【Proteus仿真】数码管+4x4键盘矩阵按键简易计算器
The rooster Electronic Society graphical programming real questions and answers analysis of the scratch grade test level 1 June 2022
Key sprite fighting monsters - multi window and multi thread background skills
美国芯片再遭重击,Intel或将被台积电击败而沦落至全球第三
Which parameter is the partition information adjusted? The MySQL source stream API is used, not the table API