From 1e8a92c15404549b280b39bcbeb24c1b582df95f Mon Sep 17 00:00:00 2001 From: Slavey Karadzhov Date: Mon, 15 Mar 2021 13:13:18 +0100 Subject: [PATCH] Replaced the bash commands with a simple python patcher script. --- .../Components/esp8266/Tools/patch-phy-bin.py | 25 +++++++++++++++++++ .../Esp8266/Components/esp8266/component.mk | 6 +++-- docs/source/information/tips-n-tricks.rst | 2 +- 3 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 Sming/Arch/Esp8266/Components/esp8266/Tools/patch-phy-bin.py diff --git a/Sming/Arch/Esp8266/Components/esp8266/Tools/patch-phy-bin.py b/Sming/Arch/Esp8266/Components/esp8266/Tools/patch-phy-bin.py new file mode 100644 index 0000000000..8f38ce38aa --- /dev/null +++ b/Sming/Arch/Esp8266/Components/esp8266/Tools/patch-phy-bin.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python +######################################################## +# +# Simple PHY binary patcher +# Author: Slavey Karadzhov +# +######################################################## +import os +import sys + +def usage(): + print("Usage: \n\t%s [offset]" % sys.argv[0]) + +if __name__ == "__main__": + if len(sys.argv) not in list(range(2,4)): + usage() + sys.exit(1) + + offset = 107 + if len(sys.argv) > 2: + offset = int(sys.argv[2]) + + with os.fdopen(os.open(sys.argv[1], os.O_RDWR | os.O_CREAT), 'rb+') as f: + f.seek(offset) + f.write(bytearray(b'\xff')); diff --git a/Sming/Arch/Esp8266/Components/esp8266/component.mk b/Sming/Arch/Esp8266/Components/esp8266/component.mk index afd77a11da..3b9e3a672f 100644 --- a/Sming/Arch/Esp8266/Components/esp8266/component.mk +++ b/Sming/Arch/Esp8266/Components/esp8266/component.mk @@ -5,7 +5,7 @@ SDK_BASE ?= $(COMPONENT_PATH)/ESP8266_NONOS_SDK SDK_BASE := $(call FixPath,$(SDK_BASE)) FLASH_INIT_DATA = $(SDK_BASE)/bin/esp_init_data_default.bin -FLASH_INIT_DATA_VCC = $(SDK_BASE)/bin/esp_init_data_vcc_default.bin +FLASH_INIT_DATA_VCC = $(SDK_BASE)/bin/esp_init_data_vdd_default.bin CUSTOM_TARGETS += $(FLASH_INIT_DATA) $(FLASH_INIT_DATA_VCC) @@ -25,9 +25,11 @@ else SDK_INTERNAL := 0 endif +PHY_TOOL := $(COMPONENT_PATH)/Tools/patch-phy-bin.py + $(FLASH_INIT_DATA_VCC): $(FLASH_INIT_DATA) $(Q) cp $< $@ - $(Q) printf "\377" | dd of=$@ bs=1 seek=107 count=1 conv=notrunc + $(Q) $(PYTHON) $(PHY_TOOL) $@ DEBUG_VARS += SDK_LIBDIR SDK_INCDIR SDK_LIBDIR := $(SDK_BASE)/lib diff --git a/docs/source/information/tips-n-tricks.rst b/docs/source/information/tips-n-tricks.rst index e92142dbbc..a3b57c68c4 100644 --- a/docs/source/information/tips-n-tricks.rst +++ b/docs/source/information/tips-n-tricks.rst @@ -10,7 +10,7 @@ the official ESP8266 NONOS SDK can help you read the power voltage. For the latter to work properly you should make a small change in your application `component.mk` file and add `vdd` to the `HWCONFIG_OPTS` configuration variable. -If you cannot see such a variable in your `component.mk` file then append the following line in `component.mk`:: +If you cannot see such a variable in your `component.mk` file then append the following line to it:: HWCONFIG := vdd