ESP32-S3 support

Issue #425 closed
Sam Rossiter created an issue

Comments (26)

  1. John Maloney repo owner

    Not yet.

    If you have an S3 and are comfortable with PlatformIO or the Arduino IDE, you could give it a try. I'm guess it won't take much work to get it running, but I don't have an S3 board myself and am super busy with other things.

  2. John Maloney repo owner

    If you have PlatformIO installed, this command will list boards with ESP-S3's:

    pio boards ESP32S3
    

    Let me know how it goes. Once you've gotten it to build and install, I can point you to a few places you can add cases for the S3 to customize it (e.g. to set the board name, define the size of the object storage heap, set the user LED pin, etc.

    Good luck!

  3. Sam Rossiter reporter

    In VScode platformio.ini starts with an error “[{
    "resource": "/home/sam/Desktop/microblocks/smallvm/platformio.ini",
    "owner": "PlatformIO",
    "severity": 8,
    "message": "Invalid environment name 'm5stick+'. The name can contain alphanumeric, underscore, and hyphen characters (a-z, 0-9, -, _)",
    "startLineNumber": 1,
    "startColumn": 1,
    "endLineNumber": 1,
    "endColumn": 1
    }]

    I’ll just comment it out, but presumably it should be removed/fixed?

  4. Sam Rossiter reporter

    With this as my Plaformio.ini

    ; PlatformIO Project Configuration File
    ;
    ; Please visit documentation for the other options and examples
    ; https://docs.platformio.org/page/projectconf.html
    
    ; To build 'cd' to the the 'smallvm' folder and run a command like:
    ;   pio run -e microbit -t upload
    ; to build and install the MicroBlocks VM a given board (e.g. microbit) or
    ;   pio run
    ; to compile MicroBlocks for all platforms.
    
    [platformio]
    src_dir = vm
    
    [env]
    framework = arduino
    monitor_speed = 115200
    
    
    [env:adafruit_feather_esp32s3]
    platform = espressif32
    board = um_feathers3
    lib_deps =WebSockets
        256dpi/MQTT
    

    It currently fails with

    In file included from vm/sensorPrims.cpp:16:
    vm/sensorPrims.cpp: In function 'int* primMagneticField(int, int**)':
    vm/sensorPrims.cpp:1363:18: error: 'hall_sensor_read' was not declared in this scope
       return int2obj(hall_sensor_read());
                      ^~~~~~~~~~~~~~~~
    vm/mem.h:73:30: note: in definition of macro 'int2obj'
     #define int2obj(n) ((OBJ) (((n) << 1) | 1))
                                  ^
    vm/sensorPrims.cpp:1363:18: note: suggested alternative: 'uart_send_break'
       return int2obj(hall_sensor_read());
                      ^~~~~~~~~~~~~~~~
    vm/mem.h:73:30: note: in definition of macro 'int2obj'
     #define int2obj(n) ((OBJ) (((n) << 1) | 1))
                                  ^
    

    Not sure what to do with that, I’ll Google it sometime.

  5. John Maloney repo owner

    Ahh! The S3 does not have a Hall magnetic sensor. You can replace vm/sensorPrims.cpp line 1363 with:

    return zeroObj;

    to fix the compile error.

  6. John Maloney repo owner

    Thanks for reporting the m5stick+ issue. That was due to a recent change in platformio. I've fixed the platformio.ini file in the dev branch. The fix will be in the next stable release. Meanwhile, you can just delete or comment out that entry.

  7. Sam Rossiter reporter

    Great, that works. Thanks.

    Just noting the next issue so I can return to it later

    /home/sam/.platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld: .pio/build/adafruit_feather_esp32s3/src/ioPrims.cpp.o:(.literal.primAnalogWrite+0x4): undefined reference to `dacWrite'
    /home/sam/.platformio/packages/toolchain-xtensa-esp32s3/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld: .pio/build/adafruit_feather_esp32s3/src/ioPrims.cpp.o: in function `primAnalogWrite':
    /home/sam/Desktop/microblocks/smallvm/vm/ioPrims.cpp:1011: undefined reference to `dacWrite'
    

  8. Sam Rossiter reporter

    Nice with that commented it compiles

    =========== [SUCCESS] Took 15.22 seconds ==========================================

  9. Dariusz Dorożalski

    I've got the same error while Platform.io was still working and blocking the port.

    Chrome Debuger, Console

    gpSupport.js:847 Uncaught (in promise) DOMException: Failed to execute 'open' on 'SerialPort': Failed to open serial port.
    
  10. Sam Rossiter reporter

    Thanks looking at the console I see

    Loaded 159 library files from embedded file system
    emModule.js:18 Welcome to GP!
    emModule.js:18 Connected to webserial
    emModule.js:18 All tasks stopped
    emModule.js:18 Read 0 vars 1 chunks
    emModule.js:18 All tasks stopped
    emModule.js:18 Memory cleared
    emModule.js:18 Downloaded 1 scripts to board (332 msecs)
    emModule.js:18 Downloaded 1 scripts to board (85 msecs)
    emModule.js:18 Connected
    emModule.js:18 Chip type: nil
    emModule.js:18 Error: Unknown chip type

  11. Dariusz Dorożalski
    Connected 
    emModule.js:18 Chip type: nil 
    emModule.js:18 Error: Unknown chip type
    

    It seems to be a part of the "Update firmware..." . The connection routine, on my ESP32-S3-Freenova@Win10, stops at "Memory cleared".

    There is no reason to update the firmware as the ad hoc version, tailored for the ESP32-S3 was just uploaded.

  12. John Maloney repo owner

    As Dariusz points out, the message "Error: Unknown chip type" is part of the MicroBlocks firmware update code but that code shouldn't be running unless you selected "update firmware on board" from the gear menu. Do you think you may have done that?

    The first part of the console log, up to "Downloaded 1 scripts to board (85 msecs)" looks as though the IDE is successfully communicating with the board.

    Incidentally, as you are working, be sure that you close or disconnect MicroBlocks while using PlatformIO to compile and upload new firmware to the ESP32. If you don't, the MicroBlocks IDE can try to communicate with the board at the same time as PlatformIO, which confuses the PlatformIO flashing process.

    Once PlatformIO has finished flashing the new firmware, you can try to connect from the MicroBlocks UI. Note that, after erasing Flash, it can take a minute or more for the ESP32 file system to get initialized, during which time the board is unresponsive. If your ESP32-S3 has a larger amoung of Flash then the file system creation could take longer. Once the file system has been set up one can usually update the firmware without doing a full Flash erase.

    It looks as though you are very close to getting this working!

  13. John Maloney repo owner

    I got some time so I tried compiling for an ESP32-S3. After working around the two issues you found (no Hall sensor, no DAC), it compiled. But I don't have an S3 board to test it on.

    I will add some #ifdefs for the S3 in the dev branch to disable the Hall and DAC features for ESP32-S3 and ESP32-S2 boards.

  14. Sam Rossiter reporter

    I’m returning to this after some time.

    I now get

    ros2@ros2:~/smallvm$ pio run -e esp32s3 -t upload

    Processing esp32s3 (platform: espressif32; board: esp32-s3-devkitc-1; framework: arduino)

    Verbose mode can be enabled via -v, --verbose option
    CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32-s3-devkitc-1.html
    PLATFORM: Espressif 32 (6.5.0) > Espressif ESP32-S3-DevKitC-1-N8 (8 MB QD, No PSRAM)
    HARDWARE: ESP32S3 240MHz, 320KB RAM, 8MB Flash
    DEBUG: Current (esp-builtin) On-board (esp-builtin) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
    PACKAGES:

    • framework-arduinoespressif32 @ 3.20014.231204 (2.0.14)
    • tool-esptoolpy @ 1.40501.0 (4.5.1)
    • tool-mkfatfs @ 2.0.1
    • tool-mklittlefs @ 1.203.210628 (2.3)
    • tool-mkspiffs @ 2.230.0 (2.30)
    • tool-openocd-esp32 @ 2.1100.20220706 (11.0)
    • toolchain-riscv32-esp @ 8.4.0+2021r2-patch5
    • toolchain-xtensa-esp32s3 @ 8.4.0+2021r2-patch5
      Converting vm.ino
      LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
      LDF Modes: Finder ~ chain, Compatibility ~ soft
      Found 33 compatible libraries
      Scanning dependencies...
      Dependency Graph
      |-- ESP32 BLE Arduino @ 2.0.0
      |-- WiFi @ 2.0.0
      |-- SPI @ 2.0.0
      |-- Wire @ 2.0.0
      |-- FS @ 2.0.0
      |-- LittleFS @ 2.0.0
      Building in release mode
      Compiling .pio/build/esp32s3/src/cameraPrims.cpp.o
      Compiling .pio/build/esp32s3/src/dataPrims.c.o
      Compiling .pio/build/esp32s3/src/filePrims.cpp.o
      Compiling .pio/build/esp32s3/src/fileTransfer.cpp.o
      Compiling .pio/build/esp32s3/src/hidPrims.cpp.o
      Compiling .pio/build/esp32s3/src/interp.c.o
      Compiling .pio/build/esp32s3/src/ioPrims.cpp.o
      Compiling .pio/build/esp32s3/src/mem.c.o
      Compiling .pio/build/esp32s3/src/miscPrims.c.o
      Compiling .pio/build/esp32s3/src/netPrims.cpp.o
      Compiling .pio/build/esp32s3/src/oneWirePrims.cpp.o
      vm/netPrims.cpp:26:11: fatal error: WebSocketsServer.h: No such file or directory

    My Platformio.ini

    [env:esp32s3]
    platform = espressif32
    board = esp32-s3-devkitc-1
    ; board_build.f_flash = 80000000L
    ; board_build.flash_mode = qio
    ; board_build.partitions = min_spiffs.csv
    monitor_speed = 115200
    upload_port = /dev/ttyUSB0
    upload_protocol = esptool
    ; upload_protocol = espota
    ; upload_port = 192.168.1.101

  15. John Maloney repo owner

    Try adding these library dependencies to your env:

    lib_deps =
        paulstoffregen/OneWire
        WebSockets
        256dpi/MQTT
        NimBLE-Arduino
    

    FYI, if you pull the latest dev branch, there is now an entry for the S3 in the platformio.ini file.

  16. Sam Rossiter reporter

    Nice, that’s uploaded. Can’t yet connect via microblocks UI, but I’ll keep playing with it

  17. John Maloney repo owner

    It sounds like it compiles okay and uploads to the board without error. Great!

    You may need to power-cycle the board after uploading the firmware. Also, the very first time it runs it can take a minute or more for the LittleFS file system to initialize the file system in its Flash memory partition.

    One thing to check is whether a serial device for the board appears when you plug it in.

    On Linux or MacOS, you can do:

    ls /dev | grep cu

    to list external serial ports. You should see an entry like:

    cu.usbmodem1102

    and that entry will be missing if you run the command when the board is not plugged in.

    On Linux, you'll need to make sure you have access to the serial port. The easiest way to do that is to add yourself to the "dialout" or "tty" group -- the exact group varies depending on your distro. You'll need to log out and then back in to make that change take effect.

    Another option is to run the pilot version of MicroBlocks webapp (https://microblocks.fun/run-pilot/microblocks.html) in a Chrome or Edge browser and us the "connect (BLE)" command to connect to the board over BLE.

  18. Sam Rossiter reporter

    This is working now thanks (building in a virtualbox and it had lost the virtual USB on re-boot)

  19. Log in to comment