This commit is contained in:
pvvx 2017-06-21 03:00:20 +03:00
parent 34d3652711
commit 39f77eb92b
1844 changed files with 899433 additions and 7 deletions

View file

@ -0,0 +1,7 @@
@echo off
call paths.bat
cd flasher
openocd -f interface/cmsis-dap.cfg -c "adapter_khz 1000" -f rtl8710.ocd -f cortex.ocd -c "init" -c "reset halt" -c "load_ram_binary RTL00Console_ROM.bin 0x10000BA8" -c "exit"
rem -c "shutdown"

View file

@ -0,0 +1,7 @@
@echo off
call paths.bat
cd flasher
openocd -f interface/cmsis-dap.cfg -c "adapter_khz 1000" -f rtl8710.ocd -f cortex.ocd -c "init" -c "reset halt" -c "rtl8710_flash_read_id" -c "adapter_khz 5000" -c "rtl8710_flash_read ../fullflash.bin 0 1048576" -c "shutdown"
echo flash read fullflash.bin
pause

View file

@ -0,0 +1,6 @@
@echo off
call paths.bat
@cd flasher
openocd -f interface/cmsis-dap.cfg -c "adapter_khz 1000" -f rtl8710.ocd -f cortex.ocd -c "init" -c "reset halt" -c "restart_from_falsh" -c "shutdown"
rem

View file

@ -0,0 +1,6 @@
@echo off
call paths.bat
cd flasher
openocd -f interface/cmsis-dap.cfg -c "adapter_khz 3500" -f rtl8710.ocd -f cortex.ocd -c "init" -c "reset halt" -c "rtl8710_flash_read_id" -c "rtl8710_flash_auto_erase 1" -c "rtl8710_flash_auto_verify 1" -c "rtl8710_flash_write fullflash.bin 0" -c "shutdown"
pause

View file

@ -0,0 +1,3 @@
@echo off
call paths.bat
start JLink.exe -Device CORTEX-M3 -If SWD -Speed 4000 flasher\RTL00ConsoleROM.JLinkScript

View file

@ -0,0 +1,3 @@
@echo off
call paths.bat
JLink.exe -Device CORTEX-M3 -If SWD -Speed 10000 flasher/RTL_FFlash.JLinkScript

View file

@ -0,0 +1,3 @@
@echo off
call paths.bat
JLink.exe -Device CORTEX-M3 -If SWD -Speed 1000 flasher\RTL_Reset.JLinkScript

View file

@ -0,0 +1,3 @@
@echo off
call paths.bat
start JLink.exe -Device CORTEX-M3 -If SWD -Speed 4000 flasher\RTL_RunRAM.JLinkScript

View file

@ -0,0 +1,6 @@
@echo off
call paths.bat
start JLinkGDBServer.exe -device Cortex-M3 -if SWD -ir -endian little -speed 1000
arm-none-eabi-gdb.exe -x flasher/gdb_rdflash.jlink
taskkill /F /IM JLinkGDBServer.exe

View file

@ -0,0 +1,15 @@
@echo off
call paths.bat
@if exist build\obj\build.axf goto run
echo File 'build\obj\build.axf' not found!
echo Build project...
mingw32-make.exe -f Makefile all
@if not exist build\obj\build.axf goto err
:run
start JLinkGDBServer.exe -device Cortex-M3 -if SWD -ir -endian little -speed 1000
arm-none-eabi-gdb.exe -x flasher/gdb_run_ram.jlink
taskkill /F /IM JLinkGDBServer.exe
goto end
:err
echo Error!
:end

View file

@ -0,0 +1,21 @@
@echo off
call paths.bat
@if %1x==x goto xxx
set img_file=%1
goto run
:xxx
set img_file=build/bin/ram_all.bin
:run
echo define call1>flasher/flash_file.jlink
echo SetFirwareSize %img_file%>>flasher/flash_file.jlink
echo end>>flasher/flash_file.jlink
echo define call2>>flasher/flash_file.jlink
echo FlasherWrite %img_file% 0 $Image1Size>>flasher/flash_file.jlink
echo end>>flasher/flash_file.jlink
echo define call3>>flasher/flash_file.jlink
echo FlasherWrite %img_file% $Image2Addr $Image2Size>>flasher/flash_file.jlink
echo end>>flasher/flash_file.jlink
start JLinkGDBServer.exe -device Cortex-M3 -if SWD -ir -endian little -speed 3500
arm-none-eabi-gdb.exe -x flasher/gdb_wrflash.jlink
taskkill /F /IM JLinkGDBServer.exe

View file

@ -0,0 +1,6 @@
@echo off
call paths.bat
start JLinkGDBServer.exe -device Cortex-M3 -if SWD -ir -endian little -speed 1000
arm-none-eabi-gdb.exe -x flasher/gdb_init.jlink
taskkill /F /IM JLinkGDBServer.exe

View file

@ -0,0 +1,15 @@
@echo off
call paths.bat
@if exist build\bin\ota.bin goto run
echo File 'build\obj\ota.bin' not found!
echo Build project...
mingw32-make.exe -f Makefile all
@if not exist build\bin\ota.bin goto err
:run
start start JLinkGDBServer.exe -device Cortex-M3 -if SWD -ir -endian little -speed 1000
arm-none-eabi-gdb.exe -x flasher/gdb_ota.jlink
taskkill /F /IM JLinkGDBServer.exe
goto end
:err
echo Error!
:end

View file

@ -0,0 +1,7 @@
@echo off
call paths.bat
cd flasher
openocd -f interface/Jlink.cfg -c "adapter_khz 3500" -f rtl8710.ocd -f cortex.ocd -c "init" -c "reset halt" -c "rtl8710_flash_read_id" -c "adapter_khz 3900" -c "rtl8710_flash_read ../fullflash.bin 0 1048576" -c "shutdown"
echo flash read fullflash.bin
pause

View file

@ -0,0 +1,6 @@
@echo off
call paths.bat
openocd -f interface/Jlink.cfg -c "adapter_khz 1000" -f rtl8710.ocd -f cortex.ocd -c "init" -c "reset halt" -c "adapter_khz 3500" -c "rtl8710_flash_read_id" -c "rtl8710_flash_read ../fullflash.bin 0 1048576" -c "shutdown"
echo flash read fullflash.bin
pause

View file

@ -0,0 +1,4 @@
@echo off
call paths.bat
taskkill /F /IM openocd.exe
start openocd -f interface\Jlink.cfg -f flasher\ameba1.cfg

View file

@ -0,0 +1,7 @@
@echo off
call paths.bat
cd flasher
openocd -f interface/stlink-v2.cfg -c "adapter_khz 1000" -f rtl8710.ocd -f cortex.ocd -c "init" -c "reset halt" -c "rtl8710_flash_read_id" -c "adapter_khz 5000" -c "rtl8710_flash_read ../fullflash.bin 0 1048576" -c "shutdown"
echo flash read fullflash.bin
pause

View file

@ -0,0 +1,6 @@
@echo off
call paths.bat
@cd flasher
openocd -f interface/stlink-v2.cfg -c "adapter_khz 1000" -f rtl8710.ocd -f cortex.ocd -c "init" -c "reset halt" -c "cortex_reboot" -c "shutdown"
rem

View file

@ -0,0 +1,40 @@
import jlinkarm as jl
def loaddll(dll_path):
jl.loadJLinkARMdll(dll_path)
jl.open()
if jl.is_connected == 0:
raise RuntimeError('Jlink not connected')
jl.exec_command('device Cortex-M3', 0, 0)
jl.exec_command('endian little', 0, 0)
jl.tif_select(1)
jl.set_speed(1000)
jl.clear_RESET()
jl.clear_TRST()
time.sleep(0.01)
jl.set_RESET()
jl.set_TRST()
jl.reset()
jl.halt()
jl.set_speed(3500)
def ram_all(binfile, image1=True, image2=True):
bin = None
with file(binfile, 'rb') as f:
bin = f.read()
get_dword = lambda address: struct.unpack('<L', bin[address:address + 4])[0]
if image1:
i1_address = 0x0
i1_length = get_dword(0x10)
jl.write_mem(0x10000bc8, bin[i1_address + 0x20: i1_address + 0x20 + i1_length])
if image2:
i2_address = (get_dword(0x18) & 0xffff) * 1024
i2_length = get_dword(i2_address) + 0x10
jl.write_mem(0x10006000, bin[i2_address + 0x10: i2_address + 0x10 + i2_length])
jl.reset()
jl.write_u32(0x40000210, 0x20111113)
jl.go()
jl.close()

View file

@ -0,0 +1,113 @@
import ctypes
_jl = None
def loadJLinkARMdll(lib_str):
global _jl
_jl = ctypes.cdll.LoadLibrary(lib_str)
if _jl:
return _jl
else:
raise RuntimeError('JLink ARM dynamic library is not loaded')
def _jlink():
if _jl:
return _jl
else:
raise RuntimeError('JLink ARM dynamic library is not loaded')
def open():
r = _jlink().JLINKARM_Open()
if r != 0: raise RuntimeError('Adapter is not found')
def exec_command(cmd, a, b):
r = _jlink().JLINKARM_ExecCommand(cmd, a, b)
#if r != 0: raise RuntimeError('Unable to execute command')
def tif_select(n):
if not isinstance(n, ctypes.c_ulong):
n = ctypes.c_ulong(n)
r = _jlink().JLINKARM_TIF_Select(n)
if r != 0: raise RuntimeError('Unable to select TIF')
def set_speed(speed):
if not isinstance(speed, ctypes.c_ulong):
speed = ctypes.c_ulong(speed)
r = _jlink().JLINKARM_SetSpeed(speed)
#if r != 0: raise RuntimeError('Unable to set speed')
def reset():
r = _jlink().JLINKARM_Reset()
if r != 0: raise RuntimeError('fail')
def is_connected():
if _jlink().JLINKARM_IsConnected() != 0: return True
else: return False
def go():
r = _jlink().JLINKARM_Go()
#if r != 0: raise RuntimeError('fail')
def write_u32(r, val):
if not isinstance(val, ctypes.c_ulong):
val = ctypes.c_ulong(val)
r = _jlink().JLINKARM_WriteU32(r, val)
if r != 0: raise RuntimeError('fail')
def read_reg(r):
return _jlink().JLINKARM_ReadReg(r)
def write_reg(r, val):
if not isinstance(val, ctypes.c_ulong):
val = ctypes.c_ulong(val)
ret = _jlink().JLINKARM_WriteReg(r, val)
#if ret != 0: raise RuntimeError('fail')
def get_speed():
return _jlink().JLINKARM_GetSpeed()
def write_mem(startaddress, buf):
_jlink().JLINKARM_WriteMem.argtypes = [ctypes.c_int, ctypes.c_int, ctypes.c_char_p]
_jlink().JLINKARM_WriteMem.restype = ctypes.c_int
print "writemem addr %s size %s" % (hex(startaddress), hex(len(buf)))
r = _jlink().JLINKARM_WriteMem(startaddress, len(buf), buf)
#if r != 0: raise RuntimeError('fail')
def read_mem_U32(startaddress, count):
buftype=ctypes.c_uint32 * int(count)
buf=buftype()
r=_jlink().JLINKARM_ReadMemU32(startaddress, count, buf, 0)
#if r != 0: raise RuntimeError('fail')
return buf
def close():
r = _jlink().JLINKARM_Close()
#if r != 0: raise RuntimeError('fail')
def clear_TCK():
r = _jlink().JLINKARM_ClrTCK()
def set_TCK():
r = _jlink().JLINKARM_SetTCK()
def clear_TMS():
r = _jlink().JLINKARM_ClrTMS()
def set_TMS():
r = _jlink().JLINKARM_SetTMS()
def clear_TDI():
r = _jlink().JLINKARM_ClrTDI()
def set_TDI():
r = _jlink().JLINKARM_SetTDI()
def clear_TRST():
r = _jlink().JLINKARM_ClrTRST()
def set_TRST():
r = _jlink().JLINKARM_SetTRST()
def clear_RESET():
r = _jlink().JLINKARM_ClrRESET()
def set_RESET():
r = _jlink().JLINKARM_SetRESET()
def halt():
r = _jlink().JLINKARM_Halt()

View file

@ -0,0 +1 @@
PATH=D:\MCU\GNU_Tools_ARM_Embedded\5.4_2016q2\bin;D:\MCU\SEGGER\JLink_V612i;%PATH%

View file

@ -0,0 +1,53 @@
#!/usr/bin/env python3
# -*- coding: cp1251 -*-
import jlinkarm as jl
import os, sys, time, struct
dllfilename = 'D:/MCU/SEGGER/JLink_V612i/JLinkARM.dll'
if __name__ == '__main__':
if len(sys.argv) >= 2:
if sys.argv[1] == '-h':
print 'Usage: ldram.py ram_all.bin'
exit(0)
imgfilename = 'build/bin/ram_all.bin'
if len(sys.argv) > 1:
if sys.argv[1]:
imgfilename = sys.argv[1]
try:
ff = open(imgfilename, "rb")
except:
print "Error file open " + imgfilename
exit(1)
jl.loadJLinkARMdll(dllfilename)
jl.open()
if jl.is_connected == 0:
raise RuntimeError('Jlink not connected')
jl.exec_command('device Cortex-M3', 0, 0)
jl.exec_command('endian little', 0, 0)
jl.tif_select(1)
jl.set_speed(1000)
jl.clear_RESET()
jl.clear_TRST()
time.sleep(0.01)
jl.set_RESET()
jl.set_TRST()
jl.reset()
jl.halt()
jl.set_speed(3500)
bin = ff.read()
get_dword = lambda address: struct.unpack('<L', bin[address:address + 4])[0]
i1_address = 0x0
i1_length = get_dword(0x10)
jl.write_mem(0x10000bc8, bin[i1_address + 0x20: i1_address + 0x20 + i1_length])
i2_address = (get_dword(0x18) & 0xffff) * 1024
i2_length = get_dword(i2_address) + 0x10
jl.write_mem(0x10006000, bin[i2_address + 0x10: i2_address + 0x10 + i2_length])
jl.reset()
jl.write_u32(0x40000210, 0x20111113)
jl.go()
jl.close()
ff.close()
exit(0)