Hello,
I am new to ESP8266 and learning more about it. I more or less know about the hardware components. I am a bit confused on the software part. Please clarify me on the below queries.
1. I couldn't find any software architecture document on ESP8266. Please send me a link on this.
2. I also couldn't find anything on the presence of any operating systems(RTOS) on it. Please correct me if I am wrong and also provide some documentation on this.
3. If the above is wrong, does it just contain the boot loader which runs the flashed code.
Regards,
mysran
Software Architecture
Re: Software Architecture
Postby Pato » Tue Jul 24, 2018 1:40 am
Hi,
Here is my basic understanding so far, certainly not accurate, but maybe it can give you some hints
I will assume you are talking about bare C software programming (the one I play with):
1) The ESP being basically a microcontroller, you decide the sofware architecture... However, Espressif provides SDKs to abstract all the low-level and HAL interface (to handle the i2c, the WiFi, etc). As I understand it the code of the SDK has the standard 'main()' entry points and runs in a kindof endless loop. For me, this is the Hardware Abstraction Layer.
On top on this SDK, you can build your own code. As the main() is already taken by the SDK, it provides you a "secondary" entry point with the canonical name "user_init()" (function called by the SDK some time after boot and after the SDK did some partial initialization) where your custom code must begin (it's nearly like a "main()").
The natural architecture for the ESP is via timers and callback functions, or system task and messaging (https://bbs.espressif.com/viewtopic.php?t=838), as you must not block the execution with your custom code for too long: the SDK needs CPU time to handle all the HAL stuff and especially all about TCP/WiFi.
Kolban's book about ESP8266 turns out to be a very good introduction for me !
2) The SDK comes in RTOS (based on FreeRtos if I remember) and NON-RTOS version: you can have little info in "ESP8266 SDK Getting Started Guide" (you'll see that with the ESP, the scarce documentation is mainly spread all over the Internet via user forums and sample codes. The official one is here: https://www.espressif.com/en/support/do ... d%5B%5D=14)
However I personnaly consider the NONOS SDK layer as a minimal operating system.
3) To conclude (very simplified), I would say:
Bootloader -> Run flashed code ( SDK code + your code starting in "user_init()" that must share the execution time)
NB: The bootloader must be flashed along with your own code. Note there is different versions of the bootloader, e.g. depending on if you plan to do OTA upgrade or not...
NB2: I found precious informations there when I started:
The official documentation from Espressif, which slowly goes more and more furnished:
https://www.espressif.com/en/support/download/documents
Very nice introduction with bare C programming:
https://hackaday.com/2015/03/18/how-to- ... fi-module/
An explanation of the skeleton of a C code for the Esp:
http://sub.nanona.fi/esp8266/source-skeleton.html
How to wire the ESP for a flash and to test it:
http://www.esp8266.com/wiki/doku.php?id ... he-esp8266
A simple but well-detailed C example:
https://www.cnx-software.com/2016/10/07 ... -language/
If you need help to setup Lubuntu on VirtualBox:
https://dwheelerau.com/2014/01/25/setti ... rtual-box/
Info and example about the obscure FOTA (Firmware-On-The-Air) ability that never worked for me:
http://harizanov.com/2015/06/firmware-o ... p8266-soc/
I hope it started to answer your question !
Here is my basic understanding so far, certainly not accurate, but maybe it can give you some hints

I will assume you are talking about bare C software programming (the one I play with):
1) The ESP being basically a microcontroller, you decide the sofware architecture... However, Espressif provides SDKs to abstract all the low-level and HAL interface (to handle the i2c, the WiFi, etc). As I understand it the code of the SDK has the standard 'main()' entry points and runs in a kindof endless loop. For me, this is the Hardware Abstraction Layer.
On top on this SDK, you can build your own code. As the main() is already taken by the SDK, it provides you a "secondary" entry point with the canonical name "user_init()" (function called by the SDK some time after boot and after the SDK did some partial initialization) where your custom code must begin (it's nearly like a "main()").
The natural architecture for the ESP is via timers and callback functions, or system task and messaging (https://bbs.espressif.com/viewtopic.php?t=838), as you must not block the execution with your custom code for too long: the SDK needs CPU time to handle all the HAL stuff and especially all about TCP/WiFi.
Kolban's book about ESP8266 turns out to be a very good introduction for me !
2) The SDK comes in RTOS (based on FreeRtos if I remember) and NON-RTOS version: you can have little info in "ESP8266 SDK Getting Started Guide" (you'll see that with the ESP, the scarce documentation is mainly spread all over the Internet via user forums and sample codes. The official one is here: https://www.espressif.com/en/support/do ... d%5B%5D=14)
However I personnaly consider the NONOS SDK layer as a minimal operating system.
3) To conclude (very simplified), I would say:
Bootloader -> Run flashed code ( SDK code + your code starting in "user_init()" that must share the execution time)
NB: The bootloader must be flashed along with your own code. Note there is different versions of the bootloader, e.g. depending on if you plan to do OTA upgrade or not...
NB2: I found precious informations there when I started:
The official documentation from Espressif, which slowly goes more and more furnished:
https://www.espressif.com/en/support/download/documents
Very nice introduction with bare C programming:
https://hackaday.com/2015/03/18/how-to- ... fi-module/
An explanation of the skeleton of a C code for the Esp:
http://sub.nanona.fi/esp8266/source-skeleton.html
How to wire the ESP for a flash and to test it:
http://www.esp8266.com/wiki/doku.php?id ... he-esp8266
A simple but well-detailed C example:
https://www.cnx-software.com/2016/10/07 ... -language/
If you need help to setup Lubuntu on VirtualBox:
https://dwheelerau.com/2014/01/25/setti ... rtual-box/
Info and example about the obscure FOTA (Firmware-On-The-Air) ability that never worked for me:
http://harizanov.com/2015/06/firmware-o ... p8266-soc/
I hope it started to answer your question !
Who is online
Users browsing this forum: No registered users and 128 guests
Login
Newbies Start Here
Are you new to ESP8266?
Unsure what to do?
Dunno where to start?
Start right here!
Latest SDK
Documentation
Complete listing of the official ESP8266 related documentation release by ESPRESSIF!
Must read here!
- All times are UTC+08:00
- Top
- Delete all board cookies
About Us
Espressif Systems is a fabless semiconductor company providing cutting-edge low power WiFi SoCs and wireless solutions for wireless communications and Internet of Things applications. We are the manufacturer of ESP8266EX.