Skip to content

Commit 103bd3c

Browse files
almir-okatosylvioalves
authored andcommitted
bootloader_support: restore files to IDF 5.1.x version
As the modified files are not used when building MCUboot or app with simple boot anymore, the patches are being undone. Signed-off-by: Almir Okato <[email protected]>
1 parent c7fdbd8 commit 103bd3c

File tree

7 files changed

+46
-127
lines changed

7 files changed

+46
-127
lines changed

components/bootloader_support/src/bootloader_console_loader.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "esp32s3/rom/usb/cdc_acm.h"
2626
#include "esp32s3/rom/usb/usb_persist.h"
2727
#endif
28-
#include "stubs.h"
2928

3029
#ifdef CONFIG_ESP_CONSOLE_USB_CDC
3130
/* The following functions replace esp_rom_uart_putc, esp_rom_uart_tx_one_char,

components/bootloader_support/src/esp32/bootloader_esp32.c

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,10 @@
3636
#include "esp_rom_sys.h"
3737
#include "esp_rom_spiflash.h"
3838
#include "esp_efuse.h"
39-
#include "esp_flash_internal.h"
4039

4140
static const char *TAG = "boot.esp32";
4241

43-
#if !CONFIG_APP_BUILD_TYPE_RAM
42+
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
4443
static void bootloader_reset_mmu(void)
4544
{
4645
/* completely reset MMU in case serial bootloader was running */
@@ -180,15 +179,13 @@ esp_err_t bootloader_init(void)
180179
{
181180
assert(&_bss_start <= &_bss_end);
182181
assert(&_data_start <= &_data_end);
183-
// int *sp = esp_cpu_get_sp();
184-
// assert((unsigned*)sp < (unsigned*)&_bss_start);
185-
// assert((unsigned*)sp < (unsigned*)&_data_start);
182+
int *sp = esp_cpu_get_sp();
183+
assert(sp < &_bss_start);
184+
assert(sp < &_data_start);
186185
}
187186
#endif
188-
#ifndef __ZEPHYR__
189187
// clear bss section
190188
bootloader_clear_bss_section();
191-
#endif
192189
#endif // !CONFIG_APP_BUILD_TYPE_RAM
193190

194191
// init eFuse virtual mode (read eFuses to RAM)
@@ -197,7 +194,7 @@ esp_err_t bootloader_init(void)
197194
#ifndef CONFIG_EFUSE_VIRTUAL_KEEP_IN_FLASH
198195
esp_efuse_init_virtual_mode_in_ram();
199196
#endif
200-
#endif /* CONFIG_EFUSE_VIRTUAL */
197+
#endif
201198
// bootst up vddsdio
202199
bootloader_common_vddsdio_configure();
203200
// check rated CPU clock
@@ -208,17 +205,10 @@ esp_err_t bootloader_init(void)
208205
bootloader_clock_configure();
209206
// initialize uart console, from now on, we can use esp_log
210207
bootloader_console_init();
211-
// print 2nd bootloader banner
208+
/* print 2nd bootloader banner */
212209
bootloader_print_banner();
213210

214-
#ifndef CONFIG_BOOTLOADER_MCUBOOT
215-
spi_flash_init_chip_state();
216-
if ((ret = esp_flash_init_default_chip()) != ESP_OK) {
217-
return ret;
218-
}
219-
#endif
220-
221-
#if !CONFIG_APP_BUILD_TYPE_RAM
211+
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
222212
// reset MMU
223213
bootloader_reset_mmu();
224214
// update flash ID
@@ -228,6 +218,7 @@ esp_err_t bootloader_init(void)
228218
ESP_LOGE(TAG, "failed when running XMC startup flow, reboot!");
229219
return ret;
230220
}
221+
#if !CONFIG_APP_BUILD_TYPE_RAM
231222
// read bootloader header
232223
if ((ret = bootloader_read_bootloader_header()) != ESP_OK) {
233224
return ret;
@@ -236,18 +227,18 @@ esp_err_t bootloader_init(void)
236227
if ((ret = bootloader_check_bootloader_validity()) != ESP_OK) {
237228
return ret;
238229
}
230+
#endif // #if !CONFIG_APP_BUILD_TYPE_RAM
239231
// initialize spi flash
240232
if ((ret = bootloader_init_spi_flash()) != ESP_OK) {
241233
return ret;
242234
}
243-
#endif // #if !CONFIG_APP_BUILD_TYPE_RAM
235+
#endif //#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
244236

245237
// check whether a WDT reset happend
246238
bootloader_check_wdt_reset();
247239
// config WDT
248240
bootloader_config_wdt();
249241
// enable RNG early entropy source
250242
bootloader_enable_random();
251-
252243
return ret;
253244
}

components/bootloader_support/src/esp32c2/bootloader_esp32c2.c

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@
3939
#include "esp_efuse.h"
4040
#include "hal/mmu_hal.h"
4141
#include "hal/cache_hal.h"
42-
#if !defined(CONFIG_BOOTLOADER_MCUBOOT)
43-
#include "esp_flash_internal.h"
44-
#endif
4542

4643
static const char *TAG = "boot.esp32c2";
4744

@@ -65,7 +62,7 @@ static void bootloader_check_wdt_reset(void)
6562
soc_reset_reason_t rst_reason = esp_rom_get_reset_reason(0);
6663
if (rst_reason == RESET_REASON_CORE_RTC_WDT || rst_reason == RESET_REASON_CORE_MWDT0 ||
6764
rst_reason == RESET_REASON_CPU0_MWDT0 || rst_reason == RESET_REASON_CPU0_RTC_WDT) {
68-
ESP_EARLY_LOGW(TAG, "PRO CPU has been reset by WDT.");
65+
ESP_LOGW(TAG, "PRO CPU has been reset by WDT.");
6966
wdt_rst = 1;
7067
}
7168
if (wdt_rst) {
@@ -104,15 +101,13 @@ esp_err_t bootloader_init(void)
104101
/* check that static RAM is after the stack */
105102
assert(&_bss_start <= &_bss_end);
106103
assert(&_data_start <= &_data_end);
107-
#ifndef __ZEPHYR__
108104
// clear bss section
109105
bootloader_clear_bss_section();
110-
#endif
111106
#endif // !CONFIG_APP_BUILD_TYPE_RAM
112107

113108
// init eFuse virtual mode (read eFuses to RAM)
114109
#ifdef CONFIG_EFUSE_VIRTUAL
115-
ESP_EARLY_LOGW(TAG, "eFuse virtual mode is enabled. If Secure boot or Flash encryption is enabled then it does not provide any security. FOR TESTING ONLY!");
110+
ESP_LOGW(TAG, "eFuse virtual mode is enabled. If Secure boot or Flash encryption is enabled then it does not provide any security. FOR TESTING ONLY!");
116111
#ifndef CONFIG_EFUSE_VIRTUAL_KEEP_IN_FLASH
117112
esp_efuse_init_virtual_mode_in_ram();
118113
#endif
@@ -124,40 +119,25 @@ esp_err_t bootloader_init(void)
124119
/* print 2nd bootloader banner */
125120
bootloader_print_banner();
126121

127-
#ifndef CONFIG_BOOTLOADER_MCUBOOT
128-
spi_flash_init_chip_state();
129-
if ((ret = esp_flash_init_default_chip()) != ESP_OK) {
130-
return ret;
131-
}
132-
#endif
133-
134122
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
135123
//init cache hal
136124
cache_hal_init();
137125
//init mmu
138126
mmu_hal_init();
139127
// update flash ID
140128
bootloader_flash_update_id();
141-
// Check and run XMC startup flow
142-
if ((ret = bootloader_flash_xmc_startup()) != ESP_OK) {
143-
ESP_EARLY_LOGE(TAG, "failed when running XMC startup flow, reboot!");
144-
return ret;
145-
}
146129
#if !CONFIG_APP_BUILD_TYPE_RAM
147130
// read bootloader header
148131
if ((ret = bootloader_read_bootloader_header()) != ESP_OK) {
149-
ESP_EARLY_LOGE(TAG, "failed to read flash!");
150132
return ret;
151133
}
152134
// read chip revision and check if it's compatible to bootloader
153135
if ((ret = bootloader_check_bootloader_validity()) != ESP_OK) {
154-
ESP_EARLY_LOGE(TAG, "failed to vallidate!");
155136
return ret;
156137
}
157138
#endif // !CONFIG_APP_BUILD_TYPE_RAM
158139
// initialize spi flash
159140
if ((ret = bootloader_init_spi_flash()) != ESP_OK) {
160-
ESP_EARLY_LOGE(TAG, "failed to init spi flash!");
161141
return ret;
162142
}
163143
#endif //#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP

components/bootloader_support/src/esp32c3/bootloader_esp32c3.c

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@
4444
#include "hal/mmu_hal.h"
4545
#include "hal/cache_hal.h"
4646
#include "hal/efuse_hal.h"
47-
#if !defined(CONFIG_BOOTLOADER_MCUBOOT)
48-
#include "esp_flash_internal.h"
49-
#endif
5047

5148
static const char *TAG = "boot.esp32c3";
5249

@@ -70,7 +67,7 @@ static void bootloader_check_wdt_reset(void)
7067
soc_reset_reason_t rst_reason = esp_rom_get_reset_reason(0);
7168
if (rst_reason == RESET_REASON_CORE_RTC_WDT || rst_reason == RESET_REASON_CORE_MWDT0 || rst_reason == RESET_REASON_CORE_MWDT1 ||
7269
rst_reason == RESET_REASON_CPU0_MWDT0 || rst_reason == RESET_REASON_CPU0_MWDT1 || rst_reason == RESET_REASON_CPU0_RTC_WDT) {
73-
ESP_EARLY_LOGW(TAG, "PRO CPU has been reset by WDT.");
70+
ESP_LOGW(TAG, "PRO CPU has been reset by WDT.");
7471
wdt_rst = 1;
7572
}
7673
if (wdt_rst) {
@@ -143,15 +140,13 @@ esp_err_t bootloader_init(void)
143140
/* check that static RAM is after the stack */
144141
assert(&_bss_start <= &_bss_end);
145142
assert(&_data_start <= &_data_end);
146-
#ifndef __ZEPHYR__
147143
// clear bss section
148144
bootloader_clear_bss_section();
149-
#endif
150145
#endif // !CONFIG_APP_BUILD_TYPE_RAM
151146

152147
// init eFuse virtual mode (read eFuses to RAM)
153148
#ifdef CONFIG_EFUSE_VIRTUAL
154-
ESP_EARLY_LOGW(TAG, "eFuse virtual mode is enabled. If Secure boot or Flash encryption is enabled then it does not provide any security. FOR TESTING ONLY!");
149+
ESP_LOGW(TAG, "eFuse virtual mode is enabled. If Secure boot or Flash encryption is enabled then it does not provide any security. FOR TESTING ONLY!");
155150
#ifndef CONFIG_EFUSE_VIRTUAL_KEEP_IN_FLASH
156151
esp_efuse_init_virtual_mode_in_ram();
157152
#endif
@@ -163,13 +158,6 @@ esp_err_t bootloader_init(void)
163158
/* print 2nd bootloader banner */
164159
bootloader_print_banner();
165160

166-
#ifndef CONFIG_BOOTLOADER_MCUBOOT
167-
spi_flash_init_chip_state();
168-
if ((ret = esp_flash_init_default_chip()) != ESP_OK) {
169-
return ret;
170-
}
171-
#endif
172-
173161
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
174162
//init cache hal
175163
cache_hal_init();
@@ -179,24 +167,21 @@ esp_err_t bootloader_init(void)
179167
bootloader_flash_update_id();
180168
// Check and run XMC startup flow
181169
if ((ret = bootloader_flash_xmc_startup()) != ESP_OK) {
182-
ESP_EARLY_LOGE(TAG, "failed when running XMC startup flow, reboot!");
170+
ESP_LOGE(TAG, "failed when running XMC startup flow, reboot!");
183171
return ret;
184172
}
185173
#if !CONFIG_APP_BUILD_TYPE_RAM
186174
// read bootloader header
187175
if ((ret = bootloader_read_bootloader_header()) != ESP_OK) {
188-
ESP_EARLY_LOGE(TAG, "failed to read flash!");
189176
return ret;
190177
}
191178
// read chip revision and check if it's compatible to bootloader
192179
if ((ret = bootloader_check_bootloader_validity()) != ESP_OK) {
193-
ESP_EARLY_LOGE(TAG, "failed to vallidate!");
194180
return ret;
195181
}
196182
#endif //#if !CONFIG_APP_BUILD_TYPE_RAM
197183
// initialize spi flash
198184
if ((ret = bootloader_init_spi_flash()) != ESP_OK) {
199-
ESP_EARLY_LOGE(TAG, "failed to init spi flash!");
200185
return ret;
201186
}
202187
#endif // !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP

components/bootloader_support/src/esp32c6/bootloader_esp32c6.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@
4545
#include "soc/lp_wdt_reg.h"
4646
#include "hal/efuse_hal.h"
4747
#include "modem/modem_lpcon_reg.h"
48-
#if !defined(CONFIG_BOOTLOADER_MCUBOOT)
49-
#include "esp_flash_internal.h"
50-
#endif
5148

5249
static const char *TAG = "boot.esp32c6";
5350

@@ -71,7 +68,7 @@ static void bootloader_check_wdt_reset(void)
7168
soc_reset_reason_t rst_reason = esp_rom_get_reset_reason(0);
7269
if (rst_reason == RESET_REASON_CORE_RTC_WDT || rst_reason == RESET_REASON_CORE_MWDT0 || rst_reason == RESET_REASON_CORE_MWDT1 ||
7370
rst_reason == RESET_REASON_CPU0_MWDT0 || rst_reason == RESET_REASON_CPU0_MWDT1 || rst_reason == RESET_REASON_CPU0_RTC_WDT) {
74-
ESP_EARLY_LOGW(TAG, "PRO CPU has been reset by WDT.");
71+
ESP_LOGW(TAG, "PRO CPU has been reset by WDT.");
7572
wdt_rst = 1;
7673
}
7774
if (wdt_rst) {
@@ -145,13 +142,6 @@ esp_err_t bootloader_init(void)
145142
/* print 2nd bootloader banner */
146143
bootloader_print_banner();
147144

148-
#ifndef CONFIG_BOOTLOADER_MCUBOOT
149-
spi_flash_init_chip_state();
150-
if ((ret = esp_flash_init_default_chip()) != ESP_OK) {
151-
return ret;
152-
}
153-
#endif
154-
155145
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
156146
//init cache hal
157147
cache_hal_init();

components/bootloader_support/src/esp32s2/bootloader_esp32s2.c

Lines changed: 14 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@
3838
#include "esp_efuse.h"
3939
#include "hal/mmu_hal.h"
4040
#include "hal/cache_hal.h"
41-
#if !defined(CONFIG_BOOTLOADER_MCUBOOT)
42-
#include "esp_flash_internal.h"
43-
#endif
4441

4542
static const char *TAG = "boot.esp32s2";
4643

@@ -54,8 +51,6 @@ static void wdt_reset_cpu0_info_enable(void)
5451

5552
static void wdt_reset_info_dump(int cpu)
5653
{
57-
/* FIXME: failing EDT test due to error in early log */
58-
#if 0
5954
uint32_t inst = 0, pid = 0, stat = 0, data = 0, pc = 0,
6055
lsstat = 0, lsaddr = 0, lsdata = 0, dstat = 0;
6156
const char *cpu_name = cpu ? "APP" : "PRO";
@@ -72,20 +67,19 @@ static void wdt_reset_info_dump(int cpu)
7267

7368
if (DPORT_RECORD_PDEBUGINST_SZ(inst) == 0 &&
7469
DPORT_RECORD_PDEBUGSTATUS_BBCAUSE(dstat) == DPORT_RECORD_PDEBUGSTATUS_BBCAUSE_WAITI) {
75-
ESP_EARLY_LOGW(TAG, "WDT reset info: %s CPU PC=0x%"PRIx32" (waiti mode)", cpu_name, pc);
70+
ESP_LOGW(TAG, "WDT reset info: %s CPU PC=0x%"PRIx32" (waiti mode)", cpu_name, pc);
7671
} else {
77-
ESP_EARLY_LOGW(TAG, "WDT reset info: %s CPU PC=0x%"PRIx32, cpu_name, pc);
72+
ESP_LOGW(TAG, "WDT reset info: %s CPU PC=0x%"PRIx32, cpu_name, pc);
7873
}
79-
ESP_EARLY_LOGD(TAG, "WDT reset info: %s CPU STATUS 0x%08"PRIx32, cpu_name, stat);
80-
ESP_EARLY_LOGD(TAG, "WDT reset info: %s CPU PID 0x%08"PRIx32, cpu_name, pid);
81-
ESP_EARLY_LOGD(TAG, "WDT reset info: %s CPU PDEBUGINST 0x%08"PRIx32, cpu_name, inst);
82-
ESP_EARLY_LOGD(TAG, "WDT reset info: %s CPU PDEBUGSTATUS 0x%08"PRIx32, cpu_name, dstat);
83-
ESP_EARLY_LOGD(TAG, "WDT reset info: %s CPU PDEBUGDATA 0x%08"PRIx32, cpu_name, data);
84-
ESP_EARLY_LOGD(TAG, "WDT reset info: %s CPU PDEBUGPC 0x%08"PRIx32, cpu_name, pc);
85-
ESP_EARLY_LOGD(TAG, "WDT reset info: %s CPU PDEBUGLS0STAT 0x%08"PRIx32, cpu_name, lsstat);
86-
ESP_EARLY_LOGD(TAG, "WDT reset info: %s CPU PDEBUGLS0ADDR 0x%08"PRIx32, cpu_name, lsaddr);
87-
ESP_EARLY_LOGD(TAG, "WDT reset info: %s CPU PDEBUGLS0DATA 0x%08"PRIx32, cpu_name, lsdata);
88-
#endif
74+
ESP_LOGD(TAG, "WDT reset info: %s CPU STATUS 0x%08"PRIx32, cpu_name, stat);
75+
ESP_LOGD(TAG, "WDT reset info: %s CPU PID 0x%08"PRIx32, cpu_name, pid);
76+
ESP_LOGD(TAG, "WDT reset info: %s CPU PDEBUGINST 0x%08"PRIx32, cpu_name, inst);
77+
ESP_LOGD(TAG, "WDT reset info: %s CPU PDEBUGSTATUS 0x%08"PRIx32, cpu_name, dstat);
78+
ESP_LOGD(TAG, "WDT reset info: %s CPU PDEBUGDATA 0x%08"PRIx32, cpu_name, data);
79+
ESP_LOGD(TAG, "WDT reset info: %s CPU PDEBUGPC 0x%08"PRIx32, cpu_name, pc);
80+
ESP_LOGD(TAG, "WDT reset info: %s CPU PDEBUGLS0STAT 0x%08"PRIx32, cpu_name, lsstat);
81+
ESP_LOGD(TAG, "WDT reset info: %s CPU PDEBUGLS0ADDR 0x%08"PRIx32, cpu_name, lsaddr);
82+
ESP_LOGD(TAG, "WDT reset info: %s CPU PDEBUGLS0DATA 0x%08"PRIx32, cpu_name, lsdata);
8983
}
9084

9185
static void bootloader_check_wdt_reset(void)
@@ -94,7 +88,7 @@ static void bootloader_check_wdt_reset(void)
9488
soc_reset_reason_t rst_reason = esp_rom_get_reset_reason(0);
9589
if (rst_reason == RESET_REASON_CORE_RTC_WDT || rst_reason == RESET_REASON_CORE_MWDT0 || rst_reason == RESET_REASON_CORE_MWDT1 ||
9690
rst_reason == RESET_REASON_CPU0_MWDT0 || rst_reason == RESET_REASON_CPU0_MWDT1 || rst_reason == RESET_REASON_CPU0_RTC_WDT) {
97-
// PRO CPU has been reset by WDT
91+
ESP_LOGW(TAG, "PRO CPU has been reset by WDT.");
9892
wdt_rst = 1;
9993
}
10094
if (wdt_rst) {
@@ -126,15 +120,13 @@ esp_err_t bootloader_init(void)
126120
assert(&_data_start <= &_data_end);
127121
}
128122
#endif
129-
#ifndef __ZEPHYR__
130123
// clear bss section
131124
bootloader_clear_bss_section();
132-
#endif /* __ZEPHYR__ */
133125
#endif // !CONFIG_APP_BUILD_TYPE_RAM
134126

135127
// init eFuse virtual mode (read eFuses to RAM)
136128
#ifdef CONFIG_EFUSE_VIRTUAL
137-
ESP_EARLY_LOGW(TAG, "eFuse virtual mode is enabled. If Secure boot or Flash encryption is enabled then it does not provide any security. FOR TESTING ONLY!");
129+
ESP_LOGW(TAG, "eFuse virtual mode is enabled. If Secure boot or Flash encryption is enabled then it does not provide any security. FOR TESTING ONLY!");
138130
#ifndef CONFIG_EFUSE_VIRTUAL_KEEP_IN_FLASH
139131
esp_efuse_init_virtual_mode_in_ram();
140132
#endif
@@ -147,13 +139,6 @@ esp_err_t bootloader_init(void)
147139
/* print 2nd bootloader banner */
148140
bootloader_print_banner();
149141

150-
#ifndef CONFIG_BOOTLOADER_MCUBOOT
151-
spi_flash_init_chip_state();
152-
if ((ret = esp_flash_init_default_chip()) != ESP_OK) {
153-
return ret;
154-
}
155-
#endif
156-
157142
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
158143
// init cache hal
159144
cache_hal_init();
@@ -165,7 +150,7 @@ esp_err_t bootloader_init(void)
165150
bootloader_flash_update_id();
166151
// Check and run XMC startup flow
167152
if ((ret = bootloader_flash_xmc_startup()) != ESP_OK) {
168-
ESP_EARLY_LOGE(TAG, "failed when running XMC startup flow, reboot!");
153+
ESP_LOGE(TAG, "failed when running XMC startup flow, reboot!");
169154
return ret;
170155
}
171156
#if !CONFIG_APP_BUILD_TYPE_RAM

0 commit comments

Comments
 (0)