@@ -11,8 +11,8 @@ use crate::{
11
11
connection:: Connection ,
12
12
elf:: { FirmwareImage , FlashFrequency , FlashMode } ,
13
13
error:: ChipDetectError ,
14
- flash_target:: { Esp32Target , Esp8266Target , FlashTarget , RamTarget } ,
15
- flasher:: { FlashSize , SpiAttachParams } ,
14
+ flash_target:: { Esp32Target , Esp8266Target , FlashTarget , RamTarget , MAX_RAM_BLOCK_SIZE } ,
15
+ flasher:: { FlashSize , SpiAttachParams , FLASH_WRITE_SIZE } ,
16
16
image_format:: { ImageFormat , ImageFormatId } ,
17
17
Error , PartitionTable ,
18
18
} ;
@@ -91,6 +91,14 @@ pub trait ChipType: ReadEFuse {
91
91
fn supports_target ( target : & str ) -> bool {
92
92
Self :: SUPPORTED_TARGETS . contains ( & target)
93
93
}
94
+
95
+ fn flash_write_size ( & self , _connection : & mut Connection ) -> Result < usize , Error > {
96
+ Ok ( FLASH_WRITE_SIZE )
97
+ }
98
+
99
+ fn max_ram_block_size ( & self , _connection : & mut Connection ) -> Result < usize , Error > {
100
+ Ok ( MAX_RAM_BLOCK_SIZE )
101
+ }
94
102
}
95
103
96
104
pub trait ReadEFuse {
@@ -295,8 +303,12 @@ impl Chip {
295
303
}
296
304
}
297
305
298
- pub fn ram_target ( & self , entry : Option < u32 > ) -> Box < dyn FlashTarget > {
299
- Box :: new ( RamTarget :: new ( entry) )
306
+ pub fn ram_target (
307
+ & self ,
308
+ entry : Option < u32 > ,
309
+ max_ram_block_size : usize ,
310
+ ) -> Box < dyn FlashTarget > {
311
+ Box :: new ( RamTarget :: new ( entry, max_ram_block_size) )
300
312
}
301
313
302
314
pub fn flash_target (
@@ -408,6 +420,28 @@ impl Chip {
408
420
Chip :: Esp8266 => Esp8266 :: flash_frequency_encodings ( ) ,
409
421
}
410
422
}
423
+
424
+ pub fn flash_write_size ( & self , connection : & mut Connection ) -> Result < usize , Error > {
425
+ match self {
426
+ Chip :: Esp32 => Esp32 . flash_write_size ( connection) ,
427
+ Chip :: Esp32c2 => Esp32c2 . flash_write_size ( connection) ,
428
+ Chip :: Esp32c3 => Esp32c3 . flash_write_size ( connection) ,
429
+ Chip :: Esp32s2 => Esp32s2 . flash_write_size ( connection) ,
430
+ Chip :: Esp32s3 => Esp32s3 . flash_write_size ( connection) ,
431
+ Chip :: Esp8266 => Esp8266 . flash_write_size ( connection) ,
432
+ }
433
+ }
434
+
435
+ pub fn max_ram_block_size ( & self , connection : & mut Connection ) -> Result < usize , Error > {
436
+ match self {
437
+ Chip :: Esp32 => Esp32 . max_ram_block_size ( connection) ,
438
+ Chip :: Esp32c2 => Esp32c2 . max_ram_block_size ( connection) ,
439
+ Chip :: Esp32c3 => Esp32c3 . max_ram_block_size ( connection) ,
440
+ Chip :: Esp32s2 => Esp32s2 . max_ram_block_size ( connection) ,
441
+ Chip :: Esp32s3 => Esp32s3 . max_ram_block_size ( connection) ,
442
+ Chip :: Esp8266 => Esp8266 . max_ram_block_size ( connection) ,
443
+ }
444
+ }
411
445
}
412
446
413
447
pub ( crate ) fn bytes_to_mac_addr ( bytes : & [ u8 ] ) -> String {
0 commit comments