jacdac-esp32/Makefile

153 строки
4.3 KiB
Makefile
Исходник Постоянная ссылка Обычный вид История

2022-06-22 03:22:53 +03:00
.SECONDARY: # this prevents object files from being removed
.DEFAULT_GOAL := all
2023-02-14 04:34:37 +03:00
CLI = node devicescript/cli/devicescript
2023-02-14 05:16:49 +03:00
JDC = devicescript/runtime/jacdac-c
2023-02-14 21:55:50 +03:00
BUILD = build
2022-06-22 04:16:36 +03:00
IDF = idf.py
2022-06-22 03:22:53 +03:00
_IGNORE0 := $(shell test -f Makefile.user || cp sample-Makefile.user Makefile.user)
2023-02-22 02:11:44 +03:00
ifeq ($(TARGET),)
2022-06-22 03:22:53 +03:00
include Makefile.user
2023-02-22 02:11:44 +03:00
endif
2022-06-22 03:22:53 +03:00
2022-07-09 02:39:02 +03:00
MON_PORT ?= $(SERIAL_PORT)
2023-02-15 02:10:11 +03:00
ESPTOOL ?= esptool.py
2022-07-09 02:39:02 +03:00
2023-02-14 05:16:49 +03:00
BL_OFF = $(shell grep CONFIG_BOOTLOADER_OFFSET_IN_FLASH= sdkconfig | sed -e 's/.*=//')
2022-09-13 21:27:00 +03:00
2022-06-22 03:22:53 +03:00
ifeq ($(TARGET),esp32s2)
2022-06-22 03:44:02 +03:00
GCC_PREF = xtensa-esp32s2-elf
endif
2023-06-18 00:25:03 +03:00
ifeq ($(TARGET),esp32s3)
GCC_PREF = xtensa-esp32s3-elf
endif
2022-06-22 03:44:02 +03:00
ifeq ($(TARGET),esp32c3)
GCC_PREF = riscv32-esp-elf
endif
2023-02-14 23:53:32 +03:00
ifeq ($(TARGET),esp32)
GCC_PREF = xtensa-esp32-elf
endif
2023-02-14 04:34:37 +03:00
BOARD ?= $(shell basename `ls boards/$(TARGET)/*.board.json | head -1` .board.json)
2022-06-22 03:44:02 +03:00
ifeq ($(GCC_PREF),)
$(error Define 'TARGET = esp32s2' or similar in Makefile.user)
2022-06-22 03:22:53 +03:00
endif
2023-02-14 21:14:50 +03:00
prep: devicescript/cli/built/devicescript-cli.cjs sdkconfig.defaults refresh-version
2022-06-22 04:13:23 +03:00
2023-02-14 21:55:50 +03:00
all: inner-build patch
2023-02-14 21:41:46 +03:00
2023-04-03 21:29:57 +03:00
inner-build: check-export check-submodule prep
2022-06-22 04:16:36 +03:00
$(IDF) --ccache build
2022-06-22 04:13:23 +03:00
$(MAKE) combine
2022-06-22 03:22:53 +03:00
2023-02-14 21:55:50 +03:00
ci-build:
2023-05-16 02:47:37 +03:00
$(IDF) --ccache build
$(MAKE) combine
2023-02-14 21:55:50 +03:00
mv $(BUILD) build-$(TARGET)
ci-patch:
$(MAKE) patch BUILD=build-$(TARGET)
2022-06-22 03:22:53 +03:00
sdkconfig.defaults: Makefile.user
2023-02-14 21:36:43 +03:00
@if test -f sdkconfig ; then \
if grep -q 'CONFIG_IDF_TARGET="$(TARGET)"' sdkconfig ; then echo target OK ; \
2023-02-14 21:55:50 +03:00
else echo cleaning target... ; rm -rf $(BUILD) sdkconfig ; $(MAKE) refresh-version ; fi ; \
2023-02-14 21:36:43 +03:00
fi
2023-02-14 21:46:24 +03:00
cat boards/$(TARGET)/sdkconfig.$(TARGET) boards/sdkconfig.common > sdkconfig.defaults
2023-06-17 23:51:40 +03:00
for folder in boards/$(TARGET)/ boards/ ; do \
if test -f $$folder/idf_component.yml ; then cp $$folder/idf_component.yml main/ ; break ; fi ; \
done
2023-02-14 21:55:50 +03:00
@mkdir -p $(BUILD)
echo "idf_build_set_property(COMPILE_OPTIONS "$(COMPILE_OPTIONS)" APPEND)" > $(BUILD)/options.cmake
2022-06-22 03:22:53 +03:00
2023-02-14 05:16:49 +03:00
combine:
2023-02-15 02:10:11 +03:00
$(ESPTOOL) --chip $(TARGET) merge_bin \
2023-02-14 21:55:50 +03:00
-o $(BUILD)/combined.bin \
2023-02-14 21:04:12 +03:00
--target-offset $(BL_OFF) \
2023-02-14 21:55:50 +03:00
$(BL_OFF) $(BUILD)/bootloader/bootloader.bin \
0x8000 $(BUILD)/partition_table/partition-table.bin \
0x10000 $(BUILD)/espjd.bin
2023-02-14 21:41:46 +03:00
patch:
2023-02-14 05:16:49 +03:00
mkdir -p dist
2023-06-22 21:17:16 +03:00
$(CLI) binpatch --slug microsoft/devicescript-esp32 \
--bin $(BUILD)/combined.bin --elf $(BUILD)/espjd.elf --generic \
boards/$(TARGET)/*.board.json $(PATCH_ARGS)
2023-02-14 05:16:49 +03:00
2022-06-22 03:22:53 +03:00
clean:
2023-02-14 21:55:50 +03:00
rm -rf sdkconfig sdkconfig.defaults $(BUILD)
2022-05-06 23:18:52 +03:00
2020-11-13 15:41:17 +03:00
vscode:
2023-02-14 21:55:50 +03:00
. $$IDF_PATH/export.sh ; $(IDF) --ccache build
2020-11-13 15:41:17 +03:00
2023-04-03 21:29:57 +03:00
check-submodule:
@test -f $(JDC)/jacdac/README.md || git submodule update --init --recursive
2020-07-22 18:11:29 +03:00
check-export:
@if [ "X$$IDF_TOOLS_EXPORT_CMD" = X ] ; then echo Run: ; echo . $$IDF_PATH/export.sh ; exit 1 ; fi
2023-04-03 21:29:57 +03:00
2020-07-22 18:11:29 +03:00
2023-04-03 21:29:57 +03:00
devicescript/cli/built/devicescript-cli.cjs: check-submodule
2023-02-14 21:14:50 +03:00
cd devicescript && yarn
cd devicescript && yarn build-fast
2020-07-22 18:11:29 +03:00
f: flash
r: flash
2022-06-22 03:44:02 +03:00
flash: all
2023-02-15 02:10:11 +03:00
$(ESPTOOL) --chip $(TARGET) -p $(SERIAL_PORT) write_flash \
2023-02-14 21:14:50 +03:00
$(BL_OFF) dist/devicescript-$(TARGET)-$(BOARD)-$(BL_OFF).bin
2020-07-22 18:11:29 +03:00
mon:
2023-02-14 21:55:50 +03:00
. $(IDF_PATH)/export.sh ; $(IDF_PATH)/tools/idf_monitor.py --port $(MON_PORT) --baud 115200 $(BUILD)/espjd.elf
2022-05-04 00:26:20 +03:00
2023-02-17 21:38:42 +03:00
monf:
2023-03-23 20:51:22 +03:00
. $(IDF_PATH)/export.sh ; $(IDF_PATH)/tools/idf_monitor.py --port $(SERIAL_PORT) --baud 1500000 $(BUILD)/espjd.elf
2023-02-17 21:38:42 +03:00
2022-12-01 21:39:15 +03:00
monu:
2023-02-14 21:55:50 +03:00
. $(IDF_PATH)/export.sh ; $(IDF_PATH)/tools/idf_monitor.py --port $(SERIAL_PORT) --baud 115200 $(BUILD)/espjd.elf
2022-12-01 21:39:15 +03:00
2022-05-04 00:26:20 +03:00
mon-2:
2022-06-22 04:16:36 +03:00
$(IDF) monitor
2020-07-22 18:11:29 +03:00
prep-gdb:
2023-02-14 21:55:50 +03:00
echo > $(BUILD)/gdbinit
echo "target remote :3333" >> $(BUILD)/gdbinit
echo "set remote hardware-watchpoint-limit 2" >> $(BUILD)/gdbinit
2020-07-22 18:11:29 +03:00
gdb: prep-gdb
2023-02-14 21:55:50 +03:00
echo "mon halt" >> $(BUILD)/gdbinit
$(GCC_PREF)-gdb -x $(BUILD)/gdbinit $(BUILD)/espjd.elf
2020-07-22 18:11:29 +03:00
rst:
2023-02-14 21:55:50 +03:00
echo "mon reset halt" >> $(BUILD)/gdbinit
echo "flushregs" >> $(BUILD)/gdbinit
echo "thb app_main" >> $(BUILD)/gdbinit
echo "c" >> $(BUILD)/gdbinit
$(GCC_PREF)-gdb -x $(BUILD)/gdbinit $(BUILD)/espjd.elf
2022-05-06 23:09:19 +03:00
2023-02-22 02:11:44 +03:00
fake-dist:
rm -rf dist/
2023-06-22 21:17:16 +03:00
$(MAKE) TARGET=esp32 PATCH_ARGS=--fake patch
$(MAKE) TARGET=esp32c3 PATCH_ARGS=--fake patch
$(MAKE) TARGET=esp32s2 PATCH_ARGS=--fake patch
$(MAKE) TARGET=esp32s3 PATCH_ARGS=--fake patch
2022-05-06 23:09:19 +03:00
2023-04-03 22:01:06 +03:00
update-devs: devicescript/cli/built/devicescript-cli.cjs
node devicescript/scripts/bumparch.mjs --update
bump: update-devs
2023-03-22 02:23:26 +03:00
node devicescript/scripts/bumparch.mjs
2022-05-06 23:09:19 +03:00
2023-05-16 01:21:39 +03:00
FW_VERSION = $(shell sh $(JDC)/scripts/git-version.sh)
2022-05-06 23:09:19 +03:00
refresh-version:
2023-02-14 21:55:50 +03:00
@mkdir -p $(BUILD)
echo 'const char app_fw_version[] = "v$(FW_VERSION)";' > $(BUILD)/version-tmp.c
@diff $(BUILD)/version.c $(BUILD)/version-tmp.c >/dev/null 2>/dev/null || \
(echo "refresh version"; cp $(BUILD)/version-tmp.c $(BUILD)/version.c)