Skip to content

Commit de3bbdc

Browse files
authored
Document all public types (#909)
* Escape square brackets in efuse field doc comments * Reduce visibility of non-public error types * Deny missing documentation in library code * Document all public types * Fix clippy warnings
1 parent a43be2e commit de3bbdc

File tree

11 files changed

+208
-73
lines changed

11 files changed

+208
-73
lines changed

espflash/src/cli/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
//! [cargo-espflash]: https://crates.io/crates/cargo-espflash
1111
//! [espflash]: https://crates.io/crates/espflash
1212
13+
#![allow(missing_docs)]
14+
1315
use std::{
1416
collections::HashMap,
1517
fs::{self, File},

espflash/src/command.rs

Lines changed: 74 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -34,35 +34,63 @@ const SYNC_FRAME: [u8; 36] = [
3434
#[non_exhaustive]
3535
#[repr(u8)]
3636
pub enum CommandType {
37-
Unknown = 0,
38-
// Commands supported by the ESP32's bootloaders
37+
/// Unknown command type
38+
Unknown = 0x00,
39+
40+
// Commands supported by the ESP32's bootloader
41+
/// Begin flash download
3942
FlashBegin = 0x02,
43+
/// Flash download data
4044
FlashData = 0x03,
45+
/// Finish flash download
4146
FlashEnd = 0x04,
47+
/// Begin RAM download
4248
MemBegin = 0x05,
49+
/// RAM download data
4350
MemEnd = 0x06,
51+
/// Finish RAM download
4452
MemData = 0x07,
53+
/// Synchronize frame
4554
Sync = 0x08,
55+
/// Write 32-bit memory address
4656
WriteReg = 0x09,
57+
/// Read 32-bit memory address
4758
ReadReg = 0x0A,
48-
// Commands supported by the ESP32s bootloaders
59+
60+
// Commands supported by the ESP32's bootloader
61+
/// Configure SPI flash
4962
SpiSetParams = 0x0B,
63+
/// Attach SPI flash
5064
SpiAttach = 0x0D,
65+
/// Read flash
66+
///
67+
/// ROM-code only, much slower than the stub's `READ_FLASH` command.
68+
ReadFlashSlow = 0x0E,
69+
/// Change baud rate
5170
ChangeBaudrate = 0x0F,
71+
/// Begin compressed flash download
5272
FlashDeflBegin = 0x10,
73+
/// Compressed flash download data
5374
FlashDeflData = 0x11,
75+
/// Finish compressed flash download
5476
FlashDeflEnd = 0x12,
77+
/// Calculate MD5 checksum of flash region
5578
FlashMd5 = 0x13,
79+
/// Read chip security info
5680
GetSecurityInfo = 0x14,
81+
5782
// Stub-only commands
83+
/// Erase entire flash chip
5884
EraseFlash = 0xD0,
85+
/// Erase flash region
5986
EraseRegion = 0xD1,
87+
/// Read flash
6088
ReadFlash = 0xD2,
61-
ReadFlashSlow = 0x0E, // ROM only, much slower than the stub read_flash
89+
/// Exits loader and runs user code
6290
RunUserCode = 0xD3,
63-
// Flash encryption debug mode supported command
64-
FlashEncryptedData = 0xD4,
91+
6592
// Not part of the protocol
93+
/// Detect the ID of the connected flash
6694
FlashDetect = 0x9F,
6795
}
6896

@@ -190,7 +218,7 @@ impl CommandType {
190218
#[derive(Copy, Clone, Debug)]
191219
#[non_exhaustive]
192220
pub enum Command<'a> {
193-
/// Begin Flash Download
221+
/// Begin flash download
194222
FlashBegin {
195223
/// Size to erase
196224
size: u32,
@@ -203,7 +231,7 @@ pub enum Command<'a> {
203231
/// Supports encryption
204232
supports_encryption: bool,
205233
},
206-
/// Flash Download Data
234+
/// Flash download data
207235
FlashData {
208236
/// Data
209237
data: &'a [u8],
@@ -214,15 +242,15 @@ pub enum Command<'a> {
214242
/// Sequence number
215243
sequence: u32,
216244
},
217-
/// Finish Flash Download
245+
/// Finish flash download
218246
FlashEnd {
219247
/// Reboot
220248
///
221249
/// 0 to reboot, 1 to run user code. Not necessary to send this command
222250
/// if you wish to stay in the loader.
223251
reboot: bool,
224252
},
225-
/// Begin RAM Download Start
253+
/// Begin RAM download start
226254
MemBegin {
227255
/// Total size
228256
size: u32,
@@ -235,9 +263,14 @@ pub enum Command<'a> {
235263
/// Supports encryption
236264
supports_encryption: bool,
237265
},
238-
/// Finish RAM Download
239-
MemEnd { no_entry: bool, entry: u32 },
240-
/// RAM Download Data
266+
/// Finish RAM download
267+
MemEnd {
268+
/// Execute flag
269+
no_entry: bool,
270+
/// Entry point address
271+
entry: u32,
272+
},
273+
/// RAM download data
241274
MemData {
242275
/// Data size
243276
data: &'a [u8],
@@ -248,9 +281,9 @@ pub enum Command<'a> {
248281
/// Sequence number
249282
sequence: u32,
250283
},
251-
/// Sync Frame
284+
/// Sync frame
252285
///
253-
/// 36 bytes: 0x07 0x07 0x12 0x20, followed by 32 x 0x55
286+
/// 36 bytes: `0x07 0x07 0x12 0x20`, followed by 32 x `0x55`.
254287
Sync,
255288
/// Write 32-bit memory address
256289
WriteReg {
@@ -267,11 +300,20 @@ pub enum Command<'a> {
267300
address: u32,
268301
},
269302
/// Configure SPI flash
270-
SpiSetParams { spi_params: SpiSetParams },
303+
SpiSetParams {
304+
/// SPI attach parameters
305+
spi_params: SpiSetParams,
306+
},
271307
/// Attach SPI flash
272-
SpiAttach { spi_params: SpiAttachParams },
308+
SpiAttach {
309+
/// SPI attach parameters
310+
spi_params: SpiAttachParams,
311+
},
273312
/// Attach SPI flash (stub)
274-
SpiAttachStub { spi_params: SpiAttachParams },
313+
SpiAttachStub {
314+
/// SPI attach parameters
315+
spi_params: SpiAttachParams,
316+
},
275317
/// Change Baud rate
276318
ChangeBaudrate {
277319
/// New baud rate
@@ -295,7 +337,7 @@ pub enum Command<'a> {
295337
offset: u32,
296338
/// Supports encryption
297339
///
298-
/// ROM loader only: 1 to begin encrypted flash, 0 to not.
340+
/// ROM loader only: `1` to begin encrypted flash, `0` to not.
299341
supports_encryption: bool,
300342
},
301343
/// Compressed flash download data
@@ -313,8 +355,8 @@ pub enum Command<'a> {
313355
FlashDeflEnd {
314356
/// Reboot
315357
///
316-
/// 0 to reboot, 1 to run user code. Not necessary to send this command
317-
/// if you wish to stay in the loader.
358+
/// `0` to reboot, `1` to run user code. Not necessary to send this
359+
/// command if you wish to stay in the loader.
318360
reboot: bool,
319361
},
320362
/// Calculate MD5 of flash region
@@ -326,11 +368,11 @@ pub enum Command<'a> {
326368
},
327369
/// Erase entire flash chip
328370
///
329-
/// Supported by Stub Loader Only
371+
/// Supported by stub loader only.
330372
EraseFlash,
331373
/// Erase flash region
332374
///
333-
/// Supported by Stub Loader Only
375+
/// Supported by stub loader only.
334376
EraseRegion {
335377
/// Flash offset to erase
336378
offset: u32,
@@ -339,7 +381,7 @@ pub enum Command<'a> {
339381
},
340382
/// Read flash
341383
///
342-
/// Supported by Stub Loader Only
384+
/// Supported by stub loader only.
343385
ReadFlash {
344386
/// Flash offset
345387
offset: u32,
@@ -352,22 +394,26 @@ pub enum Command<'a> {
352394
},
353395
/// Read flash (slow)
354396
///
355-
/// Supported by ROM Loader Only
397+
/// Supported by ROM loader only.
356398
ReadFlashSlow {
399+
/// Offset in flash to start from
357400
offset: u32,
401+
/// Size of the region to read
358402
size: u32,
403+
/// Block size
359404
block_size: u32,
405+
/// Maximum number of in-flight bytes
360406
max_in_flight: u32,
361407
},
362408
/// Exits loader and runs user code
363409
RunUserCode,
364-
/// Read SPI flash manufacturer and device id
410+
/// Read SPI flash manufacturer and device ID
365411
///
366-
/// Not part of the serial protocol
412+
/// Not part of the serial protocol.
367413
FlashDetect,
368414
/// Read chip security info
369415
///
370-
/// Not supported in ESP322
416+
/// Not supported by ESP32.
371417
GetSecurityInfo,
372418
}
373419

0 commit comments

Comments
 (0)