| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- #
- # $ Copyright Cypress Semiconductor $
- #
- # script for BCM4390x
- source [find mem_helper.tcl]
- source [find target/swj-dp.tcl]
- # Default is to connect under Reset
- reset_config trst_and_srst srst_nogate connect_assert_srst
- # For 'Attach' configuration use the following
- # reset_config trst_only connect_deassert_srst
- set CHIP_RAM_START 0x004A0000
- set CHIPNAME BCM43909
- set ADAPTER_SPEED_CONNECT 100
- set ADAPTER_SPEED_OPERATE 8000
- adapter speed $ADAPTER_SPEED_CONNECT
- adapter srst delay 10
- if [using_jtag] {
- jtag_ntrst_delay 10
- }
- swj_newdap $CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id 0x0ba00477 -ignore-version
- set _TARGETNAME $CHIPNAME.cpu
- dap create $CHIPNAME.dap -chain-position $CHIPNAME.cpu
- target create $_TARGETNAME cortex_r4 -dap $CHIPNAME.dap -dbgbase 0x80001000
- $_TARGETNAME configure -rtos auto -rtos-wipe-on-reset-halt 1
- # Force backplane run on fast HT clock (160Mhz) even in sleep mode and boost JTAG clock
- proc boost_jtag_speed {} {
- set CHIPC_CCS_REG 0x180001E0
- mmw $CHIPC_CCS_REG 0x02 0
- sleep 10
- adapter speed $::ADAPTER_SPEED_OPERATE
- }
- # Disable watchdog when board halted (e.g. breakpoint)
- proc halt_event_proc { } {
- set PMU_WATCHDOG_ADDRESS 0x18020634
- mww $PMU_WATCHDOG_ADDRESS 0x00000000
- }
- set _reset_mode ""
- proc init_reset { mode } {
- set ::_reset_mode $mode
- if {[using_jtag]} {
- jtag arp_init-reset
- }
- }
- $_TARGETNAME configure -event gdb-attach {
- halt
- cortex_r4 maskisr on
- gdb_breakpoint_override hard
- boost_jtag_speed
- }
- $_TARGETNAME configure -event debug-halted { halt_event_proc }
- $_TARGETNAME configure -event halted { halt_event_proc }
- $_TARGETNAME configure -event reset-start {
- adapter speed $::ADAPTER_SPEED_CONNECT
- }
- $_TARGETNAME configure -event reset-end {
- if { $::_reset_mode ne "run" } {
- boost_jtag_speed
- # SRST does not currently reset the system properly - the following is required to work around this.
- # Clear LR to avoid having the debugger think that there is a stack frame
- reg lr 0x0
- # Vector #0 - reset instruction, all others zero
- set FLOPS_ADDRESS 0x00000000
- mww [expr {$FLOPS_ADDRESS + 0x0} ] 0xB03EF000
- mww [expr {$FLOPS_ADDRESS + 0x4} ] 0x00000000 7
- # cleanup socsram settings
- set SOCSRAM_X_INDEX 0x1800C010
- set SOCSRAM_X_PDA 0x1800C044
- for { set idx 0 } { $idx <= 7 } { incr idx } {
- mww $SOCSRAM_X_INDEX $idx
- mww $SOCSRAM_X_PDA 0x80000000
- }
- }
- }
- $_TARGETNAME configure -memorymap RW 0x00000000 32 FLOPS "Interrupt Vectors"
- $_TARGETNAME configure -memorymap RO 0x00400000 0x00090000 ROM "ROM"
- $_TARGETNAME configure -memorymap RW 0x004A0000 0x00202000 RAM "RAM"
- $_TARGETNAME configure -memorymap RW 0x008A0000 0x00202000 RAM2 "RAM_uncached"
- $_TARGETNAME configure -memorymap RW 0x14000000 0x04000000 SFLASH "SFLASH"
- $_TARGETNAME configure -memorymap RW 0x18000000 0x00027000 BACKPLANE "Backplane Registers"
- $_TARGETNAME configure -memorymap RW 0x18100000 0x00032000 BACKPLANE2 "Backplane Wrapper Registers"
- $_TARGETNAME configure -memorymap RW 0x40000000 0x08000000 DDR "DDR"
- $_TARGETNAME configure -memorymap RW 0x001b0000 0x00090000 RAM "WLAN RAM"
- source [find $::SFLASH_WRITE_SCRIPT]
- proc init_attach_session {} {
- reset_config trst_only srst_gates_jtag connect_deassert_srst
- init
- }
- proc init_debug_session {} {
- reset_config trst_and_srst srst_nogate connect_assert_srst
- init
- reset init
- }
- proc ocd_gdb_restart {target_id} {
- init_debug_session
- }
- proc erase_all {} {
- if [catch {sflash_erase "$::SFLASH_LOADER_FILE" 43909}] {
- echo "** Erase operation failed **"
- } else {
- echo "** Erase operation completed successfully **"
- }
- }
- proc program {filename args} {
- set do_reset 0
- set do_exit 0
- set address 0
- foreach arg $args {
- if {[string equal $arg "preverify"]} {
- echo "** 'preverify' argument not supported **"
- } elseif {[string equal $arg "verify"]} {
- echo "** 'verify' argument not supported **"
- } elseif {[string equal $arg "reset"]} {
- set do_reset 1
- } elseif {[string equal $arg "exit"]} {
- set do_exit 1
- } else {
- set address $arg
- }
- }
- if { [file extension $filename] != ".bin" } {
- program_error "** Only binary files (*.bin) are supported, programming failed **" $do_exit
- return
- }
- # make sure init is called
- if {[catch {init}] != 0} {
- program_error "** OpenOCD init failed **" 1
- }
- # reset target and call any init scripts
- if {[catch {reset init}] != 0} {
- program_error "** Unable to reset target **" $do_exit
- }
- if [catch {sflash_write_file "$filename" "$address" "$::SFLASH_LOADER_FILE" 0 43909} ] {
- program_error "** Programming Failed **" $do_exit
- } else {
- echo "** Program operation completed successfully **"
- }
- if { $do_reset } {
- # reset target if requested
- if {$do_exit == 1} {
- # also disable target polling, we are shutting down anyway
- poll off
- }
- echo "** Resetting Target **"
- reset run
- }
- if { $do_exit } {
- shutdown
- }
- }
|