Software Architecture

mysran
Posts: 1
Joined: Thu Jul 12, 2018 1:23 pm

Software Architecture

Postby mysran » Thu Jul 12, 2018 1:35 pm

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

Pato
Posts: 32
Joined: Sat Mar 24, 2018 12:52 am

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 !

Who is online

Users browsing this forum: No registered users and 128 guests