前往小程序,Get更优阅读体验!
立即前往
发布
社区首页 >专栏 >脱离Arduino IDE的外部编译及上传模式

脱离Arduino IDE的外部编译及上传模式

作者头像
云深无际
发布2020-12-03 15:18:51
发布2020-12-03 15:18:51
1.9K00
代码可运行
举报
文章被收录于专栏:云深之无迹云深之无迹
运行总次数:0
代码可运行

这边先下载一个截图软件,电脑上面没有软件了

代码语言:javascript
代码运行次数:0
复制
https://zh.snipaste.com/

大疆官网下载的安装包里面有这个东西,解压就好.如果不知道我在说什么可能文章不太适合你,可以看看我前面的文章

这个是打开的东西,可以看到是一些bat脚本

我展开以后,是这样的

本文主要的参考来源是大疆官方的文档

本文要解决的问题是,Arduino每次编译太耗费时间,应该怎么办

打开看看是什么内容

右键编辑打开

自带的记事本就可以打开

写好的模样

我把这个框架写了一下

这个地方的位置是

  1. arduino的位置
  2. 相应硬件库的位置

要是自己的Arduino就改成自己的,要是Dji提供的,就写成这个

这个地方为了大家看的明白,我重新写了一下位置

这个地方是官方给的demo

第一个<arduino_loc>

这个地方是硬件库

一定是这个里面的目录


CALL从一个批处理程序调用另一个批处理程序,并且不终止父批处理程序。call命令主要有2种用法,一种是调用其他批处理程序(*.bat,*.exe,*.cmd,*.COM),目前常用的是*.exe文件和*.bat文件;另一种是CALL :label arguments

这个地方我看见了%1这种写法:

bat脚本中的%~的作用

代码语言:javascript
代码运行次数:0
复制
%0,指的是当前脚本,而~代表各种扩展,如下:

%~f0  将 %I 扩展到一个完全合格的路径名 
%~d0  仅将 %I 扩展到一个驱动器号
%~p0  仅将 %I 扩展到一个路径
%~n0  仅将 %I 扩展到一个文件名 
%~x0  仅将 %I 扩展到一个文件扩展名 
%~s0  扩展的路径只含有短名
%~a0  将 %I 扩展到文件的文件属性
%~t0  将 %I 扩展到文件的日期/时间
 %~z0  将 %I 扩展到文件的大小

%1,,代表传给脚本的第一个参数,%~1,也代表第一个参数,只是参数包含引号的时候,将引号去掉。

可以看到,%1是表示传递给脚本的第一个参数的意思

代码语言:javascript
代码运行次数:0
复制
@echo off
call tool_core\build.bat C:\Users\brody.zhang\Desktop\arduino-1.8.12 C:\Users\brody.zhang\Documents\Arduino %1
call tool_core\build.bat <arduino_loc> <lib_loc> %1
call tool_core\flash_firmonly.bat %2 %3

这个地方还相应的出现了 %2 %3,第二个第三个参数的意思

要两个参数

@REN是注释的意思

可以看到是要求参数的

  1. 需要编译的ino的文件的地址
  2. 需要上传的端口号
  3. 你的ino的文件的名字

就像这样

这个是要调用的文件的里面调用的另一个脚本,可以看到是esptool

代码语言:javascript
代码运行次数:0
复制
call tool_core\flash_firmonly.bat %2 %3
代码语言:javascript
代码运行次数:0
复制
--chip esp32 --port %1

 write_flash -z 0X10000 build\%2.ino.bin

传入两个参数,一个是端口号码,这个是一个上传的脚本的名字

代码语言:javascript
代码运行次数:0
复制
call tool_core\build.bat
代码语言:javascript
代码运行次数:0
复制
@echo off
md build
md core_cache

set arduino_path= %1
set arduino_lib_path= %2

%1\arduino-builder.exe -fqbn espressif:esp32:esp32 -build-path build -build-cache core_cache -hardware %arduino_lib_path%\hardware -libraries  %arduino_lib_path%\libraries -libraries  %arduino_lib_path%\hardware\espressif\esp32\libraries -tools %arduino_lib_path%\hardware\espressif\esp32\tools -tools %arduino_path%\tools-builder  %3

这个就是加快编译速度关键的代码,

用到了已经编译过的缓存文件


1.创建文件夹:md 2.删除文件夹:rd 3.重命名文件(夹):ren

4.移动文件(夹):move

代码语言:javascript
代码运行次数:0
复制
%1\arduino-builder.exe -fqbn 
espressif:esp32:esp32 -build-path build -build-cache core_cache -hardware 
%arduino_lib_path%\hardware -libraries  
%arduino_lib_path%\libraries -libraries  
%arduino_lib_path%\hardware\espressif\esp32\libraries -tools 
%arduino_lib_path%\hardware\espressif\esp32\tools -tools 
%arduino_path%\tools-builder  
%3

我试用一下这个编译器

下面一个是英文原版的编译帮助每一个是翻译的

代码语言:javascript
代码运行次数:0
复制
Parameter 'hardware' is mandatory
Usage of C:\Users\yunswj\Desktop\官网Arduino发布0903\Arduino IDE(已集成RMTT支持包)\arduino-1.8.12\arduino-builder.exe:
  -build-cache string
        builds of 'core.a' are saved into this folder to be cached and reused
  -build-options-file string
        Instead of specifying --hardware, --tools etc every time, you can load all such options from a file
  -build-path string
        build path
  -built-in-libraries value
        Specify a built-in 'libraries' folder. These are low priority libraries. Can be added multiple times for specifying multiple built-in 'libraries' folders
  -code-complete-at string
        output code completions for sketch at a specific location. Location format is "file:line:col"    
  -compile
        compiles the given sketch
  -core-api-version string
        version of core APIs (used to populate ARDUINO #define) (default "10600")
  -daemon
        daemonizes and serves its functions via rpc
  -debug-level int
        Turns on debugging messages. The higher, the chattier (default 5)
  -dump-prefs
        dumps build properties used when compiling
  -experimental
        enables experimental features
  -fqbn string
        fully qualified board name
  -hardware value
        Specify a 'hardware' folder. Can be added multiple times for specifying multiple 'hardware' folders
  -ide-version string
        [deprecated] use 'core-api-version' instead (default "10600")
  -jobs int
        specify how many concurrent gcc processes should run at the same time. Defaults to the number of 
available cores on the running machine
  -libraries value
        Specify a 'libraries' folder. Can be added multiple times for specifying multiple 'libraries' folders
  -logger string
        Sets type of logger. Available values are 'human', 'humantags', 'machine' (default "human")
  -prefs value
        Specify a custom preference. Can be added multiple times for specifying multiple custom preferences
  -preprocess
        preprocess the given sketch
  -quiet
        if 'true' doesn't print any warnings or progress or whatever
  -tools value
        Specify a 'tools' folder. Can be added multiple times for specifying multiple 'tools' folders
  -trace
        traces the whole process lifecycle
  -verbose
        if 'true' prints lots of stuff
  -version
        prints version and exits
  -vid-pid string
        specify to use vid/pid specific build properties, as defined in boards.txt
  -warnings string
        Sets warnings level. Available values are 'none', 'default', 'more' and 'all'
代码语言:javascript
代码运行次数:0
复制
参数“硬件”是强制性的
C:\ Users \ yunswj \ Desktop \官网Arduino发布0903 \ Arduino IDE(已集成RMTT支持包)\ arduino-1.8.12 \ arduino-builder.exe的用法:
  -build-cache字符串
        “ core.a”的内部版本保存到此文件夹中以进行缓存和重复使用
  -build-options-文件字符串
        您不必每次都指定--hardware,-tools等,而可以从文件中加载所有此类选项。
  -build-path字符串
        建立路径
  内置的图书馆价值
        指定一个内置的“库”文件夹。这些是低优先级的库。可以多次添加以指定多个内置“库”文件夹
  -code-complete-at字符串
        在特定位置输出草图的代码完成。位置格式为“ file:line:col”
  -编译
        编译给定的草图
  -core-api-version字符串
        核心API的版本(用于填充ARDUINO #define)(默认为“ 10600”)
  -守护进程
        通过rpc守护并服务其功能
  -调试级别的int
        打开调试消息。较高的聊天记录(默认为5)
  -dump-prefs
        转储编译时使用的构建属性
  -实验性的
        启用实验功能
  -fqbn字符串
        完全合格的董事会名称
  -硬件价值
        指定一个“硬件”文件夹。可以多次添加以指定多个“硬件”文件夹
  -ide-version字符串
        [不建议使用]改为使用“ core-api-version”(默认为“ 10600”)
  -工作int
        指定应同时运行多少个并发的gcc进程。默认为
正在运行的计算机上的可用内核
  -图书馆价值
        指定一个“库”文件夹。可以多次添加以指定多个“库”文件夹
  -logger字符串
        设置记录器的类型。可用值是“人类”,“人类标签”,“机器”(默认为“人类”)
  -偏好值
        指定自定义首选项。可以多次添加以指定多个自定义首选项
  -预处理
        预处理给定的草图
  -安静
        如果'true'不显示任何警告或进度或任何其他内容
  -工具价值
        指定一个“工具”文件夹。可以多次添加以指定多个“工具”文件夹
  -跟踪
        追踪整个过程的生命周期
  -冗长
        如果'true'打印很多东西
  -版
        打印版本并退出
  -vid-pid字符串
        指定使用vids / pid特定的构建属性,如boards.txt中所定义
  -警告字符串
        设置警告级别。可用值为“无”,“默认”,“更多”和“全部”

我把文件都翻译了

代码语言:javascript
代码运行次数:0
复制
 完全合格的板子名称

fqbn的参数,看下文的意思

代码语言:javascript
代码运行次数:0
复制
      指定一个“工具”文件夹。可以多次添加以指定多个“工具”文件夹

在这个编译的参数里面有所体现


本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2020-11-30,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 云深之无迹 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • bat脚本中的%~的作用
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档