тест OTA
This commit is contained in:
parent
8db97af330
commit
f2667e9270
26 changed files with 6237 additions and 5988 deletions
2981
BOOT_BTH01_v06.hex
Normal file
2981
BOOT_BTH01_v06.hex
Normal file
File diff suppressed because it is too large
Load diff
2965
BOOT_THB2_v06.hex
Normal file
2965
BOOT_THB2_v06.hex
Normal file
File diff suppressed because it is too large
Load diff
BIN
BTH01_v06.bin
Normal file
BIN
BTH01_v06.bin
Normal file
Binary file not shown.
2978
BTH01_v06.hex
2978
BTH01_v06.hex
File diff suppressed because it is too large
Load diff
|
|
@ -3,11 +3,13 @@ Custom firmware for Tuya [THB2](https://pvvx.github.io/THB2) and [BTH01](https:/
|
|||
|
||||
* Проект в начальной стадии разработки, до появления функционального OTA.
|
||||
|
||||
* Тестовый [PHY62x2BTHome.html](https://pvvx.github.io/THB2/web/PHY62x2BTHome.html)
|
||||
|
||||
В плане проекта предусматривается дальнейшая поддержка [TH-05](https://pvvx.github.io/TH-05).
|
||||
|
||||
Прошивка для THB2 (файл THB2_v06.hex).
|
||||
Прошивка для THB2 (файл BOOT_THB2_v06.hex).
|
||||
|
||||
Прошивка для BTH01 (файл BTH01_v06.hex).
|
||||
Прошивка для BTH01 (файл BOOT_BTH01_v06.hex).
|
||||
|
||||
## Основные характеристики:
|
||||
|
||||
|
|
@ -24,7 +26,7 @@ Custom firmware for Tuya [THB2](https://pvvx.github.io/THB2) and [BTH01](https:/
|
|||
1. Соединить GND, TX, RX, RTS–RESET, VCC (+3.3B).
|
||||
2. Запустить:
|
||||
```
|
||||
python3 rdwr_phy62x2.py -p COM11 -e -r wh THB2_v05.hex
|
||||
python3 rdwr_phy62x2.py -p COM11 -e -r wh BOOT_xxx_vxx.hex
|
||||
```
|
||||
3. Прошивка зашита. Устройство работает.
|
||||
|
||||
|
|
|
|||
BIN
THB2_v06.bin
Normal file
BIN
THB2_v06.bin
Normal file
Binary file not shown.
2962
THB2_v06.hex
2962
THB2_v06.hex
File diff suppressed because it is too large
Load diff
|
|
@ -14,7 +14,7 @@
|
|||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="${ProjName}" buildProperties="" description="" id="ilg.gnuarmeclipse.managedbuild.cross.toolchain.base.28719871" name="Default" optionalBuildProperties="org.eclipse.cdt.docker.launcher.containerbuild.property.dockerdpath=,org.eclipse.cdt.docker.launcher.containerbuild.property.selectedvolumes=,org.eclipse.cdt.docker.launcher.containerbuild.property.volumes=" parent="org.eclipse.cdt.build.core.emptycfg">
|
||||
<configuration artifactName="${ProjName}" buildProperties="" description="" id="ilg.gnuarmeclipse.managedbuild.cross.toolchain.base.28719871" name="Default" optionalBuildProperties="org.eclipse.cdt.docker.launcher.containerbuild.property.dockerdpath=,org.eclipse.cdt.docker.launcher.containerbuild.property.volumes=,org.eclipse.cdt.docker.launcher.containerbuild.property.selectedvolumes=" parent="org.eclipse.cdt.build.core.emptycfg">
|
||||
<folderInfo id="ilg.gnuarmeclipse.managedbuild.cross.toolchain.base.28719871.266191087" name="/" resourcePath="">
|
||||
<toolChain id="ilg.gnuarmeclipse.managedbuild.cross.toolchain.base.321694806" name="Arm Cross GCC" superClass="ilg.gnuarmeclipse.managedbuild.cross.toolchain.base">
|
||||
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.architecture.2086137351" name="Architecture" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.architecture" value="ilg.gnuarmeclipse.managedbuild.cross.option.architecture.arm" valueType="enumerated"/>
|
||||
|
|
@ -330,6 +330,14 @@
|
|||
<useDefaultCommand>true</useDefaultCommand>
|
||||
<runAllBuilders>true</runAllBuilders>
|
||||
</target>
|
||||
<target name="BOOT_OTA=1" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
|
||||
<buildCommand>${cross_make}</buildCommand>
|
||||
<buildArguments>-j24</buildArguments>
|
||||
<buildTarget>BOOT_OTA=1</buildTarget>
|
||||
<stopOnError>true</stopOnError>
|
||||
<useDefaultCommand>true</useDefaultCommand>
|
||||
<runAllBuilders>true</runAllBuilders>
|
||||
</target>
|
||||
</buildTargets>
|
||||
</storageModule>
|
||||
</cproject>
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser" keep-relative-paths="false" name="CDT GCC Build Output Parser" parameter="([^/\\\\]*)((g?cc)|([gc]\+\+)|(clang))" prefer-non-shared="true"/>
|
||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="150159375649064648" id="org.eclipse.embedcdt.managedbuild.cross.arm.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Arm Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="20603724518044815" id="org.eclipse.embedcdt.managedbuild.cross.arm.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Arm Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||
</provider>
|
||||
|
|
|
|||
|
|
@ -82,10 +82,17 @@ CFLAGS += -funsigned-char -funsigned-bitfields
|
|||
CFLAGS += -fms-extensions
|
||||
CFLAGS += -specs=nosys.specs
|
||||
CFLAGS += -Wl,--gc-sections
|
||||
#CFLAGS += -MM $(CFLAGS) $(INCFLAGS) $< -MT $@ -MF $(OBJ_DIR)/$(patsubst %.o,%.d,$@)
|
||||
|
||||
#LDSCRIPT ?= $(SDK_PATH)/misc/phy6222.ld
|
||||
ifdef BOOT_OTA
|
||||
LDSCRIPT ?= $(SDK_PATH)/misc/boot_ota_phy62x2.ld
|
||||
DEFINES += -DOTA_TYPE=OTA_TYPE_BOOT
|
||||
BIN_OTA =
|
||||
else
|
||||
LDSCRIPT ?= $(SDK_PATH)/misc/phy6222.ld
|
||||
DEFINES += -DOTA_TYPE=OTA_TYPE_APP
|
||||
BIN_OTA = $(OBJ_DIR)/$(PROJECT_NAME).bin
|
||||
endif
|
||||
|
||||
LDFLAGS := $(ARCH_FLAGS)
|
||||
LDFLAGS += --static -nostartfiles -nostdlib
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
|
|
@ -229,7 +236,7 @@ DEPENDENCY_LIST = $(OBJS:%o=%d)
|
|||
##############################################################################
|
||||
.PHONY: all directory clean size flash erase_and_flash
|
||||
|
||||
all: directory $(SRC_O) $(OBJ_DIR)/$(PROJECT_NAME).elf $(OBJ_DIR)/$(PROJECT_NAME).hex $(OBJ_DIR)/$(PROJECT_NAME).asm size
|
||||
all: directory $(SRC_O) $(OBJ_DIR)/$(PROJECT_NAME).elf $(OBJ_DIR)/$(PROJECT_NAME).hex $(BIN_OTA) $(OBJ_DIR)/$(PROJECT_NAME).asm size
|
||||
|
||||
%.elf %.map: $(SRC_O) $(LDSCRIPT) Makefile
|
||||
@echo LD: $@
|
||||
|
|
@ -239,9 +246,9 @@ all: directory $(SRC_O) $(OBJ_DIR)/$(PROJECT_NAME).elf $(OBJ_DIR)/$(PROJECT_NAME
|
|||
@echo OBJCOPY: $@
|
||||
@$(OBJCOPY) -O ihex $^ $@
|
||||
|
||||
%.bin: %.elf
|
||||
@echo OBJCOPY: $@
|
||||
@$(OBJCOPY) -O binary $^ $@
|
||||
%.bin: %.hex
|
||||
@echo Make: $@
|
||||
@$(PYTHON) ./phy62x2_ota.py $(OBJ_DIR)/$(PROJECT_NAME).hex
|
||||
|
||||
%.asm: %.elf
|
||||
@echo OBJDUMP: $@
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ MEMORY
|
|||
jumptbl (rw) : ORIGIN = 0x1fff0000, LENGTH = 0x00400
|
||||
gcfgtbl (rw) : ORIGIN = 0x1fff0400, LENGTH = 0x00400
|
||||
sram (rwx) : ORIGIN = 0x1fff1838, LENGTH = 0x0E7C8
|
||||
flash (rx) : ORIGIN = 0x11020000, LENGTH = 0x20000
|
||||
flash (rx) : ORIGIN = 0x11010100, LENGTH = 0x1ff00
|
||||
sram2 (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000
|
||||
sram3 (rwx) : ORIGIN = 0x20010000, LENGTH = 0x02000
|
||||
sram4 (rwx) : ORIGIN = 0x20012000, LENGTH = 0x00800
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ MEMORY
|
|||
jumptbl (rw) : ORIGIN = 0x1fff0000, LENGTH = 0x00400
|
||||
gcfgtbl (rw) : ORIGIN = 0x1fff0400, LENGTH = 0x00400
|
||||
sram (rwx) : ORIGIN = 0x1fff1838, LENGTH = 0x0E7C8
|
||||
flash (rx) : ORIGIN = 0x11020000, LENGTH = 0x20000
|
||||
flash (rx) : ORIGIN = 0x11010100, LENGTH = 0x1ff00
|
||||
sram2 (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000
|
||||
sram3 (rwx) : ORIGIN = 0x20010000, LENGTH = 0x02000
|
||||
sram4 (rwx) : ORIGIN = 0x20012000, LENGTH = 0x00800
|
||||
|
|
|
|||
2
bthome_phy6222/ihex_bth01.cmd
Normal file
2
bthome_phy6222/ihex_bth01.cmd
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
python3 C:\Python310\Scripts\hexinfo.py .\bin\BTH01_v06.hex
|
||||
python3 C:\Python310\Scripts\hexinfo.py .\bin\BOOT_BTH01_v06.hex
|
||||
|
|
@ -1 +0,0 @@
|
|||
python3 C:\Python310\Scripts\hexinfo.py .\bin\THB2_v06.hex
|
||||
2
bthome_phy6222/ihex_thb2.cmd
Normal file
2
bthome_phy6222/ihex_thb2.cmd
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
python3 C:\Python310\Scripts\hexinfo.py .\bin\THB2_v06.hex
|
||||
python3 C:\Python310\Scripts\hexinfo.py .\bin\BOOT_THB2_v06.hex
|
||||
|
|
@ -1,16 +1,29 @@
|
|||
@set PATH=D:\MCU\GNU_Tools_ARM_Embedded\13.2.rel1\bin;%PATH%
|
||||
@set SWVER=_v06
|
||||
@del /Q "THB2%SWVER%.hex"
|
||||
@del /Q "build\THB2%SWVER%.hex"
|
||||
@del /Q "build\THB2%SWVER%.bin"
|
||||
@mkdir .\bin
|
||||
@make -s clean
|
||||
@make -s -j PROJECT_NAME=THB2%SWVER% POJECT_DEF="-DDEVICE=DEVICE_THB2"
|
||||
@if not exist "build\THB2%SWVER%.hex" goto :error
|
||||
@copy "build\THB2%SWVER%.hex" .\bin
|
||||
@copy "build\THB2%SWVER%.bin" .\bin
|
||||
@del /Q "build\BTH01%SWVER%.hex"
|
||||
@del /Q "build\BTH01%SWVER%.bin"
|
||||
@make -s clean
|
||||
@make -s -j PROJECT_NAME=BTH01%SWVER% POJECT_DEF="-DDEVICE=DEVICE_BTH01"
|
||||
@if not exist "build\BTH01%SWVER%.hex" goto :error
|
||||
@copy "build\BTH01%SWVER%.hex" .\bin
|
||||
@copy "build\BTH01%SWVER%.bin" .\bin
|
||||
@del /Q "build\BOOT_THB2%SWVER%.hex"
|
||||
@mkdir .\bin
|
||||
@make -s clean
|
||||
@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
|
||||
@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
|
||||
@exit
|
||||
:error
|
||||
@echo "Error!"
|
||||
207
bthome_phy6222/phy62x2_ota.py
Normal file
207
bthome_phy6222/phy62x2_ota.py
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
# wrflash_phy6202.py 07.12.2019 pvvx #
|
||||
|
||||
import argparse
|
||||
import io
|
||||
import os
|
||||
import struct
|
||||
import sys
|
||||
import zlib
|
||||
|
||||
START_UP_FLAG = 0x36594850 #"PHY6"
|
||||
|
||||
MAX_FLASH_SIZE = 0x200000
|
||||
EXT_FLASH_ADD = 0x400000
|
||||
|
||||
DEF_START_RUN_APP_ADDR = 0x1FFF1838
|
||||
DEF_START_WR_FLASH_ADDR = 0x010000
|
||||
|
||||
PHY_FLASH_SECTOR_SIZE = 4096
|
||||
PHY_FLASH_SECTOR_MASK = 0xfffff000
|
||||
PHY_WR_BLK_SIZE = 0x2000
|
||||
|
||||
__progname__ = 'PHY62x2 OTA Utility'
|
||||
__filename__ = 'phy62x2_ota.py'
|
||||
__version__ = "22.01.24"
|
||||
|
||||
def do_crc(s, c):
|
||||
return zlib.crc32(s, c) & 0xffffffff
|
||||
|
||||
class phy_ota:
|
||||
def ParseHexFile(self, hexfile):
|
||||
try:
|
||||
fin = open(hexfile)
|
||||
except:
|
||||
print('No file opened', hexfile)
|
||||
return None
|
||||
table = []
|
||||
result = bytearray()
|
||||
addr = 0
|
||||
naddr = 0
|
||||
taddr = 0
|
||||
addr_flg = 0
|
||||
table.append([0, result, 0x2000])
|
||||
for hexstr in fin.readlines():
|
||||
hexstr = hexstr.strip()
|
||||
if hexstr[7:9] == '04':
|
||||
if(len(result)):
|
||||
#print(hex(addr))
|
||||
table.append([addr, result, 0])
|
||||
addr = int(hexstr[9:13],16) << 16
|
||||
addr_flg = 0
|
||||
result = bytearray()
|
||||
continue
|
||||
if hexstr[7:9] == '05' or hexstr[7:9] == '01':
|
||||
table.append([addr, result, 0])
|
||||
break
|
||||
taddr = (int(hexstr[3:7],16))
|
||||
if addr_flg == 0:
|
||||
addr_flg = 1
|
||||
addr = addr | taddr
|
||||
naddr = taddr
|
||||
if taddr != naddr:
|
||||
addr_flg = 1
|
||||
table.append([addr, result, 0])
|
||||
addr = (addr & 0xFFFF0000) | taddr
|
||||
result = bytearray()
|
||||
#print(hexstr[9:-3])
|
||||
result.extend(bytearray.fromhex(hexstr[9:-2]))
|
||||
naddr = taddr + int(hexstr[1:3],16)
|
||||
fin.close()
|
||||
return table
|
||||
def WriteHexf(self, sn, ph):
|
||||
offset = ph[2]
|
||||
offset &= 0x00ffffff
|
||||
idx = 0
|
||||
size = len(ph[1])
|
||||
return True
|
||||
def HexfHeader(self, hp, start = DEF_START_RUN_APP_ADDR, raddr = DEF_START_WR_FLASH_ADDR, otaid = START_UP_FLAG):
|
||||
if len(hp) > 1:
|
||||
if len(hp) > 15:
|
||||
print('Maximum number of segments = 15!')
|
||||
return None
|
||||
size = 0x100
|
||||
sections = 15
|
||||
faddr_min = MAX_FLASH_SIZE-1
|
||||
faddr_max = 0
|
||||
rsize = 0
|
||||
hexf = bytearray(struct.pack('<IIII', otaid, len(hp), start, 0xffffffff))
|
||||
for ihp in hp:
|
||||
if (ihp[0] & 0x1fff0000) == 0x1fff0000: # SRAM
|
||||
rsize += len(ihp[1])
|
||||
elif (ihp[0] & (~(MAX_FLASH_SIZE-1))) == 0x11000000: # Flash
|
||||
offset = ihp[0] & (MAX_FLASH_SIZE-1)
|
||||
if faddr_min > offset:
|
||||
faddr_min = offset
|
||||
send = offset + len(ihp[1])
|
||||
if faddr_max <= send:
|
||||
faddr_max = send
|
||||
if (raddr + rsize) >= faddr_min:
|
||||
raddr = (faddr_max + 3) & 0xfffffffc
|
||||
#print('Test: Flash addr min: %08x, max: %08x, RAM addr: %08x' % (faddr_min, faddr_max, raddr))
|
||||
print ('---- Segments Table -------------------------------------')
|
||||
for ihp in hp:
|
||||
if (ihp[0] & 0x1fff0000) == 0x1fff0000: # SRAM
|
||||
faddr = raddr
|
||||
raddr += (len(ihp[1])+3) & 0xfffffffc
|
||||
elif (ihp[0] & (~(MAX_FLASH_SIZE-1))) == 0x11000000: # Flash
|
||||
faddr = ihp[0] & (MAX_FLASH_SIZE-1)
|
||||
elif ihp[0] == 0:
|
||||
continue
|
||||
else:
|
||||
print('Invalid Segment Address 0x%08x!' % ihp[0])
|
||||
return None
|
||||
ihp[2] = faddr
|
||||
sections -= 1
|
||||
print('Segment: %08x <- Flash addr: %08x, Size: %08x' % (ihp[0], faddr, len(ihp[1])))
|
||||
hexf.extend(bytearray(struct.pack('<IIII', faddr, len(ihp[1]), ihp[0], 0xffffffff)))
|
||||
fill = len(ihp[1]) % 4
|
||||
if fill != 0:
|
||||
ihp[1].extend(bytearray(b'\xff')*(4 - fill))
|
||||
size += len(ihp[1])
|
||||
if sections > 0:
|
||||
hexf.extend(bytearray(b'\xff')*(0x10*sections))
|
||||
fill = size % 16
|
||||
if fill != 0:
|
||||
hp[len(hp)-1][1].extend(bytearray(b'\xff')*(16 - fill))
|
||||
size += 16 - fill
|
||||
hexf[12:16] = int.to_bytes(size, 4, byteorder='little')
|
||||
return hexf
|
||||
return None
|
||||
|
||||
class FatalError(RuntimeError):
|
||||
def __init__(self, message):
|
||||
RuntimeError.__init__(self, message)
|
||||
|
||||
@staticmethod
|
||||
def WithResult(message, result):
|
||||
message += " (result was %s)" % hexify(result)
|
||||
return FatalError(message)
|
||||
|
||||
def arg_auto_int(x):
|
||||
return int(x, 0)
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='%s version %s' % (__progname__, __version__), prog = __filename__)
|
||||
parser.add_argument('--flgota', '-f', help = 'Flag OTA (default: 0x%08x)' % START_UP_FLAG, type = arg_auto_int, default = START_UP_FLAG);
|
||||
parser.add_argument('--start', '-s', help = 'Application start address (default: 0x%08x)' % DEF_START_RUN_APP_ADDR, type = arg_auto_int, default = DEF_START_RUN_APP_ADDR);
|
||||
parser.add_argument('--address', '-a', 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('--outfile', '-o', help = 'Output bin file')
|
||||
parser.add_argument('filename', help = 'Name of hex file')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
print('=========================================================')
|
||||
print('%s version %s' % (__progname__, __version__))
|
||||
print('---------------------------------------------------------')
|
||||
phy = phy_ota()
|
||||
|
||||
hp = phy.ParseHexFile(args.filename)
|
||||
|
||||
if hp == None:
|
||||
sys.exit(2)
|
||||
hexf = phy.HexfHeader(hp, args.start, args.address, args.flgota)
|
||||
if hexf == None:
|
||||
sys.exit(2)
|
||||
hp[0][1] = hexf
|
||||
print ('----------------------------------------------------------')
|
||||
(outfile, ext) = os.path.splitext(args.filename)
|
||||
outfile += '.bin'
|
||||
if args.outfile != None:
|
||||
outfile = args.outfile
|
||||
try:
|
||||
fout = open(outfile, 'wb')
|
||||
except:
|
||||
print('No file opened', outfile)
|
||||
sys.exit(3)
|
||||
fsize = 0
|
||||
for ihp in hp:
|
||||
fsize += len(ihp[1])
|
||||
fillsize = 16 - fsize % 16
|
||||
fsize += fillsize
|
||||
segment = 0
|
||||
crc = 0
|
||||
try:
|
||||
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])))
|
||||
else:
|
||||
print('Segment: %08x <- Flash addr: %08x, Size: %08x' % (ihp[0], ihp[2], len(ihp[1])))
|
||||
fout.write(ihp[1])
|
||||
crc = do_crc(ihp[1], crc)
|
||||
segment += 1
|
||||
crc = 0xffffffff - crc
|
||||
#print('CRC32: %04x' % crc)
|
||||
fout.write(bytearray(struct.pack('<I', crc)))
|
||||
size = fout.tell()
|
||||
fout.close()
|
||||
except:
|
||||
print('No write file', outfile)
|
||||
sys.exit(3)
|
||||
print ('----------------------------------------------------------')
|
||||
print ('Write to file: %s %u bytes - ok.' % (outfile, size))
|
||||
sys.exit(0)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
@ -134,6 +134,9 @@ int ota_parser(unsigned char *pout, unsigned char *pmsg, unsigned int msg_size)
|
|||
ota.pkt_index = -1;
|
||||
ota.pkt_total = 0;
|
||||
ota.fw_value = START_UP_FLAG;
|
||||
/* GAPRole_SendUpdateParam( gapRole_MinConnInterval, gapRole_MaxConnInterval,
|
||||
0, gapRole_TimeoutMultiplier,
|
||||
GAPROLE_RESEND_PARAM_UPDATE ); */
|
||||
} else if (ota_adr == CMD_OTA_SET) {
|
||||
if(ota.start_flag) {
|
||||
err_flg = OTA_NO_START;
|
||||
|
|
@ -218,18 +221,20 @@ int ota_parser(unsigned char *pout, unsigned char *pmsg, unsigned int msg_size)
|
|||
} else
|
||||
err_flg = OTA_FW_CRC32_ERR;
|
||||
}
|
||||
if (err_flg == OTA_SUCCESS && ota_adr < ota.pkt_total) {
|
||||
tmp = (ota.program_offset + (ota_adr << 4))
|
||||
if (err_flg == OTA_SUCCESS) {
|
||||
if(ota_adr < ota.pkt_total) {
|
||||
tmp = (ota.program_offset + (ota_adr << 4))
|
||||
& (~(FLASH_SECTOR_SIZE-1));
|
||||
if (tmp > ota.erase_addr) {
|
||||
ota.erase_addr = tmp;
|
||||
hal_flash_erase_sector(tmp);
|
||||
ota.debug_flag++;
|
||||
}
|
||||
hal_flash_write(ota.program_offset + (ota_adr << 4), pmsg + 2, 16);
|
||||
ota.pkt_index = ota_adr;
|
||||
} else
|
||||
err_flg = OTA_OVERFLOW;
|
||||
if (tmp > ota.erase_addr) {
|
||||
ota.erase_addr = tmp;
|
||||
hal_flash_erase_sector(tmp);
|
||||
ota.debug_flag++;
|
||||
}
|
||||
hal_flash_write(ota.program_offset + (ota_adr << 4), pmsg + 2, 16);
|
||||
ota.pkt_index = ota_adr;
|
||||
} else
|
||||
err_flg = OTA_OVERFLOW;
|
||||
}
|
||||
} else
|
||||
err_flg = OTA_PKT_CRC_ERR; // crc error
|
||||
} else
|
||||
|
|
@ -262,7 +267,7 @@ static uint32_t start_app(void) {
|
|||
|
||||
spif_read(info_seg_faddr, (uint8_t*)&info_app, sizeof(info_app));
|
||||
if(info_app.flag == START_UP_FLAG) {
|
||||
if(info_app.seg_count <= 16) {
|
||||
if(info_app.seg_count <= 15) {
|
||||
while(info_app.seg_count) {
|
||||
info_seg_faddr += sizeof(info_app);
|
||||
spif_read(info_seg_faddr, (uint8_t*)&info_seg, sizeof(info_seg));
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ int cmd_parser(uint8_t * obuf, uint8_t * ibuf, uint32_t len) {
|
|||
// } else if (cmd == CMD_ID_DNAME) {
|
||||
// } else if (cmd == CMD_ID_DEV_MAC) {
|
||||
} else if (cmd == CMD_ID_MTU) {
|
||||
if (ibuf[1] >= MTU_SIZE)
|
||||
if (ibuf[1] <= MTU_SIZE)
|
||||
ATT_UpdateMtuSize(gapRole_ConnectionHandle, ibuf[1]);
|
||||
else
|
||||
obuf[1] = 0xff;
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@
|
|||
// Maximum connection interval (units of 1.25ms, 800=1000ms) if automatic parameter update request is enabled
|
||||
#define DEFAULT_DESIRED_MAX_CONN_INTERVAL 24 // 30 ms
|
||||
// Slave latency to use if automatic parameter update request is enabled
|
||||
#define DEFAULT_DESIRED_SLAVE_LATENCY 29 // (29+1)*30 = 900 ms
|
||||
#define DEFAULT_DESIRED_SLAVE_LATENCY 0 // (29+1)*30 = 900 ms
|
||||
// Supervision timeout value (units of 10ms, 1000=10s) if automatic parameter update request is enabled
|
||||
#define DEFAULT_DESIRED_CONN_TIMEOUT 400 // 4s
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
/**************************************************************************************************
|
||||
/****************************************************************************
|
||||
Filename: sbpProfile.c
|
||||
Revised:
|
||||
Revision:
|
||||
Description: This file contains the Simple GATT profile sample GATT service
|
||||
profile for use with the BLE sample application.
|
||||
**************************************************************************************************/
|
||||
Description: This file contains the Simple GATT profile sample GATT
|
||||
service profile for use with the BLE sample application.
|
||||
*****************************************************************************/
|
||||
|
||||
/*********************************************************************
|
||||
INCLUDES
|
||||
|
|
@ -186,7 +186,6 @@ static gattAttribute_t simpleProfileAttrTbl[SERVAPP_NUM_ATTR_SUPPORTED] =
|
|||
#endif
|
||||
};
|
||||
|
||||
|
||||
/*********************************************************************
|
||||
* LOCAL FUNCTIONS
|
||||
*/
|
||||
|
|
@ -439,7 +438,6 @@ static void simpleProfile_HandleConnStatusCB( uint16_t connHandle, uint8_t chang
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void new_cmd_data(void) {
|
||||
attHandleValueNoti_t noti;
|
||||
noti.handle = simpleProfileAttrTbl[CDM_DATA_ATTR_IDX].handle;
|
||||
|
|
|
|||
|
|
@ -396,7 +396,7 @@ void SimpleBLEPeripheral_Init( uint8 task_id )
|
|||
pGlobal_config[LL_SWITCH] |= CONN_CSA2_ALLOW;
|
||||
llInitFeatureSetCodedPHY(TRUE);
|
||||
#endif
|
||||
// llInitFeatureSet2MPHY(TRUE);
|
||||
llInitFeatureSet2MPHY(TRUE);
|
||||
llInitFeatureSetDLE(TRUE);
|
||||
#else
|
||||
llInitFeatureSet2MPHY(FALSE);
|
||||
|
|
|
|||
|
|
@ -531,16 +531,17 @@ function sendLastOTA() {
|
|||
let s = "Программирование завершено за " + (new Date().getTime() - startTime) / 1000 + " секунды";
|
||||
showProgress(s);
|
||||
addLog(s);
|
||||
/* Сброс - отключен для теста
|
||||
var data = "02ff";
|
||||
return otaCharSend(data).then(_ => {
|
||||
addLog("Программирование завершено за " + (new Date().getTime() - startTime) / 1000 + " секунды");
|
||||
}).catch(function(err) {
|
||||
updateFail(err);
|
||||
});
|
||||
*/
|
||||
} else
|
||||
showError("Ошибка ("+value.getUint8(0)+") OTA: " + get_msg_ota_err(value.getUint8(0)));
|
||||
}).catch(function(err) { updateFail(err); });
|
||||
/* Сброс - отключен для теста
|
||||
var data = "02ff";
|
||||
otaCharSend(data).then(_ => {
|
||||
addLog("Программирование завершено за " + (new Date().getTime() - startTime) / 1000 + " секунды");
|
||||
}).catch(function(err) {
|
||||
updateFail(err);
|
||||
}); */
|
||||
}
|
||||
|
||||
function sendOTAblock(blockNr) {
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
python3 rdwr_phy62x2.py -p COM11 -b 1000000 -r -e wh .\bin\THB2_v06.hex
|
||||
|
|
@ -1 +1 @@
|
|||
python3 rdwr_phy62x2.py -p COM11 -e -r wh BTH01_v06.hex
|
||||
python3 rdwr_phy62x2.py -p COM11 -e -r wh BOOT_BTH01_v06.hex
|
||||
|
|
@ -1 +1 @@
|
|||
python3 rdwr_phy62x2.py -p COM11 -e -r wh THB2_v06.hex
|
||||
python3 rdwr_phy62x2.py -p COM11 -e -r wh BOOT_THB2_v06.hex
|
||||
Loading…
Add table
Add a link
Reference in a new issue