Skip to content

Commit c37abb1

Browse files
Update porting-guide.md
1 parent bb2ae16 commit c37abb1

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

docs/os-development/porting-guide.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,25 @@ Of course, porting is always quite a technical undertaking, so if you want to ma
88

99
If you prefer to have the porting work done for you and you're open to making a donation, be sure to [reach out](mailto:info@MicroPythonOS.com) and we'll get it done!
1010

11+
## Overriding Board Detection
12+
13+
MicroPythonOS detects your board at boot by probing unique IDs and I2C addresses in `lib/mpos/main.py:detect_board()`. When porting to a new board, you can skip modifying that detection logic entirely by pre-setting the hardware ID before `mpos.main` is imported:
14+
15+
```python
16+
from mpos.device_info import DeviceInfo
17+
DeviceInfo.set_hardware_id("myboard")
18+
19+
import mpos.main # skips detection, imports mpos.board.myboard directly
20+
```
21+
22+
This is useful when:
23+
- You're using a generic build (`ESP32_GENERIC_S3`) and don't want to create a custom build.
24+
- You just want to deploy your board init file alongside an override — no frozen-code changes.
25+
26+
You don't need a `mpos/board/myboard.py` file at all — the import is optional (`ImportError` is caught). You can initialize your display and peripherals inline instead, right in the same script that sets the hardware ID. Place the override in your own `main.py` on the internal storage (it runs before `mpos.main`), or in `_boot.py` before the standard `main.py` is reached.
27+
28+
If `DeviceInfo.hardware_id` is still `"missing-hardware-info"` (its default), `mpos.main` falls through to normal detection.
29+
1130
## What to write
1231

1332
By design, the only device-specific code for MicroPythonOS is found in the ```internal_filesystem/lib/mpos/board/<boardname>.py``` files.

0 commit comments

Comments
 (0)