Compare commits
2 Commits
2156d824c5
...
9ad69d3e3c
Author | SHA1 | Date |
---|---|---|
David Anderson | 9ad69d3e3c | |
David Anderson | 5e66d8b205 |
|
@ -14,7 +14,7 @@ func main() {
|
||||||
}
|
}
|
||||||
defer dbg.Close()
|
defer dbg.Close()
|
||||||
|
|
||||||
mem := memory.New(dbg, 4*1024)
|
mem := memory.New(dbg, 128*1024)
|
||||||
|
|
||||||
if err := UI(mem); err != nil {
|
if err := UI(mem); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
portDev = "/dev/ttyUSB0"
|
portDev = "/dev/ttyUSB0"
|
||||||
portSpeed = 115_200
|
portSpeed = 1_382_400 // 1.3Mbps
|
||||||
maxAddr = 1 << 17
|
maxAddr = 1 << 17
|
||||||
pingResponse = 0xEA
|
pingResponse = 0xEA
|
||||||
readTimeout = 2 * time.Second
|
readTimeout = 2 * time.Second
|
||||||
|
@ -26,7 +26,7 @@ type Serial struct {
|
||||||
|
|
||||||
func Open() (*Serial, error) {
|
func Open() (*Serial, error) {
|
||||||
mode := &serial.Mode{
|
mode := &serial.Mode{
|
||||||
BaudRate: 115_200,
|
BaudRate: portSpeed,
|
||||||
}
|
}
|
||||||
port, err := serial.Open(portDev, mode)
|
port, err := serial.Open(portDev, mode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -38,6 +38,7 @@ func Open() (*Serial, error) {
|
||||||
port.Close()
|
port.Close()
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
port.SetReadTimeout(readTimeout)
|
port.SetReadTimeout(readTimeout)
|
||||||
if _, err := io.ReadFull(port, packet[:1]); err != nil {
|
if _, err := io.ReadFull(port, packet[:1]); err != nil {
|
||||||
port.Close()
|
port.Close()
|
||||||
|
@ -80,7 +81,7 @@ func encode(cmd int, addr int, data byte) [4]byte {
|
||||||
func (d *Serial) readSlow(bs []byte, off int64) (int, error) {
|
func (d *Serial) readSlow(bs []byte, off int64) (int, error) {
|
||||||
d.portMu.Lock()
|
d.portMu.Lock()
|
||||||
defer d.portMu.Unlock()
|
defer d.portMu.Unlock()
|
||||||
if off+int64(len(bs)) >= maxAddr {
|
if off+int64(len(bs)) > maxAddr {
|
||||||
return 0, errors.New("OOB read")
|
return 0, errors.New("OOB read")
|
||||||
}
|
}
|
||||||
for i := range bs {
|
for i := range bs {
|
||||||
|
@ -100,7 +101,7 @@ func (d *Serial) readSlow(bs []byte, off int64) (int, error) {
|
||||||
func (d *Serial) readBurst(bs []byte, off int64) (int, error) {
|
func (d *Serial) readBurst(bs []byte, off int64) (int, error) {
|
||||||
d.portMu.Lock()
|
d.portMu.Lock()
|
||||||
defer d.portMu.Unlock()
|
defer d.portMu.Unlock()
|
||||||
if off+int64(len(bs)) >= maxAddr {
|
if off+int64(len(bs)) > maxAddr {
|
||||||
return 0, errors.New("OOB read")
|
return 0, errors.New("OOB read")
|
||||||
}
|
}
|
||||||
for i := 0; i < len(bs); i += 255 {
|
for i := 0; i < len(bs); i += 255 {
|
||||||
|
@ -125,7 +126,7 @@ func (d *Serial) ReadAt(bs []byte, off int64) (int, error) {
|
||||||
func (d *Serial) WriteAt(bs []byte, off int64) (int, error) {
|
func (d *Serial) WriteAt(bs []byte, off int64) (int, error) {
|
||||||
d.portMu.Lock()
|
d.portMu.Lock()
|
||||||
defer d.portMu.Unlock()
|
defer d.portMu.Unlock()
|
||||||
if off+int64(len(bs)) >= maxAddr {
|
if off+int64(len(bs)) > maxAddr {
|
||||||
return 0, errors.New("OOB write")
|
return 0, errors.New("OOB write")
|
||||||
}
|
}
|
||||||
for i, v := range bs {
|
for i, v := range bs {
|
||||||
|
|
|
@ -82,8 +82,8 @@ func (m debugger) readFullMemory() tea.Cmd {
|
||||||
|
|
||||||
func (m debugger) readFullMemoryCmds() []tea.Cmd {
|
func (m debugger) readFullMemoryCmds() []tea.Cmd {
|
||||||
var ret []tea.Cmd
|
var ret []tea.Cmd
|
||||||
for i := 0; i < m.mem.Len(); i += 128 {
|
for i := 0; i < m.mem.Len(); i += 32 * 1024 {
|
||||||
ret = append(ret, m.readMemory(i, 128))
|
ret = append(ret, m.readMemory(i, 32*1024))
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ module mkTop(Top);
|
||||||
|
|
||||||
////////////
|
////////////
|
||||||
// Debugging
|
// Debugging
|
||||||
let debugger <- mkUARTDebugger(25_000_000, 115_200, mem.debugger);
|
let debugger <- mkUARTDebugger(25_000_000, 1_382_400, mem.debugger);
|
||||||
let blinky <- mkBlinky(25_000_000);
|
let blinky <- mkBlinky(25_000_000);
|
||||||
|
|
||||||
////////////
|
////////////
|
||||||
|
|
Loading…
Reference in New Issue