Discuss here different C compiler set ups, and compiling executables for the ESP8266
User avatar
By itmarshall
#47348 Hi all,

I'm new to the ESP8266, and am trying to compile a very basic program (for now) that writes to the serial port on UART0 using "os_printf". To initialise the UART, I am calling the "uart_init" function, which appears in the SDK documentation in the "user_init" function. Unfortunately, I get a "warning: implicit declaration of function 'uart_init'" and "error: 'BIT_RATE_115200' undeclared (first use in this function)".

I have tried to look around, and example code I see is including "driver/uart.h", which I have copied from my SDK's "driver_lib" example(along with the "uart.c" file) to my local project and tried that, but I then get a lot of errors, including "warning: implicit declaration of function 'uart_div_modify'" and "error: 'RX_BUFF_SIZE' undeclared".

I have built the SDK for Linux using the "esp-open-sdk" at "https://github.com/pfalcon/esp-open-sdk" which uses SDK version 1.5.2. I have tried it with both STANDALONE=y and STANDALONE=n to no avail.

I would have thought that writing to the UART would be one of the simpler things to do, but I am totally stumped! Is there something that I'm missing? Some special incarnation of that make command that will allow it to work?

Thanks!
User avatar
By smh
#47394 G'day mate,

Within the user_init() function I've been using this line to setup the uart with baudrate of 115200.
Code: Select alluart_div_modify(0, UART_CLK_FREQ / 115200);

I think os_printf() just requires that osapi.h is included.

And viewing the uart output using screen
Code: Select allsudo screen /dev/ttyUSB0 115200


Hopefully that helps you
-smh
User avatar
By itmarshall
#47399 G'day smh,

Thanks for the tip, it let me get my UART to work with os_printf! I also took some bits from the Arduino serial implementation for the ESP8266 to get a putc equivalent that lets be write zero bytes (required for a protocol I've reverse engineered). I'm using the Python "miniterm.py" program to interact with the serial port, but will give the screen command a go, too - I've only seen it used for pseudo TTY logins on a box before.

Unfortunately, it seems that I've only worked around the problem of the includes, as I'm now stuck at the next barrier. :(

I am now trying to read from the UART0, with a call-back for when data arrives. I have implemented a "uart0_rx_intr_handler" function, but it is not being called. Once again, looking through samples or other code looks like I should be bringing in the files from the SDK's "examples/driver_lib" area, but I am still unable to get the thing to compile if I do so.

Is there any way to get a callback upon receiving some serial bytes? Or should I be setting up a timer and/or task to poll for any received bytes in the FIFO?

Thanks,

Ian.
User avatar
By smh
#47411 Hi Ian,

Reading from the UART is what I am also stuck on currently. :?

There are a few blog posts kicking around but nothing that I've found very useful. If you find anything please let me know too!