Skip to content

Commit

Permalink
Merge pull request #490 from MartinMueller2003/main
Browse files Browse the repository at this point in the history
Changes to vscode scripts
  • Loading branch information
forkineye authored Mar 18, 2022
2 parents 0468d32 + 6125ab8 commit 1c8f73b
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 7 deletions.
58 changes: 58 additions & 0 deletions .scripts/CopyTargets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import platform
import shutil
Import("env")

BUILD_DIR = env['PROJECT_BUILD_DIR']
PIOENV = env['PIOENV']
BOARD = env['BOARD']
PROGNAME = env['PROGNAME']
BOARD_MCU = env['BOARD_MCU']

# print("BUILD_DIR " + BUILD_DIR)
# print("PIOENV " + PIOENV)
# print("BOARD " + BOARD)
# print("PROGNAME " + PROGNAME)
# print("BOARD_MCU " + BOARD_MCU)
# print("CustomTargets.py - Success")

BOARD_FLASH_MODE = env['BOARD_FLASH_MODE']
BOARD_F_FLASH = env['BOARD_F_FLASH'].removesuffix('000000L') + 'm'
# print("BOARD_FLASH_MODE " + BOARD_FLASH_MODE)
# print("BOARD_F_FLASH " + BOARD_F_FLASH)

SRC_DIR = BUILD_DIR + "\\" + PIOENV + "\\"
SRC_BIN = SRC_DIR + PROGNAME + ".bin"
SRC_PART = SRC_DIR + "partitions.bin"
# print("SRC_BIN " + SRC_BIN)

DST_DIR = ".\\dist\\firmware\\" + BOARD_MCU + "\\"
DST_BIN = DST_DIR + PIOENV + "-app.bin"
DST_PART = DST_DIR + PIOENV + "-partitions.bin"
DST_BOOT = DST_DIR + PIOENV + "-bootloader.bin"

def after_build(source, target, env):

print("Copy: " + SRC_BIN)
shutil.copyfile(SRC_BIN, DST_BIN)

if("FLASH_EXTRA_IMAGES" in env):
FLASH_EXTRA_IMAGES = env['FLASH_EXTRA_IMAGES']
# print('FLASH_EXTRA_IMAGES: ')
for imageId in range(len(FLASH_EXTRA_IMAGES)):
ImagePath = FLASH_EXTRA_IMAGES[imageId][1]
# print(ImagePath)
if("boot_app0" in ImagePath):
print("Copy: " + ImagePath)
shutil.copyfile(ImagePath, DST_DIR + "boot_app0.bin")

elif ("partitions" in ImagePath):
print("Copy: " + ImagePath)
shutil.copyfile(ImagePath, DST_PART)

elif("bootloader" in ImagePath):
SRC_BL_DIR = ImagePath.replace('${BOARD_FLASH_MODE}', BOARD_FLASH_MODE).replace("${__get_board_f_flash(__env__)}", BOARD_F_FLASH)
# print("Copy SRC_BL_DIR: " + SRC_BL_DIR)
print("Copy: " + SRC_BL_DIR)
shutil.copyfile(SRC_BL_DIR, DST_BOOT)

env.AddPostAction("buildprog", after_build)
12 changes: 5 additions & 7 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ lib_ignore =
extra_scripts =
pre:.scripts/pio-version.py
.scripts/download_fs.py

; build_type = debug
upload_port = com6

Expand All @@ -59,8 +60,6 @@ build_flags =
-DFP_IN_IROM ; https://github.com/esp8266/Arduino/pull/7180
; -DPIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48
; -DVTABLES_IN_IRAM
extra_scripts = .scripts/download_fs.py

lib_deps =
${env.lib_deps}
me-no-dev/ESPAsyncUDP @ 0.0.0-alpha+sha.697c75a025
Expand All @@ -75,14 +74,13 @@ platform = espressif32
board_build.filesystem = littlefs
board_build.partitions = ESP32_partitions.csv
monitor_filters = esp32_exception_decoder

build_flags =
${env.build_flags}
build_flags = ${env.build_flags}
lib_deps =
${env.lib_deps}
esphome/AsyncTCP-esphome @ 1.2.2
extra_scripts = .scripts/replace_fs.py
.scripts/download_fs.py

extra_scripts = ${env.extra_scripts}
.scripts/replace_fs.py

;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~;
; ESP32 pulling from upstream core ;
Expand Down

0 comments on commit 1c8f73b

Please sign in to comment.