add update boot, обновление скриптов сборки и прошивки
This commit is contained in:
parent
947b371563
commit
6c3c1c920a
63 changed files with 15697 additions and 39 deletions
2
bthome_phy6222/.gitignore
vendored
2
bthome_phy6222/.gitignore
vendored
|
|
@ -1,3 +1,5 @@
|
|||
bin
|
||||
boot
|
||||
Listings
|
||||
Objects
|
||||
TestTHB2.asm
|
||||
|
|
|
|||
|
|
@ -117,11 +117,13 @@ CFLAGS += -Wl,--gc-sections
|
|||
ifdef BOOT_OTA
|
||||
LDSCRIPT ?= $(SDK_PATH)/misc/boot_ota_phy62x2.ld
|
||||
DEFINES += -DOTA_TYPE=OTA_TYPE_BOOT
|
||||
BIN_OTA =
|
||||
BIN_OTA = $(OBJ_DIR)/$(PROJECT_NAME).bin
|
||||
ADD_OPT = -w 0x2F00 -f ota_upboot.add
|
||||
else
|
||||
LDSCRIPT ?= $(SDK_PATH)/misc/phy6222.ld
|
||||
DEFINES += -DOTA_TYPE=OTA_TYPE_NONE
|
||||
BIN_OTA = $(OBJ_DIR)/$(PROJECT_NAME).bin
|
||||
ADD_OPT =
|
||||
endif
|
||||
|
||||
LDFLAGS := $(ARCH_FLAGS)
|
||||
|
|
@ -279,7 +281,7 @@ all: directory $(SRC_O) $(OBJ_DIR)/$(PROJECT_NAME).elf $(OBJ_DIR)/$(PROJECT_NAME
|
|||
|
||||
%.bin: %.hex
|
||||
@echo Make: $@
|
||||
@$(PYTHON) ./phy62x2_ota.py $(OBJ_DIR)/$(PROJECT_NAME).hex
|
||||
@$(PYTHON) ./phy62x2_ota.py $(ADD_OPT) $(OBJ_DIR)/$(PROJECT_NAME).hex
|
||||
|
||||
%.asm: %.elf
|
||||
@echo OBJDUMP: $@
|
||||
|
|
@ -301,7 +303,7 @@ flash:
|
|||
@$(PYTHON) ./rdwr_phy62x2.py -p$(COM_PORT) -b 1000000 -r wh $(OBJ_DIR)/$(PROJECT_NAME).hex
|
||||
|
||||
flash_ota:
|
||||
@$(PYTHON) ./rdwr_phy62x2.py -p$(COM_PORT) -b 1000000 -r we 0x10000 $(OBJ_DIR)/$(PROJECT_NAME).bin
|
||||
@$(PYTHON) ./rdwr_phy62x2.py -p$(COM_PORT) -b 1000000 -r we 0x10000 $(BIN_OTA)
|
||||
|
||||
erase_and_flash:
|
||||
@$(PYTHON) ./rdwr_phy62x2.py -p$(COM_PORT) -b 1000000 -e -r wh $(OBJ_DIR)/$(PROJECT_NAME).hex
|
||||
|
|
|
|||
|
|
@ -49,6 +49,29 @@ static xflash_Ctx_t s_xflashCtx = {
|
|||
.spif_ref_clk = SYS_CLK_DLL_64M,
|
||||
.rd_instr = XFRD_FCMD_READ_DUAL };
|
||||
|
||||
/*
|
||||
void spif_cmd(uint8_t op, uint8_t addrlen, uint8_t rdlen, uint8_t wrlen, uint8_t mbit, uint8_t dummy)
|
||||
{
|
||||
uint32_t temp = op << 0x18;
|
||||
if (addrlen != 0) {
|
||||
temp = temp | 0x80000 | addrlen * 0x10000 - 0x10000;
|
||||
}
|
||||
if (rdlen != 0) {
|
||||
temp = temp | 0x800000 | rdlen * 0x100000 - 0x100000;
|
||||
}
|
||||
if (wrlen != 0) {
|
||||
temp = temp | 0x8000 | wrlen * 0x1000 - 0x1000;
|
||||
}
|
||||
if (mbit != 0) {
|
||||
temp = temp | 0x40000;
|
||||
}
|
||||
if (dummy != 0) {
|
||||
temp = temp | dummy << 7;
|
||||
}
|
||||
AP_SPIF->fcmd = temp | 1;
|
||||
...
|
||||
}
|
||||
*/
|
||||
|
||||
__ATTR_SECTION_SRAM__ static inline uint32_t spif_lock() {
|
||||
HAL_ENTER_CRITICAL_SECTION();
|
||||
|
|
|
|||
|
|
@ -46,18 +46,7 @@ SECTIONS
|
|||
*.o(_section_standby_code_)
|
||||
*.o(_section_sram_code_)
|
||||
|
||||
*patch.o(.text.*)
|
||||
*patch_ext_adv.o(.text.*)
|
||||
|
||||
*rf_phy_driver.o(.text.*)
|
||||
*pwrmgr.o(.text .text.*)
|
||||
*timer.o(.text .text.*)
|
||||
|
||||
*flash.o(.text .text.*)
|
||||
*clock.o(.text.*)
|
||||
|
||||
*phy_sec_ext.o(.text .text.*)
|
||||
|
||||
*main.o(.text.*)
|
||||
*libgcc.a:*.o(.text .text.*)
|
||||
|
||||
_etextram = ABSOLUTE(.);
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -3,6 +3,7 @@
|
|||
@del /Q "build\THB2%SWVER%.hex"
|
||||
@del /Q "build\THB2%SWVER%.bin"
|
||||
@mkdir .\bin
|
||||
@mkdir .\boot
|
||||
@make -s clean
|
||||
@make -s -j PROJECT_NAME=THB2%SWVER% POJECT_DEF="-DDEVICE=DEVICE_THB2"
|
||||
@if not exist "build\THB2%SWVER%.hex" goto :error
|
||||
|
|
@ -48,36 +49,42 @@
|
|||
@make -s -j PROJECT_NAME=BOOT_THB2%SWVER% BOOT_OTA=1 POJECT_DEF="-DDEVICE=DEVICE_THB2"
|
||||
@if not exist "build\BOOT_THB2%SWVER%.hex" goto :error
|
||||
@copy "build\BOOT_THB2%SWVER%.hex" .\bin
|
||||
@copy "build\BOOT_THB2%SWVER%.bin" .\boot
|
||||
@
|
||||
@del /Q "build\BOOT_BTH01%SWVER%.hex"
|
||||
@make -s clean
|
||||
@make -s -j PROJECT_NAME=BOOT_BTH01%SWVER% BOOT_OTA=1 POJECT_DEF="-DDEVICE=DEVICE_BTH01"
|
||||
@if not exist "build\BOOT_BTH01%SWVER%.hex" goto :error
|
||||
@copy "build\BOOT_BTH01%SWVER%.hex" .\bin
|
||||
@copy "build\BOOT_BTH01%SWVER%.bin" .\boot
|
||||
@
|
||||
@del /Q "build\BOOT_TH05%SWVER%.hex"
|
||||
@make -s clean
|
||||
@make -s -j PROJECT_NAME=BOOT_TH05%SWVER% BOOT_OTA=1 POJECT_DEF="-DDEVICE=DEVICE_TH05"
|
||||
@if not exist "build\BOOT_TH05%SWVER%.hex" goto :error
|
||||
@copy "build\BOOT_TH05%SWVER%.hex" .\bin
|
||||
@copy "build\BOOT_TH05%SWVER%.bin" .\boot
|
||||
@
|
||||
@del /Q "build\BOOT_TH05D%SWVER%.hex"
|
||||
@make -s clean
|
||||
@make -s -j PROJECT_NAME=BOOT_TH05D%SWVER% BOOT_OTA=1 POJECT_DEF="-DDEVICE=DEVICE_TH05D"
|
||||
@if not exist "build\BOOT_TH05D%SWVER%.hex" goto :error
|
||||
@copy "build\BOOT_TH05D%SWVER%.hex" .\bin
|
||||
@copy "build\BOOT_TH05D%SWVER%.bin" .\boot
|
||||
@
|
||||
@del /Q "build\BOOT_TH05F%SWVER%.hex"
|
||||
@make -s clean
|
||||
@make -s -j PROJECT_NAME=BOOT_TH05F%SWVER% BOOT_OTA=1 POJECT_DEF="-DDEVICE=DEVICE_TH05F"
|
||||
@if not exist "build\BOOT_TH05F%SWVER%.hex" goto :error
|
||||
@copy "build\BOOT_TH05F%SWVER%.hex" .\bin
|
||||
@copy "build\BOOT_TH05F%SWVER%.bin" .\boot
|
||||
@
|
||||
@del /Q "build\BOOT_THB1%SWVER%.hex"
|
||||
@make -s clean
|
||||
@make -s -j PROJECT_NAME=BOOT_THB1%SWVER% BOOT_OTA=1 POJECT_DEF="-DDEVICE=DEVICE_THB1"
|
||||
@if not exist "build\BOOT_THB1%SWVER%.hex" goto :error
|
||||
@copy "build\BOOT_THB1%SWVER%.hex" .\bin
|
||||
@copy "build\BOOT_THB1%SWVER%.bin" .\boot
|
||||
@exit
|
||||
:error
|
||||
@echo "Error!"
|
||||
BIN
bthome_phy6222/ota_upboot.add
Normal file
BIN
bthome_phy6222/ota_upboot.add
Normal file
Binary file not shown.
|
|
@ -23,7 +23,7 @@ PHY_WR_BLK_SIZE = 0x2000
|
|||
|
||||
__progname__ = 'PHY62x2 OTA Utility'
|
||||
__filename__ = 'phy62x2_ota.py'
|
||||
__version__ = "23.01.24"
|
||||
__version__ = "25.02.24"
|
||||
|
||||
def do_crc(s, c):
|
||||
return zlib.crc32(s, c) & 0xffffffff
|
||||
|
|
@ -84,10 +84,11 @@ class phy_ota:
|
|||
size = 0x100
|
||||
sections = 15
|
||||
wfaddr = (wrfaddr & (MAX_FLASH_SIZE-1)) + size
|
||||
wrfaddr = wfaddr;
|
||||
faddr_min = MAX_FLASH_SIZE-1 # xip addr min
|
||||
faddr_max = 0 # xip addr max
|
||||
rsize = 0 # size ram data
|
||||
hexf = bytearray(struct.pack('<IIII', otaid, len(hp), start, 0xffffffff))
|
||||
hexf = bytearray(struct.pack('<IIII', otaid, len(hp)-1, start, 0xffffffff))
|
||||
for ihp in hp:
|
||||
if (ihp[0] & 0x1fff0000) == 0x1fff0000: # SRAM
|
||||
rsize += len(ihp[1])
|
||||
|
|
@ -154,6 +155,7 @@ def main():
|
|||
parser.add_argument('--idota', '-i', help = 'Flag ID OTA (default: 0x%08x)' % START_UP_FLAG, type = arg_auto_int, default = START_UP_FLAG);
|
||||
parser.add_argument('--runaddr', '-r', help = 'Application run-start address (default: 0x%08x)' % DEF_START_RUN_APP_ADDR, type = arg_auto_int, default = DEF_START_RUN_APP_ADDR);
|
||||
parser.add_argument('--wraddr', '-w', help = 'Application write address (default: 0x%08x)' % DEF_START_WR_FLASH_ADDR, type = arg_auto_int, default = DEF_START_WR_FLASH_ADDR);
|
||||
parser.add_argument('--fbup', '-f', help = 'Boot update file (default: none)', default = None);
|
||||
parser.add_argument('--outfile', '-o', help = 'Output bin file')
|
||||
parser.add_argument('filename', help = 'Name of hex file')
|
||||
|
||||
|
|
@ -162,15 +164,36 @@ def main():
|
|||
print('=========================================================')
|
||||
print('%s version %s' % (__progname__, __version__))
|
||||
print('---------------------------------------------------------')
|
||||
|
||||
if args.fbup != None:
|
||||
try:
|
||||
fbup = open(args.fbup, 'rb')
|
||||
except Exception as e:
|
||||
print('Error: Open file %s, %s' % (args.fbup, e))
|
||||
exit(1)
|
||||
try:
|
||||
datafbup = fbup.read();
|
||||
except Exception as e:
|
||||
print('Error: Read file %s,: %s' % (args.fbup, e))
|
||||
exit(1)
|
||||
fbup.close()
|
||||
fbupid = int.from_bytes(datafbup[0:4], byteorder='little')
|
||||
fbuplen = int.from_bytes(datafbup[12:16], byteorder='little')
|
||||
print("Boot update file id: %08x:%08x" %(fbupid, fbuplen))
|
||||
if (fbupid != START_UP_FLAG) or ((fbuplen + 4) != len(datafbup)) or (fbuplen > 4096) or (fbuplen <= 256):
|
||||
print('Error: Boot update file %s format!' % args.fbup)
|
||||
exit(2)
|
||||
datafbup = bytearray(datafbup[0:-4])
|
||||
|
||||
phy = phy_ota()
|
||||
|
||||
hp = phy.ParseHexFile(args.filename, args.wraddr)
|
||||
|
||||
if hp == None:
|
||||
sys.exit(2)
|
||||
sys.exit(3)
|
||||
hexf = phy.HexfHeader(hp, args.runaddr, args.wraddr, args.idota)
|
||||
if hexf == None:
|
||||
sys.exit(2)
|
||||
sys.exit(4)
|
||||
hp[0][1] = hexf
|
||||
|
||||
print ('---- File Structure -------------------------------------')
|
||||
|
|
@ -182,15 +205,19 @@ def main():
|
|||
fout = open(outfile, 'wb')
|
||||
except:
|
||||
print('No file opened', outfile)
|
||||
sys.exit(3)
|
||||
sys.exit(5)
|
||||
fsize = 0
|
||||
for ihp in hp:
|
||||
fsize += len(ihp[1])
|
||||
fillsize = 16 - fsize % 16
|
||||
fsize += fillsize
|
||||
segment = 0
|
||||
crc = 0
|
||||
try:
|
||||
if args.fbup != None:
|
||||
#print('size: %08x , %08x' % (fsize, fbuplen))
|
||||
datafbup[12:16] = int.to_bytes(fsize + fbuplen, 4, byteorder='little')
|
||||
datafbup[0xfc:0x100] = int.to_bytes((fbuplen + DEF_START_WR_FLASH_ADDR) | 0x11000000, 4, byteorder='little')
|
||||
crc = do_crc(datafbup, crc)
|
||||
fout.write(datafbup)
|
||||
for ihp in hp:
|
||||
if ihp[0] == 0:
|
||||
print('Segment Table[%02d] <- Flash addr: %08x, Size: %08x' % (len(hp) - 1, ihp[2], len(ihp[1])))
|
||||
|
|
@ -204,9 +231,9 @@ def main():
|
|||
fout.write(bytearray(struct.pack('<I', crc)))
|
||||
size = fout.tell()
|
||||
fout.close()
|
||||
except:
|
||||
print('No write file', outfile)
|
||||
sys.exit(3)
|
||||
except Exception as e:
|
||||
print('No write file %s, %s' % (outfile, e))
|
||||
sys.exit(6)
|
||||
print ('---------------------------------------------------------')
|
||||
print ('Write to file: %s %u bytes - ok.' % (outfile, size))
|
||||
sys.exit(0)
|
||||
|
|
|
|||
|
|
@ -459,7 +459,7 @@ class phyflasher:
|
|||
def HexfHeader(self, hp, start = DEF_START_RUN_APP_ADDR, raddr = DEF_START_WR_FLASH_ADDR):
|
||||
if len(hp) > 1:
|
||||
hexf = bytearray(b'\xff')*(0x100)
|
||||
hexf[0:4] = int.to_bytes(len(hp), 4, byteorder='little')
|
||||
hexf[0:4] = int.to_bytes(len(hp)-1, 4, byteorder='little')
|
||||
hexf[8:12] = int.to_bytes(start, 4, byteorder='little')
|
||||
#sections = 0
|
||||
faddr_min = MAX_FLASH_SIZE-1
|
||||
|
|
@ -592,8 +592,6 @@ def main():
|
|||
print ('Error Flash read Unique ID!')
|
||||
sys.exit(3)
|
||||
print ('Flash Serial Number:', rb.hex()) # Unique ID
|
||||
|
||||
exit(0)
|
||||
if args.operation == 'rc':
|
||||
#filename = "r%08x-%08x.bin" % (addr, length)
|
||||
if args.size == 0:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue