2026/5/21 5:30:18
网站建设
项目流程
苏州基础网站建设,ui培训公司,网站建设都需要那些材料,小学学校网站模板文章目录 openpnp - Smoothieware - 固件工程编译(msys2-mingw64环境)概述笔记代码分支起点MSYS2 MINGW64 快捷方式对应的实际程序msys2-mingw64安装缺失组件安装git 处理make时缺copy命令修正make all时的错误编译过了将编译优化选项改为-Og指定c标准END openpnp - Smoothiewa…文章目录openpnp - Smoothieware - 固件工程编译(msys2-mingw64环境)概述笔记代码分支起点MSYS2 MINGW64 快捷方式对应的实际程序msys2-mingw64安装缺失组件安装git处理make时缺copy命令修正make all时的错误编译过了将编译优化选项改为-Og指定c标准ENDopenpnp - Smoothieware - 固件工程编译(msys2-mingw64环境)概述准备学习Smoothieware工程将固件调试环境先搭建一下。前面实验已经将 MSYS2 MINGW64 eclipse-cpp arm-gnu-toolchain makefile的单步调试环境搞定了已经可以正常调试LPC17xx-DFU-Bootloader工程。就在这个环境基础上搭建Smoothieware的固件调试环境。先编译过了再整单步调试环境。笔记代码分支起点看自己挑一个带win_install.cmd的后期版本提交点做个分支开始实验。chenxls3561 MINGW64 /D/3rd/openpnp_prj/Smoothieware/Smoothieware $gitremote -v origin https://github.com/Smoothieware/Smoothieware.git(fetch)origin https://github.com/Smoothieware/Smoothieware.git(push)MSYS2 MINGW64 快捷方式对应的实际程序C:\msys64\mingw64.exe // 如果嫌弃找快捷方式麻烦可以自己做个.bat, 直接启动mingw64.exemsys2-mingw64安装缺失组件安装gitmake clean 时显示缺少gitchenxls3561 MINGW64 /d/3rd/openpnp_prj/Smoothieware/Smoothieware $ pacman -Ssgit|grepmingw-w64-x86_64-git mingw64/mingw-w64-x86_64-git-lfs3.7.1-1 mingw64/mingw-w64-x86_64-git-repo0.4.20-2 mingw64/mingw-w64-x86_64-gitg44-7 mingw64/mingw-w64-x86_64-github-cli2.83.1-1 mingw64/mingw-w64-x86_64-gitui0.27.0-1// 查看具体的软件信息看到下列软件是git相关的 pacman -Si mingw-w64-x86_64-git-repo pacman -Si mingw-w64-x86_64-git-lfs// 安装git软件 pacman -S mingw-w64-x86_64-git-repo // 装了这个软件, 并没有git pacman -S mingw-w64-x86_64-git-lfs // 这个软件包中有git// 测试一下是否有git命令可用? $ wheregitC:\msys64\usr\bin\git.exe $git--versiongitversion2.51.2 // 和win10中装的git版本一样现在make clean 执行成功了处理make时缺copy命令先尝试将msys2-mingw64中的cp.exe命令拷贝为copy.exe, 看make时行不行?chenxls3561 MINGW64 /D/3rd/openpnp_prj/Smoothieware/Smoothieware $ where copy 信息: 用提供的模式无法找到文件。 chenxls3561 MINGW64 /D/3rd/openpnp_prj/Smoothieware/Smoothieware $ wherecpC:\msys64\usr\bin\cp.exe chenxls3561 MINGW64 /D/3rd/openpnp_prj/Smoothieware/Smoothieware $cp/usr/bin/cp.exe /usr/bin/copy.exe chenxls3561 MINGW64 /D/3rd/openpnp_prj/Smoothieware/Smoothieware $ where copy C:\msys64\usr\bin\copy.exemake all 时copy语法不对。删掉C:\msys64\usr\bin\copy.exe将win10的copy命令是内部命令无法拷贝到msys2只能去改makefile, 将copy命令改为cp修改 arm-common.mk 如下:# Command line tools that are different between *nix and Windows.# ifeq $(OS) Windows_NTifeq01SHELLcmd.exe REMOVEdel /q REMOVE_DIRrd /s /q COPYcopy CATtype MKDIRmkdir QUIETnul2nulexit0NOSTDOUTnulelseREMOVErm REMOVE_DIRrm -r -f COPYcp CATcat MKDIRmkdir -p QUIET/dev/null21;exit0NOSTDOUT/dev/null endif# Macro which will convert / to \ on Windows.# ifeq $(OS) Windows_NTifeq01define convert-slash$(subst /,\,$1)endefelsedefine convert-slash$1endef endif修改D:\3rd\openpnp_prj\Smoothieware\Smoothieware\mbed\src\Makefile如下# Command line tools that are different between *nix and Windows.# ifeq $(OS) Windows_NTifeq01REMOVEdel /q REMOVE_DIRrd /s /q COPYcopy CATtype MKDIRmkdir QUIETnul2nulexit0NOSTDOUTnulelseREMOVErm REMOVE_DIRrm -r -f COPYcp CATcat MKDIRmkdir -p QUIET/dev/null21;exit0NOSTDOUT/dev/null endif# Macro which will convert / to \ on Windows.# ifeq $(OS) Windows_NTifeq01define convert-slash$(subst /,\,$1)endefelsedefine convert-slash$1endef endif修改 D:\3rd\openpnp_prj\Smoothieware\Smoothieware\src\makefile# generate a git version string# ifneq $(OS) Windows_NTifneq01DEFINES-D__GITVERSIONSTRING__\$(shell ./generate-version.sh)\elseDEFINES-D__GITVERSIONSTRING__\$(shell generate-version.bat)\ endif## ifneq $(OS) Windows_NTifneq01COPYcpelseCOPYcopy endifmake all 时可以进行下去了还有些别的错应该是要特定版本编译器才能正常编译过否则就要改代码。作者推荐的方式是用win_install.cmd下载作者确认过版本的gcc, 然后生成另外一个bat, 指向下载解压后的bin目录进行编译。我后续将makefile工程引入eclipse-cpp, 最好是能用msys2-mingw64的命令行编译过那样在eclipse-cpp中编译工程时就可以和msys2-mingw64编译的过程和效果相同。其实就是arm-gcc版本的不同只要作者代码写的没问题arm-gcc版本差一点问题不大。用作者指定的arm-gcc环境编译警告也是一堆好不到哪里去。如果用作者指定版本的arm-gcc编译器能0警告0错误那我就在eclipse-cpp中指定作者版本的arm-gcc进行编译。可惜不是。改代码吧。将编译日志拷贝下来看到generate-version.sh执行失败估计是权限问题将权限加上(不能只加执行权限因为还要产生文件version.cpp)。cd/D/3rd/openpnp_prj/Smoothieware/Smoothieware/srcchmod777./generate-version.sh还不行修改 D:\3rd\openpnp_prj\Smoothieware\Smoothieware\src\Makefile让 sh 执行.sh, 而不是直接用shell 执行# generate a git version string# ifneq $(OS) Windows_NTifneq01DEFINES-D__GITVERSIONSTRING__\$(shellsh./generate-version.sh)\elseDEFINES-D__GITVERSIONSTRING__\$(shell generate-version.bat)\ endif现在工程总的make clean 执行成功了。修正make all时的错误make all 有些错误准备修正。修改时需要最小化修改哪里缺头文件就加在哪不乱加头文件。根据编译信息找报错文件时用vscode打开源码目录的方式包含整个Makeile工程所在目录方便一些(也可以在源码目录下右击选择菜单any code)执行下面这行命令有报错的话将全部日志拷贝出来找出报错点进行修正然后再执行下面这行组合命令直到编译通过。makecleanclearmakeall 为了节省时间第一次运行上面的命令剩下时间只运行clearmakeall 如果报错时是由于旧代码没完全编译引起的运行完整命令 等都修正完了再运行一次完整的命令确认一下。D:\3rd\openpnp_prj\Smoothieware\Smoothieware\src\libs\Kernel.h#ifndef KERNEL_H#define KERNEL_H#define THEKERNEL Kernel::instance#define THECONVEYOR THEKERNEL-conveyor#define THEROBOT THEKERNEL-robot#include Module.h#include array#include vector#include string#include cstdint // add by meD:\3rd\openpnp_prj\Smoothieware\Smoothieware\src\libs\ConfigValue.h#ifndef CONFIGVALUE_H#define CONFIGVALUE_H#include string#include cstdint // add by meusing std::string;D:\3rd\openpnp_prj\Smoothieware\Smoothieware\src\modules\communication\GcodeDispatch.h#pragma once#include libs/Module.h#include stdio.h#include string#include cstdint // add by meD:\3rd\openpnp_prj\Smoothieware\Smoothieware\src\modules\robot\Block.h#pragma once#include bitset#include ActuatorCoordinates.h#include cstdint // add by meD:\3rd\openpnp_prj\Smoothieware\Smoothieware\src\modules\communication\utils\Gcode.h#ifndef GCODE_H#define GCODE_H#include string#include map#include cstdint // add by meD:\3rd\openpnp_prj\Smoothieware\Smoothieware\src\modules\robot\ActuatorCoordinates.h#pragma once#include array#include cstddef // add to fix build errD:\3rd\openpnp_prj\Smoothieware\Smoothieware\src\modules\tools\temperatureswitch\TemperatureSwitch.h#ifndef TEMPERATURESWITCH_MODULE_H#define TEMPERATURESWITCH_MODULE_Husing namespace std;#include libs/Module.h#include string#include vector#include cstdint // add to fix errD:\3rd\openpnp_prj\Smoothieware\Smoothieware\src\modules\tools\zprobe\CartGridStrategy.h#pragma once#include LevelingStrategy.h#include string.h#include tuple#include string // add to fix err#include cstdint // add to fix errD:\3rd\openpnp_prj\Smoothieware\Smoothieware\src\modules\tools\zprobe\DeltaGridStrategy.h#pragma once#include LevelingStrategy.h#include string.h#include tuple#include cstdint // add to fix errD:\3rd\openpnp_prj\Smoothieware\Smoothieware\src\modules\utils\player\Player.h#pragma once#include Module.h#include stdio.h#include string#include map#include vector#include cstdint // add to fix errusing std::string;D:\3rd\openpnp_prj\Smoothieware\Smoothieware\src\modules\utils\panel\PanelScreen.h#ifndef PANELSCREEN_H#define PANELSCREEN_H#include string#include deque#include cstdint // add to fix errD:\3rd\openpnp_prj\Smoothieware\Smoothieware\src\modules\utils\panel\screens\CustomScreen.h#ifndef CUSTOMSCREEN_H#define CUSTOMSCREEN_H#include PanelScreen.h#include vector#include tuple#include cstdint // add to fix errD:\3rd\openpnp_prj\Smoothieware\Smoothieware\src\modules\utils\motordrivercontrol\drivers\DRV8711\drv8711.h#pragma once#include functional#include bitset#include cstdint // add to fix errD:\3rd\openpnp_prj\Smoothieware\Smoothieware\src\modules\utils\motordrivercontrol\drivers\TMC26X\TMC26X.h#pragma once#include functional#include map#include bitset#include cstdint // add to fix err增加 version.cpp, 值根据 generate-version.sh 显示的值来将 generate-version.sh和generate-version.bat中touch version.cpp 的代码行注释掉防止覆盖自己改的version.cpp// file src/version.cpp#includeversion.h/* $ ./src/generate-version.sh v2025_1116_0429-65ea3b7 */constchar*Version::get_build(void)const{returnv2025_1116_0429-65ea3b7;}constchar*Version::get_build_date(void)const{return2025_1116_0429;}编译过了运行完整命令make clean clear make all确认确实编译过了。将编译优化选项改为-OgD:\3rd\openpnp_prj\Smoothieware\Smoothieware\build\common.mk 编译选项都在common.mk中将OPTIMIZATION的值都改为g按照-Og编译出来的elf, 不影响单步调试。比原版编译的elf输出还小 指定c标准msys2-mingw64中编译工程.cpp默认是用的c17作者编译时用的应该不是c17标准。现在编译完有c17不支持的关键字警告./vendor/NXP/cmsis/LPC1768/core_cmFunc.h: Infunctionuint32_t __get_PSP():./vendor/NXP/cmsis/LPC1768/core_cmFunc.h:412:21: warning: ISO C17 does not allowregisterstorag e class specifier[-Wregister]412|register uint32_t result;|^~~~~~查了资料register 关键字在 C11、C98 等早期标准中有效用于提示编译器将变量存储在寄存器中以提高访问效率例如循环计数器. 从 C17 标准开始register 被废弃deprecated并完全移除。编译器会发出 -Wregister 警告提示该关键字不再合法.C14/C11都支持register关键字。在makefile中显势指定使用C14makefile中, 作者就是用的gnu11标准。 GPFLAGS$(GCFLAGS)-fno-rtti -stdgnu11 C_FLAGS-stdc99 CPPFLAGSCFLAGS -fno-rtti -stdgnu11 -fno-exceptionsCXXFLAGSCFLAGS -fno-rtti -stdgnu11 -fexceptions# used for a .cxx file that needs to be compiled with exceptions在msys2-mingw64中查看arm-none-eabi-g支持的c标准也支持gnu11 arm-none-eabi-g --help -v|grepstd-stdgnu11 Conform to the ISO2011C standard with GNU 那这个问题就不管了。 且这个警告是CMSIS库中的警告不管了。 如果register关键字在c17中无效那么编译出的输出就和没有register关键字相同运行效率稍慢不影响正确性。END