Advertisement
DeaD_EyE

compose esp32 binary to flash it

Mar 28th, 2022
877
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. from pathlib import Path
  2.  
  3.  
  4. BASE = Path("/home/andre/ESP32_Build/home/build/micropython/ports/esp32/build-GENERIC/")
  5. START = 0x1000
  6. FILES = (
  7.     (BASE / "bootloader/bootloader.bin", 0),
  8.     (BASE / "partition_table/partition-table.bin", 0x8000 - START),
  9.     (BASE / "micropython.bin", 0x10000 - START)
  10. )
  11. TARGET = Path.home().joinpath("micropython_esp32.bin")
  12.  
  13.  
  14. with TARGET.open("w+b") as fd_out:
  15.     for file, offset in FILES:
  16.         print(f"Writing {file.name} as offset {offset:x}")
  17.         fd_out.seek(offset)
  18.         with file.open("rb") as fd_in:
  19.             while chunk := fd_in.read(65 * 1024 ** 1):
  20.                 fd_out.write(chunk)
  21.  
  22.  
  23. # start flashing at 0x1000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement