diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 00000000..d120798d --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,150 @@ +name: Build LVGL MicroPython on Linux + +on: + push: + branches: + - add-submodules + +jobs: + build: + runs-on: ubuntu-latest # Ubuntu is Debian-based and commonly used in GitHub Actions + + steps: + - name: Checkout repository with submodules + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install lvgl_micropython dependencies + run: | + sudo apt-get update + sudo apt-get install -y \ + build-essential \ + libffi-dev \ + pkg-config \ + cmake \ + ninja-build \ + gnome-desktop-testing \ + libasound2-dev \ + libpulse-dev \ + libaudio-dev \ + libjack-dev \ + libsndio-dev \ + libx11-dev \ + libxext-dev \ + libxrandr-dev \ + libxcursor-dev \ + libxfixes-dev \ + libxi-dev \ + libxss-dev \ + libxkbcommon-dev \ + libdrm-dev \ + libgbm-dev \ + libgl1-mesa-dev \ + libgles2-mesa-dev \ + libegl1-mesa-dev \ + libdbus-1-dev \ + libibus-1.0-dev \ + libudev-dev \ + fcitx-libs-dev \ + libpipewire-0.3-dev \ + libwayland-dev \ + libdecor-0-dev + + - name: Install additional MicroPythonOS dependencies + run: | + sudo apt-get update + sudo apt-get install -y libv4l-dev + + - name: Build LVGL MicroPython for unix dev + run: | + ./scripts/build_mpos.sh unix dev + + - name: Upload built binary as artifact + uses: actions/upload-artifact@v4 + with: + name: lvgl_micropy_unix + path: lvgl_micropython/build/lvgl_micropy_unix + compression-level: 0 # dont zip it + retention-days: 7 + + - name: Build LVGL MicroPython esp32 prod fri3d-2024 + run: | + ./scripts/build_mpos.sh esp32 prod fri3d-2024 + + - name: Upload built binary as artifact + uses: actions/upload-artifact@v4 + with: + name: MicroPythonOS_fri3d-2024_prod + path: lvgl_micropython/build/lvgl_micropy_ESP32_GENERIC_S3-SPIRAM_OCT-16.bin + compression-level: 0 # dont zip it + retention-days: 7 + + - name: Upload built binary as artifact + uses: actions/upload-artifact@v4 + with: + name: MicroPythonOS_fri3d-2024_prod.ota + path: lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/micropython.bin + compression-level: 0 # dont zip it + retention-days: 7 + + - name: Cleanup + run: | + rm lvgl_micropython/build/lvgl_micropy_ESP32_GENERIC_S3-SPIRAM_OCT-16.bin + rm lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/micropython.bin + + - name: Build LVGL MicroPython esp32 dev fri3d-2024 + run: | + ./scripts/build_mpos.sh esp32 dev fri3d-2024 + + - name: Upload built binary as artifact + uses: actions/upload-artifact@v4 + with: + name: MicroPythonOS_fri3d-2024_dev + path: lvgl_micropython/build/lvgl_micropy_ESP32_GENERIC_S3-SPIRAM_OCT-16.bin + compression-level: 0 # dont zip it + retention-days: 7 + + - name: Cleanup + run: | + rm lvgl_micropython/build/lvgl_micropy_ESP32_GENERIC_S3-SPIRAM_OCT-16.bin + rm lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/micropython.bin + + - name: Build LVGL MicroPython esp32 prod waveshare-esp32-s3-touch-lcd-2 + run: | + ./scripts/build_mpos.sh esp32 prod waveshare-esp32-s3-touch-lcd-2 + + - name: Upload built binary as artifact + uses: actions/upload-artifact@v4 + with: + name: MicroPythonOS_waveshare-esp32-s3-touch-lcd-2_prod + path: lvgl_micropython/build/lvgl_micropy_ESP32_GENERIC_S3-SPIRAM_OCT-16.bin + compression-level: 0 # dont zip it + retention-days: 7 + + - name: Upload built binary as artifact + uses: actions/upload-artifact@v4 + with: + name: MicroPythonOS_waveshare-esp32-s3-touch-lcd-2_prod.ota + path: lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/micropython.bin + compression-level: 0 # dont zip it + retention-days: 7 + + - name: Cleanup + run: | + rm lvgl_micropython/build/lvgl_micropy_ESP32_GENERIC_S3-SPIRAM_OCT-16.bin + rm lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/micropython.bin + + - name: Build LVGL MicroPython esp32 dev waveshare-esp32-s3-touch-lcd-2 + run: | + ./scripts/build_mpos.sh esp32 dev waveshare-esp32-s3-touch-lcd-2 + + - name: Upload built binary as artifact + uses: actions/upload-artifact@v4 + with: + name: MicroPythonOS_waveshare-esp32-s3-touch-lcd-2_dev + path: lvgl_micropython/build/lvgl_micropy_ESP32_GENERIC_S3-SPIRAM_OCT-16.bin + compression-level: 0 # dont zip it + retention-days: 7 + + diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 00000000..2484b3f7 --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,117 @@ +name: Build LVGL MicroPython for MacOS + +on: + push: + branches: + - add-submodules + pull_request: + branches: [add-submodules] + workflow_dispatch: + +jobs: + build: + runs-on: macos-14 + + steps: + - name: Checkout repository with submodules + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install dependencies via Homebrew + run: | + xcode-select --install || true # already installed on github + brew install pkg-config libffi ninja make SDL2 + + - name: Build LVGL MicroPython for unix dev + run: | + ./scripts/build_mpos.sh macOS dev + + - name: Upload built binary as artifact + uses: actions/upload-artifact@v4 + with: + name: lvgl_micropy_macOS + path: lvgl_micropython/build/lvgl_micropy_macOS + compression-level: 0 # don't zip it + retention-days: 7 + + + - name: Build LVGL MicroPython esp32 prod fri3d-2024 + run: | + ./scripts/build_mpos.sh esp32 prod fri3d-2024 + + - name: Upload built binary as artifact + uses: actions/upload-artifact@v4 + with: + name: MicroPythonOS_fri3d-2024_prod + path: lvgl_micropython/build/lvgl_micropy_ESP32_GENERIC_S3-SPIRAM_OCT-16.bin + compression-level: 0 # don't zip it + retention-days: 7 + + - name: Upload built binary as artifact + uses: actions/upload-artifact@v4 + with: + name: MicroPythonOS_fri3d-2024_prod.ota + path: lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/micropython.bin + compression-level: 0 # don't zip it + retention-days: 7 + + - name: Cleanup + run: | + rm lvgl_micropython/build/lvgl_micropy_ESP32_GENERIC_S3-SPIRAM_OCT-16.bin + rm lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/micropython.bin + + - name: Build LVGL MicroPython esp32 dev fri3d-2024 + run: | + ./scripts/build_mpos.sh esp32 dev fri3d-2024 + + - name: Upload built binary as artifact + uses: actions/upload-artifact@v4 + with: + name: MicroPythonOS_fri3d-2024_dev + path: lvgl_micropython/build/lvgl_micropy_ESP32_GENERIC_S3-SPIRAM_OCT-16.bin + compression-level: 0 # don't zip it + retention-days: 7 + + - name: Cleanup + run: | + rm lvgl_micropython/build/lvgl_micropy_ESP32_GENERIC_S3-SPIRAM_OCT-16.bin + rm lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/micropython.bin + + + - name: Build LVGL MicroPython esp32 prod waveshare-esp32-s3-touch-lcd-2 + run: | + ./scripts/build_mpos.sh esp32 prod waveshare-esp32-s3-touch-lcd-2 + + - name: Upload built binary as artifact + uses: actions/upload-artifact@v4 + with: + name: MicroPythonOS_waveshare-esp32-s3-touch-lcd-2_prod + path: lvgl_micropython/build/lvgl_micropy_ESP32_GENERIC_S3-SPIRAM_OCT-16.bin + compression-level: 0 # don't zip it + retention-days: 7 + + - name: Upload built binary as artifact + uses: actions/upload-artifact@v4 + with: + name: MicroPythonOS_waveshare-esp32-s3-touch-lcd-2_prod.ota + path: lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/micropython.bin + compression-level: 0 # don't zip it + retention-days: 7 + + - name: Cleanup + run: | + rm lvgl_micropython/build/lvgl_micropy_ESP32_GENERIC_S3-SPIRAM_OCT-16.bin + rm lvgl_micropython/lib/micropython/ports/esp32/build-ESP32_GENERIC_S3-SPIRAM_OCT/micropython.bin + + - name: Build LVGL MicroPython esp32 dev waveshare-esp32-s3-touch-lcd-2 + run: | + ./scripts/build_mpos.sh esp32 dev waveshare-esp32-s3-touch-lcd-2 + + - name: Upload built binary as artifact + uses: actions/upload-artifact@v4 + with: + name: MicroPythonOS_waveshare-esp32-s3-touch-lcd-2_dev + path: lvgl_micropython/build/lvgl_micropy_ESP32_GENERIC_S3-SPIRAM_OCT-16.bin + compression-level: 0 # don't zip it + retention-days: 7 diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..4156f9ff --- /dev/null +++ b/.gitmodules @@ -0,0 +1,13 @@ +[submodule "freezeFS"] + path = freezeFS + url = https://github.com/MicroPythonOS/freezeFS +[submodule "secp256k1-embedded-ecdh"] + path = secp256k1-embedded-ecdh + url = https://github.com/MicroPythonOS/secp256k1-embedded-ecdh + branch = micropython_1.25.0 +[submodule "lvgl_micropython"] + path = lvgl_micropython + url = https://github.com/MicroPythonOS/lvgl_micropython +[submodule "micropython-camera-API"] + path = micropython-camera-API + url = https://github.com/cnadler86/micropython-camera-API diff --git a/CHANGELOG.md b/CHANGELOG.md index b5d7a6d1..5b024323 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +0.3.0 +===== +- Overhaul build system: much simplier (single clone and script run), add MacOS support, build with GitHub Workflow, etc. +- Remove "long press pin 0" for bootloader mode; either use the Settings app or keep it pressed while pressing and releasing the "RESET" button + 0.2.1 ===== - Settings app: fix stray /cat in Europe/Brussels timezone diff --git a/README.md b/README.md index b9e5dc3d..b898f4b3 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ Main repository for MicroPythonOS. -See https://MicroPythonOS.com/ and https://docs.MicroPythonOS.com/ +See https://MicroPythonOS.com/ and https://docs.MicroPythonOS.com/ for more info. diff --git a/c_mpos/micropython.cmake b/c_mpos/micropython.cmake index 1b3a181a..e2c80627 100644 --- a/c_mpos/micropython.cmake +++ b/c_mpos/micropython.cmake @@ -7,7 +7,6 @@ add_library(usermod_c_mpos INTERFACE) set(MPOS_C_INCLUDES) set(MPOS_C_SOURCES - ${CMAKE_CURRENT_LIST_DIR}/src/hello_world.c ${CMAKE_CURRENT_LIST_DIR}/src/quirc_decode.c ${CMAKE_CURRENT_LIST_DIR}/quirc/lib/identify.c ${CMAKE_CURRENT_LIST_DIR}/quirc/lib/version_db.c diff --git a/c_mpos/micropython.mk b/c_mpos/micropython.mk index 656c623f..66dfa1f0 100644 --- a/c_mpos/micropython.mk +++ b/c_mpos/micropython.mk @@ -4,9 +4,15 @@ ifneq (,$(findstring -Wno-missing-field-initializers, $(CFLAGS_USERMOD))) CFLAGS_USERMOD += -Wno-missing-field-initializers endif -SRC_USERMOD_C += $(MOD_DIR)/src/hello_world.c +# Check which system this build is being performed on +UNAME_S := $(shell uname -s) +ifneq ($(UNAME_S),Darwin) + # Non-macOS settings (e.g., Linux) + LDFLAGS += -lv4l2 + SRC_USERMOD_C += $(MOD_DIR)/src/webcam.c +endif + SRC_USERMOD_C += $(MOD_DIR)/src/quirc_decode.c -SRC_USERMOD_C += $(MOD_DIR)/src/webcam.c SRC_USERMOD_C += $(MOD_DIR)/quirc/lib/identify.c SRC_USERMOD_C += $(MOD_DIR)/quirc/lib/version_db.c @@ -15,4 +21,3 @@ SRC_USERMOD_C += $(MOD_DIR)/quirc/lib/quirc.c CFLAGS+= -I/usr/include -LDFLAGS+= -lv4l2 diff --git a/c_mpos/src/hello_world.c b/c_mpos/src/hello_world.c deleted file mode 100644 index 58b9ab94..00000000 --- a/c_mpos/src/hello_world.c +++ /dev/null @@ -1,32 +0,0 @@ -#include "py/obj.h" -#include "py/runtime.h" - - -//#error "building hello world from lcd_utils" - -// C function to print "Hello World" -static mp_obj_t hello_world(void) { - printf("Hello World from C compiled!\n"); - return mp_const_none; // MicroPython functions typically return None -} - -// Define the function entry in the module -static MP_DEFINE_CONST_FUN_OBJ_0(hello_world_obj, hello_world); - -// Module function table -static const mp_rom_map_elem_t hello_world_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_hello_world) }, - { MP_ROM_QSTR(MP_QSTR_hello), MP_ROM_PTR(&hello_world_obj) }, -}; - -// Module globals dictionary -static MP_DEFINE_CONST_DICT(hello_world_module_globals, hello_world_module_globals_table); - -// Module definition -const mp_obj_module_t hello_world_module = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t *)&hello_world_module_globals, -}; - -// Register the module with MicroPython -MP_REGISTER_MODULE(MP_QSTR_hello_world, hello_world_module); diff --git a/freezeFS b/freezeFS new file mode 160000 index 00000000..92f12eb1 --- /dev/null +++ b/freezeFS @@ -0,0 +1 @@ +Subproject commit 92f12eb1aec68cc9730ef479e655804ce7dbb9ac diff --git a/internal_filesystem/apps/com.quasikili.quasicalculator b/internal_filesystem/apps/com.quasikili.quasicalculator index 22e9cc13..f41f6e2f 120000 --- a/internal_filesystem/apps/com.quasikili.quasicalculator +++ b/internal_filesystem/apps/com.quasikili.quasicalculator @@ -1 +1 @@ -../../../MPOS-Kilculator/ \ No newline at end of file +../../../MPOS-QuasiCalculator/ \ No newline at end of file diff --git a/internal_filesystem/apps/com.quasikili.quasinametag b/internal_filesystem/apps/com.quasikili.quasinametag new file mode 120000 index 00000000..ffa883b2 --- /dev/null +++ b/internal_filesystem/apps/com.quasikili.quasinametag @@ -0,0 +1 @@ +../../../MPOS-QuasiNametag/ \ No newline at end of file diff --git a/internal_filesystem/builtin/system/button.py b/internal_filesystem/builtin/system/button.py deleted file mode 100644 index 8e18f674..00000000 --- a/internal_filesystem/builtin/system/button.py +++ /dev/null @@ -1,54 +0,0 @@ -print("button.py running") - -import lvgl as lv - -from machine import Pin, Timer -import time -import _thread - -from mpos.apps import Activity, ActivityNavigator, Intent -from mpos.bootloader import ResetIntoBootloader - -# Configure IO0 as input with pull-up resistor -button = Pin(0, Pin.IN, Pin.PULL_UP) - -# Variables for long press detection -long_press_duration = 3000 -press_start_time = 0 -is_pressed = False - -# Timer for checking long press -timer = Timer(-1) - -def on_long_press(t): # Callback for when long press duration is reached. - print("button.py: long press detected") - global timer - timer.deinit() # Stop the timer - global is_pressed - if is_pressed and button.value() == 0: # Ensure button is still pressed - #_thread.stack_size(mpos.apps.good_stack_size()) - #_thread.start_new_thread(handle_long_press, ()) - #lv.async_call(lambda l: handle_long_press(), None) - intent = Intent(activity_class=ResetIntoBootloader) - ActivityNavigator.startActivity(intent) - else: - is_pressed = False - -def button_handler(pin): - """Interrupt handler for button press and release.""" - global press_start_time, is_pressed, timer - if button.value() == 0: # Button pressed (LOW due to pull-up) - print("Button IO0 pressed") - press_start_time = time.ticks_ms() - is_pressed = True - # Start timer to check for long press after long_press_duration - timer.init(mode=Timer.ONE_SHOT, period=long_press_duration, callback=on_long_press) - else: # Button released (HIGH) - print("Button IO0 released") - timer.deinit() # Cancel timer if button is released early - is_pressed = False - -# Set up interrupt for both falling (press) and rising (release) edges -button.irq(trigger=Pin.IRQ_FALLING | Pin.IRQ_RISING, handler=button_handler) - -print("button.py finished") diff --git a/internal_filesystem/lib/mpos/info.py b/internal_filesystem/lib/mpos/info.py index e8716546..e24724ea 100644 --- a/internal_filesystem/lib/mpos/info.py +++ b/internal_filesystem/lib/mpos/info.py @@ -1,4 +1,4 @@ -CURRENT_OS_VERSION = "0.2.1" +CURRENT_OS_VERSION = "0.3.0" # Unique string that defines the hardware, used by OSUpdate and the About app _hardware_id = "missing-hardware-info" diff --git a/internal_filesystem/main.py b/internal_filesystem/main.py index 0fd399cd..b15fb607 100644 --- a/internal_filesystem/main.py +++ b/internal_filesystem/main.py @@ -49,8 +49,6 @@ except Exception as e: # This will throw an exception if there is already a "/builtin" folder present print("main.py: WARNING: could not import/run freezefs_mount_builtin: ", e) -mpos.apps.execute_script("builtin/system/button.py", True) # Install button handler through IRQ - try: import mpos.wifi _thread.stack_size(mpos.apps.good_stack_size()) diff --git a/lvgl_micropython b/lvgl_micropython new file mode 160000 index 00000000..24a1c2de --- /dev/null +++ b/lvgl_micropython @@ -0,0 +1 @@ +Subproject commit 24a1c2de2e51387ce92b80dc2e890ef8368fda80 diff --git a/manifest.py b/manifest.py deleted file mode 100644 index 3c548e4b..00000000 --- a/manifest.py +++ /dev/null @@ -1,4 +0,0 @@ -freeze('internal_filesystem/', 'boot.py') # Hardware initialization -freeze('internal_filesystem/', 'main.py') # User Interface initialization -freeze('internal_filesystem/lib', '') # Additional libraries -freeze('../freezeFS/', 'freezefs_mount_builtin.py') # Built-in apps diff --git a/manifest_unix.py b/manifest_unix.py deleted file mode 100644 index c2a9945e..00000000 --- a/manifest_unix.py +++ /dev/null @@ -1,4 +0,0 @@ -freeze('internal_filesystem/', 'boot_unix.py') # Hardware initialization -freeze('internal_filesystem/', 'main.py') # User Interface initialization -freeze('internal_filesystem/lib', '') # Additional libraries -freeze('../freezeFS/', 'freezefs_mount_builtin.py') # Built-in apps diff --git a/manifests/manifest.py b/manifests/manifest.py new file mode 100644 index 00000000..39f577ee --- /dev/null +++ b/manifests/manifest.py @@ -0,0 +1,4 @@ +freeze('../internal_filesystem/', 'boot.py') # Hardware initialization +freeze('../internal_filesystem/', 'main.py') # User Interface initialization +freeze('../internal_filesystem/lib', '') # Additional libraries +freeze('../freezeFS/', 'freezefs_mount_builtin.py') # Built-in apps diff --git a/manifest_fri3d-2024.py b/manifests/manifest_fri3d-2024.py similarity index 60% rename from manifest_fri3d-2024.py rename to manifests/manifest_fri3d-2024.py index b8c72e45..6b5c3aa1 100644 --- a/manifest_fri3d-2024.py +++ b/manifests/manifest_fri3d-2024.py @@ -1,4 +1,4 @@ freeze('/tmp/', 'boot.py') # Hardware initialization - this file is copied from boot_fri3d-2024.py to /tmp by the build script to have it named boot.py -freeze('internal_filesystem/', 'main.py') # User Interface initialization -freeze('internal_filesystem/lib', '') # Additional libraries +freeze('../internal_filesystem/', 'main.py') # User Interface initialization +freeze('../internal_filesystem/lib', '') # Additional libraries freeze('../freezeFS/', 'freezefs_mount_builtin.py') # Built-in apps diff --git a/manifests/manifest_unix.py b/manifests/manifest_unix.py new file mode 100644 index 00000000..5012e02a --- /dev/null +++ b/manifests/manifest_unix.py @@ -0,0 +1,4 @@ +freeze('../internal_filesystem/', 'boot_unix.py') # Hardware initialization +freeze('../internal_filesystem/', 'main.py') # User Interface initialization +freeze('../internal_filesystem/lib', '') # Additional libraries +freeze('../freezeFS/', 'freezefs_mount_builtin.py') # Built-in apps diff --git a/micropython-camera-API b/micropython-camera-API new file mode 160000 index 00000000..2dd97117 --- /dev/null +++ b/micropython-camera-API @@ -0,0 +1 @@ +Subproject commit 2dd97117359d00729d50448df19404d18f67ac30 diff --git a/scripts/build_lvgl_micropython.sh b/scripts/build_lvgl_micropython.sh deleted file mode 100755 index c98584db..00000000 --- a/scripts/build_lvgl_micropython.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/bash - -mydir=$(readlink -f "$0") -mydir=$(dirname "$mydir") -twoup=$(readlink -f "$mydir"/../..) # build process needs absolute paths -oneup=$(readlink -f "$mydir"/..) # build process needs absolute paths - -target="$1" -buildtype="$2" -subtarget="$3" - -if [ -z "$target" -o -z "$buildtype" ]; then - echo "Usage: $0 target buildtype [optional subtarget]" - echo "Usage: $0 []" - echo "Example: $0 unix dev" - echo "Example: $0 esp32 dev fri3d-2024" - echo "Example: $0 esp32 prod fri3d-2024" - echo "Example: $0 esp32 dev waveshare-esp32-s3-touch-lcd-2" - echo "Example: $0 esp32 prod waveshare-esp32-s3-touch-lcd-2" - echo - echo "A 'dev' build is without any preinstalled files or builtin/ filsystem, so it will just start with a black screen and you'll have to do: ./scripts/install.sh to install the User Interface." - echo "A 'prod' build has the files from manifest*.py frozen in. Don't forget to run: ./scripts/freezefs_mount_builtin.sh !" - exit 1 -fi - -if [ "$buildtype" == "prod" ]; then - ./scripts/freezefs_mount_builtin.sh -fi - - - -manifest="" -if [ "$target" == "esp32" ]; then - if [ "$buildtype" == "prod" ]; then - if [ "$subtarget" == "fri3d-2024" ]; then - cp internal_filesystem/boot_fri3d-2024.py /tmp/boot.py # dirty hack to have it included as boot.py by the manifest - manifest="manifest_fri3d-2024.py" - else - manifest="manifest.py" - fi - else - echo "Note that you can also prevent the builtin filesystem from being mounted by umounting it and creating a builtin/ folder." - fi - # Build for https://www.waveshare.com/wiki/ESP32-S3-Touch-LCD-2. - # See https://github.com/lvgl-micropython/lvgl_micropython - # --ota: support Over-The-Air updates - # --partition size: both OTA partitions are 4MB - # --flash-size: total flash size is 16MB - # --debug: enable debugging from ESP-IDF but makes copying files to it very slow - # --dual-core-threads: disabled GIL, run code on both CPUs - # --task-stack-size={stack size in bytes} - # CONFIG_* sets ESP-IDF options - # listing processes on the esp32 still doesn't work because no esp32.vtask_list_threads() or something - # CONFIG_FREERTOS_USE_TRACE_FACILITY=y - # CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID=y - # CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y - [ ! -z "$manifest" ] && frozenmanifest="FROZEN_MANIFEST="$(readlink -f "$manifest") - pushd "$twoup"/lvgl_micropython - python3 make.py --ota --partition-size=4194304 --flash-size=16 esp32 BOARD=ESP32_GENERIC_S3 BOARD_VARIANT=SPIRAM_OCT DISPLAY=st7789 INDEV=cst816s USER_C_MODULE="$twoup"/micropython-camera-API/src/micropython.cmake USER_C_MODULE="$twoup"/secp256k1-embedded-ecdh/micropython.cmake USER_C_MODULE="$oneup"/c_mpos/micropython.cmake CONFIG_FREERTOS_USE_TRACE_FACILITY=y CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID=y CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y "$frozenmanifest" - popd -elif [ "$target" == "unix" -o "$target" == "macOS" ]; then - if [ "$buildtype" == "prod" ]; then - manifest="manifest_unix.py" - fi - # build for desktop - #python3 make.py "$target" DISPLAY=sdl_display INDEV=sdl_pointer INDEV=sdl_keyboard "$manifest" - # LV_CFLAGS are passed to USER_C_MODULES - # STRIP= makes it so that debug symbols are kept - [ ! -z "$manifest" ] && frozenmanifest="FROZEN_MANIFEST="$(readlink -f "$manifest") - pushd "$twoup"/lvgl_micropython - # USER_C_MODULE doesn't seem to work properly so there are symlinks in lvgl_micropython/extmod/ - python3 make.py "$target" LV_CFLAGS="-g -O0 -ggdb -ljpeg" STRIP= DISPLAY=sdl_display INDEV=sdl_pointer INDEV=sdl_keyboard "$manifest" - popd -else - echo "invalid target $target" -fi - diff --git a/scripts/build_mpos.sh b/scripts/build_mpos.sh new file mode 100755 index 00000000..953a264b --- /dev/null +++ b/scripts/build_mpos.sh @@ -0,0 +1,132 @@ +#!/bin/bash + +mydir=$(readlink -f "$0") +mydir=$(dirname "$mydir") +codebasedir=$(readlink -f "$mydir"/..) # build process needs absolute paths + +target="$1" +buildtype="$2" +subtarget="$3" + +if [ -z "$target" -o -z "$buildtype" ]; then + echo "Usage: $0 target buildtype [optional subtarget]" + echo "Usage: $0 []" + echo "Example: $0 unix dev" + echo "Example: $0 esp32 dev fri3d-2024" + echo "Example: $0 esp32 prod fri3d-2024" + echo "Example: $0 esp32 dev waveshare-esp32-s3-touch-lcd-2" + echo "Example: $0 esp32 prod waveshare-esp32-s3-touch-lcd-2" + echo + echo "A 'dev' build is without any preinstalled files or builtin/ filsystem, so it will just start with a black screen and you'll have to do: ./scripts/install.sh to install the User Interface." + echo "A 'prod' build has the files from manifest*.py frozen in. Don't forget to run: ./scripts/freezefs_mount_builtin.sh !" + exit 1 +fi + + +# This assumes all the git submodules have been checked out recursively + +echo "Fetch tags for lib/SDL, otherwise lvgl_micropython's make.py script can't checkout a specific tag..." +pushd "$codebasedir"/lvgl_micropython/lib/SDL +git fetch --unshallow origin 2>/dev/null # will give error if already done +# Or fetch all refs without unshallowing (keeps it shallow but adds refs) +git fetch origin 'refs/tags/*:refs/tags/*' +popd + +echo "Check need to add esp32-camera..." +idfile="$codebasedir"/lvgl_micropython/lib/micropython/ports/esp32/main/idf_component.yml +if ! grep esp32-camera "$idfile"; then + echo "Adding esp32-camera to $idfile" + echo " espressif/esp32-camera: + git: https://github.com/MicroPythonOS/esp32-camera" >> "$idfile" + echo "Resulting file:" + cat "$idfile" +else + echo "No need to add esp32-camera to $idfile" +fi + +echo "Check need to add lvgl_micropython manifest to micropython-camera-API's manifest..." +camani="$codebasedir"/micropython-camera-API/src/manifest.py +rellvglmani=lvgl_micropython/build/manifest.py +abslvglmani="$codebasedir"/"$rellvglmani" +if ! grep "$rellvglmani" "$camani"; then + echo "Adding include(\"$abslvglmani\") to $camani" + echo >> "$camani" # needs newline because file doesn't have newline at the end + echo "include(\"$abslvglmani\") # workaround to prevent micropython-camera-API from overriding the lvgl_micropython manifest..." >> "$camani" + echo "Resulting file:" + cat "$camani" +else + echo "No need to add include(\"$abslvglmani\") to $camani" +fi + +echo "Check need to add asyncio..." +manifile="$codebasedir"/lvgl_micropython/lib/micropython/ports/unix/variants/manifest.py +if ! grep asyncio "$manifile"; then + echo "Adding asyncio to $manifile" + echo 'include("$(MPY_DIR)/extmod/asyncio") # needed to have asyncio, which is used by aiohttp, which has used by websockets' >> "$manifile" + echo "Resulting file:" + cat "$manifile" +else + echo "No need to add asyncio to $manifile" +fi + +# unix and macOS builds need these symlinks because make.py doesn't handle USER_C_MODULE arguments for them: +echo "Symlinking secp256k1-embedded-ecdh for unix and macOS builds..." +ln -sf ../../secp256k1-embedded-ecdh "$codebasedir"/lvgl_micropython/ext_mod/secp256k1-embedded-ecdh +echo "Symlinking c_mpos for unix and macOS builds..." +ln -sf ../../c_mpos "$codebasedir"/lvgl_micropython/ext_mod/c_mpos + +if [ "$buildtype" == "prod" ]; then + freezefs="$codebasedir"/scripts/freezefs_mount_builtin.sh + echo "It's a $buildtype build, running $freezefs" + $freezefs +fi + + + +manifest="" +if [ "$target" == "esp32" ]; then + if [ "$buildtype" == "prod" ]; then + if [ "$subtarget" == "fri3d-2024" ]; then + cp internal_filesystem/boot_fri3d-2024.py /tmp/boot.py # dirty hack to have it included as boot.py by the manifest + manifest="manifest_fri3d-2024.py" + else + manifest="manifest.py" + fi + manifest=$(readlink -f "$codebasedir"/manifests/"$manifest") + frozenmanifest="FROZEN_MANIFEST=$manifest" + else + echo "Note that you can also prevent the builtin filesystem from being mounted by umounting it and creating a builtin/ folder." + fi + # Build for https://www.waveshare.com/wiki/ESP32-S3-Touch-LCD-2. + # See https://github.com/lvgl-micropython/lvgl_micropython + # --ota: support Over-The-Air updates + # --partition size: both OTA partitions are 4MB + # --flash-size: total flash size is 16MB + # --debug: enable debugging from ESP-IDF but makes copying files to it very slow + # --dual-core-threads: disabled GIL, run code on both CPUs + # --task-stack-size={stack size in bytes} + # CONFIG_* sets ESP-IDF options + # listing processes on the esp32 still doesn't work because no esp32.vtask_list_threads() or something + # CONFIG_FREERTOS_USE_TRACE_FACILITY=y + # CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID=y + # CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y + pushd "$codebasedir"/lvgl_micropython/ + python3 make.py --ota --partition-size=4194304 --flash-size=16 esp32 BOARD=ESP32_GENERIC_S3 BOARD_VARIANT=SPIRAM_OCT DISPLAY=st7789 INDEV=cst816s USER_C_MODULE="$codebasedir"/micropython-camera-API/src/micropython.cmake USER_C_MODULE="$codebasedir"/secp256k1-embedded-ecdh/micropython.cmake USER_C_MODULE="$codebasedir"/c_mpos/micropython.cmake CONFIG_FREERTOS_USE_TRACE_FACILITY=y CONFIG_FREERTOS_VTASKLIST_INCLUDE_COREID=y CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y "$frozenmanifest" + popd +elif [ "$target" == "unix" -o "$target" == "macOS" ]; then + if [ "$buildtype" == "prod" ]; then + manifest=$(readlink -f "$codebasedir"/manifests/manifest_unix.py) + frozenmanifest="FROZEN_MANIFEST=$manifest" + fi + # build for desktop + #python3 make.py "$target" DISPLAY=sdl_display INDEV=sdl_pointer INDEV=sdl_keyboard "$manifest" + # LV_CFLAGS are passed to USER_C_MODULES + # STRIP= makes it so that debug symbols are kept + pushd "$codebasedir"/lvgl_micropython/ + # USER_C_MODULE doesn't seem to work properly so there are symlinks in lvgl_micropython/extmod/ + python3 make.py "$target" LV_CFLAGS="-g -O0 -ggdb -ljpeg" STRIP= DISPLAY=sdl_display INDEV=sdl_pointer INDEV=sdl_keyboard "$manifest" + popd +else + echo "invalid target $target" +fi + diff --git a/scripts/freezefs_mount_builtin.sh b/scripts/freezefs_mount_builtin.sh index 10253d77..d4677a1d 100755 --- a/scripts/freezefs_mount_builtin.sh +++ b/scripts/freezefs_mount_builtin.sh @@ -1,5 +1,8 @@ -builtindir=$(readlink -f "internal_filesystem/builtin") +mydir=$(readlink -f "$0") +mydir=$(dirname "$mydir") # scripts dir -pushd ../freezeFS/ +builtindir=$(readlink -f "$mydir"/../internal_filesystem/builtin) + +pushd "$mydir"/../freezeFS/ python3 -m freezefs --target /builtin --on-import mount "$builtindir" freezefs_mount_builtin.py popd diff --git a/scripts/run_desktop.sh b/scripts/run_desktop.sh index ae21d53d..8ddf9998 100755 --- a/scripts/run_desktop.sh +++ b/scripts/run_desktop.sh @@ -1,3 +1,6 @@ +#!/bin/bash -x +scriptdir=$(readlink -f "$0") +scriptdir=$(dirname "$scriptdir") script="$1" if [ -f "$script" ]; then script=$(readlink -f "$script") @@ -40,13 +43,13 @@ export HEAPSIZE=128M # for 1280x720 images in the image viewer # print os and set binary os_name=$(uname -s) -if [ "$os_name" == "Darwin" ]; then +if [ "$os_name" = "Darwin" ]; then echo "Running on macOS" - binary=../lvgl_micropython/build/lvgl_micropy_macOS + binary="$scriptdir"/../lvgl_micropython/build/lvgl_micropy_macOS else # other cases can be added here echo "Running on $os_name" - binary=../lvgl_micropython/build/lvgl_micropy_unix + binary="$scriptdir"/../lvgl_micropython/build/lvgl_micropy_unix fi binary=$(readlink -f "$binary") diff --git a/secp256k1-embedded-ecdh b/secp256k1-embedded-ecdh new file mode 160000 index 00000000..3d5149dd --- /dev/null +++ b/secp256k1-embedded-ecdh @@ -0,0 +1 @@ +Subproject commit 3d5149ddc4814cd4c70d5190a52035e4d45ee52f