@@ -4,10 +4,10 @@ use strum_macros::Display;
4
4
5
5
use crate :: {
6
6
connection:: Connection ,
7
- elf:: FirmwareImage ,
7
+ elf:: { FirmwareImage , FlashFrequency , FlashMode } ,
8
8
error:: ChipDetectError ,
9
9
flash_target:: { Esp32Target , Esp8266Target , FlashTarget , RamTarget } ,
10
- flasher:: SpiAttachParams ,
10
+ flasher:: { FlashSize , SpiAttachParams } ,
11
11
image_format:: { ImageFormat , ImageFormatId } ,
12
12
Error , PartitionTable ,
13
13
} ;
@@ -49,11 +49,14 @@ pub trait ChipType: ReadEFuse {
49
49
50
50
/// Get the firmware segments for writing an image to flash.
51
51
fn get_flash_segments < ' a > (
52
- image : & ' a FirmwareImage ,
52
+ image : & ' a dyn FirmwareImage < ' a > ,
53
53
bootloader : Option < Vec < u8 > > ,
54
54
partition_table : Option < PartitionTable > ,
55
55
image_format : ImageFormatId ,
56
56
chip_revision : Option < u32 > ,
57
+ flash_mode : Option < FlashMode > ,
58
+ flash_size : Option < FlashSize > ,
59
+ flash_freq : Option < FlashFrequency > ,
57
60
) -> Result < Box < dyn ImageFormat < ' a > + ' a > , Error > ;
58
61
59
62
/// Read the MAC address of the connected chip.
@@ -189,11 +192,14 @@ impl Chip {
189
192
190
193
pub fn get_flash_image < ' a > (
191
194
& self ,
192
- image : & ' a FirmwareImage ,
195
+ image : & ' a dyn FirmwareImage < ' a > ,
193
196
bootloader : Option < Vec < u8 > > ,
194
197
partition_table : Option < PartitionTable > ,
195
198
image_format : Option < ImageFormatId > ,
196
199
chip_revision : Option < u32 > ,
200
+ flash_mode : Option < FlashMode > ,
201
+ flash_size : Option < FlashSize > ,
202
+ flash_freq : Option < FlashFrequency > ,
197
203
) -> Result < Box < dyn ImageFormat < ' a > + ' a > , Error > {
198
204
let image_format = image_format. unwrap_or_else ( || self . default_image_format ( ) ) ;
199
205
@@ -204,31 +210,50 @@ impl Chip {
204
210
partition_table,
205
211
image_format,
206
212
chip_revision,
213
+ flash_mode,
214
+ flash_size,
215
+ flash_freq,
207
216
) ,
208
217
Chip :: Esp32c3 => Esp32c3 :: get_flash_segments (
209
218
image,
210
219
bootloader,
211
220
partition_table,
212
221
image_format,
213
222
chip_revision,
223
+ flash_mode,
224
+ flash_size,
225
+ flash_freq,
214
226
) ,
215
227
Chip :: Esp32s2 => Esp32s2 :: get_flash_segments (
216
228
image,
217
229
bootloader,
218
230
partition_table,
219
231
image_format,
220
232
chip_revision,
233
+ flash_mode,
234
+ flash_size,
235
+ flash_freq,
221
236
) ,
222
237
Chip :: Esp32s3 => Esp32s3 :: get_flash_segments (
223
238
image,
224
239
bootloader,
225
240
partition_table,
226
241
image_format,
227
242
chip_revision,
243
+ flash_mode,
244
+ flash_size,
245
+ flash_freq,
246
+ ) ,
247
+ Chip :: Esp8266 => Esp8266 :: get_flash_segments (
248
+ image,
249
+ None ,
250
+ None ,
251
+ image_format,
252
+ chip_revision,
253
+ flash_mode,
254
+ flash_size,
255
+ flash_freq,
228
256
) ,
229
- Chip :: Esp8266 => {
230
- Esp8266 :: get_flash_segments ( image, None , None , image_format, chip_revision)
231
- }
232
257
}
233
258
}
234
259
0 commit comments