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

Commits on Apr 6, 2019

  1. applet.memory.onfi: print ID signature.

    This could be used e.g. with Flash Extractor.
    whitequark committed Apr 6, 2019
    Copy the full SHA
    5e4362f View commit details
  2. applet.memory.onfi: allow reading data and spare into one file.

    This could be used e.g. with Flash Extractor.
    whitequark committed Apr 6, 2019
    Copy the full SHA
    7bfb641 View commit details
Showing with 24 additions and 11 deletions.
  1. +24 −11 software/glasgow/applet/memory/onfi/__init__.py
35 changes: 24 additions & 11 deletions software/glasgow/applet/memory/onfi/__init__.py
Original file line number Diff line number Diff line change
@@ -242,13 +242,16 @@ async def _read_id(self, address, length):
self._log("read ID addr=%#04x", address)
return await self._do_read(command=0x90, address=[address], length=length)

async def read_signature(self):
return await self._read_id(address=0x20, length=4)

async def read_jedec_id(self):
manufacturer_id, device_id = await self._read_id(address=0x00, length=2)
return manufacturer_id, device_id

async def read_signature(self):
return await self._read_id(address=0x00, length=4)

async def read_onfi_signature(self):
return await self._read_id(address=0x20, length=4)

async def read_status(self):
self._log("read status")
status, = await self._do_read(command=0x70, length=1)
@@ -395,10 +398,10 @@ def count(arg):
help="read COUNT pages")
p_read.add_argument(
"data_file", metavar="DATA-FILE", type=argparse.FileType("wb"),
help="write bytes from data area to DATA-FILE")
help="write bytes from data and possibly spare area to DATA-FILE")
p_read.add_argument(
"spare_file", metavar="SPARE-FILE", type=argparse.FileType("wb"),
help="write bytes from spare area to SPARE-FILE")
"spare_file", metavar="SPARE-FILE", type=argparse.FileType("wb"), nargs="?",
help="write bytes from spare area to SPARE-FILE instead of DATA-FILE")

p_program = p_operation.add_parser(
"program", help="program data and spare contents for a page range")
@@ -437,8 +440,14 @@ async def interact(self, device, args, onfi_iface):
self.logger.info("JEDEC manufacturer %#04x (%s) device %#04x",
manufacturer_id, manufacturer_name, device_id)

# First four bytes of Read ID are often used as-is in data recovery software,
# so print these for convenience as well.
signature = await onfi_iface.read_signature()
self.logger.info("ID signature %s",
" ".join("{:02x}".format(byte) for byte in signature))

onfi_param = None
if await onfi_iface.read_signature() == b"ONFI":
if await onfi_iface.read_onfi_signature() == b"ONFI":
parameter_page = await onfi_iface.read_parameter_page()
try:
onfi_param = ONFIParameters(parameter_page[512:])
@@ -594,10 +603,14 @@ async def interact(self, device, args, onfi_iface):
self.logger.info("reading page (row) %d", row)
chunk = await onfi_iface.read(column=0, row=row, length=page_size + spare_size)

args.data_file.write(chunk[:page_size])
args.data_file.flush()
args.spare_file.write(chunk[-spare_size:])
args.spare_file.flush()
if args.spare_file:
args.data_file.write(chunk[:page_size])
args.data_file.flush()
args.spare_file.write(chunk[-spare_size:])
args.spare_file.flush()
else:
args.data_file.write(chunk)
args.data_file.flush()

row += 1
count -= 1