Compare commits

..

2 Commits

Author SHA1 Message Date
David Anderson 9ad69d3e3c debugger: crank the debug port up to 1.3Mbps
With this, full memory read-out takes ~1s.
2024-09-19 22:14:00 -07:00
David Anderson 5e66d8b205 debugger: load all 128k of VRAM 2024-09-19 21:10:48 -07:00
4 changed files with 10 additions and 9 deletions

View File

@ -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)

View File

@ -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 {

View File

@ -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
} }

View File

@ -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);
//////////// ////////////