board/FLASHING.md

8.5 KiB

If you manufactured the board yourself, you probably want to install WLED to it.

WLED

You can easily install the latest WLED release, but this will not support DMX or the status LED.

  • prepare a USB to UART adapter and 1x6 100 mil pin header to be inserted on the DEBUG port
  • connect UART GND to DEBUG GND, UART TX to DEBUG RX, UART RX to DEBUG TX
  • plug USB to UART adapter to computer
  • remove USB from the board
  • go to the WLED install page
  • select version (latest release or stable starting with 0.15.0) and audio reactive variant
  • click on install
  • select serial port, but don't click on connect yet
  • press and hold DL button on board
  • plug USB into board
  • you can release the DL button
  • insert and hold pins in DEBUG header with an angle to make temporary contact
  • press "Connect" on page
  • press "INSTALL WLED"
  • wait for 2 minutes to flash WLED, still holding the DEBUG header

WARNING: Do not select WLED version 0.14.. It has a unknown issue with the ESP32-MINI modules used by WLED chain (probably related to the toolchain), which causes the firmware crash and reboot in a loop. WLED v0.15. or older v0.13.3 and Sound Reactive v0.13.4 start fine. The UART interface is still broken though, and prevents from using Improv for WiFi configuration.

If you prefer to use WLED binary releases and esptool on the command line instead of the web interface, here the commands (set the version to the one wished):

export WLED_VERSION="0.15.0"
export WLED_PATH=`echo $WLED_VERSION | sed 's/\./_/g'`
wget https://install.wled.me/bin/release_${WLED_PATH}/esp32_bootloader_v4.bin
wget https://install.wled.me/bin/release_${WLED_PATH}/WLED_${WLED_VERSION}_ESP32_audioreactive.bin
esptool.py --port /dev/ttyUSB0 erase_flash
esptool.py --port /dev/ttyUSB0 write_flash 0x0 ./esp32_bootloader_v4.bin
esptool.py --port /dev/ttyUSB0 write_flash 0x10000 WLED_${WLED_VERSION}_ESP32_audioreactive.bin

If the USB to UART adapter also breaks out the DTR and RTS signals, you can connect them to the DL and RST pin respectively on the debug header. Now esptool will take care of resetting and putting the board into bootloader mode. You don't have to press on the DL button and re-plug the power over USB anymore by hand.

A CH340K USB to UART chip can also be soldered on the back of the board. You then don't need an external USB to UART adapter anymore, as it is now on board. This is very useful when you have to flash or configure often the board.

Once the firmware is install, re-plug the power to start it. If you added the RST button on the back, you can also press this alternatively. If you connected the DEBUG RST signal to RTS on the USB to UART adapter, you can also lower the line to reset it. This signal is also connected to the optional on-board USB to UART chip.

To restart the board and check the debug output:

picocom -b 115200 --lower-rts --lower-dtr /dev/ttyUSB0

MM

binary

MoonModules (MM) is a fork of WLED. It is often used to experiment with features that could then be released in WLED. It includes the DMX IN support our board takes advantage of.

We can compile it, or use binaries. WLED install also to get the binaries or install them using the web page. Select board type / software version under Moon Mod: ESP32 (4MN Flash, S: Audioreactive, no other Usermods included).

Use the same instructions from previous WLED section to install the binary on the board. The only feature not supported by this firmware is the WLED STATUS LED on the top left corner of board.

compiling

To support DMX IN and the STATUS LED, we need to compile WLED MM.

Get the release:

export MM_RELEASE="0.14.1-beta.30"
wget https://github.com/MoonModules/WLED/archive/refs/tags/v$MM_RELEASE.tar.gz
tar xf v$MM_RELEASE.tar.gz
cd WLED-$MM_RELEASE

Or if you want the latest source:

git clone https://github.com/MoonModules/WLED MM_WLED
cd MM_WLED
git checkout mdev

Let's define our devices (e.g. the build environments):

cat > platformio_override.ini << EOF
[platformio]
default_envs = wled_chain

; for WLED chain v5 and v6
[env:wled_chain]
; V4 add DMX IN support
extends = esp32_4MB_V4_S_base
build_flags = ${esp32_4MB_V4_S_base.esp32_build_flags}
  -D WLED_RELEASE_NAME=WLED_chain1
  -D STATUSLED=2
  -D DATA_PINS=25,26,27
lib_deps = ${esp32_4MB_V4_S_base.esp32_lib_deps}
build_unflags = ${esp32_4MB_V4_S_base.build_unflags}
  -D USERMOD_ARTIFX
  -D USERMOD_AUTO_SAVE
  -D USERMOD_DALLASTEMPERATURE
  -D USE_ALT_DISPLAY
  -D USERMOD_FOUR_LINE_DISPLAY
  -D USERMOD_ROTARY_ENCODER_UI
  -D WLED_DISABLE_ESPNOW ; counter build_disable_sync_interfaces
EOF

To compile the firmware:

platformio run

To install the firmware over UART:

# erase to start clean, not always needed but also removes previous configuration
esptool.py --port /dev/ttyUSB0 erase_flash
# .pio/build/wled_chain/bootloader.bin is also compiled, but it does not boot (and is way smaller)
wget https://github.com/Aircoookie/WLED/releases/download/v0.13.1/esp32_bootloader_v4.bin
esptool.py --port /dev/ttyUSB0 write_flash 0 esp32_bootloader_v4.bin
# now flash the compiled WLED
esptool.py --port /dev/ttyUSB0 write_flash 0x10000 .pio/build/wled_chain/firmware.bin

Once flashed, the WLED status LED on the top left of the corner should blink.

To get serial log with RTS connected to RST and DTR to DL:

picocom -b 115200 --lower-rts --lower-dtr --imap lfcrlf /dev/ttyUSB0

configuration

If you manufactured and flashed the device yourself, you will also have to configure it. Once flashed, the device will create a WiFi access point named WLED-AP. The corresponding password it wled1234. When connecting to it, you will be redirected to its home page where you can configure the WiFi to connect to your network.

To configure the device manually:

  • go to "TO THE CONTROLS!"
    • go to "Config" gear on top
    • go to "LED Preferences"
    • in the "Maximum PSU Current" field, enter 2500 (mA)
    • under "LED outputs", click twice on "+"
    • in "LED outputs" section 1, set "GPIO" to 25 and "Length" to 30
    • in "LED outputs" section 2, set "GPIO" to 26 and "Length" to 30
    • in "LED outputs" section 3, set "GPIO" to 27 and "Length" to 30
    • click on "Save" on top
  • go to "Usermods"
    • under "AudioReactive", tick "Enable"
    • click on "Save" on top
  • go to "Usermods"
    • under "AudioReactive" "Digitalmic", set "Type" to "Generic I2S PDM"
    • click on "Save" on top
  • go to "Usermods"
    • under "AudioReactive" "Digitalmic"
    • set "Pin I2S SD" to 5
    • set "Pin I2S WS" to 18
    • set "Pin I2S SCK" to "undefined"
    • click on "Save" on top
  • got to "User Interface"
    • in the "Server description" field, enter "WLED chain"
    • click on "Save" on top
  • go to "Sync Interfaces"
    • under DMX Input Pins
    • set "DMX RX" to 35
    • set "DMX TX" to 33
    • set "DMX Enable" to 32
    • click on "Save" on top
  • got to "WiFi Setup"
    • in the "AP SSID" field, enter "WLED chain-AP"
    • click on "Save & Connect" on top

The WiFi connection should drop, and the new "WLED chain-AP" access point should appear, still with password "wled1234". To test the LED outputs, go to "TO THE CONTROLS!", select the Effect mode "Rainbow" and see the LEDs connected to the outputs on the bottom of the board cycle through colors. To test the microphone for audio-reactive effects, select the Effect mode "Gravimeter". Clamp in your hands, and the LEDs should light up red and fade out.

To not have to configure every field by hand, go to the "Security & Updates" menu. There you can backup the configuration and presents. You can then upload them to the next device.

To update the firmware.bin firmware over HTTP using the command line (much faster than over UART):

curl --form "update=@firmware.bin" 'http://4.3.2.1/update'

To upload the wled_cfg.json configuration:

curl --form "data=@wled_cfg.json;type=application/json;name=data;filename=/cfg.json" 'http://4.3.2.1/upload'

To upload the wled_presets.json presets:

curl --form "data=@wled_presets.json;type=application/json;name=data;filename=/presets.json" 'http://4.3.2.1/upload'