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: whitequark/glasgow
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f55a512cecea
Choose a base ref
...
head repository: whitequark/glasgow
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d89fbd70b8f3
Choose a head ref
  • 2 commits
  • 5 files changed
  • 1 contributor

Commits on Mar 8, 2019

  1. Copy the full SHA
    d3592a8 View commit details
  2. Copy the full SHA
    d89fbd7 View commit details
44 changes: 9 additions & 35 deletions software/glasgow/applet/program/avr/__init__.py
Original file line number Diff line number Diff line change
@@ -8,37 +8,12 @@
from migen import *
from fx2.format import autodetect, input_data, output_data

from ....database.atmel.avr import *
from ...interface.spi_master import SPIMasterSubtarget, SPIMasterInterface
from ... import *


AVRDevice = collections.namedtuple("AVRDevice",
("name", "signature",
"calibration_size", "fuses_size",
"program_size", "program_page",
"eeprom_size", "eeprom_page"))

devices = [
AVRDevice("attiny13a", signature=[0x1e, 0x90, 0x07],
calibration_size=2, fuses_size=2,
program_size=1024, program_page=32,
eeprom_size=64, eeprom_page=4),
AVRDevice("attiny25", signature=[0x1e, 0x91, 0x08],
calibration_size=2, fuses_size=3,
program_size=1024, program_page=32,
eeprom_size=128, eeprom_page=4),
AVRDevice("attiny45", signature=[0x1e, 0x92, 0x06],
calibration_size=2, fuses_size=3,
program_size=2048, program_page=64,
eeprom_size=256, eeprom_page=4),
AVRDevice("attiny85", signature=[0x1e, 0x93, 0x0B],
calibration_size=2, fuses_size=3,
program_size=4096, program_page=64,
eeprom_size=512, eeprom_page=4),
]


class ProgramAVRError(GlasgowAppletError):
class AVRError(GlasgowAppletError):
pass


@@ -69,7 +44,7 @@ async def programming_enable(self):
if echo == 0b0101_0011:
self._log("synchronization ok")
else:
raise ProgramAVRError("device not present or not synchronized")
raise AVRError("device not present or not synchronized")

async def programming_disable(self):
self._log("programming disable")
@@ -246,8 +221,11 @@ class ProgramAVRApplet(GlasgowApplet, name="program-avr"):
While programming is disabled, the SPI bus is tristated, so the applet can be used for
in-circuit programming.
Supported devices: {}
""".format(", ".join(map(lambda d: d.name, devices)))
Supported devices are:
{devices}
""".format(
devices="\n".join(" * {.name}".format(device) for device in devices)
)

__pins = ("reset", "sck", "miso", "mosi")

@@ -355,11 +333,7 @@ async def interact(self, device, args, avr_iface):
await avr_iface.programming_enable()

signature = await avr_iface.read_signature()
for device in devices:
if device.signature == signature:
break
else:
device = None
device = devices_by_signature[signature]
self.logger.info("device signature: %s (%s)",
"{:02x} {:02x} {:02x}".format(*signature),
"unknown" if device is None else device.name)
8 changes: 4 additions & 4 deletions software/glasgow/applet/program/xc9500/__init__.py
Original file line number Diff line number Diff line change
@@ -267,7 +267,7 @@ async def identify(self):
idcode = DR_IDCODE.from_bitarray(idcode_bits)
self._log("read IDCODE mfg_id=%03x part_id=%04x",
idcode.mfg_id, idcode.part_id)
device = devices[idcode.mfg_id, idcode.part_id]
device = devices_by_idcode[idcode.mfg_id, idcode.part_id]
return idcode, device

async def read_usercode(self):
@@ -424,15 +424,15 @@ class ProgramXC9500Applet(JTAGProbeApplet, name="program-xc9500"):
The "program word failed" messages during programming do not necessarily mean a failed
programming attempt or a bad device. Always verify the programmed bitstream.
The list of supported devices is:
Supported devices are:
{devices}
The Glasgow .bit XC9500 bitstream format is a flat, unstructured sequence of 32-bit words
comprising the bitstream, written in little endian binary. It is substantially different
from both .jed and .svf bitstream formats, but matches the internal device programming
architecture.
""".format(
devices="\n".join(map(lambda x: " * {.name}".format(x), devices.values()))
devices="\n".join(" * {.name}".format(device) for device in devices)
)

@classmethod
@@ -546,7 +546,7 @@ class ProgramXC9500AppletTool(GlasgowAppletTool, applet=ProgramXC9500Applet):
def add_arguments(cls, parser):
def idcode(arg):
idcode = DR_IDCODE.from_int(int(arg, 16))
device = devices[idcode.mfg_id, idcode.part_id]
device = devices_by_idcode[idcode.mfg_id, idcode.part_id]
if device is None:
raise argparse.ArgumentTypeError("unknown IDCODE")
return device
Empty file.
38 changes: 38 additions & 0 deletions software/glasgow/database/atmel/avr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from collections import namedtuple, defaultdict


__all__ = ["devices", "devices_by_signature"]


AVRDevice = namedtuple("AVRDevice",
("name", "signature",
"calibration_size", "fuses_size",
"program_size", "program_page",
"eeprom_size", "eeprom_page"))


devices = [
AVRDevice("ATtiny13a",
signature=(0x1e, 0x90, 0x07),
calibration_size=2, fuses_size=2,
program_size=1024, program_page=32,
eeprom_size=64, eeprom_page=4),
AVRDevice("ATtiny25",
signature=(0x1e, 0x91, 0x08),
calibration_size=2, fuses_size=3,
program_size=1024, program_page=32,
eeprom_size=128, eeprom_page=4),
AVRDevice("ATtiny45",
signature=(0x1e, 0x92, 0x06),
calibration_size=2, fuses_size=3,
program_size=2048, program_page=64,
eeprom_size=256, eeprom_page=4),
AVRDevice("ATtiny85",
signature=(0x1e, 0x93, 0x0B),
calibration_size=2, fuses_size=3,
program_size=4096, program_page=64,
eeprom_size=512, eeprom_page=4),
]

devices_by_signature = defaultdict(lambda: None,
((device.signature, device) for device in devices))
17 changes: 11 additions & 6 deletions software/glasgow/database/xilinx/xc9500.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
from collections import defaultdict, namedtuple


__all__ = ["devices"]
__all__ = ["devices", "devices_by_idcode"]


XC9500Device = namedtuple("XC9500Device", (
"name", "bitstream_words", "usercode_low", "usercode_high"
"name", "idcode", "bitstream_words", "usercode_low", "usercode_high"
))


devices = defaultdict(lambda: None, {
(0x049, 0x9604): XC9500Device(name="XC9572XL", bitstream_words=1620,
usercode_low=90, usercode_high=105),
})
devices = [
XC9500Device("XC9572XL",
idcode=(0x049, 0x9604),
bitstream_words=1620,
usercode_low=90, usercode_high=105),
]

devices_by_idcode = defaultdict(lambda: None,
((device.idcode, device) for device in devices))