Mastering Embedded Linux Programming 学习 (一)嵌入式交叉编译工具链的构建,基于crosstool-NG

Mastering Embedded Linux Programming 学习 (一)

一、ubuntu 软件包下载

sudo apt install autoconf automake bison bzip2 cmake \
flex g++ gawk gcc gettext git gperf help2man libncurses5-dev libstdc++6 libtool \
libtool-bin make patch python3-dev rsync texinfo unzip wget xz-utils

二、安装QEMU


qemu-system-arm -machine vexpress-a9 -m 256M -drive file=rootfs.ext4,sd -net nic -net use -kernel zImage -dtb vexpress-v2p-ca9.dtb -append "console=ttyAMA0,115200 root=/dev/mmcblk0" -serial stdio -net nic,model=lan9118 -net tap,ifname=tap0

使用上面的命令创建一个虚拟机

sudo tunctl -u $(whoami) -t tap0

上面的一行命令创建一个名为tap0的网络接口,tunctl命令需要安装一个uml-utilities的软件包

三、安装crosstool-NG

# git clone https://github.com/crosstool-ng/crosstool-ng.git
git clone https://gitee.com/ffbuild/crosstool-ng.git
cd crosstool-ng
git checkout crosstool-ng-1.24.0
./bootstrap
./configure --prefix=${PWD}
make
make install

四、使用crosstool-NG为BeagleBone Black构建工具链

输出支持的工具链

执行完上面的命令之后,使用下面的命令可以列出支持哪些工具链

bin/ct-ng list-samples

显示工具链配置

bin/ct-ng show-arm-cortex_a8-linux-gnueabi

类似的就是在list-samples输出的选项前面加上show-前缀,输出相应工具链的信息
上面的命令输出如下图所示
图一

选择工具链

要选择一个工具链,使用如下的命令就可以指定一个工具链

bin/ct-ng arm-cortex_a8-linux-gnueabi

配置工具链

bin/ct-ng menuconfig

使用上面的命令就可以图形化配置我们的工具链,如下图所示
在这里插入图片描述
建议:

  1. Paths and misc options选项下禁用 Render the toolchain read-only
  2. Target options | Floating point选项下选中hardware(FPU)(CT_ARCH_FLOAT_HW)
  3. Target options选项下的Use specific FPU 输入neon

构建工具链

bin/ct-ng build

运行上面的命令就开始为BeagleBone Black构建交叉编译工具链了

不出意外还是出意外了

好家伙,跑了两个多小时,报错了
在这里插入图片描述

调试开始
  1. 参考博客下载离线包Linux-交叉编译工具链的制作(crosstool-ng-1.24)
  2. 修改.config文件里面的src路径,把build时需要下载的包手动下载放到文件夹下面就可以了(上面的博客提供的仓库的软件包在2022.11.4日已经更新了,需要重新下载对应版本的)
  3. linux内核源码下载国内源
  4. expat下载国内源
  5. ncurses-6.1下载国内源

    然后就可以build成功了
调试结束

五、使用crosstool-NG为QEMU构建工具链

首先运行

bin/ct-ng distclean

清除之前build留下的内容
后面的步骤和BeagleBone Black构建相同,只需要禁用Paths and misc options下的Render the toolchain readonly就可以了
注意:还需要修改src目录,这样才能找到我们下载好的各种软件源码压缩包

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Key Features, Create efficient and secure embedded devices using LinuxMinimize project costs by using open source tools and programsExplore each component technology in depth, using sample implementations as a guide, Book Description, Mastering Embedded Linux Programming takes you through the product cycle and gives you an in-depth description of the components and options that are available at each stage. You will begin by learning about toolchains, bootloaders, the Linux kernel, and how to configure a root filesystem to create a basic working device. You will then learn how to use the two most commonly used build systems, Buildroot and Yocto, to speed up and simplify the development process. Building on this solid base, the next section considers how to make best use of raw NAND/NOR flash memory and managed flash eMMC chips, including mechanisms for increasing the lifetime of the devices and to perform reliable in-field updates. Next, you need to consider what techniques are best suited to writing applications for your device. We will then see how functions are split between processes and the usage of POSIX threads, which have a big impact on the responsiveness and performance of the final device The closing sections look at the techniques available to developers for profiling and tracing applications and kernel code using perf and ftrace., What you will learn, Understand the role of the Linux kernel and select an appropriate role for your applicationUse Buildroot and Yocto to create embedded Linux systems quickly and efficientlyCreate customized bootloaders using U-BootEmploy perf and ftrace to identify performance bottlenecksUnderstand device trees and make changes to accommodate new hardware on your deviceWrite applications that interact with Linux device driversDesign and write multi-threaded applications using POSIX threadsMeasure real-time latencies and tune the Linux kernel to minimize them, About the Author, Chris Simmonds is a software consultant and trainer who lives in southern England. He has been using Linux in embedded systems since the late 1990s, during which he has worked on many interesting projects, including a stereoscopic camera, intelligent weighing scales, various set-top boxes and home routers, and even a large walking robot., He is a frequent presenter at open source and embedded conferences, including the Embedded Linux Conference, Embedded World, and the Android Builders' Summit. He has been conducting training courses and workshops in embedded Linux since 2002 and in embedded Android since 2010. He has delivered hundreds of sessions to many well-known companies. You can see some of his work on the 'Inner Penguin' blog at www.2net.co.uk., Table of Contents, Starting OutLearning About ToolchainsAll About BootloadersPorting and Configuring the KernelBuilding a Root FilesystemSelecting a Build SystemCreating a Storage StrategyIntroducing Device DriversStarting up - the init ProgramLearning About Processes and ThreadsManaging MemoryDebugging with GDBProfiling and TracingReal-time Programming
Key Features Create efficient and secure embedded devices using Linux Minimize project costs by using open source tools and programs Explore each component technology in depth, using sample implementations as a guide Book Description Mastering Embedded Linux Programming takes you through the product cycle and gives you an in-depth description of the components and options that are available at each stage. You will begin by learning about toolchains, bootloaders, the Linux kernel, and how to configure a root filesystem to create a basic working device. You will then learn how to use the two most commonly used build systems, Buildroot and Yocto, to speed up and simplify the development process. Building on this solid base, the next section considers how to make best use of raw NAND/NOR flash memory and managed flash eMMC chips, including mechanisms for increasing the lifetime of the devices and to perform reliable in-field updates. Next, you need to consider what techniques are best suited to writing applications for your device. We will then see how functions are split between processes and the usage of POSIX threads, which have a big impact on the responsiveness and performance of the final device The closing sections look at the techniques available to developers for profiling and tracing applications and kernel code using perf and ftrace. What you will learn Understand the role of the Linux kernel and select an appropriate role for your application Use Buildroot and Yocto to create embedded Linux systems quickly and efficiently Create customized bootloaders using U-Boot Employ perf and ftrace to identify performance bottlenecks Understand device trees and make changes to accommodate new hardware on your device Write applications that interact with Linux device drivers Design and write multi-threaded applications using POSIX threads Measure real-time latencies and tune the Linux kernel to minimize them About the Author Chris Simmonds is a software consultant and trainer who lives in southern England. He has been using Linux in embedded systems since the late 1990s, during which he has worked on many interesting projects, including a stereoscopic camera, intelligent weighing scales, various set-top boxes and home routers, and even a large walking robot. He is a frequent presenter at open source and embedded conferences, including the Embedded Linux Conference, Embedded World, and the Android Builders' Summit. He has been conducting training courses and workshops in embedded Linux since 2002 and in embedded Android since 2010. He has delivered hundreds of sessions to many well-known companies. You can see some of his work on the "Inner Penguin" blog at www.2net.co.uk. Table of Contents Chapter 1: Starting Out Chapter 2: Learning About Toolchains Chapter 3: All About Bootloaders Chapter 4: Porting and Configuring the Kernel Chapter 5: Building a Root Filesystem Chapter 6: Selecting a Build System Chapter 7: Creating a Storage Strategy Chapter 8: Introducing Device Drivers Chapter 9: Starting up - The init Program Chapter 10: Learning About Processes and Threads Chapter 11: Managing Memory Chapter 12: Debugging with GDB Chapter 13: Profiling and Tracing Chapter 14: Real-time Programming
### 回答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、付费专栏及课程。

余额充值