Open mhightower83 opened 5 years ago
@mhightower83, what do you suggest to resolve this? A documentation addition? I don't think any of the core routines themselves (other than maybe your cool new umm stuff when called by an evil IRQ to allocate memory) try and print stuff in an ISR...
@mhightower83 I'm not sure I understand the use case either. Are there ISRs somewhere in our core or in the sdk that are printing out with unsafe functions? Or do you mean for a general guideline, e. g. :"mr user, if youre in an ISR, don't use these print functions, use those instead"?
@devyte the later.
What I noticed when I searched for a safe printf function to use for debugging from an ISR (or rsil(15)), was ets_printf()
was often suggested. And, I believe using the bare NONOS SDK it is safe (the installed putc1
function is in IRAM); however, with the current Arduino ESP8266 Core, once you run Serial.begin()
or Serial1.begin()
the installed putc1
function is in flash. Thus a group of print functions, that ~use~ rely on the results of the ets_installed_putc1
function, are not safe for ISR use even if they are in ROM.
Also worth noting is that os_printf_plus
is in IRAM and the putc1
function also started out in IRAM before Serial.begin()
. On this point, I am left wondering if the Blob would ever call os_printf_plus
from an ISR like state.
In the printout, I was trying to show the changes in the putc1
function and the print functions that it affected and how.
So my conclusion was that for debugging purposes ets_putc
, ets_uart_printf
, and uart_buff_switch
are the functions to use for printing from an ISR.
Update: Improved wording
Basic Infos
Platform
Settings in IDE
Problem Description
I have seen in several places where
ets_printf()
is the recommended function call for debug printing from an ISR; however, from what I see in the current master I don't think this is true anymore.ets_printf()
uses the character print function installed byets_install_putc1()
. At the start ofsetup()
the print function address resides in IRAM. OnceSerial.begin()
is called that print function address resides in flash. The MCVE below shows the function address under various situations and the resulting output across Serial and Serial1.It looks to me that of these options, the safest ISR debug print solution is to use
ets_uart_printf()
and/orets_putc()
. Both of these functions reside in ROM and neither uses the print function installed byets_install_putc1()
. They use an internal ROM function for printing, which requires a prior call touart_buff_switch()
to select a UART.MCVE Sketch
Debug Messages
From Serial
From Serial1