Skip to content

Commit

Permalink
整理目录、更新
Browse files Browse the repository at this point in the history
  • Loading branch information
Staok committed Apr 9, 2022
1 parent 143a1f7 commit 8886c6d
Show file tree
Hide file tree
Showing 187 changed files with 2,541 additions and 743 deletions.
Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@

# 地基

**① Linux 开发 基本工具的使用**
## ① Linux 开发 基本工具的使用

代码编辑:Vim、gedit(ubuntu 下)。编译工具:gcc,make,cmake(生成 makefile),gdb。项目管理:git。文本编辑:Windows 端的如 source insight、Notepad、VsCode 等;Linux 端的如 gedit(Ubuntu 端)、VsCode 等。

[主线剧情02-ARM-Linux基础学习记录_Real-Staok的博客-CSDN博客](https://blog.csdn.net/Staokgo/article/details/123693110#t7) 里面的 `Linux 下的开发` 一节的内容。

**② 编译 / 交叉编译 工具的获取**
## ② 编译 / 交叉编译 工具的获取

[主线剧情02-ARM-Linux基础学习记录_Real-Staok的博客-CSDN博客](https://blog.csdn.net/Staokgo/article/details/123693110#t14) 里面的 `获取交叉编译工具链` 一节的内容。其中 举出三个方法:用开发板厂家提供的 SDK 里的工具链、ARM 官网下载 合适的工具链、使用 Linaro GCC 编译器。

另外,在构建 rootfs 时候使用 buildroot 或 yocto 时候可以构建 交叉编译器。

**③ Linux 系统调用(各层调用关系)**
## ③ Linux 系统调用(各层调用关系)

- [Linux系统相关的基础问题(空间、内存、库、链接、环境变量)_~青萍之末~的博客-CSDN博客](https://blog.csdn.net/daaikuaichuan/article/details/82729483)
- [Linux系统调用_~青萍之末~的博客-CSDN博客_linux系统调用](https://blog.csdn.net/daaikuaichuan/article/details/82902407)[【第4篇】嵌入式Linux应用开发基础知识_哔哩哔哩_bilibili](https://www.bilibili.com/video/BV1kk4y117Tu?p=13),其中 `4-2_ 文件IO _系统接口` 这一个节讲解 系统调用怎么进入内核。
- [Linux内核的五大模块_~青萍之末~的博客-CSDN博客_linux内核模块](https://blog.csdn.net/daaikuaichuan/article/details/82957655),进程调度,进程间通信模块(包括管道、命名管道、消息队列、信号量和共享内存等),内存管理模块,文件系统模块,网络接口模块。
- etc.

**④ Linux 一般开发流程**
## ④ Linux 一般开发流程

[主线剧情02-ARM-Linux基础学习记录_Real-Staok的博客-CSDN博客](https://blog.csdn.net/Staokgo/article/details/123693110#t2) 里面的 `Linux 一般开发步骤` 一节的内容:

Expand All @@ -47,15 +47,15 @@
>
> u-boot、Linux内核,在 Windows 和 Ubuntu 各存一份。根文件系统使用 buildroot (或 Busybox 或 Yocto)制作,它无需放在 Windows 上。
**⑤ 主机端 与 嵌入式 Linux 板端 相互传文件**
## ⑤ 主机端 与 嵌入式 Linux 板端 相互传文件

[主线剧情02-ARM-Linux基础学习记录_Real-Staok的博客-CSDN博客]([(40条消息) 主线剧情02-ARM-Linux基础学习记录_Real-Staok的博客-CSDN博客](https://blog.csdn.net/Staokgo/article/details/123693110)) 里面的 `PC 与 嵌入式板 传输文件的方式汇总` 一节的内容。这一块内容会只在 [Github](https://github.com/Staok/ARM-Linux-Study)/[Gitee](https://gitee.com/staok/ARM-Linux-Study) 仓库内更新:

- 网络传输:ETH / WiFi。通过 SSH、NFS、TFTP 等。
- USB 传输:~~U 盘拷贝~~,芯片官方 配套的 USB 传输 / 烧写 工具。
- 串口传输:rz / sz 命令。

**⑥ 期待美好发生**
## ⑥ 期待美好发生

这儿的能力是靠 多做项目、多积累经验,量变出质变。

Expand Down Expand Up @@ -96,32 +96,32 @@ help、man 和 info 命令。
- [【主线剧情 0.0】Linux 学习资源大综合 - 知乎 (zhihu.com)](https://zhuanlan.zhihu.com/p/486903467)[CSDN 链接](https://blog.csdn.net/Staokgo/article/details/123717871#t7)) 里面的 `书籍推荐` 一节。
- [【主线剧情 0.0】Linux 学习资源大综合 - 知乎 (zhihu.com)](https://zhuanlan.zhihu.com/p/486903467)[CSDN 链接](https://blog.csdn.net/Staokgo/article/details/123717871#t7)) 里面的 `Linux 应用编程内容补充` 一节。

## 系统调用 API

参考:

- [Linux 下系统调用的三种方法_海风林影的博客-CSDN博客](https://blog.csdn.net/hazir/article/details/11894427)
- [ linux系统调用(持续更新....)_tiramisu_L的博客-CSDN博客](https://blog.csdn.net/tiramisu_L/article/details/106393065)

通过 glibc 提供的库函数、使用 syscall 直接调用、通过 int 指令陷入;popen() 函数、fgets() 函数、system() 函数、strstr() 函数。

​ TODO,这里 有待补充 以上 API 完整。

## 标准 API 富集

这里就是日常用到的 API 的积累和整理,最详细、全面的 API 参考 见 上面 `通过手册的 API 详细描述参考` 一节。

日常用到的 标准 API 富集 单独放在了 `【Linux 应用开发】` 文件夹 里面,包括:

- 文件 IO、字符流收发 和 字符串处理相关的 API 收集积累。

- 一些 Shell 命令 API 收集积累。

- 输入设备框架,读取驱动程序按照 input event 框架上传的信息。

- 文件 IO 读写的基本四种机制(阻塞、非阻塞、poll/select 和 异步通知(通过信号机制))。
- Socket TCP/UDP编程。

- Socket TCP / UDP 编程。

- 进程 和 线程 的设计和编程。包括 进程和线程的分配策略、进程和线程的 API 用法 等:
- 进程 相关 API(fork()、)。
- 进程 相关 API(fork()、exec、wait() 等等)。
- 进程间通讯(管道、命名管道、信号、信号量、消息队列、共享内存、内存映射 和 套接字)。
- pthread 线程编程库 相关 POSIX API(pthread_create()、(后面省略 pthread_)exit / cancel 和 join / tryjoin_np、self()、attr_setxxx() / attr_getxxx()、)。
- pthread 线程编程库 相关 POSIX API(pthread_create()、(后面省略 pthread_)exit / cancel 和 join / tryjoin_np、self()、attr_setxxx() / attr_getxxx()、)。
- 线程间通讯、同步的机制(锁机制(互斥锁、读写锁 和 自旋锁)、信号量机制、条件变量机制 和 信号(与 IPC 的信号使用上有区别))。

- 串口收发编程、I2C编程。

实质上就是对各种设备驱动文件 进行 open/read/write/ioctl/close 来配置和读写,有一些标准接口有标准的信息结构,因此有专门的 库,通过这些库来间接的 配置 和 读写设备驱动文件,比如 tslib、i2ctool 等等。

- 等等其它,用时补充。


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

uboot kernel roorfs 看买的放 2T 硬盘的 清华远见的视频
uboot kernel roorfs 看原子的移植,野火

【04】为linux内核移植,先比较全面的说一下文件夹都是什么用,有哪些要改

git clone https://source.codeaurora.org/external/imx/linux-imx
cd linux-imx
git checkout imx_5.4.70_2.3.0
git branch -vv

i.MX_Porting_Guide
i.MX_Linux_Users_Guide
米尔的文章
野火文档 P502
原子文档 P
第三十五章 Linux 内核顶层 Makefile 详解

https://howiexue.blog.csdn.net/article/details/76696631

https://zhuanlan.zhihu.com/p/378149586

参考100ask的BSP移植文档
https://www.freesion.com/article/2426374191/

【05】为Buildroot 构建文件系统

可以先学busybox 构建最精简的文件系统,也比较简单,从这个开始,再看buildroot

参考100ask的BSP移植文档,从0适配 buildroot
http://wiki.100ask.org/Buildroot
野火文档 P519~P536~、P1921,下载 官方文档,原子文档
看一看 100ask imxull 的 buildroot 的配置,uboot linux 的路径配置等待
如何Buildroot解决 将 最终的 flash.bin 编译出,而不是只用 uboot 编译出的:
1、buildroot 可以设置
2、修改uboot的Makefile,make后直接合成flash.bin并改名为buildroot可以识别的uboot.bin之类的

【06】为ubuntu的移植
参考米尔 L4 里面的文章
野火 P1891 制作带桌面的 ubuntu16 根文件系统

【07-08】Linux 驱动/应用开发


野火:
NFS 记到【02】
P341 proc
P343 sys 目录
P347 win 的文件操作
P353 linxu 的文件操作
P358头文件 到P475 外设应用编写 P481进程
还有设备树的使用等等
应用编程很多


Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
从而让访问该文件内容时候就像读写内存一样指针移动和读写),
常用在文件内容的搬运屏幕的 Framebuffer将屏幕驱动文件重映射到一块内存然后读写内存就是读写屏幕

详解mmap原理https://zhuanlan.zhihu.com/p/465336136


********************** 常用 字符流收发 API ***********************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

注:主要参考 百问网 、[linux基础——linux下五种IO模型小结(阻塞IO、非阻塞IO、IO复用、信号驱动式IO、异步IO)_yexz的博客-CSDN博客_linux阻塞型io](https://blog.csdn.net/a987073381/article/details/52201200) (这篇文章会讲的很明白)等。

文件io的读写的基本四种机制:非阻塞(查询),阻塞(休眠死等-唤醒返回),poll/select(设置阻塞事件和时间),异步通知
文件io的读写的基本四种机制:非阻塞(查询),阻塞(休眠死等-唤醒返回),poll/select(设置阻塞事件和时间),异步通知

## 非阻塞(查询)

Expand Down Expand Up @@ -95,11 +95,11 @@ events 的选项:
- [poll函数详解_青季的博客-CSDN博客_poll函数](https://blog.csdn.net/skypeng57/article/details/82743681)
- [ linux基础——linux下多路IO复用接口之select/poll_yexz的博客-CSDN博客](https://blog.csdn.net/a987073381/article/details/52295690)

## 异步通知(异步IO信号
## 异步通知(捕获信号 SIGIO

主要是使用信号机制。

- app 向 一个具体的驱动程序 注册 异步IO事件(SIGIO)信号和 处理/回调/钩子/handler 函数,并告知自己的进程号,并使能 异步通知。
- app 向 一个具体的驱动程序 注册 异步IO事件(SIGIO)的 信号(signal) 和 处理/回调/钩子/handler 函数,并告知自己的进程号,并使能 异步通知。
- 一个具体的驱动程序 在 特定 情况下 通过 内核提供的 API 向 APP 发 异步IO事件(SIGIO)信号。
- 则此时 APP 自动去 调用 并 执行 处理/回调/钩子/handler 函数。

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://zhuanlan.zhihu.com/p/486955226
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@

#include <linux/input.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <stdio.h>


/* ./01_get_input_info /dev/input/event0 */
int main(int argc, char **argv)
{
int fd;
int err;
int len;
int i;
unsigned char byte;
int bit;
struct input_id id;
unsigned int evbit[2];
char *ev_names[] = {
"EV_SYN ",
"EV_KEY ",
"EV_REL ",
"EV_ABS ",
"EV_MSC ",
"EV_SW ",
"NULL ",
"NULL ",
"NULL ",
"NULL ",
"NULL ",
"NULL ",
"NULL ",
"NULL ",
"NULL ",
"NULL ",
"NULL ",
"EV_LED ",
"EV_SND ",
"NULL ",
"EV_REP ",
"EV_FF ",
"EV_PWR ",
};

if (argc != 2)
{
printf("Usage: %s <dev>\n", argv[0]);
return -1;
}

fd = open(argv[1], O_RDWR);
if (fd < 0)
{
printf("open %s err\n", argv[1]);
return -1;
}

err = ioctl(fd, EVIOCGID, &id);
if (err == 0)
{
printf("bustype = 0x%x\n", id.bustype );
printf("vendor = 0x%x\n", id.vendor );
printf("product = 0x%x\n", id.product );
printf("version = 0x%x\n", id.version );
}

len = ioctl(fd, EVIOCGBIT(0, sizeof(evbit)), &evbit);
if (len > 0 && len <= sizeof(evbit))
{
printf("support ev type: ");
for (i = 0; i < len; i++)
{
byte = ((unsigned char *)evbit)[i];
for (bit = 0; bit < 8; bit++)
{
if (byte & (1<<bit)) {
printf("%s ", ev_names[i*8 + bit]);
}
}
}
printf("\n");
}

return 0;
}

Loading

0 comments on commit 8886c6d

Please sign in to comment.