草图的 arduino IDE 构建步骤是什么?

问题描述

我正在尝试构建我自己的基于终端的环境来构建程序并将其上传到我使用 SAMD21 的定制板(就像在 arduino MKRZERO 中一样)

为此,我正在查看 arduino IDE 的详细输出,并尝试将相同的命令/构建步骤移至一个简单的 makefile。我在尝试理解 arduino IDE 在编程阶段和导出二进制阶段执行的一些步骤时遇到了一些困难。

编程

我有这个非常简单的测试代码

void setup() {
// put your setup code here,to run once:

}

int x = 0;

void loop() {
// put your main code here,to run repeatedly:

 x++;
 x--;
 x++;
}

这是新编译的 IDE 上的详细输出(在 IDE 上称为验证):

https://pastebin.com/LnrC8BSi(抱歉不能发太多字符)

我的问题是:

  • 为什么第一个 g++ 命令的输出被发送到 /dev/null ?
  • 从原始代码生成的名为 ctags_target_for_gcc_minus_e.cpp 的文件是什么?

导出二进制文件

IDE 有一个“导出编译后的二进制文件”选项,该选项的输出是:

https://pastebin.com/zGQjgt2h

生成我正在寻找的文件 sketch.ino.with_bootloader.bin。但是,我似乎找不到包含引导加载程序的命令创建此版本。

我正在使用 Atmel SAM-ICE Programmer,因此我可以方便地使用已经包含引导加载程序的二进制文件,因此在使用 openocd load 命令时我不会擦除板上的引导加载程序。但是我似乎无法加载这个 with_bootloader.bin 文件,因为它不包含符号,我得到了这个输出

(gdb) file testProgram.ino.with_bootloader.mkrzero.bin 
«/home/user/Arduino/testProgram/testProgram.ino.with_bootloader.mkrzero.bin»: no está en formato ejecutable: file format not recognized
(gdb) target remote localhost:3333
Remote debugging using localhost:3333
aviso: Architecture rejected target-supplied description
aviso: No executable has been specified and target does not support
determining executable automatically.  Try using the "file" command.
Truncated register 16 in remote 'g' packet
(gdb) load
No se especificó un archivo ejecutable.
Use the command «file» or «exec-file».

非常感谢您对 Arduino IDE 构建过程的任何见解,我真的很想了解每个步骤的作用,哪些对我来说可能不是必需的

解决方法

也许你应该看看 Arduino CLI 而不是逆向工程 IDE。