diff --git a/components/base_nodemcu/Makefile.projbuild b/components/base_nodemcu/Makefile.projbuild new file mode 100644 index 00000000..e2d8ad64 --- /dev/null +++ b/components/base_nodemcu/Makefile.projbuild @@ -0,0 +1,8 @@ +BASE_NODEMCU_DIR:=$(dir $(lastword $(MAKEFILE_LIST))) +BASE_NODEMCU_BUILD_DIR:=$(BUILD_DIR_BASE)/base_nodemcu + +$(BUILD_DIR_BASE)/$(PROJECT_NAME).elf: $(BASE_NODEMCU_BUILD_DIR)/ld_patched + +$(BASE_NODEMCU_BUILD_DIR)/ld_patched: $(BUILD_DIR_BASE)/esp32/esp32.project.ld + "$(BASE_NODEMCU_DIR)/add_rodata_ld.sh" "$<" "$(BASE_NODEMCU_DIR)/ld/nodemcu_rodata.ld" + touch $@ diff --git a/components/base_nodemcu/add_rodata_ld.sh b/components/base_nodemcu/add_rodata_ld.sh new file mode 100755 index 00000000..599d01e1 --- /dev/null +++ b/components/base_nodemcu/add_rodata_ld.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# syntax: add_rodata_ld.sh /path/to/esp32.project.ld /path/to/snippet_file +set -eu +ldfile="$1" +partial="$2" +out="${ldfile}.new" +IFS=' +' +msg="/* NodeMCU patched */" +if [[ $(head -n 1 "$ldfile") =~ "$msg" ]] +then + echo "NodeMCU rodata already patched into $(basename $ldfile)" + exit 0 +else + echo "Patching in NodeMCU rodata into $(basename $ldfile)" + echo "$msg" > "$out" +fi + +cat "$ldfile" | while read line +do + if [[ $line =~ "drom0_0_seg" ]] + then + cat "$partial" >> "$out" + fi + echo $line >> "$out" +done +mv "$out" "$ldfile" diff --git a/components/base_nodemcu/component.mk b/components/base_nodemcu/component.mk index f563c84b..e69de29b 100644 --- a/components/base_nodemcu/component.mk +++ b/components/base_nodemcu/component.mk @@ -1,4 +0,0 @@ -COMPONENT_ADD_INCLUDEDIRS:=include -# Note: It appears this component must come lexicographically before esp32 -# in order to get the -T arguments in the right order. -COMPONENT_ADD_LDFLAGS:=-L $(COMPONENT_PATH)/ld -T nodemcu_core.ld -lbase_nodemcu diff --git a/components/base_nodemcu/ld/nodemcu_core.ld b/components/base_nodemcu/ld/nodemcu_rodata.ld similarity index 75% rename from components/base_nodemcu/ld/nodemcu_core.ld rename to components/base_nodemcu/ld/nodemcu_rodata.ld index 303d44b6..50458c44 100644 --- a/components/base_nodemcu/ld/nodemcu_core.ld +++ b/components/base_nodemcu/ld/nodemcu_rodata.ld @@ -1,6 +1,7 @@ -SECTIONS { - .flash.rodata : ALIGN(4) - { + + /* ----- Begin NodeMCU link-time arrays ------- */ + + . = ALIGN(4); /* Link-time arrays containing the defs for the included modules */ lua_libs = ABSOLUTE(.); KEEP(*(.lua_libs)) @@ -11,6 +12,6 @@ SECTIONS { esp_event_cb_table = ABSOLUTE(.); KEEP(*(.esp_event_cb_table)) LONG(0) LONG(0) /* Null-terminate the array */ - } -} -INSERT BEFORE .flash.text + + /* ----- End NodeMCU link-time arrays ------- */ + diff --git a/sdk/esp32-esp-idf b/sdk/esp32-esp-idf index 4aa1058e..890a341d 160000 --- a/sdk/esp32-esp-idf +++ b/sdk/esp32-esp-idf @@ -1 +1 @@ -Subproject commit 4aa1058e8a8f7f3fb17d9ac1158227ad161f2996 +Subproject commit 890a341db429db03a328035b59ca101a5952d096