mirror of
https://github.com/pvvx/RTL00_WEB.git
synced 2024-12-01 18:50:35 +00:00
199 lines
5.4 KiB
Text
199 lines
5.4 KiB
Text
|
####################################
|
||
|
# J-LINK GDB SERVER initialization #
|
||
|
####################################
|
||
|
define InitJlink
|
||
|
printf "Jlink Init:\n"
|
||
|
set verbose off
|
||
|
set complaints 0
|
||
|
set confirm off
|
||
|
set exec-done-display off
|
||
|
show exec-done-display
|
||
|
set trace-commands off
|
||
|
#set debug aix-thread off
|
||
|
#set debug dwarf2-die 0
|
||
|
set debug displaced off
|
||
|
set debug expression 0
|
||
|
set debug frame 0
|
||
|
set debug infrun 0
|
||
|
set debug observer 0
|
||
|
set debug overload 0
|
||
|
#set debugvarobj 0
|
||
|
set pagination off
|
||
|
set print address off
|
||
|
set print symbol-filename off
|
||
|
set print symbol off
|
||
|
set print pretty off
|
||
|
set print object off
|
||
|
#set debug notification off
|
||
|
set debug parser off
|
||
|
set debug remote 0
|
||
|
target remote localhost:2331
|
||
|
set remotetimeout 10000
|
||
|
monitor device Cortex-M3
|
||
|
monitor endian little
|
||
|
monitor reset
|
||
|
# Set max speed
|
||
|
monitor speed 4000
|
||
|
set mem inaccessible-by-default off
|
||
|
# Setup GDB FOR FASTER DOWNLOADS
|
||
|
set remote memory-write-packet-size 8192
|
||
|
set remote memory-write-packet-size fixed
|
||
|
end
|
||
|
#############
|
||
|
# Boot_Flash
|
||
|
define SetBootFlash
|
||
|
printf "SetBoot = Flash:\n"
|
||
|
monitor long 0x40000210 = 0x211157
|
||
|
end
|
||
|
# Boot RAM start_addr0() Run if ( v400001F4 & 0x8000000 ) && ( v40000210 & 0x80000000 )
|
||
|
define SetBootCall0
|
||
|
printf "SetBoot = Call0:\n"
|
||
|
monitor long 0x40000210 = 0x80111157
|
||
|
end
|
||
|
# Boot RAM start_addr1() Run if ( v40000210 & 0x20000000 )
|
||
|
define SetBootCall1
|
||
|
printf "SetBoot = Call1:\n"
|
||
|
monitor long 0x40000210 = 0x20111157
|
||
|
end
|
||
|
# Boot RAM start_addr2() Run if ( v40000210 & 0x10000000 )
|
||
|
define SetBootCall2
|
||
|
printf "SetBoot = Call2:\n"
|
||
|
monitor long 0x40000210 = 0x10111157
|
||
|
end
|
||
|
# Boot RAM start_addr3() Run if ( v400001F4 & 0x8000000 ) && ( v40000210 & 0x8000000 )
|
||
|
define SetBootCall3
|
||
|
printf "SetBoot = Call3:\n"
|
||
|
monitor long 0x40000210 = 0x8111157
|
||
|
end
|
||
|
# Boot RAM start_addr4() Init console, Run if ( v40000210 & 0x4000000 )
|
||
|
define SetBootCall4
|
||
|
printf "SetBoot = Call4:\n"
|
||
|
monitor long 0x40000210 = 0x4111157
|
||
|
end
|
||
|
# CPU CLK 166 MHz?
|
||
|
define SetClk166MHz
|
||
|
printf "SetCLK 166.66MHz:\n"
|
||
|
monitor long 0x40000014 = 0x00000011
|
||
|
end
|
||
|
# CPU CLK 83 MHz?
|
||
|
define SetClk83MHz
|
||
|
printf "SetCLK 83.33MHz:\n"
|
||
|
monitor long 0x40000014 = 0x00000021
|
||
|
end
|
||
|
###############
|
||
|
# System Init #
|
||
|
###############
|
||
|
define SystemInit
|
||
|
printf "System Init:\n"
|
||
|
monitor long 0x40000304 = 0x1FC00002
|
||
|
monitor long 0x40000250 = 0x400
|
||
|
monitor long 0x40000340 = 0x0
|
||
|
monitor long 0x40000230 = 0xdcc4
|
||
|
monitor long 0x40000210 = 0x11117
|
||
|
monitor long 0x40000210 = 0x11157
|
||
|
monitor long 0x400002c0 = 0x110011
|
||
|
monitor long 0x40000320 = 0xffffffff
|
||
|
end
|
||
|
############
|
||
|
# SPI Init #
|
||
|
############
|
||
|
define SPI_Init
|
||
|
printf "Init SPI:\n"
|
||
|
#enable spi flash peripheral clock
|
||
|
set $Temp = {int}(0x40000230)
|
||
|
set $Temp = ($Temp | 0x300)
|
||
|
set {int}(0x40000230) = $Temp
|
||
|
#enable spi flash peripheral
|
||
|
set $Temp = {int}(0x40000210)
|
||
|
set $Temp = ($Temp | 0x10)
|
||
|
set {int}(0x40000210) = $Temp
|
||
|
#select spi flash pinout (0 - internal), enable spi flash pins
|
||
|
set $Temp = {int}(0x400002C0)
|
||
|
set $Temp = (($Temp & 0xFFFFFFF8) | 1)
|
||
|
set {int}(0x400002C0) = $Temp
|
||
|
#disable SPI FLASH operation
|
||
|
monitor long 0x40006008 = 0
|
||
|
#disable all interrupts
|
||
|
monitor long 0x4000602C = 0
|
||
|
#use first "slave select" pin
|
||
|
monitor long 0x40006010 = 1
|
||
|
#baud rate, default value
|
||
|
monitor long 0x40006014 = 2
|
||
|
#tx fifo threshold
|
||
|
monitor long 0x40006018 = 0
|
||
|
#rx fifo threshold
|
||
|
monitor long 0x4000601C = 0
|
||
|
#disable DMA
|
||
|
monitor long 0x4000604C = 0
|
||
|
set $SPI_FLASH_BASE = 0x98000000
|
||
|
end
|
||
|
###################
|
||
|
# SetFirwareSize #
|
||
|
###################
|
||
|
define SetFirwareSize
|
||
|
set $rambuffer = 0x10000300
|
||
|
printf "Get ImagesSize:\n"
|
||
|
restore $arg0 binary $rambuffer 0 0x20
|
||
|
set $Image1Size = {int}($rambuffer+0x10) + 32
|
||
|
set $Image1LoadAddr = {int}($rambuffer+0x14)
|
||
|
set $Image2Addr = {short}($rambuffer+0x18) * 1024
|
||
|
if $Image1Size != 0 && $Image1Size < 0x1000000
|
||
|
if $Image2Addr == 0
|
||
|
set $Image2Addr = $Image1Size
|
||
|
end
|
||
|
printf "Image1Size = %d\n", $Image1Size
|
||
|
printf "Image1LoadAddr = 0x%08x\n", $Image1LoadAddr
|
||
|
printf "Image2FlashAddr = 0x%08x\n", $Image2Addr
|
||
|
set $parms1 = $rambuffer - $Image2Addr
|
||
|
set $parms3 = $Image2Addr + 0x08
|
||
|
restore $arg0 binary $parms1 $Image2Addr $parms3
|
||
|
set $Image2Size = {int}($rambuffer)
|
||
|
set $Image2LoadAddr = {int}($rambuffer+0x4)
|
||
|
if $Image2Size != 0xFFFFFFFF && $Image2Size != 0
|
||
|
set $Image2Size = $Image2Size + 16
|
||
|
printf "Image2Size = %d\n", $Image2Size
|
||
|
printf "Image2LoadAddr = 0x%08x\n", $Image2LoadAddr
|
||
|
set $FirmwareSize = $Image2Addr + $Image2Size
|
||
|
printf "FirmwareSize = %d\n", $FirmwareSize
|
||
|
else
|
||
|
set $Image2Size = 0
|
||
|
printf "Image2 - None\n"
|
||
|
set $FirmwareSize = $Image1Size
|
||
|
printf "FirmwareSize = %d\n", $FirmwareSize
|
||
|
end
|
||
|
else
|
||
|
set $Image1Size = 0
|
||
|
set $Image2Size = 0
|
||
|
set $Image2Addr = 0
|
||
|
set $FirmwareSize = 0
|
||
|
printf "Image not format Firmware!\n"
|
||
|
end
|
||
|
end
|
||
|
#####################
|
||
|
# Flash Images Info #
|
||
|
#####################
|
||
|
define FlashImagesInfo
|
||
|
printf "Flash Info:\n"
|
||
|
set $Image1Size = {int}($SPI_FLASH_BASE + 0x10) + 32
|
||
|
set $Image1LoadAddr = {int}($SPI_FLASH_BASE + 0x14)
|
||
|
if $Image1LoadAddr == 0xFFFFFFFF
|
||
|
printf "Image1 - None\n"
|
||
|
else
|
||
|
set $Image2FlashAddr = {short}($SPI_FLASH_BASE + 0x18) * 1024
|
||
|
if $Image2FlashAddr == 0
|
||
|
$Image2FlashAddr = $Image1Size
|
||
|
end
|
||
|
set $Image2Size = {int}($Image2FlashAddr + $SPI_FLASH_BASE)
|
||
|
set $Image2LoadAddr = {int}($Image2FlashAddr + $SPI_FLASH_BASE + 0x4)
|
||
|
printf "Image1Size = %d\n", $Image1Size
|
||
|
printf "Image1LoadAddr = 0x%08x\n", $Image1LoadAddr
|
||
|
printf "Image2FlashAddr = 0x%08x\n", $Image2FlashAddr
|
||
|
if $Image2Size != 0xFFFFFFFF
|
||
|
printf "Image2Size = %d\n", $Image2Size
|
||
|
printf "Image2LoadAddr = 0x%08x\n", $Image2LoadAddr
|
||
|
else
|
||
|
printf "Image2 - None\n"
|
||
|
end
|
||
|
end
|
||
|
end
|