Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update esptool #614

Closed
1 task done
boneskull opened this issue Apr 12, 2016 · 14 comments
Closed
1 task done

update esptool #614

boneskull opened this issue Apr 12, 2016 · 14 comments
Assignees
Milestone

Comments

@boneskull
Copy link

What kind of issue is this?

  • Bug report. If you’ve found a bug, please provide information below.

Configuration

Operating system: MacOS X El Capitan

PlatformIO Version (platformio --version): 2.8.6

Description of problem

I have not had any success with the packaged esptool for uploading to a WeMos D1 Mini. It always fails. I replaced it with the master branch here and now uploads work.

Steps to Reproduce

  1. Get a Mac with El Capitan, D1 Mini, and install driver from wemos.cc. Reboot
  2. Build anything with platformio
  3. Try to upload

Actual Results

$ pio run -t upload
[Mon Apr 11 17:11:26 2016] Processing d1_mini (platform: espressif, lib_install: 18, 19, 89, board: d1_mini, framework: arduino)
----------------------------------------------------------------------------------------------------------------------
<lambda>(["upload"], [".pioenvs/d1_mini/firmware.bin"])
Auto-detected UPLOAD_PORT/DISK: /dev/cu.wchusbserial14220
"/Users/boneskull/.platformio/packages/tool-esptool/esptool" -vv -cd nodemcu -cb 115200 -cp /dev/cu.wchusbserial14220 -cf .pioenvs/d1_mini/firmware.bin
esptool v0.4.8 - (c) 2014 Ch. Klippel <[email protected]>
setting board to nodemcu
setting baudrate from 115200 to 115200
setting port from /dev/tty.usbserial to /dev/cu.wchusbserial14220
espcomm_upload_file
espcomm_upload_mem
opening port /dev/cu.wchusbserial14220 at 115200
tcgetattr
tcsetattr
serial open
opening bootloader
resetting board
trying to connect
setting character timeout 0
done
setting character timeout 1
done
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
trying to connect
setting character timeout 0
done
setting character timeout 1
done
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
espcomm_send_command: receiving 2 bytes of data
warning: espcomm_send_command: wrong direction/command: 0x01 0x07, expected 0x01 0x08
trying to connect
setting character timeout 0
done
setting character timeout 1
done
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
espcomm_send_command: receiving 2 bytes of data
warning: espcomm_send_command: wrong direction/command: 0x01 0x07, expected 0x01 0x08
resetting board
trying to connect
setting character timeout 0
done
setting character timeout 1
done
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
trying to connect
setting character timeout 0
done
setting character timeout 1
done
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
espcomm_send_command: receiving 2 bytes of data
warning: espcomm_send_command: wrong direction/command: 0x01 0x07, expected 0x01 0x08
trying to connect
setting character timeout 0
done
setting character timeout 1
done
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
espcomm_send_command: receiving 2 bytes of data
resetting board
trying to connect
setting character timeout 0
done
setting character timeout 1
done
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
trying to connect
setting character timeout 0
done
setting character timeout 1
done
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
espcomm_send_command: receiving 2 bytes of data
warning: espcomm_send_command: wrong direction/command: 0x01 0x07, expected 0x01 0x08
trying to connect
setting character timeout 0
done
setting character timeout 1
done
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
espcomm_send_command: receiving 2 bytes of data
warning: espcomm_send_command: wrong direction/command: 0x01 0x07, expected 0x01 0x08
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
scons: *** [upload] Error 255
============================================ [ ERROR ] Took 2.41 seconds ============================================

Expected Results

$ pio run -t upload
[Mon Apr 11 17:13:55 2016] Processing d1_mini (platform: espressif, lib_install: 18, 19, 89, board: d1_mini, framework: arduino)
----------------------------------------------------------------------------------------------------------------------
"/Users/boneskull/.platformio/packages/tool-esptool/esptool" -eo "/Users/boneskull/.platformio/packages/framework-arduinoespressif/bootloaders/eboot/eboot.elf" -bo .pioenvs/d1_mini/firmware.bin -bm dio -bf 40 -bz 4M -bs .text -bp 4096 -ec -eo .pioenvs/d1_mini/firmware.elf -bs .irom0.text -bs .text -bs .data -bs .rodata -bc -ec
<lambda>(["upload"], [".pioenvs/d1_mini/firmware.bin"])
Auto-detected UPLOAD_PORT/DISK: /dev/cu.wchusbserial1420
"/Users/boneskull/.platformio/packages/tool-esptool/esptool" -vv -cd nodemcu -cb 115200 -cp /dev/cu.wchusbserial1420 -cf .pioenvs/d1_mini/firmware.bin
esptool v - (c) 2014 Ch. Klippel <[email protected]>
setting board to nodemcu
setting baudrate from 115200 to 115200
setting port from /dev/tty.usbserial to /dev/cu.wchusbserial1420
espcomm_upload_file
espcomm_upload_mem
opening port /dev/cu.wchusbserial1420 at 115200
tcgetattr
tcsetattr
serial open
opening bootloader
resetting board
trying to connect
setting character timeout 0
done
setting character timeout 1
done
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
trying to connect
setting character timeout 0
done
setting character timeout 1
done
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
espcomm_send_command: receiving 2 bytes of data
warning: espcomm_send_command: wrong direction/command: 0x01 0x07, expected 0x01 0x08
trying to connect
setting character timeout 0
done
setting character timeout 1
done
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
espcomm_send_command: receiving 2 bytes of data
warning: espcomm_send_command: wrong direction/command: 0x01 0x07, expected 0x01 0x08
resetting board
trying to connect
setting character timeout 0
done
setting character timeout 1
done
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
trying to connect
setting character timeout 0
done
setting character timeout 1
done
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
espcomm_send_command: receiving 2 bytes of data
espcomm_send_command: receiving 2 bytes of data
espcomm_send_command: receiving 2 bytes of data
espcomm_send_command: receiving 2 bytes of data
espcomm_send_command: receiving 2 bytes of data
espcomm_send_command: receiving 2 bytes of data
espcomm_send_command: receiving 2 bytes of data
espcomm_send_command: receiving 2 bytes of data
Uploading 242928 bytes from to flash at 0x00000000
erasing flash
size: 03b4f0 address: 000000
first_sector_index: 0
total_sector_count: 60
head_sector_count: 16
adjusted_sector_count: 44
erase_size: 02c000
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
setting timeout 15000
setting character timeout 150
done
setting timeout 1
setting character timeout 1
done
espcomm_send_command: receiving 2 bytes of data
writing flash
..............................................................................................................................................................................................................................................
starting app without reboot
espcomm_send_command: sending command header
espcomm_send_command: sending command payload
espcomm_send_command: receiving 2 bytes of data
closing bootloader
============================================ [SUCCESS] Took 32.69 seconds ============================================

If problems with PlatformIO Build System:

The content of platformio.ini:

#
# Project Configuration File
#
# A detailed documentation with the EXAMPLES is located here:
# http://docs.platformio.org/en/latest/projectconf.html
#

# A sign `#` at the beginning of the line indicates a comment
# Comment lines are ignored.

# Simple and base environment
# [env:mybaseenv]
# platform = %INSTALLED_PLATFORM_NAME_HERE%
# framework =
# board =
#
# Automatic targets - enable auto-uploading
# targets = upload

[env:d1_mini]
platform = espressif
framework = arduino
board = d1_mini
lib_install = 18, 19, 89

Source file to reproduce issue:

#include <ESP8266WiFi.h>
#include <Task.h>
#include <PubSubClient.h>
#include <Adafruit_Sensor.h>
#include <DHT_U.h>
#include <DHT.h>

#define SSID "SON OF ZOLTAR"
#define PASS "redacted"

#define CLIENT_ID "indoors"
#define DHT_PIN 4
#define DHT_TYPE DHT22

void waitForConnection(uint32_t delta);
void keepConnected(uint32_t delta);
void publishTemp(uint32_t delta);

TaskManager taskManager;
WiFiClient wifi;
PubSubClient mqtt;
DHT_Unified dht(DHT_PIN, DHT_TYPE);

FunctionTask taskWaitForConnection(waitForConnection, MsToTaskTime(250));
FunctionTask taskKeepConnected(keepConnected, MsToTaskTime(500));
FunctionTask taskPublishTemp(publishTemp, MsToTaskTime(1000));

/**
 * Returns `true` if WiFi is offline.
 */
bool offline() {
  return WiFi.status() != WL_CONNECTED;
}

float getTemperature() {
  sensors_event_t event;
  dht.temperature().getEvent(&event);
  return event.temperature;
}

void publishTemp(uint32_t delta) {
  float tempC = getTemperature();
  if (!isnan(tempC)) {
    float tempF = (tempC * 9/5) + 32.0;
    mqtt.publish("temp", String(tempF).c_str());
  }
}

/**
 * Pauses normal behavior and waits until we have a WiFi connection again,
 * then resumes.
 */
void waitForConnection(uint32_t delta) {
  if (!offline()) {
    Serial.println("Connected to " + String(SSID));
    taskManager.StopTask(&taskWaitForConnection);
    taskManager.StartTask(&taskKeepConnected);

    mqtt.setClient(wifi);
    mqtt.setServer("10.0.0.10", 1883);
    mqtt.connect(CLIENT_ID);

  }
}

/**
 * Connects to WiFi network.  Flashes colon quickly during this phase.
 */
void keepConnected(uint32_t delta) {
  if (offline()) {

    taskManager.StopTask(&taskKeepConnected);

    Serial.println("Connecting to " + String(SSID));
    WiFi.begin(SSID, PASS);

    taskManager.StartTask(&taskWaitForConnection);
  }
}

void setup() {
  Serial.begin(9600);
  WiFi.mode(WIFI_STA);
  dht.begin();
}

void loop() {
  taskManager.Loop();
}

Additional info

I have had some success uploading the built .bin with esptool.py.

@valeros
Copy link
Member

valeros commented Apr 12, 2016

Hi @boneskull !
We use the latest esptool (0.4.8) from Arduino ESP8266 (2.1.0) package.
Does uploading to your board work well in Arduino IDE? Which USB-UART bridge are you using?

@MichMich
Copy link

I've got the same issue as well. Impossible to upload to the D1 Mini. The Arduino IDE manages to upload from time to time, but gives a lot of problems too ... Maybe a driver issue for the D1's CH340G USB-UART bridge?

@ivankravets
Copy link
Member

Maybe need to ask @wemos or http://forum.wemos.cc ?

@MichMich
Copy link

There definitely is a difference between Platform and the Arduino IDE. The Arduino IDE manages to upload 25% of the time (so, it definitely has issues, but succeeds from time to time). Platform IO never manages to upload.

@valeros
Copy link
Member

valeros commented Apr 25, 2016

Could you please try this esptool? Just replace old one in /home/.platformio/packages/tool-esptool
Have you tried esptool.py as the alternative uploader?

@MichMich
Copy link

The esptool you link to, appears to be the one I'm using. I tried using esptool.py:

esptool.py --port /dev/cu.wchusbserial1440 write_flash 0x00000 .pioenvs/d1_mini/firmware.bin

But unfortunately, it fails to connect:

Connecting...
Traceback (most recent call last):
  File "/usr/local/bin/esptool.py", line 5, in <module>
    pkg_resources.run_script('esptool==0.1.0', 'esptool.py')
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 492, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 1357, in run_script
    exec_(script_code, namespace, namespace)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 47, in exec_
    exec("""exec code in globs, locs""")
  File "<string>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/esptool-0.1.0-py2.7.egg/EGG-INFO/scripts/esptool.py", line 471, in <module>

  File "/Library/Python/2.7/site-packages/esptool-0.1.0-py2.7.egg/EGG-INFO/scripts/esptool.py", line 149, in connect

Exception: Failed to connect

So this isn't a Platform issue, but really an issue with the WeMos. :(

@MichMich
Copy link

It turned out I was using a very old esptool.py, after upgrading esptool.py I am now able to upload using platform.io.

@MichMich
Copy link

Interesting. I found this pull request for the regular esptool: igrr/esptool-ck#29
I tried that pull request, and that one seems to work fine. Hopefully they merge that pull request soon.

@boneskull
Copy link
Author

I can confirm the PR @MichMich mentions fixes my problem.

@ivankravets
Copy link
Member

@MichMich @boneskull , please contact with @igrr and ask him to merge this PR igrr/esptool-ck#29

@MichMich
Copy link

Done!

@boneskull
Copy link
Author

@ivankravets I believe the fix was merged in esptool

@ivankravets ivankravets added this to the 2.10.4 milestone Jun 21, 2016
@ivankravets
Copy link
Member

@valeros the esptool has been released a few days ago. Please update all packages https://github.com/igrr/esptool-ck/releases/tag/0.4.9

@valeros
Copy link
Member

valeros commented Jun 21, 2016

Updated, thanks!

@valeros valeros closed this as completed Jun 21, 2016
ivankravets added a commit that referenced this issue Jul 6, 2016
* develop: (27 commits)
  Update boards list
  Add Arduino M0 as a separate board
  Update history
  Update microchippic32 platform and boards
  Fix PyLint warning
  Keep user changes for ".gitignore" file when re-generate/update project data
  Documented uploading of EEPROM data
  Push 2.11.1.dev1
  Automatically install dependent upload tools // Issue #472
  Split source files to HEADERS and SOURCES when generate project for Qt Creator IDE // Resolve #713
  Improve project generator for CLion IDE
  Fix missing trailing ``\`` for the source files list when generate project for Qt Creator IDE // Resolve #711
  * Fix missed ``--boot`` flag for the firmware uploader for ATSAM3X8E Cortex-M3 MCU based boards (Arduino Due, etc) // Resolve #710
  Initial support for Arduino M0/Tian boards // Issue #472
  Update project template for Qt Creator // Issue #711
  Fix missed --boot flag for sam3x uploader // Issue # 710
  Auto-remove project cache when PlatformIO is upgraded
  Version bump to 2.11.0 (issues #472, #520, #614, #620, #685, #698, #699)
  Update history
  Update espressif platform according to the new framework version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants