Skip to content

feat: add M5Stack Core2 board support#91

Open
imliubo wants to merge 1 commit intoMicroPythonOS:mainfrom
imliubo:feat-m5core2-support
Open

feat: add M5Stack Core2 board support#91
imliubo wants to merge 1 commit intoMicroPythonOS:mainfrom
imliubo:feat-m5core2-support

Conversation

@imliubo
Copy link

@imliubo imliubo commented Mar 26, 2026

Summary

Add board support for M5Stack Core2, including AXP192 power management driver
and full hardware initialization (display, touch, audio, IMU, battery).

Changes

  • New: drivers/power/axp192.py - AXP192 PMU driver
  • New: mpos/board/m5stack_core2.py - Core2 board initialization
  • Modified: mpos/main.py - Board detection for Core2 + ESP32 GPIO safety fix

Hardware Tested

  • M5Stack Core2 (original version) - all peripherals functional
  • Display, touch, IMU, battery monitoring working
  • Audio output/input registered (startup sound TODO: needs WAV file)

Notes

  • Core2 detection uses AXP192 (I2C 0x34) probe, placed before Fire detection
  • ESP32-S3 specific I2C probes (GPIO 10/11, 39/38, 48/47) are now guarded
    with chip variant check to prevent WDT reset on plain ESP32
  • No impact on existing board support (Fire, Lilygo, fri3d, etc.)

Add hardware support for M5Stack Core2 (ESP32-D0WDQ6-V3):

New files:
- drivers/power/axp192.py: AXP192 power management IC driver handling
  voltage regulation (DCDC1/3, LDO2/3), GPIO control (LCD/touch reset,
  speaker enable), battery monitoring via ADC, and charging control.
- mpos/board/m5stack_core2.py: Board initialization including ILI9342C
  display (SPI), FT6336U capacitive touch (I2C), NS4168 I2S speaker,
  SPM1423 PDM microphone, MPU6886 IMU, and AXP192-based battery
  voltage reading.

Modified files:
- mpos/main.py: Add Core2 detection via AXP192 I2C probe (0x34) in
  detect_board(). Guard ESP32-S3 specific GPIO probes (pins 10/11,
  39/38, 48/47) with chip variant check to prevent WDT reset on ESP32.

Hardware peripherals supported:
- Display: ILI9342C 320x240 via SPI (SCLK=18, MOSI=23, DC=15, CS=5)
- Touch: FT6336U via shared I2C host 0 (SDA=21, SCL=22, addr=0x38)
- Power: AXP192 via shared I2C host 0 (addr=0x34)
- Audio: NS4168 speaker (I2S: BCLK=12, LRCK=0, DATA=2)
- Mic: SPM1423 (PDM: CLK=0, DATA=34)
- IMU: MPU6886 via shared I2C host 0 (addr=0x68)
- Battery: Read via AXP192 ADC (no dedicated ADC pin needed)

All I2C devices share a single hardware I2C(0) controller. LCD reset
and backlight are controlled via AXP192 GPIO4 and DCDC3 respectively.

Tested on M5Stack Core2 (original version).

Signed-off-by: imliubo <[email protected]>
@imliubo
Copy link
Author

imliubo commented Mar 26, 2026

Here is some pic:

This is very amazing project! M5Stack would be very happy to offer some support!

@ThomasFarstrike
Copy link
Contributor

Super cool! Awesome to see another board support land, looks good!

ESP32-S3 specific I2C probes (GPIO 10/11, 39/38, 48/47) are now guarded with chip variant check to prevent WDT reset on plain ESP32

Nice touch!

In general, the whole board detect should be reworked to be more modular (not in main.py but in each board's file) but that's out of the scope of this pull request.

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.

2 participants