using esptool.py in all platform, fix makefile on windows

This commit is contained in:
funshine 2015-01-11 04:11:40 +08:00
parent bc33967c16
commit 2709258c44
4 changed files with 26 additions and 14 deletions

View File

@ -29,6 +29,7 @@ ifeq ($(OS),Windows_NT)
CPP = xtensa-lx106-elf-cpp
OBJCOPY = xtensa-lx106-elf-objcopy
endif
FIRMWAREDIR = ..\\bin\\
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
# ->AMD64
endif
@ -44,7 +45,7 @@ else
NM = xtensa-lx106-elf-nm
CPP = xtensa-lx106-elf-cpp
OBJCOPY = xtensa-lx106-elf-objcopy
FIRMWAREDIR = ../bin/
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
# LINUX
@ -136,7 +137,7 @@ endef
$(BINODIR)/%.bin: $(IMAGEODIR)/%.out
@mkdir -p $(BINODIR)
../tools/esptool.py elf2image $< -o $(BINODIR)/
../tools/esptool.py elf2image $< -o $(FIRMWAREDIR)
#############################################################
# Rules base

View File

@ -72,27 +72,26 @@
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets">
<buildTargets>
<target name="all" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>${PWD}/gen_misc.bat</buildCommand>
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>all</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="clean" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>clean</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="flash" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>${PWD}/flash.bat</buildCommand>
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget/>
<buildTarget>flash</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<useDefaultCommand>true</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
</buildTargets>

View File

@ -157,12 +157,18 @@ sinclude $(PDIR)Makefile
# generate bin file
#
ifeq ($(OS),Windows_NT)
PORT = com1
else
PORT = /dev/ttyUSB0
endif
$(BINODIR)/%.bin: $(IMAGEODIR)/%.out
@mkdir -p $(BINODIR)
../tools/esptool.py elf2image $< -o $(BINODIR)/
../tools/esptool.py elf2image $< -o $(FIRMWAREDIR)
flash:
../tools/esptool.py write_flash 0x00000 $(BINODIR)/0x00000.bin 0x10000 $(BINODIR)/0x10000.bin
../tools/esptool.py -p $(PORT) write_flash 0x00000 ../bin/0x00000.bin 0x10000 ../bin/0x10000.bin
.PHONY: FORCE
FORCE:

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2.7
#!/usr/bin/env python
#
# ESP8266 ROM Bootloader Utility
# https://github.com/themadinventor/esptool
@ -270,9 +270,12 @@ class ELFFile:
return
self.symbols = {}
try:
proc = subprocess.Popen(["xtensa-lx106-elf-nm", self.name], stdout=subprocess.PIPE)
tool_nm = "xtensa-lx106-elf-nm"
if os.getenv('XTENSA_CORE')=='lx106':
tool_nm = "xt-nm"
proc = subprocess.Popen([tool_nm, self.name], stdout=subprocess.PIPE)
except OSError:
print "Error calling xtensa-lx106-elf-nm, do you have Xtensa toolchain in PATH?"
print "Error calling "+tool_nm+", do you have Xtensa toolchain in PATH?"
sys.exit(1)
for l in proc.stdout:
fields = l.strip().split()
@ -283,7 +286,10 @@ class ELFFile:
return self.symbols[sym]
def load_section(self, section):
subprocess.check_call(["xtensa-lx106-elf-objcopy", "--only-section", section, "-Obinary", self.name, ".tmp.section"])
tool_objcopy = "xtensa-lx106-elf-objcopy"
if os.getenv('XTENSA_CORE')=='lx106':
tool_objcopy = "xt-objcopy"
subprocess.check_call([tool_objcopy, "--only-section", section, "-Obinary", self.name, ".tmp.section"])
f = open(".tmp.section", "rb")
data = f.read()
f.close()