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

Cmake source prep and building #46

Merged
merged 47 commits into from
Nov 29, 2021
Merged

Cmake source prep and building #46

merged 47 commits into from
Nov 29, 2021

Conversation

mcspr
Copy link
Collaborator

@mcspr mcspr commented Feb 10, 2020

As mentioned in the other issue, this is general cmake setup to handle lwip2 source directory, it's patching and building liblwip.a for the esp8266/Arduino project.
How this works:

$ mkdir build
$ cd build/
$ cmake ../ -DARDUINO_DIR=<PATH_TO_THE_ARDUINO_CORE_ROOT> -DCMAKE_PROGRAM_PATH=<PATH_TO_TOOLCHAIN_BIN_DIRECTORY>
$ cmake --build .
# or just `make`
# also, see `make help`

By default, build script will place the resulting library into the output/lib. This can be changed via -DLIB_INSTALL_DIR=<PATH-TO-TOOLS-SDK> (without the lib/, which is appended implicitly by the cmake tools. Not yet sure what is up with that and how to have a single one prefix configuration)
edit: or, DESTDIR=..., which I even forgot about. but that need undo'ing the manual directory management in builder externalproject declaration

  • cmake/toolchain.cmake, cmake/esp8266-platform.cmake handle the toolchain part. cflags are taken from an existing makefile definitons
  • cmake/builder.cmake builds glue+lwip in the same step, combining .o as liblwip. Following lwip2 build guidelines:
    http://git.savannah.nongnu.org/cgit/lwip.git/tree/BUILDING
    http://git.savannah.nongnu.org/cgit/lwip/lwip-contrib.git/tree/ports/unix/example_app/CMakeLists.txt
    lwip project already provides lwip2-src/src/Filelists.cmake, and simply by including it registers lwipcore library with a proper source list. Additional modules config is taken from the same file definitions, simply appending module variable to the lwipcore target sources list
  • cmake/lwip<name>/CMakeLists.txt are supposed to be for-loop replacement from the current makefile, listing things instead of dynamically generating them each time. see scripts/cmake-generate
  • Root CMakeLists.txt manages generated headers (err_t and hash string, see glue-lwip/*.h.in) and lwip2-src (upkeep, checkout, patch) and building each cmake/lwip<name>
    scripts/clean-lwip2-src and scripts/patch-lwip2-src are moved from makefile steps to handle patch invocation and git checkout & git clean

I don't think it is intended to replace existing setup (and with opensdk even wise to do so), but simply to have a general view of how the stuff works. Things are commented as much as possible, pinpointing some questions / problems / quirks with an existing setup.

@mcspr
Copy link
Collaborator Author

mcspr commented Feb 11, 2020

edit: see README-CMake.md

@d-a-v
Copy link
Owner

d-a-v commented Feb 17, 2020

Should the windows instructions be stored in this repo, in PIO repo, or in Tasmota repo ?

Should the basic instructions be put on a README.cmake file ?

I just tried on linux and compilation works (I have not tested the generated files though).

However I would rename the variable ARDUINO_DIR to ESP8266_ARDUINO_CORE_DIR (because I made it point to the arduino IDE directory the first time I tried - until I realised that one of the points of PIO is to avoid the Arduino IDE :).

I don't know in PIO how things work, but if tools/get.py script is run, compiler is then installed in $(ESP8266_ARDUINO_CORE_DIR)/tools/xtensa-lx106-elf/bin which makes (in that case) CMAKE_PROGRAM_PATH a duplicate configuration parameter.

@mcspr
Copy link
Collaborator Author

mcspr commented Feb 17, 2020

Should the windows instructions be stored in this repo, in PIO repo, or in Tasmota repo ?
Should the basic instructions be put on a README.cmake file ?

Makes sense to update Building section? PIO is just a shortcut for getting toolchain + esp8266 Core files in the same step. edit: In any case, I will move build instructions (keeping in mind both IDE and PIO)

Windows part too, I think? But I am failing hard at patching though:

  • when git clones lwip2 source with crlf line endings.
  • here is also something about git-apply that makes it fail on 0003-dhcp-dhcp6-Ensure-that-DHCP-DHCPv6-DNS-server-update.patch (assuming it is the correct order: 0001, 0002, 0003, everything else alphabetically). Generating full patch from git-format worked though, after using patch and committing the result

I just tried on linux and compilation works (I have not tested the generated files though).

Resulting firmware worked for me btw.

However I would rename the variable ARDUINO_DIR to ESP8266_ARDUINO_CORE_DIR (because I made it point to the arduino IDE directory the first time I tried - until I realised that one of the points of PIO is to avoid the Arduino IDE :).

I don't know in PIO how things work, but if tools/get.py script is run, compiler is then installed in $(ESP8266_ARDUINO_CORE_DIR)/tools/xtensa-lx106-elf/bin which makes (in that case) CMAKE_PROGRAM_PATH a duplicate configuration parameter.

Makes sense, will rename and try to search for files there beforehand. And I also haven't done "release" install target yet to copy headers to the Core directory

PIO toolchain and framework are separate packages:

  • ~/.platformio/packages/toolchain-xtensa
  • ~/.platformio/packages/framework-arduinoespressif8266
    As there could be multiple versions of the same package installed (with @version suffixes) and user can easily swap those in platformio.ini project config file

@mcspr
Copy link
Collaborator Author

mcspr commented Feb 21, 2020

  • put generated, glue dhcpserver and lwip2 headers into the tools/sdk/lwip2
  • "this was generated" README

cmake/package now handles header generation and installation and is loaded as externalproject. Reason for doing that is that external project target will automatically install everything and we don't need to have to do make install, everything is installed just by running make

@mcspr
Copy link
Collaborator Author

mcspr commented Jul 29, 2021

Have not tested that the binaries actually work, but patches apply and everything seems to be merged together correctly on Windows. And b/c it was 2y ago, need to go over the CFLAGS, lwipopts.h, etc. and check whether those are actually the same as the Makefile build

There are also these after the install phase, in the esp8266 repo:

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        tools/sdk/lwip2/include/compat/
        tools/sdk/lwip2/include/lwip/altcp.h
        tools/sdk/lwip2/include/lwip/altcp_tcp.h
        tools/sdk/lwip2/include/lwip/altcp_tls.h
        tools/sdk/lwip2/include/lwip/apps/altcp_proxyconnect.h
        tools/sdk/lwip2/include/lwip/apps/altcp_tls_mbedtls_opts.h
        tools/sdk/lwip2/include/lwip/apps/fs.h
        tools/sdk/lwip2/include/lwip/apps/http_client.h
        tools/sdk/lwip2/include/lwip/apps/httpd.h
        tools/sdk/lwip2/include/lwip/apps/httpd_opts.h
        tools/sdk/lwip2/include/lwip/apps/lwiperf.h
        tools/sdk/lwip2/include/lwip/apps/mqtt.h
        tools/sdk/lwip2/include/lwip/apps/mqtt_opts.h
        tools/sdk/lwip2/include/lwip/apps/mqtt_priv.h
        tools/sdk/lwip2/include/lwip/apps/netbiosns.h
        tools/sdk/lwip2/include/lwip/apps/netbiosns_opts.h
        tools/sdk/lwip2/include/lwip/apps/smtp.h
        tools/sdk/lwip2/include/lwip/apps/smtp_opts.h
        tools/sdk/lwip2/include/lwip/apps/snmp.h
        tools/sdk/lwip2/include/lwip/apps/snmp_core.h
        tools/sdk/lwip2/include/lwip/apps/snmp_mib2.h
        tools/sdk/lwip2/include/lwip/apps/snmp_opts.h
        tools/sdk/lwip2/include/lwip/apps/snmp_scalar.h
        tools/sdk/lwip2/include/lwip/apps/snmp_snmpv2_framework.h
        tools/sdk/lwip2/include/lwip/apps/snmp_snmpv2_usm.h
        tools/sdk/lwip2/include/lwip/apps/snmp_table.h
        tools/sdk/lwip2/include/lwip/apps/snmp_threadsync.h
        tools/sdk/lwip2/include/lwip/apps/snmpv3.h
        tools/sdk/lwip2/include/lwip/apps/tftp_opts.h
        tools/sdk/lwip2/include/lwip/apps/tftp_server.h
        tools/sdk/lwip2/include/netif/bridgeif.h
        tools/sdk/lwip2/include/netif/bridgeif_opts.h
        tools/sdk/lwip2/include/netif/ieee802154.h
        tools/sdk/lwip2/include/netif/lowpan6.h
        tools/sdk/lwip2/include/netif/lowpan6_ble.h
        tools/sdk/lwip2/include/netif/lowpan6_common.h
        tools/sdk/lwip2/include/netif/lowpan6_opts.h
        tools/sdk/lwip2/include/netif/ppp/ccp.h
        tools/sdk/lwip2/include/netif/ppp/chap-md5.h
        tools/sdk/lwip2/include/netif/ppp/chap-new.h
        tools/sdk/lwip2/include/netif/ppp/chap_ms.h
        tools/sdk/lwip2/include/netif/ppp/eap.h
        tools/sdk/lwip2/include/netif/ppp/ecp.h
        tools/sdk/lwip2/include/netif/ppp/eui64.h
        tools/sdk/lwip2/include/netif/ppp/ipv6cp.h
        tools/sdk/lwip2/include/netif/ppp/magic.h
        tools/sdk/lwip2/include/netif/ppp/mppe.h
        tools/sdk/lwip2/include/netif/ppp/polarssl/
        tools/sdk/lwip2/include/netif/ppp/ppp_impl.h
        tools/sdk/lwip2/include/netif/ppp/pppapi.h
        tools/sdk/lwip2/include/netif/ppp/pppcrypt.h
        tools/sdk/lwip2/include/netif/ppp/pppdebug.h
        tools/sdk/lwip2/include/netif/ppp/pppoe.h
        tools/sdk/lwip2/include/netif/ppp/pppol2tp.h
        tools/sdk/lwip2/include/netif/ppp/upap.h
        tools/sdk/lwip2/include/netif/slipif.h
        tools/sdk/lwip2/include/netif/zepif.h

not sure what's the difference there just yet, I don't remember these extra includes copied

@d-a-v
Copy link
Owner

d-a-v commented Sep 13, 2021

There are also these after the install phase, in the esp8266 repo:

These harmless files are unused copied from lwip's iclude files.
Those which are not currently added / committed in esp8266/Arduino are useless.

I understand that this PR needs some more checks or am I wrong ?

@mcspr
Copy link
Collaborator Author

mcspr commented Sep 14, 2021

These harmless files are unused copied from lwip's iclude files.
Those which are not currently added / committed in esp8266/Arduino are useless.

Right now it simply does PATTERN "*.h" for everything under include/. It could either be a PATTERN "paths/we/dont/like" EXCLUDE" or a list of required files.

I understand that this PR needs some more checks or am I wrong ?

I was able to bootstrap it again from the README, so I think it's done. Let me do a once-over and wip could be removed. Have you tried it btw?

and idk about the open-sdk part, but that may be added later.

@d-a-v d-a-v merged commit 99a47a9 into d-a-v:master Nov 29, 2021
@d-a-v d-a-v changed the title [wip?] Cmake source prep and building Cmake source prep and building Nov 30, 2021
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.

None yet

2 participants