-
Notifications
You must be signed in to change notification settings - Fork 92
HydraFW SPI guide
This guide is updated towards firmware release HydraFW v0.11 and later
Connections: four pins (MOSI/MISO/CLOCK/CS) and ground(GND).
Output type: 3.3volt normal, or open drain
(pull up/pull down resistors integrated in MCU or external).
Pull-up resistors: required for open drain output mode (2K – 10K).
Pull-up/down resistors Integrated in MCU: Between 30 to 50K (Typical 40K).
Maximum voltage: 5.5volts (5volt safe).
Output type - open drain/open collector (high=Hi-Z, low=ground),
normal (high=3.3volts, low=ground).
Use open drain/open collector output types with pull-up resistors
for multi-voltage interfacing.
-
show
Show SPI parameters orshow pins
Show pins used in this mode -
device
with parameter1
or2
to choose SPI device (1 or 2) -
pull
with parameterup
ordown
orfloating
to choose internal MCU pull up/down or no pull/external -
mode
with parametermaster
orslave
to choose master or slave SPI mode -
frequency
with floating frequency value: supportk
(for kHz),m
(for MHz) suffix or no suffix (for Hz)- Frequencies available for SPI1:
320khz
,650khz
,1.31mhz
,2.62mhz
,5.25mhz
,10.5mhz
,21mhz
,42mhz
- Frequencies available for SPI2:
160khz
,320khz
,650khz
,1.31mhz
,2.62mhz
,5.25mhz
,10.5mhz
,21mhz
- Frequencies available for SPI1:
-
polarity
with parameter0
or1
for clock polarity value (also called CPOL/CKP) -
phase
with parameter0
or1
for clock phase value (also called Clock Edge or CKE/CPHA) -
msb-first
orlsb-first
to send/receive respectively MSB first or LSB first. -
exit
to exit SPI mode
Note default value for device 1 or 2:
For device 1 (SPI1):
> spi device 1
Note: SPI parameters have been reset to default values.
Device: SPI1
GPIO resistor: floating
Mode: master
Frequency: 320khz (650khz, 1.31mhz, 2.62mhz, 5.25mhz, 10.50mhz, 21mhz, 42mhz)
Polarity: 0
Phase: 0
Bit order: MSB first
For device 2 (SPI2):
> spi device 2
Note: SPI parameters have been reset to default values.
Device: SPI2
GPIO resistor: floating
Mode: master
Frequency: 160khz (320khz, 650khz, 1.31mhz, 2.62mhz, 5.25mhz, 10.50mhz, 21mhz)
Polarity: 0
Phase: 0
Bit order: MSB first
Hardware Informations:
spi1> show pins
CS: PA15
SCK: PB3
MISO: PB4
MOSI: PB5
spi2> show pins
CS: PC1 (SW)
SCK: PB10
MISO: PC2
MOSI: PC3
Configuration of SPI1 650KHz(using internal MCU pull down):
> spi device 1
Note: SPI parameters have been reset to default values.
Device: SPI1
GPIO resistor: floating
Mode: master
Frequency: 320khz (650khz, 1.31mhz, 2.62mhz, 5.25mhz, 10.50mhz, 21mhz, 42mhz)
Polarity: 0
Phase: 0
Bit order: MSB first
spi1> pull down frequency 650k show
Device: SPI1
GPIO resistor: pull-down
Mode: master
Frequency: 650khz (320khz, 1.31mhz, 2.62mhz, 5.25mhz, 10.50mhz, 21mhz, 42mhz)
Polarity: 0
Phase: 0
Bit order: MSB first
trigger
configures the trigger mode
cs-on
or [
Chip select(CS) enable/active (low=state 0/GND).
cs-off
or ]
Chip select(CS) disable (high=state +3.3V).
spi1> [ 0xFF r ] [ 0 r ] [ 1 r ] [ 0x80 r ] [ 0x55 r 0xAA r 0xFF r 0x11:4 r:4 ]
/CS ENABLED
WRITE: 0xFF
READ: 0x00
/CS DISABLED
/CS ENABLED
WRITE: 0x00
READ: 0x00
/CS DISABLED
/CS ENABLED
WRITE: 0x01
READ: 0x00
/CS DISABLED
/CS ENABLED
WRITE: 0x80
READ: 0x00
/CS DISABLED
/CS ENABLED
WRITE: 0x55
READ: 0x00
WRITE: 0xAA
READ: 0x00
WRITE: 0xFF
READ: 0x00
WRITE: 0x11 0x11 0x11 0x11
READ: 0x00 0x00 0x00 0x00
/CS DISABLED
Since c10868f345027142b0bcea3c76b8ebd8c27d45c0, it is possible to use Hydrabus with Flashrom using the Serprog protocol.
- Supported with any version of Flashrom since v0.9.8 or more (tested with success also with Flashrom v1.2 / v1.3)
- flashrom v1.3 or more can be used with Windows (tested with success with Windows10) it just need to be rebuilt from source with MSYS2/MINGW64
- See pre-built version for Windows10 with MSYS2/MINGW64 in https://hydrabus.com/flashrom
- Hydrabus will automatically switch to Serprog mode when running
flashrom
- Only SPI mode is available
- Serprog mode uses SPI2
- Hydrabus will stay in Serprog mode after
flashrom
exits. Either reset Hydrabus or press UBTN to return to console mode. - Changing SPI clock speed is supported since https://github.com/hydrabus/hydrafw/pull/124. Default speed is 21MHz
SPI Flash WINBOND W25Q16DV | HydraBus SPI2 | Details |
---|---|---|
/CS Pin1 | SPI2 CS: PC1 | Chip Select |
DO(IO1) Pin2 | SPI2 MISO: PC2 | SPI MISO |
/WP(IO2) Pin3 | 3V3 | Disable write protect |
GND Pin4 | GND | |
DI(IO0) Pin5 | SPI2 MOSI: PC3 | SPI MOSI |
CLK Pin6 | SPI2 SCK: PB10 | SPI CLK |
/HOLD (IO3) Pin7 | 3V3 | Disable hold |
VCC Pin8 | 3V3 |
flashrom -p serprog:dev=<serial port>
flashrom -p serprog:dev=<serial port>,spispeed=2M
Dump the content of a SPI EEPROM :
$ flashrom -p serprog:dev=/dev/hydrabus -r /tmp/dump.bin
flashrom v1.2 on Linux 5.8.3-arch1-1 (x86_64)
flashrom is free software, get the source code at https://flashrom.org
Using clock_gettime for delay loops (clk_id: 1, resolution: 1ns).
serprog: Programmer name is "Hydrabus"
serprog: requested mapping AT45CS1282 is incompatible: 0x1080000 bytes at 0x00000000fef80000.
[...]
===
Found Unknown flash chip "SFDP-capable chip" (4096 kB, SPI) on serprog.
Reading flash... done.
For more information about flashrom
usage, check out its man page : man flashrom
For more details on SPI protocol see: http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus
- CHANGELOG
- Console commands
- Binary mode guide
-
NFC/HydraNFC v1 guide
- Read UID of an ISO/IEC_14443 Tag
- Read UID and data of a MIFARE Ultralight Tag
- Read UID of an ISO/IEC 15693 Tag
- Emul ISO14443a Tag
- Emul MIFARE Ultralight Tag
- Emul Mifare Classic Tag
- Unique NFC sniffer design
- Launch NFC sniffer from console
- Sniffer ISO14443A wireshark pcap
- Autonomous/stand-alone sniffer mode
- Sniffer ISO14443A real-time infinite trace mode
- HydraFW-HydraNFC-v1.x-TRF7970A-Tutorial