Trouble Getting printf() to work with ESP8266

Sysprogs forums Forums VisualGDB Trouble Getting printf() to work with ESP8266

This topic contains 4 replies, has 2 voices, and was last updated by  support 1 year, 8 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #13524

    TvdVen
    Participant

    Hi,

    I’m running the RTOS Http Demo for the ESP8266, using a Segger J-Link to debug.

    uart.h includes a uart_init_new() function, which I am calling in user_init(). As far as I can tell, this is all that should be necessary to then have printf() calls logged in the UART output.

    I do have some UART output (even without calling uart_init_new()), as far as I can tell, as logged by VisGDB:

    Does this mean the UART connection is working, but printf() somehow isn’t being logged there?

    I have left uart_init_new() as implemented by default:

    Any advice on how to get logging to work properly?

    #13526

    support
    Keymaster

    Hi,

    The “Info : debug cause: 0x8” and other similar messages come from OpenOCD – the command line tool used for debugging; it is not directly related to the UART port output.

    In order to see the UART output from esp8266, you would need to physically connect a USB-to-UART adapter to the UART pins on your module (please ensure you use a level translator, as UART and regular CMOS logic use different voltages and connecting them directly might burn one side). Once you connect it, you can see the UART output in the corresponding COM port (either via VisualGDB’s Embedded Terminal or using our free SmarTTY tool).

    #13542

    TvdVen
    Participant

    Thank you for the advice. I have now connected a USB-to-UART cable to my ESP8266 (alongside the Segger J-Link), and succeeded in opening a raw terminal for the COM port.

    I am receiving output on the COM port, but a lot more than the simple printf(“test”); that I am expecting, and it is all garbled (including the “test”).

    I have experimented with a few of the settings, mostly baud rate, which I think should be set to 74880. This value is also what the uart_config is set to in uart_init_new() (see OP).

    However, I have noticed that it works seemingly identically without calling uart_init_new(), so I am unsure whether this is necessary or what it is good for.

    My output looks like this before my call to printf():

    b??d???????????????????FC?????b?????????????????b???b?????D?????????????????b???b?????D??????????????????b???b?????D?????bG?B?SV@Y?VTRj1FXk?U?W?s5i?Ptm@ZhXxPd\2hY??X?!KefXIPPa?SV@YX[DGQm?QY*i?5tX?D+a_g??R\lRj!?1X63V?cv5GhG1i7_g??R^lRj!iVe??XYgWl\?D?{?Qv_%yhP?m*?[PPe??X?i?w?dXD

    Printing “test” adds Z*i.

    I doubt the garbled output will be helpful in helping you determine what might be going wrong, but do you have any suggestions as to what I could check/try?

    • This reply was modified 1 year, 8 months ago by  TvdVen.
    #13544

    TvdVen
    Participant

    I can’t seem to edit my previous post anymore, but I seem to have stumbled upon the fix since then. Changing the default baud rate of 74880 in the uart_init_new() function to 115200 and setting the COM port baud rate to that same value has resulted in legible output. Thank you for the assistance!

    #13555

    support
    Keymaster

    Hi,

    Good to know it works. If you encounter further issues, don’t hesitate to create another topic.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.