From 745b4319a21cfebefead76c7fcacd0b619d48063 Mon Sep 17 00:00:00 2001 From: robert-hh Date: Mon, 17 May 2021 12:31:11 +0200 Subject: [PATCH] mimxrt/boards/TEENSY40: Re-create the flash FS after deploy. This is required since the Teensy Halfkay loader attempts to erase all of the flash but fails to do so, at least in my tests. Formatting brings it back to a known state. --- ports/mimxrt/Makefile | 2 ++ ports/mimxrt/boards/TEENSY40/format.py | 11 +++++++++++ ports/mimxrt/boards/TEENSY40/mpconfigboard.mk | 2 ++ 3 files changed, 15 insertions(+) create mode 100644 ports/mimxrt/boards/TEENSY40/format.py diff --git a/ports/mimxrt/Makefile b/ports/mimxrt/Makefile index 7feab6cd7..956291b32 100644 --- a/ports/mimxrt/Makefile +++ b/ports/mimxrt/Makefile @@ -2,6 +2,8 @@ BOARD ?= TEENSY40 BOARD_DIR ?= boards/$(BOARD) BUILD ?= build-$(BOARD) +PORT ?= /dev/ttyACM0 + CROSS_COMPILE ?= arm-none-eabi- ifeq ($(wildcard $(BOARD_DIR)/.),) diff --git a/ports/mimxrt/boards/TEENSY40/format.py b/ports/mimxrt/boards/TEENSY40/format.py new file mode 100644 index 000000000..75e5aa95c --- /dev/null +++ b/ports/mimxrt/boards/TEENSY40/format.py @@ -0,0 +1,11 @@ +# format.py +# Re-create the file system + +import os +import mimxrt + +bdev = mimxrt.Flash() + +os.VfsLfs2.mkfs(bdev, progsize=256) +vfs = os.VfsLfs2(bdev, progsize=256) +os.mount(vfs, "/") diff --git a/ports/mimxrt/boards/TEENSY40/mpconfigboard.mk b/ports/mimxrt/boards/TEENSY40/mpconfigboard.mk index 6b939a3af..79365d0da 100644 --- a/ports/mimxrt/boards/TEENSY40/mpconfigboard.mk +++ b/ports/mimxrt/boards/TEENSY40/mpconfigboard.mk @@ -3,3 +3,5 @@ MCU_VARIANT = MIMXRT1062DVJ6A deploy: $(BUILD)/firmware.hex teensy_loader_cli --mcu=imxrt1062 -v -w $< + sleep 1 + $(PYTHON) $(TOP)/tools/pyboard.py --device $(PORT) $(BOARD_DIR)/format.py