ESP32-D2WD does not execute code from Arduino (works fine with ESP-IDF)

demultiplexer
Posts: 3
Joined: Sun Aug 13, 2017 8:00 am

ESP32-D2WD does not execute code from Arduino (works fine with ESP-IDF)

Postby demultiplexer » Mon Aug 14, 2017 7:45 am

Disclaimer: I never use Arduino, so expect the simplest mistakes on my part.

I have developed a custom board for ESP32-D2WD and am now in the process of programming it. Since this is going to be an open source project, I would like the board to be programmed in the Arduino environment to maximize community accessibility. Unfortunately, it seems like the compiling or flashing procedure used by the arduino-esp32 (https://github.com/espressif/arduino-esp32) toolchain does something differently compared to the ESP-IDF toolchain that causes code to run fine under ESP-IDF and not at all under Arduino.

So, first things first, I literally try the first available examples:
- Change menuconfig to the correct serial port
- compile and flash hello_world in esp-idf

This works flawlessly.

Then I start the Arduino environment, set up exactly following the instructions and compile/flash the sample program in the readme file

Code: Select all

#include "Arduino.h"

          void setup(){
            Serial.begin(115200);
          }

          void loop(){
            Serial.println("loop");
            delay(1000);
          }
This is with the correct settings (40MHz flash, DIO)

This does not work and returns:

Code: Select all

ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x33 (SPI_FAST_FLASH_BOOT)
configsip: 188777542, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0010,len:4
load:0x3fff0014,len:588
load:0x40078000,len:0
load:0x40078000,len:10472
entry 0x40078a28
user code done
I have tried a bunch of things; e.g. copying the hello_world example into Arduino and compiling/flashing that - doesn't work. Trying it in the setup()/loop() format, doesn't work. And yes, I added 'extern "C"' to make app_main() work. The correct program is being compiled, i can find some recognizable strings in there. The flash size is recognized correctly (2MB) and nothing seems to go wrong during flashing.

What could I be doing wrong?

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: ESP32-D2WD does not execute code from Arduino (works fine with ESP-IDF)

Postby kolban » Mon Aug 14, 2017 1:36 pm

Have you seen the instructions here:

https://github.com/espressif/arduino-esp32

and look at the section called "Using as ESP-IDF component".

Can you validate that you have an ESP-IDF component created as described in that recipe? The error message you encounter would be appear (opinion) to be consistent with not being able to find the the Arduino component.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: ESP32-D2WD does not execute code from Arduino (works fine with ESP-IDF)

Postby WiFive » Mon Aug 14, 2017 2:17 pm

You may need to change the partition table and update the bootloader

demultiplexer
Posts: 3
Joined: Sun Aug 13, 2017 8:00 am

Re: ESP32-D2WD does not execute code from Arduino (works fine with ESP-IDF)

Postby demultiplexer » Mon Aug 14, 2017 7:48 pm

kolban wrote:Have you seen the instructions here:

https://github.com/espressif/arduino-esp32

and look at the section called "Using as ESP-IDF component".

Can you validate that you have an ESP-IDF component created as described in that recipe? The error message you encounter would be appear (opinion) to be consistent with not being able to find the the Arduino component.
Sure. FIrst I'm trying this on ESP-IDF using the Arduino component:

Code: Select all

rst:0x1 (POWERON_RESET),boot:0x33 (SPI_FAST_FLASH_BOOT)
configsip: 188777542, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0010,len:4
load:0x3fff0014,len:7348
load:0x40078000,len:0
load:0x40078000,len:14024
entry 0x400792fc
[1B][0;32mI (46) boot: ESP-IDF v3.0-dev-253-gcd5cc992 2nd stage bootloader[1B][0m
[1B][0;32mI (46) boot: compile time 21:15:04[1B][0m
[1B][0;32mI (46) boot: Enabling RNG early entropy source...[1B][0m
D (64) bootloader_flash: mmu set block paddr=0x00000000 (was 0xffffffff)[1B][0m
D (85) boot: magic e9[1B][0m
D (92) boot: segments 04[1B][0m
D (100) boot: spi_mode 02[1B][0m
D (108) boot: spi_speed 00[1B][0m
D (117) boot: spi_size 01[1B][0m
[1B][0;32mI (125) boot: SPI Speed      : 40MHz[1B][0m
[1B][0;32mI (138) boot: SPI Mode       : DIO[1B][0m
[1B][0;32mI (151) boot: SPI Flash Size : 2MB[1B][0m
D (163) bootloader_flash: mmu set paddr=00000000 count=1[1B][0m
D (180) boot: mapped partition table 0x8000 at 0x3f408000[1B][0m
[1B][0;31mE (197) flash_parts: partition 3 invalid - offset 0x150000 size 0x140000 exceeds flash chip size 0x200000[1B][0m
[1B][0;31mE (228) boot: Failed to verify partition table[1B][0m
[1B][0;31mE (244) boot: load partition table error![1B][0m
user code done
Okay, that is quite an obvious error, the partition is wrong, so let's modify default.csv to something appropriate for 2MB of flash:

Code: Select all

# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x5000,
otadata,  data, ota,     0xe000,  0x2000,
app0,     app,  ota_0,   0x10000, 0x80000,
app1,     app,  ota_1,   0x90000, 0x80000,
eeprom,   data, 0x99,    0x110000,0x1000,
spiffs,   data, spiffs,  0x111000,0xEF000
(yes, it is a mess). So another make clean, make, make flash gives me:

Code: Select all

loop
loop
loop
loop
loop
loop
loop
loop
loop
loop
loop
loop
loop
loop
loop
loop
loop
loop
Okay, 'arduino' now works if I use esp-idf to compile it. How about the Arduino IDE, which is what I'm actually after?

Code: Select all

ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x33 (SPI_FAST_FLASH_BOOT)
configsip: 188777542, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0010,len:4
load:0x3fff0014,len:588
load:0x40078000,len:0
load:0x40078000,len:10472
entry 0x40078a28
user code done
Nope, the Arduino IDE still does nothing. Obviously. So I guess this is *some* config/include/whatever issue with the esp32 toolchain behind Arduino? Unfortunately with literally zero verbose output it's hard to figure out what the issue is. How about I copy my default.csv into the Arduino toolchain?

Code: Select all

ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x33 (SPI_FAST_FLASH_BOOT)
configsip: 188777542, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0010,len:4
load:0x3fff0014,len:588
load:0x40078000,len:0
load:0x40078000,len:10472
entry 0x40078a28
[1F]ëë[0B]WHøloop
loop
loop
loop
loop
loop
Success!!

Thanks to WiFive and actually using esp-idf with its superior verbosity to find out what was the issue with Arduino.

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: ESP32-D2WD does not execute code from Arduino (works fine with ESP-IDF)

Postby ESP_Angus » Tue Aug 15, 2017 3:39 am

Glad you worked out a solution, demultiplexer. Are you able to please raise an issue for this on the arduino-esp32 github?
https://github.com/espressif/arduino-esp32/

demultiplexer
Posts: 3
Joined: Sun Aug 13, 2017 8:00 am

Re: ESP32-D2WD does not execute code from Arduino (works fine with ESP-IDF)

Postby demultiplexer » Tue Aug 15, 2017 6:13 am

ESP_Angus wrote:Glad you worked out a solution, demultiplexer. Are you able to please raise an issue for this on the arduino-esp32 github?
https://github.com/espressif/arduino-esp32/
Just did. Thanks again!

Who is online

Users browsing this forum: Google [Bot] and 70 guests