Mastering Embedded Linux Programming 学习 (三)在百问网157开发板上,编译构建linux内核

Mastering Embedded Linux Programming 学习 (三)在百问网157开发板上,编译构建linux内核

一、下载内核源码

wget http://ftp.sjtu.edu.cn/sites/ftp.kernel.org/pub/linux/kernel/v5.x/linux-5.4.223.tar.gz
tar -zxvf linux-5.4.223.tar.gz
mv linux-5.4.223 linux-stable

书上用的是5.4.50版本的,但又提到了如果有新的5.4.x的就用新的5.4.x的,这里下载下来测试一下

设备树文件添加、修改

从原有的157设备树文件复制成我们的板子的文件

cp arch/arm/boot/dts/stm32mp157a-dk1.dts arch/arm/boot/dts/stm32mp157c-myboard.dts

并把arch/arm/boot/dts/stm32mp157c-dk2.dts的额外内容添加到arch/arm/boot/dts/stm32mp157c-myboard.dts

修改arch/arm/boot/dts/Makefile,在157系列下面添加我们的设备树文件,这样在编译stm32mp157系列的设备树的时候就可以自动编译我们的设备树文件了
在这里插入图片描述

删除i2c4节点

在根节点下添加电源配置

v3v3: regulator-3p3v {
	compatible = "regulator-fixed";
	regulator-name = "v3v3";
	regulator-min-microvolt = <3300000>;
	regulator-max-microvolt = <3300000>;
	regulator-always-on;
	regulator-boot-on;
};

v1v8_audio: regulator-v1v8-audio {
	compatible = "regulator-fixed";
	regulator-name = "v1v8_audio";
	regulator-min-microvolt = <1800000>;
	regulator-max-microvolt = <1800000>;
	regulator-always-on;
	regulator-boot-on;
};

v3v3_hdmi: regulator-v3v3-hdmi {
	compatible = "regulator-fixed";
	regulator-name = "v3v3_hdmi";
	regulator-min-microvolt = <3300000>;
	regulator-max-microvolt = <3300000>;
	regulator-always-on;
	regulator-boot-on;
};

v1v2_hdmi: regulator-v1v2-hdmi {
	compatible = "regulator-fixed";
	regulator-name = "v1v2_hdmi";
	regulator-min-microvolt = <1200000>;
	regulator-max-microvolt = <1200000>;
	regulator-always-on;
	regulator-boot-on;
};

vdd: regulator-vdd {
	compatible = "regulator-fixed";
	regulator-name = "vdd";
	regulator-min-microvolt = <3300000>;
	regulator-max-microvolt = <3300000>;
	regulator-always-on;
	regulator-boot-on;
};

vdd: regulator-vdd {
	compatible = "regulator-fixed";
	regulator-name = "vdd";
	regulator-min-microvolt = <3300000>;
	regulator-max-microvolt = <3300000>;
	regulator-always-on;
	regulator-boot-on;
};

vdd_usb: regulator-vdd-usb {
	compatible = "regulator-fixed";
	regulator-name = "vdd_usb";
	regulator-min-microvolt = <3300000>;
	regulator-max-microvolt = <3300000>;
	regulator-always-on;
	regulator-boot-on;
};

有了u-boot的经历,这里就轻车熟路了

编译命令

使用stm32的配置来编译

make ARCH=arm multi_v7_defconfig
make ARCH=arm LOADADDR=0xC2000040 -j 64 uImage
make ARCH=arm dtbs

格式化SD卡

将SD卡的第四个分区格式化为fat格式,然后挂载到ubuntu,最后把生成的uImage和stm32mp157c-myboard.dtb拷贝进去

加载启动内核

通过SD卡进入到u-boot,然后通过如下命令把uImage和设备树加载到DDRAM

fatload mmc 0:4 0xC2000040 uImage

上面这个命令是把0号mmc设备,也就是SD卡的第四个分区里的uImage文件加载到0xC2000040这个位置,这里使用的fatload,所以在这之前要把SD卡第四个分区格式化成fat格式

fatload mmc 0:4 0xC4000040 stm32mp157c-myboard.dtb

同样,把设备树文件加载到内存,这里选择0xC4000040是防止设备树覆盖了内核镜像,这里需要计算一下
结果如下所示
在这里插入图片描述
然后开始启动我们的内核

bootm 0xC2000040 - 0xC4000040

有输出,但是卡在了文件系统这里了,没关系
在这里插入图片描述

Linux has been the mainstay of embedded computing for many years. And yet, there are remarkably few books that cover the topic as a whole: this book is intended to fill that gap. The term embedded Linux is not well-defined, and can be applied to the operating system inside a wide range of devices ranging from thermostats to Wi-Fi routers to industrial control units. However, they are all built on the same basic open source software. Those are the technologies that I describe in this book, based on my experience as an engineer and the materials I have developed for my training courses. Technology does not stand still. The industry based around embedded computing is just as susceptible to Moore's law as mainstream computing. The exponential growth that this implies has meant that a surprisingly large number of things have changed since the first edition of this book was published. This second edition is fully revised to use the latest versions of the major open source components, which include Linux 4.9, Yocto Project 2.2 Morty, and Buildroot 2017.02. Since it is clear that embedded Linux will play an important part in the Internet of Things, there is a new chapter on the updating of devices in the field, including Over the Air updates. Another trend is the quest to reduce power consumption, both to extend the battery life of mobile devices and to reduce energy costs. The chapter on power management shows how this is done. Mastering Embedded Linux Programming covers the topics in roughly the order that you will encounter them in a real-life project. The first 6 chapters are concerned with the early stages of the project, covering basics such as selecting the toolchain, the bootloader, and the kernel. At the conclusion of this this section, I introduce the idea of using an embedded build tool, using Buildroot and the Yocto Project as examples. The middle part of the book, chapters 7 through to 13, will help you in the implementation phase of the project. It covers the topics of filesystems, the init program, multithreaded programming, software update, and power management. The third section, chapters 14 and 15, show you how to make effective use of the many debug and profiling tools that Linux has to offer in order to detect problems and identify bottlenecks. The final chapter brings together several threads to explain how Linux can be used in real-time applications. Each chapter introduces a major area of embedded Linux. It describes the background so that you can learn the general principles, but it also includes detailed worked examples that illustrate each of these areas. You can treat this as a book of theory, or a book of examples. It works best if you do both: understand the theory and try it out in real life.
### 回答1: 《嵌入式Linux编程的精髓-第二版》是一本涵盖嵌入式Linux编程相关知识的书籍。嵌入式系统是指嵌入到设备中,负责控制设备运行的计算机系统。Linux是一种自由、开放源代码的操作系统,广泛应用于嵌入式系统中。 在第二版中,这本书提供了嵌入式系统开发的最新趋势和技术。它讲解了嵌入式Linux系统的搭建和配置,包括交叉编译工具链的搭建、Linux内核的配置和裁剪,以及Bootloader的加载等。此外,书中还介绍了如何进行硬件与软件的交互,包括GPIO控制、设备驱动的开发与调试等。 本书还特别强调了实践与项目开发。作者通过编写一些实际案例来引导读者探索不同的嵌入式项目,包括络应用、图形界面、多媒体处理、无线通信等。这有助于读者将所学知识应用到实际开发中,提高嵌入式系统的开发能力。 此外,本书还介绍了调试和优化嵌入式系统的方法。作者分享了一些调试工具和技巧,帮助读者解决开发中的常见问题。还介绍了优化嵌入式系统性能的方法,以提高系统的速度和响应能力。 总之,《嵌入式Linux编程的精髓-第二版》是一本全面而实践性强的嵌入式Linux编程学习指南。通过学习本书,读者将能够掌握Linux的基本原理和嵌入式系统的开发技巧,并能够应用于实际项目中,提高嵌入式系统的性能和稳定性。 ### 回答2: 《嵌入式Linux编程:第二版》是一本涵盖嵌入式Linux系统开发的重要概念和技术的书籍。本书旨在帮助读者掌握嵌入式Linux编程的各个方面,从而成为一名嵌入式系统开发专家。 第二版的《嵌入式Linux编程》与第一版相比,进行了更新和扩展。本书涵盖了Linux内核的最新版本,并介绍了最新的嵌入式Linux开发工具和技术。同时,本书还增加了对容器化和虚拟化技术在嵌入式Linux系统中的应用的讨论。 本书的内容涵盖了从基础知识到高级主题的嵌入式Linux系统开发。读者将学习如何搭建嵌入式Linux开发环境,了解Linux内核的基本概念和结构,并深入研究设备驱动程序和文件系统的开发。此外,本书还介绍了嵌入式系统的调试和性能优化技术,以及与硬件交互的通信协议和接口。 读者在阅读本书时,将通过实例和案例学习,结合实际应用场景,将理论知识应用到实际项目中。通过深入学习嵌入式Linux编程,读者将能够理解和掌握嵌入式Linux系统的架构和工作原理,能够编写高效、可靠的设备驱动程序和应用程序,并能够解决嵌入式系统开发中遇到的各种挑战和问题。 总之,通过阅读《嵌入式Linux编程:第二版》,读者将获得全面的嵌入式Linux编程知识和技能,并能够在实际项目中应用这些知识和技能,成为一名嵌入式系统开发专家。 ### 回答3: 《嵌入式Linux编程掌握-第二版》是一本深入了解嵌入式Linux编程的指南。这本书适合有一定编程基础的读者,他们有兴趣学习如何在嵌入式系统中使用Linux。它提供了关于嵌入式Linux的详细知识和实践经验,包括Linux内核和设备驱动程序的基础知识,以及如何将Linux运行在各种不同的嵌入式硬件上。 这本书的第二版提供了更加深入和全面的内容,与第一版相比进行了更新和扩充。它介绍了如何为嵌入式系统配置和编译Linux内核,以及如何开发和调试Linux设备驱动程序。此外,它还涵盖了嵌入式Linux系统的络和存储管理,以及如何优化和调试系统性能。 书中还包含了大量的示例代码和实验项目,读者可以通过实践来加深对所学知识的理解和掌握。此外,该书还介绍了一些流行的嵌入式开发板和硬件平台,以及常用的开发工具和调试技术。 总的来说,通过阅读《嵌入式Linux编程掌握-第二版》,读者将获得深入了解嵌入式Linux系统开发的能力,并在实践中掌握如何在嵌入式系统中应用Linux的技术和工具。这对想要在嵌入式领域从事开发工作的人来说是一本很有价值的参考书。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值