Open
Description
Description
I've added a help
option to the Makefile file.
I do not fell comfortable to make a PR but this is helpful.
If one agreed, can do the PR for me?
Here is the new code
# Makefile for MicroPython on ESP32.
#
# This is a simple, convenience wrapper around idf.py (which uses CMake).
include ../../py/verbose.mk
# -------------------------------------------------------------------------
# Board Selection
# -------------------------------------------------------------------------
ifdef BOARD_DIR
BOARD ?= $(notdir $(BOARD_DIR:/=))
else
BOARD ?= ESP32_GENERIC
BOARD_DIR ?= boards/$(BOARD)
endif
ifeq ($(wildcard $(BOARD_DIR)/.),)
ifeq ($(findstring boards/GENERIC,$(BOARD_DIR)),boards/GENERIC)
$(warning The GENERIC* boards have been renamed to ESP32_GENERIC*)
endif
$(error Invalid BOARD specified: $(BOARD_DIR))
endif
# Build directory naming
ifneq ($(BOARD_VARIANT),)
BUILD ?= build-$(BOARD)-$(BOARD_VARIANT)
else
BUILD ?= build-$(BOARD)
endif
# -------------------------------------------------------------------------
# Serial Settings
# -------------------------------------------------------------------------
ifneq ($(PORT),)
PORT_ARG := -p $(PORT)
endif
ifneq ($(BAUD),)
BAUD_ARG := -b $(BAUD)
endif
DEVICE += $(PORT_ARG) $(BAUD_ARG)
PYTHON ?= python3
# -------------------------------------------------------------------------
# IDF/CMake Flags
# -------------------------------------------------------------------------
CMAKE_ARGS =
ifdef USER_C_MODULES
CMAKE_ARGS += -DUSER_C_MODULES=${USER_C_MODULES}
endif
IDFPY_FLAGS += -D MICROPY_BOARD=$(BOARD) -D MICROPY_BOARD_DIR="$(abspath $(BOARD_DIR))" $(CMAKE_ARGS)
ifdef FROZEN_MANIFEST
IDFPY_FLAGS += -D MICROPY_FROZEN_MANIFEST=$(FROZEN_MANIFEST)
endif
ifdef BOARD_VARIANT
IDFPY_FLAGS += -D MICROPY_BOARD_VARIANT=$(BOARD_VARIANT)
endif
ifdef MICROPY_PREVIEW_VERSION_2
IDFPY_FLAGS += -D MICROPY_PREVIEW_VERSION_2=1
endif
ifeq ($(BUILD_VERBOSE),1)
IDFPY_FLAGS += --verbose
endif
HELP_BUILD_ERROR ?= "See \033[1;31mhttps://github.com/micropython/micropython/wiki/Build-Troubleshooting\033[0m"
# -------------------------------------------------------------------------
# Command Wrapper
# -------------------------------------------------------------------------
define RUN_IDF_PY
$(Q)idf.py $(IDFPY_FLAGS) -B $(BUILD) $(1)
endef
# -------------------------------------------------------------------------
# Targets
# -------------------------------------------------------------------------
.PHONY: all clean deploy erase submodules FORCE help
all:
$(Q)idf.py $(IDFPY_FLAGS) -B $(BUILD) build || (echo -e $(HELP_BUILD_ERROR); false)
$(Q)$(PYTHON) makeimg.py \
$(BUILD)/sdkconfig \
$(BUILD)/bootloader/bootloader.bin \
$(BUILD)/partition_table/partition-table.bin \
$(BUILD)/micropython.bin \
$(BUILD)/firmware.bin \
$(BUILD)/micropython.uf2
$(BUILD)/bootloader/bootloader.bin \
$(BUILD)/partition_table/partition-table.bin \
$(BUILD)/micropython.bin: FORCE
clean:
$(call RUN_IDF_PY,fullclean)
deploy:
$(call RUN_IDF_PY,$(DEVICE) flash)
erase:
$(call RUN_IDF_PY,$(DEVICE) erase-flash)
monitor:
$(call RUN_IDF_PY,$(DEVICE) monitor)
size:
$(call RUN_IDF_PY,size)
size-components:
$(call RUN_IDF_PY,size-components)
size-files:
$(call RUN_IDF_PY,size-files)
submodules:
$(Q)IDF_COMPONENT_MANAGER=0 idf.py $(IDFPY_FLAGS) -B $(BUILD)/submodules -D UPDATE_SUBMODULES=1 reconfigure
# -------------------------------------------------------------------------
# Help: list available boards and variants
# -------------------------------------------------------------------------
help:
@echo "Available BOARD options:"
@cd boards && find . -maxdepth 1 -type d | sed 's|^\./||' | grep -v '^\.$$'
@echo ""
@echo "Available BOARD_VARIANT options per board:"
@for b in boards/*; do \
if [ -d "$$b" ]; then \
board=$$(basename $$b); \
variants=$$(cd $$b && ls mpconfigvariant_*.cmake 2>/dev/null | sed 's/^mpconfigvariant_//' | sed 's/\.cmake$$//'); \
if [ -n "$$variants" ]; then \
echo " $$board: $$variants"; \
fi; \
fi; \
done
Code Size
No code size impact
Implementation
I hope the MicroPython maintainers or community will implement this feature
Code of Conduct
Yes, I agree