Skip to content

Add initial support for M5Stack-Fire board#32

Merged
ThomasFarstrike merged 5 commits intoMicroPythonOS:mainfrom
ancebfer:m5stack-fire
Feb 13, 2026
Merged

Add initial support for M5Stack-Fire board#32
ThomasFarstrike merged 5 commits intoMicroPythonOS:mainfrom
ancebfer:m5stack-fire

Conversation

@ancebfer
Copy link
Copy Markdown
Contributor

@ancebfer ancebfer commented Feb 7, 2026

Only display and buttons support for M5Stack-Fire.

DON'T merge directly to the main branch. Create his own branch.

demo.mp4

M5Stack-Fire board detection should be:

i2c0 = I2C(0, sda=Pin(21), scl=Pin(22)) 
if {0x68} <= set(i2c0.scan()): # IMU (MPU6886)
    return "m5stack-fire"

But there are some pin incompatibilities between ESP32 and ESP32-S3 boards that don't allow I2C scan.
M5Stack-Fire uses an ILI9342 instead of an ILI9341. Therefore, lvgl_micropython should include "_ili9341_init_type3.py".
Avoid new "_ili9341_init_type3.py" file dependency in lvgl_micropython by following suggestion:

lvgl-micropython/lvgl_micropython#527
@ThomasFarstrike
Copy link
Copy Markdown
Contributor

Very cool!

DON'T merge directly to the main branch. Create his own branch.

Why not? :-D I think we can merge this fairly soon, I mean, ok, we need to modify the build script so that it has "esp32" and "esp32s3" as targets, but other than that...?

@ancebfer
Copy link
Copy Markdown
Contributor Author

As you guessed, this is exactly the reason: the pull request changes the build script from esp32s3 to esp32.

As you suggest, modifying the build script to support both esp32 and esp32s3 is the better solution.

Best regards.

@jedie
Copy link
Copy Markdown
Contributor

jedie commented Feb 10, 2026

I can confirm, that it works in general.

@ThomasFarstrike
Copy link
Copy Markdown
Contributor

Awesome! I wouldn't mind merging this! We will have to start carrying 2 builds (esp32 and esp32s3) which means more release artifacts, double the OTA update images, double the webinstaller images,... but this was bound to happen :-D

Let's push out the 0.8.0 release as a "stable" checkpoint and then integrate this one for the next release.

@ancebfer
Copy link
Copy Markdown
Contributor Author

Build fails because the move command uses esp32s3 image name instead of esp32 image name:

/Users/runner/.espressif/python_env/idf5.4_py3.14_env/bin/python -m esptool --chip esp32 -p (PORT) -b 460800 --before default_reset --after hard_reset write_flash --flash_mode dio --flash_size 16MB --flash_freq 40m --erase-all 0x0 /Users/runner/work/MicroPythonOS/MicroPythonOS/lvgl_micropython/build/lvgl_micropy_ESP32_GENERIC-SPIRAM-16.bin

~/work/MicroPythonOS/MicroPythonOS
Grepping...
/Users/runner/work/MicroPythonOS/MicroPythonOS
./internal_filesystem/lib/mpos/ui/camera_activity.py
./scripts/build_mpos.sh
mv: rename lvgl_micropython/build/lvgl_micropy_ESP32_GENERIC_S3-SPIRAM_OCT-16.bin to lvgl_micropython/build/MicroPythonOS_esp32_0.7.2.bin: No such file or directory
Error: Process completed with exit code 1.

if (btn_a.value() == 0) and (btn_c.value() == 0):
current_key = lv.KEY.ESC

# Key repeat logic
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In #35 i implement a other auto-key-repeat solution. Maybe it fits also for the FIRE ?

REPEAT_INITIAL_DELAY_MS = 300  # Delay before first repeat
REPEAT_RATE_MS = 100  # Interval between repeats
next_repeat = None  # Used for auto-repeat key handling


def input_callback(indev, data):
    global next_repeat

    current_key = None

    if crossbar_pressed := crossbar.poll():
        current_key = crossbar_pressed
    elif button_menu.value() == 0:
        current_key = lv.KEY.ESC
        
    # ... handle other buttons here ...
    
    else:
        # No crossbar/buttons pressed
        if data.key:  # A key was previously pressed and now released
            # print(f"Key {data.key=} released")
            data.key = 0
            data.state = lv.INDEV_STATE.RELEASED
            next_repeat = None
        return

    # A key is currently pressed
    current_time = time.ticks_ms()
    repeat = current_time > next_repeat if next_repeat else False  # Auto repeat?
    if repeat or current_key != data.key:
        print(f"Key {current_key} pressed {repeat=}")

        data.key = current_key
        data.state = lv.INDEV_STATE.PRESSED

        if current_key == lv.KEY.ESC:  # Handle ESC for back navigation
            mpos.ui.back_screen()
        elif current_key == lv.KEY.RIGHT:
            mpos.ui.focus_direction.move_focus_direction(90)
            
        # ... handle other buttons here ...

        if not repeat:
            # Initial press: Delay before first repeat
            next_repeat = current_time + REPEAT_INITIAL_DELAY_MS
        else:
            # Faster auto repeat after initial press
            next_repeat = current_time + REPEAT_RATE_MS

TFT_HOR_RES=320
TFT_VER_RES=240

spi_bus = machine.SPI.Bus(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems this doesn't work in a soft reset. So why not doing this:

try:
    spi_bus = machine.SPI.Bus(host=SPI_BUS, mosi=LCD_MOSI, sck=LCD_SCLK)
except Exception as e:
    print(f"Error initializing SPI bus: {e}")
    print("Attempting hard reset in 3sec...")
    time.sleep(3)
    machine.reset()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably fine, I mean it's a workaround, not a fix, or something that seems trivial, but it's better than nothing, I guess...

I never understood why those soft resets even happen... any idea? I think I disabled them at some point in mpremote.py because of... issues...

@ThomasFarstrike
Copy link
Copy Markdown
Contributor

Build fails because the move command uses esp32s3 image name instead of esp32 image name:

I've added esp32 and esp32s3 as separate targets, should be good now, if not, I'll fix it.

@ThomasFarstrike ThomasFarstrike merged commit 2ef3b1c into MicroPythonOS:main Feb 13, 2026
0 of 2 checks passed
@ThomasFarstrike
Copy link
Copy Markdown
Contributor

It's merged, and I had to move around drivers around to make a unified build, but I don't have the hardware to test and make sure I properly adjusted the imports etc.

Would you mind trying the latest esp32 build from https://github.com/MicroPythonOS/MicroPythonOS/actions/ ?

Thanks a lot for your help!

@ancebfer
Copy link
Copy Markdown
Contributor Author

After testing the latest esp32 build (MicroPythonOS_esp32_0.8.1.bin), I can confirm that it works as expected in the M5Stack-Fire.

Best regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants