Building firmware using PlatformIO

59 views
Skip to first unread message

Taylor Lee

unread,
May 9, 2023, 6:40:02 PM5/9/23
to WVR Audio
Hello,

I am trying to build firmware using PlatformIO but it keeps locking up, and I have to use recovery mode to fix it. I have put together a simple project based on wvr_basic.ino, and setup my .ini file as instructed in your readme.

I noticed that the build file out of VS is .bin. It seems all the firmware files need to be .ino.bin, and simply changing the name doesn't work?

Any idea what I may be missing?

Thanks!

WVR Audio

unread,
May 9, 2023, 7:10:46 PM5/9/23
to WVR Audio
Hey sorry to hear that.
.bin is the correct extension. The Arduino IDE adds .ino.bin but it's not important.
Do you have a USB->FTDI module? It is highly recommended that you have one setup, otherwise there is no way to debug issues that come up when writing custom firmware. https://github.com/marchingband/wvr#setting-up-for-arduino-ide-programming
If you would like to link me to your code, I could try to identify possible issues.

Let me know any other ways I can support you in your firmware!

Taylor Lee

unread,
May 9, 2023, 7:39:51 PM5/9/23
to WVR Audio
I really appreciate the quick response! 
I will hook up an FTDI cable and see what I can get out of the debug terminal. In the mean time I have attached my main.cpp.
main.cpp

Taylor Lee

unread,
May 9, 2023, 7:56:00 PM5/9/23
to WVR Audio
I was able to connect my FTDI cable, and got the following output. This shows it first booting wvr_basic 3.8.0 successfully, and then it shows the loop I see when I run my firmware.

àets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x3f (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1324
ho 0 tail 12 room 4
load:0x40078000,len:13508
load:0x40080400,len:3604
entry 0x400805f0
Total heap: 308132
Free heap: 280960
Total PSRAM: 4192139
Free PSRAM: 4192139
[   874][I][wvr_0.3.cpp:84] wvr_init(): arduino setup running on core 1
[   875][I][wvr_0.3.cpp:85] wvr_init(): cpu speed 240
[   880][I][wvr_0.3.cpp:86] wvr_init(): Flash Speed = 80000000 Flash mode = 2
[   887][I][wvr_0.3.cpp:87] wvr_init(): wvr starting up

*** VERSION 3.8.0 ***


after begin, remaining: 4430799, used:4290638901
Name: 8GTF4R
Type: MMC
Speed: 52 MHz
Size: 7456MB
CSD: ver=3, sector_size=512, capacity=15269888 read_bl_len=9
[   954][I][emmc.c:80] emmc_init(): bus width is 4
after emmc, remaining: 4429879, used:920
[   968][I][file_system.c:160] try_read_metadata(): on disk metadata tag is: wvr_magic_15
[   969][I][file_system.c:162] try_read_metadata(): found the right tag :)
after file system, remaining: 4177371, used:252508
[  1170][I][boot.cpp:159] check_for_recovery_mode(): recovery mode pin 4 reads high
after dac, remaining: 4173935, used:3436
after midi, remaining: 4150067, used:23868
after midi parser, remaining: 4150067, used:0
[  1179][I][midi_in.c:133] read_uart_task(): midi task running on core 0
[  1191][I][wav_player.c:185] init_buffs(): 18 buffers were initialized
[  1198][I][wav_player.c:926] wav_player_start(): dma capable output buf : true
[  1202][I][wav_player.c:379] wav_player_task(): wav player running on core 1
after wav player, remaining: 3977011, used:173056
Configuring access point...
[  1325][I][server.cpp:653] server_begin(): set ssid :WVR, set passphrase: 12345678
AP IP address: 192.168.5.18
[  1326][I][server.cpp:663] server_begin(): metadata wifiPower is 8
[  1331][I][server.cpp:667] server_begin(): wifi power is 8
Server started
after server, remaining: 3918627, used:58384
after button, remaining: 3915995,àets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x3f (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1324
ho 0 tail 12 room 4
load:0x40078000,len:13508
load:0x40080400,len:3604
entry 0x400805f0
E (352) esp_core_dump_flash: Nþ½Édump partition found!
E (352) esp_core_dump_flash: No core dump partition found!
Total heap: 314292
Free heap: 286528
Total PSRAM: 4192123
Free PSRAM: 4192123
after begin, remaining: 4437159, used:4290633701
Name: 8GTF4R
Type: MMC
Speed: 52 MHz
Size: 7456MB
CSD: ver=3, sector_size=512, capacity=15269888 read_bl_len=9
after emmc, remaining: 4436351, used:808
after file system, remaining: 4183759, used:252592
after dac, remaining: 4180267, used:3492
after midi, remaining: 4156323, used:23944
after midi parser, remaining: 4156323, used:0
after wav player, remaining: 3983031, used:173292
Configuring access point...
AP IP address: 192.168.5.18
Serverets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x3f (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1324
ho 0 tail 12 room 4
load:0x40078000,len:13508
load:0x40080400,len:3604
entry 0x400805f0
E (352) esp_core_dump_flash: Nþ½Édump partition found!
E (352) esp_core_dump_flash: No core dump partition found!
Total heap: 314292
Free heap: 286528
Total PSRAM: 4192123
Free PSRAM: 4192123
after begin, remaining: 4437159, used:4290633701
Name: 8GTF4R
Type: MMC
Speed: 52 MHz
Size: 7456MB
CSD: ver=3, sector_size=512, capacity=15269888 read_bl_len=9
after emmc, remaining: 4436351, used:808
after file system, remaining: 4183759, used:252592
after dac, remaining: 4180267, used:3492
after midi, remaining: 4156323, used:23944
after midi parser, remaining: 4156323, used:0
after wav player, remaining: 3983031, used:173292
Configuring access point...
AP IP address: 192.168.5.18 

Andrew March

unread,
May 9, 2023, 8:50:46 PM5/9/23
to Taylor Lee, WVR Audio
Great!
Set useFTDI = 1;
And the missing logs will print.

--
You received this message because you are subscribed to the Google Groups "WVR Audio" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wvr-audio+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wvr-audio/3f13c23a-d39d-428e-9d6f-92f9aaaae8cen%40googlegroups.com.

Andrew March

unread,
May 9, 2023, 8:57:57 PM5/9/23
to Taylor Lee, WVR Audio
Also, do not reset or otherwise use D0 or D1 … those are the FTDI pins so you need to leave them alone for logging.

Taylor Lee

unread,
May 9, 2023, 9:10:03 PM5/9/23
to WVR Audio
Enabled FTDI and I get te same printout, but now I am seeing the following at each reset;


...
Server started
after server, remaining: 3912851, used:70180
after button, remaining: 3910203, used:2648
after gpio, remaining: 391020ets Jun  8 2016 00:22:57
...

WVR Audio

unread,
May 10, 2023, 12:21:55 PM5/10/23
to WVR Audio
Ok strange, I'll run some tests this morning. thanks for your patience and for the bug report.

WVR Audio

unread,
May 10, 2023, 1:12:39 PM5/10/23
to WVR Audio
I commented out lines 85, 86, 91, 92, 97, 98, 103, 104, 105, 106 (everything for D0 and D1).
Then uploaded the firmware using the web UI.
I started the terminal with `pio device monitor`
and got this error log

rst:0xc (SW_CPU_RESET),boot:0x3f (SPI_FAST_FLASH_BOOT)

configsip: 0, SPIWP:0xee

clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00

mode:DIO, clock div:1

load:0x3fff0030,len:1324

ho 0 tail 12 room 4

load:0x40078000,len:13508

load:0x40080400,len:3604

entry 0x400805f0

E (352) esp_core_dump_flash: N␀4KW␖$VW␋␗␒,.]ZZ␋֫VRH␔␒MJHY.\5KWE}͡␂r␚ɕ"յѥѥ2չjRTotal heap: 314252

Free heap: 281376

Total PSRAM: 4192123

Free PSRAM: 4192123

after begin, remaining: 4436991, used:4290633845

Name: 8GTF4R␆

Type: MMC

Speed: 52 MHz

Size: 7456MB

CSD: ver=3, sector_size=512, capacity=15269888 read_bl_len=9

after emmc, remaining: 4436183, used:808

after file system, remaining: 4183591, used:252592

after dac, remaining: 4180099, used:3492

after midi, remaining: 4156155, used:23944

after midi parser, remaining: 4156155, used:0

after wav player, remaining: 3982863, used:173292

Configuring access point...

AP IP address: 192.168.5.18

Server started

after server, remaining: 3912675, used:70188

after button, remaining: 3910027, used:2648

after gpio, remaining: 3910027, used:0

after rpc, remaining: 3905135, used:4892

Total heap: 309684

Free heap: 76108

Total PSRAM: 4191467

Free PSRAM: 3870519

Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.


Core  1 register dump:

PC      : 0x400d268f  PS      : 0x00060630  A0      : 0x800d2575  A1      : 0x3ffb2250  

A2      : 0x00000000  A3      : 0x400d23f4  A4      : 0x00000002  A5      : 0x00000028  

A6      : 0x007bf518  A7      : 0x003fffff  A8      : 0x00000000  A9      : 0x3ffb2230  

A10     : 0x3fff796c  A11     : 0x00000028  A12     : 0x00000000  A13     : 0x00040000  

A14     : 0x00000028  A15     : 0x003fffff  SAR     : 0x00000016  EXCCAUSE: 0x0000001c  

EXCVADDR: 0x00000010  LBEG    : 0x4008b9c0  LEND    : 0x4008b9cb  LCOUNT  : 0x00000000  



Backtrace: 0x400d268c:0x3ffb2250 0x400d2572:0x3ffb2270 0x400dbf9a:0x3ffb2290

The Backtrace is the part that will provide the stack trace, but it must be decoded.
in PIO this is done by adding 

build_type = debug
monitor_filters = esp32_exception_decoder

to the platform.ini

flashing this debug binary I get this extra log

 #0  0x400d2700:0x3ffb2250 in init_wav_lut at /Users/andy/wvr/wvr/src/file_system.c:248 (discriminator 3)

  #1  0x400d25c9:0x3ffb2270 in init_metadata at /Users/andy/wvr/wvr/src/file_system.c:201

  #2  0x400ddfe7:0x3ffb2290 in setCpuFrequencyMhz at /Users/andy/.platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal-cpu.c:171

As is sometimes the case, this wasn't particularly helpful information.

However I started commenting out other stuff to debug and spotrted the bug in your code

lines 97-101 you initialize Button in the the same variable multiple times.

it should be:

switchOne = new Button(D0, FALLING, 40);
switchTwo = new Button(D1, FALLING, 40);
switchThree = new Button(D2, FALLING, 40);
switchFour = new Button(D3, FALLING, 40);
switchFive = new Button(D4, FALLING, 40);

Taylor Lee

unread,
May 10, 2023, 1:15:53 PM5/10/23
to WVR Audio
Thank you.
I am having another issue now, which maybe needs a new thread. I tried using the Arduino IDE to build my firmware and it corrupted things on the ESP32. I used the IDE to upload wvr_ftdi.ino over FTDI, but even after successfully loading it, the ESP32 cannot boot.

Here is the printout I see repeat.

Rebooting...

ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x3f (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1344
load:0x40078000,len:13924

ho 0 tail 12 room 4
load:0x40080400,len:3600
entry 0x400805f0
Total heap: 319580
Free heap: 291768
Total PSRAM: 0
Free PSRAM: 0
after begin, remaining: 245108, used:4294825840

Name: 8GTF4R
Type: MMC
Speed: 52 MHz
Size: 7456MB
CSD: ver=3, sector_size=512, capacity=15269888 read_bl_len=9
after emmc, remaining: 244300, used:808
Guru Meditation Error: Core  1 panic'ed (StoreProhibited). Exception was unhandled.

Core  1 register dump:
PC      : 0x400d3c01  PS      : 0x00060c30  A0      : 0x800d8c99  A1      : 0x3ffb21e0  
A2      : 0x00000000  A3      : 0x3ffc4368  A4      : 0x3ffc4364  A5      : 0x00000003  
A6      : 0x00000001  A7      : 0x0000e100  A8      : 0x00000000  A9      : 0x3ffb21c0  
A10     : 0x00000000  A11     : 0x09cbeaf4  A12     : 0x09cbeaf4  A13     : 0x3ffb217c  
A14     : 0x3ffc4ab8  A15     : 0x3ffb217c  SAR     : 0x00000004  EXCCAUSE: 0x0000001d  
EXCVADDR: 0x00000000  LBEG    : 0x4008ac01  LEND    : 0x4008ac11  LCOUNT  : 0xfffffffe  


Backtrace: 0x400d3bfe:0x3ffb21e0 0x400d8c96:0x3ffb2200 0x400d2fec:0x3ffb2250 0x400d8d44:0x3ffb2270 0x400e4922:0x3ffb2290




ELF file SHA256: 9752c7329fcbfca0

Rebooting...

WVR Audio

unread,
May 10, 2023, 1:17:21 PM5/10/23
to WVR Audio
This PIO toolchain is quite new to me, so do bare with me please.
I am also noticing an issue of some kind, where the WVR is flashed initially using Arduino CLI (when I manufacture them), subsequently uploading binaries produces with PIO seems to have an issue with some of the flash addresses for the debug dump ... I am not sure if it will cause problems, but, I would recommend running:

pio run -t upload
At 
at least once when you begin with a new WVR, using the instructions here: https://github.com/marchingband/wvr#using-ftdi
This means that PIO will upload all the contents of flash, not just the binary, and everything will be in its intended place in flash.

WVR Audio

unread,
May 10, 2023, 1:21:07 PM5/10/23
to WVR Audio
Your problem on the Arduino IDE is indicated by these lines in the log:
Total PSRAM: 0
Free PSRAM: 0

You will need to tell the Arduino IDE that you are using a WROVER module, and that it has PSRAM
They keep changing exactly how that works, so I am not sure ATM, but let me know once you figure it out, and I will update the readme

WVR Audio

unread,
May 10, 2023, 1:23:06 PM5/10/23
to WVR Audio
Anytime you change hardware settings, you will need to flash via FTDI, this information is not contained in the .bin file, so the full flash must be erased and written fresh, which is only possible vie FTDI

Taylor Lee

unread,
May 10, 2023, 2:27:37 PM5/10/23
to WVR Audio
Yes! Thank you, you have fixed both issues.
 Sorry the original issue was just my bad code. Hopefully this post will at least be helpful for all the new Sparkfun users :P .
I really, really appreciate the quick help. This has been a life saver in a crunch.

WVR Audio

unread,
May 10, 2023, 2:29:28 PM5/10/23
to WVR Audio
Awesome! No problem, I appreciate having someone run through the process. You may be the first user to build and use a custom binary, so congratulations!

Taylor Lee

unread,
May 11, 2023, 2:59:43 PM5/11/23
to WVR Audio
Oh wow, I didn't expect to be the first. In that case, I am impressed it went so smoothly :P .

In appreciation of your wonderful support, I thought I should share a couple photos of the finished project.
This is for part of a product demonstration, where we need to see how a device responds to different audio inputs. The blue button just turns on a usb fan to simulate wind.
PXL_20230511_130012983.jpg

Taylor Lee

unread,
May 11, 2023, 3:00:14 PM5/11/23
to WVR Audio
cnt.
PXL_20230511_130207386.jpg

WVR Audio

unread,
May 12, 2023, 1:38:51 AM5/12/23
to WVR Audio
oh AMAZING 😍
Thank you so much!!
I should start a gallery soon, I have 4 or 5 decent build pix from various makers now :)

Reply all
Reply to author
Forward
0 new messages