From 0fd67b9be905c74e3c83a07d6ddc5653a3e4dc7f Mon Sep 17 00:00:00 2001 From: ian Date: Wed, 4 Jan 2006 21:41:32 +0000 Subject: [PATCH] reorganise crashread to perhaps work following new panic reset mode --- detpic/crashread | 266 ++++++++++++++++++++++++----------------------- 1 file changed, 138 insertions(+), 128 deletions(-) diff --git a/detpic/crashread b/detpic/crashread index 61a276e..98841bc 100755 --- a/detpic/crashread +++ b/detpic/crashread @@ -1,14 +1,5 @@ #!/usr/bin/tclsh8.4 -set port [lindex $argv 0] -set map [lindex $argv 1] -set slave [lindex $argv 2] - -set m [open $map] -set block preable -set headings unknown -set inblk 3 - proc debug {s} { puts "$s" } proc manyset {list args} { @@ -29,126 +20,12 @@ proc wantlockind {lockind thing l} { default { error "unknown $thing lockind $lockind in $l" } } -while {[gets $m l] >= 0} { - if {![regexp {\S} $l]} { - set inblk 0 - set section unknown - set headings n/a - } elseif {$inblk==0 && [regexp {^\s+(\S.*\S)\s*$} $l dummy block]} { - incr inblk - } elseif {$inblk==1} { - set headings [string trim $l] - incr inblk - } elseif {$inblk==2 && [regexp {^[- \t]+$} $l]} { - incr inblk - } elseif {[inblk {^Section Info$} \ - {^Section\s+Type\s+Address\s+Location\s+Size\(Bytes\)$}]} { - manyset $l sec type addr lockind size - switch -exact $type code { continue } udata { } \ - default { error "unknown section type $type in $l" } - if {[wantlockind $lockind section $l]<=0} continue - set addr [format 0x%08x $addr] - lappend sections [list $addr $sec [format 0x%08x $size]] - } elseif {[inblk {^Symbols$} \ - {^Name\s+Address\s+Location\s+Storage\s+File$}]} { - manyset $l sym addr lockind storage file - if {![wantlockind $lockind symbol $l]} continue - switch -exact $storage { - extern { set sym [list {} $sym] } - static { - regexp {^(.*)\.asm$} $file dummy file - set sym [list $file: $sym] - } - default { error "unknown storage $storage in $l" } - } - set addr [format 0x%08x $addr] - if {[string compare $lockind data]} { - set sv symbolsbylockind($lockind) - } else { - set sv symbols - } - lappend $sv [list $addr $sym] - } elseif {$inblk==3} { - } else { - error "unknown $inblk <$block> <$headings> $l" - } -} - -set ok { - INTCON* FSR2* - OSCCON LVDCON WDTCON RCON - T1CON T2CON - SSPADD SSPSTAT SSPCON1 SSPCON2 - ADRESH ADRESL ADCON* - CCPR1* CCP1CON - ECCPR1* ECCP1DEL ECCPAS - CMCON CVRCON T3CON - SPBRG TXSTA RXSTA - EEADR EEDATA - IPR* PIR* PIE* - TRIS* LAT* -} - -set h [open /usr/share/gputils/header/p18f458.inc] -set section unknown -set lastaddr -1 -while {[gets $h l]>=0} { - if {[regexp {^\;\-\-+\s+(\S.*\S)\s+\-\-+$} $l dummy section]} { - continue - } elseif {![regexp {^Register Files$} $section]} { - continue - } elseif {[regexp -nocase \ - {^([a-z][a-z0-9]*)\s+equ\s+h\'0(f[0-9a-f]{2})\'\s*$} \ - $l dummy sym loc]} { - set addr [format 0x%08x 0x$loc] - foreach pat $ok { - if {[string match $pat $sym]} { - if {$addr != $lastaddr} { - lappend sections [list $addr =SFRs= 0x1] - set lastaddr $addr - } - lappend symbols [list $addr [list SFR $sym]] - } - } - } elseif {[regexp -nocase {^\;\s*reserved} $l]} { - } elseif {![regexp {\S} $l]} { - } else { - error "unknown <$section> $l" - } -} - -lappend symbols {0x00000060 {=udata,!acs=}} -#lappend symbols {0x00000f00 {=SFRs,!acs=}} -lappend symbols {0x00000f60 {=SFRs,acs= {}}} -lappend sections {0x00000f00 {=SFRs=} 0} -#lappend sections {0x00000060 {==========UDATA,!ACS===========} 0} -#lappend sections {0x00000f60 {==========SFRs,ACS===========} 0} - -lappend sections [list 0x1000 =END= 0] -foreach tosort {sections symbols symbolsbylockind(program)} { - set $tosort [lsort [set $tosort]] -} - proc addendlast {v ev evn} { upvar #0 $v syms lappend syms [list [lindex [lindex $syms end] 0] [list {} (lastsymbol)]] lappend syms [list [format 0x%08lx $ev] [list {} $evn]] } -addendlast symbolsbylockind(program) 0x8000 (end) - -set p [open $port {RDWR NONBLOCK} 0] -exec stty -F $port min 1 time 0 -istrip -ocrnl -onlcr -onocr -opost \ - -ctlecho -echo -echoe -echok -echonl -iexten -isig \ - -icanon -icrnl \ - 9600 clocal cread -crtscts -hup -parenb cs8 -cstopb \ - -ixoff bs0 cr0 ff0 nl0 -ofill -olcuc - -fconfigure $p -blocking yes -buffering none \ - -translation binary -encoding binary - -fconfigure stdout -buffering none - proc xmit {b} { global p #debug >xmit|$b< @@ -287,13 +164,146 @@ proc ms_reset {arg} { xmit 0x09 } -switch -exact [llength $argv].[lindex $argv 0] { - 1.--reset { ms_reset 0 } - 2.--reset { ms_reset [lindex $argv 1] } - 3. { } - default { error "need args: serial port, map file, picno" } +proc badusage {m} { + set m "bad usage: $m" + append m { +usage: .../crashread + pass `-1' for for test (data memory map) mode only + pass `reset' for to reset pics (then + should be or -) +} + error $m +} + +if {[llength $argv] != 3} { badusage "wrong # args" } + +set port [lindex $argv 0] +set map [lindex $argv 1] +set slave [lindex $argv 2] + +set p [open $port {RDWR NONBLOCK} 0] +exec stty -F $port min 1 time 0 -istrip -ocrnl -onlcr -onocr -opost \ + -ctlecho -echo -echoe -echok -echonl -iexten -isig \ + -icanon -icrnl \ + 9600 clocal cread -crtscts -hup -parenb cs8 -cstopb \ + -ixoff bs0 cr0 ff0 nl0 -ofill -olcuc + +fconfigure $p -blocking yes -buffering none \ + -translation binary -encoding binary + +fconfigure stdout -buffering none + +if {![string compare reset $map]} { + ms_reset $picno } +set m [open $map] +set block preable +set headings unknown +set inblk 3 + +while {[gets $m l] >= 0} { + if {![regexp {\S} $l]} { + set inblk 0 + set section unknown + set headings n/a + } elseif {$inblk==0 && [regexp {^\s+(\S.*\S)\s*$} $l dummy block]} { + incr inblk + } elseif {$inblk==1} { + set headings [string trim $l] + incr inblk + } elseif {$inblk==2 && [regexp {^[- \t]+$} $l]} { + incr inblk + } elseif {[inblk {^Section Info$} \ + {^Section\s+Type\s+Address\s+Location\s+Size\(Bytes\)$}]} { + manyset $l sec type addr lockind size + switch -exact $type code { continue } udata { } \ + default { error "unknown section type $type in $l" } + if {[wantlockind $lockind section $l]<=0} continue + set addr [format 0x%08x $addr] + lappend sections [list $addr $sec [format 0x%08x $size]] + } elseif {[inblk {^Symbols$} \ + {^Name\s+Address\s+Location\s+Storage\s+File$}]} { + manyset $l sym addr lockind storage file + if {![wantlockind $lockind symbol $l]} continue + switch -exact $storage { + extern { set sym [list {} $sym] } + static { + regexp {^(.*)\.asm$} $file dummy file + set sym [list $file: $sym] + } + default { error "unknown storage $storage in $l" } + } + set addr [format 0x%08x $addr] + if {[string compare $lockind data]} { + set sv symbolsbylockind($lockind) + } else { + set sv symbols + } + lappend $sv [list $addr $sym] + } elseif {$inblk==3} { + } else { + error "unknown $inblk <$block> <$headings> $l" + } +} + +set ok { + INTCON* FSR2* + OSCCON LVDCON WDTCON RCON + T1CON T2CON + SSPADD SSPSTAT SSPCON1 SSPCON2 + ADRESH ADRESL ADCON* + CCPR1* CCP1CON + ECCPR1* ECCP1DEL ECCPAS + CMCON CVRCON T3CON + SPBRG TXSTA RXSTA + EEADR EEDATA + IPR* PIR* PIE* + TRIS* LAT* +} + +set h [open /usr/share/gputils/header/p18f458.inc] +set section unknown +set lastaddr -1 +while {[gets $h l]>=0} { + if {[regexp {^\;\-\-+\s+(\S.*\S)\s+\-\-+$} $l dummy section]} { + continue + } elseif {![regexp {^Register Files$} $section]} { + continue + } elseif {[regexp -nocase \ + {^([a-z][a-z0-9]*)\s+equ\s+h\'0(f[0-9a-f]{2})\'\s*$} \ + $l dummy sym loc]} { + set addr [format 0x%08x 0x$loc] + foreach pat $ok { + if {[string match $pat $sym]} { + if {$addr != $lastaddr} { + lappend sections [list $addr =SFRs= 0x1] + set lastaddr $addr + } + lappend symbols [list $addr [list SFR $sym]] + } + } + } elseif {[regexp -nocase {^\;\s*reserved} $l]} { + } elseif {![regexp {\S} $l]} { + } else { + error "unknown <$section> $l" + } +} + +lappend symbols {0x00000060 {=udata,!acs=}} +#lappend symbols {0x00000f00 {=SFRs,!acs=}} +lappend symbols {0x00000f60 {=SFRs,acs= {}}} +lappend sections {0x00000f00 {=SFRs=} 0} +#lappend sections {0x00000060 {==========UDATA,!ACS===========} 0} +#lappend sections {0x00000f60 {==========SFRs,ACS===========} 0} + +lappend sections [list 0x1000 =END= 0] +foreach tosort {sections symbols symbolsbylockind(program)} { + set $tosort [lsort [set $tosort]] +} + +addendlast symbolsbylockind(program) 0x8000 (end) + set readcursor -1 set ms [expr { -- 2.30.2