Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building firmware requires extra knowledge #8

Open
kf106 opened this issue Oct 11, 2023 · 6 comments
Open

Building firmware requires extra knowledge #8

kf106 opened this issue Oct 11, 2023 · 6 comments

Comments

@kf106
Copy link

kf106 commented Oct 11, 2023

  1. I couldn't get it to work with esp-idf v4.4, I needed to use esp-idf v4.4.4. I combined the esp-idf clone instructions as follows:
git clone https://github.com/espressif/esp-idf.git
git checkout v4.4.4
git submodule update --init --recursive
  1. the micropython repo that is current didn't work. I had to use v1.20.0 as follows:
git clone https://github.com/micropython/micropython.git
git checkout v1.20.0
git submodule update --init
  1. The relative path for the make command didn't work for the USER_C_MODULES; I had to use an absolute ~/<path to st7789_mpy> argument

  2. I needed to supply a board argument: BOARD=GENERIC_S3_SPIRAM_OCT

  3. the sdkconfig.board file in micropython/ports/esp32/boards/GENERIC_S3_SPIRAM_OCT/ needed editing to select 16MB:

CONFIG_FLASHMODE_QIO=y
CONFIG_ESPTOOLPY_FLASHFREQ_80M=y
CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y
CONFIG_ESPTOOLPY_AFTER_NORESET=y

CONFIG_SPIRAM_MEMTEST=

CONFIG_ESPTOOLPY_FLASHSIZE_4MB=
CONFIG_ESPTOOLPY_FLASHSIZE_8MB=
CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-8MiB.csv"

After that, I got a firmware.bin in the build-GENERIC_S3_SPIRAM_OCT folder that, after flashing, gave me a micropython REPL after connecting with putty.

I hope this helps other people having the same problem. I was building on a clean install of Ubuntu 22.04.

@robsannaa
Copy link

Didn't you get an error like this?
*** Support for FROZEN_MPY_DIR was removed. Please use manifest.py instead, see https://docs.micropython.org/en/latest/reference/manifest.html. Stop.

@russhughes
Copy link
Owner

That is another new change in the build system.

@ubidefeo
Copy link

ubidefeo commented Jan 3, 2024

@kf106

I have successfully compiled with the latest IDF (checkout 5.0.4) and MicroPython (master branch).
I also configured default I2C(0) pins in mpconfigboard.cmake
Here are the steps I followed, forgive the lengthy description, it's from my Obsidian notes

LilyGo T-Display S3 with 320x170 OLED parallel

  • copy ports/esp32/boards/ESP32_GENERIC_S3 to `ports/esp32/boards/LILYGO_T-Display_S3

  • add modules to get them frozen in the build (optional)

    • tdisplay.py
  • add manifest.py to instruct using a boards manifest and integrate other directives (optional)

  • edit the following files to add information on the board

    • board.json (info used in sys to provide implementation details)
    • board.md (just textual information for the download page)
    • manifest.py ONLY IF YOU ADDED FROZEN MODULES (build directives for the board)
       include("$(PORT_DIR)/boards/manifest.py")
       freeze("modules")
      
    • mpconfigboard.cmake ONLY IF YOU ADDED FROZEN MODULES (cmake directives )
      • add set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)
    • mpconfigboard.h (build config directives such as I2C pins or other custom info)
       #ifndef MICROPY_HW_BOARD_NAME
       // Can be set by mpconfigboard.cmake.
       #define MICROPY_HW_BOARD_NAME               "LilyGo T-Display S3"
       #endif
       #define MICROPY_HW_MCU_NAME                 "ESP32S3"
       // Enable UART REPL for modules that have an external USB-UART and don't use native USB.
       #define MICROPY_HW_ENABLE_UART_REPL         (1)
       #define MICROPY_HW_I2C0_SCL                 (44)
       #define MICROPY_HW_I2C0_SDA                 (43)
       
      
  • sdkconfig.board contains configuration for flash, speed, partitions etc
    CONFIG_ESPTOOLPY_FLASHMODE_QIO=y CONFIG_ESPTOOLPY_FLASHFREQ_80M=y CONFIG_ESPTOOLPY_AFTER_NORESET=y CONFIG_ESPTOOLPY_FLASHSIZE_4MB= CONFIG_ESPTOOLPY_FLASHSIZE_8MB= CONFIG_ESPTOOLPY_FLASHSIZE_16MB=y CONFIG_PARTITION_TABLE_CUSTOM=y CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions-16MiB.csv"

  • git clone git@github.com:russhughes/st7789s3_mpy.git somewhere (make sure it's patched for MP 1.22+ and IDF 5.x)

  • my patched version is here https://github.com/ubidefeo/st7789s3_mpy/tree/main

  • cd into the ports/esp32 and run

    • make BOARD=LILYGO_T-Display_S3 USER_C_MODULES={PATH_TO_ST7789s3_mpy_CLONED_REPO}/st7789s3_mpy/st7789/micropython.cmake
  • flash the obtained build-LILYGO_T-Display_S3/firmware.bin to the board

    • put the board into boot mode:
      • Hold BOOT (B0)
      • press RESET
      • release RESET
    • erase and flash the binary
      • esptool.py --chip=auto -p {SERIAL_PORT} erase_flash
      • esptool.py --chip=auto -p {SERIAL_PORT} write_flash -z 0 build-LILYGO_T-Display_S3/firmware.bin
    • RESET the board

if you're interested, here's the module I modified and froze

tdisplay.py

""" LilyGo T-DISPLAY-S3 170x320 ST7789 display """

from machine import Pin, SPI, freq
import st7789

freq(240000000)  # 240mhz clock

TFA = 0
BFA = 0

def Display(rotation=0, buffer_size=0, options=0):
    LCD_POWER = Pin(15, Pin.OUT)
    LCD_POWER.value(1)

    return st7789.ST7789(
        Pin(48, Pin.OUT),
        Pin(47, Pin.OUT),
        Pin(46, Pin.OUT),
        Pin(45, Pin.OUT),
        Pin(42, Pin.OUT),
        Pin(41, Pin.OUT),
        Pin(40, Pin.OUT),
        Pin(39, Pin.OUT),
        Pin(8, Pin.OUT),
        Pin(9, Pin.OUT),
        170,
        320,
        reset=Pin(5, Pin.OUT),
        cs=Pin(6, Pin.OUT),
        dc=Pin(7, Pin.OUT),
        backlight=Pin(38, Pin.OUT),
        rotation=rotation,
        options=options,
        buffer_size= buffer_size)

class Buttons():
    def __init__(self):
        self.name = "t-display-s3"
        self.left = Pin(0, Pin.IN)
        self.right = Pin(14, Pin.IN)

@whatdtech
Copy link

Thank you so much @ubidefeo

@ubidefeo
Copy link

ubidefeo commented Feb 4, 2024

@whatdtech , did you manage? :)

@whatdtech
Copy link

Yes

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

No branches or pull requests

5 participants