PM_K-1 0.0.11: fix boot crash - CircuitPython str has no .isalnum()
With the .mpy loading (no more OOM), the full app ran on hardware for the first time and hit _slkey()'s c.isalnum() in the set-list dedup -> AttributeError (MicroPython/CircuitPython str omits isalnum; my CPython harness has it, so it slipped through). Replaced with a membership test against an explicit alnum set (uses only .lower()). Also compile the .mpy from inside pico-cp/ so tracebacks read "app.py" instead of "pico-cp/app.py". Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7481f91935
commit
13318daf5b
3 changed files with 6 additions and 5 deletions
4
build.sh
4
build.sh
|
|
@ -15,9 +15,9 @@ mkdir -p dist
|
||||||
# Precompile the PM_K-1 CircuitPython firmware to .mpy. CircuitPython compiles a ~56KB .py at boot,
|
# Precompile the PM_K-1 CircuitPython firmware to .mpy. CircuitPython compiles a ~56KB .py at boot,
|
||||||
# which fragments the heap and OOMs on the RP2040; a precompiled .mpy loads without compiling. Needs
|
# which fragments the heap and OOMs on the RP2040; a precompiled .mpy loads without compiling. Needs
|
||||||
# Adafruit's mpy-cross matching the device's CircuitPython (10.2.1) -> emits CircuitPython mpy v6.
|
# Adafruit's mpy-cross matching the device's CircuitPython (10.2.1) -> emits CircuitPython mpy v6.
|
||||||
MPYC="tools/mpy-cross"
|
MPYC="$PWD/tools/mpy-cross"; ROOT="$PWD"
|
||||||
[[ -x "$MPYC" ]] || { echo "error: $MPYC missing (Adafruit mpy-cross for CircuitPython 10.2.1)" >&2; exit 1; }
|
[[ -x "$MPYC" ]] || { echo "error: $MPYC missing (Adafruit mpy-cross for CircuitPython 10.2.1)" >&2; exit 1; }
|
||||||
"$MPYC" pico-cp/app.py -o dist/app.mpy
|
( cd pico-cp && "$MPYC" app.py -o "$ROOT/dist/app.mpy" ) # compile from pico-cp/ so tracebacks read "app.py"
|
||||||
echo "precompiled dist/app.mpy ($(stat -c%s dist/app.mpy) bytes <- $(stat -c%s pico-cp/app.py) source)"
|
echo "precompiled dist/app.mpy ($(stat -c%s dist/app.mpy) bytes <- $(stat -c%s pico-cp/app.py) source)"
|
||||||
|
|
||||||
python3 - <<'PY'
|
python3 - <<'PY'
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
import board, busio, digitalio, analogio, pwmio, displayio, vectorio, time, json, gc, os, supervisor
|
import board, busio, digitalio, analogio, pwmio, displayio, vectorio, time, json, gc, os, supervisor
|
||||||
supervisor.runtime.autoreload = False # we write our own files (log + pushed programs); never self-restart
|
supervisor.runtime.autoreload = False # we write our own files (log + pushed programs); never self-restart
|
||||||
APP_VERSION = "0.0.10" # firmware version (the A/B updater pushes/compares this)
|
APP_VERSION = "0.0.11" # firmware version (the A/B updater pushes/compares this)
|
||||||
try:
|
try:
|
||||||
import rtc # set from the editor's clock SysEx so the log has real timestamps
|
import rtc # set from the editor's clock SysEx so the log has real timestamps
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
@ -292,8 +292,9 @@ def lane_to_str(L): # serialize a lane back
|
||||||
if L['mute']: s += '!'
|
if L['mute']: s += '!'
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def _slkey(t): # normalise a title for built-in/user de-duplication
|
_ALNUM = "abcdefghijklmnopqrstuvwxyz0123456789"
|
||||||
return "".join(c.lower() for c in t if c.isalnum())
|
def _slkey(t): # normalise a title for built-in/user de-dup (no str.isalnum on CircuitPython)
|
||||||
|
return "".join(c for c in t.lower() if c in _ALNUM)
|
||||||
def load_user_setlists():
|
def load_user_setlists():
|
||||||
# User playlists from /programs.json (pushed by the editor). New {setlists:[{title,programs:[..]}]} form,
|
# User playlists from /programs.json (pushed by the editor). New {setlists:[{title,programs:[..]}]} form,
|
||||||
# or the old flat {programs:[..]} (one list). Built-ins are baked in BUILTIN_SETLISTS, never here.
|
# or the old flat {programs:[..]} (one list). Built-ins are baked in BUILTIN_SETLISTS, never here.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue