summaryrefslogtreecommitdiff
path: root/examples/device/msc_dual_lun/README.md
blob: 5433a87373b4afcaef90daaabdb05b3c7fbe3a45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# MSC Dual LUN

A USB Mass Storage device that presents two logical units (LUNs), each a small in-RAM FAT12 disk.

## What it does

- Exposes two LUNs, each a 8 KB FAT12 RAM disk containing a `README.TXT` file (`TinyUSB 0` and `TinyUSB 1` volumes).
- Both disks are read/write by default, so host changes are written back to RAM (unless built read-only).
- Pressing the board button marks LUN1 as "not ready" to simulate removable media being absent (e.g. SD card removed).
- Reports a custom SCSI inquiry: vendor `TinyUSB`, product `Mass Storage`, revision `1.0`.
- Runs under no-OS, FreeRTOS or ThreadX (USB device and LED blink as separate tasks under an RTOS).
- LED blink rate indicates bus state (not mounted / mounted / suspended).

## USB Descriptors

| Interface | Class driver |
|-----------|--------------|
| 0 | MSC (mass storage) |

## Configuration

Notable `tusb_config.h` settings:

```c
#define CFG_TUD_MSC               1
#define CFG_TUD_MSC_EP_BUFSIZE    512
```

## Building

CMake:

```bash
mkdir build && cd build
cmake -DBOARD=raspberry_pi_pico ..
cmake --build .
```

Make:

```bash
make BOARD=raspberry_pi_pico all
```

## Try it

After plugging in, two removable drives appear on the host, each containing a `README.TXT`. Open or modify the files to exercise reads and writes. Press the board button to make the second drive report "not ready" (medium not present).