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

Espressif : upload to IP address (OTA) #365

Closed
itsjustvenky opened this issue Dec 9, 2015 · 33 comments
Closed

Espressif : upload to IP address (OTA) #365

itsjustvenky opened this issue Dec 9, 2015 · 33 comments
Assignees
Milestone

Comments

@itsjustvenky
Copy link

Quickstart

OTA firmware uploading is implemented in PlatformIO 2.6.

Please use PlatformIO 2.6 or above and official ESP8266 documentation https://github.com/esp8266/Arduino/blob/master/doc/platformio.md


using Arduino IDE I can upload a ESP sketch over OTA to a remote ESP using command

python.exe C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266/tools/espota.py -i 192.168.0.105 -p 8266 -f 
C:\Users\VENKAT~1.VEN\AppData\Local\Temp\build1686115882947863985.tmp/BasicOTA.cpp.bin 

Is there a way to do this in platformio

thanks
Venkatesh

@itsjustvenky itsjustvenky changed the title esptool upload to IP address (OTA) Espressif : upload to IP address (OTA) Dec 9, 2015
@valeros
Copy link
Member

valeros commented Dec 9, 2015

Hi @itsjustvenky
espota.py is located here: c:\Users\User\.platformio\packages\framework-arduinoespressif\tools\espota.py
Firmware binary file is located here: path_to_project\.pioenv\env\firmware.bin

@ivankravets
Copy link
Member

See here how to define own uploader http://docs.platformio.org/en/latest/projectconf.html#extra-script and related issue #351 (comment)

@itsjustvenky
Copy link
Author

@valeros @ivankravets thank you.

@itsjustvenky
Copy link
Author

Sorry one more question : Can I set the value of properties like this "$UPLOADER" inside platformio.ini ? it seems to be not working. Also can I create a new properties like UPLOADER_IP_OTA and use it in script ? please let me know. thanks.

@itsjustvenky itsjustvenky reopened this Dec 10, 2015
@ivankravets
Copy link
Member

Can I set the value of properties like this "$UPLOADER" inside platformio.ini

No, you can't. The only way is extra script.

can I create a new properties like UPLOADER_IP_OTA and use it in script

For example, platformio.ini

[env:***]
...
UPLOADER_IP_OTA = 127.0.0.1
...

Yes, you can. To get this value inside extra script use ARGUMENTS.get("UPLOADER_IP_OTA")


The OTA solution

  • platformio_extra_script.py - place it near platformio.ini
from os.path import join
from SCons.Script import DefaultEnvironment

env = DefaultEnvironment()

env.Replace(
    UPLOADEROTA=join("$PIOPACKAGES_DIR",
                     "framework-arduinoespressif", "tools", "espota.py"),
    UPLOADCMD='$UPLOADEROTA -i $UPLOAD_PORT -p 8266 -f $SOURCE'
)
  • Specify extra_script in platformio.ini, for example
[env:esp01]
platform = espressif
framework = arduino
board = esp01
build_flags = -Wl,-T${PIOPACKAGES_DIR}/ldscripts/esp8266.flash.1m64.ld
upload_port = 127.0.0.1
extra_script = platformio_extra_script.py

To print current environment of @platformio builder use platformio run --target envdump

@itsjustvenky
Copy link
Author

@ivankravets Thanks for the solution.

@ivankravets
Copy link
Member

Does it work for you?

@itsjustvenky
Copy link
Author

Nope.

I added lines exactly what you have given in above comments.

I used this command in script : print env['CPPDEFINES']
and the output is

['F_CPU=$BOARD_F_CPU', '__ets__', 'ICACHE_FLASH', 'ARDUINO_ESP8266_ESP01', 'ARDUINO_ARCH_ESP8266', 'ESP8266', 'ARDUINO=200', ['UPLOADER_IP_OTA', 'HELLO'], 'PLATFORMIO=020500']

When I use this command : print env['CPPDEFINES'].get("UPLOADER_IP_OTA")
I am seeing this error

AttributeError: 'list' object has no attribute 'get'

From above I can see "CPPDEFINES" is a list and with exception to one value "UPLOADER_IP_OTA", which is dictionary value.

please suggest. thanks.

@ivankravets
Copy link
Member

@itsjustvenky I've just got what do you need. See updated #365 (comment)

I didn't test it. Please report me if it doesn't work.

@ivankravets
Copy link
Member

I've just updated again my comment. Looks like you don't need to create own board. You can override LD script using build_flags.

@ivankravets ivankravets self-assigned this Dec 10, 2015
@ivankravets
Copy link
Member

See TOTALY updated comment. Please use that solution #365 (comment)

@itsjustvenky
Copy link
Author

@ivankravets Thank you so much. OTA works now with the configuration from platformio.ini. Appreciated!!!

@ivankravets
Copy link
Member

Thanks for the report. Ok, let's explain what have you changed. Do you use standard PlatformIO packages?

@ivankravets ivankravets added this to the 2.5.1 milestone Dec 10, 2015
@itsjustvenky
Copy link
Author

I am still on SDK v1.4.. apart from this everything I reverted back.

@ivankravets
Copy link
Member

Where did you replace this SDK v1.4?

@itsjustvenky
Copy link
Author

I have complete overwritten these two folders with 1.4 SDK (esp-open-sdk).

~/.platformio/packages/sdk-esp8266
~/.platformio/packages/toolchain-xtensa

Here is the board I have created.

{
   "esp01-1m": {
        "build": {
            "core": "esp8266",
            "extra_flags": "-DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_ESP8266 -DESP8266",
            "f_cpu": "80000000L",
            "ldscript": "esp8266.flash.1m128.ld",
            "mcu": "esp8266",
            "variant": "generic"
        },
        "frameworks": ["arduino"],
        "name": "Espressif ESP8266 ESP-01-1MB board",
        "platform": "espressif",
        "upload": {
            "maximum_ram_size": 32768,
            "maximum_size": 1048576,
            "protocol": "arduino",
            "require_upload_port" : true,
            "speed": 115200
        },
        "url": "https://nurdspace.nl/ESP8266",
        "vendor": "Espressif"
    }
}

@itsjustvenky
Copy link
Author

Extra script for Arduino-OTA

from os.path import join
from SCons.Script import DefaultEnvironment

env = DefaultEnvironment()

env.Replace(
    UPLOADEROTA=join("$PIOPACKAGES_DIR",
                     "framework-arduinoespressif", "tools", "espota.py"),
    UPLOADCMD='$UPLOADEROTA -i $UPLOAD_PORT -p 8266 -f $SOURCE --debug --progress'
)

I have added two other option's to command line, DEBUG and PROGRESS.

@ivankravets
Copy link
Member

I have complete overwritten these two folders with 1.4 SDK (esp-open-sdk).
~/.platformio/packages/sdk-esp8266
~/.platformio/packages/toolchain-xtensa

Why did you replace these packages? ~/.platformio/packages/sdk-esp8266 isn't used in your example because Espressif Arduino contains own version of SDK See ~/.platformio/packages/framework-arduinoespressif/tools/sdk.

Ok, please make these changes:

  1. Backup ~/.platformio/boards folder which you created for esp01-1m
  2. Remove ~/.platformio directory
  3. Run your example, PlatformIO should install stable frameworks, toolchains. Then place boards folder back.

Thanks!

@itsjustvenky
Copy link
Author

@ivankravets Sorry for the confusion. Please ignore the SDK part. I reverted everything back to how it was installed by platformio (followed your above steps). thanks.

@ivankravets
Copy link
Member

I reverted everything back to how it was installed by platformio (followed your above steps). thanks.

Does it work?

@itsjustvenky
Copy link
Author

Yes Arduino OTA works fine.

One more thing : in file "~/.platformio/packages/sdk-esp8266/version.txt" I see

esp_iot_sdk_v1.2.0_15_07_03

But the actual SDK version @platformio provides is 1.3.. right ?

@itsjustvenky
Copy link
Author

If the "build_flags" is set in "platformio.ini", then it overrides the "ldscript" in custom boards json file.

@ivankravets
Copy link
Member

But the actual SDK version @platformio provides is 1.3.. right ?

The actual is esp_iot_sdk_v1.2.0_15_07_03

If the "build_flags" is set in "platformio.ini", then it overrides the "ldscript" in custom boards json file.

Yes

P.S: Wait from me new PlatformIO 2.5.1.dev0 where all these features are implemented.

@itsjustvenky
Copy link
Author

so you mean to say "esp_iot_sdk_v1.2.0_15_07_03" = 1.3 ?

@itsjustvenky
Copy link
Author

In my arduino (ide) sdk version it is "1.3.0_15_08_10_p1" (arduino esp8266 sdk 2.0.0)

@ivankravets
Copy link
Member

@itsjustvenky please don't mix ~/.platformio/packages/sdk-esp8266 and ~/.platformio/packages/framework-arduinoespressif/tools/sdk. If you specify framework = arduino in platformio.ini then PlatformIO uses SDK from Espressif Arduino Framework, otherwise for native project will be used ~/.platformio/packages/sdk-esp8266. See example https://github.com/platformio/platformio/tree/develop/examples/espressif/esp8266-native

@ivankravets
Copy link
Member

I've just pushed new development version of PlatformIO 2.5.1.dev0.

  1. Please remove own boards folder from PIO home
  2. Install development version http://docs.platformio.org/en/latest/installation.html#d-development-version
  3. Remove from your project extra scripts and left only
[env:esp01_1m]
platform = espressif
framework = arduino
board = esp01_1m
upload_port = YOUR_DEVICE_IP_HERE

Waiting for the feedback. If you need additional flags to uploader see http://docs.platformio.org/en/latest/projectconf.html#upload-flags

@itsjustvenky
Copy link
Author

Installed dev version

venkat@venkat-VirtualBox:~$ platformio --version
PlatformIO, version 2.5.1.dev0

Test the Arduino-OTA and worked correctly.

Question : How do I revert back to 2.5.0 (release) ? if I want to

@ivankravets
Copy link
Member

Test the Arduino-OTA and worked correctly.

Thanks!

Question : How do I revert back to 2.5.0 (release) ? if I want to

pip uninstall platformio
pip install platformio

@itsjustvenky
Copy link
Author

venkat@venkat-VirtualBox:~/Projects/platformio/esp8266/esp01-1mdev$ platformio run  --target upload
[Fri Dec 11 20:47:10 2015] Processing esp01_1m (platform: espressif, upload_port: 192.168.0.105, board: esp01_1m, framework: arduino)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
BeforeUpload(["upload"], [".pioenvs/esp01_1m/firmware.bin"])
/home/venkat/.platformio/packages/framework-arduinoespressif/tools/espota.py --debug --progress -i 192.168.0.105 -f .pioenvs/esp01_1m/firmware.bin
20:47:11 [DEBUG]: Options: {'esp_ip': '192.168.0.105', 'image': '.pioenvs/esp01_1m/firmware.bin', 'auth': '', 'esp_port': 8266, 'spiffs': False, 'debug': True, 'progress': True}
20:47:11 [INFO]: Starting on 0.0.0.0:37848
20:47:11 [INFO]: Upload size: 226208
20:47:11 [INFO]: Sending invitation to: 192.168.0.105
20:47:11 [INFO]: Waiting for device...
Uploading: [============================================================] 100% Done...

20:47:16 [INFO]: Waiting for result...
20:47:16 [INFO]: Result: OK
============================================================================= [SUCCESS] Took 6.55 seconds =============================================================================
venkat@venkat-VirtualBox:~/Projects/platformio/esp8266/esp01-1mdev$ 

@itsjustvenky
Copy link
Author

@ivankravets thanks for all the help.

@itsjustvenky
Copy link
Author

Are you planning to release 2.5.1 anytime soon ?

@ivankravets
Copy link
Member

Are you planning to release 2.5.1 anytime soon ?

See https://github.com/platformio/platformio/milestones . Release is planned on December 15, 2015

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

3 participants