Implementation to use a Flipper-Zero as SWD/DCSD-Cable for iPhones just like known Kanzi/Kong/Tamarin Cables
iPhone | DCSD | Reset | DFU | JTAG |
---|---|---|---|---|
14 Pro Max | ✅ | ✅ | ✅ | ❌ |
14 Pro | ✅ | ✅ | ✅ | ❌ |
SE (2022) | ✅ | ✅ | ✅ | ❌ |
XS | ❌ | ❌ | ❌ | ❌ |
Here some specs about the protocol used:
- Name: SDQ (IDBUS) developed by Texas Instruments
- Source: Reversed Protocol
Credits for SDQ reverse engineering to @nyansatan
Credits to @stacksmashing for an example pi pico implementation and his defcon talk on this subject. ( watch here)
python -m pip install --upgrade ufbt
- Download Update
ufbt update --channel=release
- Flash Firmware to the Flipper
ufbt flash_usb
- VSCode setup and build
ufbt faps vscode_dist
- if it doesnt work, use only setup-command:
ufbt vscode_dist
- then build it using the commands in section
Build FAP
NAviagte to the root-folder of this project and execute the following command to build the app from src:
ufbt
The .fap
-File is located in ./dist
-Folder after successful build
ufbt launch
Cable | Flipper |
---|---|
Yellow (ID0) | PA7 (PIN 2) |
Blue (ID1) | PA6 (PIN 3) |
Black (GND) | GND (PIN 8) |
Purple (L1n) | TX (PIN 13) |
Orange (L1p) | RX (PIN 14) |
Open the Project in CLion
Breakout Color Coding
Female Port Pinout
USB UART Pinout
Download latest JLINK Software
Then update the Firmware of the JLink.
- Pinoout of the Segger J-Link
Mapping Table:
Flipper GPIO | JLINK GPIO
__________________________
12 (SIO) | 7 (TMS)
11 (GND) | 8 (GND)
10 (SWC) | 9 (TCK)
09 (3v3) | 1 (VTref)
or buy a JTAG Adapter for Flipper Zero by @jrozner on Tindie and extend the GPIO-Pins
- Repo: UFBT GitHub
- Docs: UFBT DOCS
- DWT_CYCCNT explained: ARM DOCS
@startuml
skinparam linetype polyline
skinparam linetype ortho
class SDQDevice {
+ const GpioPin* gpio_pin
+ const UsbUartBridge* uart_bridge
+ SDQTimings timings
+ SDQDeviceError error
+ SDQDeviceCommand runCommand
+ bool listening
+ bool connected
+ bool resetInProgress
+ SDQDeviceCommandCallback command_callback
+ command_callback_context: void*
void start()
void stop()
bool send(const uint8_t data[], size_t data_size)
bool receive(uint8_t data[], size_t data_size)
}
enum SDQDeviceError {
SDQDeviceErrorNone
SDQDeviceErrorResetInProgress
SDQDeviceErrorPresenceConflict
SDQDeviceErrorInvalidCommand
SDQDeviceErrorBitReadTiming
SDQDeviceErrorTimeout
}
enum SDQDeviceCommand {
SDQDeviceCommand_NONE
SDQDeviceCommand_DCSD
SDQDeviceCommand_JTAG
SDQDeviceCommand_DFU
SDQDeviceCommand_RECOVERY
SDQDeviceCommand_USB_A_CHARGING_CABLE
}
class SDQTimings {
+ uint32_t BREAK_meaningful_min
+ uint32_t BREAK_meaningful_max
+ uint32_t BREAK_meaningful
+ uint32_t BREAK_recovery
+ uint32_t WAKE_meaningful_min
+ uint32_t WAKE_meaningful_max
+ uint32_t WAKE_meaningful
+ uint32_t WAKE_recovery
+ uint32_t ZERO_meaningful_min
+ uint32_t ZERO_meaningful_max
+ uint32_t ZERO_meaningful
+ uint32_t ZERO_recovery
+ uint32_t ONE_meaningful_min
+ uint32_t ONE_meaningful_max
+ uint32_t ONE_meaningful
+ uint32_t ONE_recovery
+ uint32_t ZERO_STOP_recovery
+ uint32_t ONE_STOP_recovery
}
class TRISTART_RESPONSES {
DFU: uint8_t[7]
RESET_DEVICE: uint8_t[7]
USB_UART_JTAG: uint8_t[7]
USB_SPAM_JTAG: uint8_t[7]
USB_UART: uint8_t[7]
USB_A_CHARGING_CABLE: uint8_t[7]
}
class UsbUartBridge {
}
interface yuricable_pro_max {
+ const GpioPin SDQ_PIN
{static} void demo_input_callback(InputEvent* input_event, FuriMessageQueue* queue)
{static} void demo_render_callback(Canvas* canvas, void* ctx)
int32_t yuricable_pro_max_app(void* p)
}
SDQDevice *-- SDQTimings
SDQDevice *-- TRISTART_RESPONSES
SDQDevice <-left- SDQDeviceError
SDQDevice <-left- SDQDeviceCommand
SDQDevice +-right- yuricable_pro_max
SDQDevice +-right- UsbUartBridge
@enduml
@startgantt
Labels on first column
saturday are closed
sunday are closed
project starts 2024-01-10
[M1] happens D+1
[M2] happens D+6
[Docu] requires 5 day and starts D+1
-- Flipper --
[SDQ Implementation] requires 2 day
[CLI Commands] requires 2 day and starts at [SDQ Implementation]s end
[UART Implementation] requires 1 day and starts at [SDQ Implementation]s end
[SWD Implementation] requires 1 day and starts at [UART Implementation]s end
[JTAG Implementation] requires 1 day and starts at [SWD Implementation]s end
-- Monitor --
[Explor WebSerial] requires 2 day
[Create React App] requires 1 day and starts at [Explor WebSerial]s end
[Implement WebSerial] requires 1 day and starts at [Create React App]s end
[Command Buttons] requires 1 day and starts at [Implement WebSerial]s end
[Device Filter] requires 1 day and starts at [Implement WebSerial]s end
@endgantt