Embox编译和闪烁
Embox compilation and flashing
我有兴趣尝试通过 JTAG 从 Windows 或 Mac 机器(交叉编译)编译、打包和闪存 Embox 到 MCU,以及我有很多顾虑。
观察我认为 编写 Embox 应用程序并将它们 deploying/flashing 写入 MCU 的正常方式:
如你所见,在我上面的理解中:
- Embox 源代码被编译(通过
make
)到某个文件(目标文件?),<file>.<ext>
- 同时,我的应用程序的源代码被(以某种方式)交叉编译成一个与 Embox
兼容的对象文件(myapp.o)
- 一些工具结合了:(a)
make
生成的 Embox <file>.<ext>
,(b) myapp.o
和 (c) 我指定的任何其他库。它将这些作为输入并生成单个应用程序映像,准备通过 JTAG 进行闪存
我的顾虑,也在插图中指出:
- 运行
make
在 Embox 源代码上生成的 Embox "artifact" 的确切名称和文件扩展名是什么?根据您使用的是 Windows 还是 Mac,此神器是否有所不同?除了 make
之外还需要哪些工具来制作此神器?
- 这个接收 Object/interim 文件并生成单个应用程序图像的神奇工具是什么?此应用图片的确切名称和文件扩展名是什么?
- 我需要什么工具才能将
myapp.c
和 myapp.h
交叉编译成与 Embox 兼容的 myapp.o
?
第一次听说Embox,但是把Embox和你的代码结合起来的工具明显是linker (so a cross ld
from binutils, see documentation of ld
). To understand more about linkers, read Levine's book Linkers and loaders
编译Embox源代码生成的Embox可能是一个库(libembox.a
),或者是一个可重定位的目标文件embox.o
- 可能是由ld -r
生成的)。
生成的应用程序映像可能是原始二进制文件 (.bin
),但如果它由 GRUB 加载程序加载,则可能是 ELF 文件。
我猜构建过程与 Linux 内核构建过程非常相似。
顺便说一句,我认为在 Linux 系统上进行开发会更简单,因为 Linux 每天都使用相同类型的工具。因此,您可以在开发笔记本电脑上安装 Linux。
您需要一个交叉编译器(针对您的目标平台)来编译您的代码以与 Embox 结合。
我是 Embox 开发人员之一,负责构建工具。
Basile has given 对整个过程的正确概述:
- 源代码被编译成一个可重定位的
embox.o
with ld -r
,
- 然后 link 进入
embox
ELF 二进制文件,
- ... 又转化为
.bin
和 .srec
用于经常闪烁。
二进制工件进入 build/base/bin
。
让我补充一些细节。
首先,您可能不需要深入研究link针对 Embox 应用程序的细节。相反,正确的方法是 将您的应用程序 集成到 Mybuild - Embox 构建系统 - 并让它为您处理低级 link 年龄细节。因此,值得先构建香草 Embox,然后在模拟器上看到它 运行。
为 ARM 构建和 运行 宁 Embox
我建议您从 arm/qemu
模板开始。这不适合你的 MCU,但如果你的应用程序没有做一些不寻常的事情,那么在将它移植到目标 MCU 之前在 QEMU 上测试它会更容易。无论如何,这是一个很好的起点,可以检查开发环境是否健全以及一切构建是否正常。
在 Linux 上开发真的会让你的生活更轻松,就像 sudo apt-get install build-essential
加上几个包和安装交叉编译器一样。但是,如果您打算在 Windows 上进行开发,您可能会发现 this guide useful. In addition, you'll need to patch make
to make it work on Windows: Issue 504. And here is how to 设置 QEMU。
ARM推荐的交叉编译器是官方GNU Tools for ARM.
所以基本上,这里是准备 Linux 开发机器用于构建和 运行ning Embox for ARM 的步骤:
sudo add-apt-repository -y ppa:terry.guo/gcc-arm-embedded
sudo apt-get update
sudo apt-get install build-essential gcc-arm-none-eabi u-boot-tools qemu-system
克隆存储库:
git clone https://github.com/embox/embox embox
cd embox
建造arm/qemu
:
make confload-arm/qemu
make
confload
目标使用名为 arm/qemu
的预定义模板初始化 conf/
目录。 conf/
是目标图像(Embox + 您的应用程序)配置所在的位置。
运行 QEMU。有一个方便的包装器,它从 Embox 配置和 运行s QEMU 正确推断出必要的选项:
sudo ./scripts/qemu/auto_qemu
如果一切顺利,您会看到一些东西 like that。键入 help
以列出可用命令。
将您的应用程序添加为 Embox 命令
就个人而言,当我尝试新事物时,我通常 "mimic" 别人的方法是从 application/system 获得第一反馈。在这里,我建议推导,例如一个现有的 cat
command,抛开它的一切,有效地将它变成一个 Hello world 应用程序。
现在,在 src/cmds
中创建目录 hello
并在其中添加两个文件:
hello.c
文件
/**
* Plain C Hello World application.
*/
#include <stdio.h>
int main(int argc, char **argv) {
printf("Hello world!\n");
return 0;
}
如您所见,这是一个普通的 C 程序,不使用任何 Embox 特定的 API。现在让我们将它集成到 Embox 中。
Hello.my
文件
package embox.cmd.hello
@AutoCmd
@Cmd(name = "hello",
help = "<This is what `help hello` will output>",
man = '''
<What is shown when running `man hello`>
''')
module hello {
source "hello.c"
depends embox.compat.libc.all // for stdio
}
现在将新定义的模块添加到配置中。
conf/mods.config
文件
package genconfig
configuration conf {
...
include embox.cmd.hello.hello
}
构建并运行
运行make
。这将使用 Embox 适当地编译 hello.c
和 link 它。之后,运行 使用 sudo ./scripts/qemu/auto_qemu
并在 embox>
提示符中键入 hello
。
就是这样。
关于您的问题
总结:
Embox source code is compiled (via make
) into some file (Object file?), <file>.<ext>
At the same time, my app's source code is cross-compiled (somehow) into an Object file (myapp.o)
that is compatible with Embox
您的应用程序和 Embox 本身都与常规(交叉)编译器一起编译,defined in conf/build.conf
通过 CROSS_COMPILE
变量。
Some tool combines: (a) the Embox <file>.<ext>
produced by make
, (b) myapp.o
and (c) any other libs I specify. It takes these as inputs and produces a single application image that is ready to be flashed via JTAG
这些是 link 编辑 ld
作为构建过程的一部分。
What is the exact name and file extension of the Embox "artifact" produced by running make
on Embox source code? Is this artifact different depending on whether you are on Windows or Mac?
主要构建工件是 build/base/bin/embox
(ELF)和 build/base/bin/embox.bin
(二进制)。如果我没记错的话,这些在所有构建平台上都具有相同的扩展名(好吧,可能会有 embox.exe
而不是 embox
,但这不太可能)。
What tools besides make
are necessary to produce this artifact?
本质上是交叉编译器。 GNU Tools for ARM embedded processors是个不错的选择。
在 Windows 的情况下加上一些怪癖(见上文)。
What is this magic tool that takes in Object/interim files and produces a single app image? What is the exact name and file extension of this app image?
没有这样的神器。 :)
What tools do I need to cross-compile myapp.c
and myapp.h
into a myapp.o
that is Embox compatible?
这再次隐藏在 Mybuild 下。简而言之,它:
- 使用交叉编译器将
myapp.c
编译成 myapp.o
- 如果应用被定义为
@AutoCmd
模块,它:
- 通过将指向
main
的指针与名称 等一些元数据一起存储在命令注册表中注册应用程序
- 从目标文件中删除
main
符号以防止在多个应用程序的情况下发生冲突
- links
myapp.o
因为它是 Embox 的一部分进入 embox.o
然后进入 embox
ELF
我有兴趣尝试通过 JTAG 从 Windows 或 Mac 机器(交叉编译)编译、打包和闪存 Embox 到 MCU,以及我有很多顾虑。
观察我认为 编写 Embox 应用程序并将它们 deploying/flashing 写入 MCU 的正常方式:
如你所见,在我上面的理解中:
- Embox 源代码被编译(通过
make
)到某个文件(目标文件?),<file>.<ext>
- 同时,我的应用程序的源代码被(以某种方式)交叉编译成一个与 Embox 兼容的对象文件(
- 一些工具结合了:(a)
make
生成的 Embox<file>.<ext>
,(b)myapp.o
和 (c) 我指定的任何其他库。它将这些作为输入并生成单个应用程序映像,准备通过 JTAG 进行闪存
myapp.o)
我的顾虑,也在插图中指出:
- 运行
make
在 Embox 源代码上生成的 Embox "artifact" 的确切名称和文件扩展名是什么?根据您使用的是 Windows 还是 Mac,此神器是否有所不同?除了make
之外还需要哪些工具来制作此神器? - 这个接收 Object/interim 文件并生成单个应用程序图像的神奇工具是什么?此应用图片的确切名称和文件扩展名是什么?
- 我需要什么工具才能将
myapp.c
和myapp.h
交叉编译成与 Embox 兼容的myapp.o
?
第一次听说Embox,但是把Embox和你的代码结合起来的工具明显是linker (so a cross ld
from binutils, see documentation of ld
). To understand more about linkers, read Levine's book Linkers and loaders
编译Embox源代码生成的Embox可能是一个库(libembox.a
),或者是一个可重定位的目标文件embox.o
- 可能是由ld -r
生成的)。
生成的应用程序映像可能是原始二进制文件 (.bin
),但如果它由 GRUB 加载程序加载,则可能是 ELF 文件。
我猜构建过程与 Linux 内核构建过程非常相似。
顺便说一句,我认为在 Linux 系统上进行开发会更简单,因为 Linux 每天都使用相同类型的工具。因此,您可以在开发笔记本电脑上安装 Linux。
您需要一个交叉编译器(针对您的目标平台)来编译您的代码以与 Embox 结合。
我是 Embox 开发人员之一,负责构建工具。
Basile has given 对整个过程的正确概述:
- 源代码被编译成一个可重定位的
embox.o
withld -r
, - 然后 link 进入
embox
ELF 二进制文件, - ... 又转化为
.bin
和.srec
用于经常闪烁。
二进制工件进入 build/base/bin
。
让我补充一些细节。
首先,您可能不需要深入研究link针对 Embox 应用程序的细节。相反,正确的方法是 将您的应用程序 集成到 Mybuild - Embox 构建系统 - 并让它为您处理低级 link 年龄细节。因此,值得先构建香草 Embox,然后在模拟器上看到它 运行。
为 ARM 构建和 运行 宁 Embox
我建议您从 arm/qemu
模板开始。这不适合你的 MCU,但如果你的应用程序没有做一些不寻常的事情,那么在将它移植到目标 MCU 之前在 QEMU 上测试它会更容易。无论如何,这是一个很好的起点,可以检查开发环境是否健全以及一切构建是否正常。
在 Linux 上开发真的会让你的生活更轻松,就像 sudo apt-get install build-essential
加上几个包和安装交叉编译器一样。但是,如果您打算在 Windows 上进行开发,您可能会发现 this guide useful. In addition, you'll need to patch make
to make it work on Windows: Issue 504. And here is how to 设置 QEMU。
ARM推荐的交叉编译器是官方GNU Tools for ARM.
所以基本上,这里是准备 Linux 开发机器用于构建和 运行ning Embox for ARM 的步骤:
sudo add-apt-repository -y ppa:terry.guo/gcc-arm-embedded
sudo apt-get update
sudo apt-get install build-essential gcc-arm-none-eabi u-boot-tools qemu-system
克隆存储库:
git clone https://github.com/embox/embox embox
cd embox
建造arm/qemu
:
make confload-arm/qemu
make
confload
目标使用名为 arm/qemu
的预定义模板初始化 conf/
目录。 conf/
是目标图像(Embox + 您的应用程序)配置所在的位置。
运行 QEMU。有一个方便的包装器,它从 Embox 配置和 运行s QEMU 正确推断出必要的选项:
sudo ./scripts/qemu/auto_qemu
如果一切顺利,您会看到一些东西 like that。键入 help
以列出可用命令。
将您的应用程序添加为 Embox 命令
就个人而言,当我尝试新事物时,我通常 "mimic" 别人的方法是从 application/system 获得第一反馈。在这里,我建议推导,例如一个现有的 cat
command,抛开它的一切,有效地将它变成一个 Hello world 应用程序。
现在,在 src/cmds
中创建目录 hello
并在其中添加两个文件:
hello.c
文件
/**
* Plain C Hello World application.
*/
#include <stdio.h>
int main(int argc, char **argv) {
printf("Hello world!\n");
return 0;
}
如您所见,这是一个普通的 C 程序,不使用任何 Embox 特定的 API。现在让我们将它集成到 Embox 中。
Hello.my
文件
package embox.cmd.hello
@AutoCmd
@Cmd(name = "hello",
help = "<This is what `help hello` will output>",
man = '''
<What is shown when running `man hello`>
''')
module hello {
source "hello.c"
depends embox.compat.libc.all // for stdio
}
现在将新定义的模块添加到配置中。
conf/mods.config
文件
package genconfig
configuration conf {
...
include embox.cmd.hello.hello
}
构建并运行
运行make
。这将使用 Embox 适当地编译 hello.c
和 link 它。之后,运行 使用 sudo ./scripts/qemu/auto_qemu
并在 embox>
提示符中键入 hello
。
就是这样。
关于您的问题
总结:
Embox source code is compiled (via
make
) into some file (Object file?),<file>.<ext>
At the same time, my app's source code is cross-compiled (somehow) into an Object file (myapp.o)
that is compatible with Embox
您的应用程序和 Embox 本身都与常规(交叉)编译器一起编译,defined in conf/build.conf
通过 CROSS_COMPILE
变量。
Some tool combines: (a) the Embox
<file>.<ext>
produced bymake
, (b)myapp.o
and (c) any other libs I specify. It takes these as inputs and produces a single application image that is ready to be flashed via JTAG
这些是 link 编辑 ld
作为构建过程的一部分。
What is the exact name and file extension of the Embox "artifact" produced by running
make
on Embox source code? Is this artifact different depending on whether you are on Windows or Mac?
主要构建工件是 build/base/bin/embox
(ELF)和 build/base/bin/embox.bin
(二进制)。如果我没记错的话,这些在所有构建平台上都具有相同的扩展名(好吧,可能会有 embox.exe
而不是 embox
,但这不太可能)。
What tools besides
make
are necessary to produce this artifact?
本质上是交叉编译器。 GNU Tools for ARM embedded processors是个不错的选择。
在 Windows 的情况下加上一些怪癖(见上文)。
What is this magic tool that takes in Object/interim files and produces a single app image? What is the exact name and file extension of this app image?
没有这样的神器。 :)
What tools do I need to cross-compile
myapp.c
andmyapp.h
into amyapp.o
that is Embox compatible?
这再次隐藏在 Mybuild 下。简而言之,它:
- 使用交叉编译器将
myapp.c
编译成myapp.o
- 如果应用被定义为
@AutoCmd
模块,它:- 通过将指向
main
的指针与名称 等一些元数据一起存储在命令注册表中注册应用程序
- 从目标文件中删除
main
符号以防止在多个应用程序的情况下发生冲突
- 通过将指向
- links
myapp.o
因为它是 Embox 的一部分进入embox.o
然后进入embox
ELF