Skip to content

SWD module

alvaoze edited this page Jun 27, 2024 · 1 revision

Prerequisites

api = HardsploitAPI()
crossvalue = [24, 25, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0,
              1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
              48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]
api.set_cross_wiring(crossvalue)

The code initializes the Hardsploit API and sets the cross-wiring configuration. It is required for the SWD communication.

"set_cross_wiring()" is used to configure the physical and logical connections between Hardsploit's components.

SWD Class

swd = HardsploitSWD(memory_start_address, 
                    memory_size_address, 
                    cpu_id_address, 
                    device_id_address, 
                    hardsploit_api)
Parametter Type
memory_start_address String
memory_size_address String
cpu_id_address String
device_id_address String
hardsploit_api Instance of HardsploitAPI
Signal

SWD_CLK -> D0

SWD_IO -> D1

SWD Read

swd.dump_flash(file_path)
Parametter Type Informations
file_path String It is the file where you want to write the dumped memory.

SWD Write

swd.write_flash(firmware_path)
Parametter Type Informations
firmware_path String It is the file that you want to write into the memory of the chip.

SWD Infos

swd.obtain_codes()

This function will return a dictionary with 3 keys and their corresponding values:

Key Informations
DebugPortId Id of the debug port
AccessPortId Id of the access port
CpuId Id of the CPU

SWD Erase

swd.erase_flash()

Erase the memory of the chip.

Clone this wiki locally