Adding flashing.

This commit is contained in:
Brad Nelson
2024-01-01 19:58:23 -08:00
parent 1e01a47380
commit 7209ca594a
4 changed files with 55 additions and 4 deletions

View File

@ -105,6 +105,13 @@ WIN_LFLAGS64 = [
'/LIBPATH:"c:/Program Files (x86)/Windows Kits/10/Lib/10.0.19041.0/ucrt/x64"',
] + WIN_LIBS
LOCALAPPDATAR = str(subprocess.check_output('cmd.exe /c echo "%LOCALAPPDATA%"',
shell=True, stderr=subprocess.DEVNULL).splitlines()[0], 'ascii').replace('\\', '/')
LOCALAPPDATA = LOCALAPPDATAR.replace('C:/', '/mnt/c/')
ARDUINO_CLI = LOCALAPPDATA + '/Programs/arduino-ide/resources/app/lib/backend/resources/arduino-cli.exe'
WINTMP = LOCALAPPDATA + '/Temp'
WINTMPR = LOCALAPPDATAR + '/Temp'
def Escape(path):
return path.replace(' ', '\\ ').replace('(', '\\(').replace(')', '\\)')
@ -388,7 +395,7 @@ def GenRun(target, script, options, sources):
return target
def OneShot(target, command, source, pool=None):
def OneShot(target, source, command, pool=None):
global output
output += f'build {target}: oneshot {source}\n'
output += f' command = {command}\n'

View File

@ -66,3 +66,45 @@ Run('$dst/gen/esp32_sim_opcodes.h', '$dst/gen/print-esp32-builtins')
# Main Alias.
Alias('esp32', ' '.join(ESP32_FILES))
# Automate building / flashing.
BOARDS = {
'esp32': '--fqbn=esp32:esp32:esp32:PSRAM=disabled,PartitionScheme=no_ota,CPUFreq=240,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,LoopCore=1,EventsCore=1,DebugLevel=none,EraseFlash=none',
'esp32s2': '--fqbn=esp32:esp32:esp32s2:CDCOnBoot=default,MSCOnBoot=default,DFUOnBoot=default,UploadMode=default,PSRAM=disabled,PartitionScheme=default,CPUFreq=240,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=none,EraseFlash=none',
'esp32s3': '--fqbn=esp32:esp32:esp32s3:PSRAM=disabled,FlashMode=qio,FlashSize=4M,LoopCore=1,EventsCore=1,USBMode=hwcdc,CDCOnBoot=default,MSCOnBoot=default,DFUOnBoot=default,UploadMode=default,PartitionScheme=default,CPUFreq=240,UploadSpeed=921600,DebugLevel=none,EraseFlash=none',
'esp32c3': '--fqbn=esp32:esp32:esp32c3:CDCOnBoot=default,PartitionScheme=default,CPUFreq=160,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=none,EraseFlash=none',
'esp32cam': '--fqbn=esp32:esp32:esp32cam:CPUFreq=240,FlashMode=qio,PartitionScheme=huge_app,FlashFreq=80,DebugLevel=none,EraseFlash=none',
}
for board in BOARDS:
options = BOARDS[board]
Command(f'$dst/esp32/{board}_build/flash.not',
'$dst/esp32/ESP32forth/ESP32forth.ino',
f"""\
rm -rf {WINTMP}/ueforth_esp32/ESP32forth/ && \
cp -r $dst/esp32/ESP32forth {WINTMP}/ueforth_esp32/ && \
cd {WINTMP} && \
{ARDUINO_CLI} compile """ + """\
--port $${PORT:-com3} --upload """ + f"""\
{options} \
--build-path ueforth_esp32/{board}_build \
--build-cache-path ueforth_esp32/{board}_cache \
ueforth_esp32/ESP32forth/ESP32forth.ino""")
Alias(f'{board}-flash', f'$dst/esp32/{board}_build/flash.not')
Command(f'$dst/esp32/{board}_build/ESP32forth.ino.bin',
'$dst/esp32/ESP32forth/ESP32forth.ino',
f"""\
rm -rf {WINTMP}/ueforth_esp32/ESP32forth/ && \
cp -r $dst/esp32/ESP32forth {WINTMP}/ueforth_esp32/ && \
cd {WINTMP} && \
{ARDUINO_CLI} compile {options} \
--build-path ueforth_esp32/{board}_build \
--build-cache-path ueforth_esp32/{board}_cache \
ueforth_esp32/ESP32forth/ESP32forth.ino && \
cd - && \
cp {WINTMP}/ueforth_esp32/{board}_build/*.bin \
$dst/esp32/{board}_build/ESP32forth.ino.bin""")
Alias(f'{board}-build', f'$dst/esp32/{board}_build/ESP32forth.ino.bin')
Alias('esp32all', ' '.join([i + '-build' for i in BOARDS.keys()]))
Alias('putty', OneShot('$dst/gen/putty.not', '',
'$${HOME}/Desktop/putty.exe -serial $${PORT:-com3} -sercfg 115200'))

View File

@ -19,7 +19,7 @@ static char filename2[PATH_MAX];
#include "esp32/faults.h"
#include "common/calling.h"
#include "common/interp.h"
#include "esp32_boot.h"
#include "gen/esp32_boot.h"
// Work around lack of ftruncate
static cell_t ResizeFile(cell_t fd, cell_t size) {

View File

@ -21,5 +21,7 @@ Alias('posix', ' '.join([
'$dst/posix/ueforth', '$src/common/all_tests.fs'),
]))
OneShot('install', 'sudo cp $dst/posix/ueforth /usr/bin/ueforth',
'$dst/posix/ueforth', pool='console')
OneShot('install',
'$dst/posix/ueforth',
'sudo cp $dst/posix/ueforth /usr/bin/ueforth',
pool='console')