You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(75) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(70) |
Feb
(20) |
Mar
(52) |
Apr
(149) |
May
(387) |
Jun
(466) |
Jul
(133) |
Aug
(87) |
Sep
(122) |
Oct
(140) |
Nov
(185) |
Dec
(105) |
2010 |
Jan
(85) |
Feb
(45) |
Mar
(75) |
Apr
(17) |
May
(41) |
Jun
(52) |
Jul
(33) |
Aug
(29) |
Sep
(36) |
Oct
(15) |
Nov
(26) |
Dec
(34) |
2011 |
Jan
(26) |
Feb
(25) |
Mar
(26) |
Apr
(29) |
May
(20) |
Jun
(27) |
Jul
(15) |
Aug
(32) |
Sep
(13) |
Oct
(64) |
Nov
(60) |
Dec
(10) |
2012 |
Jan
(64) |
Feb
(63) |
Mar
(39) |
Apr
(43) |
May
(54) |
Jun
(11) |
Jul
(30) |
Aug
(45) |
Sep
(11) |
Oct
(70) |
Nov
(24) |
Dec
(23) |
2013 |
Jan
(17) |
Feb
(8) |
Mar
(35) |
Apr
(40) |
May
(20) |
Jun
(24) |
Jul
(36) |
Aug
(25) |
Sep
(42) |
Oct
(40) |
Nov
(9) |
Dec
(21) |
2014 |
Jan
(29) |
Feb
(24) |
Mar
(60) |
Apr
(22) |
May
(22) |
Jun
(46) |
Jul
(11) |
Aug
(23) |
Sep
(26) |
Oct
(10) |
Nov
(14) |
Dec
(2) |
2015 |
Jan
(28) |
Feb
(47) |
Mar
(33) |
Apr
(58) |
May
(5) |
Jun
(1) |
Jul
|
Aug
(8) |
Sep
(12) |
Oct
(25) |
Nov
(58) |
Dec
(21) |
2016 |
Jan
(12) |
Feb
(40) |
Mar
(2) |
Apr
(1) |
May
(67) |
Jun
(2) |
Jul
(5) |
Aug
(36) |
Sep
|
Oct
(24) |
Nov
(17) |
Dec
(50) |
2017 |
Jan
(14) |
Feb
(16) |
Mar
(2) |
Apr
(35) |
May
(14) |
Jun
(16) |
Jul
(3) |
Aug
(3) |
Sep
|
Oct
(19) |
Nov
|
Dec
(16) |
2018 |
Jan
(55) |
Feb
(11) |
Mar
(34) |
Apr
(14) |
May
(4) |
Jun
(20) |
Jul
(39) |
Aug
(16) |
Sep
(17) |
Oct
(16) |
Nov
(20) |
Dec
(30) |
2019 |
Jan
(29) |
Feb
(24) |
Mar
(37) |
Apr
(26) |
May
(19) |
Jun
(21) |
Jul
(2) |
Aug
(3) |
Sep
(9) |
Oct
(12) |
Nov
(12) |
Dec
(12) |
2020 |
Jan
(47) |
Feb
(36) |
Mar
(54) |
Apr
(44) |
May
(37) |
Jun
(19) |
Jul
(32) |
Aug
(13) |
Sep
(16) |
Oct
(24) |
Nov
(32) |
Dec
(11) |
2021 |
Jan
(14) |
Feb
(5) |
Mar
(40) |
Apr
(32) |
May
(42) |
Jun
(31) |
Jul
(29) |
Aug
(47) |
Sep
(38) |
Oct
(17) |
Nov
(74) |
Dec
(33) |
2022 |
Jan
(11) |
Feb
(15) |
Mar
(40) |
Apr
(21) |
May
(39) |
Jun
(44) |
Jul
(19) |
Aug
(46) |
Sep
(79) |
Oct
(35) |
Nov
(21) |
Dec
(15) |
2023 |
Jan
(56) |
Feb
(13) |
Mar
(43) |
Apr
(28) |
May
(60) |
Jun
(15) |
Jul
(29) |
Aug
(28) |
Sep
(32) |
Oct
(21) |
Nov
(42) |
Dec
(39) |
2024 |
Jan
(35) |
Feb
(17) |
Mar
(28) |
Apr
(7) |
May
(14) |
Jun
(35) |
Jul
(30) |
Aug
(35) |
Sep
(30) |
Oct
(28) |
Nov
(38) |
Dec
(18) |
2025 |
Jan
(21) |
Feb
(28) |
Mar
(36) |
Apr
(35) |
May
(34) |
Jun
(58) |
Jul
(9) |
Aug
(50) |
Sep
|
Oct
|
Nov
|
Dec
|
From: Øyvind H. <go...@us...> - 2010-11-09 09:27:26
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via e7b2958229c7e0d7e98e130764aa50d1ca9017d3 (commit) via 4747af362de04b508c91df4004d2aed5579c8a1c (commit) via d220e22e6376fa67d85c9731a4165f86609390d8 (commit) from fc4e001de34029ca6451038a351b433677d4f388 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit e7b2958229c7e0d7e98e130764aa50d1ca9017d3 Author: Antonio Borneo <bor...@gm...> Date: Mon Nov 8 17:23:49 2010 +0800 TCL scripts: replace "puts" with "echo" Signed-off-by: Antonio Borneo <bor...@gm...> diff --git a/src/jtag/startup.tcl b/src/jtag/startup.tcl index fdd3078..1779df5 100644 --- a/src/jtag/startup.tcl +++ b/src/jtag/startup.tcl @@ -30,7 +30,7 @@ proc init_reset { mode } { # documented nor supported except on ZY1000. proc power_restore {} { - puts "Sensed power restore, running reset init and halting GDB." + echo "Sensed power restore, running reset init and halting GDB." reset init # Halt GDB so user can deal with a detected power restore. @@ -47,7 +47,7 @@ proc power_restore {} { add_help_text power_restore "Overridable procedure run when power restore is detected. Runs 'reset init' by default." proc power_dropout {} { - puts "Sensed power dropout." + echo "Sensed power dropout." } ######### @@ -56,7 +56,7 @@ proc power_dropout {} { # documented nor supported except on ZY1000. proc srst_deasserted {} { - puts "Sensed nSRST deasserted, running reset init and halting GDB." + echo "Sensed nSRST deasserted, running reset init and halting GDB." reset init # Halt GDB so user can deal with a detected reset. @@ -73,7 +73,7 @@ proc srst_deasserted {} { add_help_text srst_deasserted "Overridable procedure run when srst deassert is detected. Runs 'reset init' by default." proc srst_asserted {} { - puts "Sensed nSRST asserted." + echo "Sensed nSRST asserted." } # measure actual JTAG clock diff --git a/tcl/bitsbytes.tcl b/tcl/bitsbytes.tcl index 3f65c20..2c4fd29 100644 --- a/tcl/bitsbytes.tcl +++ b/tcl/bitsbytes.tcl @@ -54,7 +54,7 @@ proc show_normalize_bitfield { VALUE MSB LSB } { set m [create_mask $MSB $LSB] set mr [expr $VALUE & $m] set sr [expr $mr >> $LSB] - puts [format "((0x%08x & 0x%08x) -> 0x%08x) >> %2d => (0x%x) %5d " $VALUE $m $mr $LSB $sr $sr] + echo [format "((0x%08x & 0x%08x) -> 0x%08x) >> %2d => (0x%x) %5d " $VALUE $m $mr $LSB $sr $sr] return $sr } diff --git a/tcl/board/at91eb40a.cfg b/tcl/board/at91eb40a.cfg index 14f21a1..dc5aacb 100644 --- a/tcl/board/at91eb40a.cfg +++ b/tcl/board/at91eb40a.cfg @@ -53,7 +53,7 @@ flash bank $_FLASHNAME ecosflash 0x01000000 0x200000 2 2 $_TARGETNAME ecos/at91e $_TARGETNAME configure -work-area-phys 0x00030000 -work-area-size 0x10000 -work-area-backup 0 $_TARGETNAME configure -event reset-init { - puts "Running reset init script for AT91EB40A" + echo "Running reset init script for AT91EB40A" # Reset script for AT91EB40a reg cpsr 0x000000D3 mww 0xFFE00020 0x1 diff --git a/tcl/board/dm355evm.cfg b/tcl/board/dm355evm.cfg index 02c4c86..0c971e9 100644 --- a/tcl/board/dm355evm.cfg +++ b/tcl/board/dm355evm.cfg @@ -18,7 +18,7 @@ $_TARGETNAME configure -event reset-init { dm355evm_init } proc dm355evm_init {} { global dm355 - puts "Initialize DM355 EVM board" + echo "Initialize DM355 EVM board" # CLKIN = 24 MHz ... can't talk quickly to ARM yet jtag_rclk 1500 diff --git a/tcl/board/dm6446evm.cfg b/tcl/board/dm6446evm.cfg index dcd1c4e..0d2f6a4 100644 --- a/tcl/board/dm6446evm.cfg +++ b/tcl/board/dm6446evm.cfg @@ -59,7 +59,7 @@ $_TARGETNAME configure -event reset-init { dm6446evm_init } # proc dm6446evm_init {} { - puts "Initialize DM6446 EVM board" + echo "Initialize DM6446 EVM board" # FIXME initialize everything: # - PLL1 diff --git a/tcl/board/ethernut3.cfg b/tcl/board/ethernut3.cfg index 34e9b72..ad45527 100644 --- a/tcl/board/ethernut3.cfg +++ b/tcl/board/ethernut3.cfg @@ -77,10 +77,10 @@ proc board_remap {{VERBOSE 0}} { mww 0xffe00020 0x00000001 if {$VERBOSE != 0} { - puts "0x00000000 RAM" - puts "0x10000000 Flash" - puts "0x20000000 Ethernet" - puts "0x21000000 CPLD" - puts "0x22000000 Expansion" + echo "0x00000000 RAM" + echo "0x10000000 Flash" + echo "0x20000000 Ethernet" + echo "0x21000000 CPLD" + echo "0x22000000 Expansion" } } diff --git a/tcl/board/lubbock.cfg b/tcl/board/lubbock.cfg index b58ad5a..298954c 100644 --- a/tcl/board/lubbock.cfg +++ b/tcl/board/lubbock.cfg @@ -38,7 +38,7 @@ proc hexled {u32} { proc lubbock_init {target} { - puts "Initialize PXA255 Lubbock board" + echo "Initialize PXA255 Lubbock board" # (1) pinmux diff --git a/tcl/board/olimex_sam9_l9260.cfg b/tcl/board/olimex_sam9_l9260.cfg index 7c4b2cc..5c16ed2 100644 --- a/tcl/board/olimex_sam9_l9260.cfg +++ b/tcl/board/olimex_sam9_l9260.cfg @@ -35,7 +35,7 @@ $_TARGETNAME configure -event reset-init { ## # Clock configuration for 99.328 MHz main clock. ## - puts "Setting up clock" + echo "Setting up clock" mww 0xfffffc20 0x00004001 # CKGR_MOR : enable main oscillator, 512 slow clock startup sleep 20 # wait 20 ms (need 15.6 ms for startup) mww 0xfffffc30 0x00000001 # PMC_MCKR : switch to main oscillator (18.432 MHz) @@ -54,7 +54,7 @@ $_TARGETNAME configure -event reset-init { ## # SDRAM configuration for 2 x Samsung K4S561632J-UC75, 4M x 16Bit x 4 Banks. ## - puts "Configuring SDRAM" + echo "Configuring SDRAM" mww 0xfffff870 0xffff0000 # PIOC_ASR : select peripheral function for D15..D31 mww 0xfffff804 0xffff0000 # PIOC_PDR : disable PIO function for D15..D31 @@ -92,7 +92,7 @@ $_TARGETNAME configure -event reset-init { ## # NAND Flash Configuration for 1 x Samsung K9F4G08U0M, 512M x 8Bit. ## - puts "Configuring NAND flash" + echo "Configuring NAND flash" mww 0xfffffc10 0x00000010 ;# PMC_PCER : enable PIOC clock mww 0xfffff800 0x00006000 ;# PIOC_PER : enable PIO function for 13(RDY/~BSY) and 14(~CS) mww 0xfffff810 0x00004000 ;# PIOC_OER : enable output on 14 @@ -116,7 +116,7 @@ $_TARGETNAME configure -event reset-init { ## # Dataflash configuration for 1 x Atmel AT45DB161D, 16Mbit ## - puts "Setting up dataflash" + echo "Setting up dataflash" mww 0xfffff404 0x00000807 ;# PIOA_PDR : disable PIO function for 0(SPI0_MISO), 1(SPI0_MOSI), # 2(SPI0_SPCK), and 11(SPI0_NPCS1) mww 0xfffff470 0x00000007 ;# PIOA_ASR : select peripheral A function for 0, 1, and 2 diff --git a/tcl/board/telo.cfg b/tcl/board/telo.cfg index 1c0ad76..119373c 100644 --- a/tcl/board/telo.cfg +++ b/tcl/board/telo.cfg @@ -31,24 +31,24 @@ $_TARGETNAME configure -event reset-init { setupTelo #turn up the JTAG speed adapter_khz 3000 - puts "JTAG speek now 3MHz" - puts "type helpC100 to get help on C100" + echo "JTAG speek now 3MHz" + echo "type helpC100 to get help on C100" } $_TARGETNAME configure -event reset-deassert-post { # Force target into ARM state. # soft_reset_halt # not implemented on ARM11 - puts "Detected SRSRT asserted on C100.CPU" + echo "Detected SRSRT asserted on C100.CPU" } $_TARGETNAME configure -event reset-assert-post { - puts "Assering reset" + echo "Assering reset" #sleep 10 } -proc power_restore {} { puts "Sensed power restore. No action." } -proc srst_deasserted {} { puts "Sensed nSRST deasserted. No action." } +proc power_restore {} { echo "Sensed power restore. No action." } +proc srst_deasserted {} { echo "Sensed nSRST deasserted. No action." } # boots from NOR on CS0: 8 MBytes CFI flash, 16-bit bus diff --git a/tcl/board/zy1000.cfg b/tcl/board/zy1000.cfg index d2561e9..63334ee 100644 --- a/tcl/board/zy1000.cfg +++ b/tcl/board/zy1000.cfg @@ -85,11 +85,11 @@ proc production_info {} { # Progress messages are output via puts proc production {firmwarefile serialnumber} { if {[string length $serialnumber]!=12} { - puts "Invalid serial number" + echo "Invalid serial number" return } - puts "Power cycling target" + echo "Power cycling target" power off sleep 3000 power on @@ -99,10 +99,10 @@ proc production {firmwarefile serialnumber} { verify_image $firmwarefile 0x1000000 bin # Big endian... weee!!!! - puts "Setting MAC number to $serialnumber" + echo "Setting MAC number to $serialnumber" flash fillw [expr 0x1030000-0x8] "0x[string range $serialnumber 2 3][string range $serialnumber 0 1]0000" 1 flash fillw [expr 0x1030000-0x4] "0x[string range $serialnumber 10 11][string range $serialnumber 8 9][string range $serialnumber 6 7][string range $serialnumber 4 5]" 1 - puts "Production successful" + echo "Production successful" } diff --git a/tcl/chip/atmel/at91/aic.tcl b/tcl/chip/atmel/at91/aic.tcl index 366be6d..6dae36a 100644 --- a/tcl/chip/atmel/at91/aic.tcl +++ b/tcl/chip/atmel/at91/aic.tcl @@ -57,33 +57,33 @@ proc show_AIC { } { if [catch { mem2array aaa 32 $AIC_SMR [expr 32 * 4] } msg ] { error [format "%s (%s)" $msg AIC_SMR] } - puts "AIC_SMR: Mode & Type" + echo "AIC_SMR: Mode & Type" global AT91C_ID for { set x 0 } { $x < 32 } { } { - puts -nonewline " " - puts -nonewline [format "%2d: %5s 0x%08x | " $x $AT91C_ID($x) $aaa($x)] + echo -n " " + echo -n [format "%2d: %5s 0x%08x | " $x $AT91C_ID($x) $aaa($x)] incr x - puts -nonewline [format "%2d: %5s 0x%08x | " $x $AT91C_ID($x) $aaa($x)] + echo -n [format "%2d: %5s 0x%08x | " $x $AT91C_ID($x) $aaa($x)] incr x - puts -nonewline [format "%2d: %5s 0x%08x | " $x $AT91C_ID($x) $aaa($x)] + echo -n [format "%2d: %5s 0x%08x | " $x $AT91C_ID($x) $aaa($x)] incr x - puts [format "%2d: %5s 0x%08x" $x $AT91C_ID($x) $aaa($x)] + echo [format "%2d: %5s 0x%08x" $x $AT91C_ID($x) $aaa($x)] incr x } global AIC_SVR if [catch { mem2array aaa 32 $AIC_SVR [expr 32 * 4] } msg ] { error [format "%s (%s)" $msg AIC_SVR] } - puts "AIC_SVR: Vectors" + echo "AIC_SVR: Vectors" for { set x 0 } { $x < 32 } { } { - puts -nonewline " " - puts -nonewline [format "%2d: %5s 0x%08x | " $x $AT91C_ID($x) $aaa($x)] + echo -n " " + echo -n [format "%2d: %5s 0x%08x | " $x $AT91C_ID($x) $aaa($x)] incr x - puts -nonewline [format "%2d: %5s 0x%08x | " $x $AT91C_ID($x) $aaa($x)] + echo -n [format "%2d: %5s 0x%08x | " $x $AT91C_ID($x) $aaa($x)] incr x - puts -nonewline [format "%2d: %5s 0x%08x | " $x $AT91C_ID($x) $aaa($x)] + echo -n [format "%2d: %5s 0x%08x | " $x $AT91C_ID($x) $aaa($x)] incr x - puts [format "%2d: %5s 0x%08x" $x $AT91C_ID($x) $aaa($x)] + echo [format "%2d: %5s 0x%08x" $x $AT91C_ID($x) $aaa($x)] incr x } diff --git a/tcl/chip/atmel/at91/rtt.tcl b/tcl/chip/atmel/at91/rtt.tcl index 433cfe3..8be6a56 100644 --- a/tcl/chip/atmel/at91/rtt.tcl +++ b/tcl/chip/atmel/at91/rtt.tcl @@ -18,16 +18,16 @@ proc show_RTTC_RTMR_helper { NAME ADDR VAL } { # Nasty hack, make this a float by tacking a .0 on the end # otherwise, jim makes the value an integer set f [expr $AT91C_SLOWOSC_FREQ.0 / $rtpres.0] - puts [format "\tPrescale value: 0x%04x (%5d) => %f Hz" $rtpres $rtpres $f] + echo [format "\tPrescale value: 0x%04x (%5d) => %f Hz" $rtpres $rtpres $f] if { $VAL & $BIT16 } { - puts "\tBit16 -> Alarm IRQ Enabled" + echo "\tBit16 -> Alarm IRQ Enabled" } else { - puts "\tBit16 -> Alarm IRQ Disabled" + echo "\tBit16 -> Alarm IRQ Disabled" } if { $VAL & $BIT17 } { - puts "\tBit17 -> RTC Inc IRQ Enabled" + echo "\tBit17 -> RTC Inc IRQ Enabled" } else { - puts "\tBit17 -> RTC Inc IRQ Disabled" + echo "\tBit17 -> RTC Inc IRQ Disabled" } # Bit 18 is write only. } @@ -35,14 +35,14 @@ proc show_RTTC_RTMR_helper { NAME ADDR VAL } { proc show_RTTC_RTSR_helper { NAME ADDR VAL } { global BIT0 BIT1 if { $VAL & $BIT0 } { - puts "\tBit0 -> ALARM PENDING" + echo "\tBit0 -> ALARM PENDING" } else { - puts "\tBit0 -> alarm not pending" + echo "\tBit0 -> alarm not pending" } if { $VAL & $BIT1 } { - puts "\tBit0 -> RTINC PENDING" + echo "\tBit0 -> RTINC PENDING" } else { - puts "\tBit0 -> rtinc not pending" + echo "\tBit0 -> rtinc not pending" } } diff --git a/tcl/chip/atmel/at91/usarts.tcl b/tcl/chip/atmel/at91/usarts.tcl index f798fc4..6842029 100644 --- a/tcl/chip/atmel/at91/usarts.tcl +++ b/tcl/chip/atmel/at91/usarts.tcl @@ -41,9 +41,9 @@ proc show_mmr_USx_MR_helper { NAME ADDR VAL } { set x [show_normalize_bitfield $VAL 3 0] if { $x == 0 } { - puts "\tNormal operation" + echo "\tNormal operation" } else { - puts [format "\tNon Normal operation mode: 0x%02x" $x] + echo [format "\tNon Normal operation mode: 0x%02x" $x] } set x [show_normalize_bitfield $VAL 11 9] @@ -61,17 +61,17 @@ proc show_mmr_USx_MR_helper { NAME ADDR VAL } { } } } - puts [format "\tParity: %s " $s] + echo [format "\tParity: %s " $s] set x [expr 5 + [show_normalize_bitfield $VAL 7 6]] - puts [format "\tDatabits: %d" $x] + echo [format "\tDatabits: %d" $x] set x [show_normalize_bitfield $VAL 13 12] switch -exact $x { - 0 { puts "\tStop bits: 1" } - 1 { puts "\tStop bits: 1.5" } - 2 { puts "\tStop bits: 2" } - 3 { puts "\tStop bits: Illegal/Reserved" } + 0 { echo "\tStop bits: 1" } + 1 { echo "\tStop bits: 1.5" } + 2 { echo "\tStop bits: 2" } + 3 { echo "\tStop bits: Illegal/Reserved" } } } diff --git a/tcl/chip/st/spear/quirk_no_srst.tcl b/tcl/chip/st/spear/quirk_no_srst.tcl index df22764..fd02d07 100644 --- a/tcl/chip/st/spear/quirk_no_srst.tcl +++ b/tcl/chip/st/spear/quirk_no_srst.tcl @@ -37,9 +37,9 @@ proc sp_reset_deassert_post {} { set bar(3) \\ poll on - puts "====> Press reset button on the board <====" + echo "====> Press reset button on the board <====" for {set i 0} { [sp_is_halted] == 0 } { set i [expr $i + 1]} { - puts -nonewline "$bar([expr $i & 3])\r" + echo -n "$bar([expr $i & 3])\r" sleep 200 } diff --git a/tcl/chip/st/spear/spear3xx_ddr.tcl b/tcl/chip/st/spear/spear3xx_ddr.tcl index eb1c4b0..a804cdc 100644 --- a/tcl/chip/st/spear/spear3xx_ddr.tcl +++ b/tcl/chip/st/spear/spear3xx_ddr.tcl @@ -23,11 +23,11 @@ proc sp3xx_ddr_init {ddr_type} { mww $ddr_size 0x87654321 mww 0x00000000 0x12345678 if {[expr [mrw 0x00000000] == 0x12345678 && [mrw $ddr_size] == 0x87654321]} { - puts [format \ + echo [format \ "Double chip DDR memory. Total memory size 0x%08x byte" \ [expr 2 * $ddr_size]] } else { - puts [format \ + echo [format \ "Single chip DDR memory. Memory size 0x%08x byte" \ $ddr_size] } diff --git a/tcl/mmr_helpers.tcl b/tcl/mmr_helpers.tcl index 9029911..ce116e4 100644 --- a/tcl/mmr_helpers.tcl +++ b/tcl/mmr_helpers.tcl @@ -13,7 +13,7 @@ proc show_mmr32_reg { NAME } { set a [set [set NAME]] if ![catch { set v [memread32 $a] } msg ] { - puts [format "%15s: (0x%08x): 0x%08x" $NAME $a $v] + echo [format "%15s: (0x%08x): 0x%08x" $NAME $a $v] # Was a helper defined? set fn show_${NAME}_helper @@ -43,18 +43,18 @@ proc show_mmr32_bits { NAMES VAL } { } for { set x 24 } { $x >= 0 } { incr x -8 } { - puts -nonewline " " + echo -n " " for { set y 7 } { $y >= 0 } { incr y -1 } { set s $MYNAMES([expr $x + $y]) - puts -nonewline [format "%2d: %-*s | " [expr $x + $y] $w $s ] + echo -n [format "%2d: %-*s | " [expr $x + $y] $w $s ] } - puts "" + echo "" - puts -nonewline " " + echo -n " " for { set y 7 } { $y >= 0 } { incr y -1 } { - puts -nonewline [format " %d%*s | " [expr !!($VAL & (1 << ($x + $y)))] [expr $w -1] ""] + echo -n [format " %d%*s | " [expr !!($VAL & (1 << ($x + $y)))] [expr $w -1] ""] } - puts "" + echo "" } } @@ -68,5 +68,5 @@ proc show_mmr_bitfield { MSB LSB VAL FIELDNAME FIELDVALUES } { } else { set sval "" } - puts [format "%-15s: %d (0x%0*x) %s" $FIELDNAME $nval $width $nval $sval ] + echo [format "%-15s: %d (0x%0*x) %s" $FIELDNAME $nval $width $nval $sval ] } diff --git a/tcl/target/aduc702x.cfg b/tcl/target/aduc702x.cfg index d58b723..dcb9c12 100644 --- a/tcl/target/aduc702x.cfg +++ b/tcl/target/aduc702x.cfg @@ -45,7 +45,7 @@ flash bank $_FLASHNAME aduc702x 0 0 0 0 $_TARGETNAME proc watchdog_service {} { global watchdog_hdl mww 0xffff036c 0 -# puts "watchdog!!" +# echo "watchdog!!" set watchdog_hdl [after 500 watchdog_service] } diff --git a/tcl/target/c100config.tcl b/tcl/target/c100config.tcl index 17a9476..52efa83 100644 --- a/tcl/target/c100config.tcl +++ b/tcl/target/c100config.tcl @@ -8,7 +8,7 @@ proc config {label} { # show the value for the param. with label proc showconfig {label} { - puts [format "0x%x" [dict get [configC100] $label ]] + echo [format "0x%x" [dict get [configC100] $label ]] } # Telo board config @@ -53,7 +53,7 @@ proc setupTelo {} { proc setupNOR {} { - puts "Setting up NOR: 16MB, 16-bit wide bus, CS0" + echo "Setting up NOR: 16MB, 16-bit wide bus, CS0" # this is taken from u-boot/boards/mindspeed/ooma-darwin/board.c:nor_hw_init() set EX_CSEN_REG [regs EX_CSEN_REG ] set EX_CS0_SEG_REG [regs EX_CS0_SEG_REG ] @@ -99,7 +99,7 @@ proc bootNOR {} { resume } proc setupGPIO {} { - puts "Setting up GPIO block for Telo" + echo "Setting up GPIO block for Telo" # This is current setup for Telo (see sch. for details): #GPIO0 reset for FXS-FXO IC, leave as input, the IC has internal pullup #GPIO1 irq line for FXS-FXO @@ -117,14 +117,14 @@ proc setupGPIO {} { } proc highGPIO5 {} { - puts "GPIO5 high" + echo "GPIO5 high" set GPIO_OUTPUT_REG [regs GPIO_OUTPUT_REG] # set GPIO5=1 mmw $GPIO_OUTPUT_REG [expr 1 << 5] 0x0 } proc lowGPIO5 {} { - puts "GPIO5 low" + echo "GPIO5 low" set GPIO_OUTPUT_REG [regs GPIO_OUTPUT_REG] # set GPIO5=0 mmw $GPIO_OUTPUT_REG 0x0 [expr 1 << 5] @@ -161,12 +161,12 @@ proc ooma_board_detect {} { # read the current value of the BOOTSRAP pins set tmp [mrw $GPIO_BOOTSTRAP_REG] - puts [format "GPIO_BOOTSTRAP_REG (0x%x): 0x%x" $GPIO_BOOTSTRAP_REG $tmp] + echo [format "GPIO_BOOTSTRAP_REG (0x%x): 0x%x" $GPIO_BOOTSTRAP_REG $tmp] # extract the GPBP bits set gpbt [expr ($tmp &0x1C00) >> 10 | ($tmp & 0x40) >>3] # display board ID - puts [format "This is %s (0x%x)" [dict get [boardID $gpbt] $gpbt name] $gpbt] + echo [format "This is %s (0x%x)" [dict get [boardID $gpbt] $gpbt name] $gpbt] # show it on serial console putsUART0 [format "This is %s (0x%x)\n" [dict get [boardID $gpbt] $gpbt name] $gpbt] # return the ddr2 size, used to configure DDR2 on a given board. @@ -228,13 +228,13 @@ proc configureDDR2regs_256M {} { # start DDRC mw64bit $DENALI_CTL_02_DATA [expr $DENALI_CTL_02_VAL | (1 << 32)] # wait int_status[2] (DRAM init complete) - puts -nonewline "Waiting for DDR2 controller to init..." + echo -n "Waiting for DDR2 controller to init..." set tmp [mrw [expr $DENALI_CTL_08_DATA + 4]] while { [expr $tmp & 0x040000] == 0 } { sleep 1 set tmp [mrw [expr $DENALI_CTL_08_DATA + 4]] } - puts "done." + echo "done." # do ddr2 training sequence # TBD (for now, if you need it, run trainDDR command) @@ -296,7 +296,7 @@ proc configureDDR2regs_128M {} { # start DDRC mw64bit $DENALI_CTL_02_DATA [expr $DENALI_CTL_02_VAL | (1 << 32)] # wait int_status[2] (DRAM init complete) - puts -nonewline "Waiting for DDR2 controller to init..." + echo -n "Waiting for DDR2 controller to init..." set tmp [mrw [expr $DENALI_CTL_08_DATA + 4]] while { [expr $tmp & 0x040000] == 0 } { sleep 1 @@ -304,7 +304,7 @@ proc configureDDR2regs_128M {} { } # This is not necessary #mw64bit $DENALI_CTL_11_DATA [expr ($DENALI_CTL_11_VAL & ~0x00007F0000000000) | ($wr_dqs_shift << 40) ] - puts "done." + echo "done." # do ddr2 training sequence # TBD (for now, if you need it, run trainDDR command) @@ -398,10 +398,10 @@ proc flashUBOOT {file} { # make sure we are accessing the lower part of NOR lowGPIO5 flash probe 0 - puts "Erasing sectors 0-3 for uboot" + echo "Erasing sectors 0-3 for uboot" putsUART0 "Erasing sectors 0-3 for uboot\n" flash erase_sector 0 0 3 - puts "Programming u-boot" + echo "Programming u-boot" putsUART0 "Programming u-boot..." arm11 memwrite burst enable flash write_image $file $EXP_CS0_BASEADDR diff --git a/tcl/target/c100helper.tcl b/tcl/target/c100helper.tcl index 3251066..c9124cb 100644 --- a/tcl/target/c100helper.tcl +++ b/tcl/target/c100helper.tcl @@ -1,28 +1,28 @@ proc helpC100 {} { - puts "List of useful functions for C100 processor:" - puts "1) reset init: will set up your Telo board" - puts "2) setupNOR: will setup NOR access" - puts "3) showNOR: will show current NOR config registers for 16-bit, 16MB NOR" - puts "4) setupGPIO: will setup GPIOs for Telo board" - puts "5) showGPIO: will show current GPIO config registers" - puts "6) highGPIO5: will set GPIO5=NOR_addr22=1 to access upper 8MB" - puts "7) lowGPIO5: will set GPIO5=NOR_addr22=0 to access lower 8MB" - puts "8) showAmbaClk: will show current config registers for Amba Bus Clock" - puts "9) setupAmbaClk: will setup Amba Bus Clock=165MHz" - puts "10) showArmClk: will show current config registers for Arm Bus Clock" - puts "11) setupArmClk: will setup Amba Bus Clock=450MHz" - puts "12) ooma_board_detect: will show which version of Telo you have" - puts "13) setupDDR2: will configure DDR2 controller, you must have PLLs configureg" - puts "14) showDDR2: will show DDR2 config registers" - puts "15) showWatchdog: will show current regster config for watchdog" - puts "16) reboot: will trigger watchdog and reboot Telo (hw reset)" - puts "17) bootNOR: will boot Telo from NOR" - puts "18) setupUART0: will configure UART0 for 115200 8N1, PLLs have to be confiured" - puts "19) putcUART0: will print a character on UART0" - puts "20) putsUART0: will print a string on UART0" - puts "21) trainDDR2: will run DDR2 training program" - puts "22) flashUBOOT: will prgram NOR sectors 0-3 with u-boot.bin" + echo "List of useful functions for C100 processor:" + echo "1) reset init: will set up your Telo board" + echo "2) setupNOR: will setup NOR access" + echo "3) showNOR: will show current NOR config registers for 16-bit, 16MB NOR" + echo "4) setupGPIO: will setup GPIOs for Telo board" + echo "5) showGPIO: will show current GPIO config registers" + echo "6) highGPIO5: will set GPIO5=NOR_addr22=1 to access upper 8MB" + echo "7) lowGPIO5: will set GPIO5=NOR_addr22=0 to access lower 8MB" + echo "8) showAmbaClk: will show current config registers for Amba Bus Clock" + echo "9) setupAmbaClk: will setup Amba Bus Clock=165MHz" + echo "10) showArmClk: will show current config registers for Arm Bus Clock" + echo "11) setupArmClk: will setup Amba Bus Clock=450MHz" + echo "12) ooma_board_detect: will show which version of Telo you have" + echo "13) setupDDR2: will configure DDR2 controller, you must have PLLs configureg" + echo "14) showDDR2: will show DDR2 config registers" + echo "15) showWatchdog: will show current regster config for watchdog" + echo "16) reboot: will trigger watchdog and reboot Telo (hw reset)" + echo "17) bootNOR: will boot Telo from NOR" + echo "18) setupUART0: will configure UART0 for 115200 8N1, PLLs have to be confiured" + echo "19) putcUART0: will print a character on UART0" + echo "20) putsUART0: will print a string on UART0" + echo "21) trainDDR2: will run DDR2 training program" + echo "22) flashUBOOT: will prgram NOR sectors 0-3 with u-boot.bin" } source [find mem_helper.tcl] @@ -39,14 +39,14 @@ proc mr64bit {reg} { proc mw64bit {reg value} { set high [expr $value >> 32] set low [expr $value & 0xffffffff] - #puts [format "mw64bit(0x%x): 0x%08x%08x" $reg $high $low] + #echo [format "mw64bit(0x%x): 0x%08x%08x" $reg $high $low] mww $reg $low mww [expr $reg+4] $high } proc showNOR {} { - puts "This is the current NOR setup" + echo "This is the current NOR setup" set EX_CSEN_REG [regs EX_CSEN_REG ] set EX_CS0_SEG_REG [regs EX_CS0_SEG_REG ] set EX_CS0_CFG_REG [regs EX_CS0_CFG_REG ] @@ -59,23 +59,23 @@ proc showNOR {} { set EX_WRFSM_REG [regs EX_WRFSM_REG ] set EX_RDFSM_REG [regs EX_RDFSM_REG ] - puts [format "EX_CSEN_REG (0x%x): 0x%x" $EX_CSEN_REG [mrw $EX_CSEN_REG]] - puts [format "EX_CS0_SEG_REG (0x%x): 0x%x" $EX_CS0_SEG_REG [mrw $EX_CS0_SEG_REG]] - puts [format "EX_CS0_CFG_REG (0x%x): 0x%x" $EX_CS0_CFG_REG [mrw $EX_CS0_CFG_REG]] - puts [format "EX_CS0_TMG1_REG (0x%x): 0x%x" $EX_CS0_TMG1_REG [mrw $EX_CS0_TMG1_REG]] - puts [format "EX_CS0_TMG2_REG (0x%x): 0x%x" $EX_CS0_TMG2_REG [mrw $EX_CS0_TMG2_REG]] - puts [format "EX_CS0_TMG3_REG (0x%x): 0x%x" $EX_CS0_TMG3_REG [mrw $EX_CS0_TMG3_REG]] - puts [format "EX_CLOCK_DIV_REG (0x%x): 0x%x" $EX_CLOCK_DIV_REG [mrw $EX_CLOCK_DIV_REG]] - puts [format "EX_MFSM_REG (0x%x): 0x%x" $EX_MFSM_REG [mrw $EX_MFSM_REG]] - puts [format "EX_CSFSM_REG (0x%x): 0x%x" $EX_CSFSM_REG [mrw $EX_CSFSM_REG]] - puts [format "EX_WRFSM_REG (0x%x): 0x%x" $EX_WRFSM_REG [mrw $EX_WRFSM_REG]] - puts [format "EX_RDFSM_REG (0x%x): 0x%x" $EX_RDFSM_REG [mrw $EX_RDFSM_REG]] + echo [format "EX_CSEN_REG (0x%x): 0x%x" $EX_CSEN_REG [mrw $EX_CSEN_REG]] + echo [format "EX_CS0_SEG_REG (0x%x): 0x%x" $EX_CS0_SEG_REG [mrw $EX_CS0_SEG_REG]] + echo [format "EX_CS0_CFG_REG (0x%x): 0x%x" $EX_CS0_CFG_REG [mrw $EX_CS0_CFG_REG]] + echo [format "EX_CS0_TMG1_REG (0x%x): 0x%x" $EX_CS0_TMG1_REG [mrw $EX_CS0_TMG1_REG]] + echo [format "EX_CS0_TMG2_REG (0x%x): 0x%x" $EX_CS0_TMG2_REG [mrw $EX_CS0_TMG2_REG]] + echo [format "EX_CS0_TMG3_REG (0x%x): 0x%x" $EX_CS0_TMG3_REG [mrw $EX_CS0_TMG3_REG]] + echo [format "EX_CLOCK_DIV_REG (0x%x): 0x%x" $EX_CLOCK_DIV_REG [mrw $EX_CLOCK_DIV_REG]] + echo [format "EX_MFSM_REG (0x%x): 0x%x" $EX_MFSM_REG [mrw $EX_MFSM_REG]] + echo [format "EX_CSFSM_REG (0x%x): 0x%x" $EX_CSFSM_REG [mrw $EX_CSFSM_REG]] + echo [format "EX_WRFSM_REG (0x%x): 0x%x" $EX_WRFSM_REG [mrw $EX_WRFSM_REG]] + echo [format "EX_RDFSM_REG (0x%x): 0x%x" $EX_RDFSM_REG [mrw $EX_RDFSM_REG]] } proc showGPIO {} { - puts "This is the current GPIO register setup" + echo "This is the current GPIO register setup" # GPIO outputs register set GPIO_OUTPUT_REG [regs GPIO_OUTPUT_REG] # GPIO Output Enable register @@ -93,19 +93,19 @@ proc showGPIO {} { set GPIO_IOCTRL_REG [regs GPIO_IOCTRL_REG] set GPIO_DEVID_REG [regs GPIO_DEVID_REG] - puts [format "GPIO_OUTPUT_REG (0x%x): 0x%x" $GPIO_OUTPUT_REG [mrw $GPIO_OUTPUT_REG]] - puts [format "GPIO_OE_REG (0x%x): 0x%x" $GPIO_OE_REG [mrw $GPIO_OE_REG]] - puts [format "GPIO_HI_INT_ENABLE_REG(0x%x): 0x%x" $GPIO_HI_INT_ENABLE_REG [mrw $GPIO_HI_INT_ENABLE_REG]] - puts [format "GPIO_LO_INT_ENABLE_REG(0x%x): 0x%x" $GPIO_LO_INT_ENABLE_REG [mrw $GPIO_LO_INT_ENABLE_REG]] - puts [format "GPIO_INPUT_REG (0x%x): 0x%x" $GPIO_INPUT_REG [mrw $GPIO_INPUT_REG]] - puts [format "APB_ACCESS_WS_REG (0x%x): 0x%x" $APB_ACCESS_WS_REG [mrw $APB_ACCESS_WS_REG]] - puts [format "MUX_CONF_REG (0x%x): 0x%x" $MUX_CONF_REG [mrw $MUX_CONF_REG]] - puts [format "SYSCONF_REG (0x%x): 0x%x" $SYSCONF_REG [mrw $SYSCONF_REG]] - puts [format "GPIO_ARM_ID_REG (0x%x): 0x%x" $GPIO_ARM_ID_REG [mrw $GPIO_ARM_ID_REG]] - puts [format "GPIO_BOOTSTRAP_REG (0x%x): 0x%x" $GPIO_BOOTSTRAP_REG [mrw $GPIO_BOOTSTRAP_REG]] - puts [format "GPIO_LOCK_REG (0x%x): 0x%x" $GPIO_LOCK_REG [mrw $GPIO_LOCK_REG]] - puts [format "GPIO_IOCTRL_REG (0x%x): 0x%x" $GPIO_IOCTRL_REG [mrw $GPIO_IOCTRL_REG]] - puts [format "GPIO_DEVID_REG (0x%x): 0x%x" $GPIO_DEVID_REG [mrw $GPIO_DEVID_REG]] + echo [format "GPIO_OUTPUT_REG (0x%x): 0x%x" $GPIO_OUTPUT_REG [mrw $GPIO_OUTPUT_REG]] + echo [format "GPIO_OE_REG (0x%x): 0x%x" $GPIO_OE_REG [mrw $GPIO_OE_REG]] + echo [format "GPIO_HI_INT_ENABLE_REG(0x%x): 0x%x" $GPIO_HI_INT_ENABLE_REG [mrw $GPIO_HI_INT_ENABLE_REG]] + echo [format "GPIO_LO_INT_ENABLE_REG(0x%x): 0x%x" $GPIO_LO_INT_ENABLE_REG [mrw $GPIO_LO_INT_ENABLE_REG]] + echo [format "GPIO_INPUT_REG (0x%x): 0x%x" $GPIO_INPUT_REG [mrw $GPIO_INPUT_REG]] + echo [format "APB_ACCESS_WS_REG (0x%x): 0x%x" $APB_ACCESS_WS_REG [mrw $APB_ACCESS_WS_REG]] + echo [format "MUX_CONF_REG (0x%x): 0x%x" $MUX_CONF_REG [mrw $MUX_CONF_REG]] + echo [format "SYSCONF_REG (0x%x): 0x%x" $SYSCONF_REG [mrw $SYSCONF_REG]] + echo [format "GPIO_ARM_ID_REG (0x%x): 0x%x" $GPIO_ARM_ID_REG [mrw $GPIO_ARM_ID_REG]] + echo [format "GPIO_BOOTSTRAP_REG (0x%x): 0x%x" $GPIO_BOOTSTRAP_REG [mrw $GPIO_BOOTSTRAP_REG]] + echo [format "GPIO_LOCK_REG (0x%x): 0x%x" $GPIO_LOCK_REG [mrw $GPIO_LOCK_REG]] + echo [format "GPIO_IOCTRL_REG (0x%x): 0x%x" $GPIO_IOCTRL_REG [mrw $GPIO_IOCTRL_REG]] + echo [format "GPIO_DEVID_REG (0x%x): 0x%x" $GPIO_DEVID_REG [mrw $GPIO_DEVID_REG]] } @@ -116,22 +116,22 @@ proc showAmbaClk {} { set CLKCORE_AHB_CLK_CNTRL [regs CLKCORE_AHB_CLK_CNTRL] set PLL_CLK_BYPASS [regs PLL_CLK_BYPASS] - puts [format "CLKCORE_AHB_CLK_CNTRL (0x%x): 0x%x" $CLKCORE_AHB_CLK_CNTRL [mrw $CLKCORE_AHB_CLK_CNTRL]] + echo [format "CLKCORE_AHB_CLK_CNTRL (0x%x): 0x%x" $CLKCORE_AHB_CLK_CNTRL [mrw $CLKCORE_AHB_CLK_CNTRL]] mem2array value 32 $CLKCORE_AHB_CLK_CNTRL 1 # see if the PLL is in bypass mode set bypass [expr ($value(0) & $PLL_CLK_BYPASS) >> 24 ] - puts [format "PLL bypass bit: %d" $bypass] + echo [format "PLL bypass bit: %d" $bypass] if {$bypass == 1} { - puts [format "Amba Clk is set to REFCLK: %d (MHz)" [expr $CFG_REFCLKFREQ/1000000]] + echo [format "Amba Clk is set to REFCLK: %d (MHz)" [expr $CFG_REFCLKFREQ/1000000]] } else { # nope, extract x,y,w and compute the PLL output freq. set x [expr ($value(0) & 0x0001F0000) >> 16] - puts [format "x: %d" $x] + echo [format "x: %d" $x] set y [expr ($value(0) & 0x00000007F)] - puts [format "y: %d" $y] + echo [format "y: %d" $y] set w [expr ($value(0) & 0x000000300) >> 8] - puts [format "w: %d" $w] - puts [format "Amba PLL Clk: %d (MHz)" [expr ($CFG_REFCLKFREQ * $y / (($w + 1) * ($x + 1) * 2))/1000000]] + echo [format "w: %d" $w] + echo [format "Amba PLL Clk: %d (MHz)" [expr ($CFG_REFCLKFREQ * $y / (($w + 1) * ($x + 1) * 2))/1000000]] } } @@ -154,10 +154,10 @@ proc setupAmbaClk {} { set x [config x_amba] set y [config y_amba] - puts [format "Setting Amba PLL to lock to %d MHz" [expr $CONFIG_SYS_HZ_CLOCK/1000000]] - #puts [format "setupAmbaClk: w= %d" $w] - #puts [format "setupAmbaClk: x= %d" $x] - #puts [format "setupAmbaClk: y= %d" $y] + echo [format "Setting Amba PLL to lock to %d MHz" [expr $CONFIG_SYS_HZ_CLOCK/1000000]] + #echo [format "setupAmbaClk: w= %d" $w] + #echo [format "setupAmbaClk: x= %d" $x] + #echo [format "setupAmbaClk: y= %d" $y] # set PLL into BYPASS mode using MUX mmw $CLKCORE_AHB_CLK_CNTRL $PLL_CLK_BYPASS 0x0 # do an internal PLL bypass @@ -176,7 +176,7 @@ proc setupAmbaClk {} { mmw $CLKCORE_AHB_CLK_CNTRL 0x0 0xFFFFFF mmw $CLKCORE_AHB_CLK_CNTRL [expr (($x << 16) + ($w << 8) + $y)] 0x0 # wait for PLL to lock - puts "Wating for Amba PLL to lock" + echo "Wating for Amba PLL to lock" while {[expr [mrw $CLKCORE_PLL_STATUS] & $AHBCLK_PLL_LOCK] == 0} { sleep 1 } # remove the internal PLL bypass mmw $CLKCORE_AHB_CLK_CNTRL 0x0 $AHB_PLL_BY_CTRL @@ -191,22 +191,22 @@ proc showArmClk {} { set CLKCORE_ARM_CLK_CNTRL [regs CLKCORE_ARM_CLK_CNTRL] set PLL_CLK_BYPASS [regs PLL_CLK_BYPASS] - puts [format "CLKCORE_ARM_CLK_CNTRL (0x%x): 0x%x" $CLKCORE_ARM_CLK_CNTRL [mrw $CLKCORE_ARM_CLK_CNTRL]] + echo [format "CLKCORE_ARM_CLK_CNTRL (0x%x): 0x%x" $CLKCORE_ARM_CLK_CNTRL [mrw $CLKCORE_ARM_CLK_CNTRL]] mem2array value 32 $CLKCORE_ARM_CLK_CNTRL 1 # see if the PLL is in bypass mode set bypass [expr ($value(0) & $PLL_CLK_BYPASS) >> 24 ] - puts [format "PLL bypass bit: %d" $bypass] + echo [format "PLL bypass bit: %d" $bypass] if {$bypass == 1} { - puts [format "Amba Clk is set to REFCLK: %d (MHz)" [expr $CFG_REFCLKFREQ/1000000]] + echo [format "Amba Clk is set to REFCLK: %d (MHz)" [expr $CFG_REFCLKFREQ/1000000]] } else { # nope, extract x,y,w and compute the PLL output freq. set x [expr ($value(0) & 0x0001F0000) >> 16] - puts [format "x: %d" $x] + echo [format "x: %d" $x] set y [expr ($value(0) & 0x00000007F)] - puts [format "y: %d" $y] + echo [format "y: %d" $y] set w [expr ($value(0) & 0x000000300) >> 8] - puts [format "w: %d" $w] - puts [format "Arm PLL Clk: %d (MHz)" [expr ($CFG_REFCLKFREQ * $y / (($w + 1) * ($x + 1) * 2))/1000000]] + echo [format "w: %d" $w] + echo [format "Arm PLL Clk: %d (MHz)" [expr ($CFG_REFCLKFREQ * $y / (($w + 1) * ($x + 1) * 2))/1000000]] } } @@ -228,10 +228,10 @@ proc setupArmClk {} { set x [config x_arm] set y [config y_arm] - puts [format "Setting Arm PLL to lock to %d MHz" [expr $CFG_ARM_CLOCK/1000000]] - #puts [format "setupArmClk: w= %d" $w] - #puts [format "setupArmaClk: x= %d" $x] - #puts [format "setupArmaClk: y= %d" $y] + echo [format "Setting Arm PLL to lock to %d MHz" [expr $CFG_ARM_CLOCK/1000000]] + #echo [format "setupArmClk: w= %d" $w] + #echo [format "setupArmaClk: x= %d" $x] + #echo [format "setupArmaClk: y= %d" $y] # set PLL into BYPASS mode using MUX mmw $CLKCORE_ARM_CLK_CNTRL $PLL_CLK_BYPASS 0x0 # do an internal PLL bypass @@ -250,7 +250,7 @@ proc setupArmClk {} { mmw $CLKCORE_ARM_CLK_CNTRL 0x0 0xFFFFFF mmw $CLKCORE_ARM_CLK_CNTRL [expr (($x << 16) + ($w << 8) + $y)] 0x0 # wait for PLL to lock - puts "Wating for Amba PLL to lock" + echo "Wating for Amba PLL to lock" while {[expr [mrw $CLKCORE_PLL_STATUS] & $FCLK_PLL_LOCK] == 0} { sleep 1 } # remove the internal PLL bypass mmw $CLKCORE_ARM_CLK_CNTRL 0x0 $ARM_PLL_BY_CTRL @@ -261,14 +261,14 @@ proc setupArmClk {} { proc setupPLL {} { - puts "PLLs setup" + echo "PLLs setup" setupAmbaClk setupArmClk } # converted from u-boot/cpu/arm1136/bsp100.c:SoC_mem_init() proc setupDDR2 {} { - puts "Configuring DDR2" + echo "Configuring DDR2" set MEMORY_BASE_ADDR [regs MEMORY_BASE_ADDR] set MEMORY_MAX_ADDR [regs MEMORY_MAX_ADDR] @@ -289,13 +289,13 @@ proc setupDDR2 {} { # ooma_board_detect returns DDR2 memory size set tmp [ooma_board_detect] if {$tmp == "128M"} { - puts "DDR2 size 128MB" + echo "DDR2 size 128MB" set ddr_size $DDR_SZ_128M } elseif {$tmp == "256M"} { - puts "DDR2 size 256MB" + echo "DDR2 size 256MB" set ddr_size $DDR_SZ_256M } else { - puts "Don't know how to handle this DDR2 size?" + echo "Don't know how to handle this DDR2 size?" } # Memory setup register @@ -313,7 +313,7 @@ proc setupDDR2 {} { } elseif {$tmp == "256M"} { configureDDR2regs_256M } else { - puts "Don't know how to configure DDR2 setup?" + echo "Don't know how to configure DDR2 setup?" } } @@ -344,47 +344,47 @@ proc showDDR2 {} { set DENALI_CTL_20_DATA [regs DENALI_CTL_20_DATA] set tmp [mr64bit $DENALI_CTL_00_DATA] - puts [format "DENALI_CTL_00_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_00_DATA $tmp(1) $tmp(0)] + echo [format "DENALI_CTL_00_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_00_DATA $tmp(1) $tmp(0)] set tmp [mr64bit $DENALI_CTL_01_DATA] - puts [format "DENALI_CTL_01_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_01_DATA $tmp(1) $tmp(0)] + echo [format "DENALI_CTL_01_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_01_DATA $tmp(1) $tmp(0)] set tmp [mr64bit $DENALI_CTL_02_DATA] - puts [format "DENALI_CTL_02_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_02_DATA $tmp(1) $tmp(0)] + echo [format "DENALI_CTL_02_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_02_DATA $tmp(1) $tmp(0)] set tmp [mr64bit $DENALI_CTL_03_DATA] - puts [format "DENALI_CTL_03_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_03_DATA $tmp(1) $tmp(0)] + echo [format "DENALI_CTL_03_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_03_DATA $tmp(1) $tmp(0)] set tmp [mr64bit $DENALI_CTL_04_DATA] - puts [format "DENALI_CTL_04_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_04_DATA $tmp(1) $tmp(0)] + echo [format "DENALI_CTL_04_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_04_DATA $tmp(1) $tmp(0)] set tmp [mr64bit $DENALI_CTL_05_DATA] - puts [format "DENALI_CTL_05_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_05_DATA $tmp(1) $tmp(0)] + echo [format "DENALI_CTL_05_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_05_DATA $tmp(1) $tmp(0)] set tmp [mr64bit $DENALI_CTL_06_DATA] - puts [format "DENALI_CTL_06_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_06_DATA $tmp(1) $tmp(0)] + echo [format "DENALI_CTL_06_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_06_DATA $tmp(1) $tmp(0)] set tmp [mr64bit $DENALI_CTL_07_DATA] - puts [format "DENALI_CTL_07_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_07_DATA $tmp(1) $tmp(0)] + echo [format "DENALI_CTL_07_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_07_DATA $tmp(1) $tmp(0)] set tmp [mr64bit $DENALI_CTL_08_DATA] - puts [format "DENALI_CTL_08_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_08_DATA $tmp(1) $tmp(0)] + echo [format "DENALI_CTL_08_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_08_DATA $tmp(1) $tmp(0)] set tmp [mr64bit $DENALI_CTL_09_DATA] - puts [format "DENALI_CTL_09_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_09_DATA $tmp(1) $tmp(0)] + echo [format "DENALI_CTL_09_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_09_DATA $tmp(1) $tmp(0)] set tmp [mr64bit $DENALI_CTL_10_DATA] - puts [format "DENALI_CTL_10_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_10_DATA $tmp(1) $tmp(0)] + echo [format "DENALI_CTL_10_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_10_DATA $tmp(1) $tmp(0)] set tmp [mr64bit $DENALI_CTL_11_DATA] - puts [format "DENALI_CTL_11_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_11_DATA $tmp(1) $tmp(0)] + echo [format "DENALI_CTL_11_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_11_DATA $tmp(1) $tmp(0)] set tmp [mr64bit $DENALI_CTL_12_DATA] - puts [format "DENALI_CTL_12_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_12_DATA $tmp(1) $tmp(0)] + echo [format "DENALI_CTL_12_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_12_DATA $tmp(1) $tmp(0)] set tmp [mr64bit $DENALI_CTL_13_DATA] - puts [format "DENALI_CTL_13_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_13_DATA $tmp(1) $tmp(0)] + echo [format "DENALI_CTL_13_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_13_DATA $tmp(1) $tmp(0)] set tmp [mr64bit $DENALI_CTL_14_DATA] - puts [format "DENALI_CTL_14_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_14_DATA $tmp(1) $tmp(0)] + echo [format "DENALI_CTL_14_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_14_DATA $tmp(1) $tmp(0)] set tmp [mr64bit $DENALI_CTL_15_DATA] - puts [format "DENALI_CTL_15_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_15_DATA $tmp(1) $tmp(0)] + echo [format "DENALI_CTL_15_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_15_DATA $tmp(1) $tmp(0)] set tmp [mr64bit $DENALI_CTL_16_DATA] - puts [format "DENALI_CTL_16_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_16_DATA $tmp(1) $tmp(0)] + echo [format "DENALI_CTL_16_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_16_DATA $tmp(1) $tmp(0)] set tmp [mr64bit $DENALI_CTL_17_DATA] - puts [format "DENALI_CTL_17_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_17_DATA $tmp(1) $tmp(0)] + echo [format "DENALI_CTL_17_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_17_DATA $tmp(1) $tmp(0)] set tmp [mr64bit $DENALI_CTL_18_DATA] - puts [format "DENALI_CTL_18_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_18_DATA $tmp(1) $tmp(0)] + echo [format "DENALI_CTL_18_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_18_DATA $tmp(1) $tmp(0)] set tmp [mr64bit $DENALI_CTL_19_DATA] - puts [format "DENALI_CTL_19_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_19_DATA $tmp(1) $tmp(0)] + echo [format "DENALI_CTL_19_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_19_DATA $tmp(1) $tmp(0)] set tmp [mr64bit $DENALI_CTL_20_DATA] - puts [format "DENALI_CTL_20_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_20_DATA $tmp(1) $tmp(0)] + echo [format "DENALI_CTL_20_DATA (0x%x): 0x%08x%08x" $DENALI_CTL_20_DATA $tmp(1) $tmp(0)] } @@ -462,7 +462,7 @@ proc initC100 {} { # DDR2 memory init setupDDR2 putsUART0 "C100 initialization complete.\n" - puts "C100 initialization complete." + echo "C100 initialization complete." } # show current state of watchdog timer @@ -471,9 +471,9 @@ proc showWatchdog {} { set TIMER_WDT_CONTROL [regs TIMER_WDT_CONTROL] set TIMER_WDT_CURRENT_COUNT [regs TIMER_WDT_CURRENT_COUNT] - puts [format "TIMER_WDT_HIGH_BOUND (0x%x): 0x%x" $TIMER_WDT_HIGH_BOUND [mrw $TIMER_WDT_HIGH_BOUND]] - puts [format "TIMER_WDT_CONTROL (0x%x): 0x%x" $TIMER_WDT_CONTROL [mrw $TIMER_WDT_CONTROL]] - puts [format "TIMER_WDT_CURRENT_COUNT (0x%x): 0x%x" $TIMER_WDT_CURRENT_COUNT [mrw $TIMER_WDT_CURRENT_COUNT]] + echo [format "TIMER_WDT_HIGH_BOUND (0x%x): 0x%x" $TIMER_WDT_HIGH_BOUND [mrw $TIMER_WDT_HIGH_BOUND]] + echo [format "TIMER_WDT_CONTROL (0x%x): 0x%x" $TIMER_WDT_CONTROL [mrw $TIMER_WDT_CONTROL]] + echo [format "TIMER_WDT_CURRENT_COUNT (0x%x): 0x%x" $TIMER_WDT_CURRENT_COUNT [mrw $TIMER_WDT_CURRENT_COUNT]] } # converted from u-boot/cpu/arm1136/comcerto/intrrupts.c:void reset_cpu (ulong ignored) @@ -490,17 +490,17 @@ proc reboot {} { # I don't want to miss the high_bound==curr_count condition mww $TIMER_WDT_HIGH_BOUND 0xffffff mww $TIMER_WDT_CURRENT_COUNT 0x0 - puts "JTAG speed lowered to 100kHz" + echo "JTAG speed lowered to 100kHz" adapter_khz 100 mww $TIMER_WDT_CONTROL 0x1 # wait until the reset - puts -nonewline "Wating for watchdog to trigger..." + echo -n "Wating for watchdog to trigger..." #while {[mrw $TIMER_WDT_CONTROL] == 1} { - # puts [format "TIMER_WDT_CURRENT_COUNT (0x%x): 0x%x" $TIMER_WDT_CURRENT_COUNT [mrw $TIMER_WDT_CURRENT_COUNT]] + # echo [format "TIMER_WDT_CURRENT_COUNT (0x%x): 0x%x" $TIMER_WDT_CURRENT_COUNT [mrw $TIMER_WDT_CURRENT_COUNT]] # sleep 1 # #} while {[c100.cpu curstate] != "running"} { sleep 1} - puts "done." - puts [format "Note that C100 is in %s state, type halt to stop" [c100.cpu curstate]] + echo "done." + echo [format "Note that C100 is in %s state, type halt to stop" [c100.cpu curstate]] } diff --git a/tcl/target/c100regs.tcl b/tcl/target/c100regs.tcl index 56f0771..a2c7a60 100644 --- a/tcl/target/c100regs.tcl +++ b/tcl/target/c100regs.tcl @@ -11,7 +11,7 @@ proc regs {reg} { } proc showreg {reg} { - puts [format "0x%x" [dict get [regsC100] $reg ]] + echo [format "0x%x" [dict get [regsC100] $reg ]] } proc regsC100 {} { diff --git a/tcl/target/imx31.cfg b/tcl/target/imx31.cfg index 3af6383..b9eddd0 100644 --- a/tcl/target/imx31.cfg +++ b/tcl/target/imx31.cfg @@ -60,8 +60,8 @@ set _TARGETNAME $_CHIPNAME.cpu target create $_TARGETNAME arm11 -endian $_ENDIAN -chain-position $_TARGETNAME -proc power_restore {} { puts "Sensed power restore. No action." } -proc srst_deasserted {} { puts "Sensed nSRST deasserted. No action." } +proc power_restore {} { echo "Sensed power restore. No action." } +proc srst_deasserted {} { echo "Sensed nSRST deasserted. No action." } # trace setup ... NOTE, "normal full" mode fudges the real ETMv3.1 mode etm config $_TARGETNAME 16 normal full etb diff --git a/tcl/target/imx35.cfg b/tcl/target/imx35.cfg index 30cb386..8a6aa87 100644 --- a/tcl/target/imx35.cfg +++ b/tcl/target/imx35.cfg @@ -47,8 +47,8 @@ jtag newtap $_CHIPNAME smda -irlen 5 -ircapture 0x1 -irmask 0x1f -expected-id $_ set _TARGETNAME $_CHIPNAME.cpu target create $_TARGETNAME arm11 -endian $_ENDIAN -chain-position $_TARGETNAME -proc power_restore {} { puts "Sensed power restore. No action." } -proc srst_deasserted {} { puts "Sensed nSRST deasserted. No action." } +proc power_restore {} { echo "Sensed power restore. No action." } +proc srst_deasserted {} { echo "Sensed nSRST deasserted. No action." } # trace setup ... NOTE, "normal full" mode fudges the real ETMv3.1 mode etm config $_TARGETNAME 16 normal full etb diff --git a/tcl/target/lpc3250.cfg b/tcl/target/lpc3250.cfg index e902fb4..d64e15f 100644 --- a/tcl/target/lpc3250.cfg +++ b/tcl/target/lpc3250.cfg @@ -32,5 +32,5 @@ jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CP set _TARGETNAME $_CHIPNAME.cpu target create $_TARGETNAME arm926ejs -endian little -chain-position $_TARGETNAME -work-area-phys 0x00000000 -work-area-size 0x7d0000 -work-area-backup 0 -proc power_restore {} { puts "Sensed power restore. No action." } -proc srst_deasserted {} { puts "Sensed nSRST deasserted. No action." } +proc power_restore {} { echo "Sensed power restore. No action." } +proc srst_deasserted {} { echo "Sensed nSRST deasserted. No action." } diff --git a/tcl/test/selftest.cfg b/tcl/test/selftest.cfg index 912d1c0..be420ca 100755 --- a/tcl/test/selftest.cfg +++ b/tcl/test/selftest.cfg @@ -8,7 +8,7 @@ proc selftest {tmpfile address size} { } for {set i 0} {$i < 10 } {set i [expr $i+1]} { - puts "Test iteration $i" + echo "Test iteration $i" dump_image $tmpfile $address $size verify_image $tmpfile $address bin load_image $tmpfile $address bin commit 4747af362de04b508c91df4004d2aed5579c8a1c Author: Antonio Borneo <bor...@gm...> Date: Mon Nov 8 15:13:28 2010 +0800 JIM: document "echo" command Document "-n" option in manual; Modify "echo" command definition as COMMAND_HANDLER to easily add help message Add help message aligned with manual. Signed-off-by: Antonio Borneo <bor...@gm...> diff --git a/doc/openocd.texi b/doc/openocd.texi index 5387082..f946bdf 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -5446,9 +5446,10 @@ file (which is normally the server's standard output). @xref{Running}. @end deffn -@deffn Command echo message +@deffn Command echo [-n] message Logs a message at "user" priority. Output @var{message} to stdout. +Option "-n" suppresses trailing newline. @example echo "Downloading kernel -- please wait" @end example diff --git a/src/helper/command.c b/src/helper/command.c index 6c408ee..af1d66f 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -777,19 +777,16 @@ static int jim_find(Jim_Interp *interp, int argc, Jim_Obj *const *argv) return JIM_OK; } -static int jim_echo(Jim_Interp *interp, int argc, Jim_Obj *const *argv) +COMMAND_HANDLER(jim_echo) { - const char *str; - str = Jim_GetString(argv[1], NULL); - if (argc == 3 && !strcmp(str, "-n")) + if (CMD_ARGC == 2 && !strcmp(CMD_ARGV[0], "-n")) { - str = Jim_GetString(argv[2], NULL); - LOG_USER_N("%s", str); + LOG_USER_N("%s", CMD_ARGV[1]); return JIM_OK; } - if (argc != 2) + if (CMD_ARGC != 1) return JIM_ERR; - LOG_USER("%s", str); + LOG_USER("%s", CMD_ARGV[0]); return JIM_OK; } @@ -1262,6 +1259,15 @@ static const struct command_registration command_subcommand_handlers[] = { static const struct command_registration command_builtin_handlers[] = { { + .name = "echo", + .handler = jim_echo, + .mode = COMMAND_ANY, + .help = "Logs a message at \"user\" priority. " + "Output message to stdout. " + "Option \"-n\" suppresses trailing newline", + .usage = "[-n] string", + }, + { .name = "add_help_text", .handler = handle_help_add_command, .mode = COMMAND_ANY, @@ -1364,7 +1370,6 @@ struct command_context* command_init(const char *startup_tcl, Jim_Interp *interp Jim_NewStringObj(interp, HostOs , strlen(HostOs))); Jim_CreateCommand(interp, "ocd_find", jim_find, NULL, NULL); - Jim_CreateCommand(interp, "echo", jim_echo, NULL, NULL); Jim_CreateCommand(interp, "capture", jim_capture, NULL, NULL); register_commands(context, NULL, command_builtin_handlers); commit d220e22e6376fa67d85c9731a4165f86609390d8 Author: Antonio Borneo <bor...@gm...> Date: Mon Nov 8 12:08:56 2010 +0800 JIM: Add "-n" option to "echo" With the new JIMTCL, "puts" only writes to stdout. To write on telnet port too, "echo" must be used. This patch gives to "echo" similar commandline option of "puts". Signed-off-by: Antonio Borneo <bor...@gm...> diff --git a/src/helper/command.c b/src/helper/command.c index 5a68208..6c408ee 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -779,9 +779,16 @@ static int jim_find(Jim_Interp *interp, int argc, Jim_Obj *const *argv) static int jim_echo(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { + const char *str; + str = Jim_GetString(argv[1], NULL); + if (argc == 3 && !strcmp(str, "-n")) + { + str = Jim_GetString(argv[2], NULL); + LOG_USER_N("%s", str); + return JIM_OK; + } if (argc != 2) return JIM_ERR; - const char *str = Jim_GetString(argv[1], NULL); LOG_USER("%s", str); return JIM_OK; } ----------------------------------------------------------------------- Summary of changes: doc/openocd.texi | 3 +- src/helper/command.c | 22 +++- src/jtag/startup.tcl | 8 +- tcl/bitsbytes.tcl | 2 +- tcl/board/at91eb40a.cfg | 2 +- tcl/board/dm355evm.cfg | 2 +- tcl/board/dm6446evm.cfg | 2 +- tcl/board/ethernut3.cfg | 10 +- tcl/board/lubbock.cfg | 2 +- tcl/board/olimex_sam9_l9260.cfg | 8 +- tcl/board/telo.cfg | 12 +- tcl/board/zy1000.cfg | 8 +- tcl/chip/atmel/at91/aic.tcl | 24 ++-- tcl/chip/atmel/at91/rtt.tcl | 18 ++-- tcl/chip/atmel/at91/usarts.tcl | 16 ++-- tcl/chip/st/spear/quirk_no_srst.tcl | 4 +- tcl/chip/st/spear/spear3xx_ddr.tcl | 4 +- tcl/mmr_helpers.tcl | 16 ++-- tcl/target/aduc702x.cfg | 2 +- tcl/target/c100config.tcl | 26 ++-- tcl/target/c100helper.tcl | 220 +++++++++++++++++----------------- tcl/target/c100regs.tcl | 2 +- tcl/target/imx31.cfg | 4 +- tcl/target/imx35.cfg | 4 +- tcl/target/lpc3250.cfg | 4 +- tcl/test/selftest.cfg | 2 +- 26 files changed, 220 insertions(+), 207 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Øyvind H. <go...@us...> - 2010-11-09 09:26:37
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via fc4e001de34029ca6451038a351b433677d4f388 (commit) via 6ef3d4ccfe2ac017c26072101059628baf99f318 (commit) via 49a231f38dd97c4565868e7b47b51196c19d3d99 (commit) via e774df7f69568c63388a041c1ce5bf0cf95172e1 (commit) from fc4cbc0f988c347be298518b32643fc2fc4e692d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit fc4e001de34029ca6451038a351b433677d4f388 Author: Ãyvind Harboe <oyv...@zy...> Date: Mon Nov 8 16:53:24 2010 +0100 stm32: return early upon block write failure only if we do not have enough ram do we continue. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/flash/nor/stm32x.c b/src/flash/nor/stm32x.c index 63a137c..6b46afc 100644 --- a/src/flash/nor/stm32x.c +++ b/src/flash/nor/stm32x.c @@ -668,6 +668,9 @@ static int stm32x_write(struct flash_bank *bank, uint8_t *buffer, } } + if ((retval != ERROR_OK) && (retval != ERROR_TARGET_RESOURCE_NOT_AVAILABLE)) + return retval; + while (words_remaining > 0) { uint16_t value; commit 6ef3d4ccfe2ac017c26072101059628baf99f318 Author: Ãyvind Harboe <oyv...@zy...> Date: Mon Nov 8 16:26:58 2010 +0100 stm32: return error when failing to read add missing error handling. Output warning when assuming maximum flash size in the family when failing to read. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/flash/nor/stm32x.c b/src/flash/nor/stm32x.c index ae4f02b..63a137c 100644 --- a/src/flash/nor/stm32x.c +++ b/src/flash/nor/stm32x.c @@ -115,7 +115,9 @@ static int stm32x_read_options(struct flash_bank *bank) stm32x_info = bank->driver_priv; /* read current option bytes */ - target_read_u32(target, STM32_FLASH_OBR, &optiondata); + int retval = target_read_u32(target, STM32_FLASH_OBR, &optiondata); + if (retval != ERROR_OK) + return retval; stm32x_info->option_bytes.user_options = (uint16_t)0xFFF8 | ((optiondata >> 2) & 0x07); stm32x_info->option_bytes.RDP = (optiondata & (1 << OPT_READOUT)) ? 0xFFFF : 0x5AA5; @@ -124,7 +126,9 @@ static int stm32x_read_options(struct flash_bank *bank) LOG_INFO("Device Security Bit Set"); /* each bit refers to a 4bank protection */ - target_read_u32(target, STM32_FLASH_WRPR, &optiondata); + retval = target_read_u32(target, STM32_FLASH_WRPR, &optiondata); + if (retval != ERROR_OK) + return retval; stm32x_info->option_bytes.protection[0] = (uint16_t)optiondata; stm32x_info->option_bytes.protection[1] = (uint16_t)(optiondata >> 8); @@ -287,7 +291,9 @@ static int stm32x_protect_check(struct flash_bank *bank) /* medium density - each bit refers to a 4bank protection * high density - each bit refers to a 2bank protection */ - target_read_u32(target, STM32_FLASH_WRPR, &protection); + int retval = target_read_u32(target, STM32_FLASH_WRPR, &protection); + if (retval != ERROR_OK) + return retval; /* medium density - each protection bit is for 4 * 1K pages * high density - each protection bit is for 2 * 2K pages */ @@ -418,7 +424,9 @@ static int stm32x_protect(struct flash_bank *bank, int set, int first, int last) /* medium density - each bit refers to a 4bank protection * high density - each bit refers to a 2bank protection */ - target_read_u32(target, STM32_FLASH_WRPR, &protection); + int retval = target_read_u32(target, STM32_FLASH_WRPR, &protection); + if (retval != ERROR_OK) + return retval; prot_reg[0] = (uint16_t)protection; prot_reg[1] = (uint16_t)(protection >> 8); @@ -713,12 +721,16 @@ static int stm32x_probe(struct flash_bank *bank) stm32x_info->probed = 0; /* read stm32 device id register */ - target_read_u32(target, 0xE0042000, &device_id); + int retval = target_read_u32(target, 0xE0042000, &device_id); + if (retval != ERROR_OK) + return retval; LOG_INFO("device id = 0x%08" PRIx32 "", device_id); - /* get flash size from target */ - if (target_read_u16(target, 0x1FFFF7E0, &num_pages) != ERROR_OK) + /* get flash size from target. */ + retval = target_read_u16(target, 0x1FFFF7E0, &num_pages); + if (retval != ERROR_OK) { + LOG_WARNING("failed reading flash size, default to max target family"); /* failed reading flash size, default to max target family */ num_pages = 0xffff; } @@ -855,7 +867,9 @@ static int get_stm32x_info(struct flash_bank *bank, char *buf, int buf_size) int printed; /* read stm32 device id register */ - target_read_u32(target, 0xE0042000, &device_id); + int retval = target_read_u32(target, 0xE0042000, &device_id); + if (retval != ERROR_OK) + return retval; if ((device_id & 0x7ff) == 0x410) { @@ -1093,7 +1107,9 @@ COMMAND_HANDLER(stm32x_handle_options_read_command) return ERROR_TARGET_NOT_HALTED; } - target_read_u32(target, STM32_FLASH_OBR, &optionbyte); + retval = target_read_u32(target, STM32_FLASH_OBR, &optionbyte); + if (retval != ERROR_OK) + return retval; command_print(CMD_CTX, "Option Byte: 0x%" PRIx32 "", optionbyte); if (buf_get_u32((uint8_t*)&optionbyte, OPT_ERROR, 1)) commit 49a231f38dd97c4565868e7b47b51196c19d3d99 Author: Ãyvind Harboe <oyv...@zy...> Date: Mon Nov 8 16:22:22 2010 +0100 stm32: add error propagation on writes catch problems earlier. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/flash/nor/stm32x.c b/src/flash/nor/stm32x.c index 9decac2..ae4f02b 100644 --- a/src/flash/nor/stm32x.c +++ b/src/flash/nor/stm32x.c @@ -145,18 +145,31 @@ static int stm32x_erase_options(struct flash_bank *bank) stm32x_read_options(bank); /* unlock flash registers */ - target_write_u32(target, STM32_FLASH_KEYR, KEY1); - target_write_u32(target, STM32_FLASH_KEYR, KEY2); + int retval = target_write_u32(target, STM32_FLASH_KEYR, KEY1); + if (retval != ERROR_OK) + return retval; + + retval = target_write_u32(target, STM32_FLASH_KEYR, KEY2); + if (retval != ERROR_OK) + return retval; /* unlock option flash registers */ - target_write_u32(target, STM32_FLASH_OPTKEYR, KEY1); - target_write_u32(target, STM32_FLASH_OPTKEYR, KEY2); + retval = target_write_u32(target, STM32_FLASH_OPTKEYR, KEY1); + if (retval != ERROR_OK) + return retval; + retval = target_write_u32(target, STM32_FLASH_OPTKEYR, KEY2); + if (retval != ERROR_OK) + return retval; /* erase option bytes */ - target_write_u32(target, STM32_FLASH_CR, FLASH_OPTER | FLASH_OPTWRE); - target_write_u32(target, STM32_FLASH_CR, FLASH_OPTER | FLASH_STRT | FLASH_OPTWRE); + retval = target_write_u32(target, STM32_FLASH_CR, FLASH_OPTER | FLASH_OPTWRE); + if (retval != ERROR_OK) + return retval; + retval = target_write_u32(target, STM32_FLASH_CR, FLASH_OPTER | FLASH_STRT | FLASH_OPTWRE); + if (retval != ERROR_OK) + return retval; - int retval = stm32x_wait_status_busy(bank, 10); + retval = stm32x_wait_status_busy(bank, 10); if (retval != ERROR_OK) return retval; @@ -175,59 +188,83 @@ static int stm32x_write_options(struct flash_bank *bank) stm32x_info = bank->driver_priv; /* unlock flash registers */ - target_write_u32(target, STM32_FLASH_KEYR, KEY1); - target_write_u32(target, STM32_FLASH_KEYR, KEY2); + int retval = target_write_u32(target, STM32_FLASH_KEYR, KEY1); + if (retval != ERROR_OK) + return retval; + retval = target_write_u32(target, STM32_FLASH_KEYR, KEY2); + if (retval != ERROR_OK) + return retval; /* unlock option flash registers */ - target_write_u32(target, STM32_FLASH_OPTKEYR, KEY1); - target_write_u32(target, STM32_FLASH_OPTKEYR, KEY2); + retval = target_write_u32(target, STM32_FLASH_OPTKEYR, KEY1); + if (retval != ERROR_OK) + return retval; + retval = target_write_u32(target, STM32_FLASH_OPTKEYR, KEY2); + if (retval != ERROR_OK) + return retval; /* program option bytes */ - target_write_u32(target, STM32_FLASH_CR, FLASH_OPTPG | FLASH_OPTWRE); + retval = target_write_u32(target, STM32_FLASH_CR, FLASH_OPTPG | FLASH_OPTWRE); + if (retval != ERROR_OK) + return retval; /* write user option byte */ - target_write_u16(target, STM32_OB_USER, stm32x_info->option_bytes.user_options); + retval = target_write_u16(target, STM32_OB_USER, stm32x_info->option_bytes.user_options); + if (retval != ERROR_OK) + return retval; - int retval = stm32x_wait_status_busy(bank, 10); + retval = stm32x_wait_status_busy(bank, 10); if (retval != ERROR_OK) return retval; /* write protection byte 1 */ - target_write_u16(target, STM32_OB_WRP0, stm32x_info->option_bytes.protection[0]); + retval = target_write_u16(target, STM32_OB_WRP0, stm32x_info->option_bytes.protection[0]); + if (retval != ERROR_OK) + return retval; retval = stm32x_wait_status_busy(bank, 10); if (retval != ERROR_OK) return retval; /* write protection byte 2 */ - target_write_u16(target, STM32_OB_WRP1, stm32x_info->option_bytes.protection[1]); + retval = target_write_u16(target, STM32_OB_WRP1, stm32x_info->option_bytes.protection[1]); + if (retval != ERROR_OK) + return retval; retval = stm32x_wait_status_busy(bank, 10); if (retval != ERROR_OK) return retval; /* write protection byte 3 */ - target_write_u16(target, STM32_OB_WRP2, stm32x_info->option_bytes.protection[2]); + retval = target_write_u16(target, STM32_OB_WRP2, stm32x_info->option_bytes.protection[2]); + if (retval != ERROR_OK) + return retval; retval = stm32x_wait_status_busy(bank, 10); if (retval != ERROR_OK) return retval; /* write protection byte 4 */ - target_write_u16(target, STM32_OB_WRP3, stm32x_info->option_bytes.protection[3]); + retval = target_write_u16(target, STM32_OB_WRP3, stm32x_info->option_bytes.protection[3]); + if (retval != ERROR_OK) + return retval; retval = stm32x_wait_status_busy(bank, 10); if (retval != ERROR_OK) return retval; /* write readout protection bit */ - target_write_u16(target, STM32_OB_RDP, stm32x_info->option_bytes.RDP); + retval = target_write_u16(target, STM32_OB_RDP, stm32x_info->option_bytes.RDP); + if (retval != ERROR_OK) + return retval; retval = stm32x_wait_status_busy(bank, 10); if (retval != ERROR_OK) return retval; - target_write_u32(target, STM32_FLASH_CR, FLASH_LOCK); + retval = target_write_u32(target, STM32_FLASH_CR, FLASH_LOCK); + if (retval != ERROR_OK) + return retval; return ERROR_OK; } @@ -321,23 +358,35 @@ static int stm32x_erase(struct flash_bank *bank, int first, int last) } /* unlock flash registers */ - target_write_u32(target, STM32_FLASH_KEYR, KEY1); - target_write_u32(target, STM32_FLASH_KEYR, KEY2); + int retval = target_write_u32(target, STM32_FLASH_KEYR, KEY1); + if (retval != ERROR_OK) + return retval; + retval = target_write_u32(target, STM32_FLASH_KEYR, KEY2); + if (retval != ERROR_OK) + return retval; for (i = first; i <= last; i++) { - target_write_u32(target, STM32_FLASH_CR, FLASH_PER); - target_write_u32(target, STM32_FLASH_AR, bank->base + bank->sectors[i].offset); - target_write_u32(target, STM32_FLASH_CR, FLASH_PER | FLASH_STRT); + retval = target_write_u32(target, STM32_FLASH_CR, FLASH_PER); + if (retval != ERROR_OK) + return retval; + retval = target_write_u32(target, STM32_FLASH_AR, bank->base + bank->sectors[i].offset); + if (retval != ERROR_OK) + return retval; + retval = target_write_u32(target, STM32_FLASH_CR, FLASH_PER | FLASH_STRT); + if (retval != ERROR_OK) + return retval; - int retval = stm32x_wait_status_busy(bank, 100); + retval = stm32x_wait_status_busy(bank, 100); if (retval != ERROR_OK) return retval; bank->sectors[i].is_erased = 1; } - target_write_u32(target, STM32_FLASH_CR, FLASH_LOCK); + retval = target_write_u32(target, STM32_FLASH_CR, FLASH_LOCK); + if (retval != ERROR_OK) + return retval; return ERROR_OK; } @@ -583,8 +632,12 @@ static int stm32x_write(struct flash_bank *bank, uint8_t *buffer, } /* unlock flash registers */ - target_write_u32(target, STM32_FLASH_KEYR, KEY1); - target_write_u32(target, STM32_FLASH_KEYR, KEY2); + retval = target_write_u32(target, STM32_FLASH_KEYR, KEY1); + if (retval != ERROR_OK) + return retval; + retval = target_write_u32(target, STM32_FLASH_KEYR, KEY2); + if (retval != ERROR_OK) + return retval; /* multiple half words (2-byte) to be programmed? */ if (words_remaining > 0) @@ -612,8 +665,12 @@ static int stm32x_write(struct flash_bank *bank, uint8_t *buffer, uint16_t value; memcpy(&value, buffer + bytes_written, sizeof(uint16_t)); - target_write_u32(target, STM32_FLASH_CR, FLASH_PG); - target_write_u16(target, address, value); + retval = target_write_u32(target, STM32_FLASH_CR, FLASH_PG); + if (retval != ERROR_OK) + return retval; + retval = target_write_u16(target, address, value); + if (retval != ERROR_OK) + return retval; retval = stm32x_wait_status_busy(bank, 5); if (retval != ERROR_OK) @@ -629,17 +686,19 @@ static int stm32x_write(struct flash_bank *bank, uint8_t *buffer, uint16_t value = 0xffff; memcpy(&value, buffer + bytes_written, bytes_remaining); - target_write_u32(target, STM32_FLASH_CR, FLASH_PG); - target_write_u16(target, address, value); + retval = target_write_u32(target, STM32_FLASH_CR, FLASH_PG); + if (retval != ERROR_OK) + return retval; + retval = target_write_u16(target, address, value); + if (retval != ERROR_OK) + return retval; retval = stm32x_wait_status_busy(bank, 5); if (retval != ERROR_OK) return retval; } - target_write_u32(target, STM32_FLASH_CR, FLASH_LOCK); - - return ERROR_OK; + return target_write_u32(target, STM32_FLASH_CR, FLASH_LOCK); } static int stm32x_probe(struct flash_bank *bank) @@ -1156,18 +1215,28 @@ static int stm32x_mass_erase(struct flash_bank *bank) } /* unlock option flash registers */ - target_write_u32(target, STM32_FLASH_KEYR, KEY1); - target_write_u32(target, STM32_FLASH_KEYR, KEY2); + int retval = target_write_u32(target, STM32_FLASH_KEYR, KEY1); + if (retval != ERROR_OK) + return retval; + retval = target_write_u32(target, STM32_FLASH_KEYR, KEY2); + if (retval != ERROR_OK) + return retval; /* mass erase flash memory */ - target_write_u32(target, STM32_FLASH_CR, FLASH_MER); - target_write_u32(target, STM32_FLASH_CR, FLASH_MER | FLASH_STRT); + retval = target_write_u32(target, STM32_FLASH_CR, FLASH_MER); + if (retval != ERROR_OK) + return retval; + retval = target_write_u32(target, STM32_FLASH_CR, FLASH_MER | FLASH_STRT); + if (retval != ERROR_OK) + return retval; - int retval = stm32x_wait_status_busy(bank, 100); + retval = stm32x_wait_status_busy(bank, 100); if (retval != ERROR_OK) return retval; - target_write_u32(target, STM32_FLASH_CR, FLASH_LOCK); + retval = target_write_u32(target, STM32_FLASH_CR, FLASH_LOCK); + if (retval != ERROR_OK) + return retval; return ERROR_OK; } commit e774df7f69568c63388a041c1ce5bf0cf95172e1 Author: Ãyvind Harboe <oyv...@zy...> Date: Mon Nov 8 16:02:07 2010 +0100 stm32: sharpen error handling for timeouts delete lots of crud by handling this all in one spot. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/flash/nor/stm32x.c b/src/flash/nor/stm32x.c index 5b31b04..9decac2 100644 --- a/src/flash/nor/stm32x.c +++ b/src/flash/nor/stm32x.c @@ -54,33 +54,56 @@ FLASH_BANK_COMMAND_HANDLER(stm32x_flash_bank_command) return ERROR_OK; } -static uint32_t stm32x_get_flash_status(struct flash_bank *bank) +static int stm32x_get_flash_status(struct flash_bank *bank, uint32_t *status) { struct target *target = bank->target; - uint32_t status; - - target_read_u32(target, STM32_FLASH_SR, &status); - - return status; + return target_read_u32(target, STM32_FLASH_SR, status); } -static uint32_t stm32x_wait_status_busy(struct flash_bank *bank, int timeout) +static int stm32x_wait_status_busy(struct flash_bank *bank, int timeout) { struct target *target = bank->target; uint32_t status; + int retval = ERROR_OK; /* wait for busy to clear */ - while (((status = stm32x_get_flash_status(bank)) & FLASH_BSY) && (timeout-- > 0)) + for (;;) { + retval = stm32x_get_flash_status(bank, &status); + if (retval != ERROR_OK) + return retval; LOG_DEBUG("status: 0x%" PRIx32 "", status); + if ((status & FLASH_BSY) == 0) + break; + if (timeout-- <= 0) + { + LOG_ERROR("timed out waiting for flash"); + return ERROR_FAIL; + } alive_sleep(1); } + + if (status & FLASH_WRPRTERR) + { + LOG_ERROR("stm32x device protected"); + retval = ERROR_FAIL; + } + + if (status & FLASH_PGERR) + { + LOG_ERROR("stm32x device programming failed"); + retval = ERROR_FAIL; + } + /* Clear but report errors */ if (status & (FLASH_WRPRTERR | FLASH_PGERR)) { + /* If this operation fails, we ignore it and report the original + * retval + */ target_write_u32(target, STM32_FLASH_SR, FLASH_WRPRTERR | FLASH_PGERR); } - return status; + return retval; } static int stm32x_read_options(struct flash_bank *bank) @@ -115,7 +138,6 @@ static int stm32x_erase_options(struct flash_bank *bank) { struct stm32x_flash_bank *stm32x_info = NULL; struct target *target = bank->target; - uint32_t status; stm32x_info = bank->driver_priv; @@ -134,12 +156,9 @@ static int stm32x_erase_options(struct flash_bank *bank) target_write_u32(target, STM32_FLASH_CR, FLASH_OPTER | FLASH_OPTWRE); target_write_u32(target, STM32_FLASH_CR, FLASH_OPTER | FLASH_STRT | FLASH_OPTWRE); - status = stm32x_wait_status_busy(bank, 10); - - if (status & FLASH_WRPRTERR) - return ERROR_FLASH_OPERATION_FAILED; - if (status & FLASH_PGERR) - return ERROR_FLASH_OPERATION_FAILED; + int retval = stm32x_wait_status_busy(bank, 10); + if (retval != ERROR_OK) + return retval; /* clear readout protection and complementary option bytes * this will also force a device unlock if set */ @@ -152,7 +171,6 @@ static int stm32x_write_options(struct flash_bank *bank) { struct stm32x_flash_bank *stm32x_info = NULL; struct target *target = bank->target; - uint32_t status; stm32x_info = bank->driver_priv; @@ -170,62 +188,44 @@ static int stm32x_write_options(struct flash_bank *bank) /* write user option byte */ target_write_u16(target, STM32_OB_USER, stm32x_info->option_bytes.user_options); - status = stm32x_wait_status_busy(bank, 10); - - if (status & FLASH_WRPRTERR) - return ERROR_FLASH_OPERATION_FAILED; - if (status & FLASH_PGERR) - return ERROR_FLASH_OPERATION_FAILED; + int retval = stm32x_wait_status_busy(bank, 10); + if (retval != ERROR_OK) + return retval; /* write protection byte 1 */ target_write_u16(target, STM32_OB_WRP0, stm32x_info->option_bytes.protection[0]); - status = stm32x_wait_status_busy(bank, 10); - - if (status & FLASH_WRPRTERR) - return ERROR_FLASH_OPERATION_FAILED; - if (status & FLASH_PGERR) - return ERROR_FLASH_OPERATION_FAILED; + retval = stm32x_wait_status_busy(bank, 10); + if (retval != ERROR_OK) + return retval; /* write protection byte 2 */ target_write_u16(target, STM32_OB_WRP1, stm32x_info->option_bytes.protection[1]); - status = stm32x_wait_status_busy(bank, 10); - - if (status & FLASH_WRPRTERR) - return ERROR_FLASH_OPERATION_FAILED; - if (status & FLASH_PGERR) - return ERROR_FLASH_OPERATION_FAILED; + retval = stm32x_wait_status_busy(bank, 10); + if (retval != ERROR_OK) + return retval; /* write protection byte 3 */ target_write_u16(target, STM32_OB_WRP2, stm32x_info->option_bytes.protection[2]); - status = stm32x_wait_status_busy(bank, 10); - - if (status & FLASH_WRPRTERR) - return ERROR_FLASH_OPERATION_FAILED; - if (status & FLASH_PGERR) - return ERROR_FLASH_OPERATION_FAILED; + retval = stm32x_wait_status_busy(bank, 10); + if (retval != ERROR_OK) + return retval; /* write protection byte 4 */ target_write_u16(target, STM32_OB_WRP3, stm32x_info->option_bytes.protection[3]); - status = stm32x_wait_status_busy(bank, 10); - - if (status & FLASH_WRPRTERR) - return ERROR_FLASH_OPERATION_FAILED; - if (status & FLASH_PGERR) - return ERROR_FLASH_OPERATION_FAILED; + retval = stm32x_wait_status_busy(bank, 10); + if (retval != ERROR_OK) + return retval; /* write readout protection bit */ target_write_u16(target, STM32_OB_RDP, stm32x_info->option_bytes.RDP); - status = stm32x_wait_status_busy(bank, 10); - - if (status & FLASH_WRPRTERR) - return ERROR_FLASH_OPERATION_FAILED; - if (status & FLASH_PGERR) - return ERROR_FLASH_OPERATION_FAILED; + retval = stm32x_wait_status_busy(bank, 10); + if (retval != ERROR_OK) + return retval; target_write_u32(target, STM32_FLASH_CR, FLASH_LOCK); @@ -308,7 +308,6 @@ static int stm32x_erase(struct flash_bank *bank, int first, int last) { struct target *target = bank->target; int i; - uint32_t status; if (bank->target->state != TARGET_HALTED) { @@ -331,12 +330,10 @@ static int stm32x_erase(struct flash_bank *bank, int first, int last) target_write_u32(target, STM32_FLASH_AR, bank->base + bank->sectors[i].offset); target_write_u32(target, STM32_FLASH_CR, FLASH_PER | FLASH_STRT); - status = stm32x_wait_status_busy(bank, 100); + int retval = stm32x_wait_status_busy(bank, 100); + if (retval != ERROR_OK) + return retval; - if (status & FLASH_WRPRTERR) - return ERROR_FLASH_OPERATION_FAILED; - if (status & FLASH_PGERR) - return ERROR_FLASH_OPERATION_FAILED; bank->sectors[i].is_erased = 1; } @@ -526,7 +523,6 @@ static int stm32x_write_block(struct flash_bank *bank, uint8_t *buffer, 10000, &armv7m_info)) != ERROR_OK) { LOG_ERROR("error executing stm32x flash write algorithm"); - retval = ERROR_FLASH_OPERATION_FAILED; break; } @@ -535,7 +531,7 @@ static int stm32x_write_block(struct flash_bank *bank, uint8_t *buffer, LOG_ERROR("flash memory not erased before writing"); /* Clear but report errors */ target_write_u32(target, STM32_FLASH_SR, FLASH_PGERR); - retval = ERROR_FLASH_OPERATION_FAILED; + retval = ERROR_FAIL; break; } @@ -544,7 +540,7 @@ static int stm32x_write_block(struct flash_bank *bank, uint8_t *buffer, LOG_ERROR("flash memory write protected"); /* Clear but report errors */ target_write_u32(target, STM32_FLASH_SR, FLASH_WRPRTERR); - retval = ERROR_FLASH_OPERATION_FAILED; + retval = ERROR_FAIL; break; } @@ -572,7 +568,6 @@ static int stm32x_write(struct flash_bank *bank, uint8_t *buffer, uint32_t bytes_remaining = (count & 0x00000001); uint32_t address = bank->base + offset; uint32_t bytes_written = 0; - uint8_t status; int retval; if (bank->target->state != TARGET_HALTED) @@ -603,11 +598,6 @@ static int stm32x_write(struct flash_bank *bank, uint8_t *buffer, * we use normal (slow) single dword accesses */ LOG_WARNING("couldn't use block writes, falling back to single memory accesses"); } - else if (retval == ERROR_FLASH_OPERATION_FAILED) - { - LOG_ERROR("flash writing failed with error code: 0x%x", retval); - return ERROR_FLASH_OPERATION_FAILED; - } } else { @@ -625,18 +615,9 @@ static int stm32x_write(struct flash_bank *bank, uint8_t *buffer, target_write_u32(target, STM32_FLASH_CR, FLASH_PG); target_write_u16(target, address, value); - status = stm32x_wait_status_busy(bank, 5); - - if (status & FLASH_WRPRTERR) - { - LOG_ERROR("flash memory not erased before writing"); - return ERROR_FLASH_OPERATION_FAILED; - } - if (status & FLASH_PGERR) - { - LOG_ERROR("flash memory write protected"); - return ERROR_FLASH_OPERATION_FAILED; - } + retval = stm32x_wait_status_busy(bank, 5); + if (retval != ERROR_OK) + return retval; bytes_written += 2; words_remaining--; @@ -651,18 +632,9 @@ static int stm32x_write(struct flash_bank *bank, uint8_t *buffer, target_write_u32(target, STM32_FLASH_CR, FLASH_PG); target_write_u16(target, address, value); - status = stm32x_wait_status_busy(bank, 5); - - if (status & FLASH_WRPRTERR) - { - LOG_ERROR("flash memory not erased before writing"); - return ERROR_FLASH_OPERATION_FAILED; - } - if (status & FLASH_PGERR) - { - LOG_ERROR("flash memory write protected"); - return ERROR_FLASH_OPERATION_FAILED; - } + retval = stm32x_wait_status_busy(bank, 5); + if (retval != ERROR_OK) + return retval; } target_write_u32(target, STM32_FLASH_CR, FLASH_LOCK); @@ -770,7 +742,7 @@ static int stm32x_probe(struct flash_bank *bank) else { LOG_WARNING("Cannot identify target as a STM32 family."); - return ERROR_FLASH_OPERATION_FAILED; + return ERROR_FAIL; } LOG_INFO("flash size = %dkbytes", num_pages); @@ -938,7 +910,7 @@ static int get_stm32x_info(struct flash_bank *bank, char *buf, int buf_size) else { snprintf(buf, buf_size, "Cannot identify target as a stm32x\n"); - return ERROR_FLASH_OPERATION_FAILED; + return ERROR_FAIL; } return ERROR_OK; @@ -1176,7 +1148,6 @@ COMMAND_HANDLER(stm32x_handle_options_write_command) static int stm32x_mass_erase(struct flash_bank *bank) { struct target *target = bank->target; - uint32_t status; if (target->state != TARGET_HALTED) { @@ -1192,22 +1163,12 @@ static int stm32x_mass_erase(struct flash_bank *bank) target_write_u32(target, STM32_FLASH_CR, FLASH_MER); target_write_u32(target, STM32_FLASH_CR, FLASH_MER | FLASH_STRT); - status = stm32x_wait_status_busy(bank, 100); + int retval = stm32x_wait_status_busy(bank, 100); + if (retval != ERROR_OK) + return retval; target_write_u32(target, STM32_FLASH_CR, FLASH_LOCK); - if (status & FLASH_WRPRTERR) - { - LOG_ERROR("stm32x device protected"); - return ERROR_FLASH_OPERATION_FAILED; - } - - if (status & FLASH_PGERR) - { - LOG_ERROR("stm32x device programming failed"); - return ERROR_FLASH_OPERATION_FAILED; - } - return ERROR_OK; } ----------------------------------------------------------------------- Summary of changes: src/flash/nor/stm32x.c | 361 +++++++++++++++++++++++++++--------------------- 1 files changed, 205 insertions(+), 156 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Øyvind H. <go...@us...> - 2010-11-09 08:06:23
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via fc4cbc0f988c347be298518b32643fc2fc4e692d (commit) from 074498f836db2879d73c39615fa5dced8a6555c9 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit fc4cbc0f988c347be298518b32643fc2fc4e692d Author: Andrew Leech <cor...@gm...> Date: Tue Nov 9 08:05:02 2010 +0100 lpc3131: target definition diff --git a/tcl/target/lpc3131.cfg b/tcl/target/lpc3131.cfg new file mode 100644 index 0000000..5c6aa3c --- /dev/null +++ b/tcl/target/lpc3131.cfg @@ -0,0 +1,76 @@ +###################################### +# Target: NXP lpc3131 +###################################### + +if { [info exists CHIPNAME] } { + set _CHIPNAME $CHIPNAME +} else { + set _CHIPNAME lpc3131 +} + +if { [info exists ENDIAN] } { + set _ENDIAN $ENDIAN +} else { + set _ENDIAN little +} + +# ARM926EJS core +if { [info exists CPUTAPID ] } { + set _CPUTAPID $CPUTAPID +} else { + set _CPUTAPID 0x07926f0f +} + +# Scan Tap +# Wired to seperate STDO pin on the lpc3131, externally muxed to TDO on ea3131 module +# JTAGSEL pin must be 0 to activate, which reassigns arm tdo to a pass through. +if { [info exists SJCTAPID ] } { + set _SJCTAPID $SJCTAPID +} else { + set _SJCTAPID 0x1541E02B +} + +jtag newtap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID + +################################################################## +# various symbol definitions, to avoid hard-wiring addresses +################################################################## + +global lpc313x +set lpc313x [ dict create ] + +# Physical addresses for controllers and memory +dict set lpc313x sram0 0x11028000 +dict set lpc313x sram1 0x11040000 +dict set lpc313x uart 0x15001000 +dict set lpc313x cgu 0x13004000 +dict set lpc313x ioconfig 0x13003000 +dict set lpc313x sysconfig 0x13002800 +dict set lpc313x wdt 0x13002400 + +################################################################## +# Target configuration +################################################################## + +jtag_nsrst_delay 1000 +jtag_ntrst_delay 0 + +set _TARGETNAME $_CHIPNAME.cpu +target create $_TARGETNAME arm926ejs -endian $_ENDIAN -chain-position $_TARGETNAME + +$_TARGETNAME invoke-event halted + +$_TARGETNAME configure -work-area-phys [dict get $lpc313x sram0] -work-area-size 0x30000 -work-area-backup 0 + +$_TARGETNAME configure -event reset-init { + echo "\nRunning reset init script for LPC3131\n" + halt + wait_halt + reg cpsr 0xa00000d3 #Supervisor mode + reg pc 0x11029000 + poll + sleep 500 +} + +arm7_9 fast_memory_access enable +arm7_9 dcc_downloads enable ----------------------------------------------------------------------- Summary of changes: tcl/target/lpc3131.cfg | 76 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 76 insertions(+), 0 deletions(-) create mode 100644 tcl/target/lpc3131.cfg hooks/post-receive -- Main OpenOCD repository |
From: Øyvind H. <go...@us...> - 2010-11-06 15:44:29
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 074498f836db2879d73c39615fa5dced8a6555c9 (commit) from 8f1f8e7b96d4dfdca867cfcf69e0efab9f6e3731 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 074498f836db2879d73c39615fa5dced8a6555c9 Author: Antonio Borneo <bor...@gm...> Date: Thu Nov 4 16:53:28 2010 +0800 TCL scripts: add support for ST SPEAr310 Initial support for ST SPEAr310 and for the evaluation board EVALSPEAr310 Rev. 2.0. Scripts are split in generic for SPEAr3xx family and specific for SPEAr310. This should easily allow adding new members of the family. Signed-off-by: Antonio Borneo <bor...@gm...> diff --git a/tcl/board/spear310evb20.cfg b/tcl/board/spear310evb20.cfg new file mode 100644 index 0000000..887e799 --- /dev/null +++ b/tcl/board/spear310evb20.cfg @@ -0,0 +1,48 @@ +# Configuration for the ST SPEAr310 Evaluation board +# EVALSPEAr310 Rev. 2.0 +# http://www.st.com/spear +# +# Date: 2010-08-17 +# Author: Antonio Borneo <bor...@gm...> + +# The standard board has JTAG SRST not connected. +# This script targets such boards using quirky code to bypass the issue. +# +# Check ST Application Note (FIXME: put reference) on how to fix SRST on +# the board, then use the script board/spear310evb20_mod.cfg + + +source [find mem_helper.tcl] +source [find target/spear3xx.cfg] +source [find chip/st/spear/spear310.tcl] +source [find chip/st/spear/spear3xx_ddr.tcl] +source [find chip/st/spear/spear3xx.tcl] + +arm7_9 dcc_downloads enable +arm7_9 fast_memory_access enable + +# CFI parallel NOR on EMI CS0. 2x 16bit 8M devices = 16Mbyte. +set _FLASHNAME0 $_CHIPNAME.pnor +flash bank $_FLASHNAME0 cfi 0x50000000 0x01000000 2 4 $_TARGETNAME + +if { [info exists BOARD_HAS_SRST] } { + # Modified board has SRST on JTAG connector + reset_config trst_and_srst separate srst_gates_jtag \ + trst_push_pull srst_open_drain +} else { + # Standard board has no SRST on JTAG connector + reset_config trst_only separate srst_gates_jtag trst_push_pull + source [find chip/st/spear/quirk_no_srst.tcl] +} + +$_TARGETNAME configure -event reset-init { spear310evb20_init } + +proc spear310evb20_init {} { + reg pc 0xffff0020 # loop forever + + sp3xx_clock_default + sp3xx_common_init + sp3xx_ddr_init "mt47h64m16_3_333_cl5_async" + sp310_init + sp310_emi_init +} diff --git a/tcl/board/spear310evb20_mod.cfg b/tcl/board/spear310evb20_mod.cfg new file mode 100644 index 0000000..bf62915 --- /dev/null +++ b/tcl/board/spear310evb20_mod.cfg @@ -0,0 +1,25 @@ +# Configuration for the ST SPEAr310 Evaluation board +# EVALSPEAr310 Rev. 2.0, modified to enable SRST on JTAG connector +# http://www.st.com/spear +# +# List of board modifications to enable SRST, as per ST Application Note +# (FIXME: put reference to AN) +# - Modifications on the top layer: +# 1. remove R137 and C57, located near the SMII PHY U18; +# 2. remove R172 and C75, located near the SMII PHY U19; +# 3. remove R207 and C90, located near the SMII PHY U20; +# 4. remove C236, located near the SMII PHY U21; +# 5. remove U12, located near the JTAG connector; +# 6. solder together pins 7, 8 and 9 of U12; +# 7. solder together pins 11, 12, 13, 14, 15, 16, 17 and 18 of U12. +# - Modifications on the bottom layer: +# 8. replace reset chip U11 with a STM6315SDW13F; +# 9. add 0 ohm resistor R329. It is located close to JTAG connector. +# +# Date: 2009-10-31 +# Author: Antonio Borneo <bor...@gm...> + + +# Modified boards has SRST on JTAG connector +set BOARD_HAS_SRST 1 +source [find board/spear310evb20.cfg] diff --git a/tcl/chip/st/spear/quirk_no_srst.tcl b/tcl/chip/st/spear/quirk_no_srst.tcl new file mode 100644 index 0000000..df22764 --- /dev/null +++ b/tcl/chip/st/spear/quirk_no_srst.tcl @@ -0,0 +1,75 @@ +# Quirks to bypass missing SRST on JTAG connector +# EVALSPEAr310 Rev. 2.0 +# http://www.st.com/spear +# +# Date: 2010-08-17 +# Author: Antonio Borneo <bor...@gm...> + +# For boards that have JTAG SRST not connected. +# We use "arm9 vector_catch reset" to catch button reset event. + + +$_TARGETNAME configure -event reset-assert sp_reset_assert +$_TARGETNAME configure -event reset-deassert-post sp_reset_deassert_post + +# keeps the name of the SPEAr target +global sp_target_name +set sp_target_name $_TARGETNAME + +# Keeps the argument of "reset" command (run, init, halt). +global sp_reset_mode +set sp_reset_mode "" + +# Helper procedure. Returns 0 is target is halted. +proc sp_is_halted {} { + global sp_target_name + + return [expr [string compare [$sp_target_name curstate] "halted" ] == 0] +} + +# wait for reset button to be pressed, causing CPU to get halted +proc sp_reset_deassert_post {} { + global sp_reset_mode + + set bar(0) | + set bar(1) / + set bar(2) - + set bar(3) \\ + + poll on + puts "====> Press reset button on the board <====" + for {set i 0} { [sp_is_halted] == 0 } { set i [expr $i + 1]} { + puts -nonewline "$bar([expr $i & 3])\r" + sleep 200 + } + + # Remove catch reset event + arm9 vector_catch none + + # CPU is halted, but we typed "reset run" ... + if { [string compare $sp_reset_mode "run"] == 0 } { + resume + } +} + +# Override reset-assert, since no SRST available +# Catch reset event +proc sp_reset_assert {} { + arm9 vector_catch reset +} + +# Override default init_reset{mode} to catch parameter "mode" +proc init_reset {mode} { + global sp_reset_mode + + set sp_reset_mode $mode + + # We need to detect CPU get halted, so exit from halt + if { [sp_is_halted] } { + echo "Resuming CPU to detect reset" + resume + } + + # Execute default init_reset{mode} + jtag arp_init-reset +} diff --git a/tcl/chip/st/spear/spear310.tcl b/tcl/chip/st/spear/spear310.tcl new file mode 100644 index 0000000..b2c3676 --- /dev/null +++ b/tcl/chip/st/spear/spear310.tcl @@ -0,0 +1,40 @@ +# Specific init scripts for ST SPEAr310 system on chip +# http://www.st.com/spear +# +# Date: 2010-09-23 +# Author: Antonio Borneo <bor...@gm...> + + +proc sp310_init {} { + mww 0xfca80034 0x0000ffff # enable all RAS clocks + mww 0xfca80040 0x00000000 # remove all RAS resets + mww 0xb4000008 0x00002ff4 # RAS function enable + + mww 0xfca8013c 0x2f7bc210 # plgpio_pad_drv + mww 0xfca80140 0x017bdef6 +} + +proc sp310_emi_init {} { + # set EMI pad strength + mmw 0xfca80134 0x0e000000 0x00000000 + mmw 0xfca80138 0x0e739ce7 0x00000000 + mmw 0xfca8013c 0x00039ce7 0x00000000 + + # set safe EMI timing as in BootROM + #mww 0x4f000000 0x0000000f # tAP_0_reg + #mww 0x4f000004 0x00000000 # tSDP_0_reg + #mww 0x4f000008 0x000000ff # tDPw_0_reg + #mww 0x4f00000c 0x00000111 # tDPr_0_reg + #mww 0x4f000010 0x00000002 # tDCS_0_reg + + # set fast EMI timing as in Linux + mww 0x4f000000 0x00000010 # tAP_0_reg + mww 0x4f000004 0x00000005 # tSDP_0_reg + mww 0x4f000008 0x0000000a # tDPw_0_reg + mww 0x4f00000c 0x0000000a # tDPr_0_reg + mww 0x4f000010 0x00000005 # tDCS_0_re + + # 32bit wide, 8/16/32bit access + mww 0x4f000014 0x0000000e # control_0_reg + mww 0x4f000094 0x0000003f # ack_reg +} diff --git a/tcl/chip/st/spear/spear3xx.tcl b/tcl/chip/st/spear/spear3xx.tcl new file mode 100644 index 0000000..ea85d29 --- /dev/null +++ b/tcl/chip/st/spear/spear3xx.tcl @@ -0,0 +1,79 @@ +# Generic init scripts for all ST SPEAr3xx family +# http://www.st.com/spear +# +# Date: 2010-09-23 +# Author: Antonio Borneo <bor...@gm...> + + +# Initialize internal clock +# Default: +# - Crystal = 24 MHz +# - PLL1 = 332 MHz +# - PLL2 = 332 MHz +# - CPU_CLK = 332 MHz +# - DDR_CLK = 332 MHz async +# - HCLK = 166 MHz +# - PCLK = 83 MHz +proc sp3xx_clock_default {} { + mww 0xfca00000 0x00000002 # set sysclk slow + mww 0xfca00014 0x0ffffff8 # set pll timeout to minimum (100us ?!?) + + # DDRCORE disable to change frequency + set val [expr ([mrw 0xfca8002c] & ~0x20000000) | 0x40000000] + mww 0xfca8002c $val + mww 0xfca8002c $val # Yes, write twice! + + # programming PLL1 + mww 0xfca8000c 0xa600010c # M=166 P=1 N=12 + mww 0xfca80008 0x00001c0a # power down + mww 0xfca80008 0x00001c0e # enable + mww 0xfca80008 0x00001c06 # strobe + mww 0xfca80008 0x00001c0e + while { [expr [mrw 0xfca80008] & 0x01] == 0x00 } { sleep 1 } + + # programming PLL2 + mww 0xfca80018 0xa600010c # M=166, P=1, N=12 + mww 0xfca80014 0x00001c0a # power down + mww 0xfca80014 0x00001c0e # enable + mww 0xfca80014 0x00001c06 # strobe + mww 0xfca80014 0x00001c0e + while { [expr [mrw 0xfca80014] & 0x01] == 0x00 } { sleep 1 } + + mww 0xfca80028 0x00000082 # enable plltimeen + mww 0xfca80024 0x00000511 # set hclkdiv="/2" & pclkdiv="/2" + + mww 0xfca00000 0x00000004 # setting SYSCTL to NORMAL mode + while { [expr [mrw 0xfca00000] & 0x20] != 0x20 } { sleep 1 } + + # Select source of DDR clock + #mmw 0xfca80020 0x10000000 0x70000000 ;# PLL1 + mmw 0xfca80020 0x30000000 0x70000000 ;# PLL2 + + # DDRCORE enable after change frequency + mmw 0xfca8002c 0x20000000 0x00000000 +} + +proc sp3xx_common_init {} { + mww 0xfca8002c 0xfffffff8 # enable clock of all peripherals + mww 0xfca80038 0x00000000 # remove reset of all peripherals + + mww 0xfca800e4 0x78000008 # COMP1V8_REG + mww 0xfca800ec 0x78000008 # COMP3V3_REG + + mww 0xfca80050 0x00000001 # Enable clk mem port 1 + + mww 0xfc000000 0x10000f5f # init SMI and set HW mode + mww 0xfc000000 0x00000f5f + + # Initialize Bus Interconnection Matrix + # All ports Round-Robin and lowest priority + mww 0xfca8007c 0x80000007 + mww 0xfca80080 0x80000007 + mww 0xfca80084 0x80000007 + mww 0xfca80088 0x80000007 + mww 0xfca8008c 0x80000007 + mww 0xfca80090 0x80000007 + mww 0xfca80094 0x80000007 + mww 0xfca80098 0x80000007 + mww 0xfca8009c 0x80000007 +} diff --git a/tcl/chip/st/spear/spear3xx_ddr.tcl b/tcl/chip/st/spear/spear3xx_ddr.tcl new file mode 100644 index 0000000..eb1c4b0 --- /dev/null +++ b/tcl/chip/st/spear/spear3xx_ddr.tcl @@ -0,0 +1,120 @@ +# Init scripts to configure DDR controller of SPEAr3xx +# http://www.st.com/spear +# Original values taken from XLoader source code +# +# Date: 2010-09-23 +# Author: Antonio Borneo <bor...@gm...> + + +proc sp3xx_ddr_init {ddr_type} { + if { $ddr_type == "mt47h64m16_3_333_cl5_async" } { + ddr_spr3xx_mt47h64m16_3_333_cl5_async + set ddr_size 0x08000000 + ## add here new DDR chip definition. Prototype: + #} elseif { $ddr_type == "?????" } { + # ????? + # set ddr_size 0x????? + } else { + error "sp3xx_ddr_init: unrecognized DDR type "$ddr_type + } + + # Check for single/double memory chip + # DDR starts at address 0x00000000 + mww $ddr_size 0x87654321 + mww 0x00000000 0x12345678 + if {[expr [mrw 0x00000000] == 0x12345678 && [mrw $ddr_size] == 0x87654321]} { + puts [format \ + "Double chip DDR memory. Total memory size 0x%08x byte" \ + [expr 2 * $ddr_size]] + } else { + puts [format \ + "Single chip DDR memory. Memory size 0x%08x byte" \ + $ddr_size] + } +} + + +# from Xloader file ddr/spr300_mt47h64m16_3_333_cl5_async.S +proc ddr_spr3xx_mt47h64m16_3_333_cl5_async {} { + # DDR_PAD_REG + mww 0xfca800f0 0x00003aa5 + + # Use "1:2 sync" only when DDR clock source is PLL1 and + # HCLK is half of PLL1 + mww 0xfc600000 0x00000001 # MEMCTL_AHB_SET_00 # This is async + mww 0xfc600004 0x00000000 # MEMCTL_AHB_SET_01 +# mww 0xfc600000 0x02020201 # MEMCTL_AHB_SET_00 # This is 1:2 sync +# mww 0xfc600004 0x02020202 # MEMCTL_AHB_SET_01 + + mww 0xfc600008 0x01000000 # MEMCTL_RFSH_SET_00 + mww 0xfc60000c 0x00000101 # MEMCTL_DLL_SET_00 + mww 0xfc600010 0x00000101 # MEMCTL_GP_00 + mww 0xfc600014 0x01000000 # MEMCTL_GP_01 + mww 0xfc600018 0x00010001 # MEMCTL_GP_02 + mww 0xfc60001c 0x00000100 # MEMCTL_GP_03 + mww 0xfc600020 0x00010001 # MEMCTL_GP_04 + mww 0xfc600024 0x01020203 # MEMCTL_GP_05 + mww 0xfc600028 0x01000102 # MEMCTL_GP_06 + mww 0xfc60002c 0x02000202 # MEMCTL_AHB_SET_02 + mww 0xfc600030 0x04040105 # MEMCTL_AHB_SET_03 + mww 0xfc600034 0x03030302 # MEMCTL_AHB_SET_04 + mww 0xfc600038 0x02040101 # MEMCTL_AHB_SET_05 + mww 0xfc60003c 0x00000002 # MEMCTL_AHB_SET_06 + mww 0xfc600044 0x03000405 # MEMCTL_DQS_SET_0 + mww 0xfc600048 0x03040002 # MEMCTL_TIME_SET_01 + mww 0xfc60004c 0x04000305 # MEMCTL_TIME_SET_02 + mww 0xfc600050 0x0505053f # MEMCTL_AHB_RELPR_00 + mww 0xfc600054 0x05050505 # MEMCTL_AHB_RELPR_01 + mww 0xfc600058 0x04040405 # MEMCTL_AHB_RELPR_02 + mww 0xfc60005c 0x04040404 # MEMCTL_AHB_RELPR_03 + mww 0xfc600060 0x03030304 # MEMCTL_AHB_RELPR_04 + mww 0xfc600064 0x03030303 # MEMCTL_AHB_RELPR_05 + mww 0xfc600068 0x02020203 # MEMCTL_AHB_RELPR_06 + mww 0xfc60006c 0x02020202 # MEMCTL_AHB_RELPR_07 + mww 0xfc600070 0x01010102 # MEMCTL_AHB_RELPR_08 + mww 0xfc600074 0x01010101 # MEMCTL_AHB_RELPR_09 + mww 0xfc600078 0x00000001 # MEMCTL_AHB_RELPR_10 + mww 0xfc600088 0x0a0c0a00 # MEMCTL_DQS_SET_1 + mww 0xfc60008c 0x0000023f # MEMCTL_GP_07 + mww 0xfc600090 0x00050a00 # MEMCTL_GP_08 + mww 0xfc600094 0x11000000 # MEMCTL_GP_09 + mww 0xfc600098 0x00001302 # MEMCTL_GP_10 + mww 0xfc60009c 0x00001c1c # MEMCTL_DLL_SET_01 + mww 0xfc6000a0 0x7c000000 # MEMCTL_DQS_OUT_SHIFT + mww 0xfc6000a4 0x005c0000 # MEMCTL_WR_DQS_SHIFT + mww 0xfc6000a8 0x2b050e00 # MEMCTL_TIME_SET_03 + mww 0xfc6000ac 0x00640064 # MEMCTL_AHB_PRRLX_00 + mww 0xfc6000b0 0x00640064 # MEMCTL_AHB_PRRLX_01 + mww 0xfc6000b4 0x00000064 # MEMCTL_AHB_PRRLX_02 + mww 0xfc6000b8 0x00000000 # MEMCTL_OUTRANGE_LGTH + mww 0xfc6000bc 0x00200020 # MEMCTL_AHB_RW_SET_00 + mww 0xfc6000c0 0x00200020 # MEMCTL_AHB_RW_SET_01 + mww 0xfc6000c4 0x00200020 # MEMCTL_AHB_RW_SET_02 + mww 0xfc6000c8 0x00200020 # MEMCTL_AHB_RW_SET_03 + mww 0xfc6000cc 0x00200020 # MEMCTL_AHB_RW_SET_04 + mww 0xfc6000d8 0x00000a24 # MEMCTL_TREF + mww 0xfc6000dc 0x00000000 # MEMCTL_EMRS3_DATA + mww 0xfc6000e0 0x5b1c00c8 # MEMCTL_TIME_SET_04 + mww 0xfc6000e4 0x00c8002e # MEMCTL_TIME_SET_05 + mww 0xfc6000e8 0x00000000 # MEMCTL_VERSION + mww 0xfc6000ec 0x0001046b # MEMCTL_TINIT + mww 0xfc6000f0 0x00000000 # MEMCTL_OUTRANGE_ADDR_01 + mww 0xfc6000f4 0x00000000 # MEMCTL_OUTRANGE_ADDR_02 + mww 0xfc600104 0x001c0000 # MEMCTL_DLL_DQS_DELAY_BYPASS_0 + mww 0xfc600108 0x0019001c # MEMCTL_DLL_SET_02 + mww 0xfc60010c 0x00100000 # MEMCTL_DLL_SET_03 + mww 0xfc600110 0x001e007a # MEMCTL_DQS_SET_2 + mww 0xfc600188 0x00000000 # MEMCTL_USER_DEF_REG_0 + mww 0xfc60018c 0x00000000 # MEMCTL_USER_DEF_REG_1 + mww 0xfc600190 0x01010001 # MEMCTL_GP_11 + mww 0xfc600194 0x01000000 # MEMCTL_GP_12 + mww 0xfc600198 0x00000001 # MEMCTL_GP_13 + mww 0xfc60019c 0x00400000 # MEMCTL_GP_14 + mww 0xfc6001a0 0x00000000 # MEMCTL_EMRS2_DATA_X + mww 0xfc6001a4 0x00000000 # MEMCTL_LWPWR_CNT + mww 0xfc6001a8 0x00000000 # MEMCTL_LWPWR_REG + mww 0xfc6001ac 0x00860000 # MEMCTL_GP_15 + mww 0xfc6001b0 0x00000002 # MEMCTL_TPDEX + # MPMC START + mww 0xfc60001c 0x01000100 +} diff --git a/tcl/target/spear3xx.cfg b/tcl/target/spear3xx.cfg new file mode 100644 index 0000000..ef289e3 --- /dev/null +++ b/tcl/target/spear3xx.cfg @@ -0,0 +1,41 @@ +# Target configuration for the ST SPEAr3xx family of system on chip +# Supported SPEAr300, SPEAr310, SPEAr320 +# http://www.st.com/spear +# +# Processor: ARM926ejs +# Info: JTAG tap: spear3xx.cpu tap/device found: 0x07926041 +# Date: 2009-10-31 +# Author: Antonio Borneo <bor...@gm...> + +if { [info exists CHIPNAME] } { + set _CHIPNAME $CHIPNAME +} else { + set _CHIPNAME spear3xx +} + +if { [info exists ENDIAN] } { + set _ENDIAN $ENDIAN +} else { + set _ENDIAN little +} + +if { [info exists CPUTAPID ] } { + set _CPUTAPID $CPUTAPID +} else { + set _CPUTAPID 0x07926041 +} + +jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x01 -irmask 0x03 \ + -expected-id $_CPUTAPID + +set _TARGETNAME $_CHIPNAME.cpu +target create $_TARGETNAME arm926ejs -endian $_ENDIAN \ + -chain-position $_TARGETNAME + +# SPEAr3xx has a 8K block of sram @ 0xd280.0000 +# REVISIT: what OS puts virtual address equal to phys? +$_TARGETNAME configure \ + -work-area-virt 0xd2800000 \ + -work-area-phys 0xd2800000 \ + -work-area-size 0x2000 \ + -work-area-backup 0 ----------------------------------------------------------------------- Summary of changes: tcl/board/spear310evb20.cfg | 48 ++++++++++++++ tcl/board/spear310evb20_mod.cfg | 25 +++++++ tcl/chip/st/spear/quirk_no_srst.tcl | 75 ++++++++++++++++++++++ tcl/chip/st/spear/spear310.tcl | 40 ++++++++++++ tcl/chip/st/spear/spear3xx.tcl | 79 +++++++++++++++++++++++ tcl/chip/st/spear/spear3xx_ddr.tcl | 120 +++++++++++++++++++++++++++++++++++ tcl/target/spear3xx.cfg | 41 ++++++++++++ 7 files changed, 428 insertions(+), 0 deletions(-) create mode 100644 tcl/board/spear310evb20.cfg create mode 100644 tcl/board/spear310evb20_mod.cfg create mode 100644 tcl/chip/st/spear/quirk_no_srst.tcl create mode 100644 tcl/chip/st/spear/spear310.tcl create mode 100644 tcl/chip/st/spear/spear3xx.tcl create mode 100644 tcl/chip/st/spear/spear3xx_ddr.tcl create mode 100644 tcl/target/spear3xx.cfg hooks/post-receive -- Main OpenOCD repository |
From: Øyvind H. <go...@us...> - 2010-11-06 15:40:31
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 8f1f8e7b96d4dfdca867cfcf69e0efab9f6e3731 (commit) via d5b9c7998c43ee783c224035002cf32f062b0e2b (commit) via 1fa91f336ae35a0b7b127c81c46ff9b5041e088e (commit) via 887cac65b0672910bda4fec34ed05d72ce7208aa (commit) via 0649fb2f6c7e1bea138769ecc2ec8dc17ae98044 (commit) from 9e3d43cfe75df7c4f6797d630576f1a02428b218 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 8f1f8e7b96d4dfdca867cfcf69e0efab9f6e3731 Author: Marek Vasut <mar...@gm...> Date: Fri Oct 29 03:06:16 2010 +0200 Add EfikaMX smarttop board support This patch finally adds support for i.MX51 based Genesi USA EfikaMX smarttop board. Signed-off-by: Marek Vasut <mar...@gm...> diff --git a/tcl/board/efikamx.cfg b/tcl/board/efikamx.cfg new file mode 100644 index 0000000..f8ae25d --- /dev/null +++ b/tcl/board/efikamx.cfg @@ -0,0 +1,9 @@ +# Genesi USA EfikaMX +# http://www.genesi-usa.com/products/efika + +# Fall back to 6MHz if RTCK is not supported +jtag_rclk 6000 + +source [find target/imx51.cfg] + +reset_config trst_only commit d5b9c7998c43ee783c224035002cf32f062b0e2b Author: Marek Vasut <mar...@gm...> Date: Fri Oct 29 02:57:32 2010 +0200 CortexA8: Introduce Freescale i.MX51 variant This patch introduces support for Cortex A8 based Freescale i.MX51 CPU. This CPU has the Debug Access Port located at a different address (0x60008000) than TI OMAP3 series of CPUs. i.MX51 configuration file based on OMAP3 configuration file and an email from Alan Carvalho de Assis <ac...@gm...>. Signed-off-by: Marek Vasut <mar...@gm...> diff --git a/tcl/target/imx51.cfg b/tcl/target/imx51.cfg new file mode 100644 index 0000000..b1390ec --- /dev/null +++ b/tcl/target/imx51.cfg @@ -0,0 +1,51 @@ +# Freescale i.MX51 + +if { [info exists CHIPNAME] } { + set _CHIPNAME $CHIPNAME +} else { + set _CHIPNAME imx51 +} + +# CoreSight Debug Access Port +if { [info exists DAP_TAPID ] } { + set _DAP_TAPID $DAP_TAPID +} else { + set _DAP_TAPID 0x1ba00477 +} + +jtag newtap $_CHIPNAME DAP -irlen 4 -ircapture 0x1 -irmask 0xf \ + -expected-id $_DAP_TAPID + +# SDMA / no IDCODE +jtag newtap $_CHIPNAME SDMA -irlen 4 -ircapture 0x0 -irmask 0xf + +# SJC +if { [info exists SJC_TAPID ] } { + set _SJC_TAPID SJC_TAPID +} else { + set _SJC_TAPID 0x0190c01d +} + +jtag newtap $_CHIPNAME SJC -irlen 5 -ircapture 0x1 -irmask 0x1f \ + -expected-id $_SJC_TAPID -ignore-version + +# GDB target: Cortex-A8, using DAP +set _TARGETNAME $_CHIPNAME.cpu +target create $_TARGETNAME cortex_a8 -chain-position $_CHIPNAME.DAP + +# some TCK tycles are required to activate the DEBUG power domain +jtag configure $_CHIPNAME.SJC -event post-reset "runtest 100" + +# have the DAP "always" be active +jtag configure $_CHIPNAME.SJC -event setup "jtag tapenable $_CHIPNAME.DAP" + +proc imx51_dbginit {target} { + # General Cortex A8 debug initialisation + cortex_a8 dbginit +} + +# Slow speed to be sure it will work +jtag_rclk 1000 +$_TARGETNAME configure -event "reset-start" { jtag_rclk 1000 } + +$_TARGETNAME configure -event reset-assert-post "imx51_dbginit $_TARGETNAME" commit 1fa91f336ae35a0b7b127c81c46ff9b5041e088e Author: Marek Vasut <mar...@gm...> Date: Fri Oct 29 02:57:32 2010 +0200 CortexA8: Implement debug base autodetection Implement autodetection of debug base. Also, implement a function solving various hardware quirks (like iMX51 ROM Table location bug). Signed-off-by: Marek Vasut <mar...@gm...> diff --git a/src/target/cortex_a8.c b/src/target/cortex_a8.c index 8b4ced5..3c80923 100644 --- a/src/target/cortex_a8.c +++ b/src/target/cortex_a8.c @@ -73,7 +73,6 @@ static int cortex_a8_get_ttb(struct target *target, uint32_t *result); */ #define swjdp_memoryap 0 #define swjdp_debugap 1 -#define OMAP3530_DEBUG_BASE 0x54011000 /* * Cortex-A8 Basic debug access, very low level assumes state is saved @@ -1714,12 +1713,7 @@ static int cortex_a8_examine_first(struct target *target) int i; int retval = ERROR_OK; uint32_t didr, ctypr, ttypr, cpuid; - - /* stop assuming this is an OMAP! */ - LOG_DEBUG("TODO - autoconfigure"); - - /* Here we shall insert a proper ROM Table scan */ - armv7a->debug_base = OMAP3530_DEBUG_BASE; + uint32_t dbgbase, apid; /* We do one extra read to ensure DAP is configured, * we call ahbap_debugport_init(swjdp) instead @@ -1728,6 +1722,17 @@ static int cortex_a8_examine_first(struct target *target) if (retval != ERROR_OK) return retval; + /* Get ROM Table base */ + retval = dap_get_debugbase(swjdp, 1, &dbgbase, &apid); + if (retval != ERROR_OK) + return retval; + + /* Lookup 0x15 -- Processor DAP */ + retval = dap_lookup_cs_component(swjdp, 1, dbgbase, 0x15, + &armv7a->debug_base); + if (retval != ERROR_OK) + return retval; + retval = mem_ap_read_atomic_u32(swjdp, armv7a->debug_base + CPUDBG_CPUID, &cpuid); if (retval != ERROR_OK) return retval; commit 887cac65b0672910bda4fec34ed05d72ce7208aa Author: Marek Vasut <mar...@gm...> Date: Sun Oct 31 07:11:47 2010 +0100 ADIv5: Implement function to lookup CoreSight component This patch implements "dap_lookup_cs_component()", which allows to lookup CS component by it's identification. Signed-off-by: Marek Vasut <mar...@gm...> diff --git a/src/target/arm_adi_v5.c b/src/target/arm_adi_v5.c index 4950121..81edba4 100644 --- a/src/target/arm_adi_v5.c +++ b/src/target/arm_adi_v5.c @@ -1062,6 +1062,47 @@ int dap_get_debugbase(struct adiv5_dap *dap, int apsel, return ERROR_OK; } +int dap_lookup_cs_component(struct adiv5_dap *dap, int apsel, + uint32_t dbgbase, uint8_t type, uint32_t *addr) +{ + uint32_t apselold; + uint32_t romentry, entry_offset = 0, component_base, devtype; + int retval = ERROR_FAIL; + + if (apsel >= 256) + return ERROR_INVALID_ARGUMENTS; + + apselold = dap->apsel; + dap_ap_select(dap, apsel); + + do + { + retval = mem_ap_read_atomic_u32(dap, (dbgbase&0xFFFFF000) | + entry_offset, &romentry); + if (retval != ERROR_OK) + return retval; + + component_base = (dbgbase & 0xFFFFF000) + + (romentry & 0xFFFFF000); + + if (romentry & 0x1) { + retval = mem_ap_read_atomic_u32(dap, + (component_base & 0xfffff000) | 0xfcc, + &devtype); + if ((devtype & 0xff) == type) { + *addr = component_base; + retval = ERROR_OK; + break; + } + } + entry_offset += 4; + } while (romentry > 0); + + dap_ap_select(dap, apselold); + + return retval; +} + static int dap_info_command(struct command_context *cmd_ctx, struct adiv5_dap *dap, int apsel) { diff --git a/src/target/arm_adi_v5.h b/src/target/arm_adi_v5.h index 27a2f2f..6c1808a 100644 --- a/src/target/arm_adi_v5.h +++ b/src/target/arm_adi_v5.h @@ -383,6 +383,10 @@ int ahbap_debugport_init(struct adiv5_dap *swjdp); int dap_get_debugbase(struct adiv5_dap *dap, int apsel, uint32_t *dbgbase, uint32_t *apid); +/* Lookup CoreSight component */ +int dap_lookup_cs_component(struct adiv5_dap *dap, int apsel, + uint32_t dbgbase, uint8_t type, uint32_t *addr); + struct target; /* Put debug link into SWD mode */ commit 0649fb2f6c7e1bea138769ecc2ec8dc17ae98044 Author: Marek Vasut <mar...@gm...> Date: Sun Oct 31 05:24:36 2010 +0100 ADIv5: Introduce function to detect ROM Table location This patch adds function called "dap_detect_debug_base()", which should be called to get location of the ROM Table. By walking ROM Table, it's possible to discover the location of DAP. Sadly, some CPUs misreport this value, therefore I had to introduce an fixup table, which will be used in case such CPU is detected. Signed-off-by: Marek Vasut <mar...@gm...> diff --git a/src/target/arm_adi_v5.c b/src/target/arm_adi_v5.c index 3414796..4950121 100644 --- a/src/target/arm_adi_v5.c +++ b/src/target/arm_adi_v5.c @@ -906,7 +906,7 @@ extern const struct dap_ops jtag_dp_ops; */ int ahbap_debugport_init(struct adiv5_dap *dap) { - uint32_t idreg, romaddr, dummy; + uint32_t dummy; uint32_t ctrlstat; int cnt = 0; int retval; @@ -985,26 +985,6 @@ int ahbap_debugport_init(struct adiv5_dap *dap) if (retval != ERROR_OK) return retval; - /* - * REVISIT this isn't actually *initializing* anything in an AP, - * and doesn't care if it's a MEM-AP at all (much less AHB-AP). - * Should it? If the ROM address is valid, is this the right - * place to scan the table and do any topology detection? - */ - retval = dap_queue_ap_read(dap, AP_REG_IDR, &idreg); - if (retval != ERROR_OK) - return retval; - retval = dap_queue_ap_read(dap, AP_REG_BASE, &romaddr); - if (retval != ERROR_OK) - return retval; - - if ((retval = dap_run(dap)) != ERROR_OK) - return retval; - - LOG_DEBUG("MEM-AP #%" PRId32 " ID Register 0x%" PRIx32 - ", Debug ROM Address 0x%" PRIx32, - dap->apsel, idreg, romaddr); - return ERROR_OK; } @@ -1026,14 +1006,22 @@ is_dap_cid_ok(uint32_t cid3, uint32_t cid2, uint32_t cid1, uint32_t cid0) && ((cid1 & 0x0f) == 0) && cid0 == 0x0d; } -static int dap_info_command(struct command_context *cmd_ctx, - struct adiv5_dap *dap, int apsel) +struct broken_cpu { + uint32_t dbgbase; + uint32_t apid; + uint32_t correct_dbgbase; + char *model; +} broken_cpus[] = { + { 0x80000000, 0x04770002, 0x60000000, "imx51" }, +}; + +int dap_get_debugbase(struct adiv5_dap *dap, int apsel, + uint32_t *out_dbgbase, uint32_t *out_apid) { + uint32_t apselold; int retval; + unsigned int i; uint32_t dbgbase, apid; - int romtable_present = 0; - uint8_t mem_ap; - uint32_t apselold; /* AP address is in bits 31:24 of DP_SELECT */ if (apsel >= 256) @@ -1041,6 +1029,7 @@ static int dap_info_command(struct command_context *cmd_ctx, apselold = dap->apsel; dap_ap_select(dap, apsel); + retval = dap_queue_ap_read(dap, AP_REG_BASE, &dbgbase); if (retval != ERROR_OK) return retval; @@ -1051,6 +1040,44 @@ static int dap_info_command(struct command_context *cmd_ctx, if (retval != ERROR_OK) return retval; + /* Some CPUs are messed up, so fixup if needed. */ + for (i = 0; i < sizeof(broken_cpus)/sizeof(struct broken_cpu); i++) + if (broken_cpus[i].dbgbase == dbgbase && + broken_cpus[i].apid == apid) { + LOG_WARNING("Found broken CPU (%s), trying to fixup " + "ROM Table location from 0x%08x to 0x%08x", + broken_cpus[i].model, dbgbase, + broken_cpus[i].correct_dbgbase); + dbgbase = broken_cpus[i].correct_dbgbase; + break; + } + + dap_ap_select(dap, apselold); + + /* The asignment happens only here to prevent modification of these + * values before they are certain. */ + *out_dbgbase = dbgbase; + *out_apid = apid; + + return ERROR_OK; +} + +static int dap_info_command(struct command_context *cmd_ctx, + struct adiv5_dap *dap, int apsel) +{ + int retval; + uint32_t dbgbase, apid; + int romtable_present = 0; + uint8_t mem_ap; + uint32_t apselold; + + retval = dap_get_debugbase(dap, apsel, &dbgbase, &apid); + if (retval != ERROR_OK) + return retval; + + apselold = dap->apsel; + dap_ap_select(dap, apsel); + /* Now we read ROM table ID registers, ref. ARM IHI 0029B sec */ mem_ap = ((apid&0x10000) && ((apid&0x0F) != 0)); command_print(cmd_ctx, "AP ID register 0x%8.8" PRIx32, apid); diff --git a/src/target/arm_adi_v5.h b/src/target/arm_adi_v5.h index 92469eb..27a2f2f 100644 --- a/src/target/arm_adi_v5.h +++ b/src/target/arm_adi_v5.h @@ -178,7 +178,6 @@ struct adiv5_dap uint32_t memaccess_tck; /* Size of TAR autoincrement block, ARM ADI Specification requires at least 10 bits */ uint32_t tar_autoincr_block; - }; /** @@ -380,6 +379,9 @@ int mem_ap_write_buf_u32(struct adiv5_dap *swjdp, /* Initialisation of the debug system, power domains and registers */ int ahbap_debugport_init(struct adiv5_dap *swjdp); +/* Probe the AP for ROM Table location */ +int dap_get_debugbase(struct adiv5_dap *dap, int apsel, + uint32_t *dbgbase, uint32_t *apid); struct target; ----------------------------------------------------------------------- Summary of changes: src/target/arm_adi_v5.c | 120 ++++++++++++++++++++++++++++++++++++---------- src/target/arm_adi_v5.h | 8 +++- src/target/cortex_a8.c | 19 +++++--- tcl/board/efikamx.cfg | 9 ++++ tcl/target/imx51.cfg | 51 ++++++++++++++++++++ 5 files changed, 173 insertions(+), 34 deletions(-) create mode 100644 tcl/board/efikamx.cfg create mode 100644 tcl/target/imx51.cfg hooks/post-receive -- Main OpenOCD repository |
From: Øyvind H. <go...@us...> - 2010-11-04 14:54:51
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 9e3d43cfe75df7c4f6797d630576f1a02428b218 (commit) from 70b15389962637f13f5f3f10a6beebabed419c69 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 9e3d43cfe75df7c4f6797d630576f1a02428b218 Author: ddraskovic <ddr...@se...> Date: Thu Nov 4 14:33:10 2010 +0100 arm964e: Add support for ARM946E target. So far most of the people have been using existing ARM966E in the place of ARM946E, because they have practically the same scan chains. However, ARM946E has caches, which further complicates JATG handling via scan-chain. this was preventing single-stepping for ARM946E when SW breakpoints are used. This patch thus introduces : 1) Correct cache handling on memory write 2) Possibility to flush whole cache and turn it off during debug, or just to flush affected lines (faster and better) 3) Correct SW breakpoint handling and correct single-stepping 4) Corrects the bug on CP15 read and write, so CP15 values are now correctly R/W diff --git a/src/target/Makefile.am b/src/target/Makefile.am index e01e077..1e29ae7 100644 --- a/src/target/Makefile.am +++ b/src/target/Makefile.am @@ -60,6 +60,7 @@ ARM7_9_SRC = \ arm9tdmi.c \ arm920t.c \ arm966e.c \ + arm946e.c \ arm926ejs.c \ feroceon.c @@ -124,6 +125,7 @@ noinst_HEADERS = \ arm920t.h \ arm926ejs.h \ arm966e.h \ + arm946e.h \ arm11.h \ arm11_dbgtap.h \ armv4_5.h \ diff --git a/src/target/arm946e.c b/src/target/arm946e.c new file mode 100644 index 0000000..b9b9cef --- /dev/null +++ b/src/target/arm946e.c @@ -0,0 +1,712 @@ +/*************************************************************************** + * Copyright (C) 2005 by Dominic Rath * + * Dom...@gm... * + * * + * Copyright (C) 2008 by Spencer Oliver * + * sp...@sp... * + * * + * Copyright (C) 2010 by Drasko DRASKOVIC * + * dra...@gm... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "arm946e.h" +#include "target_type.h" +#include "arm_opcodes.h" + +#include "breakpoints.h" + +#if 0 +#define _DEBUG_INSTRUCTION_EXECUTION_ +#endif + +#define NB_CACHE_WAYS 4 + +static uint32_t dc = 0x0; +static uint32_t ic = 0x0; + +/** + * flag to give info about cache manipulation during debug : + * "0" - cache lines are invalidated "on the fly", for affected addresses. + * This is prefered from performance point of view. + * "1" - cache is invalidated and switched off on debug_entry, and switched back on on restore. + * It is kept off during debugging. + */ +static uint8_t arm946e_preserve_cache; + +int arm946e_post_debug_entry(struct target *target); +void arm946e_pre_restore_context(struct target *target); +static int arm946e_read_cp15(struct target *target, int reg_addr, uint32_t *value); + + +int arm946e_init_arch_info(struct target *target, struct arm946e_common *arm946e, struct jtag_tap *tap) +{ + struct arm7_9_common *arm7_9 = &arm946e->arm7_9_common; + + /* initialize arm7/arm9 specific info (including armv4_5) */ + arm9tdmi_init_arch_info(target, arm7_9, tap); + + arm946e->common_magic = ARM946E_COMMON_MAGIC; + + /** + * The ARM946E-S implements the ARMv5TE architecture which + * has the BKPT instruction, so we don't have to use a watchpoint comparator + */ + arm7_9->arm_bkpt = ARMV5_BKPT(0x0); + arm7_9->thumb_bkpt = ARMV5_T_BKPT(0x0) & 0xffff; + + + arm7_9->post_debug_entry = arm946e_post_debug_entry; + arm7_9->pre_restore_context = arm946e_pre_restore_context; + + /** + * disabling linefills leads to lockups, so keep them enabled for now + * this doesn't affect correctness, but might affect timing issues, if + * important data is evicted from the cache during the debug session + */ + arm946e_preserve_cache = 0; + + /* override hw single-step capability from ARM9TDMI */ + //arm7_9->has_single_step = 1; + + return ERROR_OK; +} + +static int arm946e_target_create(struct target *target, Jim_Interp *interp) +{ + struct arm946e_common *arm946e = calloc(1,sizeof(struct arm946e_common)); + + arm946e_init_arch_info(target, arm946e, target->tap); + + return ERROR_OK; +} + +static int arm946e_verify_pointer(struct command_context *cmd_ctx, + struct arm946e_common *arm946e) +{ + if (arm946e->common_magic != ARM946E_COMMON_MAGIC) { + command_print(cmd_ctx, "target is not an ARM946"); + return ERROR_TARGET_INVALID; + } + return ERROR_OK; +} + +/* + * REVISIT: The "read_cp15" and "write_cp15" commands could hook up + * to eventual mrc() and mcr() routines ... the reg_addr values being + * constructed (for CP15 only) from Opcode_1, Opcode_2, and CRn values. + * See section 7.3 of the ARM946E-S TRM. + */ +static int arm946e_read_cp15(struct target *target, int reg_addr, uint32_t *value) +{ + int retval = ERROR_OK; + struct arm7_9_common *arm7_9 = target_to_arm7_9(target); + struct arm_jtag *jtag_info = &arm7_9->jtag_info; + struct scan_field fields[3]; + uint8_t reg_addr_buf = reg_addr & 0x3f; + uint8_t nr_w_buf = 0; + + if ((retval = arm_jtag_scann(jtag_info, 0xf, TAP_IDLE)) != ERROR_OK) + { + return retval; + } + retval = arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL, TAP_IDLE); + if (retval != ERROR_OK) + return retval; + + fields[0].num_bits = 32; + /* REVISIT: table 7-2 shows that bits 31-31 need to be + * specified for accessing BIST registers ... + */ + fields[0].out_value = NULL; + fields[0].in_value = NULL; + + fields[1].num_bits = 6; + fields[1].out_value = ®_addr_buf; + fields[1].in_value = NULL; + + fields[2].num_bits = 1; + fields[2].out_value = &nr_w_buf; + fields[2].in_value = NULL; + + jtag_add_dr_scan(jtag_info->tap, 3, fields, TAP_IDLE); + + fields[0].in_value = (uint8_t *)value; + jtag_add_dr_scan(jtag_info->tap, 3, fields, TAP_IDLE); + + jtag_add_callback(arm_le_to_h_u32, (jtag_callback_data_t)value); + +#ifdef _DEBUG_INSTRUCTION_EXECUTION_ + LOG_DEBUG("addr: 0x%x value: %8.8x", reg_addr, *value); +#endif + + if ((retval = jtag_execute_queue()) != ERROR_OK) + { + return retval; + } + + return ERROR_OK; +} + +int arm946e_write_cp15(struct target *target, int reg_addr, uint32_t value) +{ + int retval = ERROR_OK; + struct arm7_9_common *arm7_9 = target_to_arm7_9(target); + struct arm_jtag *jtag_info = &arm7_9->jtag_info; + struct scan_field fields[3]; + uint8_t reg_addr_buf = reg_addr & 0x3f; + uint8_t nr_w_buf = 1; + uint8_t value_buf[4]; + + buf_set_u32(value_buf, 0, 32, value); + + if ((retval = arm_jtag_scann(jtag_info, 0xf, TAP_IDLE)) != ERROR_OK) + { + return retval; + } + retval = arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL, TAP_IDLE); + if (retval != ERROR_OK) + return retval; + + fields[0].num_bits = 32; + fields[0].out_value = value_buf; + fields[0].in_value = NULL; + + fields[1].num_bits = 6; + fields[1].out_value = ®_addr_buf; + fields[1].in_value = NULL; + + fields[2].num_bits = 1; + fields[2].out_value = &nr_w_buf; + fields[2].in_value = NULL; + + jtag_add_dr_scan(jtag_info->tap, 3, fields, TAP_IDLE); + +#ifdef _DEBUG_INSTRUCTION_EXECUTION_ + LOG_DEBUG("addr: 0x%x value: %8.8x", reg_addr, value); +#endif + + if ((retval = jtag_execute_queue()) != ERROR_OK) + { + return retval; + } + + return ERROR_OK; +} + +uint32_t arm946e_invalidate_whole_dcache(struct target *target) +{ + + uint32_t csize = 0; + uint32_t shift = 0; + uint32_t cp15_idx, seg, dtag; + int nb_idx, idx = 0; + int retval; + + /* Get cache type */ + arm946e_read_cp15(target, 0x01, (uint32_t *) &csize); + + csize = (csize >> 18) & 0x0F; + + if (csize == 0) + shift = 0; + else + shift = csize - 0x3; /* Now 0 = 4KB, 1 = 8KB, ... */ + + /* Cache size, given in bytes */ + csize = 1 << (12 + shift); + /* One line (index) is 32 bytes (8 words) long */ + nb_idx = (csize / 32); /* gives nb of lines (indexes) in the cache */ + + /* Loop for all segmentde (i.e. ways) */ + for( seg=0; seg < NB_CACHE_WAYS; seg++) + { + /* Loop for all indexes */ + for(idx=0; idx < nb_idx; idx++) + { + /* Form and write cp15 index (segment + line idx) */ + cp15_idx = seg << 30 | idx << 5; + retval = arm946e_write_cp15(target, 0x3a, cp15_idx); + if (retval != ERROR_OK) + { + LOG_DEBUG("ERROR writing index\n"); + return retval; + } + + /* Read dtag */ + arm946e_read_cp15(target, 0x16, (uint32_t *) &dtag); + + /* Check cache line VALID bit */ + if ( !(dtag >> 4 & 0x1) ) + continue; + + /* Clean data cache line */ + retval = arm946e_write_cp15(target, 0x35, 0x1); + if (retval != ERROR_OK) + { + LOG_DEBUG("ERROR cleaning cache line\n"); + return retval; + } + + /* Flush data cache line */ + retval = arm946e_write_cp15(target, 0x1a, 0x1); + if (retval != ERROR_OK) + { + LOG_DEBUG("ERROR flushing cache line\n"); + return retval; + } + } + } + + return ERROR_OK; +} + +uint32_t arm946e_invalidate_whole_icache(struct target *target) +{ + int retval; + + LOG_DEBUG("FLUSHING I$"); + + /** + * Invalidate (flush) I$ + * mcr 15, 0, r0, cr7, cr5, {0} + */ + retval = arm946e_write_cp15(target, 0x0f, 0x1); + if (retval != ERROR_OK) + { + LOG_DEBUG("ERROR flushing I$\n"); + return retval; + } + + return ERROR_OK; +} + +int arm946e_post_debug_entry(struct target *target) +{ + uint32_t ctr_reg = 0x0; + uint32_t retval = ERROR_OK; + + /* See if CACHES are enabled, and save that info + * in the global vars, so that arm946e_pre_restore_context() can use them */ + arm946e_read_cp15(target, 0x02, (uint32_t *) &ctr_reg); + dc = (ctr_reg >> 2) & 0x01; + ic = (ctr_reg >> 12) & 0x01; + + if (arm946e_preserve_cache) + { + if (dc == 1) + { + /* Clean and flush D$ */ + arm946e_invalidate_whole_dcache(target); + + /* Disable D$ */ + ctr_reg &= ~(1 << 2); + } + + if (ic == 1) + { + /* Flush I$ */ + arm946e_invalidate_whole_icache(target); + + /* Disable I$ */ + ctr_reg &= ~(1 << 12); + } + + /* Write the new configuration */ + retval = arm946e_write_cp15(target, 0x02, ctr_reg); + if (retval != ERROR_OK) + { + LOG_DEBUG("ERROR disabling cache"); + return retval; + } + } /* if preserve_cache */ + + return ERROR_OK; +} + +void arm946e_pre_restore_context(struct target *target) +{ + uint32_t ctr_reg = 0x0; + uint32_t retval; + + if (arm946e_preserve_cache) + { + /* Get the contents of the CTR reg */ + arm946e_read_cp15(target, 0x02, (uint32_t *) &ctr_reg); + + /** + * Read-modify-write CP15 test state register + * to reenable I/D-cache linefills + */ + if (dc == 1) + { + /* Enable D$ */ + ctr_reg |= 1 << 2; + } + + if (ic == 1) + { + /* Enable I$ */ + ctr_reg |= 1 << 12; + } + + /* Write the new configuration */ + retval = arm946e_write_cp15(target, 0x02, ctr_reg); + if (retval != ERROR_OK) + { + LOG_DEBUG("ERROR enabling cache\n"); + } + } /* if preserve_cache */ +} + +uint32_t arm946e_invalidate_dcache(struct target *target, uint32_t address, + uint32_t size, uint32_t count) +{ + uint32_t csize = 0x0; + uint32_t shift = 0; + uint32_t cur_addr = 0x0; + uint32_t cp15_idx, set, way, dtag; + int nb_idx; + uint32_t i = 0; + int retval; + + for(i = 0; i < count*size; i++) + { + cur_addr = address + i; + + /* Get cache type */ + arm946e_read_cp15(target, 0x01, (uint32_t *) &csize); + + /* Conclude cache size to find number of lines */ + csize = (csize >> 18) & 0x0F; + + if (csize == 0) + shift = 0; + else + shift = csize - 0x3; /* Now 0 = 4KB, 1 = 8KB, ... */ + + csize = 1 << (12 + shift); + nb_idx = (csize / 32); + + set = (cur_addr >> 5) & 0xff; /* set field is 8 bits long */ + + for (way = 0; way < NB_CACHE_WAYS; way++) + { + /** + * Find if the affected address is kept in the cache. + * Because JTAG Scan Chain 15 offers limited approach, + * we have to loop through all cache ways (segments) and + * read cache tags, then compare them with with address. + */ + + /* Form and write cp15 index (segment + line idx) */ + cp15_idx = way << 30 | set << 5; + retval = arm946e_write_cp15(target, 0x3a, cp15_idx); + if (retval != ERROR_OK) + { + LOG_DEBUG("ERROR writing index\n"); + return retval; + } + + /* Read dtag */ + arm946e_read_cp15(target, 0x16, (uint32_t *) &dtag); + + /* Check cache line VALID bit */ + if ( !(dtag >> 4 & 0x1) ) + continue; + + /* If line is valid and corresponds to affected address - invalidate it */ + if (dtag >> 5 == cur_addr >> 5) + { + /* Clean data cache line */ + retval = arm946e_write_cp15(target, 0x35, 0x1); + if (retval != ERROR_OK) + { + LOG_DEBUG("ERROR cleaning cache line\n"); + return retval; + } + + /* Flush data cache line */ + retval = arm946e_write_cp15(target, 0x1c, 0x1); + if (retval != ERROR_OK) + { + LOG_DEBUG("ERROR flushing cache line\n"); + return retval; + } + + break; + } + } /* loop through all 4 ways */ + } /* loop through all addresses */ + + return ERROR_OK; +} + +uint32_t arm946e_invalidate_icache(struct target *target, uint32_t address, + uint32_t size, uint32_t count) +{ + uint32_t cur_addr = 0x0; + uint32_t cp15_idx, set, way, itag; + uint32_t i = 0; + int retval; + + for(i = 0; i < count*size; i++) + { + cur_addr = address + i; + + set = (cur_addr >> 5) & 0xff; /* set field is 8 bits long */ + + for (way = 0; way < NB_CACHE_WAYS; way++) + { + /* Form and write cp15 index (segment + line idx) */ + cp15_idx = way << 30 | set << 5; + retval = arm946e_write_cp15(target, 0x3a, cp15_idx); + if (retval != ERROR_OK) + { + LOG_DEBUG("ERROR writing index\n"); + return retval; + } + + /* Read itag */ + arm946e_read_cp15(target, 0x17, (uint32_t *) &itag); + + /* Check cache line VALID bit */ + if ( !(itag >> 4 & 0x1) ) + continue; + + /* If line is valid and corresponds to affected address - invalidate it */ + if (itag >> 5 == cur_addr >> 5) + { + /* Flush I$ line */ + retval = arm946e_write_cp15(target, 0x1d, 0x0); + if (retval != ERROR_OK) + { + LOG_DEBUG("ERROR flushing cache line\n"); + return retval; + } + + break; + } + } /* way loop */ + } /* addr loop */ + + return ERROR_OK; +} + +/** Writes a buffer, in the specified word size, with current MMU settings. */ +int arm946e_write_memory(struct target *target, uint32_t address, + uint32_t size, uint32_t count, uint8_t *buffer) +{ + int retval; + + LOG_DEBUG("-"); + + /* Invalidate D$ if it is ON */ + if (!arm946e_preserve_cache && dc == 1) + { + arm946e_invalidate_dcache(target, address, size, count); + } + + /** + * Write memory + */ + if ( ( retval = arm7_9_write_memory(target, address, + size, count, buffer) ) != ERROR_OK ) + { + return retval; + } + + /* * + * Invalidate I$ if it is ON. + * + * D$ has been cleaned and flushed before mem write thus forcing it to behave like write-through, + * because arm7_9_write_memory() has seen non-valid bit in D$ + * and wrote data into physical RAM (without touching or allocating the cache line). + * From ARM946ES Technical Reference Manual we can see that it uses "allocate on read-miss" + * policy for both I$ and D$ (Chapter 3.2 and 3.3) + * + * Explanation : + * "ARM system developer's guide: designing and optimizing system software" by + * Andrew N. Sloss, Dominic Symes and Chris Wright, + * Chapter 12.3.3 Allocating Policy on a Cache Miss : + * A read allocate on cache miss policy allocates a cache line only during a read from main memory. + * If the victim cache line contains valid data, then it is written to main memory before the cache line + * is filled with new data. + * Under this strategy, a write of new data to memory does not update the contents of the cache memory + * unless a cache line was allocated on a previous read from main memory. + * If the cache line contains valid data, then the write updates the cache and may update the main memory if + * the cache write policy is write-through. + * If the data is not in the cache, the controller writes to main memory only. + */ + if (!arm946e_preserve_cache && ic == 1) + { + arm946e_invalidate_icache(target, address, size, count); + } + + return ERROR_OK; + +} + +int arm946e_read_memory(struct target *target, uint32_t address, + uint32_t size, uint32_t count, uint8_t *buffer) +{ + int retval; + + LOG_DEBUG("-"); + + if ( ( retval = arm7_9_read_memory(target, address, + size, count, buffer) ) != ERROR_OK ) + { + return retval; + } + + return ERROR_OK; +} + + +COMMAND_HANDLER(arm946e_handle_cp15_command) +{ + int retval; + struct target *target = get_current_target(CMD_CTX); + struct arm946e_common *arm946e = target_to_arm946(target); + + retval = arm946e_verify_pointer(CMD_CTX, arm946e); + if (retval != ERROR_OK) + return retval; + + if (target->state != TARGET_HALTED) + { + command_print(CMD_CTX, "target must be stopped for \"%s\" command", CMD_NAME); + return ERROR_OK; + } + + /* one or more argument, access a single register (write if second argument is given */ + if (CMD_ARGC >= 1) + { + uint32_t address; + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], address); + + if (CMD_ARGC == 1) + { + uint32_t value; + if ((retval = arm946e_read_cp15(target, address, &value)) != ERROR_OK) + { + command_print(CMD_CTX, + "couldn't access reg %" PRIi32, + address); + return ERROR_OK; + } + if ((retval = jtag_execute_queue()) != ERROR_OK) + { + return retval; + } + + command_print(CMD_CTX, "%" PRIi32 ": %8.8" PRIx32, + address, value); + } + else if (CMD_ARGC == 2) + { + uint32_t value; + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], value); + if ((retval = arm946e_write_cp15(target, address, value)) != ERROR_OK) + { + command_print(CMD_CTX, + "couldn't access reg %" PRIi32, + address); + return ERROR_OK; + } + command_print(CMD_CTX, "%" PRIi32 ": %8.8" PRIx32, + address, value); + } + } + + return ERROR_OK; +} + +static const struct command_registration arm946e_exec_command_handlers[] = { + { + .name = "cp15", + .handler = arm946e_handle_cp15_command, + .mode = COMMAND_EXEC, + .usage = "regnum [value]", + .help = "display/modify cp15 register", + }, + COMMAND_REGISTRATION_DONE +}; + +const struct command_registration arm946e_command_handlers[] = { + { + .chain = arm9tdmi_command_handlers, + }, + { + .name = "arm946e", + .mode = COMMAND_ANY, + .help = "arm946e command group", + .chain = arm946e_exec_command_handlers, + }, + COMMAND_REGISTRATION_DONE +}; + +/** Holds methods for ARM946 targets. */ +struct target_type arm946e_target = +{ + .name = "arm946e", + + .poll = arm7_9_poll, + .arch_state = arm_arch_state, + + .target_request_data = arm7_9_target_request_data, + + .halt = arm7_9_halt, + .resume = arm7_9_resume, + .step = arm7_9_step, + + .assert_reset = arm7_9_assert_reset, + .deassert_reset = arm7_9_deassert_reset, + .soft_reset_halt = arm7_9_soft_reset_halt, + + .get_gdb_reg_list = arm_get_gdb_reg_list, + + //.read_memory = arm7_9_read_memory, + //.write_memory = arm7_9_write_memory, + .read_memory = arm946e_read_memory, + .write_memory = arm946e_write_memory, + + .bulk_write_memory = arm7_9_bulk_write_memory, + + .checksum_memory = arm_checksum_memory, + .blank_check_memory = arm_blank_check_memory, + + .run_algorithm = armv4_5_run_algorithm, + + .add_breakpoint = arm7_9_add_breakpoint, + .remove_breakpoint = arm7_9_remove_breakpoint, + //.add_breakpoint = arm946e_add_breakpoint, + //.remove_breakpoint = arm946e_remove_breakpoint, + + .add_watchpoint = arm7_9_add_watchpoint, + .remove_watchpoint = arm7_9_remove_watchpoint, + + .commands = arm946e_command_handlers, + .target_create = arm946e_target_create, + .init_target = arm9tdmi_init_target, + .examine = arm7_9_examine, + .check_reset = arm7_9_check_reset, +}; diff --git a/src/target/arm946e.h b/src/target/arm946e.h new file mode 100644 index 0000000..557674e --- /dev/null +++ b/src/target/arm946e.h @@ -0,0 +1,53 @@ +/*************************************************************************** + * Copyright (C) 2005 by Dominic Rath * + * Dom...@gm... * + * * + * Copyright (C) 2008 by Spencer Oliver * + * sp...@sp... * + * * + * Copyright (C) 2010 by Drasko DRASKOVIC * + * dra...@gm... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef ARM946E_H +#define ARM946E_H + +#include "arm9tdmi.h" + +#define ARM946E_COMMON_MAGIC 0x20f920f9 + +struct arm946e_common +{ + struct arm7_9_common arm7_9_common; + int common_magic; + uint32_t cp15_control_reg; +}; + +static inline struct arm946e_common * +target_to_arm946(struct target *target) +{ + return container_of(target->arch_info, struct arm946e_common, + arm7_9_common.armv4_5_common); +} + +int arm946e_init_arch_info(struct target *target, + struct arm946e_common *arm946e, struct jtag_tap *tap); +int arm946e_write_cp15(struct target *target, int reg_addr, uint32_t value); + +extern const struct command_registration arm946e_command_handlers[]; + +#endif /* ARM946E_H */ diff --git a/src/target/target.c b/src/target/target.c index d200ebc..a282aab 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -58,6 +58,7 @@ extern struct target_type arm720t_target; extern struct target_type arm9tdmi_target; extern struct target_type arm920t_target; extern struct target_type arm966e_target; +extern struct target_type arm946e_target; extern struct target_type arm926ejs_target; extern struct target_type fa526_target; extern struct target_type feroceon_target; @@ -79,6 +80,7 @@ static struct target_type *target_types[] = &arm920t_target, &arm720t_target, &arm966e_target, + &arm946e_target, &arm926ejs_target, &fa526_target, &feroceon_target, ----------------------------------------------------------------------- Summary of changes: src/target/Makefile.am | 2 + src/target/arm946e.c | 712 +++++++++++++++++++++++++++++++++++ src/target/{arm966e.h => arm946e.h} | 27 +- src/target/target.c | 2 + 4 files changed, 731 insertions(+), 12 deletions(-) create mode 100644 src/target/arm946e.c copy src/target/{arm966e.h => arm946e.h} (71%) hooks/post-receive -- Main OpenOCD repository |
From: Øyvind H. <go...@us...> - 2010-10-31 13:48:31
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 70b15389962637f13f5f3f10a6beebabed419c69 (commit) via d8464623bd1c9789c593c2c0655909d4862d017d (commit) via 559d08c19ed838f7bb2a77ce56a5a274641111f8 (commit) from 4617cd0f911d64a460d99d25c531ddc55f2452ca (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 70b15389962637f13f5f3f10a6beebabed419c69 Author: Ãyvind Harboe <oyv...@zy...> Date: Fri Oct 29 15:05:15 2010 +0200 bootstrap: add quick start build instructions leave some bread-crumbs for users to figure out how to build OpenOCD Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/bootstrap b/bootstrap index 9094a27..81c9804 100755 --- a/bootstrap +++ b/bootstrap @@ -26,4 +26,16 @@ automake --gnu --add-missing --copy # AM_MAINTAINER_MODE requires --enable-maintainer-mode from everyone using # current source snapshots (working from GIT, or some source snapshot, etc) # otherwise the documentation will fail to build due to missing version.texi -echo "Bootstrap complete; you can './configure --enable-maintainer-mode ....'" +echo "Bootstrap complete. Quick start build instructions:" +echo "" +echo "1. Build Jim Tcl" +echo "" +echo "git submodule init" +echo "git submodule update" +echo "cd jimtcl" +echo "./configure --with-jim-ext=nvp" +echo "make" +echo "make install" +echo "" +echo "2. Configure" +echo "./configure --enable-maintainer-mode ...." commit d8464623bd1c9789c593c2c0655909d4862d017d Author: Ãyvind Harboe <oyv...@zy...> Date: Fri Oct 15 09:51:08 2010 +0200 jimtcl: 0.63 release as a git module. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/.gitmodules b/.gitmodules index 2fcecfd..0b6ed6f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "tools/git2cl"] path = tools/git2cl url = git://repo.or.cz/git2cl.git +[submodule "jimtcl"] + path = jimtcl + url = http://repo.or.cz/r/jimtcl.git diff --git a/jimtcl b/jimtcl new file mode 160000 index 0000000..fbbc8e0 --- /dev/null +++ b/jimtcl @@ -0,0 +1 @@ +Subproject commit fbbc8e0b402adb4b0c8d3976015fe4a82c94560f commit 559d08c19ed838f7bb2a77ce56a5a274641111f8 Author: Ãyvind Harboe <oyv...@zy...> Date: Sun Oct 10 19:17:03 2010 +0200 jim tests: use installed Delete obsolete jim that comes with OpenOCD. diff --git a/src/Makefile.am b/src/Makefile.am index a2f8d77..b54161c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -18,7 +18,7 @@ MAINFILE = main.c endif openocd_SOURCES = $(MAINFILE) -openocd_LDADD = libopenocd.la +openocd_LDADD = libopenocd.la -ljim libopenocd_la_SOURCES = \ hello.c \ diff --git a/src/ecosboard.c b/src/ecosboard.c index 26313b4..0805e6f 100644 --- a/src/ecosboard.c +++ b/src/ecosboard.c @@ -500,6 +500,10 @@ static void zylinjtag_startNetwork(void) cyg_httpd_init_tcl_interpreter(); + // Kludge! Why can't I do this from httpd.c??? I get linker errors... + // some of that --start/end-group stuff? + Jim_InitStaticExtensions(httpstate.jim_interp); + Jim_CreateCommand(httpstate.jim_interp, "log", zylinjtag_Jim_Command_log, NULL, NULL); Jim_CreateCommand(httpstate.jim_interp, "zy1000_reboot", diff --git a/src/helper/Makefile.am b/src/helper/Makefile.am index cca5ac3..c721881 100644 --- a/src/helper/Makefile.am +++ b/src/helper/Makefile.am @@ -9,7 +9,7 @@ noinst_LTLIBRARIES = libhelper.la if ECOSBOARD CONFIGFILES = time_support_ecos.c else -CONFIGFILES = options.c jim.c jim-eventloop.c time_support_common.c +CONFIGFILES = options.c time_support_common.c endif @@ -48,8 +48,6 @@ noinst_HEADERS = \ time_support.h \ replacements.h \ fileio.h \ - jim.h \ - jim-eventloop.h \ system.h \ bin2char.c diff --git a/src/helper/command.c b/src/helper/command.c index 6762ad4..5a68208 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -684,7 +684,8 @@ int command_run_line(struct command_context *context, char *line) if (retval != ERROR_COMMAND_CLOSE_CONNECTION) { /* We do not print the connection closed error message */ - Jim_PrintErrorMessage(interp); + Jim_MakeErrorMessage(interp); + LOG_USER_N("%s\n", Jim_GetString(Jim_GetResult(interp), NULL)); } if (retval == ERROR_OK) { @@ -785,89 +786,6 @@ static int jim_echo(Jim_Interp *interp, int argc, Jim_Obj *const *argv) return JIM_OK; } -static size_t openocd_jim_fwrite(const void *_ptr, size_t size, size_t n, void *cookie) -{ - size_t nbytes; - const char *ptr; - Jim_Interp *interp; - - /* make it a char easier to read code */ - ptr = _ptr; - interp = cookie; - nbytes = size * n; - if (ptr == NULL || interp == NULL || nbytes == 0) { - return 0; - } - - /* do we have to chunk it? */ - if (ptr[nbytes] == 0) - { - /* no it is a C style string */ - LOG_USER_N("%s", ptr); - return strlen(ptr); - } - /* GRR we must chunk - not null terminated */ - while (nbytes) { - char chunk[128 + 1]; - int x; - - x = nbytes; - if (x > 128) { - x = 128; - } - /* copy it */ - memcpy(chunk, ptr, x); - /* terminate it */ - chunk[n] = 0; - /* output it */ - LOG_USER_N("%s", chunk); - ptr += x; - nbytes -= x; - } - - return n; -} - -static size_t openocd_jim_fread(void *ptr, size_t size, size_t n, void *cookie) -{ - /* TCL wants to read... tell him no */ - return 0; -} - -static int openocd_jim_vfprintf(void *cookie, const char *fmt, va_list ap) -{ - char *cp; - int n; - Jim_Interp *interp; - - n = -1; - interp = cookie; - if (interp == NULL) - return n; - - cp = alloc_vprintf(fmt, ap); - if (cp) - { - LOG_USER_N("%s", cp); - n = strlen(cp); - free(cp); - } - return n; -} - -static int openocd_jim_fflush(void *cookie) -{ - /* nothing to flush */ - return 0; -} - -static char* openocd_jim_fgets(char *s, int size, void *cookie) -{ - /* not supported */ - errno = ENOTSUP; - return NULL; -} - /* Capture progress output and return as tcl return value. If the * progress output was empty, return tcl return value. */ @@ -1400,11 +1318,11 @@ struct command_context* command_init(const char *startup_tcl, Jim_Interp *interp /* Create a jim interpreter if we were not handed one */ if (interp == NULL) { - Jim_InitEmbedded(); /* Create an interpreter */ interp = Jim_CreateInterp(); /* Add all the Jim core commands */ Jim_RegisterCoreCommands(interp); + Jim_InitStaticExtensions(interp); } #endif context->interp = interp; @@ -1442,26 +1360,14 @@ struct command_context* command_init(const char *startup_tcl, Jim_Interp *interp Jim_CreateCommand(interp, "echo", jim_echo, NULL, NULL); Jim_CreateCommand(interp, "capture", jim_capture, NULL, NULL); - /* Set Jim's STDIO */ - interp->cookie_stdin = interp; - interp->cookie_stdout = interp; - interp->cookie_stderr = interp; - interp->cb_fwrite = openocd_jim_fwrite; - interp->cb_fread = openocd_jim_fread ; - interp->cb_vfprintf = openocd_jim_vfprintf; - interp->cb_fflush = openocd_jim_fflush; - interp->cb_fgets = openocd_jim_fgets; - register_commands(context, NULL, command_builtin_handlers); -#if !BUILD_ECOSBOARD - Jim_EventLoopOnLoad(interp); -#endif Jim_SetAssocData(interp, "context", NULL, context); if (Jim_Eval_Named(interp, startup_tcl, "embedded:startup.tcl",1) == JIM_ERR) { LOG_ERROR("Failed to run startup.tcl (embedded into OpenOCD)"); - Jim_PrintErrorMessage(interp); + Jim_MakeErrorMessage(interp); + LOG_USER_N("%s", Jim_GetString(Jim_GetResult(interp), NULL)); exit(-1); } Jim_DeleteAssocData(interp, "context"); diff --git a/src/helper/command.h b/src/helper/command.h index 1bf2cb4..0ee66b0 100644 --- a/src/helper/command.h +++ b/src/helper/command.h @@ -29,12 +29,11 @@ #if BUILD_ECOSBOARD #include <stdio.h> #include <stdarg.h> -/* Jim is provied by eCos */ -#include <cyg/jimtcl/jim.h> -#else -#include <helper/jim.h> #endif +#include <jim.h> +#include <jim-nvp.h> + /* To achieve C99 printf compatibility in MinGW, gnu_printf should be * used for __attribute__((format( ... ))), with GCC v4.4 or later */ diff --git a/src/helper/jim-eventloop.c b/src/helper/jim-eventloop.c deleted file mode 100644 index fe2d685..0000000 --- a/src/helper/jim-eventloop.c +++ /dev/null @@ -1,532 +0,0 @@ -/* Jim - A small embeddable Tcl interpreter - * - * Copyright 2005 Salvatore Sanfilippo <an...@in...> - * Copyright 2005 Clemens Hintze <c.h...@gm...> - * Copyright 2005 patthoyts - Pat Thoyts <pat...@us...> - * Copyright 2008 oharboe - Ãyvind Harboe - oyv...@zy... - * Copyright 2008 Andrew Lunn <an...@lu...> - * Copyright 2008 Duane Ellis <op...@du...> - * Copyright 2008 Uwe Klein <uk...@kl...> - * - * The FreeBSD license - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE JIM TCL PROJECT ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * JIM TCL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation - * are those of the authors and should not be interpreted as representing - * official policies, either expressed or implied, of the Jim Tcl Project. - **/ -/* TODO: - * - * - to really use flags in Jim_ProcessEvents() - * - more complete [after] command with [after info] and other subcommands. - * - Win32 port - */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#define JIM_EXTENSION -#define __JIM_EVENTLOOP_CORE__ -#ifdef __ECOS -#include <pkgconf/jimtcl.h> -#include <sys/time.h> -#include <cyg/jimtcl/jim.h> -#include <cyg/jimtcl/jim-eventloop.h> -#else -#include "jim.h" -#include "jim-eventloop.h" -#endif - -/* File event structure */ -typedef struct Jim_FileEvent { - void *handle; - int mask; /* one of JIM_EVENT_(READABLE | WRITABLE | EXCEPTION) */ - Jim_FileProc *fileProc; - Jim_EventFinalizerProc *finalizerProc; - void *clientData; - struct Jim_FileEvent *next; -} Jim_FileEvent; - -/* Time event structure */ -typedef struct Jim_TimeEvent { - jim_wide id; /* time event identifier. */ - int mode; /* restart, repetitive .. UK */ - long initialms; /* initial relativ timer value UK */ - long when_sec; /* seconds */ - long when_ms; /* milliseconds */ - Jim_TimeProc *timeProc; - Jim_EventFinalizerProc *finalizerProc; - void *clientData; - struct Jim_TimeEvent *next; -} Jim_TimeEvent; - -/* Per-interp stucture containing the state of the event loop */ -typedef struct Jim_EventLoop { - jim_wide timeEventNextId; - Jim_FileEvent *fileEventHead; - Jim_TimeEvent *timeEventHead; -} Jim_EventLoop; - -static void Jim_CreateFileHandler(Jim_Interp *interp, void *handle, int mask, - Jim_FileProc *proc, void *clientData, - Jim_EventFinalizerProc *finalizerProc) -{ - Jim_FileEvent *fe; - Jim_EventLoop *eventLoop = Jim_GetAssocData(interp, "eventloop"); - - // fprintf(stderr,"rein\n"); - fe = Jim_Alloc(sizeof(*fe)); - fe->handle = handle; - fe->mask = mask; - fe->fileProc = proc; - fe->finalizerProc = finalizerProc; - fe->clientData = clientData; - fe->next = eventLoop->fileEventHead; - eventLoop->fileEventHead = fe; - // fprintf(stderr,"raus\n"); -} - -static void Jim_DeleteFileHandler(Jim_Interp *interp, void *handle) -{ - Jim_FileEvent *fe, *prev = NULL; - Jim_EventLoop *eventLoop = Jim_GetAssocData(interp, "eventloop"); - - fe = eventLoop->fileEventHead; - while (fe) { - if (fe->handle == handle) { - if (prev == NULL) - eventLoop->fileEventHead = fe->next; - else - prev->next = fe->next; - if (fe->finalizerProc) - fe->finalizerProc(interp, fe->clientData); - Jim_Free(fe); - return; - } - prev = fe; - fe = fe->next; - } -} - -/* That's another part of this extension that needs to be ported - * to WIN32. */ -static void JimGetTime(long *seconds, long *milliseconds) -{ - struct timeval tv; - - gettimeofday(&tv, NULL); - *seconds = tv.tv_sec; - *milliseconds = tv.tv_usec/1000; -} - -static jim_wide Jim_CreateTimeHandler(Jim_Interp *interp, jim_wide milliseconds, - Jim_TimeProc *proc, void *clientData, - Jim_EventFinalizerProc *finalizerProc) -{ - Jim_EventLoop *eventLoop = Jim_GetAssocData(interp, "eventloop"); - jim_wide id = eventLoop->timeEventNextId++; - Jim_TimeEvent *te; - long cur_sec, cur_ms; - - JimGetTime(&cur_sec, &cur_ms); - - te = Jim_Alloc(sizeof(*te)); - te->id = id; - te->mode = 0; - te->initialms = milliseconds; - te->when_sec = cur_sec + milliseconds/1000; - te->when_ms = cur_ms + milliseconds%1000; - if (te->when_ms >= 1000) { - te->when_sec ++; - te->when_ms -= 1000; - } - te->timeProc = proc; - te->finalizerProc = finalizerProc; - te->clientData = clientData; - te->next = eventLoop->timeEventHead; - eventLoop->timeEventHead = te; - return id; -} - -static jim_wide Jim_DeleteTimeHandler(Jim_Interp *interp, jim_wide id) -{ - Jim_TimeEvent *te, *prev = NULL; - Jim_EventLoop *eventLoop = Jim_GetAssocData(interp, "eventloop"); - long cur_sec, cur_ms; - jim_wide remain ; - - JimGetTime(&cur_sec, &cur_ms); - - te = eventLoop->timeEventHead; - if (id >= eventLoop->timeEventNextId) - return -2; /* wrong event ID */ - while (te) { - if (te->id == id) { - remain = (te->when_sec - cur_sec) * 1000; - remain += (te->when_ms - cur_ms) ; - remain = (remain < 0) ? 0 : remain ; - - if (prev == NULL) - eventLoop->timeEventHead = te->next; - else - prev->next = te->next; - if (te->finalizerProc) - te->finalizerProc(interp, te->clientData); - Jim_Free(te); - return remain; - } - prev = te; - te = te->next; - } - return -1; /* NO event with the specified ID found */ -} - -/* Search the first timer to fire. - * This operation is useful to know how many time the select can be - * put in sleep without to delay any event. - * If there are no timers NULL is returned. */ -static Jim_TimeEvent *JimSearchNearestTimer(Jim_EventLoop *eventLoop) -{ - Jim_TimeEvent *te = eventLoop->timeEventHead; - Jim_TimeEvent *nearest = NULL; - - while (te) { - if (!nearest || te->when_sec < nearest->when_sec || - (te->when_sec == nearest->when_sec && - te->when_ms < nearest->when_ms)) - nearest = te; - te = te->next; - } - return nearest; -} - -/* --- POSIX version of Jim_ProcessEvents, for now the only available --- */ -#define JIM_FILE_EVENTS 1 -#define JIM_TIME_EVENTS 2 -#define JIM_ALL_EVENTS (JIM_FILE_EVENTS | JIM_TIME_EVENTS) -#define JIM_DONT_WAIT 4 - -/* Process every pending time event, then every pending file event - * (that may be registered by time event callbacks just processed). - * Without special flags the function sleeps until some file event - * fires, or when the next time event occurrs (if any). - * - * If flags is 0, the function does nothing and returns. - * if flags has JIM_ALL_EVENTS set, all the kind of events are processed. - * if flags has JIM_FILE_EVENTS set, file events are processed. - * if flags has JIM_TIME_EVENTS set, time events are processed. - * if flags has JIM_DONT_WAIT set the function returns ASAP until all - * the events that's possible to process without to wait are processed. - * - * The function returns the number of events processed. */ -int Jim_ProcessEvents(Jim_Interp *interp, int flags) -{ - int maxfd = 0, numfd = 0, processed = 0; - fd_set rfds, wfds, efds; - Jim_EventLoop *eventLoop = Jim_GetAssocData(interp, "eventloop"); - Jim_FileEvent *fe = eventLoop->fileEventHead; - Jim_TimeEvent *te; - jim_wide maxId; - JIM_NOTUSED(flags); - - FD_ZERO(&rfds); - FD_ZERO(&wfds); - FD_ZERO(&efds); - - /* Check file events */ - while (fe != NULL) { - int fd = fileno((FILE*)fe->handle); - - if (fe->mask & JIM_EVENT_READABLE) - FD_SET(fd, &rfds); - if (fe->mask & JIM_EVENT_WRITABLE) FD_SET(fd, &wfds); - if (fe->mask & JIM_EVENT_EXCEPTION) FD_SET(fd, &efds); - if (maxfd < fd) maxfd = fd; - numfd++; - fe = fe->next; - } - /* Note that we want call select() even if there are no - * file events to process as long as we want to process time - * events, in order to sleep until the next time event is ready - * to fire. */ - if (numfd || ((flags & JIM_TIME_EVENTS) && !(flags & JIM_DONT_WAIT))) { - int retval; - Jim_TimeEvent *shortest; - struct timeval tv, *tvp; - jim_wide dt; - - shortest = JimSearchNearestTimer(eventLoop); - if (shortest) { - long now_sec, now_ms; - - /* Calculate the time missing for the nearest - * timer to fire. */ - JimGetTime(&now_sec, &now_ms); - tvp = &tv; - dt = 1000 * (shortest->when_sec - now_sec); - dt += (shortest->when_ms - now_ms); - if (dt < 0) { - dt = 1; - } - tvp->tv_sec = dt / 1000; - tvp->tv_usec = dt % 1000; - // fprintf(stderr,"Next %d.% 8d\n",(int)tvp->tv_sec,(int)tvp->tv_usec); - } else { - tvp = NULL; /* wait forever */ - // fprintf(stderr,"No Event\n"); - } - - retval = select(maxfd + 1, &rfds, &wfds, &efds, tvp); - if (retval < 0) { - switch (errno) { - case EINTR: fprintf(stderr,"select EINTR\n"); break; - case EINVAL: fprintf(stderr,"select EINVAL\n"); break; - case ENOMEM: fprintf(stderr,"select ENOMEM\n"); break; - } - } else if (retval > 0) { - fe = eventLoop->fileEventHead; - while (fe != NULL) { - int fd = fileno((FILE*)fe->handle); - - // fprintf(stderr,"fd: %d mask: %02x \n",fd,fe->mask); - - if ((fe->mask & JIM_EVENT_READABLE && FD_ISSET(fd, &rfds)) || - (fe->mask & JIM_EVENT_WRITABLE && FD_ISSET(fd, &wfds)) || - (fe->mask & JIM_EVENT_EXCEPTION && FD_ISSET(fd, &efds))) - { - int mask = 0; - - if (fe->mask & JIM_EVENT_READABLE && FD_ISSET(fd, &rfds)) { - mask |= JIM_EVENT_READABLE; - if ((fe->mask & JIM_EVENT_FEOF) && feof((FILE *)fe->handle)) - mask |= JIM_EVENT_FEOF; - } - if (fe->mask & JIM_EVENT_WRITABLE && FD_ISSET(fd, &wfds)) - mask |= JIM_EVENT_WRITABLE; - if (fe->mask & JIM_EVENT_EXCEPTION && FD_ISSET(fd, &efds)) - mask |= JIM_EVENT_EXCEPTION; - if (fe->fileProc(interp, fe->clientData, mask) == JIM_ERR) { - /* Remove the element on handler error */ - Jim_DeleteFileHandler(interp, fe->handle); - } - processed++; - /* After an event is processed our file event list - * may no longer be the same, so what we do - * is to clear the bit for this file descriptor and - * restart again from the head. */ - fe = eventLoop->fileEventHead; - FD_CLR(fd, &rfds); - FD_CLR(fd, &wfds); - FD_CLR(fd, &efds); - } else { - fe = fe->next; - } - } - } - } - /* Check time events */ - te = eventLoop->timeEventHead; - maxId = eventLoop->timeEventNextId-1; - while (te) { - long now_sec, now_ms; - jim_wide id; - - if (te->id > maxId) { - te = te->next; - continue; - } - JimGetTime(&now_sec, &now_ms); - if (now_sec > te->when_sec || - (now_sec == te->when_sec && now_ms >= te->when_ms)) - { - id = te->id; - te->timeProc(interp, te->clientData); - /* After an event is processed our time event list may - * no longer be the same, so we restart from head. - * Still we make sure to don't process events registered - * by event handlers itself in order to don't loop forever - * even in case an [after 0] that continuously register - * itself. To do so we saved the max ID we want to handle. */ - Jim_DeleteTimeHandler(interp, id); - te = eventLoop->timeEventHead; - } else { - te = te->next; - } - } - - return processed; -} -/* ---------------------------------------------------------------------- */ - -static void JimELAssocDataDeleProc(Jim_Interp *interp, void *data) -{ - void *next; - Jim_FileEvent *fe; - Jim_TimeEvent *te; - Jim_EventLoop *eventLoop = data; - - fe = eventLoop->fileEventHead; - while (fe) { - next = fe->next; - if (fe->finalizerProc) - fe->finalizerProc(interp, fe->clientData); - Jim_Free(fe); - fe = next; - } - - te = eventLoop->timeEventHead; - while (te) { - next = te->next; - if (te->finalizerProc) - te->finalizerProc(interp, te->clientData); - Jim_Free(te); - te = next; - } - Jim_Free(data); -} - -static int JimELVwaitCommand(Jim_Interp *interp, int argc, - Jim_Obj *const *argv) -{ - Jim_Obj *oldValue; - - if (argc != 2) { - Jim_WrongNumArgs(interp, 1, argv, "name"); - return JIM_ERR; - } - oldValue = Jim_GetGlobalVariable(interp, argv[1], JIM_NONE); - if (oldValue) Jim_IncrRefCount(oldValue); - while (1) { - Jim_Obj *currValue; - - Jim_ProcessEvents(interp, JIM_ALL_EVENTS); - currValue = Jim_GetGlobalVariable(interp, argv[1], JIM_NONE); - /* Stop the loop if the vwait-ed variable changed value, - * or if was unset and now is set (or the contrary). */ - if ((oldValue && !currValue) || - (!oldValue && currValue) || - (oldValue && currValue && - !Jim_StringEqObj(oldValue, currValue, JIM_CASESENS))) - break; - } - if (oldValue) Jim_DecrRefCount(interp, oldValue); - return JIM_OK; -} - -static void JimAfterTimeHandler(Jim_Interp *interp, void *clientData) -{ - Jim_Obj *objPtr = clientData; - - Jim_EvalObjBackground(interp, objPtr); -} - -static void JimAfterTimeEventFinalizer(Jim_Interp *interp, void *clientData) -{ - Jim_Obj *objPtr = clientData; - - Jim_DecrRefCount(interp, objPtr); -} - -static int JimELAfterCommand(Jim_Interp *interp, int argc, - Jim_Obj *const *argv) -{ - jim_wide ms, id; - Jim_Obj *objPtr, *idObjPtr; - const char *options[] = { - "info", "cancel", "restart", "expire", NULL - }; - enum {INFO, CANCEL, RESTART, EXPIRE, CREATE }; - int option = CREATE ; - - if (argc < 3) { - Jim_WrongNumArgs(interp, 1, argv, "<after milliseconds> script"); - return JIM_ERR; - } - if (Jim_GetWide(interp, argv[1], &ms) != JIM_OK) - if (Jim_GetEnum(interp, argv[1], options, &option, "after options", - JIM_ERRMSG) != JIM_OK) - return JIM_ERR; - switch (option) { - case CREATE: - Jim_IncrRefCount(argv[2]); - id = Jim_CreateTimeHandler(interp, ms, JimAfterTimeHandler, argv[2], - JimAfterTimeEventFinalizer); - objPtr = Jim_NewStringObj(interp, NULL, 0); - Jim_AppendString(interp, objPtr, "after#", -1); - idObjPtr = Jim_NewIntObj(interp, id); - Jim_IncrRefCount(idObjPtr); - Jim_AppendObj(interp, objPtr, idObjPtr); - Jim_DecrRefCount(interp, idObjPtr); - Jim_SetResult(interp, objPtr); - return JIM_OK; - case CANCEL: - { - int tlen ; - jim_wide remain = 0; - const char *tok = Jim_GetString(argv[2], &tlen); - if (sscanf(tok,"after#%" JIM_WIDE_MODIFIER, &id) == 1) { - remain = Jim_DeleteTimeHandler(interp, id); - if (remain > -2) { - Jim_SetResult(interp, Jim_NewIntObj(interp, remain)); - return JIM_OK; - } - } - Jim_SetResultString(interp, "invalid event" , -1); - return JIM_ERR; - } - default: - fprintf(stderr,"unserviced option to after %d\n",option); - } - return JIM_OK; -} - -/* This extension is not dynamically loaded, instead it's linked statically, - which is why we shouldn't use the unspecific 'Jim_OnLoad' name */ -int Jim_EventLoopOnLoad(Jim_Interp *interp) -{ - Jim_EventLoop *eventLoop; - - Jim_InitExtension(interp); - if (Jim_PackageProvide(interp, "eventloop", "1.0", JIM_ERRMSG) != JIM_OK) - return JIM_ERR; - - eventLoop = Jim_Alloc(sizeof(*eventLoop)); - eventLoop->fileEventHead = NULL; - eventLoop->timeEventHead = NULL; - eventLoop->timeEventNextId = 1; - Jim_SetAssocData(interp, "eventloop", JimELAssocDataDeleProc, eventLoop); - - Jim_CreateCommand(interp, "vwait", JimELVwaitCommand, NULL, NULL); - Jim_CreateCommand(interp, "after", JimELAfterCommand, NULL, NULL); - - /* Export events API */ - Jim_RegisterApi(interp, "Jim_CreateFileHandler", Jim_CreateFileHandler); - Jim_RegisterApi(interp, "Jim_DeleteFileHandler", Jim_DeleteFileHandler); - Jim_RegisterApi(interp, "Jim_CreateTimeHandler", Jim_CreateTimeHandler); - Jim_RegisterApi(interp, "Jim_DeleteTimeHandler", Jim_DeleteTimeHandler); - Jim_RegisterApi(interp, "Jim_ProcessEvents", Jim_ProcessEvents); - return JIM_OK; -} diff --git a/src/helper/jim-eventloop.h b/src/helper/jim-eventloop.h deleted file mode 100644 index 95c31d6..0000000 --- a/src/helper/jim-eventloop.h +++ /dev/null @@ -1,75 +0,0 @@ -/* Jim - A small embeddable Tcl interpreter - * - * Copyright 2005 Salvatore Sanfilippo <an...@in...> - * Copyright 2005 Clemens Hintze <c.h...@gm...> - * Copyright 2005 patthoyts - Pat Thoyts <pat...@us...> - * Copyright 2008 oharboe - Ãyvind Harboe - oyv...@zy... - * Copyright 2008 Andrew Lunn <an...@lu...> - * Copyright 2008 Duane Ellis <op...@du...> - * Copyright 2008 Uwe Klein <uk...@kl...> - * - * The FreeBSD license - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE JIM TCL PROJECT ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * JIM TCL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation - * are those of the authors and should not be interpreted as representing - * official policies, either expressed or implied, of the Jim Tcl Project. - **/ -/* ------ USAGE ------- - * - * In order to use this file from other extensions include it in every - * file where you need to call the eventloop API, also in the init - * function of your extension call Jim_ImportEventloopAPI(interp) - * after the Jim_InitExtension() call. - * - * See the UDP extension as example. - */ - - -#ifndef __JIM_EVENTLOOP_H__ -#define __JIM_EVENTLOOP_H__ - -typedef int Jim_FileProc(Jim_Interp *interp, void *clientData, int mask); -typedef void Jim_TimeProc(Jim_Interp *interp, void *clientData); -typedef void Jim_EventFinalizerProc(Jim_Interp *interp, void *clientData); - -/* File event structure */ -#define JIM_EVENT_READABLE 1 -#define JIM_EVENT_WRITABLE 2 -#define JIM_EVENT_EXCEPTION 4 -#define JIM_EVENT_FEOF 8 - -int Jim_EventLoopOnLoad(Jim_Interp *interp); - -/* --- POSIX version of Jim_ProcessEvents, for now the only available --- */ -#define JIM_FILE_EVENTS 1 -#define JIM_TIME_EVENTS 2 -#define JIM_ALL_EVENTS (JIM_FILE_EVENTS | JIM_TIME_EVENTS) -#define JIM_DONT_WAIT 4 - -int Jim_ProcessEvents(Jim_Interp *interp, int flags); - -#endif /* __JIM_EVENTLOOP_H__ */ diff --git a/src/helper/jim.c b/src/helper/jim.c deleted file mode 100644 index bb74838..0000000 --- a/src/helper/jim.c +++ /dev/null @@ -1,12820 +0,0 @@ -/* Jim - A small embeddable Tcl interpreter - * - * Copyright 2005 Salvatore Sanfilippo <an...@in...> - * Copyright 2005 Clemens Hintze <c.h...@gm...> - * Copyright 2005 patthoyts - Pat Thoyts <pat...@us...> - * Copyright 2008,2009 oharboe - Ãyvind Harboe - oyv...@zy... - * Copyright 2008 Andrew Lunn <an...@lu...> - * Copyright 2008 Duane Ellis <op...@du...> - * Copyright 2008 Uwe Klein <uk...@kl...> - * Copyright 2008 Steve Bennett <st...@wo...> - * Copyright 2009 Nico Coesel <nc...@de...> - * Copyright 2009 Zachary T Welch zw...@su... - * Copyright 2009 David Brownell - * - * The FreeBSD license - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE JIM TCL PROJECT ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * JIM TCL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * The views and conclusions contained in the software and documentation - * are those of the authors and should not be interpreted as representing - * official policies, either expressed or implied, of the Jim Tcl Project. - **/ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#define __JIM_CORE__ -#define JIM_OPTIMIZATION /* comment to avoid optimizations and reduce size */ - -#ifdef __ECOS -#include <pkgconf/jimtcl.h> -#include <stdio.h> -#include <stdlib.h> - -typedef CYG_ADDRWORD intptr_t; - -#include <string.h> -#include <stdarg.h> -#include <ctype.h> -#include <limits.h> -#include <assert.h> -#include <errno.h> -#include <time.h> -#endif -#ifndef JIM_ANSIC -#define JIM_DYNLIB /* Dynamic library support for UNIX and WIN32 */ -#endif /* JIM_ANSIC */ - -#include <stdarg.h> -#include <limits.h> - -/* Include the platform dependent libraries for - * dynamic loading of libraries. */ -#ifdef JIM_DYNLIB -#if defined(_WIN32) || defined(WIN32) -#ifndef WIN32 -#define WIN32 1 -#endif -#ifndef STRICT -#define STRICT -#endif -#define WIN32_LEAN_AND_MEAN -#include <windows.h> -#if _MSC_VER >= 1000 -#pragma warning(disable:4146) -#endif /* _MSC_VER */ -#else -#include <dlfcn.h> -#endif /* WIN32 */ -#endif /* JIM_DYNLIB */ - -#ifdef __ECOS -#include <cyg/jimtcl/jim.h> -#else -#include "jim.h" -#endif - -#ifdef HAVE_BACKTRACE -#include <execinfo.h> -#endif - -/* ----------------------------------------------------------------------------- - * Global variables - * ---------------------------------------------------------------------------*/ - -/* A shared empty string for the objects string representation. - * Jim_InvalidateStringRep knows about it and don't try to free. */ -static char *JimEmptyStringRep = (char*) ""; - -/* ----------------------------------------------------------------------------- - * Required prototypes of not exported functions - * ---------------------------------------------------------------------------*/ -static void JimChangeCallFrameId(Jim_Interp *interp, Jim_CallFrame *cf); -static void JimFreeCallFrame(Jim_Interp *interp, Jim_CallFrame *cf, int flags); -static void JimRegisterCoreApi(Jim_Interp *interp); - -static Jim_HashTableType *getJimVariablesHashTableType(void); - -/* ----------------------------------------------------------------------------- - * Utility functions - * ---------------------------------------------------------------------------*/ - -static char * -jim_vasprintf(const char *fmt, va_list ap) -{ -#ifndef HAVE_VASPRINTF - /* yucky way */ -static char buf[2048]; - vsnprintf(buf, sizeof(buf), fmt, ap); - /* garentee termination */ - buf[sizeof(buf)-1] = 0; -#else - char *buf; - int result; - result = vasprintf(&buf, fmt, ap); - if (result < 0) exit(-1); -#endif - return buf; -} - -static void -jim_vasprintf_done(void *buf) -{ -#ifndef HAVE_VASPRINTF - (void)(buf); -#else - free(buf); -#endif -} - - -/* - * Convert a string to a jim_wide INTEGER. - * This function originates from BSD. - * - * Ignores `locale' stuff. Assumes that the upper and lower case - * alphabets and digits are each contiguous. - */ -#ifdef HAVE_LONG_LONG_INT -#define JimIsAscii(c) (((c) & ~0x7f) == 0) -static jim_wide JimStrtoll(const char *nptr, char **endptr, register int base) -{ - register const char *s; - register unsigned jim_wide acc; - register unsigned char c; - register unsigned jim_wide qbase, cutoff; - register int neg, any, cutlim; - - /* - * Skip white space and pick up leading +/- sign if any. - * If base is 0, allow 0x for hex and 0 for octal, else - * assume decimal; if base is already 16, allow 0x. - */ - s = nptr; - do { - c = *s++; - } while (isspace(c)); - if (c == '-') { - neg = 1; - c = *s++; - } else { - neg = 0; - if (c == '+') - c = *s++; - } - if ((base == 0 || base == 16) && - c == '0' && (*s == 'x' || *s == 'X')) { - c = s[1]; - s += 2; - base = 16; - } - if (base == 0) - base = c == '0' ? 8 : 10; - - /* - * Compute the cutoff value between legal numbers and illegal - * numbers. That is the largest legal value, divided by the - * base. An input number that is greater than this value, if - * followed by a legal input character, is too big. One that - * is equal to this value may be valid or not; the limit - * between valid and invalid numbers is then based on the last - * digit. For instance, if the range for quads is - * [-9223372036854775808..9223372036854775807] and the input base - * is 10, cutoff will be set to 922337203685477580 and cutlim to - * either 7 (neg == 0) or 8 (neg == 1), meaning that if we have - * accumulated a value > 922337203685477580, or equal but the - * next digit is > 7 (or 8), the number is too big, and we will - * return a range error. - * - * Set any if any `digits' consumed; make it negative to indicate - * overflow. - */ - qbase = (unsigned)base; - cutoff = neg ? (unsigned jim_wide)-(LLONG_MIN + LLONG_MAX) + LLONG_MAX - : LLONG_MAX; - cutlim = (int)(cutoff % qbase); - cutoff /= qbase; - for (acc = 0, any = 0;; c = *s++) { - if (!JimIsAscii(c)) - break; - if (isdigit(c)) - c -= '0'; - else if (isalpha(c)) - c -= isupper(c) ? 'A' - 10 : 'a' - 10; - else - break; - if (c >= base) - break; - if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) - any = -1; - else { - any = 1; - acc *= qbase; - acc += c; - } - } - if (any < 0) { - acc = neg ? LLONG_MIN : LLONG_MAX; - errno = ERANGE; - } else if (neg) - acc = -acc; - if (endptr != 0) - *endptr = (char *)(any ? s - 1 : nptr); - return (acc); -} -#endif - -/* Glob-style pattern matching. */ -static int JimStringMatch(const char *pattern, int patternLen, - const char *string, int stringLen, int nocase) -{ - while (patternLen) { - switch (pattern[0]) { - case '*': - while (pattern[1] == '*') { - pattern++; - patternLen--; - } - if (patternLen == 1) - return 1; /* match */ - while (stringLen) { - if (JimStringMatch(pattern + 1, patternLen-1, - string, stringLen, nocase)) - return 1; /* match */ - string++; - stringLen--; - } - return 0; /* no match */ - break; - case '?': - if (stringLen == 0) - return 0; /* no match */ - string++; - stringLen--; - break; - case '[': - { - int not, match; - - pattern++; - patternLen--; - not = pattern[0] == '^'; - if (not) { - pattern++; - patternLen--; - } - match = 0; - while (1) { - if (pattern[0] == '\\') { - pattern++; - patternLen--; - if (pattern[0] == string[0]) - match = 1; - } else if (pattern[0] == ']') { - break; - } else if (patternLen == 0) { - pattern--; - patternLen++; - break; - } else if (pattern[1] == '-' && patternLen >= 3) { - int start = pattern[0]; - int end = pattern[2]; - int c = string[0]; - if (start > end) { - int t = start; - start = end; - end = t; - } - if (nocase) { - start = tolower(start); - end = tolower(end); - c = tolower(c); - } - pattern += 2; - patternLen -= 2; - if (c >= start && c <= end) - match = 1; - } else { - if (!nocase) { - if (pattern[0] == string[0]) - match = 1; - } else { - if (tolower((int)pattern[0]) == tolower((int)string[0])) - match = 1; - } - } - pattern++; - patternLen--; - } - if (not) - match = !match; - if (!match) - return 0; /* no match */ - string++; - stringLen--; - break; - } - case '\\': - if (patternLen >= 2) { - pattern++; - patternLen--; - } - /* fall through */ - default: - if (!nocase) { - if (pattern[0] != string[0]) - return 0; /* no match */ - } else { - if (tolower((int)pattern[0]) != tolower((int)string[0])) - return 0; /* no match */ - } - string++; - stringLen--; - break; - } - pattern++; - patternLen--; - if (stringLen == 0) { - while (*pattern == '*') { - pattern++; - patternLen--; - } - break; - } - } - if (patternLen == 0 && stringLen == 0) - return 1; - return 0; -} - -static int JimStringCompare(const char *s1, int l1, const char *s2, int l2, - int nocase) -{ - unsigned char *u1 = (unsigned char*) s1, *u2 = (unsigned char*) s2; - - if (nocase == 0) { - while (l1 && l2) { - if (*u1 != *u2) - return (int)*u1-*u2; - u1++; u2++; l1--; l2--; - } - if (!l1 && !l2) return 0; - return l1-l2; - } else { - while (l1 && l2) { - if (tolower((int)*u1) != tolower((int)*u2)) - return tolower((int)*u1)-tolower((int)*u2); - u1++; u2++; l1--; l2--; - } - if (!l1 && !l2) return 0; - return l1-l2; - } -} - -/* Search 's1' inside 's2', starting to search from char 'index' of 's2'. - * The index of the first occurrence of s1 in s2 is returned. - * If s1 is not found inside s2, -1 is returned. */ -static int JimStringFirst(const char *s1, int l1, const char *s2, int l2, int index_t) -{ - int i; - - if (!l1 || !l2 || l1 > l2) return -1; - if (index_t < 0) index_t = 0; - s2 += index_t; - for (i = index_t; i <= l2-l1; i++) { - if (memcmp(s2, s1, l1) == 0) - return i; - s2++; - } - return -1; -} - -static int Jim_WideToString(char *buf, jim_wide wideValue) -{ - const char *fmt = "%" JIM_WIDE_MODIFIER; - return sprintf(buf, fmt, wideValue); -} - -static int Jim_StringToWide(const char *str, jim_wide *widePtr, int base) -{ - char *endptr; - -#ifdef HAVE_LONG_LONG_INT - *widePtr = JimStrtoll(str, &endptr, base); -#else - *widePtr = strtol(str, &endptr, base); -#endif - if ((str[0] == '\0') || (str == endptr)) - return JIM_ERR; - if (endptr[0] != '\0') { - while (*endptr) { - if (!isspace((int)*endptr)) - return JIM_ERR; - endptr++; - } - } - return JIM_OK; -} - -static int Jim_StringToIndex(const char *str, int *intPtr) -{ - char *endptr; - - *intPtr = strtol(str, &endptr, 10); - if ((str[0] == '\0') || (str == endptr)) - return JIM_ERR; - if (endptr[0] != '\0') { - while (*endptr) { - if (!isspace((int)*endptr)) - return JIM_ERR; - endptr++; - } - } - return JIM_OK; -} - -/* The string representation of references has two features in order - * to make the GC faster. The first is that every reference starts - * with a non common character '~', in order to make the string matching - * fater. The second is that the reference string rep his 32 characters - * in length, this allows to avoid to check every object with a string - * repr < 32, and usually there are many of this objects. */ - -#define JIM_REFERENCE_SPACE (35 + JIM_REFERENCE_TAGLEN) - -static int JimFormatReference(char *buf, Jim_Reference *refPtr, jim_wide id) -{ - const char *fmt = "<reference.<%s>.%020" JIM_WIDE_MODIFIER ">"; - sprintf(buf, fmt, refPtr->tag, id); - return JIM_REFERENCE_SPACE; -} - -static int Jim_DoubleToString(char *buf, double doubleValue) -{ - char *s; - int len; - - len = sprintf(buf, "%.17g", doubleValue); - s = buf; - while (*s) { - if (*s == '.') return len; - s++; - } - /* Add a final ".0" if it's a number. But not - * for NaN or InF */ - if (isdigit((int)buf[0]) - || ((buf[0] == '-' || buf[0] == '+') - && isdigit((int)buf[1]))) { - s[0] = '.'; - s[1] = '0'; - s[2] = '\0'; - return len + 2; - } - return len; -} - -static int Jim_StringToDouble(const char *str, double *doublePtr) -{ - char *endptr; - - *doublePtr = strtod(str, &endptr); - if (str[0] == '\0' || endptr[0] != '\0' || (str == endptr)) - return JIM_ERR; - return JIM_OK; -} - -static jim_wide JimPowWide(jim_wide b, jim_wide e) -{ - jim_wide i, res = 1; - if ((b == 0 && e != 0) || (e < 0)) return 0; - for (i = 0; i < e; i++) {res *= b;} - return res; -} - -/* ----------------------------------------------------------------------------- - * Special functions - * ---------------------------------------------------------------------------*/ - -/* Note that 'interp' may be NULL if not available in the - * context of the panic. It's only useful to get the error - * file descriptor, it will default to stderr otherwise. */ -void Jim_Panic(Jim_Interp *interp, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - /* - * Send it here first.. Assuming STDIO still works - */ - fprintf(stderr, JIM_NL "JIM INTERPRETER PANIC: "); - vfprintf(stderr, fmt, ap); - fprintf(stderr, JIM_NL JIM_NL); - va_end(ap); - -#ifdef HAVE_BACKTRACE - { - void *array[40]; - int size, i; - char **strings; - - size = backtrace(array, 40); - strings = backtrace_symbols(array, size); - for (i = 0; i < size; i++) - fprintf(fp,"[backtrace] %s" JIM_NL, strings[i]); - fprintf(fp,"[backtrace] Include the above lines and the output" JIM_NL); - fprintf(fp,"[backtrace] of 'nm <executable>' in the bug report." JIM_NL); - } -#endif - - /* This may actually crash... we do it last */ - if (interp && interp->cookie_stderr) { - Jim_fprintf(interp, interp->cookie_stderr, JIM_NL "JIM INTERPRETER PANIC: "); - Jim_vfprintf(interp, interp->cookie_stderr, fmt, ap); - Jim_fprintf(interp, interp->cookie_stderr, JIM_NL JIM_NL); - } - abort(); -} - -/* ----------------------------------------------------------------------------- - * Memory allocation - * ---------------------------------------------------------------------------*/ - -/* Macro used for memory debugging. - * In order for they to work you have to rename Jim_Alloc into _Jim_Alloc - * and similary for Jim_Realloc and Jim_Free */ -#if 0 -#define Jim_Alloc(s) (printf("%s %d: Jim_Alloc(%d)\n",__FILE__,__LINE__,s),_Jim_Alloc(s)) -#define Jim_Free(p) (printf("%s %d: Jim_Free(%p)\n",__FILE__,__LINE__,p),_Jim_Free(p)) -#define Jim_Realloc(p,s) (printf("%s %d: Jim_Realloc(%p,%d)\n",__FILE__,__LINE__,p,s),_Jim_Realloc(p,s)) -#endif - -void *Jim_Alloc(int size) -{ - /* We allocate zero length arrayes, etc. to use a single orthogonal codepath */ - if (size == 0) - size = 1; - void *p = malloc(size); - if (p == NULL) - Jim_Panic(NULL,"malloc: Out of memory"); - return p; -} - -void Jim_Free(void *ptr) { - free(ptr); -} - -static void *Jim_Realloc(void *ptr, int size) -{ - /* We allocate zero length arrayes, etc. to use a single orthogonal codepath */ - if (size == 0) - size = 1; - void *p = realloc(ptr, size); - if (p == NULL) - Jim_Panic(NULL,"realloc: Out of memory"); - return p; -} - -char *Jim_StrDup(const char *s) -{ - int l = strlen(s); - char *copy = Jim_Alloc(l + 1); - - memcpy(copy, s, l + 1); - return copy; -} - -static char *Jim_StrDupLen(const char *s, int l) -{ - char *copy = Jim_Alloc(l + 1); - - memcpy(copy, s, l + 1); - copy[l] = 0; /* Just to be sure, original could be substring */ - return copy; -} - -/* ----------------------------------------------------------------------------- - * Time related functions - * ---------------------------------------------------------------------------*/ -/* Returns microseconds of CPU used since start. */ -static jim_wide JimClock(void) -{ -#if (defined WIN32) && !(defined JIM_ANSIC) - LARGE_INTEGER t, f; - QueryPerformanceFrequency(&f); - QueryPerformanceCounter(&t); - return (long)((t.QuadPart * 1000000) / f.QuadPart); -#else /* !WIN32 */ - clock_t clocks = clock(); - - return (long)(clocks*(1000000/CLOCKS_PER_SEC)); -#endif /* WIN32 */ -} - -/* ----------------------------------------------------------------------------- - * Hash Tables - * ---------------------------------------------------------------------------*/ - -/* -------------------------- private prototypes ---------------------------- */ -static int JimExpandHashTableIfNeeded(Jim_HashTable *ht); -static unsigned int JimHashTableNextPower(unsigned int size); -static int JimInsertHashEntry(Jim_HashTable *ht, const void *key); - -/* -------------------------- hash functions -------------------------------- */ - -/* Thomas Wang's 32 bit Mix Function */ -static unsigned int Jim_IntHashFunction(unsigned int key) -{ - key += ~(key << 15); - key ^= (key >> 10); - key += (key << 3); - key ^= (key >> 6); - key += ~(key << 11); - key ^= (key >> 16); - return key; -} - -/* Generic hash function (we are using to multiply by 9 and add the byte - * as Tcl) */ -static unsigned int Jim_GenHashFunction(const unsigned char *buf, int len) -{ - unsigned int h = 0; - while (len--) - h += (h << 3)+*buf++; - return h; -} - -/* ----------------------------- API implementation ------------------------- */ -/* reset an hashtable already initialized with ht_init(). - * NOTE: This function should only called by ht_destroy(). */ -static void JimResetHashTable(Jim_HashTable *ht) -{ - ht->table = NULL; - ht->size = 0; - ht->sizemask = 0; - ht->used = 0; - ht->collisions = 0; -} - -/* Initialize the hash table */ -int Jim_InitHashTable(Jim_HashTable *ht, Jim_HashTableType *type, - void *privDataPtr) -{ - JimResetHashTable(ht); - ht->type = type; - ht->privdata = privDataPtr; - return JIM_OK; -} - -/* Resize the table to the minimal size that contains all the elements, - * but with the invariant of a USER/BUCKETS ration near to <= 1 */ -int Jim_ResizeHashTable(Jim_HashTable *ht) -{ - int minimal = ht->used; - - if (minimal < JIM_HT_INITIAL_SIZE) - minimal = JIM_HT_INITIAL_SIZE; - return Jim_ExpandHashTable(ht, minimal); -} - -/* Expand or create the hashtable */ -int Jim_ExpandHashTable(Jim_HashTable *ht, unsigned int size) -{ - Jim_HashTable n; /* the new hashtable */ - unsigned int realsize = JimHashTableNextPower(size), i; - - /* the size is invalid if it is smaller than the number of - * elements already inside the hashtable */ - if (ht->used >= size) - return JIM_ERR; - - Jim_InitHashTable(&n, ht->type, ht->privdata); - n.size = realsize; - n.sizemask = realsize-1; - n.table = Jim_Alloc(realsize*sizeof(Jim_HashEntry*)); - - /* Initialize all the pointers to NULL */ - memset(n.table, 0, realsize*sizeof(Jim_HashEntry*)); - - /* Copy all the elements from the old to the new table: - * note that if the old hash table is empty ht->size is zero, - * so Jim_ExpandHashTable just creates an hash table. */ - n.used = ht->used; - for (i = 0; i < ht->size && ht->used > 0; i++) { - Jim_HashEntry *he, *nextHe; - - if (ht->table[i] == NULL) continue; - - /* For each hash entry on this slot... */ - he = ht->table[i]; - while (he) { - unsigned int h; - - nextHe = he->next; - /* Get the new element index */ - h = Jim_HashKey(ht, he->key) & n.sizemask; - he->next = n.table[h]; - n.table[h] = he; - ht->used--; - /* Pass to the next element */ - he = nextHe; - } - } - assert(ht->used == 0); - Jim_Free(ht->table); - - /* Remap the new hashtable in the old */ - *ht = n; - return JIM_OK; -} - -/* Add an element to the target hash table */ -int Jim_AddHashEntry(Jim_HashTable *ht, const void *key, void *val) -{ - int index_t; - Jim_HashEntry *entry; - - /* Get the index of the new element, or -1 if - * the element already exists. */ - if ((index_t = JimInsertHashEntry(ht, key)) == -1) - return JIM_ERR; - - /* Allocates the memory and stores key */ - entry = Jim_Alloc(sizeof(*entry)); - entry->next = ht->table[index_t]; - ht->table[index_t] = entry; - - /* Set the hash entry fields. */ - Jim_SetHashKey(ht, entry, key); - Jim_SetHashVal(ht, entry, val); - ht->used++; - return JIM_OK; -} - -/* Add an element, discarding the old if the key already exists */ -int Jim_ReplaceHashEntry(Jim_HashTable *ht, const void *key, void *val) -{ - Jim_HashEntry *entry; - - /* Try to add the element. If the key - * does not exists Jim_AddHashEntry will suceed. */ - if (Jim_AddHashEntry(ht, key, val) == JIM_OK) - return JIM_OK; - /* It already exists, get the entry */ - entry = Jim_FindHashEntry(ht, key); - /* Free the old value and set the new one */ - Jim_FreeEntryVal(ht, entry); - Jim_SetHashVal(ht, entry, val); - return JIM_OK; -} - -/* Search and remove an element */ -int Jim_DeleteHashEntry(Jim_HashTable *ht, const void *key) -{ - unsigned int h; - Jim_HashEntry *he, *prevHe; - - if (ht->size == 0) - return JIM_ERR; - h = Jim_HashKey(ht, key) & ht->sizemask; - he = ht->table[h]; - - prevHe = NULL; - while (he) { - if (Jim_CompareHashKeys(ht, key, he->key)) { - /* Unlink the element from the list */ - if (prevHe) - prevHe->next = he->next; - else - ht->table[h] = he->next; - Jim_FreeEntryKey(ht, he); - Jim_FreeEntryVal(ht, he); - Jim_Free(he); - ht->used--; - return JIM_OK; - } - prevHe = he; - he = he->next; - } - return JIM_ERR; /* not found */ -} - -/* Destroy an entire hash table */ -int Jim_FreeHashTable(Jim_HashTable *ht) -{ - unsigned int i; - - /* Free all the elements */ - for (i = 0; i < ht->size && ht->used > 0; i++) { - Jim_HashEntry *he, *nextHe; - - if ((he = ht->table[i]) == NULL) continue; - while (he) { - nextHe = he->next; - Jim_FreeEntryKey(ht, he); - Jim_FreeEntryVal(ht, he); - Jim_Free(he); - ht->used--; - he = nextHe; - } - } - /* Free the table and the allocated cache structure */ - Jim_Free(ht->table); - /* Re-initialize the table */ - JimResetHashTable(ht); - return JIM_OK; /* never fails */ -} - -Jim_HashEntry *Jim_FindHashEntry(Jim_HashTable *ht, const void *key) -{ - Jim_HashEntry *he; - unsigned int h; - - if (ht->size == 0) return NULL; - h = Jim_HashKey(ht, key) & ht->sizemask; - he = ht->table[h]; - while (he) { - if (Jim_CompareHashKeys(ht, key, he->key)) - return he; - he = he->next; - } - return NULL; -} - -Jim_HashTableIterator *Jim_GetHashTableIterator(Jim_HashTable *ht) -{ - Jim_HashTableIterator *iter = Jim_Alloc(sizeof(*iter)); - - iter->ht = ht; - iter->index = -1; - iter->entry = NULL; - iter->nextEntry = NULL; - return iter; -} - -Jim_HashEntry *Jim_NextHashEntry(Jim_HashTableIterator *iter) -{ - while (1) { - if (iter->entry == NULL) { - iter->index++; - if (iter->index >= - (signed)iter->ht->size) break; - iter->entry = iter->ht->table[iter->index]; - } else { - iter->entry = iter->nextEntry; - } - if (iter->entry) { - /* We need to save the 'next' here, the iterator user - * may delete the entry we are returning. */ - iter->nextEntry = iter->entry->next; - return iter->entry; - } - } - return NULL; -} - -/* ------------------------- private functions ------------------------------ */ - -/* Expand the hash table if needed */ -static int JimExpandHashTableIfNeeded(Jim_HashTable *ht) -{ - /* If the hash table is empty expand it to the intial size, - * if the table is "full" dobule its size. */ - if (ht->size == 0) - return Jim_ExpandHashTable(ht, JIM_HT_INITIAL_SIZE); - if (ht->size == ht->used) - return Jim_ExpandHashTable(ht, ht->size*2); - return JIM_OK; -} - -/* Our hash table capability is a power of two */ -static unsigned int JimHashTableNextPower(unsigned int size) -{ - unsigned int i = JIM_HT_INITIAL_SIZE; - - if (size >= 2147483648U) - return 2147483648U; - while (1) { - if (i >= size) - return i; - i *= 2; - } -} - -/* Returns the index of a free slot that can be populated with - * an hash entry for the given 'key'. - * If the key already exists, -1 is returned. */ -static int JimInsertHashEntry(Jim_HashTable *ht, const void *key) -{ - unsigned int h; - Jim_HashEntry *he; - - /* Expand the hashtable if needed */ - if (JimExpandHashTableIfNeeded(ht) == JIM_ERR) - return -1; - /* Compute the key hash value */ - h = Jim_HashKey(ht, key) & ht->sizemask; - /* Search if this slot does not already contain the given key */ - he = ht->table[h]; - while (he) { - if (Jim_CompareHashKeys(ht, key, he->key)) - return -1; - he = he->next; - } - return h; -} - -/* ----------------------- StringCopy Hash Table Type ------------------------*/ - -static unsigned int JimStringCopyHTHashFunction(const void *key) -{ - return Jim_GenHashFunction(key, strlen(key)); -} - -static const void *JimStringCopyHTKeyDup(void *privdata, const void *key) -{ - int len = strlen(key); - char *copy = Jim_Alloc(len + 1); - JIM_NOTUSED(privdata); - - memcpy(copy, key, len); - copy[len] = '\0'; - return copy; -} - -static void *JimStringKeyValCopyHTValDup(void *privdata, const void *val) -{ - int len = strlen(val); - char *copy = Jim_Alloc(len + 1); - JIM_NOTUSED(privdata); - - memcpy(copy, val, len); - copy[len] = '\0'; - return copy; -} - -static int JimStringCopyHTKeyCompare(void *privdata, const void *key1, - const void *key2) -{ - JIM_NOTUSED(privdata); - - return strcmp(key1, key2) == 0; -} - -static void JimStringCopyHTKeyDestructor(void *privdata, const void *key) -{ - JIM_NOTUSED(privdata); - - Jim_Free((void*)key); /* ATTENTION: const cast */ -} - -static void JimStringKeyValCopyHTValDestructor(void *privdata, void *val) -{ - JIM_NOTUSED(privdata); - - Jim_Free((void*)val); /* ATTENTION: const cast */ -} - -static Jim_HashTableType JimStringCopyHashTableType = { - JimStringCopyHTHashFunction, /* hash function */ - JimStringCopyHTKeyDup, /* key dup */ - NULL, /* val dup */ - JimStringCopyHTKeyCompare, /* key compare */ - JimStringCopyHTKeyDestructor, /* key destructor */ - NULL /* ... [truncated message content] |
From: Spencer O. <nt...@us...> - 2010-10-28 12:46:43
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 4617cd0f911d64a460d99d25c531ddc55f2452ca (commit) via 1fafb669c99744b986d85b5c4a4e276767898654 (commit) from 53228fbc2e61fd39f45a43e4be54e0121e608714 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 4617cd0f911d64a460d99d25c531ddc55f2452ca Author: Spencer Oliver <nt...@us...> Date: Thu Oct 28 10:08:16 2010 +0100 src: add loader src description - add comment where to find the various loaders src files. Signed-off-by: Spencer Oliver <nt...@us...> diff --git a/src/flash/nor/pic32mx.c b/src/flash/nor/pic32mx.c index 363f49e..6e51f1a 100644 --- a/src/flash/nor/pic32mx.c +++ b/src/flash/nor/pic32mx.c @@ -227,6 +227,8 @@ static int pic32mx_protect(struct flash_bank *bank, int set, int first, int last return ERROR_OK; } +/* see contib/loaders/flash/pic32mx.s for src */ + static const uint32_t pic32mx_flash_write_code[] = { /* write: */ 0x3C08AA99, /* lui $t0, 0xaa99 */ diff --git a/src/flash/nor/stellaris.c b/src/flash/nor/stellaris.c index 287be12..069ee8c 100644 --- a/src/flash/nor/stellaris.c +++ b/src/flash/nor/stellaris.c @@ -773,6 +773,8 @@ static int stellaris_protect(struct flash_bank *bank, int set, int first, int la return ERROR_OK; } +/* see contib/loaders/flash/stellaris.s for src */ + static const uint8_t stellaris_write_code[] = { /* diff --git a/src/flash/nor/stm32x.c b/src/flash/nor/stm32x.c index 4ec777d..5b31b04 100644 --- a/src/flash/nor/stm32x.c +++ b/src/flash/nor/stm32x.c @@ -446,6 +446,8 @@ static int stm32x_write_block(struct flash_bank *bank, uint8_t *buffer, struct armv7m_algorithm armv7m_info; int retval = ERROR_OK; + /* see contib/loaders/flash/stm32x.s for src */ + static const uint8_t stm32x_flash_write_code[] = { /* write: */ 0xDF, 0xF8, 0x24, 0x40, /* ldr r4, STM32_FLASH_CR */ @@ -462,6 +464,7 @@ static int stm32x_write_block(struct flash_bank *bank, uint8_t *buffer, 0x01, 0xD1, /* bne exit */ 0x01, 0x3A, /* subs r2, r2, #1 */ 0xED, 0xD1, /* bne write */ + /* exit: */ 0x00, 0xBE, /* bkpt #0 */ 0x10, 0x20, 0x02, 0x40, /* STM32_FLASH_CR: .word 0x40022010 */ 0x0C, 0x20, 0x02, 0x40 /* STM32_FLASH_SR: .word 0x4002200C */ diff --git a/src/flash/nor/str7x.c b/src/flash/nor/str7x.c index 069e90c..3a74d35 100644 --- a/src/flash/nor/str7x.c +++ b/src/flash/nor/str7x.c @@ -406,6 +406,8 @@ static int str7x_write_block(struct flash_bank *bank, uint8_t *buffer, struct arm_algorithm armv4_5_info; int retval = ERROR_OK; + /* see contib/loaders/flash/str7x.s for src */ + static const uint32_t str7x_flash_write_code[] = { /* write: */ 0xe3a04201, /* mov r4, #0x10000000 */ diff --git a/src/flash/nor/str9x.c b/src/flash/nor/str9x.c index cfe6a77..1e71753 100644 --- a/src/flash/nor/str9x.c +++ b/src/flash/nor/str9x.c @@ -364,6 +364,8 @@ static int str9x_write_block(struct flash_bank *bank, struct arm_algorithm armv4_5_info; int retval = ERROR_OK; + /* see contib/loaders/flash/str9x.s for src */ + static const uint32_t str9x_flash_write_code[] = { /* write: */ 0xe3c14003, /* bic r4, r1, #3 */ diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index 07c8c6e..ac7f623 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -1307,6 +1307,8 @@ int arm_checksum_memory(struct target *target, uint32_t i; uint32_t exit_var = 0; + /* see contib/loaders/checksum/armv4_5_crc.s for src */ + static const uint32_t arm_crc_code[] = { 0xE1A02000, /* mov r2, r0 */ 0xE3E00000, /* mov r0, #0xffffffff */ diff --git a/src/target/armv7m.c b/src/target/armv7m.c index a73a9bb..03c9c7a 100644 --- a/src/target/armv7m.c +++ b/src/target/armv7m.c @@ -562,6 +562,8 @@ int armv7m_checksum_memory(struct target *target, struct reg_param reg_params[2]; int retval; + /* see contib/loaders/checksum/armv7m_crc.s for src */ + static const uint16_t cortex_m3_crc_code[] = { 0x4602, /* mov r2, r0 */ 0xF04F, 0x30FF, /* mov r0, #0xffffffff */ diff --git a/src/target/mips32.c b/src/target/mips32.c index 24cd7d9..533701a 100644 --- a/src/target/mips32.c +++ b/src/target/mips32.c @@ -613,6 +613,8 @@ int mips32_checksum_memory(struct target *target, uint32_t address, int retval; uint32_t i; + /* see contib/loaders/checksum/mips32.s for src */ + static const uint32_t mips_crc_code[] = { 0x248C0000, /* addiu $t4, $a0, 0 */ commit 1fafb669c99744b986d85b5c4a4e276767898654 Author: Spencer Oliver <nt...@us...> Date: Thu Oct 28 09:19:37 2010 +0100 contrib: add ram loader src code Add src code for ram loaders to contrib directory. Signed-off-by: Spencer Oliver <nt...@us...> diff --git a/contrib/loaders/README b/contrib/loaders/README new file mode 100644 index 0000000..2b123cf --- /dev/null +++ b/contrib/loaders/README @@ -0,0 +1,33 @@ +Included in these directories are the src to the various ram loaders used +within openocd. + +** target checksum loaders ** + +checksum/armv4_5_crc.s : + - ARMv4 and ARMv5 checksum loader : see target/arm_crc_code.c:arm_crc_code + +checksum/armv7m_crc.s : + - ARMv7m checksum loader : see target/armv7m.c:cortex_m3_crc_code + +checksum/mips32.s : + - MIPS32 checksum loader : see target/mips32.c:mips_crc_code + +** target flash loaders ** + +flash/pic32mx.s : + - Microchip PIC32 flash loader : see flash/nor/pic32mx.c:pic32mx_flash_write_code + +flash/stellaris.s : + - TI Stellaris flash loader : see flash/nor/stellaris.c:stellaris_write_code + +flash/stm32x.s : + - ST STM32 flash loader : see flash/nor/stm32x.c:stm32x_flash_write_code + +flash/str7x.s : + - ST STR7 flash loader : see flash/nor/str7x.c:str7x_flash_write_code + +flash/str9x.s : + - ST STR9 flash loader : see flash/nor/str9x.c:str9x_flash_write_code + +Spencer Oliver +s...@sp... diff --git a/contrib/loaders/checksum/armv4_5_crc.s b/contrib/loaders/checksum/armv4_5_crc.s new file mode 100644 index 0000000..950a8d0 --- /dev/null +++ b/contrib/loaders/checksum/armv4_5_crc.s @@ -0,0 +1,58 @@ +/*************************************************************************** + * Copyright (C) 2010 by Spencer Oliver * + * sp...@sp... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +/* + r0 - address in - crc out + r1 - char count +*/ + + .text + .arm + +_start: +main: + mov r2, r0 + mov r0, #0xffffffff /* crc */ + mov r3, r1 + mov r4, #0 + b ncomp +nbyte: + ldrb r1, [r2, r4] + ldr r7, CRC32XOR + eor r0, r0, r1, asl #24 + mov r5, #0 +loop: + cmp r0, #0 + mov r6, r0, asl #1 + add r5, r5, #1 + mov r0, r6 + eorlt r0, r6, r7 + cmp r5, #8 + bne loop + add r4, r4, #1 +ncomp: + cmp r4, r3 + bne nbyte +end: + bkpt #0 + +CRC32XOR: .word 0x04c11db7 + + .end diff --git a/contrib/loaders/checksum/armv7m_crc.s b/contrib/loaders/checksum/armv7m_crc.s new file mode 100644 index 0000000..e50db0a --- /dev/null +++ b/contrib/loaders/checksum/armv7m_crc.s @@ -0,0 +1,66 @@ +/*************************************************************************** + * Copyright (C) 2010 by Spencer Oliver * + * sp...@sp... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +/* + parameters: + r0 - address in - crc out + r1 - char count +*/ + + .text + .syntax unified + .cpu cortex-m3 + .thumb + .thumb_func + + .align 2 + +_start: +main: + mov r2, r0 + mov r0, #0xffffffff /* crc */ + mov r3, r1 + mov r4, #0 + b ncomp +nbyte: + ldrb r1, [r2, r4] + + ldr r7, CRC32XOR + eor r0, r0, r1, asl #24 + mov r5, #0 +loop: + cmp r0, #0 + mov r6, r0, asl #1 + add r5, r5, #1 + mov r0, r6 + it lt + eorlt r0, r6, r7 + cmp r5, #8 + bne loop + + add r4, r4, #1 +ncomp: + cmp r4, r3 + bne nbyte + bkpt #0 + +CRC32XOR: .word 0x04c11db7 + + .end diff --git a/contrib/loaders/checksum/mips32.s b/contrib/loaders/checksum/mips32.s new file mode 100644 index 0000000..f8f08a2 --- /dev/null +++ b/contrib/loaders/checksum/mips32.s @@ -0,0 +1,72 @@ +/*************************************************************************** + * Copyright (C) 2010 by Spencer Oliver * + * sp...@sp... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + + .global main + .text + .set noreorder + +/* params: + * $a0 address in + * $a1 byte count + * vars + * $a0 crc + * $a1 crc data byte + * temps: + * t3 v0 a3 a2 t0 v1 + */ + +.ent main +main: + addiu $t4, $a0, 0 /* address in */ + addiu $t2, $a1, 0 /* count */ + + addiu $a0, $zero, 0xffffffff /* a0 crc - result */ + + beq $zero, $zero, ncomp + addiu $t3, $zero, 0 /* clear bytes read */ + +nbyte: + lb $a1, ($t4) /* load byte from source address */ + addi $t4, $t4, 1 /* inc byte count */ + +crc: + sll $a1, $a1, 24 + lui $v0, 0x04c1 + xor $a0, $a0, $a1 + ori $a3, $v0, 0x1db7 + addu $a2, $zero, $zero /* clear bit count */ +loop: + sll $t0, $a0, 1 + addiu $a2, $a2, 1 /* inc bit count */ + slti $a0, $a0, 0 + xor $t1, $t0, $a3 + movn $t0, $t1, $a0 + slti $v1, $a2, 8 /* 8bits processed */ + bne $v1, $zero, loop + addu $a0, $t0, $zero + +ncomp: + bne $t2, $t3, nbyte /* all bytes processed */ + addiu $t3, $t3, 1 + +wait: + sdbbp + +.end main diff --git a/contrib/loaders/flash/pic32mx.s b/contrib/loaders/flash/pic32mx.s new file mode 100644 index 0000000..b26ff61 --- /dev/null +++ b/contrib/loaders/flash/pic32mx.s @@ -0,0 +1,131 @@ +/*************************************************************************** + * Copyright (C) 2010 by Spencer Oliver * + * sp...@sp... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + + .text + .set noreorder + .set noat + +/* params: + * $a0 src adr - ram + result + * $a1 dest adr - flash + * $a2 count (32bit words) + * vars + * + * temps: + * $t0, $t1, $t2, $t3, $t4, $t5 + * $s0, $s1, $s3, $s4, $s5 + */ + + .type main, @function + .global main + +.ent main +main: + /* setup constants */ + lui $t0, 0xaa99 + ori $t0, 0x6655 /* NVMKEY1 */ + lui $t1, 0x5566 + ori $t1, 0x99AA /* NVMKEY2 */ + lui $t2, 0xBF80 + ori $t2, 0xF400 /* NVMCON */ + ori $t3, $zero, 0x4003 /* NVMCON row write cmd */ + ori $t4, $zero, 0x8000 /* NVMCON start cmd */ + +write_row: + /* can we perform a row write: 128 32bit words */ + sltiu $s3, $a2, 128 + bne $s3, $zero, write_word + ori $t5, $zero, 0x4000 /* NVMCON clear cmd */ + + /* perform row write 512 bytes */ + sw $a1, 32($t2) /* set NVMADDR with dest addr - real addr */ + sw $a0, 64($t2) /* set NVMSRCADDR with src addr - real addr */ + + bal progflash + addiu $a0, $a0, 512 + addiu $a1, $a1, 512 + beq $zero, $zero, write_row + addiu $a2, $a2, -128 + +write_word: + /* write 32bit words */ + lui $s5, 0xa000 + ori $s5, 0x0000 + or $a0, $a0, $s5 /* convert to virtual addr */ + + beq $zero, $zero, next_word + ori $t3, $zero, 0x4001 /* NVMCON word write cmd */ + +prog_word: + lw $s4, 0($a0) /* load data - from virtual addr */ + sw $s4, 48($t2) /* set NVMDATA with data */ + sw $a1, 32($t2) /* set NVMADDR with dest addr - real addr */ + + bal progflash + addiu $a0, $a0, 4 + addiu $a1, $a1, 4 + addiu $a2, $a2, -1 +next_word: + bne $a2, $zero, prog_word + nop + +done: + beq $zero, $zero, exit + addiu $a0, $zero, 0 + +error: + /* save result to $a0 */ + addiu $a0, $s1, 0 + +exit: + sdbbp +.end main + + .type progflash, @function + .global progflash + +.ent progflash +progflash: + sw $t3, 0($t2) /* set NVMWREN */ + sw $t0, 16($t2) /* write NVMKEY1 */ + sw $t1, 16($t2) /* write NVMKEY2 */ + sw $t4, 8($t2) /* start operation */ + +waitflash: + lw $s0, 0($t2) + and $s0, $s0, $t4 + bne $s0, $zero, waitflash + nop + + /* following is to comply with errata #34 + * 500ns delay required */ + nop + nop + nop + nop + /* check for errors */ + lw $s1, 0($t2) + andi $s1, $zero, 0x3000 + bne $s1, $zero, error + sw $t5, 4($t2) /* clear NVMWREN */ + jr $ra + nop + +.end progflash diff --git a/contrib/loaders/flash/stellaris.s b/contrib/loaders/flash/stellaris.s new file mode 100644 index 0000000..166dd52 --- /dev/null +++ b/contrib/loaders/flash/stellaris.s @@ -0,0 +1,66 @@ +/*************************************************************************** + * Copyright (C) 2006 by Magnus Lundin * + * lu...@ml... * + * * + * Copyright (C) 2008 by Spencer Oliver * + * sp...@sp... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + + .text + .syntax unified + .cpu cortex-m3 + .thumb + .thumb_func + .align 2 + +/* + Call with : + r0 = buffer address + r1 = destination address + r2 = bytecount (in) - endaddr (work) + + Used registers: + r3 = pFLASH_CTRL_BASE + r4 = FLASHWRITECMD + r5 = #1 + r6 = bytes written + r7 = temp reg +*/ + +write: + ldr r3,pFLASH_CTRL_BASE + ldr r4,FLASHWRITECMD + movs r5, 1 + movs r6, #0 +mainloop: + str r1, [r3, #0] + ldr r7, [r0, r6] + str r7, [r3, #4] + str r4, [r3, #8] +waitloop: + ldr r7, [r3, #8] + tst r7, r5 + bne waitloop + adds r1, r1, #4 + adds r6, r6, #4 + cmp r6, r2 + bne mainloop + bkpt #0 + +pFLASH_CTRL_BASE: .word 0x400FD000 +FLASHWRITECMD: .word 0xA4420001 diff --git a/contrib/loaders/flash/stm32x.s b/contrib/loaders/flash/stm32x.s new file mode 100644 index 0000000..dcf2b83 --- /dev/null +++ b/contrib/loaders/flash/stm32x.s @@ -0,0 +1,52 @@ +/*************************************************************************** + * Copyright (C) 2010 by Spencer Oliver * + * sp...@sp... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + + .text + .arm + +/* + r0 - source address + r1 - target address + r2 - count (halfword-16bit) + r3 - result + r4 - temp + r5 - temp +*/ + +write: + ldr r4, STM32_FLASH_CR + ldr r5, STM32_FLASH_SR + mov r3, #1 + str r3, [r4, #0] + ldrh r3, [r0], #2 + strh r3, [r1], #2 +busy: + ldr r3, [r5, #0] + tst r3, #0x01 + beq busy + tst r3, #0x14 + bne exit + subs r2, r2, #1 + bne write +exit: + bkpt #0 + +STM32_FLASH_CR: .word 0x40022010 +STM32_FLASH_SR: .word 0x4002200C diff --git a/contrib/loaders/flash/str7x.s b/contrib/loaders/flash/str7x.s new file mode 100644 index 0000000..fcdb007 --- /dev/null +++ b/contrib/loaders/flash/str7x.s @@ -0,0 +1,57 @@ +/*************************************************************************** + * Copyright (C) 2010 by Spencer Oliver * + * sp...@sp... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + + .text + .arm + .section .init +/* + r0 source address + r1 address + r2 FLASH_CR0 + r3 dword count + r4 result + r5 busy mask +*/ + +write: + mov r4, #0x10000000 /* set DWPG bit */ + str r4, [r2, #0x0] /* FLASH_CR0 */ + str r1, [r2, #0x10] /* FLASH_AR */ + ldr r4, [r0], #4 /* load data */ + str r4, [r2, #0x8] /* FLASH_DR0 */ + ldr r4, [r0], #4 /* load data */ + str r4, [r2, #0xc] /* FLASH_DR1 */ + mov r4, #0x90000000 /* set DWPG and WMS bits */ + str r4, [r2, #0x0] /* FLASH_CR0 */ +busy: + ldr r4, [r2, #0x0] /* FLASH_CR0 */ + tst r4, r5 + bne busy + ldr r4, [r2, #0x14] /* FLASH_ER */ + tst r4, #0xff /* do we have errors */ + tsteq r4, #0x100 /* write protection set */ + bne exit + add r1, r1, #0x8 /* next 8 bytes */ + subs r3, r3, #1 /* decremment dword count */ + bne write +exit: + b exit + + .end diff --git a/contrib/loaders/flash/str9x.s b/contrib/loaders/flash/str9x.s new file mode 100644 index 0000000..9b15b3d --- /dev/null +++ b/contrib/loaders/flash/str9x.s @@ -0,0 +1,54 @@ +/*************************************************************************** + * Copyright (C) 2010 by Spencer Oliver * + * sp...@sp... * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + + .text + .arm + .section .init +/* + r0 source address (in) + r1 target address (in) + r2 word count (in) + r3 result (out) +*/ + +write: + bic r4, r1, #3 /* word address */ + mov r3, #0x40 /* write command */ + strh r3, [r4, #0] + ldrh r3, [r0], #2 /* read data */ + strh r3, [r1], #2 /* write data */ + mov r3, #0x70 /* status command */ + strh r3, [r4, #0] +busy: + ldrb r3, [r4, #0] /* status */ + tst r3, #0x80 + beq busy + mov r5, #0x50 /* clear status command */ + strh r5, [r4, #0] + mov r5, #0xFF /* read array */ + strh r5, [r4, #0] + tst r3, #0x12 + bne exit + subs r2, r2, #1 /* decremment word count */ + bne write +exit: + bkpt #0 + + .end ----------------------------------------------------------------------- Summary of changes: contrib/loaders/README | 33 +++++ .../dcc_stdio.h => loaders/checksum/armv4_5_crc.s} | 47 +++++-- .../dcc_stdio.h => loaders/checksum/armv7m_crc.s} | 55 +++++++-- .../nuc910.h => contrib/loaders/checksum/mips32.s | 78 +++++++----- contrib/loaders/flash/pic32mx.s | 131 ++++++++++++++++++++ .../loaders/flash/stellaris.s | 60 ++++++--- .../{libdcc/dcc_stdio.h => loaders/flash/stm32x.s} | 43 +++++-- .../arm7tdmi.h => contrib/loaders/flash/str7x.s | 48 ++++++-- .../arm7tdmi.h => contrib/loaders/flash/str9x.s | 47 +++++-- src/flash/nor/pic32mx.c | 2 + src/flash/nor/stellaris.c | 2 + src/flash/nor/stm32x.c | 3 + src/flash/nor/str7x.c | 2 + src/flash/nor/str9x.c | 2 + src/target/armv4_5.c | 2 + src/target/armv7m.c | 2 + src/target/mips32.c | 2 + 17 files changed, 446 insertions(+), 113 deletions(-) create mode 100644 contrib/loaders/README copy contrib/{libdcc/dcc_stdio.h => loaders/checksum/armv4_5_crc.s} (71%) copy contrib/{libdcc/dcc_stdio.h => loaders/checksum/armv7m_crc.s} (70%) copy src/flash/nand/nuc910.h => contrib/loaders/checksum/mips32.s (60%) create mode 100644 contrib/loaders/flash/pic32mx.s copy src/target/mips32_dmaacc.h => contrib/loaders/flash/stellaris.s (66%) copy contrib/{libdcc/dcc_stdio.h => loaders/flash/stm32x.s} (71%) copy src/target/arm7tdmi.h => contrib/loaders/flash/str7x.s (61%) copy src/target/arm7tdmi.h => contrib/loaders/flash/str9x.s (66%) hooks/post-receive -- Main OpenOCD repository |
From: Øyvind H. <go...@us...> - 2010-10-28 08:58:28
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 53228fbc2e61fd39f45a43e4be54e0121e608714 (commit) from 2ff1adfa79853dde77fe2698dd83e34b116daacc (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 53228fbc2e61fd39f45a43e4be54e0121e608714 Author: Ãyvind Harboe <oyv...@zy...> Date: Thu Oct 28 08:34:41 2010 +0200 imx31pdk: use rclk w/1MHz fallback measure_clk indicates ca. 3-4MHz, so 1MHz should be safe. Added self_test proc used to test that rclk worked. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/tcl/board/imx31pdk.cfg b/tcl/board/imx31pdk.cfg index 4dfa4db..502d407 100644 --- a/tcl/board/imx31pdk.cfg +++ b/tcl/board/imx31pdk.cfg @@ -3,6 +3,23 @@ source [find target/imx31.cfg] source [find target/imx.cfg] $_TARGETNAME configure -event reset-init { imx31pdk_init } +proc self_test {} { + echo "Running 100 iterations of test." + dump_image /ram/test 0x80000000 0x40000 + for {set i 0} {$i < 100} {set i [expr $i+1]} { + echo "Iteration $i" + reset init + mww 0x80000000 0x12345678 0x10000 + load_image /ram/test 0x80000000 bin + verify_image /ram/test 0x80000000 bin + } +} + + +# Slow fallback frequency +# measure_clk indicates ca. 3-4MHz. +jtag_rclk 1000 + proc imx31pdk_init { } { imx3x_reset ----------------------------------------------------------------------- Summary of changes: tcl/board/imx31pdk.cfg | 17 +++++++++++++++++ 1 files changed, 17 insertions(+), 0 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Øyvind H. <go...@us...> - 2010-10-27 08:51:27
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 2ff1adfa79853dde77fe2698dd83e34b116daacc (commit) from f176278e98536981a212c0cfcee75ec94ab2c158 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 2ff1adfa79853dde77fe2698dd83e34b116daacc Author: Ãyvind Harboe <oyv...@zy...> Date: Wed Oct 27 08:37:54 2010 +0200 help: help now works on configuration commands help would not show help for commands when the command interpreter was in the wrong mode, which means that e.g. "help newtap" didn't work, it wouldn't show the "jtag newtap" help as it was a configuration command. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/helper/command.c b/src/helper/command.c index 1bd8c42..6762ad4 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -956,9 +956,6 @@ static void command_help_show_wrap(const char *str, unsigned n, unsigned n2) static COMMAND_HELPER(command_help_show, struct command *c, unsigned n, bool show_help, const char *match) { - if (!command_can_run(CMD_CTX, c)) - return ERROR_OK; - char *cmd_name = command_name(c, ' '); if (NULL == cmd_name) return -ENOMEM; ----------------------------------------------------------------------- Summary of changes: src/helper/command.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Øyvind H. <go...@us...> - 2010-10-25 08:05:47
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via f176278e98536981a212c0cfcee75ec94ab2c158 (commit) via e7d26173fcd41640a85b9e315868768d7f297cda (commit) from 1ceb2c7e7ac1014d25d1544b44f59404e636ef5c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit f176278e98536981a212c0cfcee75ec94ab2c158 Author: Peter Stuge <pe...@st...> Date: Sun Oct 24 16:28:48 2010 +0200 Make systesetreq typos read sysresetreq instead Signed-off-by: Peter Stuge <pe...@st...> diff --git a/src/target/cortex_m3.c b/src/target/cortex_m3.c index 3011b59..3f080f1 100644 --- a/src/target/cortex_m3.c +++ b/src/target/cortex_m3.c @@ -2127,7 +2127,7 @@ COMMAND_HANDLER(handle_cortex_m3_reset_config_command) if (CMD_ARGC > 0) { - if (strcmp(*CMD_ARGV, "systesetreq") == 0) + if (strcmp(*CMD_ARGV, "sysresetreq") == 0) cortex_m3->soft_reset_config = CORTEX_M3_RESET_SYSRESETREQ; else if (strcmp(*CMD_ARGV, "vectreset") == 0) cortex_m3->soft_reset_config = CORTEX_M3_RESET_VECTRESET; diff --git a/tcl/target/stellaris.cfg b/tcl/target/stellaris.cfg index bfe9087..e206a9c 100644 --- a/tcl/target/stellaris.cfg +++ b/tcl/target/stellaris.cfg @@ -80,7 +80,7 @@ $_TARGETNAME configure -event reset-start { set device_class [expr (([mrw 0x400fe000] >> 16) & 0xff)] if {$device_class == 0 || $device_class == 1 || $device_class == 3} { # Sandstorm, Fury and DustDevil are able to use NVIC SYSRESETREQ - cortex_m3 reset_config systesetreq + cortex_m3 reset_config sysresetreq } else { # Tempest and newer default to using NVIC VECTRESET # this does mean a reset-init event handler is required to reset commit e7d26173fcd41640a85b9e315868768d7f297cda Author: Peter Stuge <pe...@st...> Date: Sun Oct 24 16:28:47 2010 +0200 Remove srst_pulls_trst from LPC1768 target srst_pulls_trst may be true on some (broken) LPC1768 boards but is not true in general for the LPC1768. Signed-off-by: Peter Stuge <pe...@st...> diff --git a/tcl/target/lpc1768.cfg b/tcl/target/lpc1768.cfg index 68b33c4..2059aed 100644 --- a/tcl/target/lpc1768.cfg +++ b/tcl/target/lpc1768.cfg @@ -32,9 +32,6 @@ if { [info exists CPUTAPID ] } { adapter_nsrst_delay 200 jtag_ntrst_delay 200 -# LPC2000 & LPC1700 -> SRST causes TRST -reset_config srst_pulls_trst - #jtag newtap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID swj_newdap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID ----------------------------------------------------------------------- Summary of changes: src/target/cortex_m3.c | 2 +- tcl/target/lpc1768.cfg | 3 --- tcl/target/stellaris.cfg | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Øyvind H. <go...@us...> - 2010-10-25 08:03:02
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 1ceb2c7e7ac1014d25d1544b44f59404e636ef5c (commit) via d4de14dafe43f264b9490b543b9cd50a1345fe9e (commit) from ed44447e3dfe69084b9960b844c326746681e539 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 1ceb2c7e7ac1014d25d1544b44f59404e636ef5c Author: Michal Demin <mic...@gm...> Date: Fri Oct 22 23:26:43 2010 +0200 buspirate: change handling of communication speed setting + create serial port open function Signed-off-by: Michal Demin <mic...@gm...> diff --git a/src/jtag/drivers/buspirate.c b/src/jtag/drivers/buspirate.c index 85b76ed..13819ba 100644 --- a/src/jtag/drivers/buspirate.c +++ b/src/jtag/drivers/buspirate.c @@ -108,7 +108,8 @@ static void buspirate_jtag_set_feature(int, char, char); static void buspirate_jtag_get_adcs(int); /* low level HW communication interface */ -static int buspirate_serial_setspeed(int fd, speed_t speed); +static int buspirate_serial_open(char *port); +static int buspirate_serial_setspeed(int fd, char speed); static int buspirate_serial_write(int fd, char *buf, int size); static int buspirate_serial_read(int fd, char *buf, int size); static void buspirate_serial_close(int fd); @@ -215,13 +216,13 @@ static int buspirate_init(void) return ERROR_JTAG_INIT_FAILED; } - buspirate_fd = open(buspirate_port, O_RDWR | O_NOCTTY); + buspirate_fd = buspirate_serial_open(buspirate_port); if (buspirate_fd == -1) { LOG_ERROR("Could not open serial port."); return ERROR_JTAG_INIT_FAILED; } - buspirate_serial_setspeed(buspirate_fd, B115200); + buspirate_serial_setspeed(buspirate_fd, SERIAL_NORMAL); buspirate_jtag_enable(buspirate_fd); @@ -770,7 +771,6 @@ static void buspirate_jtag_set_speed(int fd, char speed) int ret; char tmp[2]; char ack[2]; - speed_t baudrate = B115200; ack[0] = 0xAA; ack[1] = 0x55; @@ -780,10 +780,7 @@ static void buspirate_jtag_set_speed(int fd, char speed) buspirate_jtag_command(fd, tmp, 2); /* here the adapter changes speed, we need follow */ - if (speed == SERIAL_FAST) - baudrate = B1000000; - - buspirate_serial_setspeed(fd, baudrate); + buspirate_serial_setspeed(fd, speed); buspirate_serial_write(fd, ack, 2); ret = buspirate_serial_read(fd, tmp, 2); @@ -873,15 +870,23 @@ static unsigned char buspirate_jtag_command(int fd, /* low level serial port */ /* TODO add support for WIN32 and others ! */ -static int buspirate_serial_setspeed(int fd, speed_t speed) +static int buspirate_serial_open(char *port) +{ + int fd; + fd = open(buspirate_port, O_RDWR | O_NOCTTY | O_NDELAY); + return fd; +} + +static int buspirate_serial_setspeed(int fd, char speed) { struct termios t_opt; + speed_t baud = (speed == SERIAL_FAST) ? B1000000 : B115200; /* set the serial port parameters */ fcntl(fd, F_SETFL, 0); tcgetattr(fd, &t_opt); - cfsetispeed(&t_opt, speed); - cfsetospeed(&t_opt, speed); + cfsetispeed(&t_opt, baud); + cfsetospeed(&t_opt, baud); t_opt.c_cflag |= (CLOCAL | CREAD); t_opt.c_cflag &= ~PARENB; t_opt.c_cflag &= ~CSTOPB; commit d4de14dafe43f264b9490b543b9cd50a1345fe9e Author: Michal Demin <mic...@gm...> Date: Fri Oct 22 21:06:31 2010 +0200 buspirate: Serial port was not correctly closed. Signed-off-by: Michal Demin <mic...@gm...> diff --git a/src/jtag/drivers/buspirate.c b/src/jtag/drivers/buspirate.c index e5f8fb6..85b76ed 100644 --- a/src/jtag/drivers/buspirate.c +++ b/src/jtag/drivers/buspirate.c @@ -111,6 +111,7 @@ static void buspirate_jtag_get_adcs(int); static int buspirate_serial_setspeed(int fd, speed_t speed); static int buspirate_serial_write(int fd, char *buf, int size); static int buspirate_serial_read(int fd, char *buf, int size); +static void buspirate_serial_close(int fd); static void buspirate_print_buffer(char *buf, int size); static int buspirate_speed(int speed) @@ -247,6 +248,9 @@ static int buspirate_quit(void) buspirate_jtag_set_speed(buspirate_fd, SERIAL_NORMAL); buspirate_jtag_reset(buspirate_fd); + + buspirate_serial_close(buspirate_fd); + if (buspirate_port) { free(buspirate_port); buspirate_port = NULL; @@ -941,6 +945,11 @@ static int buspirate_serial_read(int fd, char *buf, int size) return len; } +static void buspirate_serial_close(int fd) +{ + close(fd); +} + #define LINE_SIZE 81 #define BYTES_PER_LINE 16 static void buspirate_print_buffer(char *buf, int size) ----------------------------------------------------------------------- Summary of changes: src/jtag/drivers/buspirate.c | 36 +++++++++++++++++++++++++----------- 1 files changed, 25 insertions(+), 11 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Øyvind H. <go...@us...> - 2010-10-12 11:30:09
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via ed44447e3dfe69084b9960b844c326746681e539 (commit) via 2ee47b22c6228b80c5a8f1e74209cbf7ad53f775 (commit) from e3773e3e3d1f1ee0dbb0b69e8babe8419784d1c1 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit ed44447e3dfe69084b9960b844c326746681e539 Author: Antonio Borneo <bor...@gm...> Date: Tue Oct 12 16:47:24 2010 +0800 TARGET: review handle_load_image_command() Collect variable definitions. Report syntax error to command dispatcher. Propagate error when unable to open file. Signed-off-by: Antonio Borneo <bor...@gm...> diff --git a/src/target/target.c b/src/target/target.c index 3c85502..6edc239 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -2596,33 +2596,25 @@ COMMAND_HANDLER(handle_load_image_command) COMMAND_HANDLER(handle_dump_image_command) { struct fileio fileio; - uint8_t buffer[560]; - int retvaltemp; - - + int retval, retvaltemp; + uint32_t address, size; + struct duration bench; struct target *target = get_current_target(CMD_CTX); if (CMD_ARGC != 3) - { - command_print(CMD_CTX, "usage: dump_image <filename> <address> <size>"); - return ERROR_OK; - } + return ERROR_COMMAND_SYNTAX_ERROR; - uint32_t address; COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], address); - uint32_t size; COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], size); - if (fileio_open(&fileio, CMD_ARGV[0], FILEIO_WRITE, FILEIO_BINARY) != ERROR_OK) - { - return ERROR_OK; - } + retval = fileio_open(&fileio, CMD_ARGV[0], FILEIO_WRITE, FILEIO_BINARY); + if (retval != ERROR_OK) + return retval; - struct duration bench; duration_start(&bench); - int retval = ERROR_OK; + retval = ERROR_OK; while (size > 0) { size_t size_written; commit 2ee47b22c6228b80c5a8f1e74209cbf7ad53f775 Author: Antonio Borneo <bor...@gm...> Date: Tue Oct 12 16:08:35 2010 +0800 TARGET: fix segfault in handle_dump_image_command() The struct fileio is used after fileio_close(). Move fileio_close() after last usage. Signed-off-by: Antonio Borneo <bor...@gm...> diff --git a/src/target/target.c b/src/target/target.c index 82cbbff..3c85502 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -2643,9 +2643,6 @@ COMMAND_HANDLER(handle_dump_image_command) address += this_run_size; } - if ((retvaltemp = fileio_close(&fileio)) != ERROR_OK) - return retvaltemp; - if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK)) { int filesize; @@ -2657,6 +2654,9 @@ COMMAND_HANDLER(handle_dump_image_command) duration_elapsed(&bench), duration_kbps(&bench, filesize)); } + if ((retvaltemp = fileio_close(&fileio)) != ERROR_OK) + return retvaltemp; + return retval; } ----------------------------------------------------------------------- Summary of changes: src/target/target.c | 30 +++++++++++------------------- 1 files changed, 11 insertions(+), 19 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: David B. <dbr...@us...> - 2010-10-10 23:42:41
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via e3773e3e3d1f1ee0dbb0b69e8babe8419784d1c1 (commit) from 3864da1ab817acab24c41366d627da9337a7993d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit e3773e3e3d1f1ee0dbb0b69e8babe8419784d1c1 Author: David Brownell <dbr...@us...> Date: Sun Oct 10 14:41:11 2010 -0700 swj-dp.tcl (SWD infrastructure #1) Provide new helper proc that can set up either an SWD or JTAG DAP based on the transport which is in use -- mostly for SWJ-DP. Also update some SWJ-DP based chips/targets to use it. The goal is making SWD-vs-JTAG transparent in most places. SWJ-DP based chips really need this flexible configuration to cope with debug adapters that support different transports, without needing new target configs for each transport or adapter. For JTAG-DP, callers will use "jtag newtap" directly, as today; only one chip-level transport option exists. For SW-DP (e.g. LPC1[13]xx or EFM32, they'll use "swd newdap" directly (part of an upcoming SWD transport patch). Again, only one transport option exists, so hard-wiring is appropriate there. Signed-off-by: David Brownell <dbr...@us...> diff --git a/tcl/target/lpc1768.cfg b/tcl/target/lpc1768.cfg index 4a1ff0b..68b33c4 100644 --- a/tcl/target/lpc1768.cfg +++ b/tcl/target/lpc1768.cfg @@ -1,5 +1,9 @@ # NXP LPC1768 Cortex-M3 with 512kB Flash and 32kB+32kB Local On-Chip SRAM, +# LPC17xx chips support both JTAG and SWD transports. +# Adapt based on what transport is active. +source [find target/swj-dp.tcl] + if { [info exists CHIPNAME] } { set _CHIPNAME $CHIPNAME } else { @@ -31,7 +35,8 @@ jtag_ntrst_delay 200 # LPC2000 & LPC1700 -> SRST causes TRST reset_config srst_pulls_trst -jtag newtap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID +#jtag newtap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID +swj_newdap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID set _TARGETNAME $_CHIPNAME.cpu target create $_TARGETNAME cortex_m3 -chain-position $_TARGETNAME diff --git a/tcl/target/stellaris.cfg b/tcl/target/stellaris.cfg index b663ce3..bfe9087 100644 --- a/tcl/target/stellaris.cfg +++ b/tcl/target/stellaris.cfg @@ -1,5 +1,12 @@ # TI/Luminary Stellaris LM3S chip family +# Luminary chips support both JTAG and SWD transports. +# Adapt based on what transport is active. +source [find target/swj-dp.tcl] + +# For now we ignore the SPI and UART options, which +# are usable only for ISP style initial flash programming. + if { [info exists CHIPNAME] } { set _CHIPNAME $CHIPNAME } else { @@ -18,6 +25,12 @@ if { [info exists CPUTAPID ] } { set _CPUTAPID 0x0ba00477 } +# SWD DAP, and JTAG TAP, take same params for now; +# ... even though SWD ignores all except TAPID, and +# JTAG shouldn't need anything more then irlen. (and TAPID). +swj_newdap $_CHIPNAME cpu -irlen 4 -irmask 0xf \ + -expected-id $_CPUTAPID -ignore-version + if { [info exists WORKAREASIZE ] } { set _WORKAREASIZE $WORKAREASIZE } else { diff --git a/tcl/target/swj-dp.tcl b/tcl/target/swj-dp.tcl new file mode 100644 index 0000000..377b7b5 --- /dev/null +++ b/tcl/target/swj-dp.tcl @@ -0,0 +1,25 @@ +# ARM Debug Interface V5 (ADI_V5) utility +# ... Mostly for SWJ-DP (not SW-DP or JTAG-DP, since +# SW-DP and JTAG-DP targets don't need to switch based +# on which transport is active. +# +# declare a JTAG or SWD Debug Access Point (DAP) +# based on the transport in use with this session. +# You can't access JTAG ops when SWD is active, etc. + +# params are currently what "jtag newtap" uses +# because OpenOCD internals are still strongly biased +# to JTAG .... but for SWD, "irlen" etc are ignored, +# and the internals work differently + +# for now, ignore non-JTAG and non-SWD transports +# (e.g. initial flash programming via SPI or UART) + +# split out "chip" and "tag" so we can someday handle +# them more uniformly irlen too...) + +proc swj_newdap {chip tag args} { +set tran [transport select] +if [string equal $tran "jtag"] { eval jtag newtap $chip $tag $args} +if [string equal $tran "swd"] { eval swd newdap $chip $tag $args } +} ----------------------------------------------------------------------- Summary of changes: tcl/target/lpc1768.cfg | 7 ++++++- tcl/target/stellaris.cfg | 13 +++++++++++++ tcl/target/swj-dp.tcl | 25 +++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletions(-) create mode 100644 tcl/target/swj-dp.tcl hooks/post-receive -- Main OpenOCD repository |
From: David B. <dbr...@us...> - 2010-10-10 23:29:59
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 3864da1ab817acab24c41366d627da9337a7993d (commit) from 6229e438dd548ae75f9d26e2ea8cbf070ce27e5f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 3864da1ab817acab24c41366d627da9337a7993d Author: David Brownell <dbr...@us...> Date: Sun Oct 10 14:27:35 2010 -0700 add JLINK protocol doc ref Provide URL for a recent version of JLINK protocol. Signed-Off-By: David Brownell <dbr...@us...> diff --git a/src/jtag/drivers/jlink.c b/src/jtag/drivers/jlink.c index 52f12b4..ff389e9 100644 --- a/src/jtag/drivers/jlink.c +++ b/src/jtag/drivers/jlink.c @@ -32,6 +32,9 @@ /* See Segger's public documentation: * Reference manual for J-Link USB Protocol * Document RM08001-R6 Date: June 16, 2009 + * (Or newer, with some SWD information). + +http://www.segger.com/cms/admin/uploads/productDocs/RM08001_JLinkUSBProtocol.pdf */ #define VID 0x1366 ----------------------------------------------------------------------- Summary of changes: src/jtag/drivers/jlink.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Spencer O. <nt...@us...> - 2010-10-05 18:00:52
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 6229e438dd548ae75f9d26e2ea8cbf070ce27e5f (commit) from ebe431879d26ca5c85021c80e18af7f91f09fa38 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 6229e438dd548ae75f9d26e2ea8cbf070ce27e5f Author: Spencer Oliver <nt...@us...> Date: Tue Oct 5 16:29:37 2010 +0100 build: remove warn_unused_result errors Remove any build errors for strtol when building release version of openocd. Signed-off-by: Spencer Oliver <nt...@us...> diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 74dec63..222af47 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -2410,7 +2410,7 @@ static int gdb_target_add_one(struct target *target) * then we increment the port number for the next target. */ char *end; - strtol(gdb_port_next, &end, 0); + portnumber = strtol(gdb_port_next, &end, 0); if (!*end) { if (parse_long(gdb_port_next, &portnumber) == ERROR_OK) diff --git a/src/server/server.c b/src/server/server.c index 01d91d3..1feb744 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -200,7 +200,7 @@ int add_service(char *name, const char *port, int max_connections, new_connectio } else { char *end; - strtol(c->port, &end, 0); + portnumber = strtol(c->port, &end, 0); if (!*end && (parse_long(c->port, &portnumber) == ERROR_OK)) { c->portnumber = portnumber; ----------------------------------------------------------------------- Summary of changes: src/server/gdb_server.c | 2 +- src/server/server.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Spencer O. <nt...@us...> - 2010-10-05 16:57:38
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via ebe431879d26ca5c85021c80e18af7f91f09fa38 (commit) from 7e4cf8db585841985115a6835d403613487993a2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit ebe431879d26ca5c85021c80e18af7f91f09fa38 Author: Spencer Oliver <nt...@us...> Date: Tue Oct 5 15:00:40 2010 +0100 gdbderver: fix gdb pipe startup overflow When usng gdb pipes we need to keep openocd output at a minimum, otherwise the gdb stdin will overflow and fail. Make the calls to gdb_port and log_output synchronous to stop this. Signed-off-by: Spencer Oliver <nt...@us...> diff --git a/src/helper/options.c b/src/helper/options.c index df4676d..f8db2cd 100644 --- a/src/helper/options.c +++ b/src/helper/options.c @@ -104,13 +104,13 @@ static void add_default_dirs(void) const char *home = getenv("HOME"); - if (home) + if (home) { char *path; path = alloc_printf("%s/.openocd", home); - if (path) + if (path) { add_script_search_dir(path); free(path); @@ -178,8 +178,10 @@ int parse_cmdline_args(struct command_context *cmd_ctx, int argc, char *argv[]) } break; case 'p': + /* to replicate the old syntax this needs to be synchronous + * otherwise the gdb stdin will overflow with the warning message */ + command_run_line(cmd_ctx, "gdb_port pipe; log_output openocd.log"); LOG_WARNING("deprecated option: -p/--pipe. Use '-c \"gdb_port pipe; log_output openocd.log\"' instead."); - add_config_command("gdb_port pipe; log_output openocd.log"); break; } } ----------------------------------------------------------------------- Summary of changes: src/helper/options.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Spencer O. <nt...@us...> - 2010-10-04 21:36:36
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 7e4cf8db585841985115a6835d403613487993a2 (commit) via 45de3b1fbe875de7ed322d76bb517bdb48e20a5a (commit) from d543aa01480f1b54041f98707102622308252e11 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 7e4cf8db585841985115a6835d403613487993a2 Author: Spencer Oliver <nt...@us...> Date: Mon Oct 4 20:35:33 2010 +0100 gdbserver: fix gdb_port memory leak Signed-off-by: Spencer Oliver <nt...@us...> diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 5180902..74dec63 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -2466,8 +2466,10 @@ COMMAND_HANDLER(handle_gdb_sync_command) COMMAND_HANDLER(handle_gdb_port_command) { int retval = CALL_COMMAND_HANDLER(server_pipe_command, &gdb_port); - if (ERROR_OK == retval) + if (ERROR_OK == retval) { + free((void*)gdb_port_next); gdb_port_next = strdup(gdb_port); + } return retval; } commit 45de3b1fbe875de7ed322d76bb517bdb48e20a5a Author: Spencer Oliver <nt...@us...> Date: Mon Oct 4 20:34:47 2010 +0100 server: fix server pipe windows support commit 50d5441e2a615fb2c44b41a777e4373901f7a2e6 caused native windows build to fail. Firstly this patch fixes the build issue, but it also disables support for named pipes under Windows. Windows does not support posix named pipes. A cross-platfom access layer will need creating before support can be enabled again. Signed-off-by: Spencer Oliver <nt...@us...> diff --git a/src/server/server.c b/src/server/server.c index c7e1e40..01d91d3 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -90,6 +90,11 @@ static int add_connection(struct service *service, struct command_context *cmd_c c->fd = service->fd; c->fd_out = fileno(stdout); +#ifdef _WIN32 + /* we are using stdin/out so ignore ctrl-c under windoze */ + SetConsoleCtrlHandler(NULL, TRUE); +#endif + /* do not check for new connections again on stdin */ service->fd = -1; @@ -268,6 +273,12 @@ int add_service(char *name, const char *port, int max_connections, new_connectio } else if (c->type == CONNECTION_PIPE) { +#ifdef _WIN32 + /* we currenty do not support named pipes under win32 + * so exit openocd for now */ + LOG_ERROR("Named pipes currently not supported under this os"); + exit(1); +#else /* Pipe we're reading from */ c->fd = open(c->port, O_RDONLY | O_NONBLOCK); if (c->fd == -1) @@ -275,6 +286,7 @@ int add_service(char *name, const char *port, int max_connections, new_connectio LOG_ERROR("could not open %s", c->port); exit(1); } +#endif } /* add to the end of linked list */ @@ -526,16 +538,8 @@ int server_preinit(void) exit(-1); } - if (server_use_pipes == 0) - { - /* register ctrl-c handler */ - SetConsoleCtrlHandler(ControlHandler, TRUE); - } - else - { - /* we are using pipes so ignore ctrl-c */ - SetConsoleCtrlHandler(NULL, TRUE); - } + /* register ctrl-c handler */ + SetConsoleCtrlHandler(ControlHandler, TRUE); signal(SIGINT, sig_handler); signal(SIGTERM, sig_handler); ----------------------------------------------------------------------- Summary of changes: src/server/gdb_server.c | 4 +++- src/server/server.c | 24 ++++++++++++++---------- 2 files changed, 17 insertions(+), 11 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Øyvind H. <go...@us...> - 2010-10-01 16:30:10
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via d543aa01480f1b54041f98707102622308252e11 (commit) from 96a56ba086ec94e577e4b3562010710abb2087c6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit d543aa01480f1b54041f98707102622308252e11 Author: Ãyvind Harboe <oyv...@zy...> Date: Sun Sep 5 21:20:15 2010 +0200 zy1000: add : port number syntax for tftp filing system Allows using non-standard port number. Default to port 69. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/ecosboard.c b/src/ecosboard.c index f6e040f..26313b4 100644 --- a/src/ecosboard.c +++ b/src/ecosboard.c @@ -1277,6 +1277,7 @@ struct Tftp cyg_uint8 *mem; int actual; char *server; + int port; char *file; }; @@ -1333,6 +1334,15 @@ static int tftpfs_open(cyg_mtab_entry *mte, cyg_dir dir, const char *name, strncpy(tftp->server, name, server - name); tftp->server[server - name] = 0; + tftp->port = 0; /* default port 69 */ + char *port; + port = strchr(tftp->server, ':'); + if (port != NULL) + { + tftp->port = atoi(port + 1); + *port = 0; + } + tftp->file = strdup(server + 1); if (tftp->file == NULL) { @@ -1350,7 +1360,7 @@ static int fetchTftp(struct Tftp *tftp) if (!tftp->readFile) { int err; - tftp->actual = tftp_client_get(tftp->file, tftp->server, 0, tftp->mem, + tftp->actual = tftp_client_get(tftp->file, tftp->server, tftp->port, tftp->mem, tftpMaxSize, TFTP_OCTET, &err); if (tftp->actual < 0) ----------------------------------------------------------------------- Summary of changes: src/ecosboard.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Øyvind H. <go...@us...> - 2010-10-01 10:29:43
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 96a56ba086ec94e577e4b3562010710abb2087c6 (commit) via 50d5441e2a615fb2c44b41a777e4373901f7a2e6 (commit) via 6c137a2fc0bf53b9c0b8eda51e6f5361552b0112 (commit) via cb2dba2c1257e0aa80edc9a171a9c5cd7b2822f8 (commit) via 5a41435e45ae18c0823780382c214fb7324dbe7d (commit) via a60a57d8ed1cb28de1eca0e2d6d78d70bd873663 (commit) via d623832685a20d8283ccfd5ede5185a48a256883 (commit) from fb7235f12ad9590ac28f7fa8147c3ade4ce8b460 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 96a56ba086ec94e577e4b3562010710abb2087c6 Author: Ãyvind Harboe <oyv...@zy...> Date: Mon Sep 27 22:55:30 2010 +0200 pipes: add documentation for pipes Stick with the name "gdb_port" even if this command can be used for other things(disable, named pipes, anonymous stdin/out pipe). "port" is correct for probably more than 90% of use cases, if not more. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/doc/openocd.texi b/doc/openocd.texi index 77a0ad3..5387082 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -1910,12 +1910,29 @@ use the command line @option{-pipe} option. @deffn {Command} gdb_port [number] @cindex GDB server -Specify or query the first port used for incoming GDB connections. -The GDB port for the -first target will be gdb_port, the second target will listen on gdb_port + 1, and so on. +Normally gdb listens to a TCP/IP port, but GDB can also +communicate via pipes(stdin/out or named pipes). The name +"gdb_port" stuck because it covers probably more than 90% of +the normal use cases. + +No arguments reports GDB port. "pipe" means listen to stdin +output to stdout, an integer is base port number, "disable" +disables the gdb server. + +When using "pipe", also use log_output to redirect the log +output to a file so as not to flood the stdin/out pipes. + +The -p/--pipe option is deprecated and a warning is printed +as it is equivalent to passing in -c "gdb_port pipe; log_output openocd.log". + +Any other string is interpreted as named pipe to listen to. +Output pipe is the same name as input pipe, but with 'o' appended, +e.g. /var/gdb, /var/gdbo. + +The GDB port for the first target will be the base port, the +second target will listen on gdb_port + 1, and so on. When not specified during the configuration stage, the port @var{number} defaults to 3333. -When specified as zero, GDB remote access ports are not activated. @end deffn @deffn {Command} tcl_port [number] @@ -1925,7 +1942,7 @@ output from the Tcl engine. Intended as a machine interface. When not specified during the configuration stage, the port @var{number} defaults to 6666. -When specified as zero, this port is not activated. + @end deffn @deffn {Command} telnet_port [number] diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 7026ff2..5180902 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -2545,9 +2545,13 @@ static const struct command_registration gdb_command_handlers[] = { .name = "gdb_port", .handler = handle_gdb_port_command, .mode = COMMAND_ANY, - .help = "Display or specify base port on which to listen " - "for incoming GDB connections. " - "No arguments reports GDB port; zero disables.", + .help = "Normally gdb listens to a TCP/IP port. Each subsequent GDB " + "server listens for the next port number after the " + "base port number specified. " + "No arguments reports GDB port. \"pipe\" means listen to stdin " + "output to stdout, an integer is base port number, \"disable\" disables " + "port. Any other string is are interpreted as named pipe to listen to. " + "Output pipe is the same name as input pipe, but with 'o' appended.", .usage = "[port_num]", }, { diff --git a/src/server/tcl_server.c b/src/server/tcl_server.c index 613eb23..1671086 100644 --- a/src/server/tcl_server.c +++ b/src/server/tcl_server.c @@ -183,7 +183,7 @@ static const struct command_registration tcl_command_handlers[] = { .mode = COMMAND_CONFIG, .help = "Specify port on which to listen " "for incoming Tcl syntax. " - "No arguments reports Tcl port; zero disables.", + "Read help on 'gdb_port'.", .usage = "[port_num]", }, COMMAND_REGISTRATION_DONE diff --git a/src/server/telnet_server.c b/src/server/telnet_server.c index 00b4b5d..98e8616 100644 --- a/src/server/telnet_server.c +++ b/src/server/telnet_server.c @@ -619,7 +619,7 @@ static const struct command_registration telnet_command_handlers[] = { .mode = COMMAND_ANY, .help = "Specify port on which to listen " "for incoming telnet connections. " - "No arguments reports telnet port; zero disables.", + "Read help on 'gdb_port'.", .usage = "[port_num]", }, COMMAND_REGISTRATION_DONE commit 50d5441e2a615fb2c44b41a777e4373901f7a2e6 Author: Ãyvind Harboe <oyv...@zy...> Date: Mon Sep 27 08:50:49 2010 +0200 server: add support for pipes -p/--pipe is now deprecated. Use '-c "gdb_port pipe;log_output openocd.log"' instead. Warning logged. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/doc/openocd.texi b/doc/openocd.texi index 230e47c..77a0ad3 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -574,7 +574,6 @@ bash$ openocd --help --debug | -d set debug level <0-3> --log_output | -l redirect log output to file <name> --command | -c run <command> ---pipe | -p use pipes when talking to gdb @end verbatim If you don't give any @option{-f} or @option{-c} options, @@ -7052,11 +7051,12 @@ This would cause GDB to connect to the gdbserver on the local pc using port 3333 @item A pipe connection is typically started as follows: @example -target remote | openocd --pipe +target remote | openocd -c "gdb_port pipe; log_output openocd.log" @end example This would cause GDB to run OpenOCD and communicate using pipes (stdin/stdout). Using this method has the advantage of GDB starting/stopping OpenOCD for the debug -session. +session. log_output sends the log output to a file to ensure that the pipe is +not saturated when using higher debug level outputs. @end enumerate To list the available OpenOCD commands type @command{monitor help} on the diff --git a/src/helper/options.c b/src/helper/options.c index 3a95df4..df4676d 100644 --- a/src/helper/options.c +++ b/src/helper/options.c @@ -2,7 +2,7 @@ * Copyright (C) 2004, 2005 by Dominic Rath * * Dom...@gm... * * * - * Copyright (C) 2007,2008 Ãyvind Harboe * + * Copyright (C) 2007-2010 Ãyvind Harboe * * oyv...@zy... * * * * This program is free software; you can redistribute it and/or modify * @@ -177,13 +177,9 @@ int parse_cmdline_args(struct command_context *cmd_ctx, int argc, char *argv[]) add_config_command(optarg); } break; - case 'p': /* --pipe | -p */ -#if BUILD_ECOSBOARD == 1 - /* pipes unsupported on hosted platforms */ - LOG_WARNING("pipes not supported on this platform"); -#else - server_use_pipes = 1; -#endif + case 'p': + LOG_WARNING("deprecated option: -p/--pipe. Use '-c \"gdb_port pipe; log_output openocd.log\"' instead."); + add_config_command("gdb_port pipe; log_output openocd.log"); break; } } @@ -198,7 +194,6 @@ int parse_cmdline_args(struct command_context *cmd_ctx, int argc, char *argv[]) LOG_OUTPUT("--debug | -d\tset debug level <0-3>\n"); LOG_OUTPUT("--log_output | -l\tredirect log output to file <name>\n"); LOG_OUTPUT("--command | -c\trun <command>\n"); - LOG_OUTPUT("--pipe | -p\tuse pipes for gdb communication\n"); exit(-1); } diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 5489958..7026ff2 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -2387,42 +2387,22 @@ static int gdb_input(struct connection *connection) return ERROR_OK; } -static int gdb_target_start(struct target *target, uint16_t port) +static int gdb_target_start(struct target *target, const char *port) { - bool use_pipes = 0 == port; struct gdb_service *gdb_service = malloc(sizeof(struct gdb_service)); if (NULL == gdb_service) return -ENOMEM; gdb_service->target = target; - add_service("gdb", use_pipes ? CONNECTION_PIPE : CONNECTION_TCP, + return add_service("gdb", port, 1, &gdb_new_connection, &gdb_input, &gdb_connection_closed, gdb_service); - - const char *name = target_name(target); - if (use_pipes) - LOG_DEBUG("gdb service for target '%s' using pipes", name); - else - LOG_DEBUG("gdb service for target '%s' on TCP port %u", name, port); - return ERROR_OK; } static int gdb_target_add_one(struct target *target) { - long portnumber_parsed; - /* If we can parse the port number - * then we increment the port number for the next target. - */ - char *end_parse; - portnumber_parsed = strtol(gdb_port_next, &end_parse, 0); - if (!*end_parse) - { - LOG_ERROR("Illegal port number"); - return ERROR_FAIL; - } - - int retval = gdb_target_start(target, portnumber_parsed); + int retval = gdb_target_start(target, gdb_port_next); if (retval == ERROR_OK) { long portnumber; diff --git a/src/server/server.c b/src/server/server.c index 435ddbb..c7e1e40 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -45,9 +45,6 @@ static struct service *services = NULL; /* shutdown_openocd == 1: exit the main event loop, and quit the debugger */ static int shutdown_openocd = 0; -/* set when using pipes rather than tcp */ -int server_use_pipes = 0; - static int add_connection(struct service *service, struct command_context *cmd_ctx) { socklen_t address_size; @@ -80,7 +77,7 @@ static int add_connection(struct service *service, struct command_context *cmd_c (char *)&flag, /* the cast is historical cruft */ sizeof(int)); /* length of option value */ - LOG_INFO("accepting '%s' connection from %i", service->name, service->port); + LOG_INFO("accepting '%s' connection from %s", service->name, service->port); if ((retval = service->new_connection(c)) != ERROR_OK) { close_socket(c->fd); @@ -88,8 +85,7 @@ static int add_connection(struct service *service, struct command_context *cmd_c free(c); return retval; } - } - else if (service->type == CONNECTION_PIPE) + } else if (service->type == CONNECTION_STDINOUT) { c->fd = service->fd; c->fd_out = fileno(stdout); @@ -97,10 +93,29 @@ static int add_connection(struct service *service, struct command_context *cmd_c /* do not check for new connections again on stdin */ service->fd = -1; + LOG_INFO("accepting '%s' connection from pipe", service->name); + if ((retval = service->new_connection(c)) != ERROR_OK) + { + LOG_ERROR("attempted '%s' connection rejected", service->name); + free(c); + return retval; + } + } else if (service->type == CONNECTION_PIPE) + { + c->fd = service->fd; /* do not check for new connections again on stdin */ service->fd = -1; - LOG_INFO("accepting '%s' connection from pipe", service->name); + char * out_file = alloc_printf("%so", service->port); + c->fd_out = open(out_file, O_WRONLY); + free(out_file); + if (c->fd_out == -1) + { + LOG_ERROR("could not open %s", service->port); + exit(1); + } + + LOG_INFO("accepting '%s' connection from pipe %s", service->name, service->port); if ((retval = service->new_connection(c)) != ERROR_OK) { LOG_ERROR("attempted '%s' connection rejected", service->name); @@ -130,7 +145,14 @@ static int remove_connection(struct service *service, struct connection *connect { service->connection_closed(c); if (service->type == CONNECTION_TCP) + { close_socket(c->fd); + } else if (service->type == CONNECTION_PIPE) + { + /* The service will listen to the pipe again */ + c->service->fd = c->fd; + } + command_done(c->cmd_ctx); /* delete connection */ @@ -148,7 +170,8 @@ static int remove_connection(struct service *service, struct connection *connect return ERROR_OK; } -int add_service(char *name, enum connection_type type, unsigned short port, int max_connections, new_connection_handler_t new_connection_handler, input_handler_t input_handler, connection_closed_handler_t connection_closed_handler, void *priv) +/* FIX! make service return error instead of invoking exit() */ +int add_service(char *name, const char *port, int max_connections, new_connection_handler_t new_connection_handler, input_handler_t input_handler, connection_closed_handler_t connection_closed_handler, void *priv) { struct service *c, **p; int so_reuseaddr_option = 1; @@ -156,9 +179,8 @@ int add_service(char *name, enum connection_type type, unsigned short port, int c = malloc(sizeof(struct service)); c->name = strdup(name); - c->type = type; - c->port = port; - c->max_connections = max_connections; + c->port = strdup(port); + c->max_connections = 1; /* Only TCP/IP ports can support more than one connection */ c->fd = -1; c->connections = NULL; c->new_connection = new_connection_handler; @@ -166,9 +188,28 @@ int add_service(char *name, enum connection_type type, unsigned short port, int c->connection_closed = connection_closed_handler; c->priv = priv; c->next = NULL; + long portnumber; + if (strcmp(c->port, "pipe") == 0) + { + c->type = CONNECTION_STDINOUT; + } else + { + char *end; + strtol(c->port, &end, 0); + if (!*end && (parse_long(c->port, &portnumber) == ERROR_OK)) + { + c->portnumber = portnumber; + c->type = CONNECTION_TCP; + } else + { + c->type = CONNECTION_PIPE; + } + } - if (type == CONNECTION_TCP) + if (c->type == CONNECTION_TCP) { + c->max_connections = max_connections; + if ((c->fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) { LOG_ERROR("error creating socket: %s", strerror(errno)); @@ -182,7 +223,7 @@ int add_service(char *name, enum connection_type type, unsigned short port, int memset(&c->sin, 0, sizeof(c->sin)); c->sin.sin_family = AF_INET; c->sin.sin_addr.s_addr = INADDR_ANY; - c->sin.sin_port = htons(port); + c->sin.sin_port = htons(c->portnumber); if (bind(c->fd, (struct sockaddr *)&c->sin, sizeof(c->sin)) == -1) { @@ -209,7 +250,7 @@ int add_service(char *name, enum connection_type type, unsigned short port, int exit(-1); } } - else if (type == CONNECTION_PIPE) + else if (c->type == CONNECTION_STDINOUT) { c->fd = fileno(stdin); @@ -225,10 +266,15 @@ int add_service(char *name, enum connection_type type, unsigned short port, int socket_nonblock(c->fd); #endif } - else + else if (c->type == CONNECTION_PIPE) { - LOG_ERROR("unknown connection type: %d", type); - exit(1); + /* Pipe we're reading from */ + c->fd = open(c->port, O_RDONLY | O_NONBLOCK); + if (c->fd == -1) + { + LOG_ERROR("could not open %s", c->port); + exit(1); + } } /* add to the end of linked list */ @@ -238,29 +284,6 @@ int add_service(char *name, enum connection_type type, unsigned short port, int return ERROR_OK; } -int add_service_pipe(char *name, const char *port, int max_connections, - new_connection_handler_t new_connection_handler, input_handler_t input_handler, - connection_closed_handler_t connection_closed_handler, void *priv) -{ - enum connection_type type = CONNECTION_TCP; - long portnumber; - char *end; - strtol(port, &end, 0); - if (!*end) - { - if ((parse_long(port, &portnumber) == ERROR_OK) && (portnumber == 0)) - { - type = CONNECTION_PIPE; - } - } else - { - LOG_ERROR("Illegal port number %s", port); - return ERROR_FAIL; - } - return add_service(name, type, portnumber, max_connections, new_connection_handler, - input_handler, connection_closed_handler, priv); -} - static int remove_services(void) { struct service *c = services; @@ -278,6 +301,8 @@ static int remove_services(void) if (c->fd != -1) close(c->fd); } + if (c->port) + free((void *)c->port); if (c->priv) free(c->priv); diff --git a/src/server/server.h b/src/server/server.h index 2c9ed44..face138 100644 --- a/src/server/server.h +++ b/src/server/server.h @@ -35,7 +35,8 @@ enum connection_type { CONNECTION_TCP, - CONNECTION_PIPE + CONNECTION_PIPE, + CONNECTION_STDINOUT }; struct connection @@ -58,7 +59,8 @@ struct service { char *name; enum connection_type type; - unsigned short port; + const char *port; + unsigned short portnumber; int fd; struct sockaddr_in sin; int max_connections; @@ -70,12 +72,7 @@ struct service struct service *next; }; -int add_service(char *name, enum connection_type type, unsigned short port, - int max_connections, new_connection_handler_t new_connection_handler, - input_handler_t in_handler, connection_closed_handler_t close_handler, - void *priv); - -int add_service_pipe(char *name, const char *port, +int add_service(char *name, const char *port, int max_connections, new_connection_handler_t new_connection_handler, input_handler_t in_handler, connection_closed_handler_t close_handler, void *priv); @@ -115,8 +112,6 @@ SERVER_PIPE_COMMAND(); SERVER_PORT_COMMAND(); -extern int server_use_pipes; - #define ERROR_SERVER_REMOTE_CLOSED (-400) #define ERROR_CONNECTION_REJECTED (-401) diff --git a/src/server/tcl_server.c b/src/server/tcl_server.c index f82cafe..613eb23 100644 --- a/src/server/tcl_server.c +++ b/src/server/tcl_server.c @@ -166,7 +166,7 @@ int tcl_init(void) return ERROR_OK; } - return add_service_pipe("tcl", tcl_port, 1, + return add_service("tcl", tcl_port, 1, &tcl_new_connection, &tcl_input, &tcl_closed, NULL); } diff --git a/src/server/telnet_server.c b/src/server/telnet_server.c index 420f5d7..00b4b5d 100644 --- a/src/server/telnet_server.c +++ b/src/server/telnet_server.c @@ -592,9 +592,7 @@ int telnet_init(char *banner) telnet_service->banner = banner; - add_service_pipe("telnet", telnet_port, 1, telnet_new_connection, telnet_input, telnet_connection_closed, telnet_service); - - return ERROR_OK; + return add_service("telnet", telnet_port, 1, telnet_new_connection, telnet_input, telnet_connection_closed, telnet_service); } /* daemon configuration command telnet_port */ commit 6c137a2fc0bf53b9c0b8eda51e6f5361552b0112 Author: Ãyvind Harboe <oyv...@zy...> Date: Mon Sep 27 08:48:31 2010 +0200 server: specify port as a string This will allow switching to using named pipes. Split this out as a seperate commit to make changes easier to follow. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 170dadc..5489958 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -80,8 +80,8 @@ static int gdb_breakpoint_override; static enum breakpoint_type gdb_breakpoint_override_type; static int gdb_error(struct connection *connection, int retval); -static unsigned short gdb_port = 3333; -static unsigned short gdb_port_next = 0; +static const char *gdb_port; +static const char *gdb_port_next; static const char DIGITS[16] = "0123456789abcdef"; static void gdb_log_callback(void *priv, const char *file, unsigned line, @@ -2410,32 +2410,37 @@ static int gdb_target_start(struct target *target, uint16_t port) static int gdb_target_add_one(struct target *target) { - if (gdb_port == 0 && server_use_pipes == 0) - { - LOG_INFO("gdb port disabled"); - return ERROR_OK; - } - if (0 == gdb_port_next) - gdb_port_next = gdb_port; - - bool use_pipes = server_use_pipes; - static bool server_started_with_pipes = false; - if (server_started_with_pipes) + long portnumber_parsed; + /* If we can parse the port number + * then we increment the port number for the next target. + */ + char *end_parse; + portnumber_parsed = strtol(gdb_port_next, &end_parse, 0); + if (!*end_parse) { - LOG_WARNING("gdb service permits one target when using pipes"); - if (0 == gdb_port) - return ERROR_OK; - - use_pipes = false; + LOG_ERROR("Illegal port number"); + return ERROR_FAIL; } - int e = gdb_target_start(target, use_pipes ? 0 : gdb_port_next); - if (ERROR_OK == e) + int retval = gdb_target_start(target, portnumber_parsed); + if (retval == ERROR_OK) { - server_started_with_pipes |= use_pipes; - gdb_port_next++; + long portnumber; + /* If we can parse the port number + * then we increment the port number for the next target. + */ + char *end; + strtol(gdb_port_next, &end, 0); + if (!*end) + { + if (parse_long(gdb_port_next, &portnumber) == ERROR_OK) + { + free((void *)gdb_port_next); + gdb_port_next = alloc_printf("%d", portnumber+1); + } + } } - return e; + return retval; } int gdb_target_add_all(struct target *target) @@ -2480,9 +2485,9 @@ COMMAND_HANDLER(handle_gdb_sync_command) /* daemon configuration command gdb_port */ COMMAND_HANDLER(handle_gdb_port_command) { - int retval = CALL_COMMAND_HANDLER(server_port_command, &gdb_port); + int retval = CALL_COMMAND_HANDLER(server_pipe_command, &gdb_port); if (ERROR_OK == retval) - gdb_port_next = gdb_port; + gdb_port_next = strdup(gdb_port); return retval; } @@ -2599,5 +2604,7 @@ static const struct command_registration gdb_command_handlers[] = { int gdb_register_commands(struct command_context *cmd_ctx) { + gdb_port = strdup("3333"); + gdb_port_next = strdup("3333"); return register_commands(cmd_ctx, NULL, gdb_command_handlers); } diff --git a/src/server/server.c b/src/server/server.c index 1c55663..435ddbb 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -238,6 +238,29 @@ int add_service(char *name, enum connection_type type, unsigned short port, int return ERROR_OK; } +int add_service_pipe(char *name, const char *port, int max_connections, + new_connection_handler_t new_connection_handler, input_handler_t input_handler, + connection_closed_handler_t connection_closed_handler, void *priv) +{ + enum connection_type type = CONNECTION_TCP; + long portnumber; + char *end; + strtol(port, &end, 0); + if (!*end) + { + if ((parse_long(port, &portnumber) == ERROR_OK) && (portnumber == 0)) + { + type = CONNECTION_PIPE; + } + } else + { + LOG_ERROR("Illegal port number %s", port); + return ERROR_FAIL; + } + return add_service(name, type, portnumber, max_connections, new_connection_handler, + input_handler, connection_closed_handler, priv); +} + static int remove_services(void) { struct service *c = services; @@ -250,6 +273,12 @@ static int remove_services(void) if (c->name) free(c->name); + if (c->type == CONNECTION_PIPE) + { + if (c->fd != -1) + close(c->fd); + } + if (c->priv) free(c->priv); @@ -591,3 +620,23 @@ SERVER_PORT_COMMAND() } return ERROR_OK; } + +SERVER_PIPE_COMMAND() +{ + switch (CMD_ARGC) { + case 0: + command_print(CMD_CTX, "%s", *out); + break; + case 1: + { + const char * t = strdup(CMD_ARGV[0]); + free((void *)*out); + *out = t; + break; + } + default: + return ERROR_INVALID_ARGUMENTS; + } + return ERROR_OK; +} + diff --git a/src/server/server.h b/src/server/server.h index 46188bb..2c9ed44 100644 --- a/src/server/server.h +++ b/src/server/server.h @@ -75,6 +75,11 @@ int add_service(char *name, enum connection_type type, unsigned short port, input_handler_t in_handler, connection_closed_handler_t close_handler, void *priv); +int add_service_pipe(char *name, const char *port, + int max_connections, new_connection_handler_t new_connection_handler, + input_handler_t in_handler, connection_closed_handler_t close_handler, + void *priv); + int server_preinit(void); int server_init(struct command_context *cmd_ctx); int server_quit(void); @@ -101,6 +106,10 @@ void openocd_sleep_postlude(void); * Call server_port like a normal COMMAND_HANDLER with an extra @a out parameter * to receive the specified port number. */ +#define SERVER_PIPE_COMMAND() \ + COMMAND_HELPER(server_pipe_command, const char **out) +SERVER_PIPE_COMMAND(); + #define SERVER_PORT_COMMAND() \ COMMAND_HELPER(server_port_command, unsigned short *out) diff --git a/src/server/tcl_server.c b/src/server/tcl_server.c index 7d84de7..f82cafe 100644 --- a/src/server/tcl_server.c +++ b/src/server/tcl_server.c @@ -35,7 +35,7 @@ struct tcl_connection { int tc_outerror; /* flag an output error */ }; -static unsigned short tcl_port = 6666; +static const char *tcl_port; /* handlers */ static int tcl_new_connection(struct connection *connection); @@ -160,23 +160,20 @@ static int tcl_closed(struct connection *connection) int tcl_init(void) { - int retval; - - if (tcl_port == 0) + if (strcmp(tcl_port, "disabled") == 0) { - LOG_INFO("tcl port disabled"); + LOG_INFO("tcl server disabled"); return ERROR_OK; } - retval = add_service("tcl", CONNECTION_TCP, tcl_port, 1, + return add_service_pipe("tcl", tcl_port, 1, &tcl_new_connection, &tcl_input, &tcl_closed, NULL); - return retval; } COMMAND_HANDLER(handle_tcl_port_command) { - return CALL_COMMAND_HANDLER(server_port_command, &tcl_port); + return CALL_COMMAND_HANDLER(server_pipe_command, &tcl_port); } static const struct command_registration tcl_command_handlers[] = { @@ -194,5 +191,6 @@ static const struct command_registration tcl_command_handlers[] = { int tcl_register_commands(struct command_context *cmd_ctx) { + tcl_port = strdup("6666"); return register_commands(cmd_ctx, NULL, tcl_command_handlers); } diff --git a/src/server/telnet_server.c b/src/server/telnet_server.c index ee8d3b1..420f5d7 100644 --- a/src/server/telnet_server.c +++ b/src/server/telnet_server.c @@ -30,7 +30,7 @@ #include "telnet_server.h" #include <target/target_request.h> -static unsigned short telnet_port = 4444; +static const char *telnet_port; static char *negotiate = "\xFF\xFB\x03" /* IAC WILL Suppress Go Ahead */ @@ -582,18 +582,17 @@ static int telnet_connection_closed(struct connection *connection) int telnet_init(char *banner) { - struct telnet_service *telnet_service = malloc(sizeof(struct telnet_service)); - - if (telnet_port == 0) + if (strcmp(telnet_port, "disabled") == 0) { - LOG_INFO("telnet port disabled"); - free(telnet_service); + LOG_INFO("telnet server disabled"); return ERROR_OK; } + struct telnet_service *telnet_service = malloc(sizeof(struct telnet_service)); + telnet_service->banner = banner; - add_service("telnet", CONNECTION_TCP, telnet_port, 1, telnet_new_connection, telnet_input, telnet_connection_closed, telnet_service); + add_service_pipe("telnet", telnet_port, 1, telnet_new_connection, telnet_input, telnet_connection_closed, telnet_service); return ERROR_OK; } @@ -601,7 +600,7 @@ int telnet_init(char *banner) /* daemon configuration command telnet_port */ COMMAND_HANDLER(handle_telnet_port_command) { - return CALL_COMMAND_HANDLER(server_port_command, &telnet_port); + return CALL_COMMAND_HANDLER(server_pipe_command, &telnet_port); } COMMAND_HANDLER(handle_exit_command) @@ -630,5 +629,6 @@ static const struct command_registration telnet_command_handlers[] = { int telnet_register_commands(struct command_context *cmd_ctx) { + telnet_port = strdup("4444"); return register_commands(cmd_ctx, NULL, telnet_command_handlers); } commit cb2dba2c1257e0aa80edc9a171a9c5cd7b2822f8 Author: Ãyvind Harboe <oyv...@zy...> Date: Mon Sep 27 09:24:51 2010 +0200 server: read/write now goes through connection fn's depending on whether the connection is over a socket or pipe, the read is done differently. pipes can return -1 when writing 0 bytes, make 0 byte writes a successful no-op. 0 byte writes falls out naturally of tcl server code. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 7343b87..170dadc 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -328,7 +328,7 @@ static int gdb_write(struct connection *connection, void *data, int len) if (gdb_con->closed) return ERROR_SERVER_REMOTE_CLOSED; - if (write_socket(connection->fd_out, data, len) == len) + if (connection_write(connection, data, len) == len) { return ERROR_OK; } diff --git a/src/server/server.c b/src/server/server.c index e67be13..1c55663 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -513,6 +513,33 @@ int server_quit(void) return ERROR_OK; } +int connection_write(struct connection *connection, const void *data, int len) +{ + if (len == 0) + { + /* successful no-op. Sockets and pipes behave differently here... */ + return 0; + } + if (connection->service->type == CONNECTION_TCP) + { + return write_socket(connection->fd_out, data, len); + } else + { + return write(connection->fd_out, data, len); + } +} + +int connection_read(struct connection *connection, void *data, int len) +{ + if (connection->service->type == CONNECTION_TCP) + { + return read_socket(connection->fd, data, len); + } else + { + return read(connection->fd, data, len); + } +} + /* tell the server we want to shut down */ COMMAND_HANDLER(handle_shutdown_command) { diff --git a/src/server/server.h b/src/server/server.h index b13baaa..46188bb 100644 --- a/src/server/server.h +++ b/src/server/server.h @@ -83,6 +83,9 @@ int server_loop(struct command_context *command_context); int server_register_commands(struct command_context *context); +int connection_write(struct connection *connection, const void *data, int len); +int connection_read(struct connection *connection, void *data, int len); + /** * Used by server_loop(), defined in server_stubs.c, httpd.c, or ecosboard.c */ diff --git a/src/server/tcl_server.c b/src/server/tcl_server.c index 9aaee5c..7d84de7 100644 --- a/src/server/tcl_server.c +++ b/src/server/tcl_server.c @@ -57,7 +57,7 @@ int tcl_output(struct connection *connection, const void *data, ssize_t len) if (tclc->tc_outerror) return ERROR_SERVER_REMOTE_CLOSED; - wlen = write_socket(connection->fd, data, len); + wlen = connection_write(connection, data, len); if (wlen == len) return ERROR_OK; @@ -92,7 +92,7 @@ static int tcl_input(struct connection *connection) struct tcl_connection *tclc; unsigned char in[256]; - rlen = read_socket(connection->fd, &in, sizeof(in)); + rlen = connection_read(connection, &in, sizeof(in)); if (rlen <= 0) { if (rlen < 0) LOG_ERROR("error during read: %s", strerror(errno)); diff --git a/src/server/telnet_server.c b/src/server/telnet_server.c index 92052ae..ee8d3b1 100644 --- a/src/server/telnet_server.c +++ b/src/server/telnet_server.c @@ -51,7 +51,7 @@ static int telnet_write(struct connection *connection, const void *data, if (t_con->closed) return ERROR_SERVER_REMOTE_CLOSED; - if (write_socket(connection->fd_out, data, len) == len) + if (connection_write(connection, data, len) == len) { return ERROR_OK; } @@ -204,7 +204,7 @@ static int telnet_input(struct connection *connection) struct telnet_connection *t_con = connection->priv; struct command_context *command_context = connection->cmd_ctx; - bytes_read = read_socket(connection->fd, buffer, TELNET_BUFFER_SIZE); + bytes_read = connection_read(connection, buffer, TELNET_BUFFER_SIZE); if (bytes_read == 0) return ERROR_SERVER_REMOTE_CLOSED; commit 5a41435e45ae18c0823780382c214fb7324dbe7d Author: Ãyvind Harboe <oyv...@zy...> Date: Mon Sep 27 08:26:31 2010 +0200 server: split file descriptors in in/out fd's pipes have different fd's for in/out. This makes the code more orthogonal and prepares for adding pipes. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 76c3e36..7343b87 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -176,7 +176,7 @@ static int gdb_get_char_inner(struct connection *connection, int* next_char) #endif for (;;) { - if (connection->service->type == CONNECTION_PIPE) + if (connection->service->type != CONNECTION_TCP) { gdb_con->buf_cnt = read(connection->fd, gdb_con->buffer, GDB_BUFFER_SIZE); } @@ -328,20 +328,9 @@ static int gdb_write(struct connection *connection, void *data, int len) if (gdb_con->closed) return ERROR_SERVER_REMOTE_CLOSED; - if (connection->service->type == CONNECTION_PIPE) + if (write_socket(connection->fd_out, data, len) == len) { - /* write to stdout */ - if (write(STDOUT_FILENO, data, len) == len) - { - return ERROR_OK; - } - } - else - { - if (write_socket(connection->fd, data, len) == len) - { - return ERROR_OK; - } + return ERROR_OK; } gdb_con->closed = 1; return ERROR_SERVER_REMOTE_CLOSED; diff --git a/src/server/server.c b/src/server/server.c index 3c85cd1..e67be13 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -57,6 +57,7 @@ static int add_connection(struct service *service, struct command_context *cmd_c c = malloc(sizeof(struct connection)); c->fd = -1; + c->fd_out = -1; memset(&c->sin, 0, sizeof(c->sin)); c->cmd_ctx = copy_command_context(cmd_ctx); c->service = service; @@ -69,6 +70,7 @@ static int add_connection(struct service *service, struct command_context *cmd_c address_size = sizeof(c->sin); c->fd = accept(service->fd, (struct sockaddr *)&service->sin, &address_size); + c->fd_out = c->fd; /* This increases performance dramatically for e.g. GDB load which * does not have a sliding window protocol. */ @@ -90,6 +92,10 @@ static int add_connection(struct service *service, struct command_context *cmd_c else if (service->type == CONNECTION_PIPE) { c->fd = service->fd; + c->fd_out = fileno(stdout); + + /* do not check for new connections again on stdin */ + service->fd = -1; /* do not check for new connections again on stdin */ service->fd = -1; @@ -205,8 +211,7 @@ int add_service(char *name, enum connection_type type, unsigned short port, int } else if (type == CONNECTION_PIPE) { - /* use stdin */ - c->fd = STDIN_FILENO; + c->fd = fileno(stdin); #ifdef _WIN32 /* for win32 set stdin/stdout to binary mode */ @@ -384,7 +389,7 @@ int server_loop(struct command_context *command_context) } else { - if (service->type != CONNECTION_PIPE) + if (service->type == CONNECTION_TCP) { struct sockaddr_in sin; socklen_t address_size = sizeof(sin); diff --git a/src/server/server.h b/src/server/server.h index a25920e..b13baaa 100644 --- a/src/server/server.h +++ b/src/server/server.h @@ -41,6 +41,7 @@ enum connection_type struct connection { int fd; + int fd_out; /* When using pipes we're writing to a different fd */ struct sockaddr_in sin; struct command_context *cmd_ctx; struct service *service; diff --git a/src/server/tcl_server.c b/src/server/tcl_server.c index 06f67ab..9aaee5c 100644 --- a/src/server/tcl_server.c +++ b/src/server/tcl_server.c @@ -58,6 +58,7 @@ int tcl_output(struct connection *connection, const void *data, ssize_t len) return ERROR_SERVER_REMOTE_CLOSED; wlen = write_socket(connection->fd, data, len); + if (wlen == len) return ERROR_OK; diff --git a/src/server/telnet_server.c b/src/server/telnet_server.c index 10caee3..92052ae 100644 --- a/src/server/telnet_server.c +++ b/src/server/telnet_server.c @@ -2,7 +2,7 @@ * Copyright (C) 2005 by Dominic Rath * * Dom...@gm... * * * - * Copyright (C) 2007,2008 Ãyvind Harboe * + * Copyright (C) 2007-2010 Ãyvind Harboe * * oyv...@zy... * * * * Copyright (C) 2008 by Spencer Oliver * @@ -51,7 +51,7 @@ static int telnet_write(struct connection *connection, const void *data, if (t_con->closed) return ERROR_SERVER_REMOTE_CLOSED; - if (write_socket(connection->fd, data, len) == len) + if (write_socket(connection->fd_out, data, len) == len) { return ERROR_OK; } commit a60a57d8ed1cb28de1eca0e2d6d78d70bd873663 Author: Ãyvind Harboe <oyv...@zy...> Date: Sun Sep 26 19:30:31 2010 +0200 server: rely on ctrl-c to stop openocd there was special support to support pressing 'x' to quit openocd. ctrl-c is sufficient. The main server loop is already complicated enough. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/server/server.c b/src/server/server.c index 7d8ad51..3c85cd1 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -2,7 +2,7 @@ * Copyright (C) 2005 by Dominic Rath * * Dom...@gm... * * * - * Copyright (C) 2007,2008 Ãyvind Harboe * + * Copyright (C) 2007-2010 Ãyvind Harboe * * oyv...@zy... * * * * Copyright (C) 2008 by Spencer Oliver * @@ -310,16 +310,6 @@ int server_loop(struct command_context *command_context) } } -#ifndef _WIN32 -#if BUILD_ECOSBOARD == 0 - if (server_use_pipes == 0) - { - /* add STDIN to read_fds */ - FD_SET(fileno(stdin), &read_fds); - } -#endif -#endif - struct timeval tv; tv.tv_sec = 0; if (poll_ok) @@ -434,21 +424,7 @@ int server_loop(struct command_context *command_context) } } -#ifndef _WIN32 -#if BUILD_ECOSBOARD == 0 - /* check for data on stdin if not using pipes */ - if (server_use_pipes == 0) - { - if (FD_ISSET(fileno(stdin), &read_fds)) - { - if (getc(stdin) == 'x') - { - shutdown_openocd = 1; - } - } - } -#endif -#else +#ifdef _WIN32 MSG msg; while (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { commit d623832685a20d8283ccfd5ede5185a48a256883 Author: Ãyvind Harboe <oyv...@zy...> Date: Sun Sep 26 18:24:36 2010 +0200 log: remove hack to redirect logs when pipes are in use There is an explicit command "log_output" that can be used to redirect log output to a file, no need for a hack in the first place. Before enabling pipes, use "log_output foo" to redirect log output to the "foo" files. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/helper/log.c b/src/helper/log.c index da227bd..b6fab01 100644 --- a/src/helper/log.c +++ b/src/helper/log.c @@ -2,7 +2,7 @@ * Copyright (C) 2005 by Dominic Rath * * Dom...@gm... * * * - * Copyright (C) 2007,2008 Ãyvind Harboe * + * Copyright (C) 2007-2010 Ãyvind Harboe * * oyv...@zy... * * * * Copyright (C) 2008 by Spencer Oliver * @@ -159,7 +159,7 @@ static void log_puts(enum log_levels level, const char *file, int line, const ch #endif string); } - else if (server_use_pipes == 0) + else { /* if we are using gdb through pipes then we do not want any output * to the pipe otherwise we get repeated strings */ @@ -241,21 +241,6 @@ COMMAND_HANDLER(handle_debug_level_command) else if (CMD_ARGC > 1) return ERROR_COMMAND_SYNTAX_ERROR; - if (debug_level >= LOG_LVL_DEBUG && server_use_pipes == 1) - { - /* if we are enabling debug info then we need to write to a - * log file otherwise the pipe will get full and cause issues - * with gdb - */ - FILE* file = fopen("openocd.log", "w"); - if (file) - { - log_output = file; - LOG_WARNING("enabling logfile output because " - "we are using pipes to talk to GDB."); - } - } - command_print(CMD_CTX, "debug_level: %i", debug_level); return ERROR_OK; ----------------------------------------------------------------------- Summary of changes: doc/openocd.texi | 33 +++++++-- src/helper/log.c | 19 +----- src/helper/options.c | 13 +--- src/server/gdb_server.c | 90 +++++++++-------------- src/server/server.c | 172 ++++++++++++++++++++++++++++++++------------ src/server/server.h | 18 ++++-- src/server/tcl_server.c | 21 +++--- src/server/telnet_server.c | 26 +++---- 8 files changed, 228 insertions(+), 164 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Zach W. <zw...@us...> - 2010-10-01 03:15:35
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via fb7235f12ad9590ac28f7fa8147c3ade4ce8b460 (commit) from 3931b99d142d337ea6558fd09aad2e0812c04507 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit fb7235f12ad9590ac28f7fa8147c3ade4ce8b460 Author: Luca Bruno <lu...@de...> Date: Mon Sep 27 16:21:04 2010 +0200 Update ep93xx and at91rm9200 drivers ep93xx and at91rm9200 are conditionally built only on arm and were not updated to reflect changes in command registration handler. This patch makes them properly compile again, fixing a build failure experienced on Debian armel. Signed-off-by: Luca Bruno <lu...@de...> Signed-off-by: Zachary T Welch <zw...@co...> diff --git a/src/jtag/drivers/at91rm9200.c b/src/jtag/drivers/at91rm9200.c index 89d7000..f7494fe 100644 --- a/src/jtag/drivers/at91rm9200.c +++ b/src/jtag/drivers/at91rm9200.c @@ -118,23 +118,9 @@ static void at91rm9200_write(int tck, int tms, int tdi); static void at91rm9200_reset(int trst, int srst); static int at91rm9200_speed(int speed); -static int at91rm9200_register_commands(struct command_context *cmd_ctx); static int at91rm9200_init(void); static int at91rm9200_quit(void); -struct jtag_interface at91rm9200_interface = -{ - .name = "at91rm9200", - - .supported = DEBUG_CAP_TMS_SEQ, - .execute_queue = bitbang_execute_queue, - - .speed = at91rm9200_speed, - .register_commands = at91rm9200_register_commands, - .init = at91rm9200_init, - .quit = at91rm9200_quit, -}; - static struct bitbang_interface at91rm9200_bitbang = { .read = at91rm9200_read, @@ -186,7 +172,7 @@ static int at91rm9200_speed(int speed) return ERROR_OK; } -static int at91rm9200_handle_device_command(struct command_context *cmd_ctx, char *cmd, char **CMD_ARGV, int argc) +COMMAND_HANDLER(at91rm9200_handle_device_command) { if (CMD_ARGC == 0) return ERROR_OK; @@ -208,12 +194,20 @@ static const struct command_registration at91rm9200_command_handlers[] = { .mode = COMMAND_CONFIG, .help = "query armjtagew info", }, + COMMAND_REGISTRATION_DONE }; -static int at91rm9200_register_commands(struct command_context *cmd_ctx) +struct jtag_interface at91rm9200_interface = { - return register_commands(cmd_ctx, NULL, at91rm9200_command_handlers); -} + .name = "at91rm9200", + + .execute_queue = bitbang_execute_queue, + + .speed = at91rm9200_speed, + .commands = at91rm9200_command_handlers, + .init = at91rm9200_init, + .quit = at91rm9200_quit, +}; static int at91rm9200_init(void) { diff --git a/src/jtag/drivers/ep93xx.c b/src/jtag/drivers/ep93xx.c index 0959a56..09312c5 100644 --- a/src/jtag/drivers/ep93xx.c +++ b/src/jtag/drivers/ep93xx.c @@ -47,7 +47,6 @@ static void ep93xx_write(int tck, int tms, int tdi); static void ep93xx_reset(int trst, int srst); static int ep93xx_speed(int speed); -static int ep93xx_register_commands(struct command_context *cmd_ctx); static int ep93xx_init(void); static int ep93xx_quit(void); @@ -61,7 +60,6 @@ struct jtag_interface ep93xx_interface = .execute_queue = bitbang_execute_queue, .speed = ep93xx_speed, - .register_commands = ep93xx_register_commands, .init = ep93xx_init, .quit = ep93xx_quit, }; @@ -123,12 +121,6 @@ static int ep93xx_speed(int speed) return ERROR_OK; } -static int ep93xx_register_commands(struct command_context *cmd_ctx) -{ - - return ERROR_OK; -} - static int set_gonk_mode(void) { void *syscon; ----------------------------------------------------------------------- Summary of changes: src/jtag/drivers/at91rm9200.c | 30 ++++++++++++------------------ src/jtag/drivers/ep93xx.c | 8 -------- 2 files changed, 12 insertions(+), 26 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Øyvind H. <go...@us...> - 2010-09-29 19:01:26
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 3931b99d142d337ea6558fd09aad2e0812c04507 (commit) from 3a693ef526575633cc350a69aa1a5d1f08e64c46 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 3931b99d142d337ea6558fd09aad2e0812c04507 Author: Ãyvind Harboe <oyv...@zy...> Date: Wed Sep 29 09:11:01 2010 +0200 fileio: fileio_size() can now fail Part of making the fileio API more robust. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/flash/mflash.c b/src/flash/mflash.c index 272127b..ba34422 100644 --- a/src/flash/mflash.c +++ b/src/flash/mflash.c @@ -720,14 +720,20 @@ COMMAND_HANDLER(mg_write_cmd) if (ret != ERROR_OK) return ret; + int filesize; buffer = malloc(MG_FILEIO_CHUNK); if (!buffer) { fileio_close(&fileio); return ERROR_FAIL; } + int retval = fileio_size(&fileio, &filesize); + if (retval != ERROR_OK) { + fileio_close(&fileio); + return retval; + } - cnt = fileio_size(&fileio) / MG_FILEIO_CHUNK; - res = fileio_size(&fileio) % MG_FILEIO_CHUNK; + cnt = filesize / MG_FILEIO_CHUNK; + res = filesize % MG_FILEIO_CHUNK; struct duration bench; duration_start(&bench); @@ -752,8 +758,8 @@ COMMAND_HANDLER(mg_write_cmd) if (duration_measure(&bench) == ERROR_OK) { command_print(CMD_CTX, "wrote %ld bytes from file %s " - "in %fs (%0.3f kB/s)", (long)fileio_size(&fileio), CMD_ARGV[1], - duration_elapsed(&bench), duration_kbps(&bench, fileio_size(&fileio))); + "in %fs (%0.3f kB/s)", (long)filesize, CMD_ARGV[1], + duration_elapsed(&bench), duration_kbps(&bench, filesize)); } free(buffer); diff --git a/src/flash/nand/fileio.c b/src/flash/nand/fileio.c index 0a006fc..c7515e2 100644 --- a/src/flash/nand/fileio.c +++ b/src/flash/nand/fileio.c @@ -180,7 +180,13 @@ COMMAND_HELPER(nand_fileio_parse_args, struct nand_fileio_state *state, return retval; if (!need_size) - state->size = fileio_size(&state->fileio); + { + int filesize; + retval = fileio_size(&state->fileio, &filesize); + if (retval != ERROR_OK) + return retval; + state->size = filesize; + } *dev = nand; diff --git a/src/flash/nand/tcl.c b/src/flash/nand/tcl.c index a54f8ea..15cf179 100644 --- a/src/flash/nand/tcl.c +++ b/src/flash/nand/tcl.c @@ -388,9 +388,14 @@ COMMAND_HANDLER(handle_nand_dump_command) if (nand_fileio_finish(&s) == ERROR_OK) { + int filesize; + retval = fileio_size(&s.fileio, &filesize); + if (retval != ERROR_OK) + return retval; + command_print(CMD_CTX, "dumped %ld bytes in %fs (%0.3f KiB/s)", - (long)fileio_size(&s.fileio), duration_elapsed(&s.bench), - duration_kbps(&s.bench, fileio_size(&s.fileio))); + (long)filesize, duration_elapsed(&s.bench), + duration_kbps(&s.bench, filesize)); } return ERROR_OK; } diff --git a/src/flash/nor/tcl.c b/src/flash/nor/tcl.c index f36ab7d..142f31f 100644 --- a/src/flash/nor/tcl.c +++ b/src/flash/nor/tcl.c @@ -604,9 +604,23 @@ COMMAND_HANDLER(handle_flash_write_bank_command) return ERROR_OK; } - buffer = malloc(fileio_size(&fileio)); + int filesize; + retval = fileio_size(&fileio, &filesize); + if (retval != ERROR_OK) + { + fileio_close(&fileio); + return retval; + } + + buffer = malloc(filesize); + if (buffer == NULL) + { + fileio_close(&fileio); + LOG_ERROR("Out of memory"); + return ERROR_FAIL; + } size_t buf_cnt; - if (fileio_read(&fileio, fileio_size(&fileio), buffer, &buf_cnt) != ERROR_OK) + if (fileio_read(&fileio, filesize, buffer, &buf_cnt) != ERROR_OK) { free(buffer); fileio_close(&fileio); @@ -622,8 +636,8 @@ COMMAND_HANDLER(handle_flash_write_bank_command) { command_print(CMD_CTX, "wrote %ld bytes from file %s to flash bank %u" " at offset 0x%8.8" PRIx32 " in %fs (%0.3f KiB/s)", - (long)fileio_size(&fileio), CMD_ARGV[1], p->bank_number, offset, - duration_elapsed(&bench), duration_kbps(&bench, fileio_size(&fileio))); + (long)filesize, CMD_ARGV[1], p->bank_number, offset, + duration_elapsed(&bench), duration_kbps(&bench, filesize)); } fileio_close(&fileio); diff --git a/src/helper/fileio.c b/src/helper/fileio.c index 7c862e4..9ae0134 100644 --- a/src/helper/fileio.c +++ b/src/helper/fileio.c @@ -245,8 +245,18 @@ int fileio_write_u32(struct fileio *fileio_p, uint32_t data) return retval; } -int fileio_size(struct fileio *fileio_p) +/** + * FIX!!!! + * + * For now this can not fail, but that's because a seek was executed + * on startup. + * + * Avoiding the seek on startup opens up for using streams. + * + */ +int fileio_size(struct fileio *fileio_p, int *size) { struct fileio_internal *fileio = fileio_p->fp; - return fileio->size; + *size = fileio->size; + return ERROR_OK; } diff --git a/src/helper/fileio.h b/src/helper/fileio.h index 40c4ef0..fa499ab 100644 --- a/src/helper/fileio.h +++ b/src/helper/fileio.h @@ -66,7 +66,7 @@ int fileio_write(struct fileio *fileio, int fileio_read_u32(struct fileio *fileio, uint32_t *data); int fileio_write_u32(struct fileio *fileio, uint32_t data); -int fileio_size(struct fileio *fileio); +int fileio_size(struct fileio *fileio, int *size); #define ERROR_FILEIO_LOCATION_UNKNOWN (-1200) #define ERROR_FILEIO_NOT_FOUND (-1201) diff --git a/src/target/etm.c b/src/target/etm.c index c71c5d1..9f7bc83 100644 --- a/src/target/etm.c +++ b/src/target/etm.c @@ -1897,7 +1897,15 @@ COMMAND_HANDLER(handle_etm_load_command) return ERROR_FAIL; } - if (fileio_size(&file) % 4) + int filesize; + int retval = fileio_size(&file, &filesize); + if (retval != ERROR_OK) + { + fileio_close(&file); + return retval; + } + + if (filesize % 4) { command_print(CMD_CTX, "size isn't a multiple of 4, no valid trace data"); fileio_close(&file); diff --git a/src/target/image.c b/src/target/image.c index e77e190..b0d957f 100644 --- a/src/target/image.c +++ b/src/target/image.c @@ -158,7 +158,13 @@ static int image_ihex_buffer_complete_inner(struct image *image, char *lpszLine, /* we can't determine the number of sections that we'll have to create ahead of time, * so we locally hold them until parsing is finished */ - ihex->buffer = malloc(fileio_size(fileio) >> 1); + int filesize; + int retval; + retval = fileio_size(fileio, &filesize); + if (retval != ERROR_OK) + return retval; + + ihex->buffer = malloc(filesize >> 1); cooked_bytes = 0x0; image->num_sections = 0; section[image->num_sections].private = &ihex->buffer[cooked_bytes]; @@ -537,7 +543,13 @@ static int image_mot_buffer_complete_inner(struct image *image, char *lpszLine, /* we can't determine the number of sections that we'll have to create ahead of time, * so we locally hold them until parsing is finished */ - mot->buffer = malloc(fileio_size(fileio) >> 1); + int retval; + int filesize; + retval = fileio_size(fileio, &filesize); + if (retval != ERROR_OK) + return retval; + + mot->buffer = malloc(filesize >> 1); cooked_bytes = 0x0; image->num_sections = 0; section[image->num_sections].private = &mot->buffer[cooked_bytes]; @@ -743,11 +755,18 @@ int image_open(struct image *image, const char *url, const char *type_string) { return retval; } + int filesize; + retval = fileio_size(&image_binary->fileio, &filesize); + if (retval != ERROR_OK) + { + fileio_close(&image_binary->fileio); + return retval; + } image->num_sections = 1; image->sections = malloc(sizeof(struct imagesection)); image->sections[0].base_address = 0x0; - image->sections[0].size = fileio_size(&image_binary->fileio); + image->sections[0].size = filesize; image->sections[0].flags = 0; } else if (image->type == IMAGE_IHEX) diff --git a/src/target/target.c b/src/target/target.c index fcdcc36..82cbbff 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -2648,9 +2648,13 @@ COMMAND_HANDLER(handle_dump_image_command) if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK)) { + int filesize; + retval = fileio_size(&fileio, &filesize); + if (retval != ERROR_OK) + return retval; command_print(CMD_CTX, - "dumped %ld bytes in %fs (%0.3f KiB/s)", (long)fileio_size(&fileio), - duration_elapsed(&bench), duration_kbps(&bench, fileio_size(&fileio))); + "dumped %ld bytes in %fs (%0.3f KiB/s)", (long)filesize, + duration_elapsed(&bench), duration_kbps(&bench, filesize)); } return retval; ----------------------------------------------------------------------- Summary of changes: src/flash/mflash.c | 14 ++++++++++---- src/flash/nand/fileio.c | 8 +++++++- src/flash/nand/tcl.c | 9 +++++++-- src/flash/nor/tcl.c | 22 ++++++++++++++++++---- src/helper/fileio.c | 14 ++++++++++++-- src/helper/fileio.h | 2 +- src/target/etm.c | 10 +++++++++- src/target/image.c | 25 ++++++++++++++++++++++--- src/target/target.c | 8 ++++++-- 9 files changed, 92 insertions(+), 20 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Øyvind H. <go...@us...> - 2010-09-29 08:47:10
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 3a693ef526575633cc350a69aa1a5d1f08e64c46 (commit) from ecad76061f6edff5db67ad05e6514dff6cd6efc7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 3a693ef526575633cc350a69aa1a5d1f08e64c46 Author: Ãyvind Harboe <oyv...@zy...> Date: Tue Sep 28 15:37:56 2010 +0200 fileio: refactor struct fileio to be an opaque structure Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/flash/mflash.c b/src/flash/mflash.c index 26b85b1..272127b 100644 --- a/src/flash/mflash.c +++ b/src/flash/mflash.c @@ -726,8 +726,8 @@ COMMAND_HANDLER(mg_write_cmd) return ERROR_FAIL; } - cnt = fileio.size / MG_FILEIO_CHUNK; - res = fileio.size % MG_FILEIO_CHUNK; + cnt = fileio_size(&fileio) / MG_FILEIO_CHUNK; + res = fileio_size(&fileio) % MG_FILEIO_CHUNK; struct duration bench; duration_start(&bench); @@ -752,8 +752,8 @@ COMMAND_HANDLER(mg_write_cmd) if (duration_measure(&bench) == ERROR_OK) { command_print(CMD_CTX, "wrote %ld bytes from file %s " - "in %fs (%0.3f kB/s)", (long)fileio.size, CMD_ARGV[1], - duration_elapsed(&bench), duration_kbps(&bench, fileio.size)); + "in %fs (%0.3f kB/s)", (long)fileio_size(&fileio), CMD_ARGV[1], + duration_elapsed(&bench), duration_kbps(&bench, fileio_size(&fileio))); } free(buffer); diff --git a/src/flash/nand/fileio.c b/src/flash/nand/fileio.c index 3e397eb..0a006fc 100644 --- a/src/flash/nand/fileio.c +++ b/src/flash/nand/fileio.c @@ -180,7 +180,7 @@ COMMAND_HELPER(nand_fileio_parse_args, struct nand_fileio_state *state, return retval; if (!need_size) - state->size = state->fileio.size; + state->size = fileio_size(&state->fileio); *dev = nand; diff --git a/src/flash/nand/tcl.c b/src/flash/nand/tcl.c index 57bbe00..a54f8ea 100644 --- a/src/flash/nand/tcl.c +++ b/src/flash/nand/tcl.c @@ -389,8 +389,8 @@ COMMAND_HANDLER(handle_nand_dump_command) if (nand_fileio_finish(&s) == ERROR_OK) { command_print(CMD_CTX, "dumped %ld bytes in %fs (%0.3f KiB/s)", - (long)s.fileio.size, duration_elapsed(&s.bench), - duration_kbps(&s.bench, s.fileio.size)); + (long)fileio_size(&s.fileio), duration_elapsed(&s.bench), + duration_kbps(&s.bench, fileio_size(&s.fileio))); } return ERROR_OK; } diff --git a/src/flash/nor/tcl.c b/src/flash/nor/tcl.c index 8604b4b..f36ab7d 100644 --- a/src/flash/nor/tcl.c +++ b/src/flash/nor/tcl.c @@ -604,9 +604,9 @@ COMMAND_HANDLER(handle_flash_write_bank_command) return ERROR_OK; } - buffer = malloc(fileio.size); + buffer = malloc(fileio_size(&fileio)); size_t buf_cnt; - if (fileio_read(&fileio, fileio.size, buffer, &buf_cnt) != ERROR_OK) + if (fileio_read(&fileio, fileio_size(&fileio), buffer, &buf_cnt) != ERROR_OK) { free(buffer); fileio_close(&fileio); @@ -622,8 +622,8 @@ COMMAND_HANDLER(handle_flash_write_bank_command) { command_print(CMD_CTX, "wrote %ld bytes from file %s to flash bank %u" " at offset 0x%8.8" PRIx32 " in %fs (%0.3f KiB/s)", - (long)fileio.size, CMD_ARGV[1], p->bank_number, offset, - duration_elapsed(&bench), duration_kbps(&bench, fileio.size)); + (long)fileio_size(&fileio), CMD_ARGV[1], p->bank_number, offset, + duration_elapsed(&bench), duration_kbps(&bench, fileio_size(&fileio))); } fileio_close(&fileio); diff --git a/src/helper/fileio.c b/src/helper/fileio.c index ba62397..7c862e4 100644 --- a/src/helper/fileio.c +++ b/src/helper/fileio.c @@ -31,7 +31,16 @@ #include "configuration.h" #include "fileio.h" -static inline int fileio_open_local(struct fileio *fileio) +struct fileio_internal { + const char *url; + ssize_t size; + enum fileio_type type; + enum fileio_access access; + FILE *file; +}; + +static inline int fileio_close_local(struct fileio_internal *fileio); +static inline int fileio_open_local(struct fileio_internal *fileio) { char file_access[4]; @@ -86,7 +95,7 @@ static inline int fileio_open_local(struct fileio *fileio) if ((fileio->size < 0)||(result < 0)||(result2 < 0)) { - fileio_close(fileio); + fileio_close_local(fileio); return ERROR_FILEIO_OPERATION_FAILED; } } @@ -98,10 +107,13 @@ static inline int fileio_open_local(struct fileio *fileio) return ERROR_OK; } -int fileio_open(struct fileio *fileio, const char *url, enum fileio_access access_type, enum fileio_type type) +int fileio_open(struct fileio *fileio_p, const char *url, enum fileio_access access_type, enum fileio_type type) { int retval = ERROR_OK; + struct fileio_internal *fileio = malloc(sizeof(struct fileio_internal)); + fileio_p->fp = fileio; + fileio->type = type; fileio->access = access_type; fileio->url = strdup(url); @@ -111,7 +123,7 @@ int fileio_open(struct fileio *fileio, const char *url, enum fileio_access acces return retval; } -static inline int fileio_close_local(struct fileio *fileio) +static inline int fileio_close_local(struct fileio_internal *fileio) { int retval; if ((retval = fclose(fileio->file)) != 0) @@ -131,21 +143,26 @@ static inline int fileio_close_local(struct fileio *fileio) return ERROR_OK; } -int fileio_close(struct fileio *fileio) +int fileio_close(struct fileio *fileio_p) { int retval; + struct fileio_internal *fileio = fileio_p->fp; retval = fileio_close_local(fileio); free((void*)fileio->url); fileio->url = NULL; + free(fileio); + fileio_p->fp = NULL; + return retval; } -int fileio_seek(struct fileio *fileio, size_t position) +int fileio_seek(struct fileio *fileio_p, size_t position) { int retval; + struct fileio_internal *fileio = fileio_p->fp; if ((retval = fseek(fileio->file, position, SEEK_SET)) != 0) { LOG_ERROR("couldn't seek file %s: %s", fileio->url, strerror(errno)); @@ -155,7 +172,7 @@ int fileio_seek(struct fileio *fileio, size_t position) return ERROR_OK; } -static int fileio_local_read(struct fileio *fileio, +static int fileio_local_read(struct fileio_internal *fileio, size_t size, void *buffer, size_t *size_read) { ssize_t retval = fread(buffer, 1, size, fileio->file); @@ -163,16 +180,18 @@ static int fileio_local_read(struct fileio *fileio, return (retval < 0) ? retval : ERROR_OK; } -int fileio_read(struct fileio *fileio, size_t size, void *buffer, +int fileio_read(struct fileio *fileio_p, size_t size, void *buffer, size_t *size_read) { + struct fileio_internal *fileio = fileio_p->fp; return fileio_local_read(fileio, size, buffer, size_read); } -int fileio_read_u32(struct fileio *fileio, uint32_t *data) +int fileio_read_u32(struct fileio *fileio_p, uint32_t *data) { uint8_t buf[4]; size_t size_read; + struct fileio_internal *fileio = fileio_p->fp; int retval = fileio_local_read(fileio, sizeof(uint32_t), buf, &size_read); if (ERROR_OK == retval && sizeof(uint32_t) != size_read) retval = -EIO; @@ -181,7 +200,7 @@ int fileio_read_u32(struct fileio *fileio, uint32_t *data) return retval; } -static int fileio_local_fgets(struct fileio *fileio, +static int fileio_local_fgets(struct fileio_internal *fileio, size_t size, void *buffer) { if (fgets(buffer, size, fileio->file) == NULL) @@ -190,12 +209,13 @@ static int fileio_local_fgets(struct fileio *fileio, return ERROR_OK; } -int fileio_fgets(struct fileio *fileio, size_t size, void *buffer) +int fileio_fgets(struct fileio *fileio_p, size_t size, void *buffer) { + struct fileio_internal *fileio = fileio_p->fp; return fileio_local_fgets(fileio, size, buffer); } -static int fileio_local_write(struct fileio *fileio, +static int fileio_local_write(struct fileio_internal *fileio, size_t size, const void *buffer, size_t *size_written) { ssize_t retval = fwrite(buffer, 1, size, fileio->file); @@ -203,24 +223,30 @@ static int fileio_local_write(struct fileio *fileio, return (retval < 0) ? retval : ERROR_OK; } -int fileio_write(struct fileio *fileio, +int fileio_write(struct fileio *fileio_p, size_t size, const void *buffer, size_t *size_written) { + struct fileio_internal *fileio = fileio_p->fp; int retval = fileio_local_write(fileio, size, buffer, size_written); if (retval == ERROR_OK) fileio->size += *size_written; return retval; } -int fileio_write_u32(struct fileio *fileio, uint32_t data) +int fileio_write_u32(struct fileio *fileio_p, uint32_t data) { uint8_t buf[4]; h_u32_to_be(buf, data); - size_t size_written; - int retval = fileio_write(fileio, 4, buf, &size_written); + int retval = fileio_write(fileio_p, 4, buf, &size_written); if (ERROR_OK == retval && size_written != sizeof(uint32_t)) retval = -EIO; return retval; } + +int fileio_size(struct fileio *fileio_p) +{ + struct fileio_internal *fileio = fileio_p->fp; + return fileio->size; +} diff --git a/src/helper/fileio.h b/src/helper/fileio.h index 597bafc..40c4ef0 100644 --- a/src/helper/fileio.h +++ b/src/helper/fileio.h @@ -46,12 +46,10 @@ enum fileio_access FILEIO_APPENDREAD, /* open for writing, position at end, allow reading */ }; -struct fileio { - const char *url; - ssize_t size; - enum fileio_type type; - enum fileio_access access; - FILE *file; +struct fileio +{ + /* The structure is opaque */ + struct fileio_internal *fp; }; int fileio_open(struct fileio *fileio, @@ -68,6 +66,7 @@ int fileio_write(struct fileio *fileio, int fileio_read_u32(struct fileio *fileio, uint32_t *data); int fileio_write_u32(struct fileio *fileio, uint32_t data); +int fileio_size(struct fileio *fileio); #define ERROR_FILEIO_LOCATION_UNKNOWN (-1200) #define ERROR_FILEIO_NOT_FOUND (-1201) diff --git a/src/target/etm.c b/src/target/etm.c index 9da6955..c71c5d1 100644 --- a/src/target/etm.c +++ b/src/target/etm.c @@ -1897,7 +1897,7 @@ COMMAND_HANDLER(handle_etm_load_command) return ERROR_FAIL; } - if (file.size % 4) + if (fileio_size(&file) % 4) { command_print(CMD_CTX, "size isn't a multiple of 4, no valid trace data"); fileio_close(&file); diff --git a/src/target/image.c b/src/target/image.c index d36fbc3..e77e190 100644 --- a/src/target/image.c +++ b/src/target/image.c @@ -158,7 +158,7 @@ static int image_ihex_buffer_complete_inner(struct image *image, char *lpszLine, /* we can't determine the number of sections that we'll have to create ahead of time, * so we locally hold them until parsing is finished */ - ihex->buffer = malloc(fileio->size >> 1); + ihex->buffer = malloc(fileio_size(fileio) >> 1); cooked_bytes = 0x0; image->num_sections = 0; section[image->num_sections].private = &ihex->buffer[cooked_bytes]; @@ -537,7 +537,7 @@ static int image_mot_buffer_complete_inner(struct image *image, char *lpszLine, /* we can't determine the number of sections that we'll have to create ahead of time, * so we locally hold them until parsing is finished */ - mot->buffer = malloc(fileio->size >> 1); + mot->buffer = malloc(fileio_size(fileio) >> 1); cooked_bytes = 0x0; image->num_sections = 0; section[image->num_sections].private = &mot->buffer[cooked_bytes]; @@ -747,7 +747,7 @@ int image_open(struct image *image, const char *url, const char *type_string) image->num_sections = 1; image->sections = malloc(sizeof(struct imagesection)); image->sections[0].base_address = 0x0; - image->sections[0].size = image_binary->fileio.size; + image->sections[0].size = fileio_size(&image_binary->fileio); image->sections[0].flags = 0; } else if (image->type == IMAGE_IHEX) diff --git a/src/target/target.c b/src/target/target.c index c37432a..fcdcc36 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -2649,8 +2649,8 @@ COMMAND_HANDLER(handle_dump_image_command) if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK)) { command_print(CMD_CTX, - "dumped %ld bytes in %fs (%0.3f KiB/s)", (long)fileio.size, - duration_elapsed(&bench), duration_kbps(&bench, fileio.size)); + "dumped %ld bytes in %fs (%0.3f KiB/s)", (long)fileio_size(&fileio), + duration_elapsed(&bench), duration_kbps(&bench, fileio_size(&fileio))); } return retval; ----------------------------------------------------------------------- Summary of changes: src/flash/mflash.c | 8 +++--- src/flash/nand/fileio.c | 2 +- src/flash/nand/tcl.c | 4 +- src/flash/nor/tcl.c | 8 +++--- src/helper/fileio.c | 58 ++++++++++++++++++++++++++++++++++------------- src/helper/fileio.h | 11 ++++----- src/target/etm.c | 2 +- src/target/image.c | 6 ++-- src/target/target.c | 4 +- 9 files changed, 64 insertions(+), 39 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Øyvind H. <go...@us...> - 2010-09-28 10:47:48
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via ecad76061f6edff5db67ad05e6514dff6cd6efc7 (commit) from 45e5d1d90acaff8cf57f694e70ec41ece9bddfcd (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit ecad76061f6edff5db67ad05e6514dff6cd6efc7 Author: Antonio Borneo <bor...@gm...> Date: Tue Sep 28 16:37:19 2010 +0800 TCL scripts: fix ocd_mem2array/mem2array In previous patch, I have introduced again the symbol "ocd_mem2array", now replaced by "mem2array". Fix the error. Signed-off-by: Antonio Borneo <bor...@gm...> diff --git a/tcl/mem_helper.tcl b/tcl/mem_helper.tcl index d811490..a3d92cb 100644 --- a/tcl/mem_helper.tcl +++ b/tcl/mem_helper.tcl @@ -3,7 +3,7 @@ # mrw: "memory read word", returns value of $reg proc mrw {reg} { set value "" - ocd_mem2array value 32 $reg 1 + mem2array value 32 $reg 1 return $value(0) } ----------------------------------------------------------------------- Summary of changes: tcl/mem_helper.tcl | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Øyvind H. <go...@us...> - 2010-09-27 22:25:31
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 45e5d1d90acaff8cf57f694e70ec41ece9bddfcd (commit) from 19167a7af6053f1eba0420509408731db007368c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 45e5d1d90acaff8cf57f694e70ec41ece9bddfcd Author: Ãyvind Harboe <oyv...@zy...> Date: Mon Sep 27 16:45:25 2010 +0200 flash: fix error handling memory leaks and missing check on memory allocation. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/flash/nor/core.c b/src/flash/nor/core.c index d200d8c..2c1d9de 100644 --- a/src/flash/nor/core.c +++ b/src/flash/nor/core.c @@ -601,7 +601,9 @@ int flash_write_unlock(struct target *target, struct image *image, /* find the corresponding flash bank */ retval = get_flash_bank_by_addr(target, run_address, false, &c); if (retval != ERROR_OK) - return retval; + { + goto done; + } if (c == NULL) { section++; /* and skip it */ @@ -653,7 +655,8 @@ int flash_write_unlock(struct target *target, struct image *image, if (run_address + run_size - 1 > c->base + c->size - 1) { LOG_ERROR("The image is too big for the flash"); - return ERROR_FAIL; + retval = ERROR_FAIL; + goto done; } /* If we're applying any sector automagic, then pad this @@ -679,6 +682,12 @@ int flash_write_unlock(struct target *target, struct image *image, /* allocate buffer */ buffer = malloc(run_size); + if (buffer == NULL) + { + LOG_ERROR("Out of memory for flash bank buffer"); + retval = ERROR_FAIL; + goto done; + } buffer_size = 0; /* read sections to the buffer */ ----------------------------------------------------------------------- Summary of changes: src/flash/nor/core.c | 13 +++++++++++-- 1 files changed, 11 insertions(+), 2 deletions(-) hooks/post-receive -- Main OpenOCD repository |