M5StickS3: PSRAM, audio and backlight initialization fixes
This issue documents several board-specific fixes for M5StickS3 in Bruce firmware.
The problems were not generic ESP32 issues, but rather initialization/config mismatches specific to the m5stack-sticks3 target.
1. PSRAM is detected as 0 on M5StickS3
Problem
On the m5stack-sticks3 build, PSRAM was reported as unavailable, and calls such as:
ESP.getPsramSize()
returned 0.
As a result, the firmware behaved as if external RAM was not present at all.
Why this happens on M5StickS3
M5StickS3 uses ESP32-S3 with OPI PSRAM.
The board configuration already had:
board_build.psram_type = opi
but this alone was not enough for PlatformIO to fully select the correct memory configuration for this board.
Without an explicit memory type in the board JSON, PlatformIO could fall back to the wrong memory profile during build/link stage, which leads to incorrect PSRAM startup behavior at runtime.
In practice, the firmware was being built with a memory configuration that did not match the actual PSRAM interface used by M5StickS3.
Fix
The board definition for M5StickS3 was updated here:
boards/_boards_json/m5stack-sticks3.json
Added:
"memory_type": "qio_opi"
Result
After setting the correct memory type for M5StickS3:
OPI PSRAM initializes correctly
ESP.getPsramSize() no longer returns 0
the board reports external RAM properly
features depending on PSRAM can work as expected
2. M5StickS3 audio fixes
Problem
Audio behavior on M5StickS3 was unstable / incorrect:
wrong or unreliable I2S-related behavior
clicks / noise during simple tones
board-specific audio pin handling was not aligned with the actual hardware setup
What was changed
Board-specific configuration was fixed in:
boards/m5stack-sticks3/m5stack-sticks3.ini
and:
boards/m5stack-sticks3/interface.cpp
Also, the generic audio logic was adjusted in:
src/modules/others/audio.cpp
Specific fixes
BCLK for M5StickS3 was corrected to 17
board initialization for StickS3 was adjusted
simple tone generation was moved to the M5.Speaker path instead of the old behavior
sound volume is now taken from:
bruceConfig.soundVolume
Why this matters specifically for M5StickS3
This is a board-specific fix for m5stack-sticks3, not just a cosmetic refactor.
M5StickS3 needs the correct low-level pin/audio setup, and using the proper M5.Speaker path significantly improves behavior for short tones and UI sounds.
Result
On M5StickS3:
audio output is initialized more correctly
simple tones behave more predictably
clicks / noise are reduced
configured sound volume is respected consistently
Additional note
The following I2C setup was intentionally kept as a working configuration for M5StickS3:
Wire1.begin(47, 48);
3. M5StickS3 backlight brightness is not applied on boot
Problem
Saved screen brightness was not being applied correctly on startup for M5StickS3.
The selected brightness only became active after manually opening the brightness settings page.
Root cause
This was caused by initialization order.
Brightness was applied early in the display startup path, but later the M5StickS3 board-specific GPIO/post-setup code reconfigured the backlight PWM and overwrote that value.
So the firmware technically loaded the saved brightness, but the board setup later replaced it with a default PWM level.
Files involved
Brightness application path:
src/main.cpp
Board-specific post-setup logic:
boards/m5stack-sticks3/interface.cpp
Fix
After the board-specific _post_setup_gpio() call, brightness is applied again:
setBrightness(bruceConfig.bright, false);
Result
On M5StickS3:
saved brightness now applies immediately at boot
user no longer needs to enter the brightness menu to “activate” it
startup behavior matches saved settings correctly
Summary
These changes are specifically important for the M5StickS3 target:
fixed PSRAM detection by setting the correct board memory type
fixed StickS3-specific audio configuration and tone path
fixed startup backlight brightness being overwritten during board init
Together, these changes make the m5stack-sticks3 build behave much closer to the actual hardware capabilities of the board.
M5StickS3: PSRAM, audio and backlight initialization fixes
This issue documents several board-specific fixes for M5StickS3 in Bruce firmware.
The problems were not generic ESP32 issues, but rather initialization/config mismatches specific to the
m5stack-sticks3target.1. PSRAM is detected as
0on M5StickS3Problem
On the
m5stack-sticks3build, PSRAM was reported as unavailable, and calls such as:ESP.getPsramSize()
returned 0.
As a result, the firmware behaved as if external RAM was not present at all.
Why this happens on M5StickS3
M5StickS3 uses ESP32-S3 with OPI PSRAM.
The board configuration already had:
board_build.psram_type = opi
but this alone was not enough for PlatformIO to fully select the correct memory configuration for this board.
Without an explicit memory type in the board JSON, PlatformIO could fall back to the wrong memory profile during build/link stage, which leads to incorrect PSRAM startup behavior at runtime.
In practice, the firmware was being built with a memory configuration that did not match the actual PSRAM interface used by M5StickS3.
Fix
The board definition for M5StickS3 was updated here:
boards/_boards_json/m5stack-sticks3.json
Added:
"memory_type": "qio_opi"
Result
After setting the correct memory type for M5StickS3:
OPI PSRAM initializes correctly
ESP.getPsramSize() no longer returns 0
the board reports external RAM properly
features depending on PSRAM can work as expected
2. M5StickS3 audio fixes
Problem
Audio behavior on M5StickS3 was unstable / incorrect:
wrong or unreliable I2S-related behavior
clicks / noise during simple tones
board-specific audio pin handling was not aligned with the actual hardware setup
What was changed
Board-specific configuration was fixed in:
boards/m5stack-sticks3/m5stack-sticks3.ini
and:
boards/m5stack-sticks3/interface.cpp
Also, the generic audio logic was adjusted in:
src/modules/others/audio.cpp
Specific fixes
BCLK for M5StickS3 was corrected to 17
board initialization for StickS3 was adjusted
simple tone generation was moved to the M5.Speaker path instead of the old behavior
sound volume is now taken from:
bruceConfig.soundVolume
Why this matters specifically for M5StickS3
This is a board-specific fix for m5stack-sticks3, not just a cosmetic refactor.
M5StickS3 needs the correct low-level pin/audio setup, and using the proper M5.Speaker path significantly improves behavior for short tones and UI sounds.
Result
On M5StickS3:
audio output is initialized more correctly
simple tones behave more predictably
clicks / noise are reduced
configured sound volume is respected consistently
Additional note
The following I2C setup was intentionally kept as a working configuration for M5StickS3:
Wire1.begin(47, 48);
3. M5StickS3 backlight brightness is not applied on boot
Problem
Saved screen brightness was not being applied correctly on startup for M5StickS3.
The selected brightness only became active after manually opening the brightness settings page.
Root cause
This was caused by initialization order.
Brightness was applied early in the display startup path, but later the M5StickS3 board-specific GPIO/post-setup code reconfigured the backlight PWM and overwrote that value.
So the firmware technically loaded the saved brightness, but the board setup later replaced it with a default PWM level.
Files involved
Brightness application path:
src/main.cpp
Board-specific post-setup logic:
boards/m5stack-sticks3/interface.cpp
Fix
After the board-specific _post_setup_gpio() call, brightness is applied again:
setBrightness(bruceConfig.bright, false);
Result
On M5StickS3:
saved brightness now applies immediately at boot
user no longer needs to enter the brightness menu to “activate” it
startup behavior matches saved settings correctly
Summary
These changes are specifically important for the M5StickS3 target:
fixed PSRAM detection by setting the correct board memory type
fixed StickS3-specific audio configuration and tone path
fixed startup backlight brightness being overwritten during board init
Together, these changes make the m5stack-sticks3 build behave much closer to the actual hardware capabilities of the board.