Skip to content

Commit 695f8e4

Browse files
committed
Merge branch 'fix/make_bootloader_flash_size_correct_v5.5' into 'release/v5.5'
fix(bootloader_flash): Make bootloader flash size accurate , etc. (backport v5.5) See merge request espressif/esp-idf!41706
2 parents f7ddaef + 1bbffc5 commit 695f8e4

36 files changed

+719
-33
lines changed

components/bootloader_support/bootloader_flash/src/bootloader_flash_config_esp32.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2018-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -267,6 +267,15 @@ static void update_flash_config(const esp_image_header_t *bootloader_hdr)
267267
case ESP_IMAGE_FLASH_SIZE_16MB:
268268
size = 16;
269269
break;
270+
case ESP_IMAGE_FLASH_SIZE_32MB:
271+
size = 32;
272+
break;
273+
case ESP_IMAGE_FLASH_SIZE_64MB:
274+
size = 64;
275+
break;
276+
case ESP_IMAGE_FLASH_SIZE_128MB:
277+
size = 128;
278+
break;
270279
default:
271280
size = 2;
272281
}
@@ -345,6 +354,15 @@ static void print_flash_info(const esp_image_header_t *bootloader_hdr)
345354
case ESP_IMAGE_FLASH_SIZE_16MB:
346355
str = "16MB";
347356
break;
357+
case ESP_IMAGE_FLASH_SIZE_32MB:
358+
str = "32MB";
359+
break;
360+
case ESP_IMAGE_FLASH_SIZE_64MB:
361+
str = "64MB";
362+
break;
363+
case ESP_IMAGE_FLASH_SIZE_128MB:
364+
str = "128MB";
365+
break;
348366
default:
349367
str = "2MB";
350368
break;

components/bootloader_support/bootloader_flash/src/bootloader_flash_config_esp32c2.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -128,6 +128,15 @@ static void update_flash_config(const esp_image_header_t *bootloader_hdr)
128128
case ESP_IMAGE_FLASH_SIZE_16MB:
129129
size = 16;
130130
break;
131+
case ESP_IMAGE_FLASH_SIZE_32MB:
132+
size = 32;
133+
break;
134+
case ESP_IMAGE_FLASH_SIZE_64MB:
135+
size = 64;
136+
break;
137+
case ESP_IMAGE_FLASH_SIZE_128MB:
138+
size = 128;
139+
break;
131140
default:
132141
size = 2;
133142
}
@@ -204,6 +213,15 @@ static void print_flash_info(const esp_image_header_t *bootloader_hdr)
204213
case ESP_IMAGE_FLASH_SIZE_16MB:
205214
str = "16MB";
206215
break;
216+
case ESP_IMAGE_FLASH_SIZE_32MB:
217+
str = "32MB";
218+
break;
219+
case ESP_IMAGE_FLASH_SIZE_64MB:
220+
str = "64MB";
221+
break;
222+
case ESP_IMAGE_FLASH_SIZE_128MB:
223+
str = "128MB";
224+
break;
207225
default:
208226
str = "2MB";
209227
break;

components/bootloader_support/bootloader_flash/src/bootloader_flash_config_esp32c3.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -139,6 +139,15 @@ static void update_flash_config(const esp_image_header_t *bootloader_hdr)
139139
case ESP_IMAGE_FLASH_SIZE_16MB:
140140
size = 16;
141141
break;
142+
case ESP_IMAGE_FLASH_SIZE_32MB:
143+
size = 32;
144+
break;
145+
case ESP_IMAGE_FLASH_SIZE_64MB:
146+
size = 64;
147+
break;
148+
case ESP_IMAGE_FLASH_SIZE_128MB:
149+
size = 128;
150+
break;
142151
default:
143152
size = 2;
144153
}
@@ -215,6 +224,15 @@ static void print_flash_info(const esp_image_header_t *bootloader_hdr)
215224
case ESP_IMAGE_FLASH_SIZE_16MB:
216225
str = "16MB";
217226
break;
227+
case ESP_IMAGE_FLASH_SIZE_32MB:
228+
str = "32MB";
229+
break;
230+
case ESP_IMAGE_FLASH_SIZE_64MB:
231+
str = "64MB";
232+
break;
233+
case ESP_IMAGE_FLASH_SIZE_128MB:
234+
str = "128MB";
235+
break;
218236
default:
219237
str = "2MB";
220238
break;

components/bootloader_support/bootloader_flash/src/bootloader_flash_config_esp32c5.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -122,6 +122,12 @@ static void update_flash_config(const esp_image_header_t *bootloader_hdr)
122122
case ESP_IMAGE_FLASH_SIZE_32MB:
123123
size = 32;
124124
break;
125+
case ESP_IMAGE_FLASH_SIZE_64MB:
126+
size = 64;
127+
break;
128+
case ESP_IMAGE_FLASH_SIZE_128MB:
129+
size = 128;
130+
break;
125131
default:
126132
size = 2;
127133
}
@@ -201,6 +207,12 @@ static void print_flash_info(const esp_image_header_t *bootloader_hdr)
201207
case ESP_IMAGE_FLASH_SIZE_32MB:
202208
str = "32MB";
203209
break;
210+
case ESP_IMAGE_FLASH_SIZE_64MB:
211+
str = "64MB";
212+
break;
213+
case ESP_IMAGE_FLASH_SIZE_128MB:
214+
str = "128MB";
215+
break;
204216
default:
205217
str = "2MB";
206218
break;

components/bootloader_support/bootloader_flash/src/bootloader_flash_config_esp32c6.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -102,6 +102,15 @@ static void update_flash_config(const esp_image_header_t *bootloader_hdr)
102102
case ESP_IMAGE_FLASH_SIZE_16MB:
103103
size = 16;
104104
break;
105+
case ESP_IMAGE_FLASH_SIZE_32MB:
106+
size = 32;
107+
break;
108+
case ESP_IMAGE_FLASH_SIZE_64MB:
109+
size = 64;
110+
break;
111+
case ESP_IMAGE_FLASH_SIZE_128MB:
112+
size = 128;
113+
break;
105114
default:
106115
size = 2;
107116
}
@@ -178,6 +187,15 @@ static void print_flash_info(const esp_image_header_t *bootloader_hdr)
178187
case ESP_IMAGE_FLASH_SIZE_16MB:
179188
str = "16MB";
180189
break;
190+
case ESP_IMAGE_FLASH_SIZE_32MB:
191+
str = "32MB";
192+
break;
193+
case ESP_IMAGE_FLASH_SIZE_64MB:
194+
str = "64MB";
195+
break;
196+
case ESP_IMAGE_FLASH_SIZE_128MB:
197+
str = "128MB";
198+
break;
181199
default:
182200
str = "2MB";
183201
break;

components/bootloader_support/bootloader_flash/src/bootloader_flash_config_esp32c61.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -115,6 +115,15 @@ static void update_flash_config(const esp_image_header_t *bootloader_hdr)
115115
case ESP_IMAGE_FLASH_SIZE_16MB:
116116
size = 16;
117117
break;
118+
case ESP_IMAGE_FLASH_SIZE_32MB:
119+
size = 32;
120+
break;
121+
case ESP_IMAGE_FLASH_SIZE_64MB:
122+
size = 64;
123+
break;
124+
case ESP_IMAGE_FLASH_SIZE_128MB:
125+
size = 128;
126+
break;
118127
default:
119128
size = 2;
120129
}
@@ -189,6 +198,15 @@ static void print_flash_info(const esp_image_header_t *bootloader_hdr)
189198
case ESP_IMAGE_FLASH_SIZE_16MB:
190199
str = "16MB";
191200
break;
201+
case ESP_IMAGE_FLASH_SIZE_32MB:
202+
str = "32MB";
203+
break;
204+
case ESP_IMAGE_FLASH_SIZE_64MB:
205+
str = "64MB";
206+
break;
207+
case ESP_IMAGE_FLASH_SIZE_128MB:
208+
str = "128MB";
209+
break;
192210
default:
193211
str = "2MB";
194212
break;

components/bootloader_support/bootloader_flash/src/bootloader_flash_config_esp32h2.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -110,6 +110,15 @@ static void update_flash_config(const esp_image_header_t *bootloader_hdr)
110110
case ESP_IMAGE_FLASH_SIZE_16MB:
111111
size = 16;
112112
break;
113+
case ESP_IMAGE_FLASH_SIZE_32MB:
114+
size = 32;
115+
break;
116+
case ESP_IMAGE_FLASH_SIZE_64MB:
117+
size = 64;
118+
break;
119+
case ESP_IMAGE_FLASH_SIZE_128MB:
120+
size = 128;
121+
break;
113122
default:
114123
size = 2;
115124
}
@@ -186,6 +195,15 @@ static void print_flash_info(const esp_image_header_t *bootloader_hdr)
186195
case ESP_IMAGE_FLASH_SIZE_16MB:
187196
str = "16MB";
188197
break;
198+
case ESP_IMAGE_FLASH_SIZE_32MB:
199+
str = "32MB";
200+
break;
201+
case ESP_IMAGE_FLASH_SIZE_64MB:
202+
str = "64MB";
203+
break;
204+
case ESP_IMAGE_FLASH_SIZE_128MB:
205+
str = "128MB";
206+
break;
189207
default:
190208
str = "2MB";
191209
break;

components/bootloader_support/bootloader_flash/src/bootloader_flash_config_esp32h21.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@ static void update_flash_config(const esp_image_header_t *bootloader_hdr)
103103
case ESP_IMAGE_FLASH_SIZE_16MB:
104104
size = 16;
105105
break;
106+
case ESP_IMAGE_FLASH_SIZE_32MB:
107+
size = 32;
108+
break;
109+
case ESP_IMAGE_FLASH_SIZE_64MB:
110+
size = 64;
111+
break;
112+
case ESP_IMAGE_FLASH_SIZE_128MB:
113+
size = 128;
114+
break;
106115
default:
107116
size = 2;
108117
}
@@ -179,6 +188,15 @@ static void print_flash_info(const esp_image_header_t *bootloader_hdr)
179188
case ESP_IMAGE_FLASH_SIZE_16MB:
180189
str = "16MB";
181190
break;
191+
case ESP_IMAGE_FLASH_SIZE_32MB:
192+
str = "32MB";
193+
break;
194+
case ESP_IMAGE_FLASH_SIZE_64MB:
195+
str = "64MB";
196+
break;
197+
case ESP_IMAGE_FLASH_SIZE_128MB:
198+
str = "128MB";
199+
break;
182200
default:
183201
str = "2MB";
184202
break;

components/bootloader_support/bootloader_flash/src/bootloader_flash_config_esp32h4.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,15 @@ static void update_flash_config(const esp_image_header_t *bootloader_hdr)
103103
case ESP_IMAGE_FLASH_SIZE_16MB:
104104
size = 16;
105105
break;
106+
case ESP_IMAGE_FLASH_SIZE_32MB:
107+
size = 32;
108+
break;
109+
case ESP_IMAGE_FLASH_SIZE_64MB:
110+
size = 64;
111+
break;
112+
case ESP_IMAGE_FLASH_SIZE_128MB:
113+
size = 128;
114+
break;
106115
default:
107116
size = 2;
108117
}
@@ -176,6 +185,15 @@ static void print_flash_info(const esp_image_header_t *bootloader_hdr)
176185
case ESP_IMAGE_FLASH_SIZE_16MB:
177186
str = "16MB";
178187
break;
188+
case ESP_IMAGE_FLASH_SIZE_32MB:
189+
str = "32MB";
190+
break;
191+
case ESP_IMAGE_FLASH_SIZE_64MB:
192+
str = "64MB";
193+
break;
194+
case ESP_IMAGE_FLASH_SIZE_128MB:
195+
str = "128MB";
196+
break;
179197
default:
180198
str = "2MB";
181199
break;

components/hal/esp32c2/include/hal/gpspi_flash_ll.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,35 @@ static inline uint32_t gpspi_flash_ll_calculate_clock_reg(uint8_t clkdiv)
425425
return div_parameter;
426426
}
427427

428+
/**
429+
* Set the clock source
430+
*
431+
* @param hw Beginning address of the peripheral registers.
432+
* @param clk_source Clock source to use
433+
*/
434+
static inline void gpspi_flash_ll_set_clk_source(spi_dev_t *hw, spi_clock_source_t clk_source)
435+
{
436+
switch (clk_source) {
437+
case SPI_CLK_SRC_XTAL:
438+
hw->clk_gate.mst_clk_sel = 0;
439+
break;
440+
default:
441+
hw->clk_gate.mst_clk_sel = 1;
442+
break;
443+
}
444+
}
445+
446+
/**
447+
* Enable/disable SPI flash module clock
448+
*
449+
* @param hw Beginning address of the peripheral registers.
450+
* @param enable true to enable, false to disable
451+
*/
452+
static inline void gpspi_flash_ll_enable_clock(spi_dev_t *hw, bool enable)
453+
{
454+
hw->clk_gate.clk_en = enable;
455+
}
456+
428457
#ifdef __cplusplus
429458
}
430459
#endif

0 commit comments

Comments
 (0)