Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: GlasgowEmbedded/glasgow
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 652bbaf5c660
Choose a base ref
...
head repository: GlasgowEmbedded/glasgow
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 312e9a032de2
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on Jul 30, 2020

  1. Copy the full SHA
    9ac9240 View commit details
  2. Copy the full SHA
    e67ef7c View commit details
  3. applet.interface.jtag_probe: flush after each REPL command.

    This is a great anti-frustration feature that I added to the global
    REPL command, but not to the applet-specific REPLs. Which led to
    great frustration.
    whitequark committed Jul 30, 2020
    Copy the full SHA
    312e9a0 View commit details
Showing with 32 additions and 31 deletions.
  1. +1 −1 docs/archive
  2. +12 −4 software/glasgow/applet/interface/jtag_probe/__init__.py
  3. +15 −16 software/glasgow/applet/program/avr/__init__.py
  4. +4 −10 software/glasgow/applet/program/avr/spi.py
2 changes: 1 addition & 1 deletion docs/archive
16 changes: 12 additions & 4 deletions software/glasgow/applet/interface/jtag_probe/__init__.py
Original file line number Diff line number Diff line change
@@ -530,10 +530,11 @@ async def run_test_idle(self, count):

async def exchange_ir(self, data):
self._current_ir = data = bits(data)
self._log_h("exchange ir")
self._log_h("exchange ir-i=<%s>", dump_bin(data))
await self.enter_shift_ir()
data = await self.shift_tdio(data)
await self.enter_update_ir()
self._log_h("exchange ir-o=<%s>", dump_bin(data))
return data

async def read_ir(self, count):
@@ -555,10 +556,11 @@ async def write_ir(self, data, *, elide=True):
await self.enter_update_ir()

async def exchange_dr(self, data):
self._log_h("exchange dr")
self._log_h("exchange dr-i=<%s>", dump_bin(data))
await self.enter_shift_dr()
data = await self.shift_tdio(data)
await self.enter_update_dr()
self._log_h("exchange dr-o=<%s>", dump_bin(data))
return data

async def read_dr(self, count, idempotent=False):
@@ -970,7 +972,10 @@ async def interact(self, device, args, jtag_iface):

if args.operation == "jtag-repl":
self.logger.info("dropping to REPL; use 'help(iface)' to see available APIs")
await AsyncInteractiveConsole(locals={"iface":jtag_iface}).interact()
await AsyncInteractiveConsole(
locals={"iface":jtag_iface},
run_callback=jtag_iface.flush
).interact()

if args.operation == "tap-repl":
tap_iface = await jtag_iface.select_tap(args.tap_index,
@@ -980,7 +985,10 @@ async def interact(self, device, args, jtag_iface):
return

self.logger.info("dropping to REPL; use 'help(iface)' to see available APIs")
await AsyncInteractiveConsole(locals={"iface":tap_iface}).interact()
await AsyncInteractiveConsole(
locals={"iface":tap_iface},
run_callback=jtag_iface.flush
).interact()

# -------------------------------------------------------------------------------------------------

31 changes: 15 additions & 16 deletions software/glasgow/applet/program/avr/__init__.py
Original file line number Diff line number Diff line change
@@ -50,57 +50,56 @@ class ProgramAVRError(GlasgowAppletError):
class ProgramAVRInterface(metaclass=ABCMeta):
@abstractmethod
async def programming_enable(self):
pass
raise NotImplementedError

@abstractmethod
async def programming_disable(self):
pass
raise NotImplementedError

@abstractmethod
async def read_signature(self):
pass
raise NotImplementedError

@abstractmethod
async def read_fuse(self, address):
pass
raise NotImplementedError

@abstractmethod
async def read_fuse_range(self, addresses):
return bytearray([await self.read_fuse(address) for address in addresses])

@abstractmethod
async def write_fuse(self, address, data):
pass
raise NotImplementedError

@abstractmethod
async def read_lock_bits(self):
pass
raise NotImplementedError

@abstractmethod
async def write_lock_bits(self, data):
pass
raise NotImplementedError

@abstractmethod
async def read_calibration(self, address):
pass
raise NotImplementedError

async def read_calibration_range(self, addresses):
return bytearray([await self.read_calibration(address) for address in addresses])

@abstractmethod
async def read_program_memory(self, address):
pass
raise NotImplementedError

async def read_program_memory_range(self, addresses):
return bytearray([await self.read_program_memory(address) for address in addresses])

@abstractmethod
async def load_program_memory_page(self, address, data):
pass
raise NotImplementedError

@abstractmethod
async def write_program_memory_page(self, address):
pass
raise NotImplementedError

async def write_program_memory_range(self, address, chunk, page_size):
dirty_page = False
@@ -119,18 +118,18 @@ async def write_program_memory_range(self, address, chunk, page_size):

@abstractmethod
async def read_eeprom(self, address):
pass
raise NotImplementedError

async def read_eeprom_range(self, addresses):
return bytearray([await self.read_eeprom(address) for address in addresses])

@abstractmethod
async def load_eeprom_page(self, address, data):
pass
raise NotImplementedError

@abstractmethod
async def write_eeprom_page(self, address):
pass
raise NotImplementedError

async def write_eeprom_range(self, address, chunk, page_size):
dirty_page = False
@@ -149,7 +148,7 @@ async def write_eeprom_range(self, address, chunk, page_size):

@abstractmethod
async def chip_erase(self):
pass
raise NotImplementedError


class ProgramAVRApplet(GlasgowApplet):
14 changes: 4 additions & 10 deletions software/glasgow/applet/program/avr/spi.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import time
# Ref: ATmega16U4/ATmega32U4 8-bit Microcontroller with 16/32K bytes of ISP Flash and USB Controller datasheet
# Accession: G00058

import math
import struct
import logging
import asyncio
import argparse
import collections
from nmigen.compat import *
from fx2.format import autodetect, input_data, output_data

from ...interface.spi_master import SPIMasterSubtarget, SPIMasterInterface
from ... import *
@@ -21,7 +18,7 @@ def __init__(self, interface, logger, addr_dut_reset):
self._addr_dut_reset = addr_dut_reset

def _log(self, message, *args):
self._logger.log(self._level, "AVR: " + message, *args)
self._logger.log(self._level, "AVR SPI: " + message, *args)

async def _command(self, byte1, byte2, byte3, byte4):
command = [byte1, byte2, byte3, byte4]
@@ -74,9 +71,6 @@ async def read_fuse(self, address):
0, 0)
return data

async def read_fuse_range(self, addresses):
return bytearray([await self.read_fuse(address) for address in addresses])

async def write_fuse(self, address, data):
self._log("write fuse address %d data %02x", address, data)
a = {