Skip to content

Commit dd1a63a

Browse files
committed
MicroPython: simplified handling of frozen startup script
1 parent 7c48ce9 commit dd1a63a

2 files changed

Lines changed: 8 additions & 22 deletions

File tree

advanced/micropython/port-riscv-emu.py/Makefile

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,39 +12,25 @@ MICROPY_ROM_TEXT_COMPRESSION ?= 1
1212
# Valid values: REPL_SYSCALL, HEADLESS, UART
1313
MODE ?= REPL_SYSCALL
1414

15-
# Script to embed (for HEADLESS and UART modes)
16-
FROZEN_SCRIPT ?= startup.py
17-
1815
# Frozen module support for HEADLESS and UART modes
19-
# HEADLESS mode requires a frozen script
20-
# UART mode optionally accepts a frozen script
16+
# The frozen script is always named startup.py
2117
ifeq ($(MODE),HEADLESS)
22-
ifeq ($(FROZEN_SCRIPT),)
23-
$(error HEADLESS mode requires FROZEN_SCRIPT to be set)
24-
endif
2518
FROZEN_ENABLED = 1
2619
else ifeq ($(MODE),UART)
27-
ifneq ($(FROZEN_SCRIPT),)
28-
FROZEN_ENABLED = 1
29-
else
30-
FROZEN_ENABLED = 0
31-
endif
20+
FROZEN_ENABLED = 1
3221
else ifeq ($(MODE),REPL_SYSCALL)
3322
FROZEN_ENABLED = 0
3423
else
3524
$(error Invalid MODE=$(MODE). Valid values: REPL_SYSCALL, HEADLESS, UART)
3625
endif
3726

3827
ifeq ($(FROZEN_ENABLED),1)
39-
# Module name includes .py extension (manifest system registers with full filename)
40-
FROZEN_MODULE_NAME = $(FROZEN_SCRIPT)
41-
42-
# Use manifest.py for freezing (idiomatic MicroPython approach)
28+
# Use manifest.py for freezing.
4329
# The manifest file will handle compilation via makemanifest.py
4430
FROZEN_MANIFEST = $(CURDIR)/manifest.py
4531

46-
# Pass FROZEN_SCRIPT to manifest as a variable
47-
MICROPY_MANIFEST_FROZEN_SCRIPT = $(FROZEN_SCRIPT)
32+
# Module name is always startup.py
33+
FROZEN_MODULE_NAME = startup.py
4834
endif
4935

5036
# include py core make definitions
@@ -173,7 +159,7 @@ $(BUILD)/firmware.elf: $(OBJ)
173159
$(Q)$(SIZE) $@
174160

175161
$(BUILD)/firmware.bin: $(BUILD)/firmware.elf
176-
$(Q)$(OBJCOPY) -O binary -j .isr_vector -j .text -j .data $^ $(BUILD)/firmware.bin
162+
$(Q)$(OBJCOPY) -O binary $^ $(BUILD)/firmware.bin
177163

178164
$(BUILD)/firmware.dfu: $(BUILD)/firmware.bin
179165
$(ECHO) "Create $@"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Manifest for freezing Python scripts into firmware
22
# This file defines which Python modules should be compiled and frozen into the firmware
33

4-
# Freeze startup.py (the default embedded script)
5-
# To freeze a different script, modify this file or specify FROZEN_SCRIPT in your Makefile
4+
# Freeze startup.py from the port directory
5+
# For HEADLESS and UART modes, startup.py will be automatically executed on boot
66
freeze("$(PORT_DIR)", "startup.py")

0 commit comments

Comments
 (0)