当前位置:网站首页>【无标题】
【无标题】
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基础——多表查询
- 天龙八部TLBB系列 - 网单用数据库修改为其他门派
- 基础 | 在物理引擎中画圆弧
- To solve the stubborn problem of Lake + warehouse hybrid architecture, Star Ring Technology launched an independent controllable cloud native Lake warehouse integrated platform
- The difference between Magento and WordPress
- Self taught programming can understand the code, but what if you can't write it yourself
- 连续10年霸榜第一?程序员「最常用」的编程语言是它?
- 事件相关电位ERP的皮层溯源分析
- Selenium 凭什么成为 Web 自动化测试的首选?(内附源码)
- 论文笔记:E(n) Equivariant Graph Neural Networks
猜你喜欢
Top the list for 10 consecutive years? What is the "most common" programming language for programmers?
京东方:随着下半年旺季到来、促销拉动、新产品发布等影响,需求有望出现好转
Sophon CE社区版上线,免费Get轻量易用、高效智能的数据分析工具
A tour of gRPC:02 - 从proto生成代码
Science: the interrelated causes and consequences of sleep in the brain
连续10年霸榜第一?程序员「最常用」的编程语言是它?
Sophon AutoCV:助力AI工业化生产,实现视觉智能感知
After studying this series of notes about software testing, it is a "bonus" to enter the factory
真正的测试 =“半个产品+半个开发”?
Small programs have a "big" role in the industrial Internet
随机推荐
进阶 | webgl性能优化初尝
UWB精准定位方案,厘米级高精度技术应用,智能配对感应技术
Time format GTM to Beijing time
What are the financial products suitable for the poor in 2022?
小程序在产业互联网有「大」作为
【Proteus仿真】数码管+4x4键盘矩阵按键简易计算器
Technology sharing | broadcast function design in integrated dispatching
暑期数据可视化分析展示效果
How to configure logback? 30 minutes for you to thoroughly learn the code to stay up late and knock
MATLAB输出格式控制 %d,%f,%c,%s的用法
MySQL foundation - transaction
How to distinguish between instructions and data in the "group counting" CPU
A tour of grpc:02 - generate code from proto
穩定幣風險狀况:USDT 和 USDC 安全嗎?
数学知识复习:第一型曲线积分
Flutter技术与实战(1)
DAP large screen theme development description
MySQL基础——多表查询
C语言——printf打印进制前缀
scratch报时的公鸡 电子学会图形化编程scratch等级考试一级真题和答案解析2022年6月