Created
March 30, 2021 21:58
-
-
Save patrickschur/a093be96c91264e7092cc2ba95616ee4 to your computer and use it in GitHub Desktop.
Reads the SPI flash memory via SMN space
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import struct | |
import io | |
import sys | |
import os | |
IOHC_NB_SMN_INDEX_REG = 0xC4 | |
config = os.open("/sys/devices/pci0000:00/0000:00:00.0/config", os.O_RDWR) | |
buffer = io.BytesIO() | |
for offset in range(0x44000000, 0x45FFFFFF, 4): | |
os.lseek(config, IOHC_NB_SMN_INDEX_REG, os.SEEK_SET) | |
os.write(config, struct.pack("I", offset)) | |
buffer.write(os.read(config, 4)) | |
os.close(config) | |
sys.stdout.buffer.write(buffer.getbuffer()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sudo ./spi.py > spi.bin