@@ -34,35 +34,63 @@ const SYNC_FRAME: [u8; 36] = [
34
34
#[ non_exhaustive]
35
35
#[ repr( u8 ) ]
36
36
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
39
42
FlashBegin = 0x02 ,
43
+ /// Flash download data
40
44
FlashData = 0x03 ,
45
+ /// Finish flash download
41
46
FlashEnd = 0x04 ,
47
+ /// Begin RAM download
42
48
MemBegin = 0x05 ,
49
+ /// RAM download data
43
50
MemEnd = 0x06 ,
51
+ /// Finish RAM download
44
52
MemData = 0x07 ,
53
+ /// Synchronize frame
45
54
Sync = 0x08 ,
55
+ /// Write 32-bit memory address
46
56
WriteReg = 0x09 ,
57
+ /// Read 32-bit memory address
47
58
ReadReg = 0x0A ,
48
- // Commands supported by the ESP32s bootloaders
59
+
60
+ // Commands supported by the ESP32's bootloader
61
+ /// Configure SPI flash
49
62
SpiSetParams = 0x0B ,
63
+ /// Attach SPI flash
50
64
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
51
70
ChangeBaudrate = 0x0F ,
71
+ /// Begin compressed flash download
52
72
FlashDeflBegin = 0x10 ,
73
+ /// Compressed flash download data
53
74
FlashDeflData = 0x11 ,
75
+ /// Finish compressed flash download
54
76
FlashDeflEnd = 0x12 ,
77
+ /// Calculate MD5 checksum of flash region
55
78
FlashMd5 = 0x13 ,
79
+ /// Read chip security info
56
80
GetSecurityInfo = 0x14 ,
81
+
57
82
// Stub-only commands
83
+ /// Erase entire flash chip
58
84
EraseFlash = 0xD0 ,
85
+ /// Erase flash region
59
86
EraseRegion = 0xD1 ,
87
+ /// Read flash
60
88
ReadFlash = 0xD2 ,
61
- ReadFlashSlow = 0x0E , // ROM only, much slower than the stub read_flash
89
+ /// Exits loader and runs user code
62
90
RunUserCode = 0xD3 ,
63
- // Flash encryption debug mode supported command
64
- FlashEncryptedData = 0xD4 ,
91
+
65
92
// Not part of the protocol
93
+ /// Detect the ID of the connected flash
66
94
FlashDetect = 0x9F ,
67
95
}
68
96
@@ -190,7 +218,7 @@ impl CommandType {
190
218
#[ derive( Copy , Clone , Debug ) ]
191
219
#[ non_exhaustive]
192
220
pub enum Command < ' a > {
193
- /// Begin Flash Download
221
+ /// Begin flash download
194
222
FlashBegin {
195
223
/// Size to erase
196
224
size : u32 ,
@@ -203,7 +231,7 @@ pub enum Command<'a> {
203
231
/// Supports encryption
204
232
supports_encryption : bool ,
205
233
} ,
206
- /// Flash Download Data
234
+ /// Flash download data
207
235
FlashData {
208
236
/// Data
209
237
data : & ' a [ u8 ] ,
@@ -214,15 +242,15 @@ pub enum Command<'a> {
214
242
/// Sequence number
215
243
sequence : u32 ,
216
244
} ,
217
- /// Finish Flash Download
245
+ /// Finish flash download
218
246
FlashEnd {
219
247
/// Reboot
220
248
///
221
249
/// 0 to reboot, 1 to run user code. Not necessary to send this command
222
250
/// if you wish to stay in the loader.
223
251
reboot : bool ,
224
252
} ,
225
- /// Begin RAM Download Start
253
+ /// Begin RAM download start
226
254
MemBegin {
227
255
/// Total size
228
256
size : u32 ,
@@ -235,9 +263,14 @@ pub enum Command<'a> {
235
263
/// Supports encryption
236
264
supports_encryption : bool ,
237
265
} ,
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
241
274
MemData {
242
275
/// Data size
243
276
data : & ' a [ u8 ] ,
@@ -248,9 +281,9 @@ pub enum Command<'a> {
248
281
/// Sequence number
249
282
sequence : u32 ,
250
283
} ,
251
- /// Sync Frame
284
+ /// Sync frame
252
285
///
253
- /// 36 bytes: 0x07 0x07 0x12 0x20, followed by 32 x 0x55
286
+ /// 36 bytes: ` 0x07 0x07 0x12 0x20` , followed by 32 x ` 0x55`.
254
287
Sync ,
255
288
/// Write 32-bit memory address
256
289
WriteReg {
@@ -267,11 +300,20 @@ pub enum Command<'a> {
267
300
address : u32 ,
268
301
} ,
269
302
/// Configure SPI flash
270
- SpiSetParams { spi_params : SpiSetParams } ,
303
+ SpiSetParams {
304
+ /// SPI attach parameters
305
+ spi_params : SpiSetParams ,
306
+ } ,
271
307
/// Attach SPI flash
272
- SpiAttach { spi_params : SpiAttachParams } ,
308
+ SpiAttach {
309
+ /// SPI attach parameters
310
+ spi_params : SpiAttachParams ,
311
+ } ,
273
312
/// Attach SPI flash (stub)
274
- SpiAttachStub { spi_params : SpiAttachParams } ,
313
+ SpiAttachStub {
314
+ /// SPI attach parameters
315
+ spi_params : SpiAttachParams ,
316
+ } ,
275
317
/// Change Baud rate
276
318
ChangeBaudrate {
277
319
/// New baud rate
@@ -295,7 +337,7 @@ pub enum Command<'a> {
295
337
offset : u32 ,
296
338
/// Supports encryption
297
339
///
298
- /// ROM loader only: 1 to begin encrypted flash, 0 to not.
340
+ /// ROM loader only: `1` to begin encrypted flash, `0` to not.
299
341
supports_encryption : bool ,
300
342
} ,
301
343
/// Compressed flash download data
@@ -313,8 +355,8 @@ pub enum Command<'a> {
313
355
FlashDeflEnd {
314
356
/// Reboot
315
357
///
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.
318
360
reboot : bool ,
319
361
} ,
320
362
/// Calculate MD5 of flash region
@@ -326,11 +368,11 @@ pub enum Command<'a> {
326
368
} ,
327
369
/// Erase entire flash chip
328
370
///
329
- /// Supported by Stub Loader Only
371
+ /// Supported by stub loader only.
330
372
EraseFlash ,
331
373
/// Erase flash region
332
374
///
333
- /// Supported by Stub Loader Only
375
+ /// Supported by stub loader only.
334
376
EraseRegion {
335
377
/// Flash offset to erase
336
378
offset : u32 ,
@@ -339,7 +381,7 @@ pub enum Command<'a> {
339
381
} ,
340
382
/// Read flash
341
383
///
342
- /// Supported by Stub Loader Only
384
+ /// Supported by stub loader only.
343
385
ReadFlash {
344
386
/// Flash offset
345
387
offset : u32 ,
@@ -352,22 +394,26 @@ pub enum Command<'a> {
352
394
} ,
353
395
/// Read flash (slow)
354
396
///
355
- /// Supported by ROM Loader Only
397
+ /// Supported by ROM loader only.
356
398
ReadFlashSlow {
399
+ /// Offset in flash to start from
357
400
offset : u32 ,
401
+ /// Size of the region to read
358
402
size : u32 ,
403
+ /// Block size
359
404
block_size : u32 ,
405
+ /// Maximum number of in-flight bytes
360
406
max_in_flight : u32 ,
361
407
} ,
362
408
/// Exits loader and runs user code
363
409
RunUserCode ,
364
- /// Read SPI flash manufacturer and device id
410
+ /// Read SPI flash manufacturer and device ID
365
411
///
366
- /// Not part of the serial protocol
412
+ /// Not part of the serial protocol.
367
413
FlashDetect ,
368
414
/// Read chip security info
369
415
///
370
- /// Not supported in ESP322
416
+ /// Not supported by ESP32.
371
417
GetSecurityInfo ,
372
418
}
373
419
0 commit comments