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

.ld scripts refactoring #1559

Merged
merged 39 commits into from
Aug 5, 2019
Merged

.ld scripts refactoring #1559

merged 39 commits into from
Aug 5, 2019

Conversation

mcspr
Copy link
Collaborator

@mcspr mcspr commented Feb 19, 2019

Fixes arduino/Arduino#1260

  • distribute two sets of ldscripts
  • automatically pick proper ldscript via platformio python extra script
  • additional flash sizes for Generic board
  • float support ON/OFF menu option for IDE
  • ldscript generator (sector calculation included, based on boards.txt.py script from Core)

Arduino IDE (only tested with 2.5.0 release):

copy proper ldscripts into the <esp8266-package-dir>/tools/sdk/ld
copy boards.local.txt into the <esp8266-package-dir>
run / restart IDE, select ESPurna board in the menu

PlatformIO

same as above, but happens automatically
added platform = ${common.arduino_core_git} and platform = ${common.arduino_core_2_5_0} to allow testing with the newest Core

TODO

boards.local.txt generator script Done
ldscript generator Done
maybe try to find out different way to detect core version (platform.txt? parse framework package version?) Done (Checking 'local....' presence)

@mcspr mcspr requested a review from xoseperez February 19, 2019 03:17
@mcspr
Copy link
Collaborator Author

mcspr commented Feb 19, 2019

Also trying out draft PRs.
I do not see travis build, so here it is: https://travis-ci.org/mcspr/espurna/builds/495245870

@mcspr
Copy link
Collaborator Author

mcspr commented Feb 22, 2019

When building from IDE, it generates special string that describes settings. Like this:

$ grep fqbn $TMP/arduino_build_446496/build.options.json
"fqbn": "esp8266com:esp8266:espurna:xtal=160,vt=flash,exceptions=disabled,ResetMethod=ck,CrystalFreq=26,FlashFreq=40,FlashMode=dout,ip=lm2f,float_support=disabled,variant=esp8285,eesz=1M,wipe=none,baud=115200"

If board definition has some defaults (espurna.build.f_cpu=80 instead of espurna.menu.blablabla.80.build.f_cpu=80), it is possible to launch cli tools with fqbn just being esp8266com:esp8266:espurna to build "default" flavour.
https://github.com/arduino/arduino-builder, arguments for which can be copied from IDE build log
https://github.com/arduino/arduino-cli, which is merciful and only wants fqbn setting

Ofc it is not compatible between versions (search SUBSTITUTIONS in boards script)

@Niek
Copy link
Contributor

Niek commented Apr 9, 2019

I think it's possible to pre-process the LD files with the compiler and use something like DEFINED(ARDUINO_ESP8266_RELEASE_2_5_0) to include the correct file. See https://sourceware.org/binutils/docs/ld/Builtin-Functions.html#Builtin-Functions

@mcspr
Copy link
Collaborator Author

mcspr commented Apr 11, 2019

But binutils DEFINED and preprocessor defined() are different things. That is a linker script level expression, checking if symbol exists. Example given uses ternary expression to assign symbol some default value. And even then, are there global level if/else expressions to use it?

But we can do something like this:

$ cat check.sh.in
#include <core_version.h>
#if defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_2)
echo old
#else
echo new
#endif
$ cc -x c -P -E -I~/.platformio/packages/framework-arduinoespressif8266@2.20402.2/cores/esp8266 check.sh.in -o check.sh
$ bash check.sh
old

BTW, Arduino Core does use preprocessor to generate that file

@Niek
Copy link
Contributor

Niek commented Apr 11, 2019

OK, I haven't tested too much with the DEFINED() in binutils.

Another option would be to use regular C #define statements in the ld files and preprocess them with something like gcc -E -x c -C eagle.flash.1m0m1s.ld | grep -v "^# " - but the bash script probably makes more sense.

@mcspr mcspr marked this pull request as ready for review April 23, 2019 23:02
@mcspr mcspr changed the title WIP .ld scripts refactoring .ld scripts refactoring Apr 23, 2019
@mcspr mcspr added this to the 1.13.6 milestone May 6, 2019
dist/boards_local_txt.py Outdated Show resolved Hide resolved
dist/ld/README.txt Outdated Show resolved Hide resolved
@Niek
Copy link
Contributor

Niek commented Jul 13, 2019

That diff is exactly what I have now in my linker script, and it works fine (with PIO). Either that or utils.ino and eeprom need to be ifdef-ed with the correct macro name.
By the way is anybody seriously building Espurna with IDE? I tried it once but it takes an hour to gather all dependencies with the correct versions etc. PIO is just so much better IMHO.

@mcspr
Copy link
Collaborator Author

mcspr commented Jul 14, 2019

Yeah, and an interesting note from the Tasmota issue tracker:
arendst/Tasmota#6073 (comment)

We do reference include inside tools/sdk/ld, so it does (?) work ok, or at least how it always worked before. But, we can't exactly not use them with 2.3.0 and rely on default scripts. We still need those aliases for some time, so I'll add this as a temporary solution (and to speed up -git builds setup time)

I'll try to come up with a reasoning for Core issue tracker and open an issue there regarding FS... symbols usage (or some other way to use them through helper methods)
Rotate lib can be forked or imported inside / be submodule / lib header
boards.local kind of solves this too, since our scripts have different names

@mcspr mcspr merged commit 437424a into xoseperez:dev Aug 5, 2019
@mcspr mcspr deleted the arduino/ldscripts branch August 5, 2019 16:44
@Niek
Copy link
Contributor

Niek commented Sep 30, 2019

FYI the SPIFFS symbols have been added to core as well now: esp8266/Arduino@418b00f

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.

A proposal for more than one client in the Ethernet Shield acting as a server.
2 participants