@@ -62,6 +62,8 @@ enum Commands {
62
62
///
63
63
/// https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/app_image_format.html
64
64
Flash ( FlashArgs ) ,
65
+ /// Hold the target device in reset
66
+ HoldInReset ( ConnectArgs ) ,
65
67
/// Open the serial monitor without flashing the connected target device
66
68
Monitor ( MonitorArgs ) ,
67
69
/// Convert partition tables between CSV and binary format
@@ -77,6 +79,8 @@ enum Commands {
77
79
PartitionTable ( PartitionTableArgs ) ,
78
80
/// Read SPI flash content
79
81
ReadFlash ( ReadFlashArgs ) ,
82
+ /// Reset the target device
83
+ Reset ( ConnectArgs ) ,
80
84
/// Generate a binary application image and save it to a local disk
81
85
///
82
86
/// If the '--merge' option is used, then the bootloader, partition table,
@@ -174,9 +178,11 @@ fn main() -> Result<()> {
174
178
Commands :: EraseParts ( args) => erase_parts ( args, & config) ,
175
179
Commands :: EraseRegion ( args) => erase_region ( args, & config) ,
176
180
Commands :: Flash ( args) => flash ( args, & config) ,
181
+ Commands :: HoldInReset ( args) => hold_in_reset ( args, & config) ,
177
182
Commands :: Monitor ( args) => serial_monitor ( args, & config) ,
178
183
Commands :: PartitionTable ( args) => partition_table ( args) ,
179
184
Commands :: ReadFlash ( args) => read_flash ( args, & config) ,
185
+ Commands :: Reset ( args) => reset ( args, & config) ,
180
186
Commands :: SaveImage ( args) => save_image ( args, & config) ,
181
187
Commands :: WriteBin ( args) => write_bin ( args, & config) ,
182
188
Commands :: ChecksumMd5 ( args) => checksum_md5 ( & args, & config) ,
@@ -206,6 +212,23 @@ pub fn erase_parts(args: ErasePartsArgs, config: &Config) -> Result<()> {
206
212
Ok ( ( ) )
207
213
}
208
214
215
+ fn reset ( args : ConnectArgs , config : & Config ) -> Result < ( ) > {
216
+ let mut args = args. clone ( ) ;
217
+ args. no_stub = true ;
218
+ let mut flash = connect ( & args, config, true , true ) ?;
219
+ info ! ( "Resetting target device" ) ;
220
+ flash. connection ( ) . reset ( ) ?;
221
+
222
+ Ok ( ( ) )
223
+ }
224
+
225
+ fn hold_in_reset ( args : ConnectArgs , config : & Config ) -> Result < ( ) > {
226
+ connect ( & args, config, true , true ) ?;
227
+ info ! ( "Holding target device in reset" ) ;
228
+
229
+ Ok ( ( ) )
230
+ }
231
+
209
232
fn flash ( args : FlashArgs , config : & Config ) -> Result < ( ) > {
210
233
let mut flasher = connect (
211
234
& args. connect_args ,
0 commit comments