46
第一部分 基 础 知 识 1开发系统的安装 2管理系统控制台 3C编译器、设备驱动及其开发技术 4使用脚本和系统守护进程的快速编程 5配置一个嵌入式操作系统 Part 1

GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

  • Upload
    others

  • View
    34

  • Download
    0

Embed Size (px)

Citation preview

Page 1: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

第一部分

基 础 知 识

■ 第1章 开发系统的安装■ 第2章 管理系统控制台■ 第3章 C编译器、设备驱动及其开发技术■ 第4章 使用脚本和系统守护进程的快速编程■ 第5章 配置一个嵌入式操作系统

Part 1

Page 2: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

第 1 章

开发系统的安装

本章将介绍三个最常用的工业应用开发平台,其中包括很著名的 Raspberry Pi(树莓派)。

这些主板大都是工业环境中的定制主板,并基于广泛使用的 CPU。实际上,虽然 Raspberry Pi 的 CPU 不易应用于元件市场上,但却可以广泛适用于不同制造商的专业主板。

接下来的章节将简要介绍每个主板,并讲解如何设置它们来运行一个完整的 GNU / Linux 部署,以及如何访问系统控制台。之后我们将在每个开发板上安装一个完整的开发系

统,以便能够添加我们自己的程序。

关于如何建立主机系统,也会提供一篇小教程,可以利用它来建立一个基于 GNU/Linux 的工作机或者一个专用虚拟机。

如果你已经有一个可运行的嵌入式系统和宿主机,这一章可以跳过。尽管如此,你也

应考虑阅读一下它,因为本章将介绍在本书中使用到的嵌入式设备。在本章中,我们将修

正本书中使用的常用术语,你可以通过不同方法在你的主板上安装系统。此外还有重要的

一点,已在你主板上运行的系统可能不同于这里介绍的,这意味着你可能需要相应地改变

本书中的一些命令才能成功使用范例。

1.1 嵌入式术语

在着手新主板之前,建议先熟悉一些使用者须知的术语,以避免误解。已经有一些

GNU / Linux 或嵌入式系统工作经验的人可跳过该部分。这里列出的开发工具是微小的单

板计算机,它可以嵌入到另一个设备中,所以用户应该熟悉如下一些在嵌入式中使用的

术语:

Chapter 1

Page 3: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

第1章 开发系统的安装   3

术语 描述

目标

目标系统是我们希望管理的嵌入式计算机。通常,它是一个 ARM 平台,但不一定全是此系列

的。事实上,还有 PowerPC 和 MIPS 等(较少)的共同平台。即使 x86 平台(标准 PC)也可以算

是嵌入式计算机

主机

主机系统是用来管理目标系统的计算机。通常,这是一个普通的 PC(x86 平台或 Mac),但也

可以使用其他平台(例如,几年前,我使用了一个基于 PowerPC 的计算机作为上位机)。

通常情况下,主机系统比目标系统更强大,因为它通常用于繁重的编译任务,而这些任务目标

机根本不能执行,或者需要较长时间来执行

串口控制台

这是嵌入式系统中最重要的通信端口。

使用串口控制台,用户控制整个系统。它不仅是调试的必须部分,还是意外情况下的杀手锏,

如果操作系统文件会混乱并且主板拒绝启动,就需要使用串口控制台。

没有串口控制台,用户仍然可以控制系统(如果正确设置),但对于开发人员或者调试员,这

是必须具备的

编译器(或本

机编译器)

本机编译器只是一个编译器。编译器运行在建立代码的机器(主机或目标机)上(也就是说,

在 PC 上运行的编译器为 PC 建立代码,而运行在 ARM 机器上为了构建 ARM 本身的代码)

交叉编译

严格地说,交叉编译器只是一个编译器,它为其他平台生成代码(也就是说,一个交叉编译器

可以在 PC 上运行,以便为 ARM 平台生成二进制文件)。但通常情况下,嵌入式开发者使用该术

语时也表示完整的编译套件,即编译器、连接器、二进制工具、库,等等。

工具链

工具链是一套编程工具,用于创建一个软件产品,即一个计算机程序或一系列相关的程序。

工具链是许多工具连接在一起形成的链,链中的工具顺序执行,所以每个工具的输出成为下一

个的输入。然而,这不是一个固定的规则。事实上,工具链内的工具不一定顺序执行。一个简单

的软件开发工具链可能会包括一个编译器、链接器(以及其他工具)、一个或多个库(为操作系统

提供的接口),以及一个调试器(用于调试程序)

发行版

一个发行版(或 Linux 发行版,通常称为发行版的简称)是由一个基于 Linux 的软件集合(内

核)和几个软件包(大多数来自 GNU 项目或基于自由软件许可证)的包管理系统管理组成的一

个操作系统。

有好多发行版,它们可应用于各种各样的从嵌入式设备(OpenWrt 和 Yocto)、个人电脑、超级

计算机等

根文件系统

根文件系统(或文件系统)的文件位于同一分区的根目录下。

这是 UNIX 系统中最重要的文件系统,也是第一个由内核挂载的文件系统,其他所有的文件系

统都挂载在它上面

系统芯片

片上系统(SoC)是一种集成电路,集成了 CPU 和各种外设(SATA 和 SD / MMC 控制器、

GPIO、I2C/SPI / W1 控制器、ADC / DAC、音频 / 视频信号和以太网或 UART 端口)到单个芯片。

这些芯片广泛应用于嵌入式系统中和适合自己的应用中

微控制器

微控制器(MCU)是在一个单一的集成电路的小型计算机(如 SoC),包含一个核心处理器、

内存和可编程 IO 外设。因此,和 SoC 之间的主要区别在于它有闪存(其中存储的程序)以及少

量的 RAM(执行程序)包含在其芯片上,微控制器专应用于嵌入式中不太复杂的任务。使用时

有时间限制,或者说是因为它们很划算

闪存闪存是一种非易失性的电子存储介质,可以电擦除和重新编程。与普通 PC 相比,这种存储器

广泛应用于嵌入式中作为大规模存储,并且它没有移动部件,对其他环境中有较好的抵抗力

既然我们已经列出一些重要的术语,就准备好进入下一节,并发掘我们的开发工具。

Page 4: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

4   第一部分 基 础 知 识

1.2 系统概述

这里简单介绍下本书中将使用的开发平台。

第一个工具是 BeagleBone Black 平台,这是一个低成本并且为开发者和社区爱好者支

持的开发平台。它能够在 10 秒内启动 Linux,并在几分钟内开始开发,它只有一个 USB 接

口,在互联网上广泛使用,所以它是每一个嵌入式编程者都应该知道的开发板。

第二个工具是 SAMA5D3 Xplained 平台,这是一个快速的设计平台,配备了一套丰富

的使用接口、存储设备和易于定制的扩展头。USB 设备连接器可用于电源板以及编程和调

试。这个板比较有趣,因为它使用的 CPU 非常低功耗,同时具有良好的性能并且大量面向

工业的设备。

最后的工具是 Wandboard 平台,这是一个高性能的具有完整多媒体功能的计算机,与

其他板相比,该板拥有良好的外设,它由一个核心模块和一个定制的接口板组成。这个板

非常有趣,因为它可以配备一个多核 CPU,还可以作为一个 CPU 模块连接到一个载波板,

它可以让嵌入式开发人员有一个高度可定制的硬件设备。

1.2.1 BeagleBone Black 开发平台

如下图所示,图中有 BeagleBone Black 和信用卡,这样你就可以了解整个系统的尺寸。

这里有一些链接,从中可以了解到一些关于 BeagleBone Black 的有用信息:

� https://beagleboard.org/black � http://beagleboard.org/static/beaglebone/latest/Docs/Hardware/BONE_SRM.pdf � http://beagleboard.org/getting-started

Page 5: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

第1章 开发系统的安装   5

� https://eewiki.net/display/linuxonarm/BeagleBone+BlackBeagleBone Black(修订本)硬件的主要特点如下表所示。

组成部分 参数说明

主处理器 ARM processor: Cortex-A8 @ 1GHz

图形处理器 PowerVR SGX

SDRAM 存储器 512MB DDR3

板载闪存 4GB, 8-bit eMMC

USB 2 端口1 个设备 1 台主机

串口 UART0 通过 6 引脚 3.3 V TTL 连接器

以太网 1 port 10/100 via RJ45 connector

SD/MMC 1 slot microSD

视频 / 音频输出 Micro HDMI

按钮

1 for power 1 for reset1 user controllable

LED 指示灯

1 for power 2 on Ethernet port 4 user controllable

主板 Wi-Fi / 蓝牙 无

SATA 无

扩充接口

Power 5V, 3.3V, VDD ADC (1.8V) GPIO 3.3V SPI, I2C, LCD, GPMC, MMC0-1, CAN 7 ADC (1.8V max) 4 timers 4 serial ports 3 PWMs

J-TAG 连接器 20 pins J-TAG (not populated)

然后,下面的图片显示的是 BeagleBone Black 的俯视图,我们可以看到一些部件:

� J1 连接器用于访问串口。

� 以太网插口。

� 电源插口。

� 两伸缩连接器 P8 和 P9,在那里可以连接专用的扩展板或自定义外设(这些连接器将

在接下来的章节中详细解释)。

� microSD 插槽。

� USB 主机接口。

� 复位按钮用来复位,电源键用来打开 / 关闭主板,还有可控的用户按钮,可以用来替

代 microSD 卡(而不是板上 eMMC)的引导。

Page 6: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

6   第一部分 基 础 知 识

电源串口 以太网插口

电源键

复位按钮

伸缩连接器

用户按钮

插槽USB 接口

伸缩连接器

访问串口

从前面的图中我们可以看到,BeagleBone Black 不像 PC,但它可以作为一个 PC。

BeagleBone Black 是一个全功能的单板计算机,如果通过 HDMI 端口连接到显示器,通过

USB 集线器连接到键盘和鼠标,就可以很容易地当作电脑来使用,但是它更适合于嵌入式

应用,由于其可扩展的连接使得它可以比 PC 作用更大,用途更多。在这本书中,我们将看

到如何管理和重装一个完整的 Debian 发行版,该系统可以让我们有一系列软件包,当作一

个正常的 PC 来用(事实上,Debian ARM 版相当于 Debian 的 x86 版本)。然后,我们将看

到如何使用扩展连接器连接到主板,并且用一些外设来监视 / 控制外部环境。

1.2.2 SAMA5D3 Xplained 开发平台

下图所示是一个 SAMA5D3 Xplained 和一张信用卡,我们可以很容易地观察到,相比

于 BeagleBone Black,这个开发板稍微大一点,因为主板上嵌入了更多的接口和端口。值

得注意的是,在板中心的扩展连接器和 Arduino R3 兼容,所以可以在扩展板上利用它

Page 7: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

第1章 开发系统的安装   7

这里有一些链接,从中可以了解到一些关于 SAMA5D3 Xplained 的有用信息:

� http://www.atmel.com/tools/ATSAMA5D3-XPLD.aspx � http://www.atmel.com/images/atmel-11269-32-bit-cortex-a5-microcontroller-sama5d3-xplained_user-guide.pdf

� http://www.at91.com/linux4sam/bin/view/Linux4SAM/Sama5d3XplainedMainPage � https://eewiki.net/display/linuxonarm/ATSAMA5D3+Xplained

值得注意的是,根据 CPU 的版本有不同版本的 SAMA5D3 主板,有 SATSAMA5D31、SATSAMA5D33、SATSAMA5D34、SATSAMA5D35、ATSAMA5D36。每个 CPU 有相同的

内核,但不同的外设集。

在这本书中,我们将使用 ATSAMA5D36 平台,其主要的硬件特点本版本如下表所示。

组成部分 参数

主处理器 ARM 处理器: Cortex-A5 @ 536MHz

图形处理器 LCD controller with graphics accelerator

SDRAM 存储器 256MB DDR2

板载闪存 256MB, NAND flash

USB 2 端口1 device 1 host

串口 UART0 通过 6 引脚 3.3 V TTL 连接器

以太网1 port 10/100/1000 via RJ45 connector 1 port 10/100 via RJ45 connector

SD/MMC1 slot SD/MMCPlus 8-bit 1 slot microSD 4-bit (not soldered)

视频 / 音频输出 Digital interface

按钮

1 for reset 1 for wake up 1 user controllable

LED 指示灯

1 for power 2 on each Ethernet port 1 user controllable

主板 Wi-Fi / 蓝牙 Optional WiFi via SDIO expansion

SATA 无

扩充接口

GPIO 3.3V SPI, I2C0 -1, CAN0-1, VBAT 12 ADC (3.3V max) 2 timers 6 serial ports 2 PWMs

J-TAG 连接器 20 pins J-TAG (not populated)

下图所示为 SAMA5D3 Xplained 的俯视图,我们可以看到:

Page 8: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

8   第一部分 基 础 知 识

� 连接器可用于访问串口。

� USB 微端口可以作为一个 USB 设备的接口,它也用作电源端口,还可以当作 SAM-BA USB 设备和 CDC 接口。

� 两个以太网接口。

� LCD 接口。

� JTAG 接口。

� 两个 USB 主机端口。

� 伸缩接头(注意,这些连接器是与 Arduino R3 兼容的)。

� 复位按钮可用于复位板。唤醒按钮可以用来打开 / 关闭板。

以太网插口USB 主机端口

用户按钮

访问串口

LCD

JTAG

唤醒按钮

复位按钮

USB 设备

扩展连接器

即使它是专为工业任务设计的,该主板也可以当作一个 PC 来用。它可以抵抗非常恶劣

的环境,低功耗并且有大量专用外设应用。相对于 BeagleBone Black,它不能外接 HDMI连接器,但它有一个专门的可带触摸屏的 LCD 连接器。

对于这个主板,我们会安装一个完整的 Debian 发行版,并且使用扩展连接器连接到

主板。

1.2.3 Wandboard 开发平台

下图所示为 Wandboard 开发平台,同信用卡的尺寸比较。

Page 9: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

第1章 开发系统的安装   9

主板相当小,但它实际上是由两部分组成的:核心模块在接口(或载体)模块的上面

(见下图)。

下面有一些网址,可以从中获得一些有用的信息:

� http://www.wandboard.org/

Page 10: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

10   第一部分 基 础 知 识

� http://www.wandboard.org/images/downloads/wbquad-revb1-userguide.pdf � http://wiki.wandboard.org/Main_Page � https://eewiki.net/display/linuxonarm/Wandboard

注意,Wandboard 板根据 CPU 版本分不同的版本,因此有 Wandboard Solo、Wandboard Dual、Wandboard Quad。每个版本的 CPU 都有相同的核心,但外设集和核心号码不同。事

实上,Wandboard 可以有单核、双核、四核 CPU。

在这本书中,我们将使用 Wandboard Quad 平台,其主要的硬件特点如下表所示。

组成部分 参数

主处理器 ARM 处理器: Quad Cortex-A9 @ 1GHz

图形处理器 Vivante GC 2000 + Vivante GC 355 + Vivante GC 320

SDRAM 存储器 2GB DDR3

板载闪存 无

USB 2 端口1 OTG 2 host

串口 UART0 via standard RS232 pin9 connector

以太网 1 port 10/100/1000 via RJ45 connector

SD/MMC 2 slot SD/MMCPlus 8-bit

视频 / 音频输出

HDMI Analog audio plus optical S/P DIF Digital camera connector

按钮 1 for reset

LED 指示灯1 for power 2 on Ethernet port

主板 Wi-Fi / 蓝牙 802.11n/4.0

SATA 1 connector

扩充接口

GPIOs 3.3V SPI, I2C0-1, CAN0-1, VBAT 12 ADC (3.3V max) 2 timers 6 serial ports 2 PWMs

J-TAG 连接器 8 pins J-TAG (not populated)

下图为 Wandboard 的俯视图,可以了解到一些信息。

� RS-232 9 引脚连接器 COM1,可用于访问串口。

� USB 迷你端口作为 USB OTG 接口。

� USB 主机端口。

� 辅助 microSD 连接器。

� 电源接口。

Page 11: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

第1章 开发系统的安装   11

� 以太网接口。

� 音频端口。

� SATA 连接器。

� HDMI 连接器。

串口(COM1)SATA 连接器音频端口

HDM1 连接器

以太网接口

电源接口

USB 主机端口

辅助 microSD 连接器

USB 设备

在顶部(核心模块在左边和接口模块在右边)有:

� 摄像头接口连接器

� 主微型 SD � Wi-Fi 芯片

� 4 个扩展连接器

� 复位按钮可用于复位主板

如下图所示,此主板也可以作为一个电脑,这也是为什么我们会在板子上装一个完整

的 Debian 发行版。和 BeagleBone Black 平台类似,此开发板有一个外接显示器的 HDMI 连接器。

扩展连接器 复位按钮

microSd

摄像头接口

WiFi J-TAG

1.3 安装开发系统

本书的目的是解释如何在主板上访问外设,以及如何快速编写程序来管理数据。要做

Page 12: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

12   第一部分 基 础 知 识

到这一点,需要一个好的开发系统。这就是为什么在本节中我们将在每个开发板上安装一

个 Debian 操作系统。

以 GNU / Linux 为基础的开发板的主要优点之一是,无论我们决定使用哪种开发板,

都可以有相同的开发环境。实际上,为了证明这一事实,我们将在每个开发板上安装完

全相同的操作系统(即使有预装操作系统的开发板)。要做到这一点,只需要一个 SD(或

microSD)卡存储我们开发的操作系统,然后按照下面的指示进行操作。但是,在着手嵌入

式板之前,需要建立宿主机。

1.3.1 设置宿主机

每一个优秀的嵌入式开发人员都知道,宿主机是必要的,即使现在的嵌入式设备变得

越来越强大,但一些资源消耗的任务,可以用宿主机来运行。

我们使用的宿主机可以是普通 PC 也可以是虚拟机。重要的是,它运行一个基于 GNU / Linux 的操作系统。在这本书中,我们将使用 Ubuntu 15.10 系统,你可以使用此系统(也可

在虚拟机内)或者使用 Ubuntu 长期支持(LTS)的版本,如 16.04 版本,没有其他问题或重

大变化。当然,也可以尝试复制一些在本书中用到的设置和安装命令到其他 Linux 发行版

的系统。

1. 基本工具如果我们安装了一个干净的系统或从来没有使用我们的机器开发过程序,那么我们必

须在继续之前安装一些有用的开发工具。第一步,我们将安装的 aptitude 工具和非常出名的

apt-get 命令相似,但它更智能(请注意,这不是必需的,因为我们仍然可以继续使用 apt-get,而没有任何问题)。这里是安装命令:

Installing the Developing System

[ 32 ]

However, before putting our hands on the embedded boards, we need to set up our hostmachine.

Setting up the host machineAs every good embedded developer knows, a host machine is absolutely necessary. Even ifthe embedded devices are getting more powerful nowadays, there are some resource-consuming tasks where a host machine can help.

The host machine we decide to use could be a normal PC or a virtualized one. Theimportant thing is that it runs a GNU/Linux-based OS! In this book, we will use an Ubuntu15.10 based system (since this is currently my laptop's configuration), you can decide to usethe same (maybe in a virtual machine) or just to use an Ubuntu Long Term Support (LTS)release, such as 16.04 for instance, without any problem or major changes. However, we canalso try to replicate some settings and installation commands that we will use during thecourse of the book into another Linux distribution with little effort.

Basic toolsIf we did a clean installation or we have never used our machine as a developing one, thenwe have to install some useful developing tools before continuing. As the first step, we willinstall the aptitude tool, which is quite similar to the most famous apt-get command,but it's smarter (note that this is not required since we may still continue using apt-getwithout any problems). Here is the installing command:

$ sudo apt-get install aptitude

Then, we can install other useful basic tools using the aptitude command as shown here:

$ sudo aptitude install openssh-server tree git device-tree-compiler lzma lzop libncurses5-dev:amd64 minicom

After all packages have been installed, we can go further and install the cross-compiler withthe relative toolchain.

然后,可以使用 aptitude 命令安装其他有用的基本工具,如下:

Installing the Developing System

[ 32 ]

However, before putting our hands on the embedded boards, we need to set up our hostmachine.

Setting up the host machineAs every good embedded developer knows, a host machine is absolutely necessary. Even ifthe embedded devices are getting more powerful nowadays, there are some resource-consuming tasks where a host machine can help.

The host machine we decide to use could be a normal PC or a virtualized one. Theimportant thing is that it runs a GNU/Linux-based OS! In this book, we will use an Ubuntu15.10 based system (since this is currently my laptop's configuration), you can decide to usethe same (maybe in a virtual machine) or just to use an Ubuntu Long Term Support (LTS)release, such as 16.04 for instance, without any problem or major changes. However, we canalso try to replicate some settings and installation commands that we will use during thecourse of the book into another Linux distribution with little effort.

Basic toolsIf we did a clean installation or we have never used our machine as a developing one, thenwe have to install some useful developing tools before continuing. As the first step, we willinstall the aptitude tool, which is quite similar to the most famous apt-get command,but it's smarter (note that this is not required since we may still continue using apt-getwithout any problems). Here is the installing command:

$ sudo apt-get install aptitude

Then, we can install other useful basic tools using the aptitude command as shown here:

$ sudo aptitude install openssh-server tree git device-tree-compiler lzma lzop libncurses5-dev:amd64 minicom

After all packages have been installed, we can go further and install the cross-compiler withthe relative toolchain.

所有软件包已经安装,接下来可以安装交叉编译器和相关工具链。

2. 交叉编译器每个宿主机对于目标机都需要一个适当的交叉编译器,所以我们必须安装一个交叉编

译器。在接下来的章节里,我们需要交叉编译器来构建一个引导加载程序和内核,由于使

用 Debian,所以可以直接在目标机的用户空间里编译应用。然而,可以使用它完成一些其

他任务,例如编译不同的驱动程序或编译用户空间应用程序。在后面的这种情况下,我们

需要格外注意交叉工具链与目标机的一些问题(依赖库的版本兼容、头文件,等等)。否则

会不时出现一些莫名其妙的问题。

Page 13: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

第1章 开发系统的安装   13

提示:请注意,如果我们使用一个嵌入式发行版如 Yocto 或 OpenWrt(第 5 章),我

们必须使用交叉编译器编译用户空间应用程序,因为在目标机上没有编译器。

安装交叉编译器有多种方案,可以从发行商处获得已有的资源。Ubuntu 有自己的交叉

编译器,如下所示,使用下面的命令:

Installing the Developing System

[ 33 ]

The cross-compilerEvery host machine needs a proper cross-compiler for the target board we wish to work on,so we have to install one. As we can see in the upcoming chapters, we mainly need a cross-compiler to build the bootloader and the kernel, since we can directly compile user-spaceapplications on the target itself due the fact we're using Debian. However, we can use it forseveral other tasks, for instance, to compile specific drivers and/or to compile user-spaceapplications even if, in this last case, we need to be careful to keep the cross toolchain instep with the target (having compatible library versions, header files, and so on). Otherwise,it would case subtle problems from time to time.

Note that if we use an embedded distribution such as Yocto orOpenWrt (Chapter 5, Setting Up an Embedded OS), we must use the cross-compiler to compile user-space applications too, since we have no nativecompiler to execute on the boards.

There are several solutions to install a cross-compiler, starting from installing the onesupplied by the used distribution to using a pre-built one. Ubuntu has its own cross-compiler, as shown here, using the following command:

$ apt-cache search gcc-[0-9.]*-armgcc-5-arm-linux-gnueabihf - GNU C compilergcc-5-arm-linux-gnueabihf-base - GCC, the GNU Compiler Collection (base package)gcc-4.7-arm-linux-gnueabi - GNU C compilergcc-4.7-arm-linux-gnueabi-base - GCC, the GNU Compiler Collection (base package)gcc-4.7-arm-linux-gnueabihf - GNU C compilergcc-4.7-arm-linux-gnueabihf-base - GCC, the GNU Compiler Collection (base package)gcc-4.8-arm-linux-gnueabihf - GNU C compilergcc-4.8-arm-linux-gnueabihf-base - GCC, the GNU Compiler Collection (base package)gcc-4.9-arm-linux-gnueabi - GNU C compilergcc-4.9-arm-linux-gnueabi-base - GCC, the GNU Compiler Collection (base package)gcc-4.9-arm-linux-gnueabihf - GNU C compilergcc-4.9-arm-linux-gnueabihf-base - GCC, the GNU Compiler Collection (base package)gcc-5-arm-linux-gnueabi - GNU C compilergcc-5-arm-linux-gnueabi-base - GCC, the GNU Compiler Collection (basepackage)

Installing the Developing System

[ 33 ]

The cross-compilerEvery host machine needs a proper cross-compiler for the target board we wish to work on,so we have to install one. As we can see in the upcoming chapters, we mainly need a cross-compiler to build the bootloader and the kernel, since we can directly compile user-spaceapplications on the target itself due the fact we're using Debian. However, we can use it forseveral other tasks, for instance, to compile specific drivers and/or to compile user-spaceapplications even if, in this last case, we need to be careful to keep the cross toolchain instep with the target (having compatible library versions, header files, and so on). Otherwise,it would case subtle problems from time to time.

Note that if we use an embedded distribution such as Yocto orOpenWrt (Chapter 5, Setting Up an Embedded OS), we must use the cross-compiler to compile user-space applications too, since we have no nativecompiler to execute on the boards.

There are several solutions to install a cross-compiler, starting from installing the onesupplied by the used distribution to using a pre-built one. Ubuntu has its own cross-compiler, as shown here, using the following command:

$ apt-cache search gcc-[0-9.]*-armgcc-5-arm-linux-gnueabihf - GNU C compilergcc-5-arm-linux-gnueabihf-base - GCC, the GNU Compiler Collection (base package)gcc-4.7-arm-linux-gnueabi - GNU C compilergcc-4.7-arm-linux-gnueabi-base - GCC, the GNU Compiler Collection (base package)gcc-4.7-arm-linux-gnueabihf - GNU C compilergcc-4.7-arm-linux-gnueabihf-base - GCC, the GNU Compiler Collection (base package)gcc-4.8-arm-linux-gnueabihf - GNU C compilergcc-4.8-arm-linux-gnueabihf-base - GCC, the GNU Compiler Collection (base package)gcc-4.9-arm-linux-gnueabi - GNU C compilergcc-4.9-arm-linux-gnueabi-base - GCC, the GNU Compiler Collection (base package)gcc-4.9-arm-linux-gnueabihf - GNU C compilergcc-4.9-arm-linux-gnueabihf-base - GCC, the GNU Compiler Collection (base package)gcc-5-arm-linux-gnueabi - GNU C compilergcc-5-arm-linux-gnueabi-base - GCC, the GNU Compiler Collection (basepackage)

注意:在本书前言中有详细的下载示例代码的步骤。在 GitHub 上也有:h ttps://github.com/PacktPublishing/GNU-Linux-Rapid-Embedded-Programming/.还有一些代码来自 https://github.com/PacktPublishing/ 上相关的书籍和视频。

然而,为了有一个与发行版无关的资源,我们决定使用一个预先构建的。在可用的资

源中,我们选择了 Linaro 这个项目中已有的工具链(http://www.linaro.org/)。那么,接下来

看看如何安装它。首先,必须使用以下命令下载存档:

Installing the Developing System

[ 34 ]

Downloading the example codeDetailed steps to download the code bundle are mentioned in the Prefaceof this book.The code bundle for the book is also hosted on GitHub at: h t t p s ://g i t h u

b . c o m /P a c k t P u b l i s h i n g /G N U - L i n u x - R a p i d - E m b e d d e d - P r o g r a m m i n g /.We also have other code bundles from our rich catalog of books andvideos available at: h t t p s ://g i t h u b . c o m /P a c k t P u b l i s h i n g /. Check themout!

However in order to have a distro-independent installation, we decide to use a pre-builtone. Looking at the available ones, we chose the toolchain from the Linaro project(http://www.linaro.org/), which is a de-facto standard. So, let's see how to install it.

First of all, we must download the archive using the following command:

$ wget -c https://releases.linaro.org/components/toolchain/binaries/5.3-2016.02/arm-linux-gnueabihf/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf.tar.xz

After the download, we need to extract the code using the following command:

$ tar xf gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf.tar.xz

You can put your new toolchain whenever you wish inside the host'sfilesystem. We put it in the /opt/linaro directory.

Then, we have to set up our environment in order to be able to execute the cross-compilerand other components:

$ export PATH=/opt/linaro/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/bin/:$PATH

You should not forget to replace the installation directory /opt/linarowith your directory!

下载后,需要使用下面的命令解压代码:

Installing the Developing System

[ 34 ]

Downloading the example codeDetailed steps to download the code bundle are mentioned in the Prefaceof this book.The code bundle for the book is also hosted on GitHub at: h t t p s ://g i t h u

b . c o m /P a c k t P u b l i s h i n g /G N U - L i n u x - R a p i d - E m b e d d e d - P r o g r a m m i n g /.We also have other code bundles from our rich catalog of books andvideos available at: h t t p s ://g i t h u b . c o m /P a c k t P u b l i s h i n g /. Check themout!

However in order to have a distro-independent installation, we decide to use a pre-builtone. Looking at the available ones, we chose the toolchain from the Linaro project(http://www.linaro.org/), which is a de-facto standard. So, let's see how to install it.

First of all, we must download the archive using the following command:

$ wget -c https://releases.linaro.org/components/toolchain/binaries/5.3-2016.02/arm-linux-gnueabihf/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf.tar.xz

After the download, we need to extract the code using the following command:

$ tar xf gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf.tar.xz

You can put your new toolchain whenever you wish inside the host'sfilesystem. We put it in the /opt/linaro directory.

Then, we have to set up our environment in order to be able to execute the cross-compilerand other components:

$ export PATH=/opt/linaro/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/bin/:$PATH

You should not forget to replace the installation directory /opt/linarowith your directory!

注意:可以把新工具链放置在主机的文件系统中。这里把它放在 /opt/linaro 这个目

录下。

接下来,必须配置运行环境,以便能够执行交叉编译器和其他组件:

Page 14: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

14   第一部分 基 础 知 识

Installing the Developing System

[ 34 ]

Downloading the example codeDetailed steps to download the code bundle are mentioned in the Prefaceof this book.The code bundle for the book is also hosted on GitHub at: h t t p s ://g i t h u

b . c o m /P a c k t P u b l i s h i n g /G N U - L i n u x - R a p i d - E m b e d d e d - P r o g r a m m i n g /.We also have other code bundles from our rich catalog of books andvideos available at: h t t p s ://g i t h u b . c o m /P a c k t P u b l i s h i n g /. Check themout!

However in order to have a distro-independent installation, we decide to use a pre-builtone. Looking at the available ones, we chose the toolchain from the Linaro project(http://www.linaro.org/), which is a de-facto standard. So, let's see how to install it.

First of all, we must download the archive using the following command:

$ wget -c https://releases.linaro.org/components/toolchain/binaries/5.3-2016.02/arm-linux-gnueabihf/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf.tar.xz

After the download, we need to extract the code using the following command:

$ tar xf gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf.tar.xz

You can put your new toolchain whenever you wish inside the host'sfilesystem. We put it in the /opt/linaro directory.

Then, we have to set up our environment in order to be able to execute the cross-compilerand other components:

$ export PATH=/opt/linaro/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/bin/:$PATH

You should not forget to replace the installation directory /opt/linarowith your directory!

注意:不能忘记用你的目录替换安装目录 /opt/linaro。

现在,可以得到下面的信息:

Installing the Developing System

[ 35 ]

Now, we should get the following lines of code:

$ arm-linux-gnueabihf-gcc --versionarm-linux-gnueabihf-gcc (Linaro GCC 5.3-2016.02) 5.3.1 20160113Copyright (C) 2015 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There isNO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULARPURPOSE.

Each time we log in to our host machine, we have to execute the precedingexport command. To avoid it, we can use the following two lines to the.bashrc file (if we use the Bash shell):

# Setup the cross-compiler export PATH=/opt/linaro/gcc-linaro-5.3-2016.02-x86_ 64_arm-linux-gnueabihf/bin/:$PATH

OK. Now, we're ready to set up our developer kits!

Setting up the BeagleBone BlackLet's start by putting our hands on the first developer kit: the BeagleBone Black. As we cansee, it comes with a pre-loaded Debian system on the on-board eMMC. However, sincewe'd like to have the same OS on all developer kits, let's see how to install a fresh OS on anew microSD and then boot from it.

Serial console for the BeagleBone BlackAs already stated (and as any real programmer of embedded devices knows), the serialconsole is a must-have during the low-level development stages! So, let's see how we canget access to it on our BeagleBone Black.

As shown in the following image, the connector J1 is exposed to the serial console pins. So,using a proper adapter, we can connect it to our host PC. However, since the pins haveelectrical signals at the TTL level, we need an adapter device to do the job, and we haveseveral possibilities.

The first one is a standard RS232-to-TTL converter shown in the following image:

注意:每次登录主机时,必须执行前面的命令。为了避免这种情况,可以使用以下

两行的 .bashrc 脚本(如果使用 bash shell):

Installing the Developing System

[ 35 ]

Now, we should get the following lines of code:

$ arm-linux-gnueabihf-gcc --versionarm-linux-gnueabihf-gcc (Linaro GCC 5.3-2016.02) 5.3.1 20160113Copyright (C) 2015 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There isNO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULARPURPOSE.

Each time we log in to our host machine, we have to execute the precedingexport command. To avoid it, we can use the following two lines to the.bashrc file (if we use the Bash shell):

# Setup the cross-compiler export PATH=/opt/linaro/gcc-linaro-5.3-2016.02-x86_ 64_arm-linux-gnueabihf/bin/:$PATH

OK. Now, we're ready to set up our developer kits!

Setting up the BeagleBone BlackLet's start by putting our hands on the first developer kit: the BeagleBone Black. As we cansee, it comes with a pre-loaded Debian system on the on-board eMMC. However, sincewe'd like to have the same OS on all developer kits, let's see how to install a fresh OS on anew microSD and then boot from it.

Serial console for the BeagleBone BlackAs already stated (and as any real programmer of embedded devices knows), the serialconsole is a must-have during the low-level development stages! So, let's see how we canget access to it on our BeagleBone Black.

As shown in the following image, the connector J1 is exposed to the serial console pins. So,using a proper adapter, we can connect it to our host PC. However, since the pins haveelectrical signals at the TTL level, we need an adapter device to do the job, and we haveseveral possibilities.

The first one is a standard RS232-to-TTL converter shown in the following image:

下面,我们准备设置开发包。

1.3.2 设置 BeagleBone Black 开发平台

从第一个开发平台 BeagleBone Black 开始,可以看到,它在 eMMC 上带有一个预加载

的 Debian 系统存储。但是既然我们要对所有的开发包都使用相同的操作系统,那就来看看

如何在新的 microSD 里面安装一个新的操作系统,然后启动。

1. 串口控制台终端的设置正如已经声明的(任何嵌入式程序员都知道的),串口控制台是初级开发阶段必须具备

的。下面让我们来看看如何在 BeagleBone Black 平台上访问串口控制台。

如下图所示,J1 连接器露出串口控制台引脚。因此,通过一个合适的适配器可以连接

到 PC。但是由于引脚有处于 TTL 电平的电信号,所以我们需要一个适配器设备来做这项工

作,有以下几种:

第一种情况,使用一个标准的 RS232-to-TTL 转换器,如下图所示。

Page 15: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

第1章 开发系统的安装   15

注意:RS232-to-TTL 转换器可以在这里买到:

http://www.cosino.io/product/rs-232-serialw-adapter。

在这种情况下,我们需要拥有一个标准的 PC 转 RS232 端口的 PC 设备,这个不容易找

到,但我们可以很容易地找到一个 RS232-to-USB 适配器来解决这个问题,或作为第二种情

况,我们可以使用一个标准的 USB-to-TTL 线,如下图所示。

该解决方案能使我们使用常见的 USB 端口来做这项工作。

然而,最后的解决方案也存在,它也用到 USB-to-TTL 转换器。但是和之前的解决方案

相比,还有一个在每个智能手机使用的微型 USB 端口,该转换器如下图所示。

注意:该设备可以在该网址购买:http://www.cosino.io/product/usb-to-serial-converter,或其他网站购买。

该装置的数据表可在该网站查看:https://www.silabs.com/Support%20Documents/TechnicalDocs/cp2104.pdf。

不管使用哪种方案,都必须用选定的适配器连接到 J1 连接器以正确捕获电信号。注

意,有关引脚信息在下表中。必须把 GND(接地)引脚与适配器的 GND 连接起来,然后交

换 TxD(发送器)和 RxD(接收器)以正确建立串行连接。

Page 16: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

16   第一部分 基 础 知 识

连接器 功能

引脚 1 GND

引脚 4 TxD

引脚 5 RxD

下图是连接示例:

如果所有连接都正常了,可以通过串口终端仿真器来查看串口的数据。我们将使用

minnicom 工具和命令,如下:

Installing the Developing System

[ 38 ]

Here is the my setup:

If all connections are OK, we can execute any serial terminal emulator to see the data fromthe serial console. We will use the minicom tool, and the command to use it is shown here:

$ minicom -o -D /dev/ttyUSB0

You must now verify that the serial port to be used is /dev/ttyUSB0, and that its setup is115200,8N1 without hardware and software flow control (in minicom, these settings canbe checked using the CTRL+A-O key sequence and then selecting the serial port setup menuentry).

To correctly get access to the serial console, we may need properprivileges. In fact, we may try to execute the preceding minicomcommand, and we don't get an output! This is because the minicomcommand silently exits if we don't have enough privileges to get access tothe port.We can verify our access to privileges by simply using another commandon it as shown here: $ cat /dev/ttyUSB0 cat: /dev/ttyUSB0: Permission denied

首先必须确认串口使用的设备是 /dev/ttyUSB0,波特率为 115200, 数据格式为 8N1,不开启硬件和软件流控制(在 minicom 中,这些设置可以使用 Ctrl+A 键和 O 键,然后选择

串口设置菜单项检查)。

注意:要正确访问串口控制台,可能需要适当的权限。事实上,可以尝试执行之前

已有的命令,却没有输出结果。这是因为,如果我们没有足够的权限来访问端口,

命令就不会执行。

可以通过另一个命令来验证,如下所示:

Installing the Developing System

[ 38 ]

Here is the my setup:

If all connections are OK, we can execute any serial terminal emulator to see the data fromthe serial console. We will use the minicom tool, and the command to use it is shown here:

$ minicom -o -D /dev/ttyUSB0

You must now verify that the serial port to be used is /dev/ttyUSB0, and that its setup is115200,8N1 without hardware and software flow control (in minicom, these settings canbe checked using the CTRL+A-O key sequence and then selecting the serial port setup menuentry).

To correctly get access to the serial console, we may need properprivileges. In fact, we may try to execute the preceding minicomcommand, and we don't get an output! This is because the minicomcommand silently exits if we don't have enough privileges to get access tothe port.We can verify our access to privileges by simply using another commandon it as shown here: $ cat /dev/ttyUSB0 cat: /dev/ttyUSB0: Permission denied

注意:这时,cat 命令完美地告诉我们哪里出问题了,可以通过使用 sudo 命令解决

这个问题,或者加入系统级的用户组。命令如下:

Installing the Developing System

[ 39 ]

In this case, the cat command perfectly tells us what's wrong. In this case,we can fix this issue using the sudo command or, even better, by properlyadding our system's user to the right group as shown here: $ ls -l /dev/ttyUSB0 crw-rw—- 1 root dialout 188, 0 Jan 12 23:06 /dev /ttyUSB0 $ sudo adduser $LOGNAME dialoutoinThen, log out and log in again, and we can access the serial deviceswithout any problem.

The BeagleBone Black should come with a pre-loaded system, so we should see the bootingsequence in the minicom window as soon as we power up the system.

Now, we only need the software to start working with our BeagleBone Black board.

U-Boot (with MLO)First of all, we have to download the sources and select a proper release to compile. Toclone the U-Boot's repository, we can use the following command:

$ git clone https://github.com/u-boot/u-boot

However, instead of using the preceding command, let me suggest that you clone U-Boot'srepository into a dedicated directory in the bare form (we use a directory named common)and then clone the BeagleBone Black's files into another subdirectory by referencing thelocal bare repository to the dedicated one (we use the directory BBB).

To download the bare repository, the commands are as follows:

$ cd common$ git clone --bare https://github.com/u-boot/u-boot

Then, the new commands to get the BeagleBone Black's sources are as follows:

$ cd BBB$ git clone --reference ~/Projects/common/u-boot.git https://github.com/u-boot/u-boot

In this manner, we can save a lot of disk space since we will use the same sources for all ourdeveloper kits.

然后注销并再次登录,之后就可以很顺利地访问串行设备。

Page 17: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

第1章 开发系统的安装   17

BeagleBone Black 应该带有一个预加载的系统,当启动系统时,在 minicom 窗口中就

可以看到引导顺序的加载。

现在,我们只需要软件就可以开始使用 BeagleBone Black 了。

2. U-Boot(基于 MLO)的设置首先,要下载资源,并选择适当的版本来编译。要复制 U-Boot 的库,可以使用下面的

命令:

Installing the Developing System

[ 39 ]

In this case, the cat command perfectly tells us what's wrong. In this case,we can fix this issue using the sudo command or, even better, by properlyadding our system's user to the right group as shown here: $ ls -l /dev/ttyUSB0 crw-rw—- 1 root dialout 188, 0 Jan 12 23:06 /dev /ttyUSB0 $ sudo adduser $LOGNAME dialoutoinThen, log out and log in again, and we can access the serial deviceswithout any problem.

The BeagleBone Black should come with a pre-loaded system, so we should see the bootingsequence in the minicom window as soon as we power up the system.

Now, we only need the software to start working with our BeagleBone Black board.

U-Boot (with MLO)First of all, we have to download the sources and select a proper release to compile. Toclone the U-Boot's repository, we can use the following command:

$ git clone https://github.com/u-boot/u-boot

However, instead of using the preceding command, let me suggest that you clone U-Boot'srepository into a dedicated directory in the bare form (we use a directory named common)and then clone the BeagleBone Black's files into another subdirectory by referencing thelocal bare repository to the dedicated one (we use the directory BBB).

To download the bare repository, the commands are as follows:

$ cd common$ git clone --bare https://github.com/u-boot/u-boot

Then, the new commands to get the BeagleBone Black's sources are as follows:

$ cd BBB$ git clone --reference ~/Projects/common/u-boot.git https://github.com/u-boot/u-boot

In this manner, we can save a lot of disk space since we will use the same sources for all ourdeveloper kits.

然而,除了使用上面的命令之外,建议将复制的 U-Boot 的库存放在一个空文件夹里

(我们用 common 这个目录),然后把 BeagleBone Black 的文件存放到本地的另一个目录中

(我们用 BBB 这个目录)。

下载库,命令如下:

Installing the Developing System

[ 39 ]

In this case, the cat command perfectly tells us what's wrong. In this case,we can fix this issue using the sudo command or, even better, by properlyadding our system's user to the right group as shown here: $ ls -l /dev/ttyUSB0 crw-rw—- 1 root dialout 188, 0 Jan 12 23:06 /dev /ttyUSB0 $ sudo adduser $LOGNAME dialoutoinThen, log out and log in again, and we can access the serial deviceswithout any problem.

The BeagleBone Black should come with a pre-loaded system, so we should see the bootingsequence in the minicom window as soon as we power up the system.

Now, we only need the software to start working with our BeagleBone Black board.

U-Boot (with MLO)First of all, we have to download the sources and select a proper release to compile. Toclone the U-Boot's repository, we can use the following command:

$ git clone https://github.com/u-boot/u-boot

However, instead of using the preceding command, let me suggest that you clone U-Boot'srepository into a dedicated directory in the bare form (we use a directory named common)and then clone the BeagleBone Black's files into another subdirectory by referencing thelocal bare repository to the dedicated one (we use the directory BBB).

To download the bare repository, the commands are as follows:

$ cd common$ git clone --bare https://github.com/u-boot/u-boot

Then, the new commands to get the BeagleBone Black's sources are as follows:

$ cd BBB$ git clone --reference ~/Projects/common/u-boot.git https://github.com/u-boot/u-boot

In this manner, we can save a lot of disk space since we will use the same sources for all ourdeveloper kits.

然后,获取 BeagleBone Black 的资源,命令如下:

Installing the Developing System

[ 39 ]

In this case, the cat command perfectly tells us what's wrong. In this case,we can fix this issue using the sudo command or, even better, by properlyadding our system's user to the right group as shown here: $ ls -l /dev/ttyUSB0 crw-rw—- 1 root dialout 188, 0 Jan 12 23:06 /dev /ttyUSB0 $ sudo adduser $LOGNAME dialoutoinThen, log out and log in again, and we can access the serial deviceswithout any problem.

The BeagleBone Black should come with a pre-loaded system, so we should see the bootingsequence in the minicom window as soon as we power up the system.

Now, we only need the software to start working with our BeagleBone Black board.

U-Boot (with MLO)First of all, we have to download the sources and select a proper release to compile. Toclone the U-Boot's repository, we can use the following command:

$ git clone https://github.com/u-boot/u-boot

However, instead of using the preceding command, let me suggest that you clone U-Boot'srepository into a dedicated directory in the bare form (we use a directory named common)and then clone the BeagleBone Black's files into another subdirectory by referencing thelocal bare repository to the dedicated one (we use the directory BBB).

To download the bare repository, the commands are as follows:

$ cd common$ git clone --bare https://github.com/u-boot/u-boot

Then, the new commands to get the BeagleBone Black's sources are as follows:

$ cd BBB$ git clone --reference ~/Projects/common/u-boot.git https://github.com/u-boot/u-boot

In this manner, we can save a lot of disk space since we will use the same sources for all ourdeveloper kits.

用这种方式,可以节省大量的磁盘空间,因为所有的开发者使用的都是相同的资源。

现在,进入新创建的文件夹,查看 U-Boot 的版本:

Installing the Developing System

[ 40 ]

Now, let's go into the newly created directory and check out a proper U-Boot release:

$ cd u-boot$ git checkout v2016.03 -b v2016.03

Now, we need some patches to properly support the BeagleBone Black, and we can get andinstall them using the following commands:

$ wget -c https://rcn-ee.com/repos/git/u-boot-patches/v2016.03/0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch$ patch -p1 < 0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch

Now, we're ready to compile. Let's do it with the following commands:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- am335x_evm_defconfig$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

Now, it's time to install the bootloader into the microSD, and to do this, we have plug a newmicroSD into our host PC. Then, we have to erase the current partition table and install anew one.

Note that the microSD should be a class 10 and at least of 4GB size.

However, we first have to discover the microSD associated device. There exist several waysto do it. We usually use the dmesg command after we have plugged in the microSD into myhost machine so that we see the following kernel messages:

Attached scsi generic sg3 type 0[sdd] 7774208 512-byte logical blocks: (3.98 GB/3.71 GiB)[sdd] Write Protect is off[sdd] Mode Sense: 0b 00 00 08[sdd] No Caching mode page found[sdd] Assuming drive cache: write through sdd: sdd1[sdd] Attached SCSI removable disk

现在,需要一些补丁来支持 BeagleBone Black,可以使用下面的命令安装:

Installing the Developing System

[ 40 ]

Now, let's go into the newly created directory and check out a proper U-Boot release:

$ cd u-boot$ git checkout v2016.03 -b v2016.03

Now, we need some patches to properly support the BeagleBone Black, and we can get andinstall them using the following commands:

$ wget -c https://rcn-ee.com/repos/git/u-boot-patches/v2016.03/0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch$ patch -p1 < 0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch

Now, we're ready to compile. Let's do it with the following commands:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- am335x_evm_defconfig$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

Now, it's time to install the bootloader into the microSD, and to do this, we have plug a newmicroSD into our host PC. Then, we have to erase the current partition table and install anew one.

Note that the microSD should be a class 10 and at least of 4GB size.

However, we first have to discover the microSD associated device. There exist several waysto do it. We usually use the dmesg command after we have plugged in the microSD into myhost machine so that we see the following kernel messages:

Attached scsi generic sg3 type 0[sdd] 7774208 512-byte logical blocks: (3.98 GB/3.71 GiB)[sdd] Write Protect is off[sdd] Mode Sense: 0b 00 00 08[sdd] No Caching mode page found[sdd] Assuming drive cache: write through sdd: sdd1[sdd] Attached SCSI removable disk

现在,我们准备编译。用下面的命令:

Installing the Developing System

[ 40 ]

Now, let's go into the newly created directory and check out a proper U-Boot release:

$ cd u-boot$ git checkout v2016.03 -b v2016.03

Now, we need some patches to properly support the BeagleBone Black, and we can get andinstall them using the following commands:

$ wget -c https://rcn-ee.com/repos/git/u-boot-patches/v2016.03/0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch$ patch -p1 < 0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch

Now, we're ready to compile. Let's do it with the following commands:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- am335x_evm_defconfig$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

Now, it's time to install the bootloader into the microSD, and to do this, we have plug a newmicroSD into our host PC. Then, we have to erase the current partition table and install anew one.

Note that the microSD should be a class 10 and at least of 4GB size.

However, we first have to discover the microSD associated device. There exist several waysto do it. We usually use the dmesg command after we have plugged in the microSD into myhost machine so that we see the following kernel messages:

Attached scsi generic sg3 type 0[sdd] 7774208 512-byte logical blocks: (3.98 GB/3.71 GiB)[sdd] Write Protect is off[sdd] Mode Sense: 0b 00 00 08[sdd] No Caching mode page found[sdd] Assuming drive cache: write through sdd: sdd1[sdd] Attached SCSI removable disk

现在,是时候将 bootloader 安装到 microSD 中了,要做到这一点,要插一个新的

microSD 卡到主机中。然后,要删除当前分区并且新建一个分区。

提示:注意 microSD 的类型必须是 class10(容量 4G 以上)。

但是,首先要找到与 microSD 相关的设备。有多种方法可以检查。通常把 microSD 插

到主机后,用 dmesg 命令可以看到内核消息,如下:

Page 18: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

18   第一部分 基 础 知 识

Installing the Developing System

[ 40 ]

Now, let's go into the newly created directory and check out a proper U-Boot release:

$ cd u-boot$ git checkout v2016.03 -b v2016.03

Now, we need some patches to properly support the BeagleBone Black, and we can get andinstall them using the following commands:

$ wget -c https://rcn-ee.com/repos/git/u-boot-patches/v2016.03/0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch$ patch -p1 < 0001-am335x_evm-uEnv.txt-bootz-n-fixes.patch

Now, we're ready to compile. Let's do it with the following commands:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- am335x_evm_defconfig$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

Now, it's time to install the bootloader into the microSD, and to do this, we have plug a newmicroSD into our host PC. Then, we have to erase the current partition table and install anew one.

Note that the microSD should be a class 10 and at least of 4GB size.

However, we first have to discover the microSD associated device. There exist several waysto do it. We usually use the dmesg command after we have plugged in the microSD into myhost machine so that we see the following kernel messages:

Attached scsi generic sg3 type 0[sdd] 7774208 512-byte logical blocks: (3.98 GB/3.71 GiB)[sdd] Write Protect is off[sdd] Mode Sense: 0b 00 00 08[sdd] No Caching mode page found[sdd] Assuming drive cache: write through sdd: sdd1[sdd] Attached SCSI removable disk

这种方式,可以知道,在系统中,microSD 与 /dev/sdd 这个设备相关联。

提示:请注意,我们的配置可能会有所不同。事实上,你可能会发现正确使用的设

备是 /dev/sdb、/dev/sdc、/dev/sde,甚至设备 /dev/mmcblk0。最后一种情况意味着

PC 使用 MMC 设备代替了使用 USB 适配器管理 SD 或 microSD 插槽。在这种特殊

情况下,内核消息会如下:

Installing the Developing System

[ 41 ]

In this way, we know that on our system, the microSD is associated with the device/dev/sdd.

Note that our configuration may vary. In fact, you may discover that theright device to use is /dev/sdb, /dev/sdc or /dev/sde or even a devicenamed /dev/mmcblk0! This last case means that the host PC is using anMMC device instead of a USB adapter to manage its SD or microSD slot.In this special situation, the kernel messages look like this: mmc0: cannot verify signal voltage switch mmc0: new ultra high speed SDR50 SDHC card at address 0007 mmcblk0: mmc0:0007 SD4GB 3.70 GiB mmcblk0: p1

However, we can also use the lsblk command that nicely lists all the currently attachedblock devices into the system as show here:

$ lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTsda 8:0 0 465.8G 0 disk+-sda1 8:1 0 21.5G 0 part+-sda2 8:2 0 116.4G 0 part+-sda3 8:3 0 1K 0 part\-sda5 8:5 0 327.9G 0 part /optsdb 8:16 0 931.5G 0 disk\-sdb1 8:17 0 931.5G 0 part /homesdc 8:32 0 223.6G 0 disk\-sdc1 8:33 0 223.6G 0 part /sdd 8:48 1 3.7G 0 disk\-sdd1 8:49 1 3.7G 0 part

Now, we can clear the current partition table using the following command:

$ sudo dd if=/dev/zero of=/dev/sdX bs=1M count=10

This is a very important step!The reader should not forget to replace device /dev/sdX with the deviceassociated with the microSD plugged into their system and follow the nextsteps carefully or they may damage the host system!

也可以使用 lsblk 命令,它会进入系统并且列出所有当前块设备,如下所示:

Installing the Developing System

[ 41 ]

In this way, we know that on our system, the microSD is associated with the device/dev/sdd.

Note that our configuration may vary. In fact, you may discover that theright device to use is /dev/sdb, /dev/sdc or /dev/sde or even a devicenamed /dev/mmcblk0! This last case means that the host PC is using anMMC device instead of a USB adapter to manage its SD or microSD slot.In this special situation, the kernel messages look like this: mmc0: cannot verify signal voltage switch mmc0: new ultra high speed SDR50 SDHC card at address 0007 mmcblk0: mmc0:0007 SD4GB 3.70 GiB mmcblk0: p1

However, we can also use the lsblk command that nicely lists all the currently attachedblock devices into the system as show here:

$ lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTsda 8:0 0 465.8G 0 disk+-sda1 8:1 0 21.5G 0 part+-sda2 8:2 0 116.4G 0 part+-sda3 8:3 0 1K 0 part\-sda5 8:5 0 327.9G 0 part /optsdb 8:16 0 931.5G 0 disk\-sdb1 8:17 0 931.5G 0 part /homesdc 8:32 0 223.6G 0 disk\-sdc1 8:33 0 223.6G 0 part /sdd 8:48 1 3.7G 0 disk\-sdd1 8:49 1 3.7G 0 part

Now, we can clear the current partition table using the following command:

$ sudo dd if=/dev/zero of=/dev/sdX bs=1M count=10

This is a very important step!The reader should not forget to replace device /dev/sdX with the deviceassociated with the microSD plugged into their system and follow the nextsteps carefully or they may damage the host system!

Installing the Developing System

[ 41 ]

In this way, we know that on our system, the microSD is associated with the device/dev/sdd.

Note that our configuration may vary. In fact, you may discover that theright device to use is /dev/sdb, /dev/sdc or /dev/sde or even a devicenamed /dev/mmcblk0! This last case means that the host PC is using anMMC device instead of a USB adapter to manage its SD or microSD slot.In this special situation, the kernel messages look like this: mmc0: cannot verify signal voltage switch mmc0: new ultra high speed SDR50 SDHC card at address 0007 mmcblk0: mmc0:0007 SD4GB 3.70 GiB mmcblk0: p1

However, we can also use the lsblk command that nicely lists all the currently attachedblock devices into the system as show here:

$ lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTsda 8:0 0 465.8G 0 disk+-sda1 8:1 0 21.5G 0 part+-sda2 8:2 0 116.4G 0 part+-sda3 8:3 0 1K 0 part\-sda5 8:5 0 327.9G 0 part /optsdb 8:16 0 931.5G 0 disk\-sdb1 8:17 0 931.5G 0 part /homesdc 8:32 0 223.6G 0 disk\-sdc1 8:33 0 223.6G 0 part /sdd 8:48 1 3.7G 0 disk\-sdd1 8:49 1 3.7G 0 part

Now, we can clear the current partition table using the following command:

$ sudo dd if=/dev/zero of=/dev/sdX bs=1M count=10

This is a very important step!The reader should not forget to replace device /dev/sdX with the deviceassociated with the microSD plugged into their system and follow the nextsteps carefully or they may damage the host system!

现在,可以使用以下命令清除当前分区表:

Installing the Developing System

[ 41 ]

In this way, we know that on our system, the microSD is associated with the device/dev/sdd.

Note that our configuration may vary. In fact, you may discover that theright device to use is /dev/sdb, /dev/sdc or /dev/sde or even a devicenamed /dev/mmcblk0! This last case means that the host PC is using anMMC device instead of a USB adapter to manage its SD or microSD slot.In this special situation, the kernel messages look like this: mmc0: cannot verify signal voltage switch mmc0: new ultra high speed SDR50 SDHC card at address 0007 mmcblk0: mmc0:0007 SD4GB 3.70 GiB mmcblk0: p1

However, we can also use the lsblk command that nicely lists all the currently attachedblock devices into the system as show here:

$ lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTsda 8:0 0 465.8G 0 disk+-sda1 8:1 0 21.5G 0 part+-sda2 8:2 0 116.4G 0 part+-sda3 8:3 0 1K 0 part\-sda5 8:5 0 327.9G 0 part /optsdb 8:16 0 931.5G 0 disk\-sdb1 8:17 0 931.5G 0 part /homesdc 8:32 0 223.6G 0 disk\-sdc1 8:33 0 223.6G 0 part /sdd 8:48 1 3.7G 0 disk\-sdd1 8:49 1 3.7G 0 part

Now, we can clear the current partition table using the following command:

$ sudo dd if=/dev/zero of=/dev/sdX bs=1M count=10

This is a very important step!The reader should not forget to replace device /dev/sdX with the deviceassociated with the microSD plugged into their system and follow the nextsteps carefully or they may damage the host system!

注意:这一步非常重要。开发者一定记住要把 microSD 卡插入系统,然后按照下面

的步骤进行,否则可能会损坏主机系统。

接着,安装新编译的 bootloader:

Installing the Developing System

[ 42 ]

Then, we can install the newly compiled bootloaders:

$ sudo dd if=MLO of=/dev/sdX count=1 seek=1 bs=128k$ sudo dd if=u-boot.img of=/dev/sdX count=2 seek=1 bs=384k

Now, we can prepare the needed partition for the root filesystem, which will be installed inthe upcoming sections. Here are the commands:

$ echo '1M,,L,*' | sudo sfdisk /dev/sdX$ sudo mkfs.ext4 -L rootfs /dev/sdX1

Since in mkfs.ext4 version 1.43, the options metadata_csum and 64bitare enabled by default. However, we need to make sure that they aredisabled; otherwise, U-Boot cannot boot from our ext4 partitions. If this isour case, we need to replace the preceding command with the followingone:

$ sudo mkfs.ext4 -L rootfs -O ^metadata_csum,^64bit /dev/sdX1

In order to get the current version of mkfs.ext4, we can use thecommand with the -V option argument.

Then, mount the newly created partition and copy the bootloaders in it (these will be usedsoon). Here are the commands:

$ sudo mkdir /media/rootfs$ sudo mount /dev/sdX1 /media/rootfs/$ sudo mkdir -p /media/rootfs/opt/backup/uboot/$ sudo cp MLO /media/rootfs/opt/backup/uboot/$ sudo cp u-boot.img /media/rootfs/opt/backup/uboot/

Now, we have just to add U-Boot's environment commands to properly load the kernel. Wehave to put all commands into a file called uEnv.txt in rootfs as follows:

$ sudo mkdir /media/rootfs/boot/$ sudo cp uEnv.txt /media/rootfs/boot/

The content of the uEnv.txt file is reported here:

loadaddr=0x82000000fdtaddr=0x88000000rdaddr=0x88080000

initrd_high=0xfffffffffdt_high=0xffffffff

现在,要为根文件系统准备所需的分区然后安装。这里是命令:

Installing the Developing System

[ 42 ]

Then, we can install the newly compiled bootloaders:

$ sudo dd if=MLO of=/dev/sdX count=1 seek=1 bs=128k$ sudo dd if=u-boot.img of=/dev/sdX count=2 seek=1 bs=384k

Now, we can prepare the needed partition for the root filesystem, which will be installed inthe upcoming sections. Here are the commands:

$ echo '1M,,L,*' | sudo sfdisk /dev/sdX$ sudo mkfs.ext4 -L rootfs /dev/sdX1

Since in mkfs.ext4 version 1.43, the options metadata_csum and 64bitare enabled by default. However, we need to make sure that they aredisabled; otherwise, U-Boot cannot boot from our ext4 partitions. If this isour case, we need to replace the preceding command with the followingone:

$ sudo mkfs.ext4 -L rootfs -O ^metadata_csum,^64bit /dev/sdX1

In order to get the current version of mkfs.ext4, we can use thecommand with the -V option argument.

Then, mount the newly created partition and copy the bootloaders in it (these will be usedsoon). Here are the commands:

$ sudo mkdir /media/rootfs$ sudo mount /dev/sdX1 /media/rootfs/$ sudo mkdir -p /media/rootfs/opt/backup/uboot/$ sudo cp MLO /media/rootfs/opt/backup/uboot/$ sudo cp u-boot.img /media/rootfs/opt/backup/uboot/

Now, we have just to add U-Boot's environment commands to properly load the kernel. Wehave to put all commands into a file called uEnv.txt in rootfs as follows:

$ sudo mkdir /media/rootfs/boot/$ sudo cp uEnv.txt /media/rootfs/boot/

The content of the uEnv.txt file is reported here:

loadaddr=0x82000000fdtaddr=0x88000000rdaddr=0x88080000

initrd_high=0xfffffffffdt_high=0xffffffff

Page 19: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

第1章 开发系统的安装   19

注意:因为在 mkfs.ext4 1.43 版本中,选项 metadata_csum 和 64bit 是默认开启的。

然而,需要确保它们被禁用;否则 U-Boot 就不能从 ext4 的分区中启动。如果是这

种情况,就需要用下面的命令替换前面的命令:

Installing the Developing System

[ 42 ]

Then, we can install the newly compiled bootloaders:

$ sudo dd if=MLO of=/dev/sdX count=1 seek=1 bs=128k$ sudo dd if=u-boot.img of=/dev/sdX count=2 seek=1 bs=384k

Now, we can prepare the needed partition for the root filesystem, which will be installed inthe upcoming sections. Here are the commands:

$ echo '1M,,L,*' | sudo sfdisk /dev/sdX$ sudo mkfs.ext4 -L rootfs /dev/sdX1

Since in mkfs.ext4 version 1.43, the options metadata_csum and 64bitare enabled by default. However, we need to make sure that they aredisabled; otherwise, U-Boot cannot boot from our ext4 partitions. If this isour case, we need to replace the preceding command with the followingone:

$ sudo mkfs.ext4 -L rootfs -O ^metadata_csum,^64bit /dev/sdX1

In order to get the current version of mkfs.ext4, we can use thecommand with the -V option argument.

Then, mount the newly created partition and copy the bootloaders in it (these will be usedsoon). Here are the commands:

$ sudo mkdir /media/rootfs$ sudo mount /dev/sdX1 /media/rootfs/$ sudo mkdir -p /media/rootfs/opt/backup/uboot/$ sudo cp MLO /media/rootfs/opt/backup/uboot/$ sudo cp u-boot.img /media/rootfs/opt/backup/uboot/

Now, we have just to add U-Boot's environment commands to properly load the kernel. Wehave to put all commands into a file called uEnv.txt in rootfs as follows:

$ sudo mkdir /media/rootfs/boot/$ sudo cp uEnv.txt /media/rootfs/boot/

The content of the uEnv.txt file is reported here:

loadaddr=0x82000000fdtaddr=0x88000000rdaddr=0x88080000

initrd_high=0xfffffffffdt_high=0xffffffff

为了得到 mkfs.ext4 当前的版本,可以在命令后面加上 -V 选项参数。

然后,挂载新创建的分区,然后把 bootloader 复制到里面。这里是命令:

Installing the Developing System

[ 42 ]

Then, we can install the newly compiled bootloaders:

$ sudo dd if=MLO of=/dev/sdX count=1 seek=1 bs=128k$ sudo dd if=u-boot.img of=/dev/sdX count=2 seek=1 bs=384k

Now, we can prepare the needed partition for the root filesystem, which will be installed inthe upcoming sections. Here are the commands:

$ echo '1M,,L,*' | sudo sfdisk /dev/sdX$ sudo mkfs.ext4 -L rootfs /dev/sdX1

Since in mkfs.ext4 version 1.43, the options metadata_csum and 64bitare enabled by default. However, we need to make sure that they aredisabled; otherwise, U-Boot cannot boot from our ext4 partitions. If this isour case, we need to replace the preceding command with the followingone:

$ sudo mkfs.ext4 -L rootfs -O ^metadata_csum,^64bit /dev/sdX1

In order to get the current version of mkfs.ext4, we can use thecommand with the -V option argument.

Then, mount the newly created partition and copy the bootloaders in it (these will be usedsoon). Here are the commands:

$ sudo mkdir /media/rootfs$ sudo mount /dev/sdX1 /media/rootfs/$ sudo mkdir -p /media/rootfs/opt/backup/uboot/$ sudo cp MLO /media/rootfs/opt/backup/uboot/$ sudo cp u-boot.img /media/rootfs/opt/backup/uboot/

Now, we have just to add U-Boot's environment commands to properly load the kernel. Wehave to put all commands into a file called uEnv.txt in rootfs as follows:

$ sudo mkdir /media/rootfs/boot/$ sudo cp uEnv.txt /media/rootfs/boot/

The content of the uEnv.txt file is reported here:

loadaddr=0x82000000fdtaddr=0x88000000rdaddr=0x88080000

initrd_high=0xfffffffffdt_high=0xffffffff

现在,只添加 U-Boot 的环境命令来正确地加载内核。必须把所有的命令放在 rootfs 的

uenv.txt 这个文件里,如下:

Installing the Developing System

[ 42 ]

Then, we can install the newly compiled bootloaders:

$ sudo dd if=MLO of=/dev/sdX count=1 seek=1 bs=128k$ sudo dd if=u-boot.img of=/dev/sdX count=2 seek=1 bs=384k

Now, we can prepare the needed partition for the root filesystem, which will be installed inthe upcoming sections. Here are the commands:

$ echo '1M,,L,*' | sudo sfdisk /dev/sdX$ sudo mkfs.ext4 -L rootfs /dev/sdX1

Since in mkfs.ext4 version 1.43, the options metadata_csum and 64bitare enabled by default. However, we need to make sure that they aredisabled; otherwise, U-Boot cannot boot from our ext4 partitions. If this isour case, we need to replace the preceding command with the followingone:

$ sudo mkfs.ext4 -L rootfs -O ^metadata_csum,^64bit /dev/sdX1

In order to get the current version of mkfs.ext4, we can use thecommand with the -V option argument.

Then, mount the newly created partition and copy the bootloaders in it (these will be usedsoon). Here are the commands:

$ sudo mkdir /media/rootfs$ sudo mount /dev/sdX1 /media/rootfs/$ sudo mkdir -p /media/rootfs/opt/backup/uboot/$ sudo cp MLO /media/rootfs/opt/backup/uboot/$ sudo cp u-boot.img /media/rootfs/opt/backup/uboot/

Now, we have just to add U-Boot's environment commands to properly load the kernel. Wehave to put all commands into a file called uEnv.txt in rootfs as follows:

$ sudo mkdir /media/rootfs/boot/$ sudo cp uEnv.txt /media/rootfs/boot/

The content of the uEnv.txt file is reported here:

loadaddr=0x82000000fdtaddr=0x88000000rdaddr=0x88080000

initrd_high=0xfffffffffdt_high=0xffffffff

uEnv.txt 文件的内容如下:

Installing the Developing System

[ 42 ]

Then, we can install the newly compiled bootloaders:

$ sudo dd if=MLO of=/dev/sdX count=1 seek=1 bs=128k$ sudo dd if=u-boot.img of=/dev/sdX count=2 seek=1 bs=384k

Now, we can prepare the needed partition for the root filesystem, which will be installed inthe upcoming sections. Here are the commands:

$ echo '1M,,L,*' | sudo sfdisk /dev/sdX$ sudo mkfs.ext4 -L rootfs /dev/sdX1

Since in mkfs.ext4 version 1.43, the options metadata_csum and 64bitare enabled by default. However, we need to make sure that they aredisabled; otherwise, U-Boot cannot boot from our ext4 partitions. If this isour case, we need to replace the preceding command with the followingone:

$ sudo mkfs.ext4 -L rootfs -O ^metadata_csum,^64bit /dev/sdX1

In order to get the current version of mkfs.ext4, we can use thecommand with the -V option argument.

Then, mount the newly created partition and copy the bootloaders in it (these will be usedsoon). Here are the commands:

$ sudo mkdir /media/rootfs$ sudo mount /dev/sdX1 /media/rootfs/$ sudo mkdir -p /media/rootfs/opt/backup/uboot/$ sudo cp MLO /media/rootfs/opt/backup/uboot/$ sudo cp u-boot.img /media/rootfs/opt/backup/uboot/

Now, we have just to add U-Boot's environment commands to properly load the kernel. Wehave to put all commands into a file called uEnv.txt in rootfs as follows:

$ sudo mkdir /media/rootfs/boot/$ sudo cp uEnv.txt /media/rootfs/boot/

The content of the uEnv.txt file is reported here:

loadaddr=0x82000000fdtaddr=0x88000000rdaddr=0x88080000

initrd_high=0xfffffffffdt_high=0xffffffff

Installing the Developing System

[ 43 ]

mmcroot=/dev/mmcblk0p1

loadximage=load mmc 0:1 ${loadaddr} /boot/vmlinuz-${uname_r}loadxfdt=load mmc 0:1 ${fdtaddr} /boot/dtbs/${uname_r}/${fdtfile}loadxrd=load mmc 0:1 ${rdaddr} /boot/initrd.img-${uname_r}; setenv rdsize ${filesize}loaduEnvtxt=load mmc 0:1 ${loadaddr} /boot/uEnv.txt ; env import -t ${loadaddr} ${filesize};loadall=run loaduEnvtxt; run loadximage; run loadxfdt;mmcargs=setenv bootargs console=tty0 console=${console} ${optargs} ${cape_disable} ${cape_enable} root=${mmcroot} rootfstype=${mmcrootfstype} ${cmdline}

uenvcmd=run loadall; run mmcargs; bootz ${loadaddr} - ${fdtaddr};

The preceding text can be found in the chapter_01/BBB-uEnv.txt filein the book's example code repository.

Now, it's time to compile the kernel.

Linux kernel for the BeagleBone BlackThe kernel sources can be downloaded from the several repositories, and we decided to usethe ones from Robert C. Nelson archives instead of the standard Debian repositoriesbecause these repositories are really well done, easy to use, and well supported in terms ofcustom kernel sources for our embedded kits!

The command is here:

$ git clone https://github.com/RobertCNelson/bb-kernel

Then, we have to enter into the newly created directory and choose which version of the kernel we wish to use. There are several choices, and I decided to use the kernel version 4.4(no specific reasons for that, it's just the release in the middle and you can choose whateverbetter fits your needs). So, we used the commands here:

$ cd bb-kernel$ git checkout origin/am33x-v4.4 -b am33x-v4.4

注意:前面的文本可以在本书附带的 chapter_01/BBB-uEnv.txt 这个文件中找到。

现在是时候编译内核了。

3. Linux 内核的设置内核源代码可以从很多库中下载,我们决定使用 Robert C. Nelson 的库而不是标准的

Page 20: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

20   第一部分 基 础 知 识

Debian 库,因为这些库都做得非常好,简单易用,而且就内核而言很好地支持了嵌入式

套件。

命令如下:

Installing the Developing System

[ 43 ]

mmcroot=/dev/mmcblk0p1

loadximage=load mmc 0:1 ${loadaddr} /boot/vmlinuz-${uname_r}loadxfdt=load mmc 0:1 ${fdtaddr} /boot/dtbs/${uname_r}/${fdtfile}loadxrd=load mmc 0:1 ${rdaddr} /boot/initrd.img-${uname_r}; setenv rdsize ${filesize}loaduEnvtxt=load mmc 0:1 ${loadaddr} /boot/uEnv.txt ; env import -t ${loadaddr} ${filesize};loadall=run loaduEnvtxt; run loadximage; run loadxfdt;mmcargs=setenv bootargs console=tty0 console=${console} ${optargs} ${cape_disable} ${cape_enable} root=${mmcroot} rootfstype=${mmcrootfstype} ${cmdline}

uenvcmd=run loadall; run mmcargs; bootz ${loadaddr} - ${fdtaddr};

The preceding text can be found in the chapter_01/BBB-uEnv.txt filein the book's example code repository.

Now, it's time to compile the kernel.

Linux kernel for the BeagleBone BlackThe kernel sources can be downloaded from the several repositories, and we decided to usethe ones from Robert C. Nelson archives instead of the standard Debian repositoriesbecause these repositories are really well done, easy to use, and well supported in terms ofcustom kernel sources for our embedded kits!

The command is here:

$ git clone https://github.com/RobertCNelson/bb-kernel

Then, we have to enter into the newly created directory and choose which version of the kernel we wish to use. There are several choices, and I decided to use the kernel version 4.4(no specific reasons for that, it's just the release in the middle and you can choose whateverbetter fits your needs). So, we used the commands here:

$ cd bb-kernel$ git checkout origin/am33x-v4.4 -b am33x-v4.4

然后,必须进入新创建的目录,并选择要用的内核版本。有多个版本,我们决定使用

4.4 内核版本(没有为什么,这个版本比较稳定,你也可以选择其他更适合你的版本)。 命令如下:

Installing the Developing System

[ 43 ]

mmcroot=/dev/mmcblk0p1

loadximage=load mmc 0:1 ${loadaddr} /boot/vmlinuz-${uname_r}loadxfdt=load mmc 0:1 ${fdtaddr} /boot/dtbs/${uname_r}/${fdtfile}loadxrd=load mmc 0:1 ${rdaddr} /boot/initrd.img-${uname_r}; setenv rdsize ${filesize}loaduEnvtxt=load mmc 0:1 ${loadaddr} /boot/uEnv.txt ; env import -t ${loadaddr} ${filesize};loadall=run loaduEnvtxt; run loadximage; run loadxfdt;mmcargs=setenv bootargs console=tty0 console=${console} ${optargs} ${cape_disable} ${cape_enable} root=${mmcroot} rootfstype=${mmcrootfstype} ${cmdline}

uenvcmd=run loadall; run mmcargs; bootz ${loadaddr} - ${fdtaddr};

The preceding text can be found in the chapter_01/BBB-uEnv.txt filein the book's example code repository.

Now, it's time to compile the kernel.

Linux kernel for the BeagleBone BlackThe kernel sources can be downloaded from the several repositories, and we decided to usethe ones from Robert C. Nelson archives instead of the standard Debian repositoriesbecause these repositories are really well done, easy to use, and well supported in terms ofcustom kernel sources for our embedded kits!

The command is here:

$ git clone https://github.com/RobertCNelson/bb-kernel

Then, we have to enter into the newly created directory and choose which version of the kernel we wish to use. There are several choices, and I decided to use the kernel version 4.4(no specific reasons for that, it's just the release in the middle and you can choose whateverbetter fits your needs). So, we used the commands here:

$ cd bb-kernel$ git checkout origin/am33x-v4.4 -b am33x-v4.4

在继续之前,可以做一些类似于我们在 U-Boot 中执行的操作,然后把 Linux 裸库从

Linux-stable 树预加载到 common 这个文件夹中。

Installing the Developing System

[ 44 ]

Now, before continuing, we can do something similar to what we did for U-Boot and thenpre-download a Linux bare repository from the linux-stable tree into the commondirectory with the following command:

$ cd common$ git clone --bare https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git

Then, we have to do a little trick to transform the just downloaded data in a form suitablefor the build_kernel.sh script we've to use here:

$ mkdir linux-stable$ mv linux-stable.git/ linux-stable/.git$ cd linux-stable$ git config --local --bool core.bare false

In this manner, we converted a bare repository into a normal one, but without checking outany file and saving a lot of disk space!

Now, by properly setting the LINUX_GIT variable into the system.sh file, we can referencethe just downloaded repository. The system.sh file can be easily obtained fromsystem.sh.sample as follows:

$ cp system.sh.sample system.sh

Then, we need to properly set the LINUX_GIT and the CC variables (to specify the cross-compiler to be used) as reported in the following patch:

--- system.sh.sample 2016-04-15 18:04:18.178681406 +0200+++ system.sh 2016-04-18 17:40:11.229958465 +0200@@ -16,12 +16,14 @@ #CC=<enter full path>/bin/arm-none-eabi- #CC=<enter full path>/bin/arm-linux-gnueabi- #CC=<enter full path>/bin/arm-linux-gnueabihf-+CC=arm-linux-gnueabihf- ###OPTIONAL: ###OPTIONAL: LINUX_GIT: specify location of locally cloned git tree. # #LINUX_GIT=/home/user/linux-stable/+LINUX_GIT=~/Projects/common/linux-stable ###OPTIONAL: MMC: (REQUIRED FOR RUNNING: tools/install_kernel.sh) #Note: This operates on raw disks, NOT PARTITIONS..

然后,执行一个小操作,以便于把刚刚下载的数据转换为适合 build_kernel.sh 这个脚

本的形式,命令如下 :

Installing the Developing System

[ 44 ]

Now, before continuing, we can do something similar to what we did for U-Boot and thenpre-download a Linux bare repository from the linux-stable tree into the commondirectory with the following command:

$ cd common$ git clone --bare https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git

Then, we have to do a little trick to transform the just downloaded data in a form suitablefor the build_kernel.sh script we've to use here:

$ mkdir linux-stable$ mv linux-stable.git/ linux-stable/.git$ cd linux-stable$ git config --local --bool core.bare false

In this manner, we converted a bare repository into a normal one, but without checking outany file and saving a lot of disk space!

Now, by properly setting the LINUX_GIT variable into the system.sh file, we can referencethe just downloaded repository. The system.sh file can be easily obtained fromsystem.sh.sample as follows:

$ cp system.sh.sample system.sh

Then, we need to properly set the LINUX_GIT and the CC variables (to specify the cross-compiler to be used) as reported in the following patch:

--- system.sh.sample 2016-04-15 18:04:18.178681406 +0200+++ system.sh 2016-04-18 17:40:11.229958465 +0200@@ -16,12 +16,14 @@ #CC=<enter full path>/bin/arm-none-eabi- #CC=<enter full path>/bin/arm-linux-gnueabi- #CC=<enter full path>/bin/arm-linux-gnueabihf-+CC=arm-linux-gnueabihf- ###OPTIONAL: ###OPTIONAL: LINUX_GIT: specify location of locally cloned git tree. # #LINUX_GIT=/home/user/linux-stable/+LINUX_GIT=~/Projects/common/linux-stable ###OPTIONAL: MMC: (REQUIRED FOR RUNNING: tools/install_kernel.sh) #Note: This operates on raw disks, NOT PARTITIONS..

以这种方式,将一个裸库转换成一个正常的库,但没有检查任何文件,并且保存了大

量的磁盘空间。

现在,在 system.sh 文件中正确设置 the LINUX_GIT 变量,可以参考刚刚下载的库。

system.sh 文件可以很容易地从 system.sh.sample 中获取 ,如下:

Installing the Developing System

[ 44 ]

Now, before continuing, we can do something similar to what we did for U-Boot and thenpre-download a Linux bare repository from the linux-stable tree into the commondirectory with the following command:

$ cd common$ git clone --bare https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git

Then, we have to do a little trick to transform the just downloaded data in a form suitablefor the build_kernel.sh script we've to use here:

$ mkdir linux-stable$ mv linux-stable.git/ linux-stable/.git$ cd linux-stable$ git config --local --bool core.bare false

In this manner, we converted a bare repository into a normal one, but without checking outany file and saving a lot of disk space!

Now, by properly setting the LINUX_GIT variable into the system.sh file, we can referencethe just downloaded repository. The system.sh file can be easily obtained fromsystem.sh.sample as follows:

$ cp system.sh.sample system.sh

Then, we need to properly set the LINUX_GIT and the CC variables (to specify the cross-compiler to be used) as reported in the following patch:

--- system.sh.sample 2016-04-15 18:04:18.178681406 +0200+++ system.sh 2016-04-18 17:40:11.229958465 +0200@@ -16,12 +16,14 @@ #CC=<enter full path>/bin/arm-none-eabi- #CC=<enter full path>/bin/arm-linux-gnueabi- #CC=<enter full path>/bin/arm-linux-gnueabihf-+CC=arm-linux-gnueabihf- ###OPTIONAL: ###OPTIONAL: LINUX_GIT: specify location of locally cloned git tree. # #LINUX_GIT=/home/user/linux-stable/+LINUX_GIT=~/Projects/common/linux-stable ###OPTIONAL: MMC: (REQUIRED FOR RUNNING: tools/install_kernel.sh) #Note: This operates on raw disks, NOT PARTITIONS..

然后,需要正确设置 LINUX_GIT 和 CC 变量(在指定的交叉编译器中使用),如下面

的补丁所报告的:

Installing the Developing System

[ 44 ]

Now, before continuing, we can do something similar to what we did for U-Boot and thenpre-download a Linux bare repository from the linux-stable tree into the commondirectory with the following command:

$ cd common$ git clone --bare https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git

Then, we have to do a little trick to transform the just downloaded data in a form suitablefor the build_kernel.sh script we've to use here:

$ mkdir linux-stable$ mv linux-stable.git/ linux-stable/.git$ cd linux-stable$ git config --local --bool core.bare false

In this manner, we converted a bare repository into a normal one, but without checking outany file and saving a lot of disk space!

Now, by properly setting the LINUX_GIT variable into the system.sh file, we can referencethe just downloaded repository. The system.sh file can be easily obtained fromsystem.sh.sample as follows:

$ cp system.sh.sample system.sh

Then, we need to properly set the LINUX_GIT and the CC variables (to specify the cross-compiler to be used) as reported in the following patch:

--- system.sh.sample 2016-04-15 18:04:18.178681406 +0200+++ system.sh 2016-04-18 17:40:11.229958465 +0200@@ -16,12 +16,14 @@ #CC=<enter full path>/bin/arm-none-eabi- #CC=<enter full path>/bin/arm-linux-gnueabi- #CC=<enter full path>/bin/arm-linux-gnueabihf-+CC=arm-linux-gnueabihf- ###OPTIONAL: ###OPTIONAL: LINUX_GIT: specify location of locally cloned git tree. # #LINUX_GIT=/home/user/linux-stable/+LINUX_GIT=~/Projects/common/linux-stable ###OPTIONAL: MMC: (REQUIRED FOR RUNNING: tools/install_kernel.sh) #Note: This operates on raw disks, NOT PARTITIONS..

Installing the Developing System

[ 44 ]

Now, before continuing, we can do something similar to what we did for U-Boot and thenpre-download a Linux bare repository from the linux-stable tree into the commondirectory with the following command:

$ cd common$ git clone --bare https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git

Then, we have to do a little trick to transform the just downloaded data in a form suitablefor the build_kernel.sh script we've to use here:

$ mkdir linux-stable$ mv linux-stable.git/ linux-stable/.git$ cd linux-stable$ git config --local --bool core.bare false

In this manner, we converted a bare repository into a normal one, but without checking outany file and saving a lot of disk space!

Now, by properly setting the LINUX_GIT variable into the system.sh file, we can referencethe just downloaded repository. The system.sh file can be easily obtained fromsystem.sh.sample as follows:

$ cp system.sh.sample system.sh

Then, we need to properly set the LINUX_GIT and the CC variables (to specify the cross-compiler to be used) as reported in the following patch:

--- system.sh.sample 2016-04-15 18:04:18.178681406 +0200+++ system.sh 2016-04-18 17:40:11.229958465 +0200@@ -16,12 +16,14 @@ #CC=<enter full path>/bin/arm-none-eabi- #CC=<enter full path>/bin/arm-linux-gnueabi- #CC=<enter full path>/bin/arm-linux-gnueabihf-+CC=arm-linux-gnueabihf- ###OPTIONAL: ###OPTIONAL: LINUX_GIT: specify location of locally cloned git tree. # #LINUX_GIT=/home/user/linux-stable/+LINUX_GIT=~/Projects/common/linux-stable ###OPTIONAL: MMC: (REQUIRED FOR RUNNING: tools/install_kernel.sh) #Note: This operates on raw disks, NOT PARTITIONS..

Page 21: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

第1章 开发系统的安装   21

Installing the Developing System

[ 44 ]

Now, before continuing, we can do something similar to what we did for U-Boot and thenpre-download a Linux bare repository from the linux-stable tree into the commondirectory with the following command:

$ cd common$ git clone --bare https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git

Then, we have to do a little trick to transform the just downloaded data in a form suitablefor the build_kernel.sh script we've to use here:

$ mkdir linux-stable$ mv linux-stable.git/ linux-stable/.git$ cd linux-stable$ git config --local --bool core.bare false

In this manner, we converted a bare repository into a normal one, but without checking outany file and saving a lot of disk space!

Now, by properly setting the LINUX_GIT variable into the system.sh file, we can referencethe just downloaded repository. The system.sh file can be easily obtained fromsystem.sh.sample as follows:

$ cp system.sh.sample system.sh

Then, we need to properly set the LINUX_GIT and the CC variables (to specify the cross-compiler to be used) as reported in the following patch:

--- system.sh.sample 2016-04-15 18:04:18.178681406 +0200+++ system.sh 2016-04-18 17:40:11.229958465 +0200@@ -16,12 +16,14 @@ #CC=<enter full path>/bin/arm-none-eabi- #CC=<enter full path>/bin/arm-linux-gnueabi- #CC=<enter full path>/bin/arm-linux-gnueabihf-+CC=arm-linux-gnueabihf- ###OPTIONAL: ###OPTIONAL: LINUX_GIT: specify location of locally cloned git tree. # #LINUX_GIT=/home/user/linux-stable/+LINUX_GIT=~/Projects/common/linux-stable ###OPTIONAL: MMC: (REQUIRED FOR RUNNING: tools/install_kernel.sh) #Note: This operates on raw disks, NOT PARTITIONS..

现在,必须用以下命令将我们的身份建立到新的 git 库中:

Installing the Developing System

[ 45 ]

Now, we have to set up our identity into the new git repository with the followingcommands:

$ git config --global user.name "Rodolfo Giometti"$ git config --global user.email "[email protected]"

Then, we can start the compilation with the following command:

$ ./build_kernel.sh

This step and the subsequent ones are time consuming and requirepatience, so you should take a cup of your preferred tea or coffee and justwait.

We should see that the correct cross-compiler is set and also the linux-stable repositoryis correctly referenced. Here is what I gets on my system:

$ ./build_kernel.sh+ Detected build host [Ubuntu 15.10]+ host: [x86_64]+ git HEAD commit: [72cf1bea12eea59be6632c9e9582f59e7f63ab3d]-----------------------------scripts/gcc: Using: arm-linux-gnueabihf-gcc (Linaro GCC 5.3-2016.02) 5.3.1 20160113Copyright (C) 2015 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.-----------------------------CROSS_COMPILE=arm-linux-gnueabihf------------------------------scripts/git: Debug: LINUX_GIT is setup as: [/home/giometti/Projects/common/linux-stable].scripts/git: [url=https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git]From https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable * branch HEAD -> FETCH_HEAD-----------------------------Cloning into '/home/giometti/Projects/BBB/bb-kernel/KERNEL'...done....

After a while, the classic kernel configuration panel should appear. Just confirm the defaultsettings by selecting the < Exit > menu option and then continue.

然后,可以用以下命令开始编译:

Installing the Developing System

[ 45 ]

Now, we have to set up our identity into the new git repository with the followingcommands:

$ git config --global user.name "Rodolfo Giometti"$ git config --global user.email "[email protected]"

Then, we can start the compilation with the following command:

$ ./build_kernel.sh

This step and the subsequent ones are time consuming and requirepatience, so you should take a cup of your preferred tea or coffee and justwait.

We should see that the correct cross-compiler is set and also the linux-stable repositoryis correctly referenced. Here is what I gets on my system:

$ ./build_kernel.sh+ Detected build host [Ubuntu 15.10]+ host: [x86_64]+ git HEAD commit: [72cf1bea12eea59be6632c9e9582f59e7f63ab3d]-----------------------------scripts/gcc: Using: arm-linux-gnueabihf-gcc (Linaro GCC 5.3-2016.02) 5.3.1 20160113Copyright (C) 2015 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.-----------------------------CROSS_COMPILE=arm-linux-gnueabihf------------------------------scripts/git: Debug: LINUX_GIT is setup as: [/home/giometti/Projects/common/linux-stable].scripts/git: [url=https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git]From https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable * branch HEAD -> FETCH_HEAD-----------------------------Cloning into '/home/giometti/Projects/BBB/bb-kernel/KERNEL'...done....

After a while, the classic kernel configuration panel should appear. Just confirm the defaultsettings by selecting the < Exit > menu option and then continue.

注意:这一步比较耗费时间和耐心,所以你可以去喝一杯咖啡,慢慢等。

我们应该看到已经设置好的交叉编译器,并且 Linux-stable 库也正确引用。下面是我的

系统上显示的内容:

Installing the Developing System

[ 45 ]

Now, we have to set up our identity into the new git repository with the followingcommands:

$ git config --global user.name "Rodolfo Giometti"$ git config --global user.email "[email protected]"

Then, we can start the compilation with the following command:

$ ./build_kernel.sh

This step and the subsequent ones are time consuming and requirepatience, so you should take a cup of your preferred tea or coffee and justwait.

We should see that the correct cross-compiler is set and also the linux-stable repositoryis correctly referenced. Here is what I gets on my system:

$ ./build_kernel.sh+ Detected build host [Ubuntu 15.10]+ host: [x86_64]+ git HEAD commit: [72cf1bea12eea59be6632c9e9582f59e7f63ab3d]-----------------------------scripts/gcc: Using: arm-linux-gnueabihf-gcc (Linaro GCC 5.3-2016.02) 5.3.1 20160113Copyright (C) 2015 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.-----------------------------CROSS_COMPILE=arm-linux-gnueabihf------------------------------scripts/git: Debug: LINUX_GIT is setup as: [/home/giometti/Projects/common/linux-stable].scripts/git: [url=https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git]From https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable * branch HEAD -> FETCH_HEAD-----------------------------Cloning into '/home/giometti/Projects/BBB/bb-kernel/KERNEL'...done....

After a while, the classic kernel configuration panel should appear. Just confirm the defaultsettings by selecting the < Exit > menu option and then continue.

等待一小会儿后,经典的内核配置面板应该会出现。通过选择 <Exit> 菜单选项来确认

默认设置,然后继续。

完成后,我们应该会看到如下所示的消息:

Installing the Developing System

[ 46 ]

When finished, we should see several messages as shown here:

...-----------------------------'arch/arm/boot/zImage' -> '/home/giometti/Projects/BBB/bb-kernel/deploy/4.4.7-bone9.zImage''.config' -> '/home/giometti/Projects/BBB/bb-kernel/deploy/config-4.4.7-bone9'-rwxrwxr-x 1 giometti giometti 7,1M apr 15 18:54 /home/giometti/Projects/BBB/bb-kernel/deploy/4.4.7-bone9.zImage-----------------------------Building modules archive...Compressing 4.4.7-bone9-modules.tar.gz...-rw-rw-r-- 1 giometti giometti 58M apr 15 18:55 /home/giometti/Projects/BBB/bb-kernel/deploy/4.4.7-bone9-modules.tar.gz-----------------------------Building firmware archive...Compressing 4.4.7-bone9-firmware.tar.gz...-rw-rw-r-- 1 giometti giometti 1,2M apr 15 18:55 /home/giometti/Projects/BBB/bb-kernel/deploy/4.4.7-bone9-firmware.tar.gz-----------------------------Building dtbs archive...Compressing 4.4.7-bone9-dtbs.tar.gz...-rw-rw-r-- 1 giometti giometti 328K apr 15 18:55 /home/giometti/Projects/BBB/bb-kernel/deploy/4.4.7-bone9-dtbs.tar.gz-----------------------------Script Completeeewiki.net: [user@localhost:~$ export kernel_version=4.4.7-bone9]-----------------------------

The last line tell us which is the kernel version to be defined into the uEnv.txt file definedearlier when we installed the bootloaders. The command is shown here:

$ sudo sh -c 'echo "uname_r=4.4.7-bone9" >> /media/rootfs/boot/uEnv.txt'

The /media/rootfs directory has been already mounted in the previoussection.

Now, we should install the kernel, but before doing it, we need the root filesystem, so let'smove to the next subsection.

Page 22: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

22   第一部分 基 础 知 识

Installing the Developing System

[ 46 ]

When finished, we should see several messages as shown here:

...-----------------------------'arch/arm/boot/zImage' -> '/home/giometti/Projects/BBB/bb-kernel/deploy/4.4.7-bone9.zImage''.config' -> '/home/giometti/Projects/BBB/bb-kernel/deploy/config-4.4.7-bone9'-rwxrwxr-x 1 giometti giometti 7,1M apr 15 18:54 /home/giometti/Projects/BBB/bb-kernel/deploy/4.4.7-bone9.zImage-----------------------------Building modules archive...Compressing 4.4.7-bone9-modules.tar.gz...-rw-rw-r-- 1 giometti giometti 58M apr 15 18:55 /home/giometti/Projects/BBB/bb-kernel/deploy/4.4.7-bone9-modules.tar.gz-----------------------------Building firmware archive...Compressing 4.4.7-bone9-firmware.tar.gz...-rw-rw-r-- 1 giometti giometti 1,2M apr 15 18:55 /home/giometti/Projects/BBB/bb-kernel/deploy/4.4.7-bone9-firmware.tar.gz-----------------------------Building dtbs archive...Compressing 4.4.7-bone9-dtbs.tar.gz...-rw-rw-r-- 1 giometti giometti 328K apr 15 18:55 /home/giometti/Projects/BBB/bb-kernel/deploy/4.4.7-bone9-dtbs.tar.gz-----------------------------Script Completeeewiki.net: [user@localhost:~$ export kernel_version=4.4.7-bone9]-----------------------------

The last line tell us which is the kernel version to be defined into the uEnv.txt file definedearlier when we installed the bootloaders. The command is shown here:

$ sudo sh -c 'echo "uname_r=4.4.7-bone9" >> /media/rootfs/boot/uEnv.txt'

The /media/rootfs directory has been already mounted in the previoussection.

Now, we should install the kernel, but before doing it, we need the root filesystem, so let'smove to the next subsection.

最后一行告诉我们,之前安装 bootloader 的时候用的那个内核版本,将内核信息导入

至 uEnv.txt 这个文件中。命令如下:

Installing the Developing System

[ 46 ]

When finished, we should see several messages as shown here:

...-----------------------------'arch/arm/boot/zImage' -> '/home/giometti/Projects/BBB/bb-kernel/deploy/4.4.7-bone9.zImage''.config' -> '/home/giometti/Projects/BBB/bb-kernel/deploy/config-4.4.7-bone9'-rwxrwxr-x 1 giometti giometti 7,1M apr 15 18:54 /home/giometti/Projects/BBB/bb-kernel/deploy/4.4.7-bone9.zImage-----------------------------Building modules archive...Compressing 4.4.7-bone9-modules.tar.gz...-rw-rw-r-- 1 giometti giometti 58M apr 15 18:55 /home/giometti/Projects/BBB/bb-kernel/deploy/4.4.7-bone9-modules.tar.gz-----------------------------Building firmware archive...Compressing 4.4.7-bone9-firmware.tar.gz...-rw-rw-r-- 1 giometti giometti 1,2M apr 15 18:55 /home/giometti/Projects/BBB/bb-kernel/deploy/4.4.7-bone9-firmware.tar.gz-----------------------------Building dtbs archive...Compressing 4.4.7-bone9-dtbs.tar.gz...-rw-rw-r-- 1 giometti giometti 328K apr 15 18:55 /home/giometti/Projects/BBB/bb-kernel/deploy/4.4.7-bone9-dtbs.tar.gz-----------------------------Script Completeeewiki.net: [user@localhost:~$ export kernel_version=4.4.7-bone9]-----------------------------

The last line tell us which is the kernel version to be defined into the uEnv.txt file definedearlier when we installed the bootloaders. The command is shown here:

$ sudo sh -c 'echo "uname_r=4.4.7-bone9" >> /media/rootfs/boot/uEnv.txt'

The /media/rootfs directory has been already mounted in the previoussection.

Now, we should install the kernel, but before doing it, we need the root filesystem, so let'smove to the next subsection.

注意:/media/rootfs 目录在前一节已经挂载好了。

现在,应该可以安装内核了,但在安装之前,需要根文件系统,所以转到下一节。

4. Debian 8 系统的设置

我们可用已有的镜像来安装 rootfs 目录包含的 Debian 操作系统,同样,我们可以将

之下载到 common 这个目录以节省空间。命令如下:

Installing the Developing System

[ 47 ]

Debian 8 (jessie) for the BeagleBone BlackTo install the rootfs directory containing our Debian OS, we can use a pre-built image,and again, we can download it into the common directory to save space. The commands areshown here:

$ cd common$ wget wget -c https://rcn-ee.com/rootfs/eewiki/minfs/debian-8.4-minimal-armhf-2016-04-02.tar.xz

Then, we can explore it by using the tar command:

$ tar xf debian-8.4-minimal-armhf-2016-04-02.tar.xz

By the time you read this, new versions could be available or the currentone could be missing. Then, we should verify the available versions in thecase of errors while downloading the rootfs image used earlier.

When finished, a new directory named debian-8.4-minimal-armhf-2016-04-02should be available on the current working directory, and to copy it on the microSD, we canuse this command:

$ cd debian-8.4-minimal-armhf-2016-04-02/$ sudo tar xpf armhf-rootfs-debian-jessie.tar -C /media/rootfs/

We have already mounted the microSD into /media/rootfs.

When finished, we can add the kernel image and its related files compiled earlier byswitching back to the kernel repository and then using these commands:

$ cd BBB/bb-kernel$ sudo cp deploy/4.4.7-bone9.zImage /media/rootfs/boot/vmlinuz-4.4.7-bone9$ sudo mkdir -p /media/rootfs/boot/dtbs/4.4.7-bone9/$ sudo tar xf deploy/4.4.7-bone9-dtbs.tar.gz -C /media/rootfs/boot/dtbs/4.4.7-bone9/$ sudo tar xf deploy/4.4.7-bone9-modules.tar.gz -C /media/rootfs/

然后,我们可以使用 tar 命令来解压它:

Installing the Developing System

[ 47 ]

Debian 8 (jessie) for the BeagleBone BlackTo install the rootfs directory containing our Debian OS, we can use a pre-built image,and again, we can download it into the common directory to save space. The commands areshown here:

$ cd common$ wget wget -c https://rcn-ee.com/rootfs/eewiki/minfs/debian-8.4-minimal-armhf-2016-04-02.tar.xz

Then, we can explore it by using the tar command:

$ tar xf debian-8.4-minimal-armhf-2016-04-02.tar.xz

By the time you read this, new versions could be available or the currentone could be missing. Then, we should verify the available versions in thecase of errors while downloading the rootfs image used earlier.

When finished, a new directory named debian-8.4-minimal-armhf-2016-04-02should be available on the current working directory, and to copy it on the microSD, we canuse this command:

$ cd debian-8.4-minimal-armhf-2016-04-02/$ sudo tar xpf armhf-rootfs-debian-jessie.tar -C /media/rootfs/

We have already mounted the microSD into /media/rootfs.

When finished, we can add the kernel image and its related files compiled earlier byswitching back to the kernel repository and then using these commands:

$ cd BBB/bb-kernel$ sudo cp deploy/4.4.7-bone9.zImage /media/rootfs/boot/vmlinuz-4.4.7-bone9$ sudo mkdir -p /media/rootfs/boot/dtbs/4.4.7-bone9/$ sudo tar xf deploy/4.4.7-bone9-dtbs.tar.gz -C /media/rootfs/boot/dtbs/4.4.7-bone9/$ sudo tar xf deploy/4.4.7-bone9-modules.tar.gz -C /media/rootfs/

注意:当你读到这里的时候,可能会有新的版本,或者当前的这个版本可能会丢失。

然后,我们应该验证可用的版本,以避免当下载根文件系统的时候出现错误。

完成后,在当前工作目录下会保存一个命名为 debian-8.4-minimal-armhf-2016-04-02 的

文件夹,我们可以使用一下命令将它复制到 microSD 卡中:

Installing the Developing System

[ 47 ]

Debian 8 (jessie) for the BeagleBone BlackTo install the rootfs directory containing our Debian OS, we can use a pre-built image,and again, we can download it into the common directory to save space. The commands areshown here:

$ cd common$ wget wget -c https://rcn-ee.com/rootfs/eewiki/minfs/debian-8.4-minimal-armhf-2016-04-02.tar.xz

Then, we can explore it by using the tar command:

$ tar xf debian-8.4-minimal-armhf-2016-04-02.tar.xz

By the time you read this, new versions could be available or the currentone could be missing. Then, we should verify the available versions in thecase of errors while downloading the rootfs image used earlier.

When finished, a new directory named debian-8.4-minimal-armhf-2016-04-02should be available on the current working directory, and to copy it on the microSD, we canuse this command:

$ cd debian-8.4-minimal-armhf-2016-04-02/$ sudo tar xpf armhf-rootfs-debian-jessie.tar -C /media/rootfs/

We have already mounted the microSD into /media/rootfs.

When finished, we can add the kernel image and its related files compiled earlier byswitching back to the kernel repository and then using these commands:

$ cd BBB/bb-kernel$ sudo cp deploy/4.4.7-bone9.zImage /media/rootfs/boot/vmlinuz-4.4.7-bone9$ sudo mkdir -p /media/rootfs/boot/dtbs/4.4.7-bone9/$ sudo tar xf deploy/4.4.7-bone9-dtbs.tar.gz -C /media/rootfs/boot/dtbs/4.4.7-bone9/$ sudo tar xf deploy/4.4.7-bone9-modules.tar.gz -C /media/rootfs/

注意:在这之前我们要把 microSD 挂载到 /media/rootfs 中。

Page 23: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

第1章 开发系统的安装   23

完成后,我们可以添加内核映像及其之前的相关文件,命令如下:

Installing the Developing System

[ 47 ]

Debian 8 (jessie) for the BeagleBone BlackTo install the rootfs directory containing our Debian OS, we can use a pre-built image,and again, we can download it into the common directory to save space. The commands areshown here:

$ cd common$ wget wget -c https://rcn-ee.com/rootfs/eewiki/minfs/debian-8.4-minimal-armhf-2016-04-02.tar.xz

Then, we can explore it by using the tar command:

$ tar xf debian-8.4-minimal-armhf-2016-04-02.tar.xz

By the time you read this, new versions could be available or the currentone could be missing. Then, we should verify the available versions in thecase of errors while downloading the rootfs image used earlier.

When finished, a new directory named debian-8.4-minimal-armhf-2016-04-02should be available on the current working directory, and to copy it on the microSD, we canuse this command:

$ cd debian-8.4-minimal-armhf-2016-04-02/$ sudo tar xpf armhf-rootfs-debian-jessie.tar -C /media/rootfs/

We have already mounted the microSD into /media/rootfs.

When finished, we can add the kernel image and its related files compiled earlier byswitching back to the kernel repository and then using these commands:

$ cd BBB/bb-kernel$ sudo cp deploy/4.4.7-bone9.zImage /media/rootfs/boot/vmlinuz-4.4.7-bone9$ sudo mkdir -p /media/rootfs/boot/dtbs/4.4.7-bone9/$ sudo tar xf deploy/4.4.7-bone9-dtbs.tar.gz -C /media/rootfs/boot/dtbs/4.4.7-bone9/$ sudo tar xf deploy/4.4.7-bone9-modules.tar.gz -C /media/rootfs/

现在,要完成这项工作,我们还必须使用以下命令建立文件系统表:

Installing the Developing System

[ 48 ]

Now, to finish the job, we must set up the filesystem table using the following command:

$ sudo sh -c "echo '/dev/mmcblk0p1 / auto errors=remount-ro 0 1' > /media/rootfs/etc/fstab"

Do the networking configuration by executing the following commands:

$ sudo sh -c "echo 'allow-hotplug lo\niface lo inet loopback\n' > /media/rootfs/etc/network/interfaces"$ sudo sh -c "echo 'allow-hotplug eth0\niface eth0 inet dhcp\n' >> /media/rootfs/etc/network/interfaces"

Now, we should be ready to boot our new system! Let's unmount the microSD from thehost PC and plug it into the BeagleBone Black and power on the board. The umountcommand line is shown here:

$ sudo umount /media/rootfs/

If everything works well on the serial console, we should see something like this:

U-Boot SPL 2016.03-dirty (Apr 15 2016 - 13:44:25)Trying to boot from MMCbad magicU-Boot 2016.03-dirty (Apr 15 2016 - 13:44:25 +0200)

Watchdog enabledI2C: readyDRAM: 512 MiBReset Source: Power-on reset has occurred.MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1Using default environment

Net: <ethaddr> not set. Validating first E-fuse MACcpsw, usb_etherPress SPACE to abort autoboot in 2 secondsswitch to partitions #0, OKmmc0 is current deviceScanning mmc 0:1......debug: [console=ttyO0,115200n8 root=/dev/mmcblk0p1 ro rootfstype=ext4rootwait].debug: [bootz 0x82000000 - 0x88000000] ...Kernel image @ 0x82000000 [ 0x000000 - 0x710b38 ]## Flattened Device Tree blob at 88000000 Booting using the fdt blob at 0x88000000 Using Device Tree in place at 88000000, end 88010a19

Starting kernel ...

通过执行下列命令来完成网络配置:

Installing the Developing System

[ 48 ]

Now, to finish the job, we must set up the filesystem table using the following command:

$ sudo sh -c "echo '/dev/mmcblk0p1 / auto errors=remount-ro 0 1' > /media/rootfs/etc/fstab"

Do the networking configuration by executing the following commands:

$ sudo sh -c "echo 'allow-hotplug lo\niface lo inet loopback\n' > /media/rootfs/etc/network/interfaces"$ sudo sh -c "echo 'allow-hotplug eth0\niface eth0 inet dhcp\n' >> /media/rootfs/etc/network/interfaces"

Now, we should be ready to boot our new system! Let's unmount the microSD from thehost PC and plug it into the BeagleBone Black and power on the board. The umountcommand line is shown here:

$ sudo umount /media/rootfs/

If everything works well on the serial console, we should see something like this:

U-Boot SPL 2016.03-dirty (Apr 15 2016 - 13:44:25)Trying to boot from MMCbad magicU-Boot 2016.03-dirty (Apr 15 2016 - 13:44:25 +0200)

Watchdog enabledI2C: readyDRAM: 512 MiBReset Source: Power-on reset has occurred.MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1Using default environment

Net: <ethaddr> not set. Validating first E-fuse MACcpsw, usb_etherPress SPACE to abort autoboot in 2 secondsswitch to partitions #0, OKmmc0 is current deviceScanning mmc 0:1......debug: [console=ttyO0,115200n8 root=/dev/mmcblk0p1 ro rootfstype=ext4rootwait].debug: [bootz 0x82000000 - 0x88000000] ...Kernel image @ 0x82000000 [ 0x000000 - 0x710b38 ]## Flattened Device Tree blob at 88000000 Booting using the fdt blob at 0x88000000 Using Device Tree in place at 88000000, end 88010a19

Starting kernel ...

现在,我们应该准备好了启动我们的新系统!让我们从主机上卸载掉 microSD 然后插

入开发板中。umount 命令行如下所示:

Installing the Developing System

[ 48 ]

Now, to finish the job, we must set up the filesystem table using the following command:

$ sudo sh -c "echo '/dev/mmcblk0p1 / auto errors=remount-ro 0 1' > /media/rootfs/etc/fstab"

Do the networking configuration by executing the following commands:

$ sudo sh -c "echo 'allow-hotplug lo\niface lo inet loopback\n' > /media/rootfs/etc/network/interfaces"$ sudo sh -c "echo 'allow-hotplug eth0\niface eth0 inet dhcp\n' >> /media/rootfs/etc/network/interfaces"

Now, we should be ready to boot our new system! Let's unmount the microSD from thehost PC and plug it into the BeagleBone Black and power on the board. The umountcommand line is shown here:

$ sudo umount /media/rootfs/

If everything works well on the serial console, we should see something like this:

U-Boot SPL 2016.03-dirty (Apr 15 2016 - 13:44:25)Trying to boot from MMCbad magicU-Boot 2016.03-dirty (Apr 15 2016 - 13:44:25 +0200)

Watchdog enabledI2C: readyDRAM: 512 MiBReset Source: Power-on reset has occurred.MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1Using default environment

Net: <ethaddr> not set. Validating first E-fuse MACcpsw, usb_etherPress SPACE to abort autoboot in 2 secondsswitch to partitions #0, OKmmc0 is current deviceScanning mmc 0:1......debug: [console=ttyO0,115200n8 root=/dev/mmcblk0p1 ro rootfstype=ext4rootwait].debug: [bootz 0x82000000 - 0x88000000] ...Kernel image @ 0x82000000 [ 0x000000 - 0x710b38 ]## Flattened Device Tree blob at 88000000 Booting using the fdt blob at 0x88000000 Using Device Tree in place at 88000000, end 88010a19

Starting kernel ...

如果在串口控制台上一切正常,我们应该看到这些信息:

Installing the Developing System

[ 48 ]

Now, to finish the job, we must set up the filesystem table using the following command:

$ sudo sh -c "echo '/dev/mmcblk0p1 / auto errors=remount-ro 0 1' > /media/rootfs/etc/fstab"

Do the networking configuration by executing the following commands:

$ sudo sh -c "echo 'allow-hotplug lo\niface lo inet loopback\n' > /media/rootfs/etc/network/interfaces"$ sudo sh -c "echo 'allow-hotplug eth0\niface eth0 inet dhcp\n' >> /media/rootfs/etc/network/interfaces"

Now, we should be ready to boot our new system! Let's unmount the microSD from thehost PC and plug it into the BeagleBone Black and power on the board. The umountcommand line is shown here:

$ sudo umount /media/rootfs/

If everything works well on the serial console, we should see something like this:

U-Boot SPL 2016.03-dirty (Apr 15 2016 - 13:44:25)Trying to boot from MMCbad magicU-Boot 2016.03-dirty (Apr 15 2016 - 13:44:25 +0200)

Watchdog enabledI2C: readyDRAM: 512 MiBReset Source: Power-on reset has occurred.MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1Using default environment

Net: <ethaddr> not set. Validating first E-fuse MACcpsw, usb_etherPress SPACE to abort autoboot in 2 secondsswitch to partitions #0, OKmmc0 is current deviceScanning mmc 0:1......debug: [console=ttyO0,115200n8 root=/dev/mmcblk0p1 ro rootfstype=ext4rootwait].debug: [bootz 0x82000000 - 0x88000000] ...Kernel image @ 0x82000000 [ 0x000000 - 0x710b38 ]## Flattened Device Tree blob at 88000000 Booting using the fdt blob at 0x88000000 Using Device Tree in place at 88000000, end 88010a19

Starting kernel ...

Installing the Developing System

[ 48 ]

Now, to finish the job, we must set up the filesystem table using the following command:

$ sudo sh -c "echo '/dev/mmcblk0p1 / auto errors=remount-ro 0 1' > /media/rootfs/etc/fstab"

Do the networking configuration by executing the following commands:

$ sudo sh -c "echo 'allow-hotplug lo\niface lo inet loopback\n' > /media/rootfs/etc/network/interfaces"$ sudo sh -c "echo 'allow-hotplug eth0\niface eth0 inet dhcp\n' >> /media/rootfs/etc/network/interfaces"

Now, we should be ready to boot our new system! Let's unmount the microSD from thehost PC and plug it into the BeagleBone Black and power on the board. The umountcommand line is shown here:

$ sudo umount /media/rootfs/

If everything works well on the serial console, we should see something like this:

U-Boot SPL 2016.03-dirty (Apr 15 2016 - 13:44:25)Trying to boot from MMCbad magicU-Boot 2016.03-dirty (Apr 15 2016 - 13:44:25 +0200)

Watchdog enabledI2C: readyDRAM: 512 MiBReset Source: Power-on reset has occurred.MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1Using default environment

Net: <ethaddr> not set. Validating first E-fuse MACcpsw, usb_etherPress SPACE to abort autoboot in 2 secondsswitch to partitions #0, OKmmc0 is current deviceScanning mmc 0:1......debug: [console=ttyO0,115200n8 root=/dev/mmcblk0p1 ro rootfstype=ext4rootwait].debug: [bootz 0x82000000 - 0x88000000] ...Kernel image @ 0x82000000 [ 0x000000 - 0x710b38 ]## Flattened Device Tree blob at 88000000 Booting using the fdt blob at 0x88000000 Using Device Tree in place at 88000000, end 88010a19

Starting kernel ...

Page 24: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

24   第一部分 基 础 知 识Installing the Developing System

[ 49 ]

[ 0.000000] Booting Linux on physical CPU 0x0...[ 5.466604] random: systemd urandom read with 17 bits of entropy available[ 5.484996] systemd[1]: systemd 215 running in system mode. (+PAM +AUDIT +SE)[ 5.498711] systemd[1]: Detected architecture 'arm'.

Welcome to Debian GNU/Linux 8 (jessie)!

[ 5.535458] systemd[1]: Set hostname to <arm>.[ 5.861405] systemd[1]: Cannot add dependency job for unit display-manager.s....[ OK ] Started LSB: Apache2 web server.[ 12.903747] random: nonblocking pool is initialized

Debian GNU/Linux 8 arm ttyS0

default username:password is [debian:temppwd]

arm login:

In order to work, we may need to completely power the BeagleBone Blackand then re-power it while keeping the user button pressed. Otherwise,the board will still continue booting from the on-board eMMC.

Great! Everything is working now. We can log in by entering the string root as bothusername and password.

Setting up the SAMA5D3 XplainedNow, it's the turn of the SAMA5D3 Xplained. Even this board may have a pre-loadeddistribution into its flash memory, but it is an embedded distribution that is not suitable forour purposes. So, as we did for the BeagleBone Black, we will install a fresh Debian OS on amicroSD card (in reality, the SAMA5D3 Xplained comes with an SD slot, but we can stilluse a microSD plugged in an SD adapter).

注意:为了可以运行,我们可能需要完整地给 BeagleBone Black 供电,然后让用户

保持按钮被按。否则,主板将依旧从主板的 eMMC 启动。

很好,现在一切就绪。我们可以输入 root 作为登录用户名和密码。

1.3.3 设置 SAMA5D3 Xplained 开发平台

现在,轮到 SAMA5D3 Xplained 了。即使这个主板可能在闪存里有一个其他发行版系

统,但它的嵌入式发行版系统不适合我们。所以,就像我们之前在 BeagleBone Black 上做

的一样,在一个 microSD 卡安装新的 Debian 操作系统(其实 SAMA5D3 Xplained 自带了一

个 SD 插槽,但我们仍然可以使用在 SD 适配器上插入 microSD)。

1. 串口控制台的设置如前一节,我们有 J23 连接器,它的串口引脚露在外面。所以,同理,使用一个适当

的适配器,就可以连接到主机。

相关引脚的信息在下表中,然后你要做的跟之前一样,必须把接地引脚与适配器的

GND 连接起来,然后交换 TxD(发送器)和 RxD(接收器)以建立正确串行连接。

连接器 J1 功能

Pin 6 GND

Pin 2 TxD

Pin 3 RxD

连接示意如下图所示:

Page 25: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

第1章 开发系统的安装   25

如果所有的连接都是正确的,我们就可以执行 minicom 工具从串口控制台查看信息。

如果我们的 SAMA5D3 Xplained 带有一个预加载的系统,在串口控制台窗口就应该能

看到启动顺序。否则,我们就应该看到 RomBOOT 信息。但无论如何,串口控制台都应该

是可用的。

注意:一定要记着验证串口被用。波特率为 115200,数据格式为 8N1 并且不开启

硬件和软件流控制。请见之前的 BeagleBone Black 平台设置。

现在,可以安装软件然后使用 SAMA5D3 Xplained 主板了。

2. U-Boot(基于 boot.bin)的设置为了获得 bootloader 的资源,我们可以使用和 BeagleBone Black 一样的资源。不过这

一次,库已经有了,所以我们只需要克隆一个新的就行了,命令如下(在此主板上,我们创

建了 A5D3 文件夹):

Installing the Developing System

[ 51 ]

You should not forget to verify the serial port to be used. You should alsosee that its setup is 115200,8N1 without hardware and software flowcontrol. See the BeagleBone Black settings earlier.

Now, let's install the software to start working with our SAMA5D3 Xplained board.

U-Boot (with boot.bin)To obtain the bootloader's sources, we can use the same trick used for BeagleBone Black'ssources. However, this time, the bare repository is already downloaded, so we just need toclone a new one with the following commands (to work with this board, we created theA5D3 directory):

$ cd A5D3$ git clone --reference ~/Projects/common/u-boot.git https://github.com/u-boot/u-boot

Now, let's go into the newly created directory and check out a proper U-Boot release to use.Here are the commands used:

$ cd u-boot$ git checkout v2016.03 -b v2016.03

Now, just as before, we need some patches to properly support the SAMA5D3 Xplained.We can get them using the following commands:

$ wget -c https://rcn-ee.com/repos/git/u-boot-patches/v2016.03/0001-sama5d3_xplained-uEnv.txt-bootz-n-fixes.patch$ patch -p1 < 0001-sama5d3_xplained-uEnv.txt-bootz-n-fixes.patch

Now, we're ready to compile:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sama5d3_xplained_mmc_defconfig$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

Now, let's install the bootloader into the microSD.

As already done earlier, we have to discover the device associated withthe microSD (see the the BeagleBone Black subsection).

现在,我们进入新创建的目录,查看 U-Boot 的版本,命令如下:

Installing the Developing System

[ 51 ]

You should not forget to verify the serial port to be used. You should alsosee that its setup is 115200,8N1 without hardware and software flowcontrol. See the BeagleBone Black settings earlier.

Now, let's install the software to start working with our SAMA5D3 Xplained board.

U-Boot (with boot.bin)To obtain the bootloader's sources, we can use the same trick used for BeagleBone Black'ssources. However, this time, the bare repository is already downloaded, so we just need toclone a new one with the following commands (to work with this board, we created theA5D3 directory):

$ cd A5D3$ git clone --reference ~/Projects/common/u-boot.git https://github.com/u-boot/u-boot

Now, let's go into the newly created directory and check out a proper U-Boot release to use.Here are the commands used:

$ cd u-boot$ git checkout v2016.03 -b v2016.03

Now, just as before, we need some patches to properly support the SAMA5D3 Xplained.We can get them using the following commands:

$ wget -c https://rcn-ee.com/repos/git/u-boot-patches/v2016.03/0001-sama5d3_xplained-uEnv.txt-bootz-n-fixes.patch$ patch -p1 < 0001-sama5d3_xplained-uEnv.txt-bootz-n-fixes.patch

Now, we're ready to compile:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sama5d3_xplained_mmc_defconfig$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

Now, let's install the bootloader into the microSD.

As already done earlier, we have to discover the device associated withthe microSD (see the the BeagleBone Black subsection).

现在,和前面一样,我们需要在 SAMA5D3 Xplained 上打一些补丁。命令如下:

Installing the Developing System

[ 51 ]

You should not forget to verify the serial port to be used. You should alsosee that its setup is 115200,8N1 without hardware and software flowcontrol. See the BeagleBone Black settings earlier.

Now, let's install the software to start working with our SAMA5D3 Xplained board.

U-Boot (with boot.bin)To obtain the bootloader's sources, we can use the same trick used for BeagleBone Black'ssources. However, this time, the bare repository is already downloaded, so we just need toclone a new one with the following commands (to work with this board, we created theA5D3 directory):

$ cd A5D3$ git clone --reference ~/Projects/common/u-boot.git https://github.com/u-boot/u-boot

Now, let's go into the newly created directory and check out a proper U-Boot release to use.Here are the commands used:

$ cd u-boot$ git checkout v2016.03 -b v2016.03

Now, just as before, we need some patches to properly support the SAMA5D3 Xplained.We can get them using the following commands:

$ wget -c https://rcn-ee.com/repos/git/u-boot-patches/v2016.03/0001-sama5d3_xplained-uEnv.txt-bootz-n-fixes.patch$ patch -p1 < 0001-sama5d3_xplained-uEnv.txt-bootz-n-fixes.patch

Now, we're ready to compile:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sama5d3_xplained_mmc_defconfig$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

Now, let's install the bootloader into the microSD.

As already done earlier, we have to discover the device associated withthe microSD (see the the BeagleBone Black subsection).

现在,我们准备编译:

Installing the Developing System

[ 51 ]

You should not forget to verify the serial port to be used. You should alsosee that its setup is 115200,8N1 without hardware and software flowcontrol. See the BeagleBone Black settings earlier.

Now, let's install the software to start working with our SAMA5D3 Xplained board.

U-Boot (with boot.bin)To obtain the bootloader's sources, we can use the same trick used for BeagleBone Black'ssources. However, this time, the bare repository is already downloaded, so we just need toclone a new one with the following commands (to work with this board, we created theA5D3 directory):

$ cd A5D3$ git clone --reference ~/Projects/common/u-boot.git https://github.com/u-boot/u-boot

Now, let's go into the newly created directory and check out a proper U-Boot release to use.Here are the commands used:

$ cd u-boot$ git checkout v2016.03 -b v2016.03

Now, just as before, we need some patches to properly support the SAMA5D3 Xplained.We can get them using the following commands:

$ wget -c https://rcn-ee.com/repos/git/u-boot-patches/v2016.03/0001-sama5d3_xplained-uEnv.txt-bootz-n-fixes.patch$ patch -p1 < 0001-sama5d3_xplained-uEnv.txt-bootz-n-fixes.patch

Now, we're ready to compile:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sama5d3_xplained_mmc_defconfig$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

Now, let's install the bootloader into the microSD.

As already done earlier, we have to discover the device associated withthe microSD (see the the BeagleBone Black subsection).

现在,让我们安装引导程序到 microSD。

注意:和之前一样,我们要找到和 microSD 卡相关的设备(见 BeagleBone Black 部

分)。

Page 26: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

26   第一部分 基 础 知 识

我们可以使用以下命令清除当前分区表:

Installing the Developing System

[ 52 ]

We can clear the current partition table using the following command:

$ sudo dd if=/dev/zero of=/dev/sdX bs=1M count=50

You should not forget to replace device /dev/sdX with the deviceassociated with the microSD plugged into your system and follow the nextsteps carefully. Otherwise, it may damage the host system!

Now, we can prepare the needed partitions for the root filesystem, which will be installed inthe upcoming sections. Here are the commands:

$ echo -e '1M,48M,0xE,*\n,,,-' | sudo sfdisk /dev/sdX$ sudo mkfs.vfat -F 16 -n BOOT /dev/sdX1$ sudo mkfs.ext4 -L rootfs /dev/sdX2

As already stated for the BeagleBone Black, we must notice that since themkfs.ext4 version 1.43, the metadata_csum and 64bit options areenabled by default. However, we need to make sure that they are disabled.Otherwise, U-Boot cannot boot from our ext4 partitions. If this is our case,we need to replace the preceding command with the following one:

$ sudo mkfs.ext4 -L rootfs -O ^metadata_csum,^64bit /dev/sdX2

Now, we can mount the newly created boot and rootfs partitions in order to be ready tocopy the bootloaders and the distro's file into them. Here are the commands:

$ sudo mkdir /media/boot$ sudo mkdir /media/rootfs$ sudo mount /dev/sdX1 /media/boot$ sudo mount /dev/sdX2 /media/rootfs

Then, we can install the newly compiled bootloaders:

$ sudo cp boot.bin /media/boot/$ sudo cp u-boot.img /media/boot/

This time, we don't need any configuration file for U-Boot (file uEnv.txt).

Now, it's time to compile the kernel.

注意:一定要记着把与 /dev/sdX 关联的 microSD 卡插入系统,并仔细地按照下面

步骤的执行。否则,可能会损坏主机系统!

现在,我们为根文件系统准备所需的分区,之后会介绍。命令如下:

Installing the Developing System

[ 52 ]

We can clear the current partition table using the following command:

$ sudo dd if=/dev/zero of=/dev/sdX bs=1M count=50

You should not forget to replace device /dev/sdX with the deviceassociated with the microSD plugged into your system and follow the nextsteps carefully. Otherwise, it may damage the host system!

Now, we can prepare the needed partitions for the root filesystem, which will be installed inthe upcoming sections. Here are the commands:

$ echo -e '1M,48M,0xE,*\n,,,-' | sudo sfdisk /dev/sdX$ sudo mkfs.vfat -F 16 -n BOOT /dev/sdX1$ sudo mkfs.ext4 -L rootfs /dev/sdX2

As already stated for the BeagleBone Black, we must notice that since themkfs.ext4 version 1.43, the metadata_csum and 64bit options areenabled by default. However, we need to make sure that they are disabled.Otherwise, U-Boot cannot boot from our ext4 partitions. If this is our case,we need to replace the preceding command with the following one:

$ sudo mkfs.ext4 -L rootfs -O ^metadata_csum,^64bit /dev/sdX2

Now, we can mount the newly created boot and rootfs partitions in order to be ready tocopy the bootloaders and the distro's file into them. Here are the commands:

$ sudo mkdir /media/boot$ sudo mkdir /media/rootfs$ sudo mount /dev/sdX1 /media/boot$ sudo mount /dev/sdX2 /media/rootfs

Then, we can install the newly compiled bootloaders:

$ sudo cp boot.bin /media/boot/$ sudo cp u-boot.img /media/boot/

This time, we don't need any configuration file for U-Boot (file uEnv.txt).

Now, it's time to compile the kernel.

注意:就像之前所述的 BeagleBone Black,我们必须注意到,因为 mkfs.ext4 版本

为 1.43 的 metadata_csum 和 64 位的选项是默认开启的。然而,我们需要确保这些

是关闭的。否则,我们无法启动 U-Boot ext4 的分区。如果是这种的情况,我们需

要用下面的命令替换前面的命令:

Installing the Developing System

[ 52 ]

We can clear the current partition table using the following command:

$ sudo dd if=/dev/zero of=/dev/sdX bs=1M count=50

You should not forget to replace device /dev/sdX with the deviceassociated with the microSD plugged into your system and follow the nextsteps carefully. Otherwise, it may damage the host system!

Now, we can prepare the needed partitions for the root filesystem, which will be installed inthe upcoming sections. Here are the commands:

$ echo -e '1M,48M,0xE,*\n,,,-' | sudo sfdisk /dev/sdX$ sudo mkfs.vfat -F 16 -n BOOT /dev/sdX1$ sudo mkfs.ext4 -L rootfs /dev/sdX2

As already stated for the BeagleBone Black, we must notice that since themkfs.ext4 version 1.43, the metadata_csum and 64bit options areenabled by default. However, we need to make sure that they are disabled.Otherwise, U-Boot cannot boot from our ext4 partitions. If this is our case,we need to replace the preceding command with the following one:

$ sudo mkfs.ext4 -L rootfs -O ^metadata_csum,^64bit /dev/sdX2

Now, we can mount the newly created boot and rootfs partitions in order to be ready tocopy the bootloaders and the distro's file into them. Here are the commands:

$ sudo mkdir /media/boot$ sudo mkdir /media/rootfs$ sudo mount /dev/sdX1 /media/boot$ sudo mount /dev/sdX2 /media/rootfs

Then, we can install the newly compiled bootloaders:

$ sudo cp boot.bin /media/boot/$ sudo cp u-boot.img /media/boot/

This time, we don't need any configuration file for U-Boot (file uEnv.txt).

Now, it's time to compile the kernel.

现在,我们可以将新创建的引导和根文件系统的分区挂载起来,以便将拷贝 bootloader和相关文件复制到里面。命令如下:

Installing the Developing System

[ 52 ]

We can clear the current partition table using the following command:

$ sudo dd if=/dev/zero of=/dev/sdX bs=1M count=50

You should not forget to replace device /dev/sdX with the deviceassociated with the microSD plugged into your system and follow the nextsteps carefully. Otherwise, it may damage the host system!

Now, we can prepare the needed partitions for the root filesystem, which will be installed inthe upcoming sections. Here are the commands:

$ echo -e '1M,48M,0xE,*\n,,,-' | sudo sfdisk /dev/sdX$ sudo mkfs.vfat -F 16 -n BOOT /dev/sdX1$ sudo mkfs.ext4 -L rootfs /dev/sdX2

As already stated for the BeagleBone Black, we must notice that since themkfs.ext4 version 1.43, the metadata_csum and 64bit options areenabled by default. However, we need to make sure that they are disabled.Otherwise, U-Boot cannot boot from our ext4 partitions. If this is our case,we need to replace the preceding command with the following one:

$ sudo mkfs.ext4 -L rootfs -O ^metadata_csum,^64bit /dev/sdX2

Now, we can mount the newly created boot and rootfs partitions in order to be ready tocopy the bootloaders and the distro's file into them. Here are the commands:

$ sudo mkdir /media/boot$ sudo mkdir /media/rootfs$ sudo mount /dev/sdX1 /media/boot$ sudo mount /dev/sdX2 /media/rootfs

Then, we can install the newly compiled bootloaders:

$ sudo cp boot.bin /media/boot/$ sudo cp u-boot.img /media/boot/

This time, we don't need any configuration file for U-Boot (file uEnv.txt).

Now, it's time to compile the kernel.

然后,我们可以安装新的编译 bootloader:

Installing the Developing System

[ 52 ]

We can clear the current partition table using the following command:

$ sudo dd if=/dev/zero of=/dev/sdX bs=1M count=50

You should not forget to replace device /dev/sdX with the deviceassociated with the microSD plugged into your system and follow the nextsteps carefully. Otherwise, it may damage the host system!

Now, we can prepare the needed partitions for the root filesystem, which will be installed inthe upcoming sections. Here are the commands:

$ echo -e '1M,48M,0xE,*\n,,,-' | sudo sfdisk /dev/sdX$ sudo mkfs.vfat -F 16 -n BOOT /dev/sdX1$ sudo mkfs.ext4 -L rootfs /dev/sdX2

As already stated for the BeagleBone Black, we must notice that since themkfs.ext4 version 1.43, the metadata_csum and 64bit options areenabled by default. However, we need to make sure that they are disabled.Otherwise, U-Boot cannot boot from our ext4 partitions. If this is our case,we need to replace the preceding command with the following one:

$ sudo mkfs.ext4 -L rootfs -O ^metadata_csum,^64bit /dev/sdX2

Now, we can mount the newly created boot and rootfs partitions in order to be ready tocopy the bootloaders and the distro's file into them. Here are the commands:

$ sudo mkdir /media/boot$ sudo mkdir /media/rootfs$ sudo mount /dev/sdX1 /media/boot$ sudo mount /dev/sdX2 /media/rootfs

Then, we can install the newly compiled bootloaders:

$ sudo cp boot.bin /media/boot/$ sudo cp u-boot.img /media/boot/

This time, we don't need any configuration file for U-Boot (file uEnv.txt).

Now, it's time to compile the kernel.

注意:这一次,对于 U-Boot 不需要任何配置文件(uEnv.txt)。

现在,我们编译内核。

3. Linux 内核的设置同样的,内核资源可以从 Robert C. Nelson 那里下载。命令如下:

Installing the Developing System

[ 53 ]

Linux kernel for SAMA5D3 XplainedAgain, the kernel sources can be downloaded from Robert C. Nelson archives. Thecommand is shown here:

$ git clone https://github.com/RobertCNelson/armv7_devel

Then, we have to enter into the newly created directory and choose which version of thekernel we wish to use. Of course, we choose the same kernel release as we did earlier, andhere are the commands:

$ cd armv7_devel/$ git checkout origin/v4.4.x-sama5-armv7 -b v4.4.x-sama5-armv7

Now, we can redo the previous settings into the system.sh file, and then, we can start thecompilation using the following command:

$ ./build_kernel.sh

This step and the subsequent ones are time consuming and requirepatience, so you should take a cup of your preferred tea or coffee and justwait.

We should see that the correct cross-compiler is set and also see that the linux-stablerepository is correctly referenced. Here is what I get on my system:

$ ./build_kernel.sh+ Detected build host [Ubuntu 15.10]+ host: [x86_64]+ git HEAD commit: [cc996bf444c2fb5f3859c431fbc3b29fe9ba6877]-----------------------------scripts/gcc: Using: arm-linux-gnueabihf-gcc (Linaro GCC 5.3-2016.02) 5.3.1 20160113Copyright (C) 2015 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.-----------------------------CROSS_COMPILE=arm-linux-gnueabihf------------------------------scripts/git: Debug: LINUX_GIT is setup as: [/home/giometti/Projects/common/linux-stable].scripts/git: [url=https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git]From https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable

然后,我们进入新创建的目录,并选择我们希望使用的内核版本。当然,我们选择和

之前一样的内核版本,下面是命令:

Installing the Developing System

[ 53 ]

Linux kernel for SAMA5D3 XplainedAgain, the kernel sources can be downloaded from Robert C. Nelson archives. Thecommand is shown here:

$ git clone https://github.com/RobertCNelson/armv7_devel

Then, we have to enter into the newly created directory and choose which version of thekernel we wish to use. Of course, we choose the same kernel release as we did earlier, andhere are the commands:

$ cd armv7_devel/$ git checkout origin/v4.4.x-sama5-armv7 -b v4.4.x-sama5-armv7

Now, we can redo the previous settings into the system.sh file, and then, we can start thecompilation using the following command:

$ ./build_kernel.sh

This step and the subsequent ones are time consuming and requirepatience, so you should take a cup of your preferred tea or coffee and justwait.

We should see that the correct cross-compiler is set and also see that the linux-stablerepository is correctly referenced. Here is what I get on my system:

$ ./build_kernel.sh+ Detected build host [Ubuntu 15.10]+ host: [x86_64]+ git HEAD commit: [cc996bf444c2fb5f3859c431fbc3b29fe9ba6877]-----------------------------scripts/gcc: Using: arm-linux-gnueabihf-gcc (Linaro GCC 5.3-2016.02) 5.3.1 20160113Copyright (C) 2015 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.-----------------------------CROSS_COMPILE=arm-linux-gnueabihf------------------------------scripts/git: Debug: LINUX_GIT is setup as: [/home/giometti/Projects/common/linux-stable].scripts/git: [url=https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git]From https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable

现在,我们可以用这个 system.sh 文件执行之前的设置,命令如下,开始编译:

Page 27: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

第1章 开发系统的安装   27

Installing the Developing System

[ 53 ]

Linux kernel for SAMA5D3 XplainedAgain, the kernel sources can be downloaded from Robert C. Nelson archives. Thecommand is shown here:

$ git clone https://github.com/RobertCNelson/armv7_devel

Then, we have to enter into the newly created directory and choose which version of thekernel we wish to use. Of course, we choose the same kernel release as we did earlier, andhere are the commands:

$ cd armv7_devel/$ git checkout origin/v4.4.x-sama5-armv7 -b v4.4.x-sama5-armv7

Now, we can redo the previous settings into the system.sh file, and then, we can start thecompilation using the following command:

$ ./build_kernel.sh

This step and the subsequent ones are time consuming and requirepatience, so you should take a cup of your preferred tea or coffee and justwait.

We should see that the correct cross-compiler is set and also see that the linux-stablerepository is correctly referenced. Here is what I get on my system:

$ ./build_kernel.sh+ Detected build host [Ubuntu 15.10]+ host: [x86_64]+ git HEAD commit: [cc996bf444c2fb5f3859c431fbc3b29fe9ba6877]-----------------------------scripts/gcc: Using: arm-linux-gnueabihf-gcc (Linaro GCC 5.3-2016.02) 5.3.1 20160113Copyright (C) 2015 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.-----------------------------CROSS_COMPILE=arm-linux-gnueabihf------------------------------scripts/git: Debug: LINUX_GIT is setup as: [/home/giometti/Projects/common/linux-stable].scripts/git: [url=https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git]From https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable

注意:这一步需要时间和耐心,可以去喝杯咖啡然后慢慢等。

我们应该看到正确的交叉编译器被设置,并且看到 Linux 的库被正确引用。以下是我

电脑显示的:

Installing the Developing System

[ 53 ]

Linux kernel for SAMA5D3 XplainedAgain, the kernel sources can be downloaded from Robert C. Nelson archives. Thecommand is shown here:

$ git clone https://github.com/RobertCNelson/armv7_devel

Then, we have to enter into the newly created directory and choose which version of thekernel we wish to use. Of course, we choose the same kernel release as we did earlier, andhere are the commands:

$ cd armv7_devel/$ git checkout origin/v4.4.x-sama5-armv7 -b v4.4.x-sama5-armv7

Now, we can redo the previous settings into the system.sh file, and then, we can start thecompilation using the following command:

$ ./build_kernel.sh

This step and the subsequent ones are time consuming and requirepatience, so you should take a cup of your preferred tea or coffee and justwait.

We should see that the correct cross-compiler is set and also see that the linux-stablerepository is correctly referenced. Here is what I get on my system:

$ ./build_kernel.sh+ Detected build host [Ubuntu 15.10]+ host: [x86_64]+ git HEAD commit: [cc996bf444c2fb5f3859c431fbc3b29fe9ba6877]-----------------------------scripts/gcc: Using: arm-linux-gnueabihf-gcc (Linaro GCC 5.3-2016.02) 5.3.1 20160113Copyright (C) 2015 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.-----------------------------CROSS_COMPILE=arm-linux-gnueabihf------------------------------scripts/git: Debug: LINUX_GIT is setup as: [/home/giometti/Projects/common/linux-stable].scripts/git: [url=https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git]From https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable

Installing the Developing System

[ 53 ]

Linux kernel for SAMA5D3 XplainedAgain, the kernel sources can be downloaded from Robert C. Nelson archives. Thecommand is shown here:

$ git clone https://github.com/RobertCNelson/armv7_devel

Then, we have to enter into the newly created directory and choose which version of thekernel we wish to use. Of course, we choose the same kernel release as we did earlier, andhere are the commands:

$ cd armv7_devel/$ git checkout origin/v4.4.x-sama5-armv7 -b v4.4.x-sama5-armv7

Now, we can redo the previous settings into the system.sh file, and then, we can start thecompilation using the following command:

$ ./build_kernel.sh

This step and the subsequent ones are time consuming and requirepatience, so you should take a cup of your preferred tea or coffee and justwait.

We should see that the correct cross-compiler is set and also see that the linux-stablerepository is correctly referenced. Here is what I get on my system:

$ ./build_kernel.sh+ Detected build host [Ubuntu 15.10]+ host: [x86_64]+ git HEAD commit: [cc996bf444c2fb5f3859c431fbc3b29fe9ba6877]-----------------------------scripts/gcc: Using: arm-linux-gnueabihf-gcc (Linaro GCC 5.3-2016.02) 5.3.1 20160113Copyright (C) 2015 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.-----------------------------CROSS_COMPILE=arm-linux-gnueabihf------------------------------scripts/git: Debug: LINUX_GIT is setup as: [/home/giometti/Projects/common/linux-stable].scripts/git: [url=https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git]From https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable

Installing the Developing System

[ 54 ]

* branch HEAD -> FETCH_HEAD-----------------------------Cloning into '/home/giometti/Projects/A5D3/armv7_devel/KERNEL'...done....

After a while, the classic kernel configuration panel should appear, but this time, we shouldchange the default configuration. In particular, we wish to change the USB Gadget settingsas shown in the following screenshot:

等一阵子之后,我们应该可以看到经典的内核配置,不过这一次我们要改变默认配置。

特别是,我们要改变 USB Gadget 的设置,如下所示:

Page 28: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

28   第一部分 基 础 知 识

然后保存配置并继续。当结束时,我们将看到如下消息:

Installing the Developing System

[ 55 ]

Then, save the configuration and continue. When finished, we should see several messagesas shown here:

...-----------------------------'arch/arm/boot/zImage' -> '/home/giometti/Projects/A5D3/armv7_devel/deploy/4.4.6-sama5-armv7-r5.zImage''.config' -> '/home/giometti/Projects/A5D3/armv7_devel/deploy/config-4.4.6-sama5-armv7-r5'-rwxrwxr-x 1 giometti giometti 3,7M apr 15 20:19 /home/giometti/Projects/A5D3/armv7_devel/deploy/4.4.6-sama5-armv7-r5.zImage-----------------------------Building modules archive...Compressing 4.4.6-sama5-armv7-r5-modules.tar.gz...-rw-rw-r-- 1 giometti giometti 328K apr 15 20:19 /home/giometti/Projects/A5D3/armv7_devel/deploy/4.4.6-sama5-armv7-r5-modules.tar.gz-----------------------------Building firmware archive...Compressing 4.4.6-sama5-armv7-r5-firmware.tar.gz...-rw-rw-r-- 1 giometti giometti 1,2M apr 15 20:19 /home/giometti/Projects/A5D3/armv7_devel/deploy/4.4.6-sama5-armv7-r5-firmware.tar.gz-----------------------------Building dtbs archive...Compressing 4.4.6-sama5-armv7-r5-dtbs.tar.gz...-rw-rw-r-- 1 giometti giometti 64K apr 15 20:19 /home/giometti/Projects/A5D3/armv7_devel/deploy/4.4.6-sama5-armv7-r5-dtbs.tar.gz-----------------------------Script Completeeewiki.net: [user@localhost:~$ export kernel_version=4.4.6-sama5-armv7-r5]-----------------------------

Now, we should install the kernel, but just as we did earlier, we need the root filesystem.So, let's move to the next subsection.

Installing the Developing System

[ 55 ]

Then, save the configuration and continue. When finished, we should see several messagesas shown here:

...-----------------------------'arch/arm/boot/zImage' -> '/home/giometti/Projects/A5D3/armv7_devel/deploy/4.4.6-sama5-armv7-r5.zImage''.config' -> '/home/giometti/Projects/A5D3/armv7_devel/deploy/config-4.4.6-sama5-armv7-r5'-rwxrwxr-x 1 giometti giometti 3,7M apr 15 20:19 /home/giometti/Projects/A5D3/armv7_devel/deploy/4.4.6-sama5-armv7-r5.zImage-----------------------------Building modules archive...Compressing 4.4.6-sama5-armv7-r5-modules.tar.gz...-rw-rw-r-- 1 giometti giometti 328K apr 15 20:19 /home/giometti/Projects/A5D3/armv7_devel/deploy/4.4.6-sama5-armv7-r5-modules.tar.gz-----------------------------Building firmware archive...Compressing 4.4.6-sama5-armv7-r5-firmware.tar.gz...-rw-rw-r-- 1 giometti giometti 1,2M apr 15 20:19 /home/giometti/Projects/A5D3/armv7_devel/deploy/4.4.6-sama5-armv7-r5-firmware.tar.gz-----------------------------Building dtbs archive...Compressing 4.4.6-sama5-armv7-r5-dtbs.tar.gz...-rw-rw-r-- 1 giometti giometti 64K apr 15 20:19 /home/giometti/Projects/A5D3/armv7_devel/deploy/4.4.6-sama5-armv7-r5-dtbs.tar.gz-----------------------------Script Completeeewiki.net: [user@localhost:~$ export kernel_version=4.4.6-sama5-armv7-r5]-----------------------------

Now, we should install the kernel, but just as we did earlier, we need the root filesystem.So, let's move to the next subsection.

现在,我们要安装内核,但正如我们之前所做的一样,我们需要根文件系统。所以让

我们转到下一个小节。

4. Debian 8 系统的设置我们可以用和 BeagleBone Black 一样的之前下载好的文件系统,所以先把它复制到

microSD:

Installing the Developing System

[ 56 ]

Debian 8 (jessie) for SAMA5D3 XplainedLike rootfs we can use the one already downloaded for the BeagleBone Black, so let's copy itinto the microSD:

$ cd common/debian-8.4-minimal-armhf-2016-04-02/$ sudo tar xpf armhf-rootfs-debian-jessie.tar -C /media/rootfs/

We have already mounted the microSD into /media/rootfs.

When finished, we can add the kernel image and the related files:

$ cd A5D3/armv7_devel$ sudo cp deploy/4.4.6-sama5-armv7-r5.zImage /media/boot/zImage$ sudo mkdir -p /media/boot/dtbs/$ sudo tar xf deploy/4.4.6-sama5-armv7-r5-dtbs.tar.gz -C /media/boot/dtbs/$ sudo tar xf deploy/4.4.6-sama5-armv7-r5-modules.tar.gz -C /media/rootfs/

Now, to finish the job, we must set up the filesystem table using the following commands:

$ sudo sh -c "echo '/dev/mmcblk0p2 / auto errors=remount-ro 0 1' > /media/rootfs/etc/fstab"$ sudo sh -c "echo '/dev/mmcblk0p1 /boot/uboot auto defaults 0 2' >> /media/rootfs/etc/fstab"

Also set up the networking configuration by executing the following commands:

$ sudo sh -c "echo 'allow-hotplug lo\niface lo inet loopback\n' > /media/rootfs/etc/network/interfaces"$ sudo sh -c "echo 'allow-hotplug eth0\niface eth0 inet dhcp\n' >> /media/rootfs/etc/network/interfaces"$ sudo sh -c "echo 'allow-hotplug eth1\niface eth1 inet dhcp' >> /media/rootfs/etc/network/interfaces"

Now, we should be ready to boot our new system! Let's unmount the microSD from thehost PC, plug it into the SAMA5D3 Xplained, and power on the board. The umountcommand lines are shown here:

$ sudo umount /media/boot/$ sudo umount /media/rootfs/

注意:我们已经把 microSD 挂载到 /media/rootfs。

完成后,就可以添加内核映像和相关文件:

Installing the Developing System

[ 56 ]

Debian 8 (jessie) for SAMA5D3 XplainedLike rootfs we can use the one already downloaded for the BeagleBone Black, so let's copy itinto the microSD:

$ cd common/debian-8.4-minimal-armhf-2016-04-02/$ sudo tar xpf armhf-rootfs-debian-jessie.tar -C /media/rootfs/

We have already mounted the microSD into /media/rootfs.

When finished, we can add the kernel image and the related files:

$ cd A5D3/armv7_devel$ sudo cp deploy/4.4.6-sama5-armv7-r5.zImage /media/boot/zImage$ sudo mkdir -p /media/boot/dtbs/$ sudo tar xf deploy/4.4.6-sama5-armv7-r5-dtbs.tar.gz -C /media/boot/dtbs/$ sudo tar xf deploy/4.4.6-sama5-armv7-r5-modules.tar.gz -C /media/rootfs/

Now, to finish the job, we must set up the filesystem table using the following commands:

$ sudo sh -c "echo '/dev/mmcblk0p2 / auto errors=remount-ro 0 1' > /media/rootfs/etc/fstab"$ sudo sh -c "echo '/dev/mmcblk0p1 /boot/uboot auto defaults 0 2' >> /media/rootfs/etc/fstab"

Also set up the networking configuration by executing the following commands:

$ sudo sh -c "echo 'allow-hotplug lo\niface lo inet loopback\n' > /media/rootfs/etc/network/interfaces"$ sudo sh -c "echo 'allow-hotplug eth0\niface eth0 inet dhcp\n' >> /media/rootfs/etc/network/interfaces"$ sudo sh -c "echo 'allow-hotplug eth1\niface eth1 inet dhcp' >> /media/rootfs/etc/network/interfaces"

Now, we should be ready to boot our new system! Let's unmount the microSD from thehost PC, plug it into the SAMA5D3 Xplained, and power on the board. The umountcommand lines are shown here:

$ sudo umount /media/boot/$ sudo umount /media/rootfs/

现在,要完成这项工作,我们必须使用以下命令建立文件系统表:

Page 29: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

第1章 开发系统的安装   29

Installing the Developing System

[ 56 ]

Debian 8 (jessie) for SAMA5D3 XplainedLike rootfs we can use the one already downloaded for the BeagleBone Black, so let's copy itinto the microSD:

$ cd common/debian-8.4-minimal-armhf-2016-04-02/$ sudo tar xpf armhf-rootfs-debian-jessie.tar -C /media/rootfs/

We have already mounted the microSD into /media/rootfs.

When finished, we can add the kernel image and the related files:

$ cd A5D3/armv7_devel$ sudo cp deploy/4.4.6-sama5-armv7-r5.zImage /media/boot/zImage$ sudo mkdir -p /media/boot/dtbs/$ sudo tar xf deploy/4.4.6-sama5-armv7-r5-dtbs.tar.gz -C /media/boot/dtbs/$ sudo tar xf deploy/4.4.6-sama5-armv7-r5-modules.tar.gz -C /media/rootfs/

Now, to finish the job, we must set up the filesystem table using the following commands:

$ sudo sh -c "echo '/dev/mmcblk0p2 / auto errors=remount-ro 0 1' > /media/rootfs/etc/fstab"$ sudo sh -c "echo '/dev/mmcblk0p1 /boot/uboot auto defaults 0 2' >> /media/rootfs/etc/fstab"

Also set up the networking configuration by executing the following commands:

$ sudo sh -c "echo 'allow-hotplug lo\niface lo inet loopback\n' > /media/rootfs/etc/network/interfaces"$ sudo sh -c "echo 'allow-hotplug eth0\niface eth0 inet dhcp\n' >> /media/rootfs/etc/network/interfaces"$ sudo sh -c "echo 'allow-hotplug eth1\niface eth1 inet dhcp' >> /media/rootfs/etc/network/interfaces"

Now, we should be ready to boot our new system! Let's unmount the microSD from thehost PC, plug it into the SAMA5D3 Xplained, and power on the board. The umountcommand lines are shown here:

$ sudo umount /media/boot/$ sudo umount /media/rootfs/

再通过执行下列命令来设置网络配置:

Installing the Developing System

[ 56 ]

Debian 8 (jessie) for SAMA5D3 XplainedLike rootfs we can use the one already downloaded for the BeagleBone Black, so let's copy itinto the microSD:

$ cd common/debian-8.4-minimal-armhf-2016-04-02/$ sudo tar xpf armhf-rootfs-debian-jessie.tar -C /media/rootfs/

We have already mounted the microSD into /media/rootfs.

When finished, we can add the kernel image and the related files:

$ cd A5D3/armv7_devel$ sudo cp deploy/4.4.6-sama5-armv7-r5.zImage /media/boot/zImage$ sudo mkdir -p /media/boot/dtbs/$ sudo tar xf deploy/4.4.6-sama5-armv7-r5-dtbs.tar.gz -C /media/boot/dtbs/$ sudo tar xf deploy/4.4.6-sama5-armv7-r5-modules.tar.gz -C /media/rootfs/

Now, to finish the job, we must set up the filesystem table using the following commands:

$ sudo sh -c "echo '/dev/mmcblk0p2 / auto errors=remount-ro 0 1' > /media/rootfs/etc/fstab"$ sudo sh -c "echo '/dev/mmcblk0p1 /boot/uboot auto defaults 0 2' >> /media/rootfs/etc/fstab"

Also set up the networking configuration by executing the following commands:

$ sudo sh -c "echo 'allow-hotplug lo\niface lo inet loopback\n' > /media/rootfs/etc/network/interfaces"$ sudo sh -c "echo 'allow-hotplug eth0\niface eth0 inet dhcp\n' >> /media/rootfs/etc/network/interfaces"$ sudo sh -c "echo 'allow-hotplug eth1\niface eth1 inet dhcp' >> /media/rootfs/etc/network/interfaces"

Now, we should be ready to boot our new system! Let's unmount the microSD from thehost PC, plug it into the SAMA5D3 Xplained, and power on the board. The umountcommand lines are shown here:

$ sudo umount /media/boot/$ sudo umount /media/rootfs/

现在,我们可以启动我们的新系统了!从主机 PC 把 microSD 卸载了,然后插入

SAMA5D3 Xplained 中,启动主板。umount 命令行如下所示:

Installing the Developing System

[ 56 ]

Debian 8 (jessie) for SAMA5D3 XplainedLike rootfs we can use the one already downloaded for the BeagleBone Black, so let's copy itinto the microSD:

$ cd common/debian-8.4-minimal-armhf-2016-04-02/$ sudo tar xpf armhf-rootfs-debian-jessie.tar -C /media/rootfs/

We have already mounted the microSD into /media/rootfs.

When finished, we can add the kernel image and the related files:

$ cd A5D3/armv7_devel$ sudo cp deploy/4.4.6-sama5-armv7-r5.zImage /media/boot/zImage$ sudo mkdir -p /media/boot/dtbs/$ sudo tar xf deploy/4.4.6-sama5-armv7-r5-dtbs.tar.gz -C /media/boot/dtbs/$ sudo tar xf deploy/4.4.6-sama5-armv7-r5-modules.tar.gz -C /media/rootfs/

Now, to finish the job, we must set up the filesystem table using the following commands:

$ sudo sh -c "echo '/dev/mmcblk0p2 / auto errors=remount-ro 0 1' > /media/rootfs/etc/fstab"$ sudo sh -c "echo '/dev/mmcblk0p1 /boot/uboot auto defaults 0 2' >> /media/rootfs/etc/fstab"

Also set up the networking configuration by executing the following commands:

$ sudo sh -c "echo 'allow-hotplug lo\niface lo inet loopback\n' > /media/rootfs/etc/network/interfaces"$ sudo sh -c "echo 'allow-hotplug eth0\niface eth0 inet dhcp\n' >> /media/rootfs/etc/network/interfaces"$ sudo sh -c "echo 'allow-hotplug eth1\niface eth1 inet dhcp' >> /media/rootfs/etc/network/interfaces"

Now, we should be ready to boot our new system! Let's unmount the microSD from thehost PC, plug it into the SAMA5D3 Xplained, and power on the board. The umountcommand lines are shown here:

$ sudo umount /media/boot/$ sudo umount /media/rootfs/

如果在串口控制台上一切正常,我们就应该看到如下信息显示:

Installing the Developing System

[ 57 ]

If everything works well on the serial console, we should see something as shown here:

RomBOOT

U-Boot SPL 2016.03-dirty (Apr 15 2016 - 19:51:18)Trying to boot from MMCreading u-boot.imgreading u-boot.img

U-Boot 2016.03-dirty (Apr 15 2016 - 19:51:18 +0200)

CPU: SAMA5D36Crystal frequency: 12 MHzCPU clock : 528 MHzMaster clock : 132 MHzDRAM: 256 MiBNAND: 256 MiBMMC: mci: 0...reading /dtbs/at91-sama5d3_xplained.dtb34694 bytes read in 10 ms (3.3 MiB/s)reading zImage3832792 bytes read in 245 ms (14.9 MiB/s)Kernel image @ 0x22000000 [ 0x000000 - 0x3a7bd8 ]## Flattened Device Tree blob at 21000000 Booting using the fdt blob at 0x21000000 Loading Device Tree to 2fadc000, end 2fae7785 ... OK

Starting kernel ...

[ 0.000000] Booting Linux on physical CPU 0x0...[ 2.170000] random: systemd urandom read with 11 bits of entropy available[ 2.180000] systemd[1]: systemd 215 running in system mode. (+PAM +AUDIT +SELINUX +IMA +SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ -SECCOMP -APPARMOR)[ 2.190000] systemd[1]: Detected architecture 'arm'.

Welcome to Debian GNU/Linux 8 (jessie)!

[ 2.240000] systemd[1]: Set hostname to <arm>.[ 2.790000] systemd[1]: Cannot add dependency job for unit display-manager.se... Starting Update UTMP about System Runlevel Changes...[ OK ] Started Update UTMP about System Runlevel Changes.

Page 30: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

30   第一部分 基 础 知 识

Installing the Developing System

[ 57 ]

If everything works well on the serial console, we should see something as shown here:

RomBOOT

U-Boot SPL 2016.03-dirty (Apr 15 2016 - 19:51:18)Trying to boot from MMCreading u-boot.imgreading u-boot.img

U-Boot 2016.03-dirty (Apr 15 2016 - 19:51:18 +0200)

CPU: SAMA5D36Crystal frequency: 12 MHzCPU clock : 528 MHzMaster clock : 132 MHzDRAM: 256 MiBNAND: 256 MiBMMC: mci: 0...reading /dtbs/at91-sama5d3_xplained.dtb34694 bytes read in 10 ms (3.3 MiB/s)reading zImage3832792 bytes read in 245 ms (14.9 MiB/s)Kernel image @ 0x22000000 [ 0x000000 - 0x3a7bd8 ]## Flattened Device Tree blob at 21000000 Booting using the fdt blob at 0x21000000 Loading Device Tree to 2fadc000, end 2fae7785 ... OK

Starting kernel ...

[ 0.000000] Booting Linux on physical CPU 0x0...[ 2.170000] random: systemd urandom read with 11 bits of entropy available[ 2.180000] systemd[1]: systemd 215 running in system mode. (+PAM +AUDIT +SELINUX +IMA +SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ -SECCOMP -APPARMOR)[ 2.190000] systemd[1]: Detected architecture 'arm'.

Welcome to Debian GNU/Linux 8 (jessie)!

[ 2.240000] systemd[1]: Set hostname to <arm>.[ 2.790000] systemd[1]: Cannot add dependency job for unit display-manager.se... Starting Update UTMP about System Runlevel Changes...[ OK ] Started Update UTMP about System Runlevel Changes.

Installing the Developing System

[ 58 ]

Debian GNU/Linux 8 arm ttyS0

default username:password is [debian:temppwd]

arm login:

Great! Everything is working now. We can log in by entering the root string as bothusername and password.

Setting up the WandboardThis has no pre-loaded distribution. So, as done for the previous boards, we will install afresh Debian OS on a microSD card.

Serial console for the WandboardLike the other boards presented in this book, the Wandboard has the COM1 connectorwhere the serial console pins are exposed. However, in this case, the port is a a standardRS-232 port. So, we don't have the TTL level signal! What we can do now is just connect theCOM1 port to our host PC serial port through a null modem cable (a serial cable where theTxD and RxD signals are crossed) or use a USB-to-RS232 adapter and then connect thisdevice to the null modem cable.

The relevant pins are reported in the following table, and just as you did earlier, you haveto connect the GND signal with the adapter's GND pin and then swap the TxD and RxD tocorrectly establish the serial connection.

COM1 Function

Pin 5 GND

Pin 2 TXD

Pin 3 RXD

很好 ! 现在一切就绪。我们可以输入 root 作为用户名和密码登录。

1.3.4 设置 Wandboard 开发平台

这个没有预装发行版系统。所以,相比于之前的主板,我们将在 microSD 卡安装新的

Debian 操作系统。

1. 串口控制台的设置像本书中的其他主板一样, wandboard 有一个 COM1 连接口,它的串口引脚露在外面。

然而,这种情况是用一个标准的 RS-232 端口。所以我们没有 TTL 电平信号!我们要做的

就是通过零调制解调器连接 COM1 端口到我们的主机 PC 机(串行电缆,TxD 和 RxD 信号

交叉),或者使用 USB-to-RS232 适配器和连接到零调制解调器。

相关引脚如下表所示,和之前做的一样,将 GND 信号线接到适配器的 GND 引脚上,

然后交换 TxD 和 RxD 使得其连接正确。

COM1 功能

Pin 5 GND

Pin 2 TxD

Pin 3 RxD

标准的 RS-232 9-pins 连接器如下图所示:

Page 31: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

第1章 开发系统的安装   31

下面这个图像是我自己的设置(用了三个适配器:两个转换器和一个调制解调器):

现在,让我们来在 WindBoard 上安装软件然后开始工作。

2. U-Boot(基于 SPL)的设置

为了获得 bootloader 的资源,我们可以使用和之前主板一样的系统,所以我们只需要

复制一个新的系统,命令如下:

Installing the Developing System

[ 59 ]

In the next image, the pin out of a standard RS-232 9-pins connector is shown:

This image is my setup (where we used three adapters: two genders changers and one nullmodem):

Now, let's install the software to start working with our WindBoard board.

U-Boot (with SPL)To obtain the bootloader's sources, we can use the same trick used for the other boards, sowe just need to clone a new one with the following command:

$ git clone --reference ~/Projects/common/u-boot.git https://github.com/u-boot/u-boot

现在,我们进入新创建的目录,检查 U-Boot 的版本。命令如下:

Installing the Developing System

[ 60 ]

Now, let's go into the newly created directory and check out a proper U-boot release to use.Here are the commands used:

$ cd u-boot$ git checkout v2016.03 -b v2016.03

Here are the patches for the Wandboard:

$ wget -c https://rcn-ee.com/repos/git/u-boot-patches/v2016.03/0001-wandboard-uEnv.txt-bootz-n-fixes.patch$ patch -p1 < 0001-wandboard-uEnv.txt-bootz-n-fixes.patch

Now, we're ready to compile. Let's do it using the following commands:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- wandboard_defconfig$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

Now, let's install the bootloader into the microSD.

As done earlier, we have to discover the device associated with themicroSD (see the BeagleBone Black or SAMA5D3 Xplained subsections).On my system, the device is still /dev/sdd.In this case, we used a 16 GB microSD since we're going to install a lot ofsoftware on this board!

Now, we can clear the current partition table using the following command:

$ sudo dd if=/dev/zero of=/dev/sdX bs=1M count=10

You must not forget to replace device /dev/sdX with the deviceassociated with the microSD plugged into your system and follow the nextsteps carefully. Otherwise, it may damage the host system!

Then, we can install the newly compiled bootloaders:

$ sudo dd if=SPL of=/dev/sdX seek=1 bs=1k$ sudo dd if=u-boot.img of=/dev/sdX seek=69 bs=1k

这些是 WandBoard 的补丁:

Installing the Developing System

[ 60 ]

Now, let's go into the newly created directory and check out a proper U-boot release to use.Here are the commands used:

$ cd u-boot$ git checkout v2016.03 -b v2016.03

Here are the patches for the Wandboard:

$ wget -c https://rcn-ee.com/repos/git/u-boot-patches/v2016.03/0001-wandboard-uEnv.txt-bootz-n-fixes.patch$ patch -p1 < 0001-wandboard-uEnv.txt-bootz-n-fixes.patch

Now, we're ready to compile. Let's do it using the following commands:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- wandboard_defconfig$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

Now, let's install the bootloader into the microSD.

As done earlier, we have to discover the device associated with themicroSD (see the BeagleBone Black or SAMA5D3 Xplained subsections).On my system, the device is still /dev/sdd.In this case, we used a 16 GB microSD since we're going to install a lot ofsoftware on this board!

Now, we can clear the current partition table using the following command:

$ sudo dd if=/dev/zero of=/dev/sdX bs=1M count=10

You must not forget to replace device /dev/sdX with the deviceassociated with the microSD plugged into your system and follow the nextsteps carefully. Otherwise, it may damage the host system!

Then, we can install the newly compiled bootloaders:

$ sudo dd if=SPL of=/dev/sdX seek=1 bs=1k$ sudo dd if=u-boot.img of=/dev/sdX seek=69 bs=1k

现在,我们准备编译。命令如下:

Installing the Developing System

[ 60 ]

Now, let's go into the newly created directory and check out a proper U-boot release to use.Here are the commands used:

$ cd u-boot$ git checkout v2016.03 -b v2016.03

Here are the patches for the Wandboard:

$ wget -c https://rcn-ee.com/repos/git/u-boot-patches/v2016.03/0001-wandboard-uEnv.txt-bootz-n-fixes.patch$ patch -p1 < 0001-wandboard-uEnv.txt-bootz-n-fixes.patch

Now, we're ready to compile. Let's do it using the following commands:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- wandboard_defconfig$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

Now, let's install the bootloader into the microSD.

As done earlier, we have to discover the device associated with themicroSD (see the BeagleBone Black or SAMA5D3 Xplained subsections).On my system, the device is still /dev/sdd.In this case, we used a 16 GB microSD since we're going to install a lot ofsoftware on this board!

Now, we can clear the current partition table using the following command:

$ sudo dd if=/dev/zero of=/dev/sdX bs=1M count=10

You must not forget to replace device /dev/sdX with the deviceassociated with the microSD plugged into your system and follow the nextsteps carefully. Otherwise, it may damage the host system!

Then, we can install the newly compiled bootloaders:

$ sudo dd if=SPL of=/dev/sdX seek=1 bs=1k$ sudo dd if=u-boot.img of=/dev/sdX seek=69 bs=1k

现在我们把 bootloader 装到 microSD。

注意:做的时候,我们要找到与 microSD 卡相关的设备(前面部分有说明)。在我

的系统中,该设备仍然是 /dev/SDD 这个设备。这时候,我们最好使用一个 16GB的 microSD,因为我们要在主板上安装很多软件!

现在,我们可以使用以下命令清除当前分区表:

Installing the Developing System

[ 60 ]

Now, let's go into the newly created directory and check out a proper U-boot release to use.Here are the commands used:

$ cd u-boot$ git checkout v2016.03 -b v2016.03

Here are the patches for the Wandboard:

$ wget -c https://rcn-ee.com/repos/git/u-boot-patches/v2016.03/0001-wandboard-uEnv.txt-bootz-n-fixes.patch$ patch -p1 < 0001-wandboard-uEnv.txt-bootz-n-fixes.patch

Now, we're ready to compile. Let's do it using the following commands:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- wandboard_defconfig$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

Now, let's install the bootloader into the microSD.

As done earlier, we have to discover the device associated with themicroSD (see the BeagleBone Black or SAMA5D3 Xplained subsections).On my system, the device is still /dev/sdd.In this case, we used a 16 GB microSD since we're going to install a lot ofsoftware on this board!

Now, we can clear the current partition table using the following command:

$ sudo dd if=/dev/zero of=/dev/sdX bs=1M count=10

You must not forget to replace device /dev/sdX with the deviceassociated with the microSD plugged into your system and follow the nextsteps carefully. Otherwise, it may damage the host system!

Then, we can install the newly compiled bootloaders:

$ sudo dd if=SPL of=/dev/sdX seek=1 bs=1k$ sudo dd if=u-boot.img of=/dev/sdX seek=69 bs=1k

Page 32: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

32   第一部分 基 础 知 识

注意:一定记住要将与 /dev/sdX 相关的 microSD 插入你主板中,并仔细地按照下

面的步骤执行,不然可能会损坏主机系统!

然后,我们可以安装新编译 bootloader:

Installing the Developing System

[ 60 ]

Now, let's go into the newly created directory and check out a proper U-boot release to use.Here are the commands used:

$ cd u-boot$ git checkout v2016.03 -b v2016.03

Here are the patches for the Wandboard:

$ wget -c https://rcn-ee.com/repos/git/u-boot-patches/v2016.03/0001-wandboard-uEnv.txt-bootz-n-fixes.patch$ patch -p1 < 0001-wandboard-uEnv.txt-bootz-n-fixes.patch

Now, we're ready to compile. Let's do it using the following commands:

$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- wandboard_defconfig$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

Now, let's install the bootloader into the microSD.

As done earlier, we have to discover the device associated with themicroSD (see the BeagleBone Black or SAMA5D3 Xplained subsections).On my system, the device is still /dev/sdd.In this case, we used a 16 GB microSD since we're going to install a lot ofsoftware on this board!

Now, we can clear the current partition table using the following command:

$ sudo dd if=/dev/zero of=/dev/sdX bs=1M count=10

You must not forget to replace device /dev/sdX with the deviceassociated with the microSD plugged into your system and follow the nextsteps carefully. Otherwise, it may damage the host system!

Then, we can install the newly compiled bootloaders:

$ sudo dd if=SPL of=/dev/sdX seek=1 bs=1k$ sudo dd if=u-boot.img of=/dev/sdX seek=69 bs=1k

现在,我们为根文件系统准备所需的分区,下面会安装,命令如下:

Installing the Developing System

[ 61 ]

Now, we can prepare the needed partition for the root filesystem, which will be installed inthe upcoming sections. The commands are shown here:

$ echo '1M,,L,*' | sudo sfdisk /dev/sdX$ sudo mkfs.ext4 -L rootfs /dev/sdX1

As already stated for the other boards, we must notice that since themkfs.ext4 version 1.43, the metadata_csum and 64bit options areenabled by default. However, we need to make sure that they are disabled.Otherwise, U-Boot cannot boot from our ext4 partitions. If this is our case,we need to replace the preceding command with the following one:

$ sudo mkfs.ext4 -L rootfs -O ^metadata_csum,^64bit /dev/sdX1

Now, we can mount the newly created boot and rootfs partition as done earlier. Here arethe commands:

$ sudo mkdir /media/rootfs$ sudo mount /dev/sdX1 /media/rootfs

Then, as done for the SAMA5D3 Xplained, we don't define an environment file uEnv.txtright now, but we will define it later since, in contrast to SAMA5D3 Xplained, we need it.

Now, it's time to compile the kernel.

Linux kernel for the WandboardThe kernel sources are still the ones from Robert C. Nelson archives. The command isshown here:

$ git clone https://github.com/RobertCNelson/armv7-multiplatform

Then, we have to enter into the newly created directory and choose which version of thekernel we wish to use. Of course, we choose the same kernel release as the one mentionedearlier, and the commands are shown here:

$ cd armv7-multiplatform/$ git checkout origin/v4.4.x -b v4.4.x

提示:因为在 mkfs.ext4 1.43 的版本中,选项中 metadata_csum 和 64 位是默认开启

的。然而,我们需要确保它们被禁用;否则 U-Boot 就不能从 ext4 的分区中启动。

如果是这种情况,就需要用下面的命令替换前面的命令:

Installing the Developing System

[ 61 ]

Now, we can prepare the needed partition for the root filesystem, which will be installed inthe upcoming sections. The commands are shown here:

$ echo '1M,,L,*' | sudo sfdisk /dev/sdX$ sudo mkfs.ext4 -L rootfs /dev/sdX1

As already stated for the other boards, we must notice that since themkfs.ext4 version 1.43, the metadata_csum and 64bit options areenabled by default. However, we need to make sure that they are disabled.Otherwise, U-Boot cannot boot from our ext4 partitions. If this is our case,we need to replace the preceding command with the following one:

$ sudo mkfs.ext4 -L rootfs -O ^metadata_csum,^64bit /dev/sdX1

Now, we can mount the newly created boot and rootfs partition as done earlier. Here arethe commands:

$ sudo mkdir /media/rootfs$ sudo mount /dev/sdX1 /media/rootfs

Then, as done for the SAMA5D3 Xplained, we don't define an environment file uEnv.txtright now, but we will define it later since, in contrast to SAMA5D3 Xplained, we need it.

Now, it's time to compile the kernel.

Linux kernel for the WandboardThe kernel sources are still the ones from Robert C. Nelson archives. The command isshown here:

$ git clone https://github.com/RobertCNelson/armv7-multiplatform

Then, we have to enter into the newly created directory and choose which version of thekernel we wish to use. Of course, we choose the same kernel release as the one mentionedearlier, and the commands are shown here:

$ cd armv7-multiplatform/$ git checkout origin/v4.4.x -b v4.4.x

现在,我们将设备挂载到新创建的目录中。命令如下:

Installing the Developing System

[ 61 ]

Now, we can prepare the needed partition for the root filesystem, which will be installed inthe upcoming sections. The commands are shown here:

$ echo '1M,,L,*' | sudo sfdisk /dev/sdX$ sudo mkfs.ext4 -L rootfs /dev/sdX1

As already stated for the other boards, we must notice that since themkfs.ext4 version 1.43, the metadata_csum and 64bit options areenabled by default. However, we need to make sure that they are disabled.Otherwise, U-Boot cannot boot from our ext4 partitions. If this is our case,we need to replace the preceding command with the following one:

$ sudo mkfs.ext4 -L rootfs -O ^metadata_csum,^64bit /dev/sdX1

Now, we can mount the newly created boot and rootfs partition as done earlier. Here arethe commands:

$ sudo mkdir /media/rootfs$ sudo mount /dev/sdX1 /media/rootfs

Then, as done for the SAMA5D3 Xplained, we don't define an environment file uEnv.txtright now, but we will define it later since, in contrast to SAMA5D3 Xplained, we need it.

Now, it's time to compile the kernel.

Linux kernel for the WandboardThe kernel sources are still the ones from Robert C. Nelson archives. The command isshown here:

$ git clone https://github.com/RobertCNelson/armv7-multiplatform

Then, we have to enter into the newly created directory and choose which version of thekernel we wish to use. Of course, we choose the same kernel release as the one mentionedearlier, and the commands are shown here:

$ cd armv7-multiplatform/$ git checkout origin/v4.4.x -b v4.4.x

然后,像在 SAMA5D3 Xplained 上做的一样,我们没有定义 uenv.txt 这个文件,但之

后要定义,可以对比 SAMA5D3 Xplained 上面的操作,这个东西很重要。

现在该编译内核了。

3. Linux 内核的设置内核资源仍然是从 Robert C. Nelson 那里下载的。命令如下:

Installing the Developing System

[ 61 ]

Now, we can prepare the needed partition for the root filesystem, which will be installed inthe upcoming sections. The commands are shown here:

$ echo '1M,,L,*' | sudo sfdisk /dev/sdX$ sudo mkfs.ext4 -L rootfs /dev/sdX1

As already stated for the other boards, we must notice that since themkfs.ext4 version 1.43, the metadata_csum and 64bit options areenabled by default. However, we need to make sure that they are disabled.Otherwise, U-Boot cannot boot from our ext4 partitions. If this is our case,we need to replace the preceding command with the following one:

$ sudo mkfs.ext4 -L rootfs -O ^metadata_csum,^64bit /dev/sdX1

Now, we can mount the newly created boot and rootfs partition as done earlier. Here arethe commands:

$ sudo mkdir /media/rootfs$ sudo mount /dev/sdX1 /media/rootfs

Then, as done for the SAMA5D3 Xplained, we don't define an environment file uEnv.txtright now, but we will define it later since, in contrast to SAMA5D3 Xplained, we need it.

Now, it's time to compile the kernel.

Linux kernel for the WandboardThe kernel sources are still the ones from Robert C. Nelson archives. The command isshown here:

$ git clone https://github.com/RobertCNelson/armv7-multiplatform

Then, we have to enter into the newly created directory and choose which version of thekernel we wish to use. Of course, we choose the same kernel release as the one mentionedearlier, and the commands are shown here:

$ cd armv7-multiplatform/$ git checkout origin/v4.4.x -b v4.4.x

然后,我们进入新创建的目录,并选择我们希望使用的内核版本。当然,我们选择和

之前提到的相同的内核版本,命令如下:

Installing the Developing System

[ 61 ]

Now, we can prepare the needed partition for the root filesystem, which will be installed inthe upcoming sections. The commands are shown here:

$ echo '1M,,L,*' | sudo sfdisk /dev/sdX$ sudo mkfs.ext4 -L rootfs /dev/sdX1

As already stated for the other boards, we must notice that since themkfs.ext4 version 1.43, the metadata_csum and 64bit options areenabled by default. However, we need to make sure that they are disabled.Otherwise, U-Boot cannot boot from our ext4 partitions. If this is our case,we need to replace the preceding command with the following one:

$ sudo mkfs.ext4 -L rootfs -O ^metadata_csum,^64bit /dev/sdX1

Now, we can mount the newly created boot and rootfs partition as done earlier. Here arethe commands:

$ sudo mkdir /media/rootfs$ sudo mount /dev/sdX1 /media/rootfs

Then, as done for the SAMA5D3 Xplained, we don't define an environment file uEnv.txtright now, but we will define it later since, in contrast to SAMA5D3 Xplained, we need it.

Now, it's time to compile the kernel.

Linux kernel for the WandboardThe kernel sources are still the ones from Robert C. Nelson archives. The command isshown here:

$ git clone https://github.com/RobertCNelson/armv7-multiplatform

Then, we have to enter into the newly created directory and choose which version of thekernel we wish to use. Of course, we choose the same kernel release as the one mentionedearlier, and the commands are shown here:

$ cd armv7-multiplatform/$ git checkout origin/v4.4.x -b v4.4.x

现在,我们可以使用 system.sh 这个脚本恢复以前的设置,然后,我们可以使用下面的

命令开始编译:

Installing the Developing System

[ 62 ]

Now, we can redo the previous settings into the system.sh file, and then, we can start thecompilation using the following command:

$ ./build_kernel.sh

This step and the subsequent ones are time consuming and requirepatience, so you should take a cup of your preferred tea or coffee and justwait.

We should see that the correct cross-compiler is set and also see that the linux-stablerepository is correctly referenced. Here is what I get on my system:

$ ./build_kernel.sh+ Detected build host [Ubuntu 15.10]+ host: [x86_64]+ git HEAD commit: [44cd32b5f0ff74d2705541225c0d7cbdfb59bf50]-----------------------------scripts/gcc: Using: arm-linux-gnueabihf-gcc (Linaro GCC 5.3-2016.02) 5.3.1 20160113Copyright (C) 2015 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.-----------------------------CROSS_COMPILE=arm-linux-gnueabihf------------------------------scripts/git: Debug: LINUX_GIT is setup as: [/home/giometti/Projects/common/linux-stable].scripts/git: [url=https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git]From https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable * branch HEAD -> FETCH_HEAD-----------------------------Cloning into '/home/giometti/Projects/WB/armv7-multiplatform/KERNEL'...done....

After a while, the classic kernel configuration panel should appear. Just confirm the defaultsettings by selecting the < Exit > menu option and continue.

注意:这一步和随后的过程比较费时间和耐心,所以你可以去喝杯咖啡等待了。

我们应该看到正确的交叉编译器被设置,并且看到 Linux 的库被正确引用。以下是我

的系统:

Page 33: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

第1章 开发系统的安装   33

Installing the Developing System

[ 62 ]

Now, we can redo the previous settings into the system.sh file, and then, we can start thecompilation using the following command:

$ ./build_kernel.sh

This step and the subsequent ones are time consuming and requirepatience, so you should take a cup of your preferred tea or coffee and justwait.

We should see that the correct cross-compiler is set and also see that the linux-stablerepository is correctly referenced. Here is what I get on my system:

$ ./build_kernel.sh+ Detected build host [Ubuntu 15.10]+ host: [x86_64]+ git HEAD commit: [44cd32b5f0ff74d2705541225c0d7cbdfb59bf50]-----------------------------scripts/gcc: Using: arm-linux-gnueabihf-gcc (Linaro GCC 5.3-2016.02) 5.3.1 20160113Copyright (C) 2015 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.-----------------------------CROSS_COMPILE=arm-linux-gnueabihf------------------------------scripts/git: Debug: LINUX_GIT is setup as: [/home/giometti/Projects/common/linux-stable].scripts/git: [url=https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git]From https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable * branch HEAD -> FETCH_HEAD-----------------------------Cloning into '/home/giometti/Projects/WB/armv7-multiplatform/KERNEL'...done....

After a while, the classic kernel configuration panel should appear. Just confirm the defaultsettings by selecting the < Exit > menu option and continue.

等待一段时间后,经典的内核配置面板应该会出现。通过 < 退出 > 选项来配置默认设

置,然后继续。

之后,我们将看到如下消息:

Installing the Developing System

[ 63 ]

When finished, we should see several messages as shown here:

...-----------------------------'arch/arm/boot/zImage' -> '/home/giometti/Projects/WB/armv7-multiplatform/deploy/4.4.7-armv7-x6.zImage''.config' -> '/home/giometti/Projects/WB/armv7-multiplatform/deploy/config-4.4.7-armv7-x6'-rwxrwxr-x 1 giometti giometti 5,6M apr 17 18:46 /home/giometti/Projects/WB/armv7-multiplatform/deploy/4.4.7-armv7-x6.zImage-----------------------------Building modules archive...Compressing 4.4.7-armv7-x6-modules.tar.gz...-rw-rw-r-- 1 giometti giometti 89M apr 17 18:47 /home/giometti/Projects/WB/armv7-multiplatform/deploy/4.4.7-armv7-x6-modules.tar.gz-----------------------------Building firmware archive...Compressing 4.4.7-armv7-x6-firmware.tar.gz...-rw-rw-r-- 1 giometti giometti 1,2M apr 17 18:47 /home/giometti/Projects/WB/armv7-multiplatform/deploy/4.4.7-armv7-x6-firmware.tar.gz-----------------------------Building dtbs archive...Compressing 4.4.7-armv7-x6-dtbs.tar.gz...-rw-rw-r-- 1 giometti giometti 3,1M apr 17 18:47 /home/giometti/Projects/WB/armv7-multiplatform/deploy/4.4.7-armv7-x6-dtbs.tar.gz-----------------------------Script Completeeewiki.net: [user@localhost:~$ export kernel_version=4.4.7-armv7-x6]-----------------------------

The last line tells us which is the kernel version to be defined in the uEnv.txt file definedearlier when we installed the bootloaders. The command is shown here:

$ sudo sh -c 'echo "uname_r=4.4.7-armv7-x6" >> /media/rootfs/boot/uEnv.txt'

The /media/rootfs directory has been already mounted in the previoussection.

Installing the Developing System

[ 63 ]

When finished, we should see several messages as shown here:

...-----------------------------'arch/arm/boot/zImage' -> '/home/giometti/Projects/WB/armv7-multiplatform/deploy/4.4.7-armv7-x6.zImage''.config' -> '/home/giometti/Projects/WB/armv7-multiplatform/deploy/config-4.4.7-armv7-x6'-rwxrwxr-x 1 giometti giometti 5,6M apr 17 18:46 /home/giometti/Projects/WB/armv7-multiplatform/deploy/4.4.7-armv7-x6.zImage-----------------------------Building modules archive...Compressing 4.4.7-armv7-x6-modules.tar.gz...-rw-rw-r-- 1 giometti giometti 89M apr 17 18:47 /home/giometti/Projects/WB/armv7-multiplatform/deploy/4.4.7-armv7-x6-modules.tar.gz-----------------------------Building firmware archive...Compressing 4.4.7-armv7-x6-firmware.tar.gz...-rw-rw-r-- 1 giometti giometti 1,2M apr 17 18:47 /home/giometti/Projects/WB/armv7-multiplatform/deploy/4.4.7-armv7-x6-firmware.tar.gz-----------------------------Building dtbs archive...Compressing 4.4.7-armv7-x6-dtbs.tar.gz...-rw-rw-r-- 1 giometti giometti 3,1M apr 17 18:47 /home/giometti/Projects/WB/armv7-multiplatform/deploy/4.4.7-armv7-x6-dtbs.tar.gz-----------------------------Script Completeeewiki.net: [user@localhost:~$ export kernel_version=4.4.7-armv7-x6]-----------------------------

The last line tells us which is the kernel version to be defined in the uEnv.txt file definedearlier when we installed the bootloaders. The command is shown here:

$ sudo sh -c 'echo "uname_r=4.4.7-armv7-x6" >> /media/rootfs/boot/uEnv.txt'

The /media/rootfs directory has been already mounted in the previoussection.

Page 34: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

34   第一部分 基 础 知 识

最后一行告诉我们,当我们安装了 bootloader 的时候,uEnv.txt 这个文件会有内核版本

信息。命令如下:

Installing the Developing System

[ 63 ]

When finished, we should see several messages as shown here:

...-----------------------------'arch/arm/boot/zImage' -> '/home/giometti/Projects/WB/armv7-multiplatform/deploy/4.4.7-armv7-x6.zImage''.config' -> '/home/giometti/Projects/WB/armv7-multiplatform/deploy/config-4.4.7-armv7-x6'-rwxrwxr-x 1 giometti giometti 5,6M apr 17 18:46 /home/giometti/Projects/WB/armv7-multiplatform/deploy/4.4.7-armv7-x6.zImage-----------------------------Building modules archive...Compressing 4.4.7-armv7-x6-modules.tar.gz...-rw-rw-r-- 1 giometti giometti 89M apr 17 18:47 /home/giometti/Projects/WB/armv7-multiplatform/deploy/4.4.7-armv7-x6-modules.tar.gz-----------------------------Building firmware archive...Compressing 4.4.7-armv7-x6-firmware.tar.gz...-rw-rw-r-- 1 giometti giometti 1,2M apr 17 18:47 /home/giometti/Projects/WB/armv7-multiplatform/deploy/4.4.7-armv7-x6-firmware.tar.gz-----------------------------Building dtbs archive...Compressing 4.4.7-armv7-x6-dtbs.tar.gz...-rw-rw-r-- 1 giometti giometti 3,1M apr 17 18:47 /home/giometti/Projects/WB/armv7-multiplatform/deploy/4.4.7-armv7-x6-dtbs.tar.gz-----------------------------Script Completeeewiki.net: [user@localhost:~$ export kernel_version=4.4.7-armv7-x6]-----------------------------

The last line tells us which is the kernel version to be defined in the uEnv.txt file definedearlier when we installed the bootloaders. The command is shown here:

$ sudo sh -c 'echo "uname_r=4.4.7-armv7-x6" >> /media/rootfs/boot/uEnv.txt'

The /media/rootfs directory has been already mounted in the previoussection.

注意:/media/rootfs 在上一节中已经被挂载了。

现在,我们应该安装内核,但首先我们需要根文件系统。所以我们转到下一个小节。

4. Debian 8 系统的设置根文件系统我们可以用和 BeagleBone Black 一样的资源,我们把它复制到 microSD:

Installing the Developing System

[ 64 ]

Now, we should install the kernel, but first, we need the root filesystem. So, let's move tothe next subsection.

Debian 8 (jessie) for the WandboardLike rootfs we can use the one already downloaded for the BeagleBone Black, so let's copy itinto the microSD:

$ cd common/debian-8.4-minimal-armhf-2016-04-02/$ sudo tar xpf armhf-rootfs-debian-jessie.tar -C /media/rootfs/

We have already mounted the microSD into /media/rootfs.

When finished, we can add the kernel image and the related files:

$ cd WB/armv7-multiplatform/$ sudo cp deploy/4.4.7-armv7-x6.zImage /media/rootfs/boot/vmlinuz-4.4.7-armv7-x6$ sudo mkdir -p /media/rootfs/boot/dtbs/4.4.7-armv7-x6/$ sudo tar xf deploy/4.4.7-armv7-x6-dtbs.tar.gz -C /media/rootfs/boot/dtbs/4.4.7-armv7-x6/$ sudo tar xf deploy/4.4.7-armv7-x6-modules.tar.gz -C /media/rootfs/

Now, to finish the job, we must set up the filesystem table using the following command:

$ sudo sh -c "echo '/dev/mmcblk0p1 / auto errors=remount-ro 0 1' > /media/rootfs/etc/fstab"

We also need to set up the networking configuration by executing the following commands:

$ sudo sh -c "echo 'allow-hotplug lo\niface lo inet loopback\n' > /media/rootfs/etc/network/interfaces"$ sudo sh -c "echo 'allow-hotplug eth0\niface eth0 inet dhcp' >> /media/rootfs/etc/network/interfaces"

Now, we should be ready to boot our new system! Let's unmount the microSD from thehost PC, plug it into the Wandboard, and power on the board. The umount command line isshown here:

$ sudo umount /media/rootfs/

注意:此时我们已经把 microSD 挂载到 /media/rootfs 了。

完成后,就可以添加内核映像和相关文件:

Installing the Developing System

[ 64 ]

Now, we should install the kernel, but first, we need the root filesystem. So, let's move tothe next subsection.

Debian 8 (jessie) for the WandboardLike rootfs we can use the one already downloaded for the BeagleBone Black, so let's copy itinto the microSD:

$ cd common/debian-8.4-minimal-armhf-2016-04-02/$ sudo tar xpf armhf-rootfs-debian-jessie.tar -C /media/rootfs/

We have already mounted the microSD into /media/rootfs.

When finished, we can add the kernel image and the related files:

$ cd WB/armv7-multiplatform/$ sudo cp deploy/4.4.7-armv7-x6.zImage /media/rootfs/boot/vmlinuz-4.4.7-armv7-x6$ sudo mkdir -p /media/rootfs/boot/dtbs/4.4.7-armv7-x6/$ sudo tar xf deploy/4.4.7-armv7-x6-dtbs.tar.gz -C /media/rootfs/boot/dtbs/4.4.7-armv7-x6/$ sudo tar xf deploy/4.4.7-armv7-x6-modules.tar.gz -C /media/rootfs/

Now, to finish the job, we must set up the filesystem table using the following command:

$ sudo sh -c "echo '/dev/mmcblk0p1 / auto errors=remount-ro 0 1' > /media/rootfs/etc/fstab"

We also need to set up the networking configuration by executing the following commands:

$ sudo sh -c "echo 'allow-hotplug lo\niface lo inet loopback\n' > /media/rootfs/etc/network/interfaces"$ sudo sh -c "echo 'allow-hotplug eth0\niface eth0 inet dhcp' >> /media/rootfs/etc/network/interfaces"

Now, we should be ready to boot our new system! Let's unmount the microSD from thehost PC, plug it into the Wandboard, and power on the board. The umount command line isshown here:

$ sudo umount /media/rootfs/

现在,要完成这个工作,我们必须使用以下命令设置文件系统表:

Installing the Developing System

[ 64 ]

Now, we should install the kernel, but first, we need the root filesystem. So, let's move tothe next subsection.

Debian 8 (jessie) for the WandboardLike rootfs we can use the one already downloaded for the BeagleBone Black, so let's copy itinto the microSD:

$ cd common/debian-8.4-minimal-armhf-2016-04-02/$ sudo tar xpf armhf-rootfs-debian-jessie.tar -C /media/rootfs/

We have already mounted the microSD into /media/rootfs.

When finished, we can add the kernel image and the related files:

$ cd WB/armv7-multiplatform/$ sudo cp deploy/4.4.7-armv7-x6.zImage /media/rootfs/boot/vmlinuz-4.4.7-armv7-x6$ sudo mkdir -p /media/rootfs/boot/dtbs/4.4.7-armv7-x6/$ sudo tar xf deploy/4.4.7-armv7-x6-dtbs.tar.gz -C /media/rootfs/boot/dtbs/4.4.7-armv7-x6/$ sudo tar xf deploy/4.4.7-armv7-x6-modules.tar.gz -C /media/rootfs/

Now, to finish the job, we must set up the filesystem table using the following command:

$ sudo sh -c "echo '/dev/mmcblk0p1 / auto errors=remount-ro 0 1' > /media/rootfs/etc/fstab"

We also need to set up the networking configuration by executing the following commands:

$ sudo sh -c "echo 'allow-hotplug lo\niface lo inet loopback\n' > /media/rootfs/etc/network/interfaces"$ sudo sh -c "echo 'allow-hotplug eth0\niface eth0 inet dhcp' >> /media/rootfs/etc/network/interfaces"

Now, we should be ready to boot our new system! Let's unmount the microSD from thehost PC, plug it into the Wandboard, and power on the board. The umount command line isshown here:

$ sudo umount /media/rootfs/

我们还需要通过执行以下命令来设置网络配置:

Installing the Developing System

[ 64 ]

Now, we should install the kernel, but first, we need the root filesystem. So, let's move tothe next subsection.

Debian 8 (jessie) for the WandboardLike rootfs we can use the one already downloaded for the BeagleBone Black, so let's copy itinto the microSD:

$ cd common/debian-8.4-minimal-armhf-2016-04-02/$ sudo tar xpf armhf-rootfs-debian-jessie.tar -C /media/rootfs/

We have already mounted the microSD into /media/rootfs.

When finished, we can add the kernel image and the related files:

$ cd WB/armv7-multiplatform/$ sudo cp deploy/4.4.7-armv7-x6.zImage /media/rootfs/boot/vmlinuz-4.4.7-armv7-x6$ sudo mkdir -p /media/rootfs/boot/dtbs/4.4.7-armv7-x6/$ sudo tar xf deploy/4.4.7-armv7-x6-dtbs.tar.gz -C /media/rootfs/boot/dtbs/4.4.7-armv7-x6/$ sudo tar xf deploy/4.4.7-armv7-x6-modules.tar.gz -C /media/rootfs/

Now, to finish the job, we must set up the filesystem table using the following command:

$ sudo sh -c "echo '/dev/mmcblk0p1 / auto errors=remount-ro 0 1' > /media/rootfs/etc/fstab"

We also need to set up the networking configuration by executing the following commands:

$ sudo sh -c "echo 'allow-hotplug lo\niface lo inet loopback\n' > /media/rootfs/etc/network/interfaces"$ sudo sh -c "echo 'allow-hotplug eth0\niface eth0 inet dhcp' >> /media/rootfs/etc/network/interfaces"

Now, we should be ready to boot our new system! Let's unmount the microSD from thehost PC, plug it into the Wandboard, and power on the board. The umount command line isshown here:

$ sudo umount /media/rootfs/

现在,我们应该准备启动我们的新系统!我们先从主机上卸下 microSD,然后将其插

入到 Wandboard 上,然后打开电源。umount 命令行如下所示:

Installing the Developing System

[ 64 ]

Now, we should install the kernel, but first, we need the root filesystem. So, let's move tothe next subsection.

Debian 8 (jessie) for the WandboardLike rootfs we can use the one already downloaded for the BeagleBone Black, so let's copy itinto the microSD:

$ cd common/debian-8.4-minimal-armhf-2016-04-02/$ sudo tar xpf armhf-rootfs-debian-jessie.tar -C /media/rootfs/

We have already mounted the microSD into /media/rootfs.

When finished, we can add the kernel image and the related files:

$ cd WB/armv7-multiplatform/$ sudo cp deploy/4.4.7-armv7-x6.zImage /media/rootfs/boot/vmlinuz-4.4.7-armv7-x6$ sudo mkdir -p /media/rootfs/boot/dtbs/4.4.7-armv7-x6/$ sudo tar xf deploy/4.4.7-armv7-x6-dtbs.tar.gz -C /media/rootfs/boot/dtbs/4.4.7-armv7-x6/$ sudo tar xf deploy/4.4.7-armv7-x6-modules.tar.gz -C /media/rootfs/

Now, to finish the job, we must set up the filesystem table using the following command:

$ sudo sh -c "echo '/dev/mmcblk0p1 / auto errors=remount-ro 0 1' > /media/rootfs/etc/fstab"

We also need to set up the networking configuration by executing the following commands:

$ sudo sh -c "echo 'allow-hotplug lo\niface lo inet loopback\n' > /media/rootfs/etc/network/interfaces"$ sudo sh -c "echo 'allow-hotplug eth0\niface eth0 inet dhcp' >> /media/rootfs/etc/network/interfaces"

Now, we should be ready to boot our new system! Let's unmount the microSD from thehost PC, plug it into the Wandboard, and power on the board. The umount command line isshown here:

$ sudo umount /media/rootfs/

如果串口控制台上一切正常,我们应该看到如下:

Installing the Developing System

[ 65 ]

If everything works well on the serial console, we should see something like this:

U-Boot SPL 2016.03-dirty (Apr 21 2016 - 10:41:24)Trying to boot from MMC

U-Boot 2016.03-dirty (Apr 21 2016 - 10:41:24 +0200)

CPU: Freescale i.MX6Q rev1.5 at 792 MHzReset cause: PORBoard: Wandboard rev C1I2C: readyDRAM: 2 GiBMMC: FSL_SDHC: 0, FSL_SDHC: 1*** Warning - bad CRC, using default environment

No panel detected: default to HDMIDisplay: HDMI (1024x768)In: serialOut: serialErr: serialNet: FEC [PRIME]Press SPACE to abort autoboot in 2 secondsswitch to partitions #0, OKmmc0 is current deviceSD/MMC found on device 0...debug: [console=ttymxc0,115200 root=/dev/mmcblk0p1 ro rootfstype=ext4rootwait] ...debug: [bootz 0x12000000 - 0x18000000] ...Kernel image @ 0x12000000 [ 0x000000 - 0x588ba0 ]## Flattened Device Tree blob at 18000000 Booting using the fdt blob at 0x18000000 Using Device Tree in place at 18000000, end 1800f7f8

Starting kernel ...

[ 0.000000] Booting Linux on physical CPU 0x0...[ 5.569385] random: systemd urandom read with 10 bits of entropy available[ 5.582907] systemd[1]: systemd 215 running in system mode. (+PAM +AUDIT +SELINUX +IMA +SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ -SECCOMP -APPARMOR)[ 5.596522] systemd[1]: Detected architecture 'arm'.

Welcome to Debian GNU/Linux 8 (jessie)!

[ 5.637466] systemd[1]: Set hostname to <arm>.

Page 35: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

第1章 开发系统的安装   35

Installing the Developing System

[ 65 ]

If everything works well on the serial console, we should see something like this:

U-Boot SPL 2016.03-dirty (Apr 21 2016 - 10:41:24)Trying to boot from MMC

U-Boot 2016.03-dirty (Apr 21 2016 - 10:41:24 +0200)

CPU: Freescale i.MX6Q rev1.5 at 792 MHzReset cause: PORBoard: Wandboard rev C1I2C: readyDRAM: 2 GiBMMC: FSL_SDHC: 0, FSL_SDHC: 1*** Warning - bad CRC, using default environment

No panel detected: default to HDMIDisplay: HDMI (1024x768)In: serialOut: serialErr: serialNet: FEC [PRIME]Press SPACE to abort autoboot in 2 secondsswitch to partitions #0, OKmmc0 is current deviceSD/MMC found on device 0...debug: [console=ttymxc0,115200 root=/dev/mmcblk0p1 ro rootfstype=ext4rootwait] ...debug: [bootz 0x12000000 - 0x18000000] ...Kernel image @ 0x12000000 [ 0x000000 - 0x588ba0 ]## Flattened Device Tree blob at 18000000 Booting using the fdt blob at 0x18000000 Using Device Tree in place at 18000000, end 1800f7f8

Starting kernel ...

[ 0.000000] Booting Linux on physical CPU 0x0...[ 5.569385] random: systemd urandom read with 10 bits of entropy available[ 5.582907] systemd[1]: systemd 215 running in system mode. (+PAM +AUDIT +SELINUX +IMA +SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ -SECCOMP -APPARMOR)[ 5.596522] systemd[1]: Detected architecture 'arm'.

Welcome to Debian GNU/Linux 8 (jessie)!

[ 5.637466] systemd[1]: Set hostname to <arm>.

Installing the Developing System

[ 66 ]

...[ OK ] Started LSB: Apache2 web server.

Debian GNU/Linux 8 arm ttymxc0

default username:password is [debian:temppwd]

arm login:

Great! Everything is working now. We can log in by entering the root string as bothusername and password.

Setting up the developing systemBefore ending the chapter, let's review each board in order to verify that our newly createdoperating systems have whatever we need to proceed further in the book.

BeagleBone Black – USB, networking, andoverlaysAs soon as we log in to our new system, we see that the prompt looks like this:

root@arm:~#

Maybe, we can customize it a bit by changing the hostname from the generic string arm intoa more appropriate bbb (which stands for BeagleBone Black). The commands to do the job areshown here:

root@arm:~# echo bbb > /etc/hostnameroot@arm:~# sed -i -e's/\<arm\>/bbb/g' /etc/hosts

Now, we have to reboot the system using the classic reboot command, and at the nextlogin, we should get a welcome message:

Debian GNU/Linux 8 bbb ttyS0default username:password is [debian:temppwd]bbb login:

After the login, we will get the new prompt:

root@bbb:~#

很好!一切就绪。我们可以通过输入 root 当作用户名和密码来登录。

1.4 设置开发系统

在结束本章之前,我们检查一下每个开发板,以便验证我们新创建的操作系统是否具

Page 36: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

36   第一部分 基 础 知 识

有我们在本书中进行下一步的需求。

1.4.1 通过 USB、网络、overlay 系统设置 BeagleBone Black

一旦登录到新系统,我们就会看到如下所示:

Installing the Developing System

[ 66 ]

...[ OK ] Started LSB: Apache2 web server.

Debian GNU/Linux 8 arm ttymxc0

default username:password is [debian:temppwd]

arm login:

Great! Everything is working now. We can log in by entering the root string as bothusername and password.

Setting up the developing systemBefore ending the chapter, let's review each board in order to verify that our newly createdoperating systems have whatever we need to proceed further in the book.

BeagleBone Black – USB, networking, andoverlaysAs soon as we log in to our new system, we see that the prompt looks like this:

root@arm:~#

Maybe, we can customize it a bit by changing the hostname from the generic string arm intoa more appropriate bbb (which stands for BeagleBone Black). The commands to do the job areshown here:

root@arm:~# echo bbb > /etc/hostnameroot@arm:~# sed -i -e's/\<arm\>/bbb/g' /etc/hosts

Now, we have to reboot the system using the classic reboot command, and at the nextlogin, we should get a welcome message:

Debian GNU/Linux 8 bbb ttyS0default username:password is [debian:temppwd]bbb login:

After the login, we will get the new prompt:

root@bbb:~#

也许,我们可以将主机名改为 bbb(BeagleBone Black)。命令如下:

Installing the Developing System

[ 66 ]

...[ OK ] Started LSB: Apache2 web server.

Debian GNU/Linux 8 arm ttymxc0

default username:password is [debian:temppwd]

arm login:

Great! Everything is working now. We can log in by entering the root string as bothusername and password.

Setting up the developing systemBefore ending the chapter, let's review each board in order to verify that our newly createdoperating systems have whatever we need to proceed further in the book.

BeagleBone Black – USB, networking, andoverlaysAs soon as we log in to our new system, we see that the prompt looks like this:

root@arm:~#

Maybe, we can customize it a bit by changing the hostname from the generic string arm intoa more appropriate bbb (which stands for BeagleBone Black). The commands to do the job areshown here:

root@arm:~# echo bbb > /etc/hostnameroot@arm:~# sed -i -e's/\<arm\>/bbb/g' /etc/hosts

Now, we have to reboot the system using the classic reboot command, and at the nextlogin, we should get a welcome message:

Debian GNU/Linux 8 bbb ttyS0default username:password is [debian:temppwd]bbb login:

After the login, we will get the new prompt:

root@bbb:~#

现在,我们使用 reboot 命令重启,在下次登录时,我们应该会收到一个欢迎消息:

Installing the Developing System

[ 66 ]

...[ OK ] Started LSB: Apache2 web server.

Debian GNU/Linux 8 arm ttymxc0

default username:password is [debian:temppwd]

arm login:

Great! Everything is working now. We can log in by entering the root string as bothusername and password.

Setting up the developing systemBefore ending the chapter, let's review each board in order to verify that our newly createdoperating systems have whatever we need to proceed further in the book.

BeagleBone Black – USB, networking, andoverlaysAs soon as we log in to our new system, we see that the prompt looks like this:

root@arm:~#

Maybe, we can customize it a bit by changing the hostname from the generic string arm intoa more appropriate bbb (which stands for BeagleBone Black). The commands to do the job areshown here:

root@arm:~# echo bbb > /etc/hostnameroot@arm:~# sed -i -e's/\<arm\>/bbb/g' /etc/hosts

Now, we have to reboot the system using the classic reboot command, and at the nextlogin, we should get a welcome message:

Debian GNU/Linux 8 bbb ttyS0default username:password is [debian:temppwd]bbb login:

After the login, we will get the new prompt:

root@bbb:~#

登录后我们会看到如下新提示:

Installing the Developing System

[ 66 ]

...[ OK ] Started LSB: Apache2 web server.

Debian GNU/Linux 8 arm ttymxc0

default username:password is [debian:temppwd]

arm login:

Great! Everything is working now. We can log in by entering the root string as bothusername and password.

Setting up the developing systemBefore ending the chapter, let's review each board in order to verify that our newly createdoperating systems have whatever we need to proceed further in the book.

BeagleBone Black – USB, networking, andoverlaysAs soon as we log in to our new system, we see that the prompt looks like this:

root@arm:~#

Maybe, we can customize it a bit by changing the hostname from the generic string arm intoa more appropriate bbb (which stands for BeagleBone Black). The commands to do the job areshown here:

root@arm:~# echo bbb > /etc/hostnameroot@arm:~# sed -i -e's/\<arm\>/bbb/g' /etc/hosts

Now, we have to reboot the system using the classic reboot command, and at the nextlogin, we should get a welcome message:

Debian GNU/Linux 8 bbb ttyS0default username:password is [debian:temppwd]bbb login:

After the login, we will get the new prompt:

root@bbb:~#

然后,我们要更新系统的资料库,然后像在宿主机上一样安装 aptitude 工具:

Installing the Developing System

[ 67 ]

Then, we will update the distribution repositories and install the aptitude tool as done forthe host machine:

root@bbb:~# apt-get updateroot@bbb:~# apt-get install aptitude

OK, now it is time to add a useful feature, that is, the possibility to establish a virtualEthernet connection between our BeagleBone Black and the host PC over the USB cableconnected with BeagleBone Black's USB device port and the host. To do this, we have firstto install the udhcpd package using the following command:

root@bbb:~# aptitude install udhcpd

Then, we must add the following lines to the /etc/network/interfaces file:

allow-hotplug usb0iface usb0 inet static address 192.168.7.2 netmask 255.255.255.252 network 192.168.7.0

Don't forget the tab character to indent the lines!

Then, restart the networking system as follows:

root@bbb:~# /etc/init.d/networking restart

IPv6: ADDRCONF(NETDEV_CHANGE): Black, we should see a message, as shown here,on the serial console:

g_ether gadget: high-speed config #1: CDC Ethernet (ECM)IPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready

A new Ethernet device should appear as reported here:

root@bbb:~# ifconfig usb0usb0 Link encap:Ethernet HWaddr 78:a5:04:ca:c9:f1 inet addr:192.168.7.2 Bcast:192.168.7.3 Mask:255.255.255.252 inet6 addr: fe80::7aa5:4ff:feca:c9f1/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:46 errors:0 dropped:0 overruns:0 frame:0 TX packets:32 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:7542 (7.3 KiB) TX bytes:5525 (5.3 KiB)

现在是时候添加一个有用的部件了,就是通过 USB 连接线建立我们的 BeagleBone Black 和主机 PC 之间的通信。所以我们首先使用以下命令安装 udhcpd 软件包:

Installing the Developing System

[ 67 ]

Then, we will update the distribution repositories and install the aptitude tool as done forthe host machine:

root@bbb:~# apt-get updateroot@bbb:~# apt-get install aptitude

OK, now it is time to add a useful feature, that is, the possibility to establish a virtualEthernet connection between our BeagleBone Black and the host PC over the USB cableconnected with BeagleBone Black's USB device port and the host. To do this, we have firstto install the udhcpd package using the following command:

root@bbb:~# aptitude install udhcpd

Then, we must add the following lines to the /etc/network/interfaces file:

allow-hotplug usb0iface usb0 inet static address 192.168.7.2 netmask 255.255.255.252 network 192.168.7.0

Don't forget the tab character to indent the lines!

Then, restart the networking system as follows:

root@bbb:~# /etc/init.d/networking restart

IPv6: ADDRCONF(NETDEV_CHANGE): Black, we should see a message, as shown here,on the serial console:

g_ether gadget: high-speed config #1: CDC Ethernet (ECM)IPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready

A new Ethernet device should appear as reported here:

root@bbb:~# ifconfig usb0usb0 Link encap:Ethernet HWaddr 78:a5:04:ca:c9:f1 inet addr:192.168.7.2 Bcast:192.168.7.3 Mask:255.255.255.252 inet6 addr: fe80::7aa5:4ff:feca:c9f1/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:46 errors:0 dropped:0 overruns:0 frame:0 TX packets:32 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:7542 (7.3 KiB) TX bytes:5525 (5.3 KiB)

然后,我们必须将以下内容添加至 / etc / network / interfaces 文件中:

Installing the Developing System

[ 67 ]

Then, we will update the distribution repositories and install the aptitude tool as done forthe host machine:

root@bbb:~# apt-get updateroot@bbb:~# apt-get install aptitude

OK, now it is time to add a useful feature, that is, the possibility to establish a virtualEthernet connection between our BeagleBone Black and the host PC over the USB cableconnected with BeagleBone Black's USB device port and the host. To do this, we have firstto install the udhcpd package using the following command:

root@bbb:~# aptitude install udhcpd

Then, we must add the following lines to the /etc/network/interfaces file:

allow-hotplug usb0iface usb0 inet static address 192.168.7.2 netmask 255.255.255.252 network 192.168.7.0

Don't forget the tab character to indent the lines!

Then, restart the networking system as follows:

root@bbb:~# /etc/init.d/networking restart

IPv6: ADDRCONF(NETDEV_CHANGE): Black, we should see a message, as shown here,on the serial console:

g_ether gadget: high-speed config #1: CDC Ethernet (ECM)IPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready

A new Ethernet device should appear as reported here:

root@bbb:~# ifconfig usb0usb0 Link encap:Ethernet HWaddr 78:a5:04:ca:c9:f1 inet addr:192.168.7.2 Bcast:192.168.7.3 Mask:255.255.255.252 inet6 addr: fe80::7aa5:4ff:feca:c9f1/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:46 errors:0 dropped:0 overruns:0 frame:0 TX packets:32 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:7542 (7.3 KiB) TX bytes:5525 (5.3 KiB)

注意:文字间缩进格式。

然后,重新启动网络系统,如下所示:

Installing the Developing System

[ 67 ]

Then, we will update the distribution repositories and install the aptitude tool as done forthe host machine:

root@bbb:~# apt-get updateroot@bbb:~# apt-get install aptitude

OK, now it is time to add a useful feature, that is, the possibility to establish a virtualEthernet connection between our BeagleBone Black and the host PC over the USB cableconnected with BeagleBone Black's USB device port and the host. To do this, we have firstto install the udhcpd package using the following command:

root@bbb:~# aptitude install udhcpd

Then, we must add the following lines to the /etc/network/interfaces file:

allow-hotplug usb0iface usb0 inet static address 192.168.7.2 netmask 255.255.255.252 network 192.168.7.0

Don't forget the tab character to indent the lines!

Then, restart the networking system as follows:

root@bbb:~# /etc/init.d/networking restart

IPv6: ADDRCONF(NETDEV_CHANGE): Black, we should see a message, as shown here,on the serial console:

g_ether gadget: high-speed config #1: CDC Ethernet (ECM)IPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready

A new Ethernet device should appear as reported here:

root@bbb:~# ifconfig usb0usb0 Link encap:Ethernet HWaddr 78:a5:04:ca:c9:f1 inet addr:192.168.7.2 Bcast:192.168.7.3 Mask:255.255.255.252 inet6 addr: fe80::7aa5:4ff:feca:c9f1/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:46 errors:0 dropped:0 overruns:0 frame:0 TX packets:32 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:7542 (7.3 KiB) TX bytes:5525 (5.3 KiB)

IPv6:ADDRCONF(NETDEV_CHANGE),我们应该看到如下消息:

Installing the Developing System

[ 67 ]

Then, we will update the distribution repositories and install the aptitude tool as done forthe host machine:

root@bbb:~# apt-get updateroot@bbb:~# apt-get install aptitude

OK, now it is time to add a useful feature, that is, the possibility to establish a virtualEthernet connection between our BeagleBone Black and the host PC over the USB cableconnected with BeagleBone Black's USB device port and the host. To do this, we have firstto install the udhcpd package using the following command:

root@bbb:~# aptitude install udhcpd

Then, we must add the following lines to the /etc/network/interfaces file:

allow-hotplug usb0iface usb0 inet static address 192.168.7.2 netmask 255.255.255.252 network 192.168.7.0

Don't forget the tab character to indent the lines!

Then, restart the networking system as follows:

root@bbb:~# /etc/init.d/networking restart

IPv6: ADDRCONF(NETDEV_CHANGE): Black, we should see a message, as shown here,on the serial console:

g_ether gadget: high-speed config #1: CDC Ethernet (ECM)IPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready

A new Ethernet device should appear as reported here:

root@bbb:~# ifconfig usb0usb0 Link encap:Ethernet HWaddr 78:a5:04:ca:c9:f1 inet addr:192.168.7.2 Bcast:192.168.7.3 Mask:255.255.255.252 inet6 addr: fe80::7aa5:4ff:feca:c9f1/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:46 errors:0 dropped:0 overruns:0 frame:0 TX packets:32 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:7542 (7.3 KiB) TX bytes:5525 (5.3 KiB)

新的以太网设备应该会出现,如下所示:

Installing the Developing System

[ 67 ]

Then, we will update the distribution repositories and install the aptitude tool as done forthe host machine:

root@bbb:~# apt-get updateroot@bbb:~# apt-get install aptitude

OK, now it is time to add a useful feature, that is, the possibility to establish a virtualEthernet connection between our BeagleBone Black and the host PC over the USB cableconnected with BeagleBone Black's USB device port and the host. To do this, we have firstto install the udhcpd package using the following command:

root@bbb:~# aptitude install udhcpd

Then, we must add the following lines to the /etc/network/interfaces file:

allow-hotplug usb0iface usb0 inet static address 192.168.7.2 netmask 255.255.255.252 network 192.168.7.0

Don't forget the tab character to indent the lines!

Then, restart the networking system as follows:

root@bbb:~# /etc/init.d/networking restart

IPv6: ADDRCONF(NETDEV_CHANGE): Black, we should see a message, as shown here,on the serial console:

g_ether gadget: high-speed config #1: CDC Ethernet (ECM)IPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready

A new Ethernet device should appear as reported here:

root@bbb:~# ifconfig usb0usb0 Link encap:Ethernet HWaddr 78:a5:04:ca:c9:f1 inet addr:192.168.7.2 Bcast:192.168.7.3 Mask:255.255.255.252 inet6 addr: fe80::7aa5:4ff:feca:c9f1/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:46 errors:0 dropped:0 overruns:0 frame:0 TX packets:32 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:7542 (7.3 KiB) TX bytes:5525 (5.3 KiB)

Page 37: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

第1章 开发系统的安装   37

Installing the Developing System

[ 67 ]

Then, we will update the distribution repositories and install the aptitude tool as done forthe host machine:

root@bbb:~# apt-get updateroot@bbb:~# apt-get install aptitude

OK, now it is time to add a useful feature, that is, the possibility to establish a virtualEthernet connection between our BeagleBone Black and the host PC over the USB cableconnected with BeagleBone Black's USB device port and the host. To do this, we have firstto install the udhcpd package using the following command:

root@bbb:~# aptitude install udhcpd

Then, we must add the following lines to the /etc/network/interfaces file:

allow-hotplug usb0iface usb0 inet static address 192.168.7.2 netmask 255.255.255.252 network 192.168.7.0

Don't forget the tab character to indent the lines!

Then, restart the networking system as follows:

root@bbb:~# /etc/init.d/networking restart

IPv6: ADDRCONF(NETDEV_CHANGE): Black, we should see a message, as shown here,on the serial console:

g_ether gadget: high-speed config #1: CDC Ethernet (ECM)IPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready

A new Ethernet device should appear as reported here:

root@bbb:~# ifconfig usb0usb0 Link encap:Ethernet HWaddr 78:a5:04:ca:c9:f1 inet addr:192.168.7.2 Bcast:192.168.7.3 Mask:255.255.255.252 inet6 addr: fe80::7aa5:4ff:feca:c9f1/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:46 errors:0 dropped:0 overruns:0 frame:0 TX packets:32 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:7542 (7.3 KiB) TX bytes:5525 (5.3 KiB)

现在我们必须在主机上配置新的以太网设备,然后我们可以尝试用 ssh 连接,如下

所示:

Installing the Developing System

[ 68 ]

OK, now, we have to configure the new Ethernet device on the host and then we can try anssh connection as shown here:

$ ssh [email protected]

On my host PC, which is Ubuntu based, before executing the sshcommand, we had to properly configure the new Ethernet device byadding a new network connection in the entry Edit Connections… in thesystem settings menu.

The authenticity of host '192.168.7.2 (192.168.7.2)' can't be established.ECDSA key fingerprint is SHA256:Iu23gb49VFKsFs+HMwjza1OzcpzRL/zxFxjFpFEiDsg.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.7.2' (ECDSA) to the list of [email protected]'s password:

Now we have to enter the root's password that is root and the trick is done:

The programs included with the Debian GNU/Linux system are freesoftware; the exact distribution terms for each program aredescribed in the individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to theextent permitted by applicable law.Last login: Sat Apr 2 18:28:44 2016root@bbb:~#

We may need to modify the ssh daemon configuration if we cannotsuccessfully log in to our system. In fact, the login by the root user may bedisabled for security reasons. To enable the login, we have to modify the/etc/ssh/sshd_config file as follows: --- /etc/ssh/sshd_config.orig 2016-04-02 18:40:31. 120000086 +0000 +++ /etc/ssh/sshd_config 2016-04-02 18:40:46.05000 0088 +0000 @@ -25,7 +25,7 @@ # Authentication: LoginGraceTime 120 -PermitRootLogin without-password +PermitRootLogin yes StrictModes yes

注意:PC 系统是基于 Ubuntu 的,在连接之前要确保网络已经配置好,可以在系统

设置菜单的 Edit Connections 添加新的网络连接来配置。

Installing the Developing System

[ 68 ]

OK, now, we have to configure the new Ethernet device on the host and then we can try anssh connection as shown here:

$ ssh [email protected]

On my host PC, which is Ubuntu based, before executing the sshcommand, we had to properly configure the new Ethernet device byadding a new network connection in the entry Edit Connections… in thesystem settings menu.

The authenticity of host '192.168.7.2 (192.168.7.2)' can't be established.ECDSA key fingerprint is SHA256:Iu23gb49VFKsFs+HMwjza1OzcpzRL/zxFxjFpFEiDsg.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.7.2' (ECDSA) to the list of [email protected]'s password:

Now we have to enter the root's password that is root and the trick is done:

The programs included with the Debian GNU/Linux system are freesoftware; the exact distribution terms for each program aredescribed in the individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to theextent permitted by applicable law.Last login: Sat Apr 2 18:28:44 2016root@bbb:~#

We may need to modify the ssh daemon configuration if we cannotsuccessfully log in to our system. In fact, the login by the root user may bedisabled for security reasons. To enable the login, we have to modify the/etc/ssh/sshd_config file as follows: --- /etc/ssh/sshd_config.orig 2016-04-02 18:40:31. 120000086 +0000 +++ /etc/ssh/sshd_config 2016-04-02 18:40:46.05000 0088 +0000 @@ -25,7 +25,7 @@ # Authentication: LoginGraceTime 120 -PermitRootLogin without-password +PermitRootLogin yes StrictModes yes

现在我们要输入 root 用户密码,如下所示:

Installing the Developing System

[ 68 ]

OK, now, we have to configure the new Ethernet device on the host and then we can try anssh connection as shown here:

$ ssh [email protected]

On my host PC, which is Ubuntu based, before executing the sshcommand, we had to properly configure the new Ethernet device byadding a new network connection in the entry Edit Connections… in thesystem settings menu.

The authenticity of host '192.168.7.2 (192.168.7.2)' can't be established.ECDSA key fingerprint is SHA256:Iu23gb49VFKsFs+HMwjza1OzcpzRL/zxFxjFpFEiDsg.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.7.2' (ECDSA) to the list of [email protected]'s password:

Now we have to enter the root's password that is root and the trick is done:

The programs included with the Debian GNU/Linux system are freesoftware; the exact distribution terms for each program aredescribed in the individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to theextent permitted by applicable law.Last login: Sat Apr 2 18:28:44 2016root@bbb:~#

We may need to modify the ssh daemon configuration if we cannotsuccessfully log in to our system. In fact, the login by the root user may bedisabled for security reasons. To enable the login, we have to modify the/etc/ssh/sshd_config file as follows: --- /etc/ssh/sshd_config.orig 2016-04-02 18:40:31. 120000086 +0000 +++ /etc/ssh/sshd_config 2016-04-02 18:40:46.05000 0088 +0000 @@ -25,7 +25,7 @@ # Authentication: LoginGraceTime 120 -PermitRootLogin without-password +PermitRootLogin yes StrictModes yes

提示:如果我们无法成功登录到我们的系统,我们可能需要修改 ssh 守护进程配置。

实际上,出于安全考虑,root 用户的登录可能会被禁用。要启用登录,我们必须修

改 /etc/ssh/sshd_config 文件,如下所示:

Installing the Developing System

[ 68 ]

OK, now, we have to configure the new Ethernet device on the host and then we can try anssh connection as shown here:

$ ssh [email protected]

On my host PC, which is Ubuntu based, before executing the sshcommand, we had to properly configure the new Ethernet device byadding a new network connection in the entry Edit Connections… in thesystem settings menu.

The authenticity of host '192.168.7.2 (192.168.7.2)' can't be established.ECDSA key fingerprint is SHA256:Iu23gb49VFKsFs+HMwjza1OzcpzRL/zxFxjFpFEiDsg.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.7.2' (ECDSA) to the list of [email protected]'s password:

Now we have to enter the root's password that is root and the trick is done:

The programs included with the Debian GNU/Linux system are freesoftware; the exact distribution terms for each program aredescribed in the individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to theextent permitted by applicable law.Last login: Sat Apr 2 18:28:44 2016root@bbb:~#

We may need to modify the ssh daemon configuration if we cannotsuccessfully log in to our system. In fact, the login by the root user may bedisabled for security reasons. To enable the login, we have to modify the/etc/ssh/sshd_config file as follows: --- /etc/ssh/sshd_config.orig 2016-04-02 18:40:31. 120000086 +0000 +++ /etc/ssh/sshd_config 2016-04-02 18:40:46.05000 0088 +0000 @@ -25,7 +25,7 @@ # Authentication: LoginGraceTime 120 -PermitRootLogin without-password +PermitRootLogin yes StrictModes yes

Installing the Developing System

[ 69 ]

RSAAuthentication yes

Then, we have to restart the daemon using the following command: root@bbb:~# /etc/init.d/ssh restart Restarting ssh (via systemctl): ssh.service.

Now, we have to install the overlay system, that is, the mechanism that allow us to load atrun time a part of a new device tree binaries and then change our kernel settings to getaccess to the board's peripherals (this mechanism will be used in the upcoming chapters,and it'll be more clear to you when we'll start using it).

To install the overlay mechanism, we must clone its repository into our BeagleBone Black asfollows:

bbb@arm:~# git clone https://github.com/beagleboard/bb.org-overlays

Then, we must update the device tree compiler (the dtc command) with the followingcommands:

root@arm:~# cd bb.org-overlays/root@arm:~/bb.org-overlays# ./dtc-overlay.sh

This command may take a while to complete. Be patient.

Installing: bison build-essential flexGet:1 http://repos.rcn-ee.com jessie InRelease [4,347 B]Get:2 http://repos.rcn-ee.com jessie/main armhf Packages [370 kB]...Installing into: /usr/local/bin/ CHK version_gen.h INSTALL-BIN INSTALL-LIB INSTALL-INCdtc: Version: DTC 1.4.1-g1e75ebc9

Then, we can install the dtbo files with the following command:

root@arm:~/bb.org-overlays# ./install.sh CLEAN src/arm DTC src/arm/BB-BONE-WTHR-01-00B0.dtbo DTC src/arm/BB-BONE-LCD3-01-00A2.dtbo DTC src/arm/BB-PWM2-00A0.dtbo...'src/arm/univ-hdmi-00A0.dtbo' -> '/lib/firmware/univ-hdmi-00A0.dtbo'

Page 38: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

38   第一部分 基 础 知 识

提示:然后,我们必须使用以下命令重新启动守护进程:

Installing the Developing System

[ 69 ]

RSAAuthentication yes

Then, we have to restart the daemon using the following command: root@bbb:~# /etc/init.d/ssh restart Restarting ssh (via systemctl): ssh.service.

Now, we have to install the overlay system, that is, the mechanism that allow us to load atrun time a part of a new device tree binaries and then change our kernel settings to getaccess to the board's peripherals (this mechanism will be used in the upcoming chapters,and it'll be more clear to you when we'll start using it).

To install the overlay mechanism, we must clone its repository into our BeagleBone Black asfollows:

bbb@arm:~# git clone https://github.com/beagleboard/bb.org-overlays

Then, we must update the device tree compiler (the dtc command) with the followingcommands:

root@arm:~# cd bb.org-overlays/root@arm:~/bb.org-overlays# ./dtc-overlay.sh

This command may take a while to complete. Be patient.

Installing: bison build-essential flexGet:1 http://repos.rcn-ee.com jessie InRelease [4,347 B]Get:2 http://repos.rcn-ee.com jessie/main armhf Packages [370 kB]...Installing into: /usr/local/bin/ CHK version_gen.h INSTALL-BIN INSTALL-LIB INSTALL-INCdtc: Version: DTC 1.4.1-g1e75ebc9

Then, we can install the dtbo files with the following command:

root@arm:~/bb.org-overlays# ./install.sh CLEAN src/arm DTC src/arm/BB-BONE-WTHR-01-00B0.dtbo DTC src/arm/BB-BONE-LCD3-01-00A2.dtbo DTC src/arm/BB-PWM2-00A0.dtbo...'src/arm/univ-hdmi-00A0.dtbo' -> '/lib/firmware/univ-hdmi-00A0.dtbo'

现在,我们必须安装覆盖系统,即该机制允许我们在运行时加载一部分二进制文件,

然后更改内核设置以访问主板的外设(这种机制将在后面的章节中使用,到时候和会更加

清楚)。

要安装覆盖机制,我们必须将其资源库复制到我们的 BeagleBone Black 中,如下所示:

Installing the Developing System

[ 69 ]

RSAAuthentication yes

Then, we have to restart the daemon using the following command: root@bbb:~# /etc/init.d/ssh restart Restarting ssh (via systemctl): ssh.service.

Now, we have to install the overlay system, that is, the mechanism that allow us to load atrun time a part of a new device tree binaries and then change our kernel settings to getaccess to the board's peripherals (this mechanism will be used in the upcoming chapters,and it'll be more clear to you when we'll start using it).

To install the overlay mechanism, we must clone its repository into our BeagleBone Black asfollows:

bbb@arm:~# git clone https://github.com/beagleboard/bb.org-overlays

Then, we must update the device tree compiler (the dtc command) with the followingcommands:

root@arm:~# cd bb.org-overlays/root@arm:~/bb.org-overlays# ./dtc-overlay.sh

This command may take a while to complete. Be patient.

Installing: bison build-essential flexGet:1 http://repos.rcn-ee.com jessie InRelease [4,347 B]Get:2 http://repos.rcn-ee.com jessie/main armhf Packages [370 kB]...Installing into: /usr/local/bin/ CHK version_gen.h INSTALL-BIN INSTALL-LIB INSTALL-INCdtc: Version: DTC 1.4.1-g1e75ebc9

Then, we can install the dtbo files with the following command:

root@arm:~/bb.org-overlays# ./install.sh CLEAN src/arm DTC src/arm/BB-BONE-WTHR-01-00B0.dtbo DTC src/arm/BB-BONE-LCD3-01-00A2.dtbo DTC src/arm/BB-PWM2-00A0.dtbo...'src/arm/univ-hdmi-00A0.dtbo' -> '/lib/firmware/univ-hdmi-00A0.dtbo'

然后,我们必须使用以下命令更新设备树编译器(dtc 命令):

Installing the Developing System

[ 69 ]

RSAAuthentication yes

Then, we have to restart the daemon using the following command: root@bbb:~# /etc/init.d/ssh restart Restarting ssh (via systemctl): ssh.service.

Now, we have to install the overlay system, that is, the mechanism that allow us to load atrun time a part of a new device tree binaries and then change our kernel settings to getaccess to the board's peripherals (this mechanism will be used in the upcoming chapters,and it'll be more clear to you when we'll start using it).

To install the overlay mechanism, we must clone its repository into our BeagleBone Black asfollows:

bbb@arm:~# git clone https://github.com/beagleboard/bb.org-overlays

Then, we must update the device tree compiler (the dtc command) with the followingcommands:

root@arm:~# cd bb.org-overlays/root@arm:~/bb.org-overlays# ./dtc-overlay.sh

This command may take a while to complete. Be patient.

Installing: bison build-essential flexGet:1 http://repos.rcn-ee.com jessie InRelease [4,347 B]Get:2 http://repos.rcn-ee.com jessie/main armhf Packages [370 kB]...Installing into: /usr/local/bin/ CHK version_gen.h INSTALL-BIN INSTALL-LIB INSTALL-INCdtc: Version: DTC 1.4.1-g1e75ebc9

Then, we can install the dtbo files with the following command:

root@arm:~/bb.org-overlays# ./install.sh CLEAN src/arm DTC src/arm/BB-BONE-WTHR-01-00B0.dtbo DTC src/arm/BB-BONE-LCD3-01-00A2.dtbo DTC src/arm/BB-PWM2-00A0.dtbo...'src/arm/univ-hdmi-00A0.dtbo' -> '/lib/firmware/univ-hdmi-00A0.dtbo'

提示:此命令可能需要一段时间才能完成,耐心一点。

Installing the Developing System

[ 69 ]

RSAAuthentication yes

Then, we have to restart the daemon using the following command: root@bbb:~# /etc/init.d/ssh restart Restarting ssh (via systemctl): ssh.service.

Now, we have to install the overlay system, that is, the mechanism that allow us to load atrun time a part of a new device tree binaries and then change our kernel settings to getaccess to the board's peripherals (this mechanism will be used in the upcoming chapters,and it'll be more clear to you when we'll start using it).

To install the overlay mechanism, we must clone its repository into our BeagleBone Black asfollows:

bbb@arm:~# git clone https://github.com/beagleboard/bb.org-overlays

Then, we must update the device tree compiler (the dtc command) with the followingcommands:

root@arm:~# cd bb.org-overlays/root@arm:~/bb.org-overlays# ./dtc-overlay.sh

This command may take a while to complete. Be patient.

Installing: bison build-essential flexGet:1 http://repos.rcn-ee.com jessie InRelease [4,347 B]Get:2 http://repos.rcn-ee.com jessie/main armhf Packages [370 kB]...Installing into: /usr/local/bin/ CHK version_gen.h INSTALL-BIN INSTALL-LIB INSTALL-INCdtc: Version: DTC 1.4.1-g1e75ebc9

Then, we can install the dtbo files with the following command:

root@arm:~/bb.org-overlays# ./install.sh CLEAN src/arm DTC src/arm/BB-BONE-WTHR-01-00B0.dtbo DTC src/arm/BB-BONE-LCD3-01-00A2.dtbo DTC src/arm/BB-PWM2-00A0.dtbo...'src/arm/univ-hdmi-00A0.dtbo' -> '/lib/firmware/univ-hdmi-00A0.dtbo'

然后,我们可以使用以下命令安装 dtbo 文件:

Installing the Developing System

[ 69 ]

RSAAuthentication yes

Then, we have to restart the daemon using the following command: root@bbb:~# /etc/init.d/ssh restart Restarting ssh (via systemctl): ssh.service.

Now, we have to install the overlay system, that is, the mechanism that allow us to load atrun time a part of a new device tree binaries and then change our kernel settings to getaccess to the board's peripherals (this mechanism will be used in the upcoming chapters,and it'll be more clear to you when we'll start using it).

To install the overlay mechanism, we must clone its repository into our BeagleBone Black asfollows:

bbb@arm:~# git clone https://github.com/beagleboard/bb.org-overlays

Then, we must update the device tree compiler (the dtc command) with the followingcommands:

root@arm:~# cd bb.org-overlays/root@arm:~/bb.org-overlays# ./dtc-overlay.sh

This command may take a while to complete. Be patient.

Installing: bison build-essential flexGet:1 http://repos.rcn-ee.com jessie InRelease [4,347 B]Get:2 http://repos.rcn-ee.com jessie/main armhf Packages [370 kB]...Installing into: /usr/local/bin/ CHK version_gen.h INSTALL-BIN INSTALL-LIB INSTALL-INCdtc: Version: DTC 1.4.1-g1e75ebc9

Then, we can install the dtbo files with the following command:

root@arm:~/bb.org-overlays# ./install.sh CLEAN src/arm DTC src/arm/BB-BONE-WTHR-01-00B0.dtbo DTC src/arm/BB-BONE-LCD3-01-00A2.dtbo DTC src/arm/BB-PWM2-00A0.dtbo...'src/arm/univ-hdmi-00A0.dtbo' -> '/lib/firmware/univ-hdmi-00A0.dtbo'

Installing the Developing System

[ 70 ]

'src/arm/univ-nhdmi-00A0.dtbo' -> '/lib/firmware/univ-nhdmi-00A0.dtbo'update-initramfs: Generating /boot/initrd.img-4.4.7-bone9cape overlays have been built and added to /lib/firmware & /boot/initrd.img-4.4.7-bone9, please reboot

OK, now, we can safely reboot the system to test it.

After reboot, to display the current overlay configuration, we can use the following catcommand:

root@arm:~# cat /sys/devices/platform/bone_capemgr/slots 0: PF---- -1 1: PF---- -1 2: PF---- -1 3: PF---- -1

Then, we can try to enable the second SPI bus char device using the following command:

root@bbb:~# echo BB-SPIDEV1 > /sys/devices/platform/bone_capemgr/slotsbone_capemgr bone_capemgr: part_number 'BB-SPIDEV1', version 'N/A'bone_capemgr bone_capemgr: slot #4: overridebone_capemgr bone_capemgr: Using override eeprom data at slot 4bone_capemgr bone_capemgr: slot #4: 'Override Board Name,00A0,Override Manuf,BB-SPIDEV1'bone_capemgr bone_capemgr: slot #4: dtbo 'BB-SPIDEV1-00A0.dtbo'loaded; overlay id#0

Now, two new char devices should appear in the /dev directory:

root@bbb:~# ls -l /dev/spidev*crw-rw---- 1 root spi 153, 0 Apr 2 19:27 /dev/spidev2.0crw-rw---- 1 root spi 153, 1 Apr 2 19:27 /dev/spidev2.1

Also, the slots file in sysfs is updated accordingly:

root@bbb:~# cat /sys/devices/platform/bone_capemgr/slots 0: PF---- -1 1: PF---- -1 2: PF---- -1 3: PF---- -1 4: P-O-L- 0 Override Board Name,00A0,Override Manuf,BB-SPIDEV1

Now, everything should be in place. However, as the last step, we can decide to copy ournew system from the microSD card to eMMC in order to boot directly from the on-boardeMMC device, thus avoiding pressing the user button each time we power up the board.

现在我们就可以安全地重新启动系统来测试它。重新启动后,我们可以使用 cat 命令显

示当前的配置:

Installing the Developing System

[ 70 ]

'src/arm/univ-nhdmi-00A0.dtbo' -> '/lib/firmware/univ-nhdmi-00A0.dtbo'update-initramfs: Generating /boot/initrd.img-4.4.7-bone9cape overlays have been built and added to /lib/firmware & /boot/initrd.img-4.4.7-bone9, please reboot

OK, now, we can safely reboot the system to test it.

After reboot, to display the current overlay configuration, we can use the following catcommand:

root@arm:~# cat /sys/devices/platform/bone_capemgr/slots 0: PF---- -1 1: PF---- -1 2: PF---- -1 3: PF---- -1

Then, we can try to enable the second SPI bus char device using the following command:

root@bbb:~# echo BB-SPIDEV1 > /sys/devices/platform/bone_capemgr/slotsbone_capemgr bone_capemgr: part_number 'BB-SPIDEV1', version 'N/A'bone_capemgr bone_capemgr: slot #4: overridebone_capemgr bone_capemgr: Using override eeprom data at slot 4bone_capemgr bone_capemgr: slot #4: 'Override Board Name,00A0,Override Manuf,BB-SPIDEV1'bone_capemgr bone_capemgr: slot #4: dtbo 'BB-SPIDEV1-00A0.dtbo'loaded; overlay id#0

Now, two new char devices should appear in the /dev directory:

root@bbb:~# ls -l /dev/spidev*crw-rw---- 1 root spi 153, 0 Apr 2 19:27 /dev/spidev2.0crw-rw---- 1 root spi 153, 1 Apr 2 19:27 /dev/spidev2.1

Also, the slots file in sysfs is updated accordingly:

root@bbb:~# cat /sys/devices/platform/bone_capemgr/slots 0: PF---- -1 1: PF---- -1 2: PF---- -1 3: PF---- -1 4: P-O-L- 0 Override Board Name,00A0,Override Manuf,BB-SPIDEV1

Now, everything should be in place. However, as the last step, we can decide to copy ournew system from the microSD card to eMMC in order to boot directly from the on-boardeMMC device, thus avoiding pressing the user button each time we power up the board.

然后,我们可以尝试使用以下命令启用第二个 SPI 总线字符设备:

Page 39: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

第1章 开发系统的安装   39

Installing the Developing System

[ 70 ]

'src/arm/univ-nhdmi-00A0.dtbo' -> '/lib/firmware/univ-nhdmi-00A0.dtbo'update-initramfs: Generating /boot/initrd.img-4.4.7-bone9cape overlays have been built and added to /lib/firmware & /boot/initrd.img-4.4.7-bone9, please reboot

OK, now, we can safely reboot the system to test it.

After reboot, to display the current overlay configuration, we can use the following catcommand:

root@arm:~# cat /sys/devices/platform/bone_capemgr/slots 0: PF---- -1 1: PF---- -1 2: PF---- -1 3: PF---- -1

Then, we can try to enable the second SPI bus char device using the following command:

root@bbb:~# echo BB-SPIDEV1 > /sys/devices/platform/bone_capemgr/slotsbone_capemgr bone_capemgr: part_number 'BB-SPIDEV1', version 'N/A'bone_capemgr bone_capemgr: slot #4: overridebone_capemgr bone_capemgr: Using override eeprom data at slot 4bone_capemgr bone_capemgr: slot #4: 'Override Board Name,00A0,Override Manuf,BB-SPIDEV1'bone_capemgr bone_capemgr: slot #4: dtbo 'BB-SPIDEV1-00A0.dtbo'loaded; overlay id#0

Now, two new char devices should appear in the /dev directory:

root@bbb:~# ls -l /dev/spidev*crw-rw---- 1 root spi 153, 0 Apr 2 19:27 /dev/spidev2.0crw-rw---- 1 root spi 153, 1 Apr 2 19:27 /dev/spidev2.1

Also, the slots file in sysfs is updated accordingly:

root@bbb:~# cat /sys/devices/platform/bone_capemgr/slots 0: PF---- -1 1: PF---- -1 2: PF---- -1 3: PF---- -1 4: P-O-L- 0 Override Board Name,00A0,Override Manuf,BB-SPIDEV1

Now, everything should be in place. However, as the last step, we can decide to copy ournew system from the microSD card to eMMC in order to boot directly from the on-boardeMMC device, thus avoiding pressing the user button each time we power up the board.

现在,/dev 目录中应该出现两个新字符设备:

Installing the Developing System

[ 70 ]

'src/arm/univ-nhdmi-00A0.dtbo' -> '/lib/firmware/univ-nhdmi-00A0.dtbo'update-initramfs: Generating /boot/initrd.img-4.4.7-bone9cape overlays have been built and added to /lib/firmware & /boot/initrd.img-4.4.7-bone9, please reboot

OK, now, we can safely reboot the system to test it.

After reboot, to display the current overlay configuration, we can use the following catcommand:

root@arm:~# cat /sys/devices/platform/bone_capemgr/slots 0: PF---- -1 1: PF---- -1 2: PF---- -1 3: PF---- -1

Then, we can try to enable the second SPI bus char device using the following command:

root@bbb:~# echo BB-SPIDEV1 > /sys/devices/platform/bone_capemgr/slotsbone_capemgr bone_capemgr: part_number 'BB-SPIDEV1', version 'N/A'bone_capemgr bone_capemgr: slot #4: overridebone_capemgr bone_capemgr: Using override eeprom data at slot 4bone_capemgr bone_capemgr: slot #4: 'Override Board Name,00A0,Override Manuf,BB-SPIDEV1'bone_capemgr bone_capemgr: slot #4: dtbo 'BB-SPIDEV1-00A0.dtbo'loaded; overlay id#0

Now, two new char devices should appear in the /dev directory:

root@bbb:~# ls -l /dev/spidev*crw-rw---- 1 root spi 153, 0 Apr 2 19:27 /dev/spidev2.0crw-rw---- 1 root spi 153, 1 Apr 2 19:27 /dev/spidev2.1

Also, the slots file in sysfs is updated accordingly:

root@bbb:~# cat /sys/devices/platform/bone_capemgr/slots 0: PF---- -1 1: PF---- -1 2: PF---- -1 3: PF---- -1 4: P-O-L- 0 Override Board Name,00A0,Override Manuf,BB-SPIDEV1

Now, everything should be in place. However, as the last step, we can decide to copy ournew system from the microSD card to eMMC in order to boot directly from the on-boardeMMC device, thus avoiding pressing the user button each time we power up the board.

另外,sysfs 中的 slot 文件也被相应地更新了 :

Installing the Developing System

[ 70 ]

'src/arm/univ-nhdmi-00A0.dtbo' -> '/lib/firmware/univ-nhdmi-00A0.dtbo'update-initramfs: Generating /boot/initrd.img-4.4.7-bone9cape overlays have been built and added to /lib/firmware & /boot/initrd.img-4.4.7-bone9, please reboot

OK, now, we can safely reboot the system to test it.

After reboot, to display the current overlay configuration, we can use the following catcommand:

root@arm:~# cat /sys/devices/platform/bone_capemgr/slots 0: PF---- -1 1: PF---- -1 2: PF---- -1 3: PF---- -1

Then, we can try to enable the second SPI bus char device using the following command:

root@bbb:~# echo BB-SPIDEV1 > /sys/devices/platform/bone_capemgr/slotsbone_capemgr bone_capemgr: part_number 'BB-SPIDEV1', version 'N/A'bone_capemgr bone_capemgr: slot #4: overridebone_capemgr bone_capemgr: Using override eeprom data at slot 4bone_capemgr bone_capemgr: slot #4: 'Override Board Name,00A0,Override Manuf,BB-SPIDEV1'bone_capemgr bone_capemgr: slot #4: dtbo 'BB-SPIDEV1-00A0.dtbo'loaded; overlay id#0

Now, two new char devices should appear in the /dev directory:

root@bbb:~# ls -l /dev/spidev*crw-rw---- 1 root spi 153, 0 Apr 2 19:27 /dev/spidev2.0crw-rw---- 1 root spi 153, 1 Apr 2 19:27 /dev/spidev2.1

Also, the slots file in sysfs is updated accordingly:

root@bbb:~# cat /sys/devices/platform/bone_capemgr/slots 0: PF---- -1 1: PF---- -1 2: PF---- -1 3: PF---- -1 4: P-O-L- 0 Override Board Name,00A0,Override Manuf,BB-SPIDEV1

Now, everything should be in place. However, as the last step, we can decide to copy ournew system from the microSD card to eMMC in order to boot directly from the on-boardeMMC device, thus avoiding pressing the user button each time we power up the board.

现在,一切都应该到位。然而,最后一步,我们决定将新系统从 microSD 卡复制到

eMMC,以便直接从板载 eMMC 存储中启动,从而避免在每次上电时按下用户按钮。

为此,我们必须安装三个新的软件包(initramfs-tools,dosfstools 和 rsync),然后使用

Robert C. Nelson 存档的脚本:

Installing the Developing System

[ 71 ]

To do this, we have to install three new packages (initramfs-tools, dosfstools, andrsync) and then use a script form the Robert C. Nelson archive:

root@bbb:~# wget https://raw.githubusercontent.com/RobertCNelson/boot-scripts/master/tools/eMMC/bbb-eMMC-flasher-eewiki-ext4.sh

Then, we just need to execute it using the following two commands, and the BeagleBoneBlack will start rewriting the eMMC contents:

root@bbb:~# chmod +x bbb-eMMC-flasher-eewiki-ext4.shroot@bbb:~# /bin/bash ./bbb-eMMC-flasher-eewiki-ext4.sh

SAMA5D3 Xplained – USB and networkingEven for the SAMA5D3 Xplained, we can have a pretty prompt. So, let's change it as donefor the BeagleBone Black:

root@arm:~# echo a5d3 > /etc/hostnameroot@arm:~# sed -i -e's/\<arm\>/a5d3/g' /etc/hosts

Now, we can reboot, and we should get a new welcome message as shown here:

Debian GNU/Linux 8 a5d3 ttyS0default username:password is [debian:temppwd]a5d3 login:

Then, we will update the distribution repositories and install the aptitude tool as done forthe host machine:

root@a5d3:~# apt-get updateroot@a5d3:~# apt-get install aptitude

OK, now, we can try to replicate BeagleBone Black's configuration, allowing an sshconnection via the USB device port. However, this time, we'll do more. In fact, we willinstall two kinds of different virtual connections over the USB cable: an Ethernet and aserial connection.

This configuration can be done on the BeagleBone Black too.

然后,我们只需要执行以下两个命令,BeagleBone Black 就开始重写 eMMC:

Installing the Developing System

[ 71 ]

To do this, we have to install three new packages (initramfs-tools, dosfstools, andrsync) and then use a script form the Robert C. Nelson archive:

root@bbb:~# wget https://raw.githubusercontent.com/RobertCNelson/boot-scripts/master/tools/eMMC/bbb-eMMC-flasher-eewiki-ext4.sh

Then, we just need to execute it using the following two commands, and the BeagleBoneBlack will start rewriting the eMMC contents:

root@bbb:~# chmod +x bbb-eMMC-flasher-eewiki-ext4.shroot@bbb:~# /bin/bash ./bbb-eMMC-flasher-eewiki-ext4.sh

SAMA5D3 Xplained – USB and networkingEven for the SAMA5D3 Xplained, we can have a pretty prompt. So, let's change it as donefor the BeagleBone Black:

root@arm:~# echo a5d3 > /etc/hostnameroot@arm:~# sed -i -e's/\<arm\>/a5d3/g' /etc/hosts

Now, we can reboot, and we should get a new welcome message as shown here:

Debian GNU/Linux 8 a5d3 ttyS0default username:password is [debian:temppwd]a5d3 login:

Then, we will update the distribution repositories and install the aptitude tool as done forthe host machine:

root@a5d3:~# apt-get updateroot@a5d3:~# apt-get install aptitude

OK, now, we can try to replicate BeagleBone Black's configuration, allowing an sshconnection via the USB device port. However, this time, we'll do more. In fact, we willinstall two kinds of different virtual connections over the USB cable: an Ethernet and aserial connection.

This configuration can be done on the BeagleBone Black too.

1.4.2 通过 USB、网络设置 SAMA5D3 Xplained

对于 SAMA5D3 Xplained,我们可以有一个很好的先例,就像 BeagleBone Black 一样

操作:

Installing the Developing System

[ 71 ]

To do this, we have to install three new packages (initramfs-tools, dosfstools, andrsync) and then use a script form the Robert C. Nelson archive:

root@bbb:~# wget https://raw.githubusercontent.com/RobertCNelson/boot-scripts/master/tools/eMMC/bbb-eMMC-flasher-eewiki-ext4.sh

Then, we just need to execute it using the following two commands, and the BeagleBoneBlack will start rewriting the eMMC contents:

root@bbb:~# chmod +x bbb-eMMC-flasher-eewiki-ext4.shroot@bbb:~# /bin/bash ./bbb-eMMC-flasher-eewiki-ext4.sh

SAMA5D3 Xplained – USB and networkingEven for the SAMA5D3 Xplained, we can have a pretty prompt. So, let's change it as donefor the BeagleBone Black:

root@arm:~# echo a5d3 > /etc/hostnameroot@arm:~# sed -i -e's/\<arm\>/a5d3/g' /etc/hosts

Now, we can reboot, and we should get a new welcome message as shown here:

Debian GNU/Linux 8 a5d3 ttyS0default username:password is [debian:temppwd]a5d3 login:

Then, we will update the distribution repositories and install the aptitude tool as done forthe host machine:

root@a5d3:~# apt-get updateroot@a5d3:~# apt-get install aptitude

OK, now, we can try to replicate BeagleBone Black's configuration, allowing an sshconnection via the USB device port. However, this time, we'll do more. In fact, we willinstall two kinds of different virtual connections over the USB cable: an Ethernet and aserial connection.

This configuration can be done on the BeagleBone Black too.

现在,我们重启,新的欢迎消息如下所示:

Installing the Developing System

[ 71 ]

To do this, we have to install three new packages (initramfs-tools, dosfstools, andrsync) and then use a script form the Robert C. Nelson archive:

root@bbb:~# wget https://raw.githubusercontent.com/RobertCNelson/boot-scripts/master/tools/eMMC/bbb-eMMC-flasher-eewiki-ext4.sh

Then, we just need to execute it using the following two commands, and the BeagleBoneBlack will start rewriting the eMMC contents:

root@bbb:~# chmod +x bbb-eMMC-flasher-eewiki-ext4.shroot@bbb:~# /bin/bash ./bbb-eMMC-flasher-eewiki-ext4.sh

SAMA5D3 Xplained – USB and networkingEven for the SAMA5D3 Xplained, we can have a pretty prompt. So, let's change it as donefor the BeagleBone Black:

root@arm:~# echo a5d3 > /etc/hostnameroot@arm:~# sed -i -e's/\<arm\>/a5d3/g' /etc/hosts

Now, we can reboot, and we should get a new welcome message as shown here:

Debian GNU/Linux 8 a5d3 ttyS0default username:password is [debian:temppwd]a5d3 login:

Then, we will update the distribution repositories and install the aptitude tool as done forthe host machine:

root@a5d3:~# apt-get updateroot@a5d3:~# apt-get install aptitude

OK, now, we can try to replicate BeagleBone Black's configuration, allowing an sshconnection via the USB device port. However, this time, we'll do more. In fact, we willinstall two kinds of different virtual connections over the USB cable: an Ethernet and aserial connection.

This configuration can be done on the BeagleBone Black too.

然后,我们将更新系统的库并安装适用于主机的 aptitude 工具:

Installing the Developing System

[ 71 ]

To do this, we have to install three new packages (initramfs-tools, dosfstools, andrsync) and then use a script form the Robert C. Nelson archive:

root@bbb:~# wget https://raw.githubusercontent.com/RobertCNelson/boot-scripts/master/tools/eMMC/bbb-eMMC-flasher-eewiki-ext4.sh

Then, we just need to execute it using the following two commands, and the BeagleBoneBlack will start rewriting the eMMC contents:

root@bbb:~# chmod +x bbb-eMMC-flasher-eewiki-ext4.shroot@bbb:~# /bin/bash ./bbb-eMMC-flasher-eewiki-ext4.sh

SAMA5D3 Xplained – USB and networkingEven for the SAMA5D3 Xplained, we can have a pretty prompt. So, let's change it as donefor the BeagleBone Black:

root@arm:~# echo a5d3 > /etc/hostnameroot@arm:~# sed -i -e's/\<arm\>/a5d3/g' /etc/hosts

Now, we can reboot, and we should get a new welcome message as shown here:

Debian GNU/Linux 8 a5d3 ttyS0default username:password is [debian:temppwd]a5d3 login:

Then, we will update the distribution repositories and install the aptitude tool as done forthe host machine:

root@a5d3:~# apt-get updateroot@a5d3:~# apt-get install aptitude

OK, now, we can try to replicate BeagleBone Black's configuration, allowing an sshconnection via the USB device port. However, this time, we'll do more. In fact, we willinstall two kinds of different virtual connections over the USB cable: an Ethernet and aserial connection.

This configuration can be done on the BeagleBone Black too.

Page 40: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

40   第一部分 基 础 知 识

现在我们可以尝试复制 BeagleBone Black 的配置,通过 USB 设备端口进行 ssh 连接。

但这次,我们要做更多的事情。其实我们通过 USB 电缆有安装两种不同的连接方式:以太

网和串行连接。

注意:这个配置也可以在 BeagleBone Black 上完成。

为此,我们需要 USB 小工具驱动程序(请参阅先前为 SAMA5D3 Xplained 完成的内核

配置设置):

Installing the Developing System

[ 72 ]

To do this, we need the USB gadget driver named CDC Composite Device (Ethernet andACM) (see the kernel configuration settings done earlier for the SAMA5D3 Xplained):

root@a5d3:~# modprobe g_cdc host_addr=78:A5:04:CA:CB:01

The kernel messages we should see on the serial console are reported here, and they showthat we have two new devices now:

using random self ethernet addressusing random host ethernet addressusing host ethernet address: 78:A5:04:CA:CB:01usb0: HOST MAC 78:a5:04:ca:cb:01usb0: MAC 22:6c:23:f0:10:62g_cdc gadget: CDC Composite Gadget, version: King Kamehameha Day 2008g_cdc gadget: g_cdc readyg_cdc gadget: high-speed config #1: CDC Composite (ECM + ACM)

In fact, now. we should have a new Ethernet device named usb0:

root@a5d3:~# ifconfig usb0usb0 Link encap:Ethernet HWaddr da:a0:89:f9:a6:1d BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

And , we should have a new serial port:

root@a5d3:~# ls -l /dev/ttyGS0crw-rw---- 1 root dialout 250, 0 Apr 2 18:28 /dev/ttyGS0

To force this new setting at every boot, we can add the kernel module name to the auto-loading module system:

root@a5d3:~# echo "g_cdc" >> /etc/modules-load.d/modules.confroot@a5d3:~# echo "options g_cdc host_addr=78:A5:04:CA:CB:01" >> /etc/modprobe.d/modules.conf

The host_addr parameter is needed to allow the host PC to recognize ourdevice and then correctly configure it by forcing a well-known MACaddress each time we start the board.

Then, we can reboot the board, and the kernel module should be already present:

root@a5d3:~# lsmodModule Size Used by

我们在串口控制台应该会看到的内核消息,显示有两个新设备如下:

Installing the Developing System

[ 72 ]

To do this, we need the USB gadget driver named CDC Composite Device (Ethernet andACM) (see the kernel configuration settings done earlier for the SAMA5D3 Xplained):

root@a5d3:~# modprobe g_cdc host_addr=78:A5:04:CA:CB:01

The kernel messages we should see on the serial console are reported here, and they showthat we have two new devices now:

using random self ethernet addressusing random host ethernet addressusing host ethernet address: 78:A5:04:CA:CB:01usb0: HOST MAC 78:a5:04:ca:cb:01usb0: MAC 22:6c:23:f0:10:62g_cdc gadget: CDC Composite Gadget, version: King Kamehameha Day 2008g_cdc gadget: g_cdc readyg_cdc gadget: high-speed config #1: CDC Composite (ECM + ACM)

In fact, now. we should have a new Ethernet device named usb0:

root@a5d3:~# ifconfig usb0usb0 Link encap:Ethernet HWaddr da:a0:89:f9:a6:1d BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

And , we should have a new serial port:

root@a5d3:~# ls -l /dev/ttyGS0crw-rw---- 1 root dialout 250, 0 Apr 2 18:28 /dev/ttyGS0

To force this new setting at every boot, we can add the kernel module name to the auto-loading module system:

root@a5d3:~# echo "g_cdc" >> /etc/modules-load.d/modules.confroot@a5d3:~# echo "options g_cdc host_addr=78:A5:04:CA:CB:01" >> /etc/modprobe.d/modules.conf

The host_addr parameter is needed to allow the host PC to recognize ourdevice and then correctly configure it by forcing a well-known MACaddress each time we start the board.

Then, we can reboot the board, and the kernel module should be already present:

root@a5d3:~# lsmodModule Size Used by

实际上,现在应该有一个名为 usb0 的以太网设备:

Installing the Developing System

[ 72 ]

To do this, we need the USB gadget driver named CDC Composite Device (Ethernet andACM) (see the kernel configuration settings done earlier for the SAMA5D3 Xplained):

root@a5d3:~# modprobe g_cdc host_addr=78:A5:04:CA:CB:01

The kernel messages we should see on the serial console are reported here, and they showthat we have two new devices now:

using random self ethernet addressusing random host ethernet addressusing host ethernet address: 78:A5:04:CA:CB:01usb0: HOST MAC 78:a5:04:ca:cb:01usb0: MAC 22:6c:23:f0:10:62g_cdc gadget: CDC Composite Gadget, version: King Kamehameha Day 2008g_cdc gadget: g_cdc readyg_cdc gadget: high-speed config #1: CDC Composite (ECM + ACM)

In fact, now. we should have a new Ethernet device named usb0:

root@a5d3:~# ifconfig usb0usb0 Link encap:Ethernet HWaddr da:a0:89:f9:a6:1d BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

And , we should have a new serial port:

root@a5d3:~# ls -l /dev/ttyGS0crw-rw---- 1 root dialout 250, 0 Apr 2 18:28 /dev/ttyGS0

To force this new setting at every boot, we can add the kernel module name to the auto-loading module system:

root@a5d3:~# echo "g_cdc" >> /etc/modules-load.d/modules.confroot@a5d3:~# echo "options g_cdc host_addr=78:A5:04:CA:CB:01" >> /etc/modprobe.d/modules.conf

The host_addr parameter is needed to allow the host PC to recognize ourdevice and then correctly configure it by forcing a well-known MACaddress each time we start the board.

Then, we can reboot the board, and the kernel module should be already present:

root@a5d3:~# lsmodModule Size Used by

而且,我们应该有一个新的串口:

Installing the Developing System

[ 72 ]

To do this, we need the USB gadget driver named CDC Composite Device (Ethernet andACM) (see the kernel configuration settings done earlier for the SAMA5D3 Xplained):

root@a5d3:~# modprobe g_cdc host_addr=78:A5:04:CA:CB:01

The kernel messages we should see on the serial console are reported here, and they showthat we have two new devices now:

using random self ethernet addressusing random host ethernet addressusing host ethernet address: 78:A5:04:CA:CB:01usb0: HOST MAC 78:a5:04:ca:cb:01usb0: MAC 22:6c:23:f0:10:62g_cdc gadget: CDC Composite Gadget, version: King Kamehameha Day 2008g_cdc gadget: g_cdc readyg_cdc gadget: high-speed config #1: CDC Composite (ECM + ACM)

In fact, now. we should have a new Ethernet device named usb0:

root@a5d3:~# ifconfig usb0usb0 Link encap:Ethernet HWaddr da:a0:89:f9:a6:1d BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

And , we should have a new serial port:

root@a5d3:~# ls -l /dev/ttyGS0crw-rw---- 1 root dialout 250, 0 Apr 2 18:28 /dev/ttyGS0

To force this new setting at every boot, we can add the kernel module name to the auto-loading module system:

root@a5d3:~# echo "g_cdc" >> /etc/modules-load.d/modules.confroot@a5d3:~# echo "options g_cdc host_addr=78:A5:04:CA:CB:01" >> /etc/modprobe.d/modules.conf

The host_addr parameter is needed to allow the host PC to recognize ourdevice and then correctly configure it by forcing a well-known MACaddress each time we start the board.

Then, we can reboot the board, and the kernel module should be already present:

root@a5d3:~# lsmodModule Size Used by

要在每次启动时强制使用这个新设置,我们可以把内核模块名字添加到系统的自动加

载模块:

Installing the Developing System

[ 72 ]

To do this, we need the USB gadget driver named CDC Composite Device (Ethernet andACM) (see the kernel configuration settings done earlier for the SAMA5D3 Xplained):

root@a5d3:~# modprobe g_cdc host_addr=78:A5:04:CA:CB:01

The kernel messages we should see on the serial console are reported here, and they showthat we have two new devices now:

using random self ethernet addressusing random host ethernet addressusing host ethernet address: 78:A5:04:CA:CB:01usb0: HOST MAC 78:a5:04:ca:cb:01usb0: MAC 22:6c:23:f0:10:62g_cdc gadget: CDC Composite Gadget, version: King Kamehameha Day 2008g_cdc gadget: g_cdc readyg_cdc gadget: high-speed config #1: CDC Composite (ECM + ACM)

In fact, now. we should have a new Ethernet device named usb0:

root@a5d3:~# ifconfig usb0usb0 Link encap:Ethernet HWaddr da:a0:89:f9:a6:1d BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

And , we should have a new serial port:

root@a5d3:~# ls -l /dev/ttyGS0crw-rw---- 1 root dialout 250, 0 Apr 2 18:28 /dev/ttyGS0

To force this new setting at every boot, we can add the kernel module name to the auto-loading module system:

root@a5d3:~# echo "g_cdc" >> /etc/modules-load.d/modules.confroot@a5d3:~# echo "options g_cdc host_addr=78:A5:04:CA:CB:01" >> /etc/modprobe.d/modules.conf

The host_addr parameter is needed to allow the host PC to recognize ourdevice and then correctly configure it by forcing a well-known MACaddress each time we start the board.

Then, we can reboot the board, and the kernel module should be already present:

root@a5d3:~# lsmodModule Size Used by

注意:host_addr 参数要允许主机识别我们的设备,然后在每次启动电路板时通过

MAC 地址来正确配置它。

然后,我们重新启动主板,并且内核模块也应该存在了:

Installing the Developing System

[ 72 ]

To do this, we need the USB gadget driver named CDC Composite Device (Ethernet andACM) (see the kernel configuration settings done earlier for the SAMA5D3 Xplained):

root@a5d3:~# modprobe g_cdc host_addr=78:A5:04:CA:CB:01

The kernel messages we should see on the serial console are reported here, and they showthat we have two new devices now:

using random self ethernet addressusing random host ethernet addressusing host ethernet address: 78:A5:04:CA:CB:01usb0: HOST MAC 78:a5:04:ca:cb:01usb0: MAC 22:6c:23:f0:10:62g_cdc gadget: CDC Composite Gadget, version: King Kamehameha Day 2008g_cdc gadget: g_cdc readyg_cdc gadget: high-speed config #1: CDC Composite (ECM + ACM)

In fact, now. we should have a new Ethernet device named usb0:

root@a5d3:~# ifconfig usb0usb0 Link encap:Ethernet HWaddr da:a0:89:f9:a6:1d BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

And , we should have a new serial port:

root@a5d3:~# ls -l /dev/ttyGS0crw-rw---- 1 root dialout 250, 0 Apr 2 18:28 /dev/ttyGS0

To force this new setting at every boot, we can add the kernel module name to the auto-loading module system:

root@a5d3:~# echo "g_cdc" >> /etc/modules-load.d/modules.confroot@a5d3:~# echo "options g_cdc host_addr=78:A5:04:CA:CB:01" >> /etc/modprobe.d/modules.conf

The host_addr parameter is needed to allow the host PC to recognize ourdevice and then correctly configure it by forcing a well-known MACaddress each time we start the board.

Then, we can reboot the board, and the kernel module should be already present:

root@a5d3:~# lsmodModule Size Used by

Installing the Developing System

[ 73 ]

usb_f_acm 3680 1u_serial 6214 3 usb_f_acmusb_f_ecm 4430 1g_cdc 2165 0u_ether 6869 2 g_cdc,usb_f_ecmlibcomposite 26527 3 g_cdc,usb_f_acm,usb_f_ecm

Good! Now, we can start configuring them.

Regarding the Ethernet device, we can repeat what we did for the BeagleBone Black byadding the following lines to the /etc/network/interfaces file:

allow-hotplug usb0iface usb0 inet static address 192.168.8.2 netmask 255.255.255.252 network 192.168.8.0

In order to avoid conflicts with the BeagleBone Black setting, we used the192.168.8.X subnetwork for this board instead of 192.168.7.X usedfor the BeagleBone Black.

Then, we've to restart the networking system as follows:

root@a5d3:~# /etc/init.d/networking restart

As we did earlier, we may need to enable the root login via ssh bymodifying the PermitRootLogin setting in the /etc/ssh/sshd_configfile and then restarting the daemon.

Then, we have to install the udhcpd daemon as we did earlier and then replace its currentconfiguration in the /etc/udhcpd.conf file with the following settings:

start 192.168.8.1end 192.168.8.1interface usb0max_leases 1option subnet 255.255.255.252

We can save the daemon's old configuration with the following command: root@a5d3:~# mv /etc/udhcpd.conf /etc/udhcpd.conf.orig

Page 41: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

第1章 开发系统的安装   41Installing the Developing System

[ 73 ]

usb_f_acm 3680 1u_serial 6214 3 usb_f_acmusb_f_ecm 4430 1g_cdc 2165 0u_ether 6869 2 g_cdc,usb_f_ecmlibcomposite 26527 3 g_cdc,usb_f_acm,usb_f_ecm

Good! Now, we can start configuring them.

Regarding the Ethernet device, we can repeat what we did for the BeagleBone Black byadding the following lines to the /etc/network/interfaces file:

allow-hotplug usb0iface usb0 inet static address 192.168.8.2 netmask 255.255.255.252 network 192.168.8.0

In order to avoid conflicts with the BeagleBone Black setting, we used the192.168.8.X subnetwork for this board instead of 192.168.7.X usedfor the BeagleBone Black.

Then, we've to restart the networking system as follows:

root@a5d3:~# /etc/init.d/networking restart

As we did earlier, we may need to enable the root login via ssh bymodifying the PermitRootLogin setting in the /etc/ssh/sshd_configfile and then restarting the daemon.

Then, we have to install the udhcpd daemon as we did earlier and then replace its currentconfiguration in the /etc/udhcpd.conf file with the following settings:

start 192.168.8.1end 192.168.8.1interface usb0max_leases 1option subnet 255.255.255.252

We can save the daemon's old configuration with the following command: root@a5d3:~# mv /etc/udhcpd.conf /etc/udhcpd.conf.orig

好了,现在我们开始配置它们。

关于以太网设备,我们可以重复之前在 BeagleBone Black 所做的操作,在 / etc / network / interfaces 文件中添加以下内容:

Installing the Developing System

[ 73 ]

usb_f_acm 3680 1u_serial 6214 3 usb_f_acmusb_f_ecm 4430 1g_cdc 2165 0u_ether 6869 2 g_cdc,usb_f_ecmlibcomposite 26527 3 g_cdc,usb_f_acm,usb_f_ecm

Good! Now, we can start configuring them.

Regarding the Ethernet device, we can repeat what we did for the BeagleBone Black byadding the following lines to the /etc/network/interfaces file:

allow-hotplug usb0iface usb0 inet static address 192.168.8.2 netmask 255.255.255.252 network 192.168.8.0

In order to avoid conflicts with the BeagleBone Black setting, we used the192.168.8.X subnetwork for this board instead of 192.168.7.X usedfor the BeagleBone Black.

Then, we've to restart the networking system as follows:

root@a5d3:~# /etc/init.d/networking restart

As we did earlier, we may need to enable the root login via ssh bymodifying the PermitRootLogin setting in the /etc/ssh/sshd_configfile and then restarting the daemon.

Then, we have to install the udhcpd daemon as we did earlier and then replace its currentconfiguration in the /etc/udhcpd.conf file with the following settings:

start 192.168.8.1end 192.168.8.1interface usb0max_leases 1option subnet 255.255.255.252

We can save the daemon's old configuration with the following command: root@a5d3:~# mv /etc/udhcpd.conf /etc/udhcpd.conf.orig

提示:为了避免与 BeagleBone Black 设置发生冲突,我们使用 192.168.8.X 子网来

代替在 BeagleBone Black 中使用过的 192.168.7.X。

然后,我们重新启动网络系统,如下所示:

Installing the Developing System

[ 73 ]

usb_f_acm 3680 1u_serial 6214 3 usb_f_acmusb_f_ecm 4430 1g_cdc 2165 0u_ether 6869 2 g_cdc,usb_f_ecmlibcomposite 26527 3 g_cdc,usb_f_acm,usb_f_ecm

Good! Now, we can start configuring them.

Regarding the Ethernet device, we can repeat what we did for the BeagleBone Black byadding the following lines to the /etc/network/interfaces file:

allow-hotplug usb0iface usb0 inet static address 192.168.8.2 netmask 255.255.255.252 network 192.168.8.0

In order to avoid conflicts with the BeagleBone Black setting, we used the192.168.8.X subnetwork for this board instead of 192.168.7.X usedfor the BeagleBone Black.

Then, we've to restart the networking system as follows:

root@a5d3:~# /etc/init.d/networking restart

As we did earlier, we may need to enable the root login via ssh bymodifying the PermitRootLogin setting in the /etc/ssh/sshd_configfile and then restarting the daemon.

Then, we have to install the udhcpd daemon as we did earlier and then replace its currentconfiguration in the /etc/udhcpd.conf file with the following settings:

start 192.168.8.1end 192.168.8.1interface usb0max_leases 1option subnet 255.255.255.252

We can save the daemon's old configuration with the following command: root@a5d3:~# mv /etc/udhcpd.conf /etc/udhcpd.conf.orig

提示: 和 前 面 一 样, 我 们 可 能 需 要 通 过 修 改 /etc/ssh/sshd_config 文 件 中 的

PermitRootLogin 设置,然后重新启动守护进程,来启动 ssh 的 root 登录。

然后,我们和以前一样安装 udhcpd 守护进程,然后使用以下设置替换 /etc/udhcpd.conf文件中的当前配置:

Installing the Developing System

[ 73 ]

usb_f_acm 3680 1u_serial 6214 3 usb_f_acmusb_f_ecm 4430 1g_cdc 2165 0u_ether 6869 2 g_cdc,usb_f_ecmlibcomposite 26527 3 g_cdc,usb_f_acm,usb_f_ecm

Good! Now, we can start configuring them.

Regarding the Ethernet device, we can repeat what we did for the BeagleBone Black byadding the following lines to the /etc/network/interfaces file:

allow-hotplug usb0iface usb0 inet static address 192.168.8.2 netmask 255.255.255.252 network 192.168.8.0

In order to avoid conflicts with the BeagleBone Black setting, we used the192.168.8.X subnetwork for this board instead of 192.168.7.X usedfor the BeagleBone Black.

Then, we've to restart the networking system as follows:

root@a5d3:~# /etc/init.d/networking restart

As we did earlier, we may need to enable the root login via ssh bymodifying the PermitRootLogin setting in the /etc/ssh/sshd_configfile and then restarting the daemon.

Then, we have to install the udhcpd daemon as we did earlier and then replace its currentconfiguration in the /etc/udhcpd.conf file with the following settings:

start 192.168.8.1end 192.168.8.1interface usb0max_leases 1option subnet 255.255.255.252

We can save the daemon's old configuration with the following command: root@a5d3:~# mv /etc/udhcpd.conf /etc/udhcpd.conf.orig

提示:我们可以使用以下命令保存守护进程的旧配置:

Installing the Developing System

[ 73 ]

usb_f_acm 3680 1u_serial 6214 3 usb_f_acmusb_f_ecm 4430 1g_cdc 2165 0u_ether 6869 2 g_cdc,usb_f_ecmlibcomposite 26527 3 g_cdc,usb_f_acm,usb_f_ecm

Good! Now, we can start configuring them.

Regarding the Ethernet device, we can repeat what we did for the BeagleBone Black byadding the following lines to the /etc/network/interfaces file:

allow-hotplug usb0iface usb0 inet static address 192.168.8.2 netmask 255.255.255.252 network 192.168.8.0

In order to avoid conflicts with the BeagleBone Black setting, we used the192.168.8.X subnetwork for this board instead of 192.168.7.X usedfor the BeagleBone Black.

Then, we've to restart the networking system as follows:

root@a5d3:~# /etc/init.d/networking restart

As we did earlier, we may need to enable the root login via ssh bymodifying the PermitRootLogin setting in the /etc/ssh/sshd_configfile and then restarting the daemon.

Then, we have to install the udhcpd daemon as we did earlier and then replace its currentconfiguration in the /etc/udhcpd.conf file with the following settings:

start 192.168.8.1end 192.168.8.1interface usb0max_leases 1option subnet 255.255.255.252

We can save the daemon's old configuration with the following command: root@a5d3:~# mv /etc/udhcpd.conf /etc/udhcpd.conf.orig

然后,我们必须通过在 / etc / default / udhcpd 文件中将 DHCPD_ENABLED 变量设置

为 yes 启用它。然后重启守护进程:

Installing the Developing System

[ 74 ]

Then, we must enable it by setting the DHCPD_ENABLED variable to yes in the/etc/default/udhcpd file. Then, restart the daemon:

root@a5d3:~# /etc/init.d/udhcpd restart

Now, regarding the serial connection, we can add the ability to do a serial login by adding anew getty service on it with the following commands:

root@a5d3:~# systemctl enable [email protected] symlink from /etc/systemd/system/getty.target.wants/[email protected] to /lib/systemd/system/[email protected]@a5d3:~# systemctl start [email protected]

Now, we only need to add the following lines to the /etc/securetty file in order to allowthe root user to login using this new communication channel:

# USB gadgetttyGS0

OK, now, if we take a look at the host PC's kernel messages, we should see something aslike this:

usb 1-1: new high-speed USB device number 3 using ehci-pciusb 1-1: New USB device found, idVendor=0525, idProduct=a4aausb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0usb 1-1: Product: CDC Composite Gadgetusb 1-1: Manufacturer: Linux 4.4.6-sama5-armv7-r5 with atmel_usba_udccdc_ether 1-1:1.0 eth0: register 'cdc_ether' at usb-0000:00:0b.0-1,CDC Ethernet Device, 78:a5:04:ca:cb:01cdc_acm 1-1:1.2: ttyACM0: USB ACM device

Then, we can test the networking connection with the ssh command with the followingcommand line on the host PC:

$ ssh [email protected] authenticity of host '192.168.8.2 (192.168.8.2)' can't be established.ECDSA key fingerprint is SHA256:OduXLAPIYgNR7Xxh8XbhSum+zOKHBbgv/tnbeDj2O30.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.8.2' (ECDSA) to the list of [email protected]'s password:

现在,关于串行连接,我们可以使用以下命令添加 getty 服务来进行串行登录:

Installing the Developing System

[ 74 ]

Then, we must enable it by setting the DHCPD_ENABLED variable to yes in the/etc/default/udhcpd file. Then, restart the daemon:

root@a5d3:~# /etc/init.d/udhcpd restart

Now, regarding the serial connection, we can add the ability to do a serial login by adding anew getty service on it with the following commands:

root@a5d3:~# systemctl enable [email protected] symlink from /etc/systemd/system/getty.target.wants/[email protected] to /lib/systemd/system/[email protected]@a5d3:~# systemctl start [email protected]

Now, we only need to add the following lines to the /etc/securetty file in order to allowthe root user to login using this new communication channel:

# USB gadgetttyGS0

OK, now, if we take a look at the host PC's kernel messages, we should see something aslike this:

usb 1-1: new high-speed USB device number 3 using ehci-pciusb 1-1: New USB device found, idVendor=0525, idProduct=a4aausb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0usb 1-1: Product: CDC Composite Gadgetusb 1-1: Manufacturer: Linux 4.4.6-sama5-armv7-r5 with atmel_usba_udccdc_ether 1-1:1.0 eth0: register 'cdc_ether' at usb-0000:00:0b.0-1,CDC Ethernet Device, 78:a5:04:ca:cb:01cdc_acm 1-1:1.2: ttyACM0: USB ACM device

Then, we can test the networking connection with the ssh command with the followingcommand line on the host PC:

$ ssh [email protected] authenticity of host '192.168.8.2 (192.168.8.2)' can't be established.ECDSA key fingerprint is SHA256:OduXLAPIYgNR7Xxh8XbhSum+zOKHBbgv/tnbeDj2O30.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.8.2' (ECDSA) to the list of [email protected]'s password:

Page 42: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

42   第一部分 基 础 知 识

现在,我们只需要将以下内容添加到 / etc / securetty 文件中,以允许 root 用户使用新

的通信通道进行登录:

Installing the Developing System

[ 74 ]

Then, we must enable it by setting the DHCPD_ENABLED variable to yes in the/etc/default/udhcpd file. Then, restart the daemon:

root@a5d3:~# /etc/init.d/udhcpd restart

Now, regarding the serial connection, we can add the ability to do a serial login by adding anew getty service on it with the following commands:

root@a5d3:~# systemctl enable [email protected] symlink from /etc/systemd/system/getty.target.wants/[email protected] to /lib/systemd/system/[email protected]@a5d3:~# systemctl start [email protected]

Now, we only need to add the following lines to the /etc/securetty file in order to allowthe root user to login using this new communication channel:

# USB gadgetttyGS0

OK, now, if we take a look at the host PC's kernel messages, we should see something aslike this:

usb 1-1: new high-speed USB device number 3 using ehci-pciusb 1-1: New USB device found, idVendor=0525, idProduct=a4aausb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0usb 1-1: Product: CDC Composite Gadgetusb 1-1: Manufacturer: Linux 4.4.6-sama5-armv7-r5 with atmel_usba_udccdc_ether 1-1:1.0 eth0: register 'cdc_ether' at usb-0000:00:0b.0-1,CDC Ethernet Device, 78:a5:04:ca:cb:01cdc_acm 1-1:1.2: ttyACM0: USB ACM device

Then, we can test the networking connection with the ssh command with the followingcommand line on the host PC:

$ ssh [email protected] authenticity of host '192.168.8.2 (192.168.8.2)' can't be established.ECDSA key fingerprint is SHA256:OduXLAPIYgNR7Xxh8XbhSum+zOKHBbgv/tnbeDj2O30.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.8.2' (ECDSA) to the list of [email protected]'s password:

现在,我们来看看主机的内核消息,应该看到如下所示:

Installing the Developing System

[ 74 ]

Then, we must enable it by setting the DHCPD_ENABLED variable to yes in the/etc/default/udhcpd file. Then, restart the daemon:

root@a5d3:~# /etc/init.d/udhcpd restart

Now, regarding the serial connection, we can add the ability to do a serial login by adding anew getty service on it with the following commands:

root@a5d3:~# systemctl enable [email protected] symlink from /etc/systemd/system/getty.target.wants/[email protected] to /lib/systemd/system/[email protected]@a5d3:~# systemctl start [email protected]

Now, we only need to add the following lines to the /etc/securetty file in order to allowthe root user to login using this new communication channel:

# USB gadgetttyGS0

OK, now, if we take a look at the host PC's kernel messages, we should see something aslike this:

usb 1-1: new high-speed USB device number 3 using ehci-pciusb 1-1: New USB device found, idVendor=0525, idProduct=a4aausb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0usb 1-1: Product: CDC Composite Gadgetusb 1-1: Manufacturer: Linux 4.4.6-sama5-armv7-r5 with atmel_usba_udccdc_ether 1-1:1.0 eth0: register 'cdc_ether' at usb-0000:00:0b.0-1,CDC Ethernet Device, 78:a5:04:ca:cb:01cdc_acm 1-1:1.2: ttyACM0: USB ACM device

Then, we can test the networking connection with the ssh command with the followingcommand line on the host PC:

$ ssh [email protected] authenticity of host '192.168.8.2 (192.168.8.2)' can't be established.ECDSA key fingerprint is SHA256:OduXLAPIYgNR7Xxh8XbhSum+zOKHBbgv/tnbeDj2O30.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.8.2' (ECDSA) to the list of [email protected]'s password:

然后,我们可以在主机上使用 ssh 命令测试网络连接:

Installing the Developing System

[ 74 ]

Then, we must enable it by setting the DHCPD_ENABLED variable to yes in the/etc/default/udhcpd file. Then, restart the daemon:

root@a5d3:~# /etc/init.d/udhcpd restart

Now, regarding the serial connection, we can add the ability to do a serial login by adding anew getty service on it with the following commands:

root@a5d3:~# systemctl enable [email protected] symlink from /etc/systemd/system/getty.target.wants/[email protected] to /lib/systemd/system/[email protected]@a5d3:~# systemctl start [email protected]

Now, we only need to add the following lines to the /etc/securetty file in order to allowthe root user to login using this new communication channel:

# USB gadgetttyGS0

OK, now, if we take a look at the host PC's kernel messages, we should see something aslike this:

usb 1-1: new high-speed USB device number 3 using ehci-pciusb 1-1: New USB device found, idVendor=0525, idProduct=a4aausb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0usb 1-1: Product: CDC Composite Gadgetusb 1-1: Manufacturer: Linux 4.4.6-sama5-armv7-r5 with atmel_usba_udccdc_ether 1-1:1.0 eth0: register 'cdc_ether' at usb-0000:00:0b.0-1,CDC Ethernet Device, 78:a5:04:ca:cb:01cdc_acm 1-1:1.2: ttyACM0: USB ACM device

Then, we can test the networking connection with the ssh command with the followingcommand line on the host PC:

$ ssh [email protected] authenticity of host '192.168.8.2 (192.168.8.2)' can't be established.ECDSA key fingerprint is SHA256:OduXLAPIYgNR7Xxh8XbhSum+zOKHBbgv/tnbeDj2O30.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.8.2' (ECDSA) to the list of [email protected]'s password:

现在,输入 root 用户密码,作业完成:

Installing the Developing System

[ 75 ]

Now, enter the root's password that is the root string and the job is done:

The programs included with the Debian GNU/Linux system are freesoftware; the exact distribution terms for each program aredescribed in the individual files in /usr/share/doc/*/copyright.Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to theextent permitted by applicable law.Last login: Sat Apr 2 18:02:23 2016root@a5d3:~#

Then, the serial connection can be tested using the minicom command as shown here:

$ sudo minicom -o -D /dev/ttyACM0Debian GNU/Linux 8 a5d3 ttyGS0default username:password is [debian:temppwd]a5d3 login:

Now, our SAMA5D3 Xplained is ready, and we can step next to the Wandboard.

Wandboard – USB and networking (wired andwireless)Again, we like to have a pretty prompt. So, let's change it as we did for the BeagleBoneBlack:

root@arm:~# echo wb > /etc/hostnameroot@arm:~# sed -i -e's/\<wb\>/a5d3/g' /etc/hosts

Now, we can reboot the system, and we should get a new welcome message as shown here:

Debian GNU/Linux 8 wb ttymxc0default username:password is [debian:temppwd]wb login:

Then, we will update the distribution repositories and install the aptitude tool as done forthe host machine:

root@wb:~# apt-get updateroot@wb:~# apt-get install aptitude

然后,可以使用 minicom 命令进行串口连接测试,如下:

Installing the Developing System

[ 75 ]

Now, enter the root's password that is the root string and the job is done:

The programs included with the Debian GNU/Linux system are freesoftware; the exact distribution terms for each program aredescribed in the individual files in /usr/share/doc/*/copyright.Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to theextent permitted by applicable law.Last login: Sat Apr 2 18:02:23 2016root@a5d3:~#

Then, the serial connection can be tested using the minicom command as shown here:

$ sudo minicom -o -D /dev/ttyACM0Debian GNU/Linux 8 a5d3 ttyGS0default username:password is [debian:temppwd]a5d3 login:

Now, our SAMA5D3 Xplained is ready, and we can step next to the Wandboard.

Wandboard – USB and networking (wired andwireless)Again, we like to have a pretty prompt. So, let's change it as we did for the BeagleBoneBlack:

root@arm:~# echo wb > /etc/hostnameroot@arm:~# sed -i -e's/\<wb\>/a5d3/g' /etc/hosts

Now, we can reboot the system, and we should get a new welcome message as shown here:

Debian GNU/Linux 8 wb ttymxc0default username:password is [debian:temppwd]wb login:

Then, we will update the distribution repositories and install the aptitude tool as done forthe host machine:

root@wb:~# apt-get updateroot@wb:~# apt-get install aptitude

现在,我们的 SAMA5D3 Xplained 已经准备就绪了,接下来开始设置 Wandboard。

1.4.3 通过 USB、有线网络和无线网络设置 Wandboard

同样,我们有之前的先例,像操作 BeagleBone Black 一样操作它:

Installing the Developing System

[ 75 ]

Now, enter the root's password that is the root string and the job is done:

The programs included with the Debian GNU/Linux system are freesoftware; the exact distribution terms for each program aredescribed in the individual files in /usr/share/doc/*/copyright.Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to theextent permitted by applicable law.Last login: Sat Apr 2 18:02:23 2016root@a5d3:~#

Then, the serial connection can be tested using the minicom command as shown here:

$ sudo minicom -o -D /dev/ttyACM0Debian GNU/Linux 8 a5d3 ttyGS0default username:password is [debian:temppwd]a5d3 login:

Now, our SAMA5D3 Xplained is ready, and we can step next to the Wandboard.

Wandboard – USB and networking (wired andwireless)Again, we like to have a pretty prompt. So, let's change it as we did for the BeagleBoneBlack:

root@arm:~# echo wb > /etc/hostnameroot@arm:~# sed -i -e's/\<wb\>/a5d3/g' /etc/hosts

Now, we can reboot the system, and we should get a new welcome message as shown here:

Debian GNU/Linux 8 wb ttymxc0default username:password is [debian:temppwd]wb login:

Then, we will update the distribution repositories and install the aptitude tool as done forthe host machine:

root@wb:~# apt-get updateroot@wb:~# apt-get install aptitude

现在,我们重启系统, 看到一个新的欢迎信息,如下所示:

Page 43: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

第1章 开发系统的安装   43

Installing the Developing System

[ 75 ]

Now, enter the root's password that is the root string and the job is done:

The programs included with the Debian GNU/Linux system are freesoftware; the exact distribution terms for each program aredescribed in the individual files in /usr/share/doc/*/copyright.Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to theextent permitted by applicable law.Last login: Sat Apr 2 18:02:23 2016root@a5d3:~#

Then, the serial connection can be tested using the minicom command as shown here:

$ sudo minicom -o -D /dev/ttyACM0Debian GNU/Linux 8 a5d3 ttyGS0default username:password is [debian:temppwd]a5d3 login:

Now, our SAMA5D3 Xplained is ready, and we can step next to the Wandboard.

Wandboard – USB and networking (wired andwireless)Again, we like to have a pretty prompt. So, let's change it as we did for the BeagleBoneBlack:

root@arm:~# echo wb > /etc/hostnameroot@arm:~# sed -i -e's/\<wb\>/a5d3/g' /etc/hosts

Now, we can reboot the system, and we should get a new welcome message as shown here:

Debian GNU/Linux 8 wb ttymxc0default username:password is [debian:temppwd]wb login:

Then, we will update the distribution repositories and install the aptitude tool as done forthe host machine:

root@wb:~# apt-get updateroot@wb:~# apt-get install aptitude

然后,我们将更新系统库并安装适用于主机的 aptitude 工具:

Installing the Developing System

[ 75 ]

Now, enter the root's password that is the root string and the job is done:

The programs included with the Debian GNU/Linux system are freesoftware; the exact distribution terms for each program aredescribed in the individual files in /usr/share/doc/*/copyright.Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to theextent permitted by applicable law.Last login: Sat Apr 2 18:02:23 2016root@a5d3:~#

Then, the serial connection can be tested using the minicom command as shown here:

$ sudo minicom -o -D /dev/ttyACM0Debian GNU/Linux 8 a5d3 ttyGS0default username:password is [debian:temppwd]a5d3 login:

Now, our SAMA5D3 Xplained is ready, and we can step next to the Wandboard.

Wandboard – USB and networking (wired andwireless)Again, we like to have a pretty prompt. So, let's change it as we did for the BeagleBoneBlack:

root@arm:~# echo wb > /etc/hostnameroot@arm:~# sed -i -e's/\<wb\>/a5d3/g' /etc/hosts

Now, we can reboot the system, and we should get a new welcome message as shown here:

Debian GNU/Linux 8 wb ttymxc0default username:password is [debian:temppwd]wb login:

Then, we will update the distribution repositories and install the aptitude tool as done forthe host machine:

root@wb:~# apt-get updateroot@wb:~# apt-get install aptitude

现在我们可以尝试允许 ssh 连接,通过 USB 设备端口来复制 BeagleBone Black 的配

置。所以,使用 aptitude 命令安装 udhcpd 软件包:

Installing the Developing System

[ 76 ]

OK, now, we can try to replicate BeagleBone Black's configuration by allowing an sshconnection via the USB device port. So, let's install the udhcpd package using the usualaptitude command:

root@wb:~# aptitude install udhcpd

Then, add the following lines to the /etc/network/interfaces file:

allow-hotplug usb0iface usb0 inet static address 192.168.9.2 netmask 255.255.255.252 network 192.168.9.0

In order to avoid conflicts with the BeagleBone Black and SAMA5D3Xplained settings, we used the subnetwork 192.168.9.X for this boardinstead of 192.168.7.X used for the BeagleBone Black or the192.168.8.X used for the SAMA5D3 Xplained.

Then, restart the networking system as follows:

root@wb:~# /etc/init.d/networking restart

As we did earlier, we may need to enable the root login via ssh bymodifying the PermitRootLogin setting in the /etc/ssh/sshd_configfile and then restarting the daemon.

Then, we have to install the udhcpd daemon as we did earlier and then replace its currentconfiguration in /etc/udhcpd.conf file with the following settings:

start 192.168.9.1end 192.168.9.1interface usb0max_leases 1option subnet 255.255.255.252

We can save the daemon's old configuration with the following command:

root@wb:~# mv /etc/udhcpd.conf /etc/udhcpd.conf.orig

然后,将以下内容添加到 / etc / network / interfaces 文件中:

Installing the Developing System

[ 76 ]

OK, now, we can try to replicate BeagleBone Black's configuration by allowing an sshconnection via the USB device port. So, let's install the udhcpd package using the usualaptitude command:

root@wb:~# aptitude install udhcpd

Then, add the following lines to the /etc/network/interfaces file:

allow-hotplug usb0iface usb0 inet static address 192.168.9.2 netmask 255.255.255.252 network 192.168.9.0

In order to avoid conflicts with the BeagleBone Black and SAMA5D3Xplained settings, we used the subnetwork 192.168.9.X for this boardinstead of 192.168.7.X used for the BeagleBone Black or the192.168.8.X used for the SAMA5D3 Xplained.

Then, restart the networking system as follows:

root@wb:~# /etc/init.d/networking restart

As we did earlier, we may need to enable the root login via ssh bymodifying the PermitRootLogin setting in the /etc/ssh/sshd_configfile and then restarting the daemon.

Then, we have to install the udhcpd daemon as we did earlier and then replace its currentconfiguration in /etc/udhcpd.conf file with the following settings:

start 192.168.9.1end 192.168.9.1interface usb0max_leases 1option subnet 255.255.255.252

We can save the daemon's old configuration with the following command:

root@wb:~# mv /etc/udhcpd.conf /etc/udhcpd.conf.orig

注意:为了避免与 BeagleBone Black 和 SAMA5D3 Xplained 设置发生冲突,我

们 使 用 子 网 192.168.9.X 代 替 BeagleBone Black 里 的 192.168.7.X 或 SAMA5D3 Xplained 里的 192.168.8.X。

然后,重新启动网络系统,如下所示:

Installing the Developing System

[ 76 ]

OK, now, we can try to replicate BeagleBone Black's configuration by allowing an sshconnection via the USB device port. So, let's install the udhcpd package using the usualaptitude command:

root@wb:~# aptitude install udhcpd

Then, add the following lines to the /etc/network/interfaces file:

allow-hotplug usb0iface usb0 inet static address 192.168.9.2 netmask 255.255.255.252 network 192.168.9.0

In order to avoid conflicts with the BeagleBone Black and SAMA5D3Xplained settings, we used the subnetwork 192.168.9.X for this boardinstead of 192.168.7.X used for the BeagleBone Black or the192.168.8.X used for the SAMA5D3 Xplained.

Then, restart the networking system as follows:

root@wb:~# /etc/init.d/networking restart

As we did earlier, we may need to enable the root login via ssh bymodifying the PermitRootLogin setting in the /etc/ssh/sshd_configfile and then restarting the daemon.

Then, we have to install the udhcpd daemon as we did earlier and then replace its currentconfiguration in /etc/udhcpd.conf file with the following settings:

start 192.168.9.1end 192.168.9.1interface usb0max_leases 1option subnet 255.255.255.252

We can save the daemon's old configuration with the following command:

root@wb:~# mv /etc/udhcpd.conf /etc/udhcpd.conf.orig

注意:如 前 所 述, 我 们 可 能 需 要 通 过 修 改 / etc / ssh / sshd_config 文 件 中 的

PermitRootLogin 设置,然后重新启动守护进程,使得 ssh 可以通过 root 登录。

然后,像之前一样安装 udhcpd 守护进程,然后使用以下设置替换 /etc/udhcpd.conf 文件中的旧配置:

Installing the Developing System

[ 76 ]

OK, now, we can try to replicate BeagleBone Black's configuration by allowing an sshconnection via the USB device port. So, let's install the udhcpd package using the usualaptitude command:

root@wb:~# aptitude install udhcpd

Then, add the following lines to the /etc/network/interfaces file:

allow-hotplug usb0iface usb0 inet static address 192.168.9.2 netmask 255.255.255.252 network 192.168.9.0

In order to avoid conflicts with the BeagleBone Black and SAMA5D3Xplained settings, we used the subnetwork 192.168.9.X for this boardinstead of 192.168.7.X used for the BeagleBone Black or the192.168.8.X used for the SAMA5D3 Xplained.

Then, restart the networking system as follows:

root@wb:~# /etc/init.d/networking restart

As we did earlier, we may need to enable the root login via ssh bymodifying the PermitRootLogin setting in the /etc/ssh/sshd_configfile and then restarting the daemon.

Then, we have to install the udhcpd daemon as we did earlier and then replace its currentconfiguration in /etc/udhcpd.conf file with the following settings:

start 192.168.9.1end 192.168.9.1interface usb0max_leases 1option subnet 255.255.255.252

We can save the daemon's old configuration with the following command:

root@wb:~# mv /etc/udhcpd.conf /etc/udhcpd.conf.orig

提示:我们可以使用以下命令保存守护进程的配置:

Installing the Developing System

[ 76 ]

OK, now, we can try to replicate BeagleBone Black's configuration by allowing an sshconnection via the USB device port. So, let's install the udhcpd package using the usualaptitude command:

root@wb:~# aptitude install udhcpd

Then, add the following lines to the /etc/network/interfaces file:

allow-hotplug usb0iface usb0 inet static address 192.168.9.2 netmask 255.255.255.252 network 192.168.9.0

In order to avoid conflicts with the BeagleBone Black and SAMA5D3Xplained settings, we used the subnetwork 192.168.9.X for this boardinstead of 192.168.7.X used for the BeagleBone Black or the192.168.8.X used for the SAMA5D3 Xplained.

Then, restart the networking system as follows:

root@wb:~# /etc/init.d/networking restart

As we did earlier, we may need to enable the root login via ssh bymodifying the PermitRootLogin setting in the /etc/ssh/sshd_configfile and then restarting the daemon.

Then, we have to install the udhcpd daemon as we did earlier and then replace its currentconfiguration in /etc/udhcpd.conf file with the following settings:

start 192.168.9.1end 192.168.9.1interface usb0max_leases 1option subnet 255.255.255.252

We can save the daemon's old configuration with the following command:

root@wb:~# mv /etc/udhcpd.conf /etc/udhcpd.conf.orig

然后,我们必须在 / etc / default / udhcpd 文件中将 DHCPD_ENABLED 变量设置为 yes

启用它。然后重新启动守护进程:

Installing the Developing System

[ 77 ]

Then, we must enable it by setting the DHCPD_ENABLED variable to yes in the/etc/default/udhcpd file. Then, restart the daemon:

root@wb:~# /etc/init.d/udhcpd restart

Now, if we try to connect to the host PC with our Wandboard, we should see the followingmessage on the serial console:

g_ether gadget: high-speed config #1: CDC Ethernet (ECM)IPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready

A new Ethernet device should appear as reported here:

root@wb:~# ifconfig usb0usb0 Link encap:Ethernet HWaddr 62:1e:f6:88:9b:42 inet addr:192.168.9.2 Bcast:192.168.9.3 Mask:255.255.255.252 inet6 addr: fe80::601e:f6ff:fe88:9b42/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:30 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:5912 (5.7 KiB)

OK, now, we have to configure the new Ethernet device on the host, and then, we can try anssh connection as shown here:

$ ssh [email protected]

On my host PC that is Ubuntu based, before executing the ssh commandearlier, we had to properly configure the new Ethernet device by adding anew network connection in the entry Edit Connections… in the systemsettings menu.

The authenticity of host '192.168.9.2 (192.168.9.2)' can't be established.ECDSA key fingerprint is SHA256:Xp2Bf+YOWL0kDSm00GxXw9CY5wH+ECnPzp0EHp3+GM8.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.9.2' (ECDSA) to the list of [email protected]'s password:

Now, enter the root's password that is the root string and the job is done:

The programs included with the Debian GNU/Linux system are freesoftware; the exact distribution terms for each program aredescribed in the individual files in /usr/share/doc/*/copyright.

Page 44: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

44   第一部分 基 础 知 识

现在,如果我们尝试使用 Wandboard 连接到主机 PC,我们应该在串口控制台上看到以

下消息:

Installing the Developing System

[ 77 ]

Then, we must enable it by setting the DHCPD_ENABLED variable to yes in the/etc/default/udhcpd file. Then, restart the daemon:

root@wb:~# /etc/init.d/udhcpd restart

Now, if we try to connect to the host PC with our Wandboard, we should see the followingmessage on the serial console:

g_ether gadget: high-speed config #1: CDC Ethernet (ECM)IPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready

A new Ethernet device should appear as reported here:

root@wb:~# ifconfig usb0usb0 Link encap:Ethernet HWaddr 62:1e:f6:88:9b:42 inet addr:192.168.9.2 Bcast:192.168.9.3 Mask:255.255.255.252 inet6 addr: fe80::601e:f6ff:fe88:9b42/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:30 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:5912 (5.7 KiB)

OK, now, we have to configure the new Ethernet device on the host, and then, we can try anssh connection as shown here:

$ ssh [email protected]

On my host PC that is Ubuntu based, before executing the ssh commandearlier, we had to properly configure the new Ethernet device by adding anew network connection in the entry Edit Connections… in the systemsettings menu.

The authenticity of host '192.168.9.2 (192.168.9.2)' can't be established.ECDSA key fingerprint is SHA256:Xp2Bf+YOWL0kDSm00GxXw9CY5wH+ECnPzp0EHp3+GM8.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.9.2' (ECDSA) to the list of [email protected]'s password:

Now, enter the root's password that is the root string and the job is done:

The programs included with the Debian GNU/Linux system are freesoftware; the exact distribution terms for each program aredescribed in the individual files in /usr/share/doc/*/copyright.

一个新就绪的以太网设备应该出现,如下所示:

Installing the Developing System

[ 77 ]

Then, we must enable it by setting the DHCPD_ENABLED variable to yes in the/etc/default/udhcpd file. Then, restart the daemon:

root@wb:~# /etc/init.d/udhcpd restart

Now, if we try to connect to the host PC with our Wandboard, we should see the followingmessage on the serial console:

g_ether gadget: high-speed config #1: CDC Ethernet (ECM)IPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready

A new Ethernet device should appear as reported here:

root@wb:~# ifconfig usb0usb0 Link encap:Ethernet HWaddr 62:1e:f6:88:9b:42 inet addr:192.168.9.2 Bcast:192.168.9.3 Mask:255.255.255.252 inet6 addr: fe80::601e:f6ff:fe88:9b42/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:30 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:5912 (5.7 KiB)

OK, now, we have to configure the new Ethernet device on the host, and then, we can try anssh connection as shown here:

$ ssh [email protected]

On my host PC that is Ubuntu based, before executing the ssh commandearlier, we had to properly configure the new Ethernet device by adding anew network connection in the entry Edit Connections… in the systemsettings menu.

The authenticity of host '192.168.9.2 (192.168.9.2)' can't be established.ECDSA key fingerprint is SHA256:Xp2Bf+YOWL0kDSm00GxXw9CY5wH+ECnPzp0EHp3+GM8.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.9.2' (ECDSA) to the list of [email protected]'s password:

Now, enter the root's password that is the root string and the job is done:

The programs included with the Debian GNU/Linux system are freesoftware; the exact distribution terms for each program aredescribed in the individual files in /usr/share/doc/*/copyright.

接下来,我们必须在主机上配置新的以太网设备,然后我们再尝试 ssh 连接,如下所示:

Installing the Developing System

[ 77 ]

Then, we must enable it by setting the DHCPD_ENABLED variable to yes in the/etc/default/udhcpd file. Then, restart the daemon:

root@wb:~# /etc/init.d/udhcpd restart

Now, if we try to connect to the host PC with our Wandboard, we should see the followingmessage on the serial console:

g_ether gadget: high-speed config #1: CDC Ethernet (ECM)IPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready

A new Ethernet device should appear as reported here:

root@wb:~# ifconfig usb0usb0 Link encap:Ethernet HWaddr 62:1e:f6:88:9b:42 inet addr:192.168.9.2 Bcast:192.168.9.3 Mask:255.255.255.252 inet6 addr: fe80::601e:f6ff:fe88:9b42/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:30 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:5912 (5.7 KiB)

OK, now, we have to configure the new Ethernet device on the host, and then, we can try anssh connection as shown here:

$ ssh [email protected]

On my host PC that is Ubuntu based, before executing the ssh commandearlier, we had to properly configure the new Ethernet device by adding anew network connection in the entry Edit Connections… in the systemsettings menu.

The authenticity of host '192.168.9.2 (192.168.9.2)' can't be established.ECDSA key fingerprint is SHA256:Xp2Bf+YOWL0kDSm00GxXw9CY5wH+ECnPzp0EHp3+GM8.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.9.2' (ECDSA) to the list of [email protected]'s password:

Now, enter the root's password that is the root string and the job is done:

The programs included with the Debian GNU/Linux system are freesoftware; the exact distribution terms for each program aredescribed in the individual files in /usr/share/doc/*/copyright.

提示:我的 PC 系统是基于 Ubuntu 的,在连接之前要确保网络已经配置好,可以

在系统设置菜单的 Edit Connections 添加新的网络连接来配置。

Installing the Developing System

[ 77 ]

Then, we must enable it by setting the DHCPD_ENABLED variable to yes in the/etc/default/udhcpd file. Then, restart the daemon:

root@wb:~# /etc/init.d/udhcpd restart

Now, if we try to connect to the host PC with our Wandboard, we should see the followingmessage on the serial console:

g_ether gadget: high-speed config #1: CDC Ethernet (ECM)IPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready

A new Ethernet device should appear as reported here:

root@wb:~# ifconfig usb0usb0 Link encap:Ethernet HWaddr 62:1e:f6:88:9b:42 inet addr:192.168.9.2 Bcast:192.168.9.3 Mask:255.255.255.252 inet6 addr: fe80::601e:f6ff:fe88:9b42/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:30 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:5912 (5.7 KiB)

OK, now, we have to configure the new Ethernet device on the host, and then, we can try anssh connection as shown here:

$ ssh [email protected]

On my host PC that is Ubuntu based, before executing the ssh commandearlier, we had to properly configure the new Ethernet device by adding anew network connection in the entry Edit Connections… in the systemsettings menu.

The authenticity of host '192.168.9.2 (192.168.9.2)' can't be established.ECDSA key fingerprint is SHA256:Xp2Bf+YOWL0kDSm00GxXw9CY5wH+ECnPzp0EHp3+GM8.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.9.2' (ECDSA) to the list of [email protected]'s password:

Now, enter the root's password that is the root string and the job is done:

The programs included with the Debian GNU/Linux system are freesoftware; the exact distribution terms for each program aredescribed in the individual files in /usr/share/doc/*/copyright.

现在,输入登录密码 root,然后一切就绪:

Installing the Developing System

[ 77 ]

Then, we must enable it by setting the DHCPD_ENABLED variable to yes in the/etc/default/udhcpd file. Then, restart the daemon:

root@wb:~# /etc/init.d/udhcpd restart

Now, if we try to connect to the host PC with our Wandboard, we should see the followingmessage on the serial console:

g_ether gadget: high-speed config #1: CDC Ethernet (ECM)IPv6: ADDRCONF(NETDEV_CHANGE): usb0: link becomes ready

A new Ethernet device should appear as reported here:

root@wb:~# ifconfig usb0usb0 Link encap:Ethernet HWaddr 62:1e:f6:88:9b:42 inet addr:192.168.9.2 Bcast:192.168.9.3 Mask:255.255.255.252 inet6 addr: fe80::601e:f6ff:fe88:9b42/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:30 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:5912 (5.7 KiB)

OK, now, we have to configure the new Ethernet device on the host, and then, we can try anssh connection as shown here:

$ ssh [email protected]

On my host PC that is Ubuntu based, before executing the ssh commandearlier, we had to properly configure the new Ethernet device by adding anew network connection in the entry Edit Connections… in the systemsettings menu.

The authenticity of host '192.168.9.2 (192.168.9.2)' can't be established.ECDSA key fingerprint is SHA256:Xp2Bf+YOWL0kDSm00GxXw9CY5wH+ECnPzp0EHp3+GM8.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.9.2' (ECDSA) to the list of [email protected]'s password:

Now, enter the root's password that is the root string and the job is done:

The programs included with the Debian GNU/Linux system are freesoftware; the exact distribution terms for each program aredescribed in the individual files in /usr/share/doc/*/copyright.

Installing the Developing System

[ 78 ]

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to theextent permitted by applicable law.Last login: Sat Apr 2 17:45:31 2016root@wb:~#

Ok now, as last step, we have to set up the on-board Wi-Fi chip. To do this, we need todownload the firmware. Here are the commands:

root@wb:~# mkdir -p /lib/firmware/brcm/root@wb:~# cd /lib/firmware/brcm/root@wb:/lib/firmware/brcm# wget -c https://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/plain/brcm/brcmfmac4329-sdio.binroot@wb:/lib/firmware/brcm# wget -c https://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/plain/brcm/brcmfmac4330-sdio.binroot@wb:/lib/firmware/brcm# wget -c https://rcn-ee.com/repos/git/meta-fsl-arm-extra/recipes-bsp/broadcom-nvram-config/files/wandboard/brcmfmac4329-sdio.txtroot@wb:/lib/firmware/brcm# wget -c https://rcn-ee.com/repos/git/meta-fsl-arm-extra/recipes-bsp/broadcom-nvram-config/files/wandboard/brcmfmac4330-sdio.txt

Then, we have to reboot the system with the usual reboot command. After reboot, ifeverything works well, we should see a new interface named wlan0 as shown here:

root@wb:~# ifconfig wlan0wlan0 Link encap:Ethernet HWaddr 44:39:c4:9a:96:24 BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

Now, we have to verify that it works. So, as the first step, let's try a wireless network scan:

root@wb:~# ifconfig wlan0 0.0.0.0root@wb:~# iwlist wlan0 scan | grep ESSID ESSID:"EnneEnne"

Great, my home network has been recognized!

We may need to connect the external antenna in order to correctly detectall wireless networks around. The external antenna connector is labeled asANT near the Wi-Fi chip.

接下来,最后一步,我们必须设置板载 Wi-Fi 芯片。为此,我们需要下载固件。命令

如下:

Installing the Developing System

[ 78 ]

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to theextent permitted by applicable law.Last login: Sat Apr 2 17:45:31 2016root@wb:~#

Ok now, as last step, we have to set up the on-board Wi-Fi chip. To do this, we need todownload the firmware. Here are the commands:

root@wb:~# mkdir -p /lib/firmware/brcm/root@wb:~# cd /lib/firmware/brcm/root@wb:/lib/firmware/brcm# wget -c https://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/plain/brcm/brcmfmac4329-sdio.binroot@wb:/lib/firmware/brcm# wget -c https://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/plain/brcm/brcmfmac4330-sdio.binroot@wb:/lib/firmware/brcm# wget -c https://rcn-ee.com/repos/git/meta-fsl-arm-extra/recipes-bsp/broadcom-nvram-config/files/wandboard/brcmfmac4329-sdio.txtroot@wb:/lib/firmware/brcm# wget -c https://rcn-ee.com/repos/git/meta-fsl-arm-extra/recipes-bsp/broadcom-nvram-config/files/wandboard/brcmfmac4330-sdio.txt

Then, we have to reboot the system with the usual reboot command. After reboot, ifeverything works well, we should see a new interface named wlan0 as shown here:

root@wb:~# ifconfig wlan0wlan0 Link encap:Ethernet HWaddr 44:39:c4:9a:96:24 BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

Now, we have to verify that it works. So, as the first step, let's try a wireless network scan:

root@wb:~# ifconfig wlan0 0.0.0.0root@wb:~# iwlist wlan0 scan | grep ESSID ESSID:"EnneEnne"

Great, my home network has been recognized!

We may need to connect the external antenna in order to correctly detectall wireless networks around. The external antenna connector is labeled asANT near the Wi-Fi chip.

Page 45: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

第1章 开发系统的安装   45

Installing the Developing System

[ 78 ]

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to theextent permitted by applicable law.Last login: Sat Apr 2 17:45:31 2016root@wb:~#

Ok now, as last step, we have to set up the on-board Wi-Fi chip. To do this, we need todownload the firmware. Here are the commands:

root@wb:~# mkdir -p /lib/firmware/brcm/root@wb:~# cd /lib/firmware/brcm/root@wb:/lib/firmware/brcm# wget -c https://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/plain/brcm/brcmfmac4329-sdio.binroot@wb:/lib/firmware/brcm# wget -c https://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/plain/brcm/brcmfmac4330-sdio.binroot@wb:/lib/firmware/brcm# wget -c https://rcn-ee.com/repos/git/meta-fsl-arm-extra/recipes-bsp/broadcom-nvram-config/files/wandboard/brcmfmac4329-sdio.txtroot@wb:/lib/firmware/brcm# wget -c https://rcn-ee.com/repos/git/meta-fsl-arm-extra/recipes-bsp/broadcom-nvram-config/files/wandboard/brcmfmac4330-sdio.txt

Then, we have to reboot the system with the usual reboot command. After reboot, ifeverything works well, we should see a new interface named wlan0 as shown here:

root@wb:~# ifconfig wlan0wlan0 Link encap:Ethernet HWaddr 44:39:c4:9a:96:24 BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

Now, we have to verify that it works. So, as the first step, let's try a wireless network scan:

root@wb:~# ifconfig wlan0 0.0.0.0root@wb:~# iwlist wlan0 scan | grep ESSID ESSID:"EnneEnne"

Great, my home network has been recognized!

We may need to connect the external antenna in order to correctly detectall wireless networks around. The external antenna connector is labeled asANT near the Wi-Fi chip.

然后,我们通过 reboot 命令重新启动系统。重新启动后,如果一切正常,我们应该看

到一个名为 wlan0 的新界面,如下所示:

Installing the Developing System

[ 78 ]

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to theextent permitted by applicable law.Last login: Sat Apr 2 17:45:31 2016root@wb:~#

Ok now, as last step, we have to set up the on-board Wi-Fi chip. To do this, we need todownload the firmware. Here are the commands:

root@wb:~# mkdir -p /lib/firmware/brcm/root@wb:~# cd /lib/firmware/brcm/root@wb:/lib/firmware/brcm# wget -c https://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/plain/brcm/brcmfmac4329-sdio.binroot@wb:/lib/firmware/brcm# wget -c https://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/plain/brcm/brcmfmac4330-sdio.binroot@wb:/lib/firmware/brcm# wget -c https://rcn-ee.com/repos/git/meta-fsl-arm-extra/recipes-bsp/broadcom-nvram-config/files/wandboard/brcmfmac4329-sdio.txtroot@wb:/lib/firmware/brcm# wget -c https://rcn-ee.com/repos/git/meta-fsl-arm-extra/recipes-bsp/broadcom-nvram-config/files/wandboard/brcmfmac4330-sdio.txt

Then, we have to reboot the system with the usual reboot command. After reboot, ifeverything works well, we should see a new interface named wlan0 as shown here:

root@wb:~# ifconfig wlan0wlan0 Link encap:Ethernet HWaddr 44:39:c4:9a:96:24 BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

Now, we have to verify that it works. So, as the first step, let's try a wireless network scan:

root@wb:~# ifconfig wlan0 0.0.0.0root@wb:~# iwlist wlan0 scan | grep ESSID ESSID:"EnneEnne"

Great, my home network has been recognized!

We may need to connect the external antenna in order to correctly detectall wireless networks around. The external antenna connector is labeled asANT near the Wi-Fi chip.

现在,我们必须验证它是否正常工作。所以首先让我们试一下无线网络扫描:

Installing the Developing System

[ 78 ]

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to theextent permitted by applicable law.Last login: Sat Apr 2 17:45:31 2016root@wb:~#

Ok now, as last step, we have to set up the on-board Wi-Fi chip. To do this, we need todownload the firmware. Here are the commands:

root@wb:~# mkdir -p /lib/firmware/brcm/root@wb:~# cd /lib/firmware/brcm/root@wb:/lib/firmware/brcm# wget -c https://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/plain/brcm/brcmfmac4329-sdio.binroot@wb:/lib/firmware/brcm# wget -c https://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/plain/brcm/brcmfmac4330-sdio.binroot@wb:/lib/firmware/brcm# wget -c https://rcn-ee.com/repos/git/meta-fsl-arm-extra/recipes-bsp/broadcom-nvram-config/files/wandboard/brcmfmac4329-sdio.txtroot@wb:/lib/firmware/brcm# wget -c https://rcn-ee.com/repos/git/meta-fsl-arm-extra/recipes-bsp/broadcom-nvram-config/files/wandboard/brcmfmac4330-sdio.txt

Then, we have to reboot the system with the usual reboot command. After reboot, ifeverything works well, we should see a new interface named wlan0 as shown here:

root@wb:~# ifconfig wlan0wlan0 Link encap:Ethernet HWaddr 44:39:c4:9a:96:24 BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

Now, we have to verify that it works. So, as the first step, let's try a wireless network scan:

root@wb:~# ifconfig wlan0 0.0.0.0root@wb:~# iwlist wlan0 scan | grep ESSID ESSID:"EnneEnne"

Great, my home network has been recognized!

We may need to connect the external antenna in order to correctly detectall wireless networks around. The external antenna connector is labeled asANT near the Wi-Fi chip.

很棒,我的家庭网络已经被识别!

注意:我们可能需要连接外部天线才能检测到所有的无线网络。外部天线连接器在

Wi-Fi 芯片附近被标记为 ANT。

现在,我们可以在这里停止 Wi-Fi 设置,因为本书将在后面适当的一章细讲。

1.4.4 通用设置

在本章结束之前,我会建议您安装一些本书在后面将要用到的一些基本和常用工具。

可以现在安装或者之后需要的时候再安装。

如果我们决定现在安装这些工具,我们必须将开发板连接到 Internet,然后为其设置合

适的网络配置。

如果我们的嵌入式套件不自动进行网络配置,并且我们的局域网中有一个 DHCP 服务

器,我们可以使用 dhclient 命令:

Installing the Developing System

[ 79 ]

For the moment, we can stop the Wi-Fi setup here since it will be restarted later in this bookin a proper chapter.

Common settingsBefore ending this chapter, let me suggest that you install some basic and common toolswe're going to use in this book. We can decide to install these tools now or, when needed,later during the reading of the book.

If we decide to perform this last step and then install these tools right now, we have toconnect our boards to the Internet using, for example, an Ethernet cable, and then setting asuitable network configuration for it.

Let me remember that if our embedded kit doesn't automatically take a networkconfiguration and we have a DHCP server in our LAN, we can force this behavior using thedhclient command:

# dhclient eth0

If we don't have a running DHCP service, we can manually set up a network configurationusing the ifconfig and route commands as shown here:

# ifconfig eth0 <LOCAL-IP-ADDR># route add default gw <GATEWAY-IP-ADDR>

OK, now, to install our tools, we can use the aptitude command again and then wait forthe complete installation:

# aptitude install autoconf git subversion make gcc libtool pkg-config bison build-essential flex strace php5-cli python-pip libpython-dev

SummaryIn this chapter, we took a first look at our new embedded developer kits. You learned howto reinstall a fresh Debian OS from scratch on all systems and how to get access to theirserial consoles.

In the next chapter, we will continue to experience the serial console in order to wellunderstand how we can use it in every contest, from the early booting stages inside thebootloader to the normal system setup and management.

如果我们没有运行的 DHCP 服务,我们可以使用 ifconfig 和 route 命令手动设置网络配

置,如下所示:

Installing the Developing System

[ 79 ]

For the moment, we can stop the Wi-Fi setup here since it will be restarted later in this bookin a proper chapter.

Common settingsBefore ending this chapter, let me suggest that you install some basic and common toolswe're going to use in this book. We can decide to install these tools now or, when needed,later during the reading of the book.

If we decide to perform this last step and then install these tools right now, we have toconnect our boards to the Internet using, for example, an Ethernet cable, and then setting asuitable network configuration for it.

Let me remember that if our embedded kit doesn't automatically take a networkconfiguration and we have a DHCP server in our LAN, we can force this behavior using thedhclient command:

# dhclient eth0

If we don't have a running DHCP service, we can manually set up a network configurationusing the ifconfig and route commands as shown here:

# ifconfig eth0 <LOCAL-IP-ADDR># route add default gw <GATEWAY-IP-ADDR>

OK, now, to install our tools, we can use the aptitude command again and then wait forthe complete installation:

# aptitude install autoconf git subversion make gcc libtool pkg-config bison build-essential flex strace php5-cli python-pip libpython-dev

SummaryIn this chapter, we took a first look at our new embedded developer kits. You learned howto reinstall a fresh Debian OS from scratch on all systems and how to get access to theirserial consoles.

In the next chapter, we will continue to experience the serial console in order to wellunderstand how we can use it in every contest, from the early booting stages inside thebootloader to the normal system setup and management.

现在要安装工具,我们可以再次使用 aptitude 命令,然后等待完整的安装:

Page 46: GNULinux嵌入式快速编程 正文 1-5images.china-pub.com/ebook7890001-7895000/7891600/ch01.pdf · 2018-05-07 · 第一部分 基 础 知 识 第1章 开发系统的安装 第2章

46   第一部分 基 础 知 识

Installing the Developing System

[ 79 ]

For the moment, we can stop the Wi-Fi setup here since it will be restarted later in this bookin a proper chapter.

Common settingsBefore ending this chapter, let me suggest that you install some basic and common toolswe're going to use in this book. We can decide to install these tools now or, when needed,later during the reading of the book.

If we decide to perform this last step and then install these tools right now, we have toconnect our boards to the Internet using, for example, an Ethernet cable, and then setting asuitable network configuration for it.

Let me remember that if our embedded kit doesn't automatically take a networkconfiguration and we have a DHCP server in our LAN, we can force this behavior using thedhclient command:

# dhclient eth0

If we don't have a running DHCP service, we can manually set up a network configurationusing the ifconfig and route commands as shown here:

# ifconfig eth0 <LOCAL-IP-ADDR># route add default gw <GATEWAY-IP-ADDR>

OK, now, to install our tools, we can use the aptitude command again and then wait forthe complete installation:

# aptitude install autoconf git subversion make gcc libtool pkg-config bison build-essential flex strace php5-cli python-pip libpython-dev

SummaryIn this chapter, we took a first look at our new embedded developer kits. You learned howto reinstall a fresh Debian OS from scratch on all systems and how to get access to theirserial consoles.

In the next chapter, we will continue to experience the serial console in order to wellunderstand how we can use it in every contest, from the early booting stages inside thebootloader to the normal system setup and management.

1.5 总结

在本章中,我们先学习了新的嵌入式开发平台。学习了如何重安装一个新的 Debian 操

作系统,以及如何访问其串口控制台。

在下一章中,我们将继续学习串口控制台,从 bootloader 的引导阶段到日常的系统设

置和管理,以便了解如何在后面的测试中使用它。