# Frequently Asked Questions

## Build

### Q1: `make` says to run `make xxx_defconfig` first. What should I do?

**Symptom**: Running `make` directly before selecting a config produces an error asking you to choose a configuration first.
**Solution**:

```bash
make list-def
make <your_board>_defconfig
make
```

---

### Q2: My board only has a `k230_canmv_*_defconfig`. How do I build an RTOS image?

**Solution**: Select the CanMV defconfig first, then switch to RTOS via `menuconfig`:

1. Run `make k230_canmv_xxx_defconfig`
1. Run `make menuconfig`
1. Disable `CanMV Components Configuration`
1. Enable `RT-Smart Configuration > Enable build Rtsmart examples` as needed
1. Enable `MPP Configuration > Enable build MPP samples` as needed
1. Run `time make log`

---

### Q3: The toolchain is missing. How do I fix it?

**Symptom**: `make` reports that the toolchain cannot be found.
**Solution**:

```bash
make dl_toolchain
```

Run this once to download the toolchain, then build again.

---

### Q4: I modified `src/rtsmart/mpp` but the changes don't take effect after `make`?

**Symptom**: The image builds, but the changes are not reflected.
**Solution**: Clean the RT-Smart build artifacts first, then rebuild:

```bash
make rtsmart-clean
make
```

## Flashing and Boot

### Q5: When should I use `*.img` vs `*.kdimg`?

**Guidelines**:

- USB GUI tool (K230BurningTool): prefer `*.kdimg`
- SD card flashing: use `*.img`
- Command-line flashing (k230-flash): typically use `*.img`

---

### Q6: After running `reboot_to_upgrade`, the board doesn't enter flashing mode?

**Solution**:

1. Make sure the flashing tool is a recent version.
1. Follow the patch instructions in the flashing guide, apply the patch, and try again.
1. Alternatively, use the hardware method: hold the Boot button while powering on to enter flashing mode.

Reference: [`userguide/how_to_flash.md`](./userguide/how_to_flash.md)

---

### Q7: Flashing succeeded but the device doesn't boot normally?

**Troubleshooting steps**:

1. Check that the image matches the board (is the defconfig correct?).
1. Check that the boot medium is correct (EMMC/SD).
1. Check the serial log to confirm whether boot is stuck at a particular stage.
1. Reflash once more to rule out file corruption or interrupted transfers.

---

### Q8: How do I quickly get started with OTA?

Follow this minimal flow:

1. Build to get the `*.kdimg` update package on your PC (located at `output/<defconfig>/images/`).
1. Transfer `*.kdimg` to the device filesystem (e.g. `/data/update.kdimg`).
1. Call the OTA interface on the board to perform the update (sample test command):

```bash
test_ota /data/update.kdimg
```

1. After a successful update log appears, reboot and confirm the new version is running.

**Notes**:

- OTA requires `*.kdimg`, not `*.img`.
- For production, it is recommended to add update package signature/source verification, power-loss recovery, and rollback policies at the application layer.

For the full mechanism and API description, see: [`advanced_development_guide/how_to_use_k230_ota.md`](./advanced_development_guide/how_to_use_k230_ota.md)

## Samples and Applications

### Q9: Samples are not in `/sdcard/app`. Does that mean packaging failed?

Not necessarily. RT-Smart samples are placed in:

```text
/sdcard/app/examples/
```

Check with:

```bash
cd /sdcard/app/examples
find . -name "*.elf" | head
```

---

### Q10: How do I configure a sample to auto-start on boot?

There are two configuration options:

1. **Runtime auto-start command (Startup command)**

   Configure in `menuconfig`:

   ```text
   RT-Smart Configuration > Startup command
   ```

   This is a runtime command string (`CONFIG_RTT_AUTO_EXEC_CMD`). Use an **absolute path**, for example:

   ```text
   /sdcard/app/examples/integrated_poc/smart_ipc.elf
   ```

1. **Fast Boot file path at image packaging time (supports variables)**

   To configure the Fast Boot source file path, go to:

   ```text
   Fast Boot Configuration > Fast boot file path
   ```

   This field supports absolute paths or `${SDK_*}` variables exported by `tools/mkenv.mk` (e.g. `${SDK_BUILD_IMAGES_DIR}`), for example:

   ```text
   ${SDK_BUILD_IMAGES_DIR}/sdcard/app/examples/integrated_poc/smart_ipc.elf
   ```

---

### Q11: How do I check which sensors the current firmware supports?

On the board, run:

```bash
list_sensor
```

If the target sensor is not listed, enable it in the Sensor-related options under `menuconfig` and rebuild and reflash.

Reference: [`userguide/sensor_list.md`](./userguide/sensor_list.md)

## Still not resolved?

Post on the [community forum](https://www.kendryte.com/answer/) for help.

Providing the following information will speed up troubleshooting:

1. The defconfig name you are using
1. The full error log (including 30 lines before and after)
1. The flashing method and image file name
1. Key sections of the serial boot log

Also include the commands you have already tried.
