Skip to content

Commit a105bdd

Browse files
authored
add comments and corrections (#8201)
* Added comments for ets_install_uart_printf and corrected it usage. * Correct case for hotkey 'p'. Added conditional build around option 'p' to call stack_thunk_dump_stack which can only print when debug is enabled.
1 parent 29c6350 commit a105bdd

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

Diff for: cores/esp8266/esp8266_undocumented.h

+12-3
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,22 @@ calls to ets_install_putc1().
5252
*/
5353
extern void uart_buff_switch(uint8_t);
5454

55+
/*
56+
ROM function, ets_install_uart_printf, is used to installs the internal ROM
57+
putc1 driver used to print on UART0 or UART1. The installed driver is use by ets_printf.
58+
Side note, ets_install_uart_printf just happens to return the address of the
59+
internal putc1 driver installed.
60+
*/
61+
extern void ets_install_uart_printf(void);
62+
5563
/*
5664
ROM function, ets_uart_printf(), prints on the UART selected by
5765
uart_buff_switch(). Supported format options are the same as vprintf(). Also
5866
has cooked newline behavior. No flash format/string support; however, ISR safe.
59-
Also, uses a static function in ROM to print characters which is only
60-
controlled by uart_buff_switch().
67+
It also uses a static function in ROM to print characters. The UART selection
68+
is handled by a prior call to uart_buff_switch(). An advantage over ets_printf,
69+
this call is not affected by calls made to ets_install_putc1 or
70+
ets_install_putc2.
6171
*/
6272
extern int ets_uart_printf(const char *format, ...) __attribute__ ((format (printf, 1, 2)));
6373

@@ -236,7 +246,6 @@ extern void Cache_Read_Disable();
236246
extern int32_t system_func1(uint32_t);
237247
extern void clockgate_watchdog(uint32_t);
238248
extern void pm_open_rf();
239-
extern void ets_install_uart_printf(uint32_t uart_no);
240249
extern void UartDwnLdProc(uint8_t* ram_addr, uint32_t size, void (**user_start_ptr)());
241250
extern int boot_from_flash();
242251
extern void ets_run() __attribute__((noreturn));

Diff for: cores/esp8266/reboot_uart_dwnld.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static inline void __wsr_vecbase(uint32_t vector_base) {
106106
const uint32_t uart_no = 0;
107107
uartAttach();
108108
Uart_Init(uart_no);
109-
ets_install_uart_printf(uart_no);
109+
ets_install_uart_printf();
110110

111111
/* reverse engineered from boot_from_something() */
112112
const uint16_t divlatch = uart_baudrate_detect(uart_no, 0);
@@ -148,4 +148,3 @@ static inline void __wsr_vecbase(uint32_t vector_base) {
148148

149149
esp8266UartDownloadMode();
150150
}
151-

Diff for: libraries/ESP8266WebServer/examples/HelloServerBearSSL/HelloServerBearSSL.ino

+7-1
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,14 @@ void processKey(Print& out, int hotKey) {
173173
}
174174
break;
175175
}
176-
case 'P':
176+
#ifdef DEBUG_ESP_PORT
177+
// From this context stack_thunk_dump_stack() will only work when Serial
178+
// debug is enabled.
179+
case 'p':
177180
out.println(F("Calling stack_thunk_dump_stack();"));
178181
stack_thunk_dump_stack();
179182
break;
183+
#endif
180184
case 'R':
181185
out.printf_P(PSTR("Restart, ESP.restart(); ...\r\n"));
182186
ESP.restart();
@@ -191,7 +195,9 @@ void processKey(Print& out, int hotKey) {
191195
out.println(F(" h - Free Heap Report;"));
192196
out.println(F(" i - iRAM umm_info(null, true);"));
193197
out.println(F(" d - dRAM umm_info(null, true);"));
198+
#ifdef DEBUG_ESP_PORT
194199
out.println(F(" p - call stack_thunk_dump_stack();"));
200+
#endif
195201
out.println(F(" R - Restart, ESP.restart();"));
196202
out.println(F(" ? - Print Help"));
197203
out.println();

0 commit comments

Comments
 (0)