Skip to content

Add PlatformIO as alternative option to use ESP8266 core for Arduino #1197

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

Merged
merged 2 commits into from
Dec 12, 2015
Merged

Add PlatformIO as alternative option to use ESP8266 core for Arduino #1197

merged 2 commits into from
Dec 12, 2015

Conversation

ivankravets
Copy link
Collaborator

Hi @igrr,

Would be thankful to place some information about PlatformIO as alternative cross-platform builder to use ESP8266 core for Arduino on the popular host OS: Mac OS X, Windows, Linux 32/64, Linux ARM (like Raspberry Pi, BeagleBone, CubieBoard).

Don't hesitate to modify this PR.

Thanks in advance!

Hi @igrr,

Would be thankful to place some information about [PlatformIO[(http://platformio.org) as alternative cross-platform builder to use ESP8266 core for Arduino on the popular host OS: Mac OS X, Windows, Linux 32/64, Linux ARM (like Raspberry Pi, BeagleBone, CubieBoard).

Don't hesitate to modify this PR.

Thanks in advance!
@ivankravets ivankravets changed the title Add @PlatformIO as alternative option to use ESP8266 core for Arduino Add PlatformIO as alternative option to use ESP8266 core for Arduino Dec 11, 2015
@mangelajo
Copy link
Contributor

Very interesting, how does it work?

I tried it with my http://github.com/ohaut/photon project, and I almost got it to work, but it fails to find some floating point functions:

xtensa-lx106-elf-g++ -o .pioenvs/esp12e/firmware.elf -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,register_chipv6_phy -Wl,-T /Users/ajo/.platformio/packages/ldscripts/esp8266.flash.4m.ld .pioenvs/esp12e/src/tmp_ino_to.o -L/Users/ajo/.platformio/packages/framework-arduinoespressif/tools/sdk/lib -L.pioenvs/esp12e -Wl,--start-group -lsmartconfig -lpp -lmain -lwpa -llwip -lnet80211 -lwps -lcrypto -lphy -lhal -laxtls -lgcc -lm .pioenvs/esp12e/libFrameworkArduinoVariant.a .pioenvs/esp12e/libFrameworkArduino.a .pioenvs/esp12e/libESP8266WiFi.a .pioenvs/esp12e/libESP8266mDNS.a .pioenvs/esp12e/libArduinoOTA.a .pioenvs/esp12e/libPubSubClient.a .pioenvs/esp12e/libTicker.a .pioenvs/esp12e/libESP8266WebServer.a -Wl,--end-group
/Users/ajo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib/libm.a(lib_a-e_pow.o):(.literal+0x100): undefined reference to __ieee754_sqrt' /Users/ajo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/lib/libm.a(lib_a-e_pow.o): In function__ieee754_pow':
e_pow.c:(.text+0x256): undefined reference to `__ieee754_sqrt'
collect2: error: ld returned 1 exit status
scons: *** [.pioenvs/esp12e/firmware.elf] Error 1

How does it work?, do you grab the esp8266/Arduino SDK libraries?

@ivankravets
Copy link
Collaborator Author

@mangelajo give me a few minutes I'll switch to @igrr toolchain for Mac OS X. I'll report here.

@ivankravets
Copy link
Collaborator Author

How does it work?

Ok, let's play with your project.

cd /tmp
wget https://github.com/ohaut/photon/archive/master.zip
unzip master.zip
# let's rename folder and init project here
# you can left this photon dir and override `src` dir. See docs for `platformio.ini/src_dir`
mv photon-master/firmware/photon photon-master/firmware/src

# update PlatformIO packages (I've just updated xtensa toolchain)
platformio update

# install dependent libary
# http://platformio.org/#!/lib/show/89/PubSubClient
platformio lib install 89

# init project
platformio init -d photon-master/firmware -b esp12e
# process
platformio run -d photon-master/firmware/
# upload
platformio run -d photon-master/firmware/ -t upload

If you want to upload using OTA then you need one of


Use development version @platformio 2.5.1.dev0 where OTA is implemented by default. Just specify --upload-port IP. PlatformIO 2.5.1 is planned for release on December 15, 2015.


Use stable PlatformIO 2.5.0 and create extra_script, see platformio/platformio-core#365 (comment)
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 --debug --progress -i $UPLOAD_PORT -p 8266 -f $SOURCE'
)

Specify extra_script in platformio.ini, for example

[env:esp12e]
platform = espressif
framework = arduino
board = esp12e
upload_port = 127.0.0.1
extra_script = platformio_extra_script.py

@mangelajo does it work for you?

@mangelajo
Copy link
Contributor

wow @ivankravets , thanks for the comprehensive details. With @igrr toolchain it does compile. I tried the dev version and it does upload too.

By "how does it work", I was meaning, if platformio does pull the Arduino sdk here in esp8266/Arduino with it's libs, etc, or the stable/stagging version published for the arduino dev env. (just to know which version of the libs does use, how to use master from esp8266/Arduino etc...).

I personally prefer cmdline over arduino dev env... :)

@mangelajo
Copy link
Contributor

👍

@ivankravets
Copy link
Collaborator Author

By "how does it work", I was meaning, if platformio does pull the Arduino sdk here in esp8266/Arduino with it's libs, etc, or the stable/stagging version published for the arduino dev env.

@platformio uses stable software. It means that current version of Arduino framework for Espressif is dated Nov 30, 2015. To check version of installed software by PlatformIO Package Manager please go to ~/.platformio/packages/framework-arduinoespressif/version.txt.

PlatformIO doesn't depend on Arduino IDE, make, cmake or system package manager. It has own super-fast code builder, built-in package and library managers and CDN Cloud Storage for pre-compiled tools, toolchains, frameworks. It allows PlatformIO to have THE SAME behaviour on the popular host OS (including ARM-based card-sized PC).

PlatformIO is totally isolated ecosystem. The only one requirement is Python Interpreter, because PlatformIO is written in Python.

I welcome you to read our docs What is PlatformIO? How does it work?

igrr added a commit that referenced this pull request Dec 12, 2015
Add PlatformIO as alternative option to use ESP8266 core for Arduino
@igrr igrr merged commit a23cb9c into esp8266:master Dec 12, 2015
@ivankravets
Copy link
Collaborator Author

Thanks a lot @igrr! 👍

@mangelajo
Copy link
Contributor

@ivankravets
Hi, I updated to latest devel version of platformio, and I got into this (I saw ld scripts were updated)

/Users/ajo/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: .pioenvs/esp12e/firmware.elf section .text' will not fit in regioniram1_0_seg

I guess I shall report an issue to platformio,

Can I see where the ldscripts are?, I'd like to review latest changes to the esp platform

Cheers.

@ivankravets
Copy link
Collaborator Author

Hi @mangelajo,

Do you use the latest PlatformIO 2.6? Also, did you update all packages via platformio update?

The ld scripts are located in ~/.platformio/packages/ldscripts. You can see full path to LD script in linker command -Wl,-T/path/to/ld

@ivankravets
Copy link
Collaborator Author

@mangelajo, Please report this issue to @platformio repository. Thanks.

@mangelajo
Copy link
Contributor

@ivankravets, thanks. platformio/platformio-core#377

I did sudo python setup.py install from platformio master, and on the first run it automatically updated the ldscripts.

I mean, not where they are stored locally, but does platformio have any git repository for it where we can track changes or submit fixes?

@ivankravets
Copy link
Collaborator Author

See previous version http://sourceforge.net/projects/platformio-storage/files/packages/ldscripts-14.tar.gz/download

To check version of installed packages use platformio platforms show espressif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants