Skip to content

feat: add M5Stack Core2 board support#91

Merged
ThomasFarstrike merged 2 commits intoMicroPythonOS:mainfrom
imliubo:feat-m5core2-support
Mar 28, 2026
Merged

feat: add M5Stack Core2 board support#91
ThomasFarstrike merged 2 commits intoMicroPythonOS:mainfrom
imliubo:feat-m5core2-support

Conversation

@imliubo
Copy link
Copy Markdown
Contributor

@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 <imliubo@makingfun.xyz>
@imliubo
Copy link
Copy Markdown
Contributor 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
Copy Markdown
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.

@ThomasFarstrike ThomasFarstrike merged commit 96164fe into MicroPythonOS:main Mar 28, 2026
4 checks passed
@ThomasFarstrike
Copy link
Copy Markdown
Contributor

There was a conflict with the T-HMI board support and I did the merge in a hurry in the browser so hopefully it's fine.

Separating the board detecting ESP32 vs ESP32S3 is a good move to narrow it down!

jedie pushed a commit to jedie/MicroPythonOS that referenced this pull request Mar 28, 2026
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 <imliubo@makingfun.xyz>
Co-authored-by: Thomas Farstrike <111072251+ThomasFarstrike@users.noreply.github.com>
@imliubo
Copy link
Copy Markdown
Contributor Author

imliubo commented Mar 28, 2026

Thx!
We are very happy to do some support to make this project more success.

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