Works in Arduino IDE not in PlatformIO

Hi,

I am have a problem with PlatformIO and some new ESP32 devkit modules and I am at my wits end. I can program the ESP32 module just fine from the Ardunio IDE. If I take a pretty simple example like the ADC to Serial program and then program it in to the ESP32, bingo no problem it works.

If I take the exact same program and try and program it via the PlatformIO platform I get the dreaded:

ets Jun  8 2016 00:22:57

rst:0x3 (SW_RESET),boot:0x13 (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:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1100
load:0x40078000,len:9232
load:0x40080400,len:6412
entry 0x400806a8
ets Jun  8 2016 00:22:57

rst:0x3 (SW_RESET),boot:0x13 (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:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1100
load:0x40078000,len:9232
load:0x40080400,len:6412
entry 0x400806a8
ets Jun  8 2016 00:22:57

This goes on forever.

I have tried:

  1. erasing the flash
  2. improving the power supply
  3. changing the flash mode, frequency etc.

Nothing seems to make any difference at all.

The problem seems to be associated with these new modules, as old modules worked fine in the past (although I do not have any old modules to hand at the moment to check with).

My platformio.ini file looks like this:

[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
monitor_speed = 115200

My program is this:

#include <Arduino.h>

/*
  AnalogReadSerial

  Reads an analog input on pin 0, prints the result to the Serial Monitor.
  Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.

  This example code is in the public domain.

  http://www.arduino.cc/en/Tutorial/AnalogReadSerial
*/

// the setup routine runs once when you press reset:
void setup()
{
  // initialize serial communication at 9600 bits per second:
  Serial.begin(115200);
}

// the loop routine runs over and over again forever:
void loop()
{
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // print out the value you read:
  Serial.println(sensorValue);
  delay(1); // delay in between reads for stability
}

I am completely at a loss what to do next? The module clearly works just fine from Arduino IDE, it is just a problem with being programmed from the PlatformIO ide.

Thanks,
Matt.

Hi @matt123p! What version of the framework is installed in Arduino IDE? Could you please try the next config:

[env:esp32doit-devkit-v1]
platform = https://github.com/platformio/platform-espressif32.git
board = esp32doit-devkit-v1
framework = arduino
monitor_speed = 115200

Hi,

Thanks for the prompt reply.

In the Arduino IDE I am using version 1.0.3.

Your intuition seems to be correct. I tried your suggestion and that fixed the problem, so I am back up and running again.

Just to complete the investigation, I went back to the release version of the platform and dumped the 1.0.3 Arduino framework over the top of the 1.0.2 framework that had been automatically downloaded and that too fixed the problem.

I also tried a simple “hello world” application using the espidf framework and that worked fine (using the released platform).

Looking at the debug output I can see:

[fum����2-hal-cpu.c:159] setCpuFrequencyMhz(): Can not switch to 240 MHz! Chip CPU frequency rated for 160MHz.

So it looks like the problem is that these cheap devboards from China are using 160MHz parts.

Thanks for all of your help!

Matt.