Skip to content

Commit

Permalink
applet.program.ecp5_sram: use GlasgowAppletError
Browse files Browse the repository at this point in the history
  • Loading branch information
gregdavill committed Apr 25, 2020
1 parent c505abe commit 58b7459
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions software/glasgow/applet/program/ecp5_sram/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,15 @@ async def identify(self):
"unknown"
self.logger.info("manufacturer=%#05x (%s) part=%#06x version=%#03x",
idcode.mfg_id, mfg_name, idcode.part_id, idcode.version)

# Decode to actual ECP5 devices
try:
device = devices_by_idcode[idcode_value]
self.logger.info("Found Device: %s", device)
except:
self.logger.error("IDCODE 0x%08X does not mtach ECP5 device", idcode_value)

device = devices_by_idcode[idcode_value] or None
if device is None:
raise GlasgowAppletError("IDCODE does not mtach ECP5 device", hex(idcode_value))
self.logger.info("Found Device: %s", device)

async def _check_status(self, status):
self.logger.info("Status Register: 0x%08X", status.to_int())
self.logger.info("Status Register: 0x%#08x", status.to_int())
self.logger.info(" %s", status)

async def program(self, bitstream):
Expand All @@ -67,7 +66,7 @@ async def program(self, bitstream):
# Slit bitstream up into chunks just for improving JTAG throughput
chunk_size = 128
bitstream_chunks = [bitstream[i:i + chunk_size] for i in range(0, len(bitstream), chunk_size)]

await self.lower.enter_shift_dr()
for chunk in bitstream_chunks:
chunk_bits = bits()
Expand All @@ -89,6 +88,8 @@ async def program(self, bitstream):
self.logger.info("Configuration Done")
else:
await self._check_status(status)
raise GlasgowAppletError("Configuration error. DONE not set",
bse_error_code[status.BSE_Error_Code])



Expand Down

0 comments on commit 58b7459

Please sign in to comment.