我想将flash
我的二进制文件转换为 esp32。有没有一种简单的方法来生成flash
二进制文件,而不使用该esptool.py
工具?esptool.py
我是移植自己的唯一选择吗?
问问题
296 次
1 回答
0
您可以将 python 程序构建为独立的 .exe 文件。
REM Script for building esptool.exe
@REM Author: Paul Abbott, 2019
@ECHO OFF
SETLOCAL EnableDelayedExpansion
REM %CD% gives current dir, but
SET THISDIR=%CD%
REM %~dp0 gives the directory of this batch file (with a trailing \)
SET SCRIPTDIR=%~dp0
SET "PROGRAMMER=%SCRIPTDIR%..\..\Tools\esp-idf\components\esptool_py\esptool\esptool.py"
pip2 install pyinstaller pyserial
rmdir /s /q build_tmp
mkdir build_tmp
C:\Python27\scripts\pyinstaller ^
--onefile ^
--specpath build_tmp ^
--workpath build_tmp\build ^
--distpath %SCRIPTDIR% ^
%PROGRAMMER%
REM Output: build_tmp\dist\esptool.exe
输出 esptool.exe 无需在任何 Windows XP、7、10 上安装任何东西即可工作。(可能也有类似的方法可以为其他操作系统构建)
现在您可以调用从生产编程脚本构建的 .exe 文件。这是我的 batchprog-esp32.cmd 例如:
@REM Script for assembly line programming of ESP32
@REM Author: Paul Abbott, 2019
@ECHO OFF
SETLOCAL EnableDelayedExpansion
REM %CD% gives current dir, but
SET THISDIR=%CD%
REM %~dp0 gives the directory of this batch file (with a trailing \)
SET SCRIPTDIR=%~dp0
SET "PROGRAMMER=%SCRIPTDIR%\esptool.exe"
SET /a DUTNUMBER=1
IF /i NOT EXIST %PROGRAMMER% (
MORE %SCRIPTDIR%readme.md
ECHO Programmer %PROGRAMMER% does not exist!.
GOTO :DIE
)
rem Restore the color of the screen
COLOR 07
CLS
ECHO Batch Programmer
ECHO/
ECHO In Directory:
ECHO %THISDIR%
ECHO/
ECHO Found .bin files in directory:
ECHO **************************************************************************
SET AppSel=0
SET AppIndex=0
SET FDataSel=0
SET FDataIndex=0
FOR %%F IN (%THISDIR%\*.bin) DO (
SET THISFILE=%%~nxF
IF NOT "!THISFILE:bootloader=!"=="!THISFILE!" (
ECHO Bootloader: %%~nxF
SET BOOTLOADER_BIN=%%~nxF
) ELSE IF NOT "!THISFILE:partitions=!"=="!THISFILE!" (
ECHO Partitions: %%~nxF
SET PARTITION_BIN=%%~nxF
) ELSE IF NOT "!THISFILE:ota_data=!"=="!THISFILE!" (
ECHO OTA_Init: %%~nxF
SET OTAINITDATA_BIN=%%~nxF
) ELSE IF NOT "!THISFILE:nvs_data=!"=="!THISFILE!" (
ECHO NVS_Init: %%~nxF
SET NVSINITDATA_BIN=%%~nxF
) ELSE IF NOT "!THISFILE:phy_init=!"=="!THISFILE!" (
ECHO PHY-Init: %%~nxF
SET PHYINITDATA_BIN=%%~nxF
) ELSE IF NOT "!THISFILE:factory_data=!"=="!THISFILE!" (
SET FDataSel.!FDataIndex!=%%~nxF
ECHO FData: %%~nxF
SET /A FDataSel = !FDataIndex!
SET /A FDataIndex += 1
) ELSE (
REM Print all other .bin files that didn't match above as potential Factory App
SET AppSel.!AppIndex!=%%~nxF
ECHO App: %%~nxF
SET /A AppSel = !AppIndex!
SET /A AppIndex += 1
)
)
ECHO **************************************************************************
ECHO/
IF !AppIndex! LEQ 1 GOTO :SKIP_APP_SELECT
REM App Select
ECHO Please choose factory app from this list:
ECHO **************************************************************************
SET /A NUMAPPS=!AppIndex!-1
FOR /L %%G IN (0,1,%NUMAPPS%) DO (
ECHO %%G: !AppSel.%%G!
)
ECHO **************************************************************************
ECHO/
SET /P AppSel= Choose the file to program to Factory App Partition [%AppSel%]^>
:SKIP_APP_SELECT
IF "!AppSel.%AppSel%!"=="" (
ECHO WARNING: No App Partition!
) ELSE (
SET FACTORYAPP_BIN=!AppSel.%AppSel%!
)
IF !FDataIndex! LEQ 0 (
REM no factorydata partition found, assume app offset at 0x10000
SET FACTORYAPP_OFFSET=0x10000
) ELSE (
REM found a factorydata partition (new format), assume app offset at 0x20000
SET FACTORYAPP_OFFSET=0x20000
)
IF !FDataIndex! LEQ 1 GOTO :SKIP_FDATA_SELECT
REM FData Select
ECHO Please choose factory data from this list:
ECHO **************************************************************************
SET /A NUMFDATAS=!FDataIndex!-1
FOR /L %%G IN (0,1,%NUMFDATAS%) DO (
ECHO %%G: !FDataSel.%%G!
)
ECHO **************************************************************************
ECHO/
SET /P AppSel= Choose the file to program to Factory Data Partition [%FDataSel%]^>
:SKIP_FDATA_SELECT
IF NOT "!FDataSel.%FDataSel%!"=="" SET FACTORYDATA_BIN=!FDataSel.%FDataSel%!
REM Configure COM port
if NOT EXIST UART_COM.CFG (
set SERCOMNO=COM1
) else (
set /P SERCOMNO= < UART_COM.CFG
)
REM remove spaces
set SERCOMNO=%SERCOMNO: =%
echo Enter the COM_PORT_NUMBER (as COM1 ~ COM99) [%SERCOMNO%]
set /p SERCOMNO=
REM remove spaces
set SERCOMNO=%SERCOMNO: =%
IF !SERCOMNO!=="" GOTO :DIE
echo %SERCOMNO% > UART_COM.CFG
SET PROGRAMMER=%PROGRAMMER% --chip esp32 ^
--port !SERCOMNO! ^
--baud 921600 ^
--before default_reset ^
--after no_reset ^
write_flash -z ^
--flash_mode dio ^
--flash_freq 80m ^
--flash_size 16MB
IF NOT "%NVSINITDATA_BIN%"=="" SET PROGRAMMER=%PROGRAMMER% 0x9000 %THISDIR%/%NVSINITDATA_BIN%
IF NOT "%OTAINITDATA_BIN%"=="" SET PROGRAMMER=%PROGRAMMER% 0xd000 %THISDIR%/%OTAINITDATA_BIN%
IF NOT "%BOOTLOADER_BIN%"=="" SET PROGRAMMER=%PROGRAMMER% 0x1000 %THISDIR%/%BOOTLOADER_BIN%
IF NOT "%PHYINITDATA_BIN%"=="" SET PROGRAMMER=%PROGRAMMER% 0xf000 %THISDIR%/%PHYINITDATA_BIN%
IF NOT "%PARTITION_BIN%"=="" SET PROGRAMMER=%PROGRAMMER% 0x8000 %THISDIR%/%PARTITION_BIN%
IF NOT "%FACTORYDATA_BIN%"=="" SET PROGRAMMER=%PROGRAMMER% 0x10000 %THISDIR%/%FACTORYDATA_BIN%
IF NOT "%FACTORYAPP_BIN%"=="" SET PROGRAMMER=%PROGRAMMER% %FACTORYAPP_OFFSET% %THISDIR%/%FACTORYAPP_BIN%
REM Restore the color of the screen
COLOR 07
ECHO/
ECHO/
ECHO/
ECHO/
ECHO/
ECHO/
ECHO/
ECHO/
ECHO/
ECHO/
ECHO/
ECHO/
ECHO/
ECHO/
ECHO/
ECHO/
ECHO/
ECHO/
:START
ECHO/
ECHO/
ECHO/
ECHO/
ECHO Batch Programmer
ECHO/
ECHO In Directory:
ECHO %THISDIR%
ECHO/
ECHO Programming these files:
ECHO **************************************************************************
IF NOT "%NVSINITDATA_BIN%"=="" ECHO %NVSINITDATA_BIN%
IF NOT "%OTAINITDATA_BIN%"=="" ECHO %OTAINITDATA_BIN%
IF NOT "%BOOTLOADER_BIN%"=="" ECHO %BOOTLOADER_BIN%
IF NOT "%PHYINITDATA_BIN%"=="" ECHO %PHYINITDATA_BIN%
IF NOT "%PARTITION_BIN%"=="" ECHO %PARTITION_BIN%
IF NOT "%FACTORYDATA_BIN%"=="" ECHO %FACTORYDATA_BIN%
IF NOT "%FACTORYAPP_BIN%"=="" ECHO %FACTORYAPP_BIN% to %FACTORYAPP_OFFSET%
ECHO **************************************************************************
ECHO/
SET /P G= Hit 'Enter' to Program device #%DUTNUMBER%^>
REM Restore the color of the screen
COLOR 07
ECHO %PROGRAMMER%
ECHO/
ECHO/
ECHO Starting Programmer. Please Wait...
ECHO/
ECHO/
ECHO/
ECHO/
ECHO/
ECHO/
CALL %PROGRAMMER%
IF %ERRORLEVEL% NEQ 0 goto :FAILURE
:SUCCESS
REM Color the screen green
color 2f
ECHO *********************************
ECHO *** Programming SUCCESS^^! ***
ECHO *********************************
ECHO/
SET /a DUTNUMBER=%DUTNUMBER% + 1
goto :START
:FAILURE
REM Color the screen red
color 4f
ECHO *********************************
ECHO *** Programming FAILURE^^! ***
ECHO *********************************
ECHO/
goto :START
:DIE
REM Color the screen red
COLOR 4f
ECHO ERROR!
PAUSE
GOTO :QUIT
:QUIT
REM Restore the Color of the screen
COLOR 07
GOTO :eof
现在我只需将该 esptool.exe 文件和 batchprog-esp32.cmd 脚本连同我的发布二进制文件一起推送到 git 存储库中。我的合同制造商提取了 repo 并且可以在不安装任何东西的情况下进行编程。
于 2020-09-10T01:51:16.957 回答