Skip to content

Commit

Permalink
Replaced the bash commands with a simple python patcher script.
Browse files Browse the repository at this point in the history
  • Loading branch information
slav-at-attachix committed Mar 15, 2021
1 parent 3f13681 commit e44b200
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
25 changes: 25 additions & 0 deletions Sming/Arch/Esp8266/Components/esp8266/Tools/patch-phy-bin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python
########################################################
#
# Simple PHY binary patcher
# Author: Slavey Karadzhov <[email protected]>
#
########################################################
import os
import sys

def usage():
print("Usage: \n\t%s <file.bin> [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'));
6 changes: 4 additions & 2 deletions Sming/Arch/Esp8266/Components/esp8266/component.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down

0 comments on commit e44b200

Please sign in to comment.