-
Notifications
You must be signed in to change notification settings - Fork 0
SPI Module
alvaoze edited this page Jun 27, 2024
·
1 revision
spi = HardsploitSPI(speed, mode, hardsploit_api)| Parametter | Type | Range |
|---|---|---|
| speed | byte | Range 1-255 SPI clock = 150Mhz / (2*speed) tested from 3 to 255 (25Mhz to about 0.3Khz) |
| mode | integer | SPI mode 0,1,2,3 |
| Hardsploit | Instance of HardsploitAPI |
This function allows you to send commands to the chip.
spi.spi_ineract(payload)| Parametter | Type | Range |
|---|---|---|
| payload | interger | Byte array want to send (Max size : 4000 bytes) |
Return : Same lenght array with answer of the slave
Port 1 : CS -> A0 SPI_CLK -> A1 MOSI-> A2 MISO -> A3
It is not possible to communicate at more than 37.50 Mhz because we have a sort of filter due to capacitance and impedance of the header and length of wires. (You can try more if you want for the moment we garanted 25Mhz)
This function allows you to read the memory of the chip.
spi.spi_generic_dump(mode, speed, read_spi_command, stPythonart_address, stop_address, max_size)| Parametter | Type | Range |
|---|---|---|
| mode | integer | SPI mode 0, 1, 2, 3 |
| speed | byte | Range 1-255 SPI clock = 150Mhz / (2*speed) tested from 3 to 255 (25Mhz to about 0.3Khz) |
| read_spi_command | integer | The read command (see datasheet but most of the time 0x03) |
| start_address | integer | Start address (included) less than sizeMax -1 |
| stop_address | integer | Stop address (included) less than start address and less than sizeMax-1 |
| max_size | integer | Max 2^32 about 4Giga in BYTE 8000 bytes = 8000*8 = 64000 bits = 64Kb memory in datasheet for example 25LC640 |
Port A : CS -> A0 SPI_CLK -> A1 MOSI -> A2 MISO -> A3
This function imports data from a file into SPI memory.
spi.spi_generic_import(start_address,
page_size,
memory_size,
data_file,
write_spi_command,
write_page_latency,
enable_write_spi_command,
clear_spi_command,
clear_chip_time,
is_flash)| Parametter | Type | Range |
|---|---|---|
| start_address | integer | Start address (included) less than sizeMax -1 |
| data_file | string | Path of file |
| memory_size | integer | Max 2^32 about 4Giga in BYTE 8000 bytes = 8000*8 = 64000 bits = 64Kb memory in datasheet for example 25LC640 |
| write_spi_commad | integer | The write command (see datasheet but most of the time 0x03) |
| write_page_latency | integer | Time to wait after write cycle (see datasheet) |
| clear_spi_command | integer | The bulk erase command only for flash (see datasheet) |
| clear_chip_time | integer | Time to wait after bulk erase (see datasheet) |
| is_flash | integer | True if a flash memory (bulk erase in this case) |
Port A : CS -> A0 SPI_CLK -> A1 MOSI -> A2 MISO -> A3