Merge pull request #89 from sej7278/master

Vastly simplified generating and flashing firmware.
This commit is contained in:
zeroday 2015-01-11 03:48:24 +08:00
commit bc33967c16
12 changed files with 5 additions and 278 deletions

View File

@ -136,7 +136,7 @@ endef
$(BINODIR)/%.bin: $(IMAGEODIR)/%.out $(BINODIR)/%.bin: $(IMAGEODIR)/%.out
@mkdir -p $(BINODIR) @mkdir -p $(BINODIR)
$(OBJCOPY) -O binary $< $@ ../tools/esptool.py elf2image $< -o $(BINODIR)/
############################################################# #############################################################
# Rules base # Rules base

View File

@ -159,8 +159,10 @@ sinclude $(PDIR)Makefile
$(BINODIR)/%.bin: $(IMAGEODIR)/%.out $(BINODIR)/%.bin: $(IMAGEODIR)/%.out
@mkdir -p $(BINODIR) @mkdir -p $(BINODIR)
$(OBJCOPY) -O binary $< $@ ../tools/esptool.py elf2image $< -o $(BINODIR)/
flash:
../tools/esptool.py write_flash 0x00000 $(BINODIR)/0x00000.bin 0x10000 $(BINODIR)/0x10000.bin
.PHONY: FORCE .PHONY: FORCE
FORCE: FORCE:

View File

@ -1,19 +0,0 @@
@echo off
set BACKPATH=%PATH%
set PATH=%BACKPATH%;%CD%\..\tools
@echo on
rem gen_misc.bat
rem eagle.app.v6.flash.bin: 0x00000
rem eagle.app.v6.irom0text.bin: 0x10000
rem esp_init_data_default.bin: 0x7c000
rem blank.bin: 0x7e000
cd ..\bin
esptool.py -p com1 write_flash 0x00000 eagle.app.v6.flash.bin 0x10000 eagle.app.v6.irom0text.bin 0x7c000 esp_init_data_default.bin 0x7e000 blank.bin
echo ************************* flash end *************************************
cd ..\app
@echo off
set PATH=%BACKPATH%
@echo on

View File

@ -1,11 +0,0 @@
#!/bin/bash -x
### gen_misc.sh
### eagle.app.v6.flash.bin: 0x00000
### eagle.app.v6.irom0text.bin: 0x10000
### esp_init_data_default.bin: 0x7c000
### blank.bin: 0x7e000
cd ../bin
../../../../../tools/esptool.py --port /dev/ttyUSB0 write_flash 0x00000 eagle.app.v6.flash.bin 0x10000 eagle.app.v6.irom0text.bin 0x7c000 esp_init_data_default.bin 0x7e000 blank.bin
echo "************************* flash end *************************************"
cd ../app

View File

@ -1,41 +0,0 @@
@echo off
set BACKPATH=%PATH%
set PATH=%BACKPATH%;%CD%\..\tools
@echo on
make %1
del /F ..\bin\eagle.app.v6.flash.bin ..\bin\eagle.app.v6.irom0text.bin ..\bin\eagle.app.v6.dump ..\bin\eagle.app.v6.S
cd .output\eagle\debug\image
@echo off
set OBJDUMP=xt-objdump
set OBJCOPY=xt-objcopy
if defined XTENSA_CORE (
set OBJDUMP=xt-objdump
set OBJCOPY=xt-objcopy
) else (
set OBJDUMP=xtensa-lx106-elf-objdump
set OBJCOPY=xtensa-lx106-elf-objcopy
)
@echo on
%OBJDUMP% -x -s eagle.app.v6.out > ..\..\..\..\..\bin\eagle.app.v6.dump
%OBJDUMP% -S eagle.app.v6.out > ..\..\..\..\..\bin\eagle.app.v6.S
%OBJCOPY% --only-section .text -O binary eagle.app.v6.out eagle.app.v6.text.bin
%OBJCOPY% --only-section .data -O binary eagle.app.v6.out eagle.app.v6.data.bin
%OBJCOPY% --only-section .rodata -O binary eagle.app.v6.out eagle.app.v6.rodata.bin
%OBJCOPY% --only-section .irom0.text -O binary eagle.app.v6.out eagle.app.v6.irom0text.bin
gen_appbin.py eagle.app.v6.out v6
xcopy /y eagle.app.v6.irom0text.bin ..\..\..\..\..\bin\
xcopy /y eagle.app.v6.flash.bin ..\..\..\..\..\bin\
cd ..\..\..\..\
@echo off
set PATH=%BACKPATH%
@echo on

View File

@ -1,25 +0,0 @@
#!/bin/bash -x
make
if [ $? == 0 ];then
rm ../bin/eagle.app.v6.flash.bin ../bin/eagle.app.v6.irom0text.bin ../bin/eagle.app.v6.dump ../bin/eagle.app.v6.S
cd .output/eagle/debug/image
xtensa-lx106-elf-objdump -x -s eagle.app.v6.out > ../../../../../bin/eagle.app.v6.dump
xtensa-lx106-elf-objdump -S eagle.app.v6.out > ../../../../../bin/eagle.app.v6.S
xtensa-lx106-elf-objcopy --only-section .text -O binary eagle.app.v6.out eagle.app.v6.text.bin
xtensa-lx106-elf-objcopy --only-section .data -O binary eagle.app.v6.out eagle.app.v6.data.bin
xtensa-lx106-elf-objcopy --only-section .rodata -O binary eagle.app.v6.out eagle.app.v6.rodata.bin
xtensa-lx106-elf-objcopy --only-section .irom0.text -O binary eagle.app.v6.out eagle.app.v6.irom0text.bin
../../../../../tools/gen_appbin.py eagle.app.v6.out v6
cp eagle.app.v6.irom0text.bin ../../../../../bin/
cp eagle.app.v6.flash.bin ../../../../../bin/
cd ../../../../../
else
echo "make error"
fi

View File

@ -1,41 +0,0 @@
@echo off
set BACKPATH=%PATH%
set PATH=%BACKPATH%;%CD%\..\tools
@echo on
make APP=$1
rm ..\bin\upgrade\%1.bin
cd .output\eagle\debug\image\
@echo off
set OBJDUMP=xt-objdump
set OBJCOPY=xt-objcopy
if defined XTENSA_CORE (
set OBJDUMP=xt-objdump
set OBJCOPY=xt-objcopy
) else (
set OBJDUMP=xtensa-lx106-elf-objdump
set OBJCOPY=xtensa-lx106-elf-objcopy
)
@echo on
%OBJCOPY% --only-section .text -O binary eagle.app.v6.out eagle.app.v6.text.bin
%OBJCOPY% --only-section .data -O binary eagle.app.v6.out eagle.app.v6.data.bin
%OBJCOPY% --only-section .rodata -O binary eagle.app.v6.out eagle.app.v6.rodata.bin
%OBJCOPY% --only-section .irom0.text -O binary eagle.app.v6.out eagle.app.v6.irom0text.bin
gen_appbin.py eagle.app.v6.out v6
gen_flashbin.py eagle.app.v6.flash.bin eagle.app.v6.irom0text.bin
cp eagle.app.flash.bin %1.bin
xcopy /y %1.bin ..\..\..\..\..\bin\upgrade\
cd ..\..\..\..\
@echo off
set PATH=%BACKPATH%
@echo on

View File

@ -1,28 +0,0 @@
#!/bin/bash -x
touch user/user_main.c
make APP=$1
if [ $? == 0 ];then
rm ../bin/upgrade/user$1.bin ../bin/upgrade/user$1.dump ../bin/upgrade/user$1.S
cd .output/eagle/debug/image/
xtensa-lx106-elf-objdump -x -s eagle.app.v6.out > ../../../../../bin/upgrade/user$1.dump
xtensa-lx106-elf-objdump -S eagle.app.v6.out > ../../../../../bin/upgrade/user$1.S
xtensa-lx106-elf-objcopy --only-section .text -O binary eagle.app.v6.out eagle.app.v6.text.bin
xtensa-lx106-elf-objcopy --only-section .data -O binary eagle.app.v6.out eagle.app.v6.data.bin
xtensa-lx106-elf-objcopy --only-section .rodata -O binary eagle.app.v6.out eagle.app.v6.rodata.bin
xtensa-lx106-elf-objcopy --only-section .irom0.text -O binary eagle.app.v6.out eagle.app.v6.irom0text.bin
../../../../../tools/gen_appbin.py eagle.app.v6.out v6
../../../../../tools/gen_flashbin.py eagle.app.v6.flash.bin eagle.app.v6.irom0text.bin
cp eagle.app.flash.bin user$1.bin
cp user$1.bin ../../../../../bin/upgrade/
cd ../../../../../
else
echo "make error"
fi

0
tools/esptool.py Normal file → Executable file
View File

View File

@ -1,77 +0,0 @@
#!/usr/bin/python
#
# Copyright (c) 2010 Espressif System
#
# grab user_start() address and pass it to genflashbin program
#
import string
import sys
import os
import re
if len(sys.argv) != 3:
print 'Usage: gen_appbin.py eagle.app.out version'
sys.exit(0)
elf_file = sys.argv[1]
ver = sys.argv[2]
#print elf_file
if os.getenv('XTENSA_CORE')=='lx106':
cmd = 'xt-nm -g ' + elf_file + ' > eagle.app.sym'
else:
cmd = 'xtensa-lx106-elf-nm -g ' + elf_file + ' > eagle.app.sym'
#print cmd
os.system(cmd)
fp = file('./eagle.app.sym')
if fp is None:
print "open sym file error\n"
exit
lines = fp.readlines()
fp.close()
entry_addr = None
p = re.compile('(\w*)(\sT\s)(call_user_start)$')
for line in lines:
m = p.search(line)
if m != None:
entry_addr = m.group(1)
#entry_addr = int(entry_addr, 16)
print entry_addr
if entry_addr is None:
print 'no entry point!!'
exit
data_start_addr = '0'
p = re.compile('(\w*)(\sA\s)(_data_start)$')
for line in lines:
m = p.search(line)
if m != None:
data_start_addr = m.group(1)
print data_start_addr
rodata_start_addr = '0'
p = re.compile('(\w*)(\sA\s)(_rodata_start)$')
for line in lines:
m = p.search(line)
if m != None:
rodata_start_addr = m.group(1)
print rodata_start_addr
if os.getenv('XTENSA_CORE')=='lx106':
cmd = 'genflashbin%s eagle.app.%s.text.bin '%(ver, ver)+entry_addr+' eagle.app.%s.data.bin '%(ver)+ data_start_addr+' eagle.app.%s.rodata.bin '%(ver)+rodata_start_addr
else:
cmd = 'genflashbin%s eagle.app.%s.text.bin '%(ver, ver)+entry_addr+' eagle.app.%s.data.bin '%(ver)+ data_start_addr+' eagle.app.%s.rodata.bin '%(ver)+rodata_start_addr
print cmd
os.system(cmd)
cmd = 'mv eagle.app.flash.bin eagle.app.%s.flash.bin'%(ver)
print cmd
os.system(cmd)

View File

@ -1,33 +0,0 @@
#!/usr/bin/python
import os
import sys
import binascii
import string
if len(sys.argv) != 3:
print 'Usage: gen_flashbin.py 1.bin 2.bin'
sys.exit(0)
bin1_name = sys.argv[1]
bin2_name = sys.argv[2]
bin1_file = open(bin1_name, 'rb')
bin2_file = open(bin2_name, 'rb')
bin1_len = os.path.getsize(bin1_name)
bin1 = bin1_file.read()
bin2 = bin2_file.read()
bitlist = ['FF']*(0x10000-bin1_len)
bytes = binascii.a2b_hex(''.join(bitlist))
bitout = open('eagle.app.flash.bin', 'wb')
bitout.write(bin1)
bitout.write(bytes)
bitout.write(bin2)
bitout.close()
bin1_file.close()
bin2_file.close()

Binary file not shown.