1
+ // This file holds the second order functions
2
+
1
3
package main
2
4
3
5
import (
@@ -18,107 +20,6 @@ import (
18
20
var ErrDownload = errors .New ("Error sending download command" )
19
21
var ErrSendData = errors .New ("Error sending senddata command" )
20
22
21
- // func flashPaged(d *ccboot.Device, filepath string) error {
22
- // log.Printf("Parsing %s\n", filepath)
23
- // file, err := elf.Open(filepath)
24
- // if err != nil {
25
- // panic(err)
26
- // }
27
- // defer file.Close()
28
-
29
- // log.Printf("Mass erasing chip\n")
30
- // if err := d.BankErase(); err != nil {
31
- // // communication error
32
- // return err
33
- // }
34
- // log.Printf("Sending GetStatus\n")
35
- // status, err := d.GetStatus()
36
- // if err != nil {
37
- // // communication error
38
- // return err
39
- // }
40
- // if status != ccboot.COMMAND_RET_SUCCESS {
41
- // fmt.Printf("Error sending bank erase: %v\n", status)
42
- // return ErrDownload
43
- // }
44
-
45
- // fmt.Println("# Program Regions #")
46
- // for _, p := range file.Progs {
47
- // fmt.Printf("0x%X (%d) aligned %d: %v\n", p.Paddr, p.Memsz, p.Align, p)
48
- // }
49
- // fmt.Println()
50
-
51
- // for _, p := range file.Progs {
52
- // addr := uint32(p.Paddr)
53
- // size := uint32(p.Memsz)
54
- // bytestream := p.Open()
55
-
56
- // if addr == 0 {
57
- // continue
58
- // }
59
-
60
- // log.Printf("Looking at prgm at 0x%X (%d): %v\n", p.Paddr, p.Memsz, p)
61
-
62
- // alignedsize := uint32((1024 * p.Align) * ((uint64(size) / (1024 * p.Align)) + 1))
63
- // log.Printf("Sending Download for address 0x%X for %d bytes\n", addr, alignedsize)
64
- // if err := d.Download(addr, alignedsize); err != nil {
65
- // // communication error
66
- // return err
67
- // }
68
- // log.Printf("Sending GetStatus\n")
69
- // status, err := d.GetStatus()
70
- // if err != nil {
71
- // // communication error
72
- // return err
73
- // }
74
- // if status != ccboot.COMMAND_RET_SUCCESS {
75
- // fmt.Printf("Error sending download address and size: %v\n", status)
76
- // return ErrDownload
77
- // }
78
- // log.Printf("Status: %v\n", status)
79
-
80
- // block := make([]byte, 1024*p.Align)
81
- // for n, _ := bytestream.Read(block); n > 0; n, _ = bytestream.Read(block) {
82
- // // time.Sleep(time.Second * time.Duration(2))
83
-
84
- // segsize := 128
85
-
86
- // for offset := 0; offset < len(block); offset += segsize {
87
- // log.Printf("Sending SendData for bytes %d to %d\n", offset, offset+segsize-1)
88
- // if err := d.SendData(block[offset : offset+segsize]); err != nil {
89
- // // communication error
90
- // return err
91
- // }
92
- // log.Printf("Sending GetStatus\n")
93
- // status, err = d.GetStatus()
94
- // if err != nil {
95
- // // communication error
96
- // return err
97
- // }
98
- // if status != ccboot.COMMAND_RET_SUCCESS {
99
- // fmt.Printf("Error sending data: %v\n", status)
100
- // return ErrSendData
101
- // }
102
- // log.Printf("Status: %v\n", status)
103
- // }
104
-
105
- // // zero out block for next use
106
- // for i, _ := range block {
107
- // block[i] = 0
108
- // }
109
- // }
110
-
111
- // }
112
- // log.Println("Resetting Device!")
113
- // err = d.Reset()
114
- // if err != nil {
115
- // // communication error
116
- // return err
117
- // }
118
- // log.Println("Flash done!")
119
- // return nil
120
- // }
121
-
122
23
func flash (d * ccboot.Device , filepath string ) error {
123
24
log .Printf ("Parsing %s\n " , filepath )
124
25
file , err := elf .Open (filepath )
@@ -232,6 +133,7 @@ func flash(d *ccboot.Device, filepath string) error {
232
133
return nil
233
134
}
234
135
136
+ // TODO: Fix rcount greater than 0 case.
235
137
func verify (d * ccboot.Device , filepath string , rcount uint32 ) (bool , error ) {
236
138
log .Printf ("Parsing %s\n " , filepath )
237
139
file , err := elf .Open (filepath )
0 commit comments