protocol.txt 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. Communication protocol documentation
  2. UART interface, 3.3V signal levels
  3. Pin PA2: TX (microcontroller -> PC)
  4. Pin PA3: RX (microcontroller <- PC)
  5. 115200 Baud (115k2 Baud)
  6. 8 Bit
  7. No Parity
  8. 1 Stop Bit
  9. Each command consists of 1 up to several characters followed by a newline (\n). \r and \r\n is also accepted as command ending.
  10. - Set the start address for firmware extraction (default: 0 = 0x00000000 = "A00000000"):
  11. AXXXXXXXX\n (where XXXXXXXX is the address HEX. E.g., send A08000000\n to start firmware extraction from address 0x08000000)
  12. - Set the length of data extraction (default: 65535 = 0x10000 = "L00010000"):
  13. LXXXXXXXX\n (where XXXXXXXX is the length in HEX. E.g., send L00001000\n to extract 0x1000 = 4096 bytes of data.)
  14. - Set BIN output mode (default):
  15. B\n
  16. - Set HEX output mode:
  17. H\n
  18. - Select Little Endian output (default):
  19. e\n
  20. - Select Big Endian output:
  21. E\n
  22. - Start Firmware extraction:
  23. S\n
  24. - Print statistics:
  25. P\n
  26. The microcontroller will acknowledge every valid command with a human-readible reply containing the current setting. An invalid command will be rejected with "ERROR: unknown command". Each reply microcontroller->PC is ended by \r\n.
  27. The address as well as the length (A and L commands) will be automatically adjusted to 32-bit alignment.
  28. Example for HEX output mode, the firmware dump is also ended by \r\n:
  29. AF77D29D 1526DB04 8316DC73 120B63E3 843B6494 \r\n
  30. In BIN mode, the firmware is sent directly in binary form without any modification (\r\n at the end is also omitted).
  31. Little Endian mode is recommended for firmware extraction. Disassemblers like radare2 expect the firmware binary to be in little endian. Strings will be directly readible when using little endian.
  32. The success ratio depends on bus load and other parameters. If a read access fails, it will be retried automatically.
  33. When reading an address failes for more than 100 times, the extraction will be aborted, since there is a major issue. The system will print
  34. \r\n!ExtractionFailureXXXXXXXX\r\n
  35. where XXXXXXXX is the SWD status in hex. (see swd.h swdStatus_t).
  36. Reasons can be:
  37. - Incorrect connection (SWD, Reset and Power connected correctly? Have you removed any (additional) debugger form the SWD?)
  38. - The chip is not affected by the exploit (may apply to future revisions, if ST decides to update their IC masks...)
  39. - You are trying to read into non-existant memory (e.g. Trying to read 128KBytes out of a 64KByte device)
  40. The statistics function prints the following data in Hex:
  41. Statistics: \r\n
  42. Attempts: 0x00001234\r\n
  43. Success: 0x00001200\r\n
  44. Failure: 0x00000034\r\n
  45. Statistics are reset each time the system start extraction (= when the "S" command is received).
  46. Attempts: Number of total read attempts (Sum of Success and Failure)
  47. Success: Number of successful reads
  48. Failure: Nummer of unsuccessful reads