You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Downloads files or directories from the ESP32 to your computer. This command behaves similarly to `upload` but in reverse.
162
160
163
-
**Scenarios & Examples:**
164
-
```bash
165
-
esp32 download main.py
166
-
# Saves /main.py from device to ./main.py locally
167
-
168
-
esp32 download lib/config.json backup_config.json
169
-
# Saves /lib/config.json from device to ./backup_config.json locally
170
-
```
161
+
**Understanding `remote_source_path` and trailing slashes for directories:**
162
+
* If `remote_source_path` points to a **file** on the ESP32 (e.g., `/data/log.txt`): The file is downloaded.
163
+
* If `remote_source_path` points to a **directory** on the ESP32 and *ends with a `/`* (e.g., `/logs/`): The *contents* of that remote directory are downloaded into the specified `local_target_path`.
164
+
* To download the contents of the root directory, use `//` (e.g., `esp32 download // local_root_backup`).
165
+
* If `remote_source_path` points to a **directory** on the ESP32 and *does not end with a `/`* (e.g., `/config`): The directory `config`*itself* (including its contents) is downloaded and created within the `local_target_path`.
Recursively downloads the contents of a directory from the ESP32 to your computer.
174
-
* `remote_source_dir`: The directory on the ESP32 to download (e.g., `lib`, `data`).
175
-
* `local_target_dir` (optional): The local directory to save into. Defaults to a new directory with the same name as `remote_source_dir` in the CWD.
167
+
**Understanding `local_target_path`:**
168
+
* If omitted, the download target is the current working directory (`.`) on your computer.
169
+
* If provided, it specifies the local directory where items will be placed or the local filename if downloading a single file to a specific name. The tool will create this directory if it doesn't exist.
176
170
177
171
**Scenarios & Examples:**
178
-
```bash
179
-
esp32 download_all lib
180
-
# Creates ./lib/ locally and copies contents of /lib from device into it.
181
172
182
-
esp32 download_all data my_backup/device_data
183
-
# Creates ./my_backup/device_data/ locally and copies /data/* into it.
184
-
```
173
+
1. **Download a remote file to the current local directory:**
174
+
```bash
175
+
esp32 download /boot.py
176
+
# Result: ./boot.py locally
177
+
```
178
+
2. **Download a remote file to a specific local directory, keeping its name:**
179
+
```bash
180
+
esp32 download /lib/utils.py my_local_lib
181
+
# Result: ./my_local_lib/utils.py locally (my_local_lib/ created if needed)
182
+
```
183
+
3. **Download a remote file to a specific local path and name:** (mpremote behavior for `cp :remote_file local_file_path`)
4. **Download a remote directory (e.g., `logs`) and its contents into the current local directory:**
189
+
```bash
190
+
esp32 download /logs
191
+
# Result: ./logs/... locally (creates a 'logs' folder in CWD)
192
+
```
193
+
5. **Download a remote directory (e.g., `data`) and its contents into a specified local directory (`backup_data`):**
194
+
```bash
195
+
esp32 download /data backup_data
196
+
# Result: ./backup_data/data/... locally
197
+
```
198
+
6. **Download the *contents* of a remote directory (e.g., `/app/`) into the current local directory:**
199
+
```bash
200
+
esp32 download /app/ .
201
+
# Result: Files and subdirectories from /app/ on device are copied into ./ locally
202
+
# Example: if /app/main.py and /app/gfx/img.png exist,
203
+
# they become ./main.py and ./gfx/img.png
204
+
```
205
+
7. **Download the *contents* of a remote directory (e.g., `/lib/`) into a specified local directory (`local_libs_backup`):**
206
+
```bash
207
+
esp32 download /lib/ local_libs_backup
208
+
# Result: Contents of /lib/ on device are copied into ./local_libs_backup/ locally
209
+
# Example: if /lib/tool.py exists, it becomes ./local_libs_backup/tool.py
210
+
```
211
+
8. **Download the *contents* of the device's root directory into a local directory `full_backup`:**
212
+
```bash
213
+
esp32 download // full_backup
214
+
# Result: All files and folders from device root copied into ./full_backup/
215
+
```
185
216
186
217
### 4.5 Managing Remote Filesystem
187
218
188
219
***`esp32 list [remote_directory]`** or **`esp32 ls [remote_directory]`**
189
-
Lists files and directories on the ESP32.
190
-
* `remote_directory` (optional): The directory to list. Defaults to the root (`/`).
220
+
Lists files and directories on the ESP32. The listing is recursive from the given path.
221
+
*`remote_directory` (optional): The directory to list (e.g., `/lib`). Defaults to the root (`/`), listing top-level items.
191
222
192
223
**Shorthand Usage:**
193
224
```bash
@@ -208,25 +239,26 @@ This command erases the ESP32-C3's flash and installs MicroPython firmware.
208
239
***`esp32 delete [remote_path_to_delete]`**
209
240
Deletes a file or directory (recursively) on the ESP32.
210
241
*`remote_path_to_delete` (optional): The file or directory to delete (e.g., `old_main.py`, `temp_files/`).
211
-
* If omitted, the command will prompt for confirmation to **delete all contents of the root directory**. **Use with extreme caution!**
242
+
* If omitted or set to `/`, the command will prompt for confirmation to **delete all contents of the root directory**. **Use with extreme caution!**
212
243
213
244
**Shorthand Usage:**
214
245
```bash
215
246
esp32 delete old_script.py
216
247
esp32 delete my_module/
217
248
esp32 delete # Prompts to wipe root
249
+
esp32 delete / # Also prompts to wipe root
218
250
```
219
251
220
252
### 4.6 Running Scripts
221
253
222
254
***`esp32 run [script_name]`**
223
255
Executes a MicroPython script that exists on the ESP32's filesystem.
224
-
*`script_name` (optional): The path to the script on the device (e.g., `app.py`, `tests/run_tests.py`). Defaults to `main.py`.
256
+
* `script_name` (optional): The path to the script on the device (e.g., `app.py`, `tests/run_tests.py`). Defaults to `main.py`. Path is relative to the device root.
225
257
The script's output (and any errors) will be displayed in your terminal.
226
258
227
259
**Shorthand Usage:**
228
260
```bash
229
-
esp32 run
261
+
esp32 run
230
262
# Executes /main.py on device
231
263
232
264
esp32 run services/scanner.py
@@ -238,7 +270,7 @@ This command erases the ESP32-C3's flash and installs MicroPython firmware.
238
270
***Connection Issues / Device Not Detected:**
239
271
* Ensure the USB-C cable supports data transfer (not just charging).
240
272
* Verify the correct COM port is selected (`esp32 devices`, `esp32 device <PORT>`).
241
-
* For flashing or if the device is unresponsive, make sure it's in**bootloader mode**. See Section 4.2 or `docs/identify_board.md`.
273
+
* For flashing or if the device is unresponsive, make sure it's in **bootloader mode**. See Section 4.2 or `docs_md/identify_board.md`.
242
274
* Check if other serial terminal programs (Arduino IDE Serial Monitor, PuTTY, etc.) are holding the port open. Close them.
243
275
244
276
* **`esptool` or `mpremote` command not found:**
@@ -252,7 +284,7 @@ This command erases the ESP32-C3's flash and installs MicroPython firmware.
252
284
```bash
253
285
esp32 flash path/to/your_downloaded_firmware.bin
254
286
```
255
-
* After flashing, physically reset the device before testing.
287
+
* After flashing, physically reset the device (unplug/replug or RST button) before testing.
256
288
257
289
* **Upload/Download/List commands fail with "No response or mpremote error":**
258
290
* Ensure MicroPython is running correctly on the device. Try `esp32 device` to test basic connectivity.
0 commit comments