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

More detailed instructions #1

Open
patrickelectric opened this issue Jan 29, 2017 · 6 comments
Open

More detailed instructions #1

patrickelectric opened this issue Jan 29, 2017 · 6 comments

Comments

@patrickelectric
Copy link

Hello, it's possible to update the doc to make more friendly to new users ?
I don't know if the problem is I that cannot make the compilation work or the project.
Best regards.

@SuperMarcus
Copy link

I would like to know more about this project too!
It'll be great if @rpoisel can make this more documented

@kxygk
Copy link

kxygk commented Mar 28, 2017

This almost made my eyes bleed, but I made it work after hacking at it for the whole evening

here is the rough outline:
(some of these steps might be redundant... but it's an ugly hack and it works. I don't know how to do this properly b/c CMake fights me at every step)

  • git clone this repo recursively

  • clone the Arduino ESP somewhere else
    https://github.com/esp8266/Arduino/

  • in the Arduino directory run build.py (it's under Arduino/tools)

  • add the compiler path to your PATH
    this will be something like 'Arduino/tools/xtensa-lx106-elf/bin/'
    it'll have all your GNU toolchain stuff with an xtensa-lx106-elf in the front:
    xtensa-lx106-elf-g++ and xtensa-lx106-elf-objcopy etc.
    (there is also Arduino/tools/xtensa-lx106-elf/xtensa-lx106-elf/bin/ ... but I don't know what that is really. It seems to be an x86 toolchain)

  • next are the horrible parts:
    There is a variable that tells CMake where the Arduino directory is:
    you can see it all over esp8266-cmake/CMakeLists.txt
    it's ARDUINO_ESP8266_DIR
    something about the CMake magic make it so that ccmake and KDevelop just won't show it to me. So I had to run cmake from the command line
    ie something like

cd esp8266-cmake
cmake -DARDUINO_ESP8266_DIR=path-to-arduino-directory/Arduino/ .

okay, but before you do that, there is more to fix!
CMake is really dumb and will repeatedly try to using your system compiler (/usr/bin/cc /usr/bin/c++)
I wasn't able to make it stop being dumb, so I forced it to use the xtensa tools
at the top of esp8266-cmake/CMakeLists.txt
I now have:

set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_FORCE_C_COMPILER xtensa-lx106-elf-gcc GNU)
set(CMAKE_FORCE_CXX_COMPILER xtensa-lx106-elf-g++ GNU)

project(ArduinoBuild VERSION 0.9.0 LANGUAGES C CXX ASM)
[...]

oh but we're not finished!
the last step is you need to go to esp8266-cmake/arduino/CMakeLists.txt
here there is a line:

install(DIRECTORY cmake/ DESTINATION cmake FILES_MATCHING PATTERN "toolchain.*.cmake")

this is actually what's was supposed to switch CMake to use the correct toolchain from the beginning, but for some reason it doesn't work. Nevertheless it's doing someother stuff that you need, so you need to change that line to be

include("cmake/toolchain.ESP8266.cmake")

Now you can run

cd esp8266-cmake
cmake -DARDUINO_ESP8266_DIR=path-to-arduino-directory/Arduino/ .
make

and you should get your libarduino.a

tomorrow I might actually try to link it to a program like in this example:
https://github.com/rpoisel/esp8266-arduino-oled-mqtt

but this is such a hack.. that I'm really tempted to drop it. The real benefit would be clean integration with KDevelop (and probably CLion) - but it might not be worth it b/c it's such a mess

if anyone can clean this up so it's usable, please let me know. I feel like @rpoisel has done 99% of the work here and someone with a bit more CMake knowledge could fix this in no-time

@o1eksiy
Copy link

o1eksiy commented Apr 7, 2017

@geokon-gh, you wrote add the compiler path to your PATH. You meant that we need to copy all files from this folder Arduino/tools/xtensa-lx106-elf/bin/ to the esp8266-cmake folder. Right?

@kxygk
Copy link

kxygk commented Apr 10, 2017

@o1eksiy
no no. The PATH variable is a Linux variable that tells the system when to look for executables.
What you're saying will work (though it's messy) but normally you just do
PATH=$PATH:path-to-toolchain-and-stuff/xtensa-lx106-elf/bin/
in your .bashrc
you may need an
export PATH

just look up "adding directories to your PATH variable on Linux" or something to that effect

@o1eksiy
Copy link

o1eksiy commented Apr 10, 2017

@geokon-gh, thanks for the respond!
On the last step
cmake -DARDUINO_ESP8266_DIR=/opt/arduino-1.6.8 .
I got

CMake Error at CMakeLists.txt:5 (project):
  VERSION not allowed unless CMP0048 is set to NEW
-- Configuring incomplete, errors occurred!

As I understood I should to use arduino 0.9.0, right?

@kxygk
Copy link

kxygk commented Apr 11, 2017

... I didn't have this issue
Look at line 5 of CMakeLists.txt .. see what's triggering it. Maybe you can remove the VERSION line?
Look up CMP0048 .. maybe it'll give you some clues?

I didn't mean to provide an install tutorial or something. Just a rough guideline. This repository isn't ready for general use in it's current form and it seems to have been sorta abandoned by it's original author. @rpoisel uses it in his other projects. Look at his repositories that start with "esp8266-". They usually depend on this library, so they may work more "out of the box". Just recursively clone them and see if it works

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

No branches or pull requests

4 participants