Skip to content

Commit 704b2f3

Browse files
TinyuZhaolbuque
authored andcommitted
boards: Add M5Unit-PoEP4 support.
Signed-off-by: tinyu <tinyu.zhao@gmail.com>
1 parent f986f06 commit 704b2f3

15 files changed

Lines changed: 307 additions & 2 deletions

File tree

.github/workflows/build-firmware.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ jobs:
9797
- M5STACK_Tab5
9898
- M5STACK_Tough
9999
- M5STACK_Unit_C6L
100+
- M5STACK_Unit_PoEP4
100101
- Nesso_N1
101102
- ESPRESSIF_ESP32_S3_BOX_3
102103
- SEEED_STUDIO_XIAO_ESP32S3
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":"V2.0","versionNumber":"V2.4.1","type":"unit-poep4","components":[],"resources":[{"software":["http"]},{"hardware":["hardware_button","hardware_pin_button","rgb","ir"]}],"units":[],"hats":[],"caps":[],"chains":[],"bases":[],"plcmodules":[],"i2cs":[],"chainBus":[],"blockly":"<block type=\"basic_on_setup\" id=\"setup_block\" deletable=\"false\" x=\"50\" y=\"50\"><mutation isBegin=\"true\"></mutation><field name=\"UPDATEOP\">true</field><statement name=\"FUNC\"><block type=\"system_m5_begin\" id=\"},fzcpA/xtwHrR%yh}!%\"><next><block type=\"ethernet_init\" id=\"vA2tzY1J-kF-@z^e4(+!\"><field name=\"NAME\">ethernet_0</field><next><block type=\"ethernet_active\" id=\"(*c]WR0Vp,_U30+q=J~@\"><field name=\"NAME\">ethernet_0</field><field name=\"OPTION\">True</field><next><block type=\"text_print\" id=\"b$.JI}TkpY5u[|Fer4;3\"><value name=\"TEXT\"><shadow type=\"text\" id=\"yuX$0uh=BJpr=fB,7_VK\"><field name=\"TEXT\">wait network connect</field></shadow></value><next><block type=\"controls_whileUntil\" id=\"tOOdY6gJn(u?u][FU,m0\"><field name=\"MODE\">UNTIL</field><value name=\"BOOL\"><block type=\"logic_compare\" id=\"Z|!X-ftjPt+O^1?!3S[p\"><field name=\"OP\">EQ</field><value name=\"A\"><block type=\"ethernet_get_status\" id=\"bAlfq|i^-X(9*Sqwp.ue\"><field name=\"NAME\">ethernet_0</field></block></value><value name=\"B\"><block type=\"ethernet_eth_status\" id=\"]3IH|{Oyu{Fyamk^3O;t\"><field name=\"OPTION\">ETH_GOT_IP</field></block></value></block></value><statement name=\"DO\"><block type=\"text_print\" id=\"AeXK.3F(sHF,?1iaCUl{\"><value name=\"TEXT\"><shadow type=\"text\" id=\"}lLDB1#fYrHT!oH%mOZt\"><field name=\"TEXT\">.</field></shadow></value><next><block type=\"time_sleep_second\" id=\"E.oQBZ#O{^:s=pJkPU5|\"><value name=\"SECOND\"><shadow type=\"math_number\" id=\"RFx#WuNpM[T{VvPKqmhP\"><mutation max=\"Infinity\" min=\"0\" precision=\"0\"></mutation><field name=\"NUM\">1</field></shadow></value></block></next></block></statement><next><block type=\"text_print\" id=\"c3G,^.Bd)m$CN*HWWoHK\"><value name=\"TEXT\"><shadow type=\"text\" id=\"R%eIH%YL=V61P1hHIwa_\"><field name=\"TEXT\">local network is connected</field></shadow></value><next><block type=\"text_print\" id=\"i5Pyn3@Kd:(F9N}jJU_V\"><value name=\"TEXT\"><shadow type=\"text\" id=\"-bA0;jP5fO53VBJoRMq~\"><field name=\"TEXT\">hello M5</field></shadow><block type=\"text_add_str\" id=\"Cqc4_Z+0xeEOx:loI6K2\"><value name=\"VALUE1\"><shadow type=\"text\" id=\"~ro.AKdt|Tf_d9U=UIVA\"><field name=\"TEXT\">IP:</field></shadow></value><value name=\"VALUE2\"><block type=\"ethernet_get_localip\" id=\"C]/3_SalSi=x}*UEyP^v\"><field name=\"NAME\">ethernet_0</field></block></value></block></value><next><block type=\"text_print\" id=\"H_*@(8#HiZ{y!xnjC^Q^\"><value name=\"TEXT\"><shadow type=\"text\" id=\"I1f6_J{.1bjh^mXs*V[k\"><field name=\"TEXT\">Please press the Btn</field></shadow></value></block></next></block></next></block></next></block></next></block></next></block></next></block></next></block></statement></block><block type=\"basic_on_loop\" id=\"loop_block\" deletable=\"false\" x=\"50\" y=\"470\"><mutation isUpdate=\"true\"></mutation><field name=\"UPDATEOP\">true</field><statement name=\"FUNC\"><block type=\"system_m5_update\" id=\"0_|ZkG_{N`VH0pI1VJQ3\"><next><block type=\"controls_if\" id=\"xje*Iou=jsv2/Lc5|FLZ\"><value name=\"IF0\"><block type=\"button_get_status\" id=\"^^+pYh]xb|H`9Mk-hDRE\"><field name=\"NAME\">BtnA</field><field name=\"OPTION\">wasClicked</field></block></value><statement name=\"DO0\"><block type=\"text_print\" id=\"rdlmIL8q,dL_bG(`z[~B\"><value name=\"TEXT\"><shadow type=\"text\" id=\"!4mqHN(-9,*00*d_(;jE\"><field name=\"TEXT\">Btn Pressed</field></shadow></value><next><block type=\"http_request\" id=\"=SN=O7(A!u_Q*F//ArM6\"><mutation contentType=\"json\"></mutation><field name=\"METHOD\">GET</field><field name=\"TYPE\">json</field><value name=\"URL\"><shadow type=\"text\" id=\"p`JcP7mv,E8P.NFnggv_\"><field name=\"TEXT\">https://wttr.in/?format=%22%C,%20%t%22</field></shadow></value><value name=\"CONTENT_TYPE\"><shadow type=\"text\" id=\"V0W3G8tYqZ/Yx6mJgf=c\"><field name=\"TEXT\">application/json</field></shadow></value><value name=\"HEADERS\"><block type=\"map_on_loop\" id=\"~SQWh{xt3`7G*OtZGJ]P\"></block></value><value name=\"DATA\"><block type=\"map_on_loop\" id=\"69t6.[I{?(([Au81DRj5\"></block></value><next><block type=\"text_print\" id=\"S`(=XajU~p)-48{ZMZ2:\"><value name=\"TEXT\"><shadow type=\"text\" id=\"-bA0;jP5fO53VBJoRMq~\"><field name=\"TEXT\">hello M5</field></shadow><block type=\"text_add_str\" id=\"AIp{u-MU]B/U!UejGkPw\"><value name=\"VALUE1\"><shadow type=\"text\" id=\"LT(t@AZR.HC,J.t=|kd!\"><field name=\"TEXT\">Status Code:</field></shadow></value><value name=\"VALUE2\"><block type=\"http_get_status_code\" id=\"yw?)7/)=!OjYU:Ja#%m8\"></block></value></block></value><next><block type=\"text_print\" id=\"o1.!m:QFzAQMEo9q5G9c\"><value name=\"TEXT\"><shadow type=\"text\" id=\"-bA0;jP5fO53VBJoRMq~\"><field name=\"TEXT\">hello M5</field></shadow><block type=\"text_add_str\" id=\"|T]JP/:$)thmR$ToysNx\"><value name=\"VALUE1\"><shadow type=\"text\" id=\"Qtq(F(V^1q5.JPm-qbKJ\"><field name=\"TEXT\">Text:</field></shadow></value><value name=\"VALUE2\"><block type=\"http_get_text\" id=\"`LXIXT7(KIah{F7q/`go\"></block></value></block></value></block></next></block></next></block></next></block></statement></block></next></block></statement></block>","screen":[],"logicWhenNum":0,"customList":[]}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# SPDX-FileCopyrightText: 2026 M5Stack Technology CO LTD
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
import os, sys, io
6+
import M5
7+
from M5 import *
8+
import machine
9+
import network
10+
import requests2
11+
import time
12+
13+
14+
ethernet_0 = None
15+
http_req = None
16+
17+
18+
def setup():
19+
global ethernet_0, http_req
20+
21+
M5.begin()
22+
ethernet_0 = network.LAN(
23+
0,
24+
phy_addr=1,
25+
phy_type=network.PHY_IP101,
26+
mdc=machine.Pin(31),
27+
mdio=machine.Pin(52),
28+
power=machine.Pin(51),
29+
)
30+
31+
ethernet_0.active(True)
32+
print("wait network connect")
33+
while not (ethernet_0.status()) == (network.ETH_GOT_IP):
34+
print(".")
35+
time.sleep(1)
36+
print("local network is connected")
37+
print((str("IP:") + str((ethernet_0.ifconfig()[0]))))
38+
print("Please press the Btn")
39+
40+
41+
def loop():
42+
global ethernet_0, http_req
43+
M5.update()
44+
if BtnA.wasClicked():
45+
print("Btn Pressed")
46+
http_req = requests2.get(
47+
"https://wttr.in/?format=%22%C,%20%t%22", headers={"Content-Type": "application/json"}
48+
)
49+
print((str("Status Code:") + str((http_req.status_code))))
50+
print((str("Text:") + str((http_req.text))))
51+
52+
53+
if __name__ == "__main__":
54+
try:
55+
setup()
56+
while True:
57+
loop()
58+
except (Exception, KeyboardInterrupt) as e:
59+
try:
60+
from utility import print_error_msg
61+
62+
print_error_msg(e)
63+
except ImportError:
64+
print("please update to latest firmware")

m5stack/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ boards := \
4949
M5STACK_Unit_C6L:unit_c6l \
5050
M5STACK_PowerHub:powerhub \
5151
M5STACK_DualKey:dualkey \
52-
M5STACK_StickS3:sticks3
52+
M5STACK_StickS3:sticks3 \
53+
M5STACK_Unit_PoEP4:unit_poep4
5354

5455
define find_board
5556
$(if $(filter $(1):%,$(boards)),$(word 2,$(subst :, ,$(filter $(1):%,$(boards)))),none)
@@ -95,7 +96,8 @@ BOARD_TYPE_DEF := \
9596
unit_c6l \
9697
powerhub \
9798
dualkey \
98-
sticks3
99+
sticks3 \
100+
unit_poep4
99101

100102
# Select the board type to build, default is None
101103
# This value affects which folder in the "./fs/system/" directory is pack into "fs-system.bin"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"deploy": [
3+
"../deploy.md"
4+
],
5+
"docs": "",
6+
"features": [
7+
"BLE",
8+
"External Flash",
9+
"WiFi"
10+
],
11+
"images": [
12+
"generic_p4.jpg"
13+
],
14+
"mcu": "esp32p4",
15+
"product": "M5Stack P4 Serials",
16+
"thumbnail": "",
17+
"url": "https://www.espressif.com/en/products/",
18+
"vendor": "M5Stack"
19+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
include("$(MPY_DIR)/../m5stack/modules/startup/manifest_unit_poep4.py")
6+
include("$(MPY_DIR)/../m5stack/libs/unit/manifest.py")
7+
include("$(MPY_DIR)/../m5stack/libs/chain/manifest.py")
8+
include("$(MPY_DIR)/../m5stack/libs/usb/manifest.py")
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
set(IDF_TARGET esp32p4)
6+
7+
# https://github.com/m5stack/m5stack-board-id/blob/main/board.csv#L29
8+
set(BOARD_ID 148)
9+
set(MICROPY_PY_LVGL 0)
10+
11+
set(SDKCONFIG_DEFAULTS
12+
./boards/sdkconfig.base
13+
${SDKCONFIG_IDF_VERSION_SPECIFIC}
14+
./boards/sdkconfig.disable_iram
15+
./boards/sdkconfig.flash_16mb
16+
./boards/sdkconfig.freertos
17+
./boards/M5STACK_Unit_PoEP4/sdkconfig.board
18+
)
19+
20+
# If not enable LVGL, ignore this...
21+
set(LV_CFLAGS -DLV_COLOR_DEPTH=16 -DLV_COLOR_16_SWAP=0)
22+
23+
if(NOT MICROPY_FROZEN_MANIFEST)
24+
set(MICROPY_FROZEN_MANIFEST ${CMAKE_SOURCE_DIR}/boards/manifest.py)
25+
endif()
26+
27+
# NOTE: 这里的配置是无效的,仅为了兼容ADF,保证编译通过
28+
set(ADF_COMPS "$ENV{ADF_PATH}/components")
29+
set(ADF_BOARD_DIR "$ENV{ADF_PATH}/components/audio_board/esp32_s3_box_3")
30+
31+
list(APPEND EXTRA_COMPONENT_DIRS
32+
$ENV{ADF_PATH}/components/audio_pipeline
33+
$ENV{ADF_PATH}/components/audio_sal
34+
$ENV{ADF_PATH}/components/esp-adf-libs
35+
$ENV{ADF_PATH}/components/esp-sr
36+
${CMAKE_SOURCE_DIR}/boards
37+
)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*/
6+
7+
#ifndef MICROPY_HW_BOARD_NAME
8+
#define MICROPY_HW_BOARD_NAME "M5STACK Unit PoEP4"
9+
#endif
10+
11+
#ifndef MICROPY_HW_MCU_NAME
12+
#define MICROPY_HW_MCU_NAME "ESP32P4"
13+
#endif
14+
#define MICROPY_HW_BOARD_NAME "M5STACK Unit PoEP4"
15+
16+
#define MICROPY_HW_ENABLE_USBDEV (0)
17+
#define MICROPY_PY_ESPNOW (0)
18+
#define MICROPY_PY_BLUETOOTH (0)
19+
#define MICROPY_PY_NETWORK_LAN (1)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# SPDX-FileCopyrightText: 2025 M5Stack Technology CO LTD
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
CONFIG_FLASHMODE_DIO=y # QIO mode has some problem when mount fs
6+
CONFIG_ESPTOOLPY_FLASHMODE_DIO=y
7+
CONFIG_ESPTOOLPY_FLASHMODE="dio"
8+
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
9+
CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y
10+
CONFIG_ESPTOOLPY_AFTER_NORESET=y
11+
12+
CONFIG_SPIRAM_MEMTEST=
13+
# CONFIG_FREERTOS_UNICORE=y
14+
15+
# M5STACK UiFlow USB description
16+
CONFIG_TINYUSB_DESC_CDC_STRING="M5Stack PowerHub(UiFlow2)"
17+
18+
# SSL
19+
CONFIG_MBEDTLS_AES_USE_INTERRUPT=n
20+
21+
CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY=y
22+
23+
# ULP Coprocessor
24+
# CONFIG_ULP_COPROC_ENABLED is not set
25+
26+
# Ethernet
27+
CONFIG_ETH_ENABLED=y
28+
CONFIG_ETH_USE_ESP32_EMAC=y
29+
CONFIG_ETH_PHY_INTERFACE_RMII=y
30+
CONFIG_ETH_DMA_BUFFER_SIZE=512
31+
CONFIG_ETH_DMA_RX_BUFFER_NUM=20
32+
CONFIG_ETH_DMA_TX_BUFFER_NUM=10
33+
# CONFIG_ETH_SOFT_FLOW_CONTROL is not set
34+
# CONFIG_ETH_IRAM_OPTIMIZATION is not set
35+
# CONFIG_ETH_USE_SPI_ETHERNET is not set
36+
# CONFIG_ETH_USE_OPENETH is not set
37+
# CONFIG_ETH_TRANSMIT_MUTEX is not set
38+
# end of Ethernet

m5stack/cmodules/m5unified/m5unified.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ static const mp_rom_map_elem_t m5_board_member_table[] = {
5454
{ MP_ROM_QSTR(MP_QSTR_M5AtomEchoS3R), MP_ROM_INT(145) },
5555
{ MP_ROM_QSTR(MP_QSTR_M5PowerHub), MP_ROM_INT(146) },
5656
{ MP_ROM_QSTR(MP_QSTR_M5DualKey), MP_ROM_INT(147) },
57+
{ MP_ROM_QSTR(MP_QSTR_M5Unit_PoEP4), MP_ROM_INT(148) },
5758
// external displays
5859
{ MP_ROM_QSTR(MP_QSTR_M5ATOMDisplay), MP_ROM_INT(192) },
5960
{ MP_ROM_QSTR(MP_QSTR_M5UnitLCD), MP_ROM_INT(193) },

0 commit comments

Comments
 (0)