1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/pkg/esp8266_sdk/Makefile
iosabi 7b1f083cd8 esp8266: Download Espressif RTOS SDK as a new RIOT PKG
RIOT-OS uses part of Espressif ESP8266 RTOS SDK to build support for
this CPU. The SDK includes some vendor-provided closed source
pre-compiled libraries that we need to modify to adapt to RIOT-OS
usage. This library modifications was done once and uploaded to a fork
of the vendor repository and was provided as an environment variable.

This patch changes two things:

1. It installs the SDK as a RIOT PKG from the new pkg/esp8266_sdk
directory instead of requiring the user to download it separately.

2. It performs the library modifications (symbol renames) on the pkg
Makefile removing the need to use a fork with the modifications applied
and simplifying the SDK update and future modifications.

This change sets the SDK package version (git SHA) to the same one that
our fork was using as a parent in the vendor repository, meaning that
the output libraries are exactly the same as before.

Tested with
```
ESP8266_RTOS_SDK_DIR=/dev/null USEMODULE=esp_log_startup make -C tests/shell BOARD=esp8266-esp-12x flash
```

and verified that the program works. The boot message now includes:
```
ESP8266-RTOS-SDK Version v3.1-51-g913a06a9
```
confirming the SDK version used.

`/dev/null` in the test is just to make sure that no evaluation of
`ESP8266_RTOS_SDK_DIR` in make is affected by the environment variable
value which would be set to the SDK for people who followed the set up
instructions before this change.

Tested the checkout size:
```bash
$ du -hs build/pkg/esp8266_sdk/
124M	build/pkg/esp8266_sdk/
```
2021-10-23 11:13:38 +00:00

38 lines
1.5 KiB
Makefile

PKG_NAME=esp8266_sdk
PKG_URL=https://github.com/espressif/ESP8266_RTOS_SDK
# This is a version in the v3.1 release branch, between 3.1 and 3.1.1.
PKG_VERSION=913a06a9ac3b2f18009e8fee8f092ca9ffeccd38
PKG_LICENSE=Apache-2.0
include $(RIOTBASE)/pkg/pkg.mk
# This directory is shared across all apps since there's no need to replicate
# these libraries on each app.
ESP8266_SDK_BUILD_DIR = $(PKG_SOURCE_DIR)/build-libs
# We need to replace some symbols in the binary libraries shipped with the SDK
# to avoid collisions with RIOT symbols.
ESP_SDK_COMPONENT_LIBS = \
libcore.a libespnow.a libgcc.a libhal.a libnet80211.a libphy.a libpp.a \
libsmartconfig.a libssc.a libwpa.a libwps.a
ESP_SDK_LIBS = $(addprefix $(ESP8266_SDK_BUILD_DIR)/, $(ESP_SDK_COMPONENT_LIBS))
all: $(ESP_SDK_LIBS) $(ESP8266_SDK_BUILD_DIR)/esp8266_idf_version.h
$(ESP8266_SDK_BUILD_DIR):
$(Q)mkdir -p $(ESP8266_SDK_BUILD_DIR)
# Set the SDK version from the SDK hash/tag. For example "v3.1-51-g913a06a9".
$(ESP8266_SDK_BUILD_DIR)/esp8266_idf_version.h: | $(ESP8266_SDK_BUILD_DIR)
$(Q)echo "#define IDF_VER \"$(shell git -C $(PKG_SOURCE_DIR) describe --tags)\"" \
> $@
$(ESP8266_SDK_BUILD_DIR)/lib%.a: \
$(PKG_SOURCE_DIR)/components/esp8266/lib/lib%.a | $(ESP8266_SDK_BUILD_DIR)
$(Q)$(OBJCOPY) \
--redefine-syms $(CURDIR)/symbol_renames.txt \
--redefine-sym printf=$(patsubst lib%.a,%,$(notdir $@))_printf \
--redefine-sym ets_printf=$(patsubst lib%.a,%,$(notdir $@))_ets_printf \
$< $@