# K230 ADB User Guide

## ADB Overview

The K230 supports Android Debug Bridge (ADB), providing device debugging and file-transfer capabilities. Through ADB, developers can interact with the K230 device from a PC — executing shell commands, transferring files, and more. ADB is particularly useful for:

- Remote debugging and log inspection
- Application deployment and testing
- File upload and download

## ADB Configuration

### Board-side Configuration

```bash
make rtsmart-menuconfig

# Locate the relevant option
Components Configuration > Enable CherryUSB > Enable CherryUSB Device
   -> USB Device Function

# Select the function
Choose: CDC + ADB  or  ADB
```

![ENABLE ADB](https://www.kendryte.com/api/post/attachment?id=770)

Differences between the available configurations:

- **CDC** — CanMV IDE connection
- **CDC+MTP** — CanMV IDE connection + CanMV disk (MTP)
- **CDC+ADB** — CanMV IDE connection + ADB
- **ADB** — ADB only
- **UVC** — UVC Device (incompatible with IDE and ADB)

### Host Environment Setup

#### Windows

1. Download Android SDK Platform Tools from the Android developer website (platform-tools zip).

1. Extract and add to PATH:

```shell
# Add platform-tools directory to the system PATH environment variable
C:\path\to\platform-tools
```

1. Verify the installation:

```text
adb version
```

#### Linux

```bash
# Ubuntu / Debian
sudo apt update
sudo apt install android-tools-adb

# Or download platform-tools manually
wget https://dl.google.com/android/repository/platform-tools-latest-linux.zip
unzip platform-tools-latest-linux.zip
export PATH=$PATH:$(pwd)/platform-tools
```

## ADB Commands

### Verify Device Connection

After connecting the device, run the following on the PC:

```text
# List connected devices
adb devices

# Expected output:
# List of devices attached
# device
```

### ADB Shell

#### Enter an interactive shell

```text
adb shell
```

#### Execute a single command

```text
# Syntax
adb shell <command>

# Example: check memory usage
adb shell free
```

### ADB File Transfer

#### `adb push` — Upload a file to the device

```text
# Syntax
adb push <local_file_path> <remote_file_path>

# Examples
adb push C:\Users\user\test.txt /tmp/test.txt
adb push ./local_config.json /tmp/config.json
adb push ./app.bin /tmp
```

#### `adb pull` — Download a file from the device

```text
# Syntax
adb pull <remote_file_path> [local_file_path]

# Examples
adb pull /tmp/syslog ./logs/
adb pull /tmp/debug.log ./debug_backup.log
adb pull /home/user/config.json ./
```

## Notes

1. File transfer supports single files only; directory transfer is not supported.
1. If ADB disconnects unexpectedly during use, the USB cable may have been jostled — reseat the cable firmly.
