Skip to content

Commit f7f3a99

Browse files
committed
Initial commit
0 parents  commit f7f3a99

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2896
-0
lines changed

.gitignore

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Compiled Sources
2+
###################
3+
*.o
4+
*.a
5+
*.elf
6+
*.bin
7+
*.map
8+
*.hex
9+
*.dis
10+
*.exe
11+
12+
# Packages
13+
############
14+
15+
# Logs and Databases
16+
######################
17+
*.log
18+
19+
# VIM Swap Files
20+
######################
21+
*.swp
22+
23+
# Build directories
24+
######################
25+
build/
26+
build-*/
27+
28+
# Test failure outputs
29+
######################
30+
tests/results/*
31+
32+
# Python cache files
33+
######################
34+
__pycache__/
35+
*.pyc
36+
37+
# Customized Makefile/project overrides
38+
######################
39+
GNUmakefile
40+
user.props
41+
42+
# Generated rst files
43+
######################
44+
genrst/
45+
46+
# MacOS desktop metadata files
47+
######################
48+
.DS_Store
49+
50+
.vscode/

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "micropython"]
2+
path = micropython
3+
url = https://github.com/micropython/micropython

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# uiflow_micropython
2+
3+
## build
4+
5+
```shell
6+
git clone https://github.com/m5stack/uiflow_micropython --recursive
7+
cd uiflow_micropython/m5stack
8+
make submodules
9+
make mpy-cross
10+
make -j
11+
make deploy PORT=/dev/ttyUSBx BAUD=1500000
12+
```

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# uiflow-micropyton api docs

m5stack/CMakeLists.txt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Top-level cmake file for building MicroPython on ESP32.
2+
3+
cmake_minimum_required(VERSION 3.12)
4+
5+
# Set the location of this port's directory.
6+
set(MICROPY_PORT_DIR ${CMAKE_SOURCE_DIR}/../micropython/ports/esp32)
7+
8+
# Set the board if it's not already set.
9+
if(NOT MICROPY_BOARD)
10+
set(MICROPY_BOARD m5stack)
11+
endif()
12+
13+
# Set the board directory and check that it exists.
14+
if(NOT MICROPY_BOARD_DIR)
15+
set(MICROPY_BOARD_DIR ${CMAKE_SOURCE_DIR}/boards/${MICROPY_BOARD})
16+
endif()
17+
if(NOT EXISTS ${MICROPY_BOARD_DIR}/mpconfigboard.cmake)
18+
message(FATAL_ERROR "Invalid MICROPY_BOARD specified: ${MICROPY_BOARD}")
19+
endif()
20+
21+
# Define the output sdkconfig so it goes in the build directory.
22+
set(SDKCONFIG ${CMAKE_BINARY_DIR}/sdkconfig)
23+
24+
# Include board config; this is expected to set SDKCONFIG_DEFAULTS (among other options).
25+
include(${MICROPY_BOARD_DIR}/mpconfigboard.cmake)
26+
27+
# Concatenate all sdkconfig files into a combined one for the IDF to use.
28+
file(WRITE ${CMAKE_BINARY_DIR}/sdkconfig.combined.in "")
29+
foreach(SDKCONFIG_DEFAULT ${SDKCONFIG_DEFAULTS})
30+
file(READ ${SDKCONFIG_DEFAULT} CONTENTS)
31+
file(APPEND ${CMAKE_BINARY_DIR}/sdkconfig.combined.in "${CONTENTS}")
32+
endforeach()
33+
configure_file(${CMAKE_BINARY_DIR}/sdkconfig.combined.in ${CMAKE_BINARY_DIR}/sdkconfig.combined COPYONLY)
34+
set(SDKCONFIG_DEFAULTS ${CMAKE_BINARY_DIR}/sdkconfig.combined)
35+
36+
# Include main IDF cmake file and define the project.
37+
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
38+
project(micropython)

m5stack/Makefile

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Makefile for MicroPython on ESP32.
2+
#
3+
# This is a simple, convenience wrapper around idf.py (which uses cmake).
4+
5+
# Select the board to build for, defaulting to GENERIC.
6+
BOARD ?= m5stack
7+
8+
# If the build directory is not given, make it reflect the board name.
9+
BUILD ?= build-$(BOARD)
10+
11+
# Device serial settings.
12+
#PORT ?= /dev/ttyS8
13+
PORT ?= /dev/ttyUSB0
14+
BAUD ?= 1500000
15+
16+
PYTHON ?= python3
17+
18+
GIT_SUBMODULES = lib/berkeley-db-1.xx
19+
20+
.PHONY: all clean deploy erase submodules FORCE
21+
22+
MAKEFILE_DIR:=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))
23+
24+
USER_C_MODULES = $(MAKEFILE_DIR)/cmodules/cmodules.cmake
25+
26+
CMAKE_ARGS =
27+
28+
ifdef USER_C_MODULES
29+
CMAKE_ARGS += -DUSER_C_MODULES=${USER_C_MODULES}
30+
endif
31+
32+
IDFPY_FLAGS += -D MICROPY_BOARD=$(BOARD) -B $(BUILD) $(CMAKE_ARGS)
33+
34+
ifdef FROZEN_MANIFEST
35+
IDFPY_FLAGS += -D MICROPY_FROZEN_MANIFEST=$(FROZEN_MANIFEST)
36+
endif
37+
38+
all:
39+
idf.py $(IDFPY_FLAGS) build
40+
@$(PYTHON) makeimg.py \
41+
$(BUILD)/sdkconfig \
42+
$(BUILD)/bootloader/bootloader.bin \
43+
$(BUILD)/partition_table/partition-table.bin \
44+
$(BUILD)/micropython.bin \
45+
$(BUILD)/firmware.bin
46+
47+
$(BUILD)/bootloader/bootloader.bin $(BUILD)/partition_table/partition-table.bin $(BUILD)/micropython.bin: FORCE
48+
49+
clean:
50+
idf.py $(IDFPY_FLAGS) fullclean
51+
52+
deploy:
53+
idf.py $(IDFPY_FLAGS) -p $(PORT) -b $(BAUD) flash
54+
55+
monitor:
56+
idf.py $(IDFPY_FLAGS) -p $(PORT) -b $(BAUD) monitor
57+
58+
erase:
59+
idf.py $(IDFPY_FLAGS) -p $(PORT) -b $(BAUD) erase_flash
60+
61+
mpy-cross:
62+
make -C ../micropython/mpy-cross
63+
64+
submodules:
65+
cd ./../micropython && git submodule update --init $(addprefix ./,$(GIT_SUBMODULES)) && cd -

m5stack/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# micropython m5stack port
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
set(SDKCONFIG_DEFAULTS
2+
./boards/sdkconfig.base
3+
./boards/sdkconfig.ble
4+
./boards/sdkconfig.spiram
5+
./boards/sdkconfig.240mhz
6+
./boards/sdkconfig.disable_iram
7+
)
8+
9+
if(NOT MICROPY_FROZEN_MANIFEST)
10+
set(MICROPY_FROZEN_MANIFEST ${CMAKE_SOURCE_DIR}/boards/manifest.py)
11+
endif()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#define MICROPY_HW_BOARD_NAME "M5STACK"
2+
#define MICROPY_HW_MCU_NAME "ESP32"

m5stack/boards/manifest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
freeze("$(MPY_DIR)/../m5stack/modules")
2+
freeze("$(MPY_DIR)/tools", ("upip.py", "upip_utarfile.py"))
3+
freeze("$(MPY_DIR)/ports/esp8266/modules", "ntptime.py")
4+
freeze("$(MPY_DIR)/drivers/dht", "dht.py")
5+
freeze("$(MPY_DIR)/drivers/onewire")
6+
include("$(MPY_DIR)/extmod/uasyncio/manifest.py")
7+
include("$(MPY_DIR)/extmod/webrepl/manifest.py")
8+
include("$(MPY_DIR)/drivers/neopixel/manifest.py")

m5stack/boards/manifest_release.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include("manifest.py")
2+
3+
freeze("$(MPY_LIB_DIR)/python-ecosys/urequests", "urequests.py")
4+
5+
freeze("$(MPY_LIB_DIR)/micropython/upysh", "upysh.py")
6+
freeze("$(MPY_LIB_DIR)/micropython/umqtt.simple", "umqtt/simple.py")
7+
freeze("$(MPY_LIB_DIR)/micropython/umqtt.robust", "umqtt/robust.py")

m5stack/boards/sdkconfig.240mhz

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# MicroPython on ESP32, ESP IDF configuration with 240MHz CPU
2+
CONFIG_ESP32_DEFAULT_CPU_FREQ_80=
3+
CONFIG_ESP32_DEFAULT_CPU_FREQ_160=
4+
CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y
5+
CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=240

m5stack/boards/sdkconfig.base

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# MicroPython on ESP32, ESP IDF configuration
2+
# The following options override the defaults
3+
4+
CONFIG_IDF_FIRMWARE_CHIP_ID=0x0000
5+
6+
# Compiler options: use -Os to reduce size, but keep full assertions
7+
# (CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE is for IDF 4.0.2)
8+
CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE=y
9+
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
10+
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y
11+
12+
# Application manager
13+
CONFIG_APP_EXCLUDE_PROJECT_VER_VAR=y
14+
CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR=y
15+
16+
# Bootloader config
17+
CONFIG_BOOTLOADER_LOG_LEVEL_WARN=y
18+
19+
# Change default log level to "ERROR" (instead of "INFO")
20+
CONFIG_LOG_DEFAULT_LEVEL_INFO=n
21+
CONFIG_LOG_DEFAULT_LEVEL_ERROR=y
22+
CONFIG_LOG_DEFAULT_LEVEL=1
23+
24+
# ESP32-specific
25+
CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=n
26+
CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=n
27+
CONFIG_ESP32_XTAL_FREQ_AUTO=y
28+
29+
# Power Management
30+
CONFIG_PM_ENABLE=y
31+
32+
# Memory protection
33+
# This is required to allow allocating IRAM
34+
CONFIG_ESP_SYSTEM_MEMPROT_FEATURE=n
35+
36+
# FreeRTOS
37+
CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=2
38+
CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y
39+
CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP=y
40+
41+
# UDP
42+
CONFIG_LWIP_PPP_SUPPORT=y
43+
CONFIG_LWIP_PPP_PAP_SUPPORT=y
44+
CONFIG_LWIP_PPP_CHAP_SUPPORT=y
45+
46+
# SSL
47+
# Use 4kiB output buffer instead of default 16kiB (because IDF heap is fragmented in 4.0)
48+
CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y
49+
50+
# ULP coprocessor support
51+
CONFIG_ESP32_ULP_COPROC_ENABLED=y
52+
53+
# For cmake build
54+
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
55+
CONFIG_PARTITION_TABLE_CUSTOM=y
56+
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
57+
58+
# To reduce iRAM usage
59+
CONFIG_ESP32_WIFI_IRAM_OPT=n
60+
CONFIG_ESP32_WIFI_RX_IRAM_OPT=n

m5stack/boards/sdkconfig.ble

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Note this requires building with IDF 4.x
2+
CONFIG_BT_ENABLED=y
3+
CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y
4+
CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=
5+
CONFIG_BTDM_CTRL_MODE_BTDM=
6+
7+
CONFIG_BT_NIMBLE_ENABLED=y
8+
9+
CONFIG_BT_NIMBLE_MAX_CONNECTIONS=4
10+
11+
# Pin to the same core as MP.
12+
# Until we move to IDF 4.2+, we need NimBLE on core 0, and for synchronisation
13+
# with the ringbuffer and scheduler MP needs to be on the same core.
14+
# See https://github.com/micropython/micropython/issues/5489
15+
CONFIG_BT_NIMBLE_PINNED_TO_CORE_0=y
16+
CONFIG_BT_NIMBLE_PINNED_TO_CORE_1=n
17+
CONFIG_BT_NIMBLE_PINNED_TO_CORE=0

m5stack/boards/sdkconfig.disable_iram

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
CONFIG_SPI_SLAVE_IN_IRAM=n
2+
CONFIG_SPI_SLAVE_ISR_IN_IRAM=n
3+
CONFIG_SPI_MASTER_IN_IRAM=n
4+
CONFIG_SPI_MASTER_ISR_IN_IRAM=n
5+
CONFIG_SPIRAM_CACHE_LIBCHAR_IN_IRAM=n
6+
CONFIG_SPIRAM_CACHE_LIBENV_IN_IRAM=n
7+
CONFIG_SPIRAM_CACHE_LIBFILE_IN_IRAM=n
8+
CONFIG_SPIRAM_CACHE_LIBIO_IN_IRAM=n
9+
CONFIG_SPIRAM_CACHE_LIBJMP_IN_IRAM=n
10+
CONFIG_SPIRAM_CACHE_LIBMATH_IN_IRAM=n
11+
CONFIG_SPIRAM_CACHE_LIBMEM_IN_IRAM=n
12+
CONFIG_SPIRAM_CACHE_LIBMISC_IN_IRAM=n
13+
CONFIG_SPIRAM_CACHE_LIBNUMPARSER_IN_IRAM=n
14+
CONFIG_SPIRAM_CACHE_LIBRAND_IN_IRAM=n
15+
CONFIG_SPIRAM_CACHE_LIBSTR_IN_IRAM=n
16+
CONFIG_SPIRAM_CACHE_LIBTIME_IN_IRAM=n

m5stack/boards/sdkconfig.spiram

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# MicroPython on ESP32, ESP IDF configuration with SPIRAM support
2+
3+
CONFIG_ESP32_SPIRAM_SUPPORT=y
4+
CONFIG_SPIRAM_CACHE_WORKAROUND=y
5+
CONFIG_SPIRAM_IGNORE_NOTFOUND=y
6+
CONFIG_SPIRAM_USE_MEMMAP=y

m5stack/boards/sdkconfig.spiram_sx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# MicroPython on ESP32-S2 and ESP32-PAD1_subscript_3, ESP IDF configuration with SPIRAM support
2+
CONFIG_ESP32S2_SPIRAM_SUPPORT=y
3+
CONFIG_SPIRAM_TYPE_AUTO=y
4+
CONFIG_DEFAULT_PSRAM_CLK_IO=30
5+
CONFIG_DEFAULT_PSRAM_CS_IO=26
6+
CONFIG_SPIRAM_SPEED_80M=y
7+
CONFIG_SPIRAM=y
8+
CONFIG_SPIRAM_BOOT_INIT=y
9+
CONFIG_SPIRAM_IGNORE_NOTFOUND=y
10+
CONFIG_SPIRAM_USE_MEMMAP=y
11+
CONFIG_SPIRAM_MEMTEST=y

m5stack/boards/sdkconfig.usb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CONFIG_USB_ENABLED=y
2+
CONFIG_USB_CDC_ENABLED=y
3+
CONFIG_USB_CDC_RX_BUFSIZE=256
4+
CONFIG_USB_CDC_TX_BUFSIZE=256

m5stack/cmodules/cmodules.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# add m5unified module
2+
include(${CMAKE_CURRENT_LIST_DIR}/m5unified/m5unified.cmake)

m5stack/libs/libffi/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
libffi - Copyright (c) 1996-2014 Anthony Green, Red Hat, Inc and others.
2+
See source files for details.
3+
4+
Permission is hereby granted, free of charge, to any person obtaining
5+
a copy of this software and associated documentation files (the
6+
``Software''), to deal in the Software without restriction, including
7+
without limitation the rights to use, copy, modify, merge, publish,
8+
distribute, sublicense, and/or sell copies of the Software, and to
9+
permit persons to whom the Software is furnished to do so, subject to
10+
the following conditions:
11+
12+
The above copyright notice and this permission notice shall be
13+
included in all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND,
16+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)