Skip to content

Commit

Permalink
Merge pull request #433 from shorepine/ulab
Browse files Browse the repository at this point in the history
ulab included in tulip (only macos desktop for now)
  • Loading branch information
bwhitman authored Jan 2, 2025
2 parents 83328ae + 41c132a commit 4615130
Show file tree
Hide file tree
Showing 301 changed files with 61,678 additions and 1,577 deletions.
3 changes: 3 additions & 0 deletions tulip/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# Tulip folder structure

```
amyboard - Tulip (headless) for the AMYboard
amyrepl - micropython build for AMY-included python with no display or tulip stuff
esp32s3 - all TulipCC hardware specific files for the supported boards
fs - the filesystem that gets flashed as /sys on first run -- examples, images, etc
linux - all Tulip Desktop for Linux specific files
macos - all Tulip Desktop for macOS specific files
shared - code shared between all Tulip ports (hardware & Desktop)
shared/py - Python modules that get loaded into Tulip
shared/desktop - code shared between Tulip Desktop ports (macOS, iOS, Linux)
shared/ulab - our fork of ulab, a numpy/scipy wrapper for micropython
web - all Tulip Desktop for Web specific files
```

Expand Down
77 changes: 77 additions & 0 deletions tulip/amyboard/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Top-level cmake file for building MicroPython on ESP32.

cmake_minimum_required(VERSION 3.12)

execute_process(COMMAND bash -c "../shared/grab_submodules.sh"
WORKING_DIRECTORY ".."
OUTPUT_VARIABLE GIT_SUBMOD_RESULT)

# We have to do some nasty stuff to get the LVGL MP submodule compiled
# We generate a lvgl.pp.c file, which is just the compiler preprocessor running in this env
execute_process(COMMAND bash -c "xtensa-esp32s3-elf-gcc -E -DLVGL_PREPROCESS -I ../../../lv_binding_micropython_tulip/pycparser/utils/fake_libc_include -I../../../lv_binding_micropython_tulip -I. -I../../../lv_binding_micropython_tulip/lvgl/src ../../../lv_binding_micropython_tulip/lvgl/lvgl.h > ../build/lvgl.pp.c"
WORKING_DIRECTORY "."
)

# Then we run a python script which generates a MP module for LVGL based on the source files (and your conf and stuff)
# This gets compiled into Tulip
execute_process(COMMAND bash -c "python3 ../../../lv_binding_micropython_tulip/gen/gen_mpy.py -M lvgl -MP lv -MD ../build/lv_mpy.json -E ../build/lvgl.pp.c ../../../lv_binding_micropython_tulip/lvgl/lvgl.h > ../build/lv_mpy.c"
WORKING_DIRECTORY "."
)

# We also have to copy over mpconfigport.h
execute_process(COMMAND bash -c "cp ../mpconfigport.h ../../../micropython/ports/esp32/mpconfigport.h" WORKING_DIRECTORY ".")

# Turn this on for debugging submodules
#file(WRITE "submod" "${GIT_SUBMOD_RESULT}")


# Set the board if it's not already set.
if(NOT MICROPY_BOARD)
set(MICROPY_BOARD TULIP4_R11)
endif()

# Set the board directory and check that it exists.
if(NOT MICROPY_BOARD_DIR)
set(MICROPY_BOARD_DIR ${CMAKE_CURRENT_LIST_DIR}/boards/${MICROPY_BOARD})
endif()
if(NOT EXISTS ${MICROPY_BOARD_DIR}/mpconfigboard.cmake)
message(FATAL_ERROR "Invalid MICROPY_BOARD specified: ${MICROPY_BOARD}")
endif()

# Define the output sdkconfig so it goes in the build directory.
set(SDKCONFIG ${CMAKE_BINARY_DIR}/sdkconfig)

# Save the manifest file set from the cmake command line.
set(MICROPY_USER_FROZEN_MANIFEST ${MICROPY_FROZEN_MANIFEST})

# Include board config; this is expected to set (among other options):
# - SDKCONFIG_DEFAULTS
# - IDF_TARGET
include(${MICROPY_BOARD_DIR}/mpconfigboard.cmake)

# Set the frozen manifest file. Note if MICROPY_FROZEN_MANIFEST is set from the cmake
# command line, then it will override the default and any manifest set by the board.
if (MICROPY_USER_FROZEN_MANIFEST)
set(MICROPY_FROZEN_MANIFEST ${MICROPY_USER_FROZEN_MANIFEST})
elseif (NOT MICROPY_FROZEN_MANIFEST)
set(MICROPY_FROZEN_MANIFEST ${CMAKE_CURRENT_LIST_DIR}/boards/manifest.py)
endif()

# Concatenate all sdkconfig files into a combined one for the IDF to use.
file(WRITE ${CMAKE_BINARY_DIR}/sdkconfig.combined.in "")
foreach(SDKCONFIG_DEFAULT ${SDKCONFIG_DEFAULTS})
file(READ ${SDKCONFIG_DEFAULT} CONTENTS)
file(APPEND ${CMAKE_BINARY_DIR}/sdkconfig.combined.in "${CONTENTS}")
endforeach()
configure_file(${CMAKE_BINARY_DIR}/sdkconfig.combined.in ${CMAKE_BINARY_DIR}/sdkconfig.combined COPYONLY)
set(SDKCONFIG_DEFAULTS ${CMAKE_BINARY_DIR}/sdkconfig.combined)

# Include main IDF cmake file.
include($ENV{IDF_PATH}/tools/cmake/project.cmake)

# Set the location of the main component for the project (one per target).
#set(EXTRA_COMPONENT_DIRS main components)

# Define the project.
project(micropython)
idf_build_set_property(COMPILE_OPTIONS "-fdiagnostics-color=always" APPEND)
18 changes: 18 additions & 0 deletions tulip/amyboard/boards/AMYBOARD/board.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"deploy": [
"../deploy_s3.md"
],
"docs": "",
"features": [
"BLE",
"WiFi"
],
"images": [
"generic_s3.jpg"
],
"mcu": "esp32s3",
"product": "Tulip CC (R10)",
"thumbnail": "",
"url": "https://www.espressif.com/en/products/modules",
"vendor": "Espressif"
}
23 changes: 23 additions & 0 deletions tulip/amyboard/boards/AMYBOARD/mpconfigboard.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
set(IDF_TARGET esp32s3)

set(MICROPY_PY_TINYUSB ON)


set(BOARD_DEFINITION1 TULIP4_R11)
set(BOARD_DEFINITION2 MAKERFABS)

set(SDKCONFIG_DEFAULTS
../../micropython/ports/esp32/boards/sdkconfig.base
../../micropython/ports/esp32/boards/sdkconfig.usb
../../micropython/ports/esp32/boards/sdkconfig.240mhz
boards/sdkconfig.tulip
boards/N32R8/sdkconfig.board
boards/TULIP4_R11/sdkconfig.board
)

list(APPEND MICROPY_SOURCE_BOARD
gt911_touchscreen.c
esp_lcd_touch_gt911.c
esp32s3_display.c
usb_host.c
)
9 changes: 9 additions & 0 deletions tulip/amyboard/boards/AMYBOARD/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "pins.h"
#define MICROPY_HW_BOARD_NAME "TulipCC"
#define MICROPY_HW_MCU_NAME "ESP32S3"

#define MICROPY_PY_MACHINE_DAC (0)

// Enable UART REPL for modules that have an external USB-UART and don't use native USB.
#define MICROPY_HW_ENABLE_UART_REPL (1)

5 changes: 5 additions & 0 deletions tulip/amyboard/boards/AMYBOARD/pins.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
I2C_SCL,GPIO9
I2C_SDA,GPIO8
FG_INT,GPIO21
UART0_TX,GPIO43
UART0_RX,GPIO44
4 changes: 4 additions & 0 deletions tulip/amyboard/boards/AMYBOARD/sdkconfig.board
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Nothing added to the N32 defaults



29 changes: 29 additions & 0 deletions tulip/amyboard/boards/manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Just not _boot, we have our own
freeze("$(PORT_DIR)/modules", "apa106.py")
freeze("$(PORT_DIR)/modules", "inisetup.py")
freeze("$(PORT_DIR)/modules", "espnow.py")
freeze("$(PORT_DIR)/modules", "flashbdev.py")

include("$(MPY_DIR)/extmod/asyncio")

# Useful networking-related packages.
#require("mip")
require("ntptime")
#require("webrepl")

# Require some micropython-lib modules.
# require("aioespnow")
require("dht")
require("ds18x20")
require("onewire")
require("umqtt.robust")
require("umqtt.simple")

freeze("$(PORT_DIR)/../shared/py")
freeze("$(MPY_DIR)/../amy", "amy.py")
freeze("$(MPY_DIR)/../amy", "juno.py")
freeze("$(MPY_DIR)/../amy", "amy_wave.py")
freeze("$(MPY_DIR)/../amy/experiments", "tulip_piano.py")
freeze("$(MPY_DIR)/../amy/experiments", "piano_params.py")

#freeze("$(MPY_DIR)/lib/micropython-lib/micropython/utarfile", "utarfile.py")
33 changes: 33 additions & 0 deletions tulip/amyboard/boards/sdkconfig.tulip
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
CONFIG_SPIRAM=y
CONFIG_SPIRAM_CACHE_WORKAROUND=y
CONFIG_SPIRAM_IGNORE_NOTFOUND=y
#CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_PERF=y
#CONFIG_COMPILER_OPTIMIZATION_NONE=y
CONFIG_USB_HOST_HUBS_SUPPORTED=y
CONFIG_USB_HOST_HUB_MULTI_LEVEL=y
CONFIG_USB_HOST_EXT_PORT_SUPPORT_LS=y
#CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=n
CONFIG_FREERTOS_HZ=1000

CONFIG_SPIRAM_TYPE_AUTO=y
CONFIG_SPIRAM_CLK_IO=30
CONFIG_SPIRAM_CS_IO=26
CONFIG_SPIRAM_BOOT_INIT=y
CONFIG_SPIRAM_IGNORE_NOTFOUND=y
CONFIG_SPIRAM_USE_CAPS_ALLOC=y
CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y

CONFIG_FREERTOS_USE_TRACE_FACILITY=n
CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y
CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP=y


CONFIG_SPIRAM_FETCH_INSTRUCTIONS=y
CONFIG_SPIRAM_RODATA=y
CONFIG_LCD_RGB_ISR_IRAM_SAFE=n
CONFIG_LCD_RGB_RESTART_IN_VSYNC=y

CONFIG_LWIP_PPP_SUPPORT=n

CONFIG_ESP_TIMER_TASK_STACK_SIZE=8192
2 changes: 2 additions & 0 deletions tulip/amyboard/boot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# boot.py
# Put anything here you want to run on Tulip startup
Loading

0 comments on commit 4615130

Please sign in to comment.