Skip to content

Commit bb961db

Browse files
Update hijack boot
1 parent cb44007 commit bb961db

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

docs/os-development/hijack-boot.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
You can intercept the boot sequence to drop into a raw REPL shell instead of starting MicroPythonOS — useful for debugging, running custom startup code, or recovering from a broken install.
44

5+
## How to Hijack the Boot Sequence
6+
7+
Basically, you have to create a file /lib/mpos/main.py
8+
Any code you place there, will be executed by the built-in main.py
9+
510
## The one-liner
611

712
```python
@@ -12,7 +17,9 @@ Copy-paste this into your device's REPL (e.g. over serial) and hit enter. The `o
1217

1318
## What it does
1419

15-
`/lib/mpos/main.py` is MicroPythonOS's entry point. When the firmware boots, it looks for `main.py` on the filesystem — if found, it runs it first. This one-liner writes a stub that raises an error instead, which means:
20+
`/lib/mpos/main.py` is MicroPythonOS's entry point, imported by the frozen `internal_filesystem/main.py`.
21+
22+
When the firmware boots, it looks for `main.py` on the filesystem — if found, it runs it first. This one-liner writes a stub that raises an error instead, which means:
1623

1724
1. The device boots into a clean MicroPython REPL.
1825
2. No MicroPythonOS code (LVGL, apps, frameworks) is loaded.
@@ -34,4 +41,6 @@ To restore normal boot on every power-on, delete the stub:
3441

3542
```python
3643
__import__("os").remove("/lib/mpos/main.py")
44+
import shutil
45+
shutil.rmtree("/lib/mpos")
3746
```

mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ nav:
9191
- On MacOS: os-development/macos.md
9292
- On Windows: os-development/windows.md
9393
- Installing on ESP32: os-development/installing-on-esp32.md
94-
- Hijacking the Boot: os-development/hijack-boot.md
9594
- Automated Testing: os-development/automated-testing.md
9695
- Emulated ESP32: os-development/emulating-esp32-on-desktop.md
9796
- Porting Guide: os-development/porting-guide.md
97+
- Hijacking the Boot: os-development/hijack-boot.md
9898
- Web Port:
9999
- Using the Web Port: web-port/using.md
100100
- Developer Info: web-port/developer.md

0 commit comments

Comments
 (0)