Basic question on programming ESP8266 using Arduino IDE

Hi. I'm new to Arduino and I never used any Arduino board before so I don't really understand how this platform works. I'm now using the Arduino IDE to program the ESP8266-01S Wi-Fi module and I have some questions regarding the IDE and library.

  1. When we program the ESP using the Arduino IDE, we didn't specify the registers all that in our code. Is the ESP8266 core taking care all these things for us? So the core is basically something that let the IDE know the information about the registers and pins? Or these are being defined somewhere else?

  2. Is the library that is used for the ESP shared with other Arduino board? For example, it seems like the serial.print() function is used for both the Arduino board and the ESP8266.

  3. There are many different ways to program the ESP like using the SDK from Espressif, using Lua script and Arduino. Is all these methods upload different file types into the ESP memory?

  4. Is there any information regarding registers in the ESP8266? It seems like the datasheet from Espressif is not providing any information for the registers. Here is the datasheet that I found: https://www.espressif.com/sites/default/files/documentation/0a-esp8266ex_datasheet_en.pdf

Serial.print("Arduino"); is a High Level Language code, and it does not bear smell of any particular microcontroller. All HLL codes must be converted into Machine Codes and get loaded into program memory of the target MCU for excution. Now, the question is: machine codes of which microcontroller -- the target MCU? In the IDE, we select the Board Type: Arduino UNO for ATmega328P MCU, Arduino DUE for ATSAM3X8E MCU, and so on. The Compiler knows the MCU type from given Board type, and it accordingly converts/maps the HLL codes into binary codes that match with the General Purpose Register Set, Control Matrix, Instruction Register, Sequence generator etc. of the target MCU. Finally, (after going through many passes of compilation process) an executable binary file is generated that we upload into the MCU for execution.

Did you want to program the ESP8266 in assembler? For that, this part of the datasheet may be relevant:

Besides the Wi-Fi functionalities, ESP8266EX also integrates an enhanced version of Tensilica’s L106 Diamond series 32-bit processor and on-chip SRAM. It can be interfaced with external sensors and other devices through the GPIOs. Software Development Kit (SDK) provides sample codes for various applications.

the esp8266 can't be used without the SDK so all methods of using the esp8266 must be over the SDK.
some hardware information is in the SDK functions some is in the Arduino core.
the Arduino core has some files that don't change (or should not change) in specific cores and some core files are implemented for the specific boards package.
the Priint and Stream class are examples of the Arduino base classes which should be same in all cores. they are base classes for Serial, networking Client and similar input/output classes.
the Arduino.h file in core contains basic function defined by Arduino to work with io pins and similar. the implementation depends on MCU used of course.
the esp8266 WiFi library is based on Arduino WiFi library API so the basic usage is same.

pauline95:
So the core is basically something that let the IDE know the information about the registers and pins?

Correct. The core takes care of all that low level stuff for you to allow for more beginner friendly, portable code.

pauline95:
2. Is the library that is used for the ESP shared with other Arduino board? For example, it seems like the serial.print() function is used for both the Arduino board and the ESP8266.

No, it's not shared with any non-ESP8266 boards. Arduino has a standardized core library API that any responsible Arduino core author will follow as closely as possible. So the interface to the library is usually the same, but the low level code implementing that interface may be significantly different from one core to another.

pert:
Arduino has a standardized core library API that any responsible Arduino core author will follow as closely as possible.

So here the core library API is like C standard for C language that compiler vendor needs to follow? Is the same concept applies here?

[/quote]

pert:
So the interface to the library is usually the same, but the low level code implementing that interface may be significantly different from one core to another.

When you say the interface to the library, do you mean the way we write code, the syntax all that?

And another question is, in Arduino, we can write code in C or C++. So, whether we use C or C++, the compiler will know automatically or there is actually some setting in the compiler that tells the compiler what language we use?

Also, as the program is in C or C++, why would the println() be used? Isn't that a function in Java?

"println" is just a name - it could just as well have been called "printWithNewline"
Presumably it was chosen to be familiar to Java programmers, unlike Arduino's use of "byte"

pauline95:
Also, as the program is in C or C++, why would the println() be used? Isn't that a function in Java?

the builder uses the file extension to distinguish languages .c, .cpp, .S (assembly)

pauline95:
So here the core library API is like C standard for C language that compiler vendor needs to follow? Is the same concept applies here?

No. It's not a language standard. It's a collection of functions and macros written in standard C++ and C.

pauline95:
When you say the interface to the library, do you mean the way we write code, the syntax all that?

I mean the API. API stands for "application programming interface". An API is the set of publicly exposed functions and macros provided by a library. It's how your code interfaces with the code in the library.

pert:
It's a collection of functions and macros written in standard C++ and C.

So how does these function helps the Arduino core author in doing there job? If the Arduino core author follows the API, then we will be able to use all the library in the same way while using different board? For example, we can use serial.print() for all different kind of board? I'm sorry if I misunderstood your meaning, I just want to understand these things as it really makes me confused.

Juraj:
the builder uses the file extension to distinguish languages .c, .cpp, .S (assembly)

The file extension? Isn't all Arduino sketch has .ino file extension?

And when we saw an Arduino code, how do we differentiate whether it's C or C++? C and C++ looks really similar.

To a first order, C is a subset of C++.

pauline95:
The file extension? Isn't all Arduino sketch has .ino file extension?

Nope. All sketches must have at least one .ino file, and the default file extension is .ino but you're welcome to add .cpp, .h, .c, or .S files to your sketch as well, and the compiler will automatically compile them as C++, C, or assembly according to the file extension. Only the .ino files undergo the special sketch pre-processing steps.

pauline95:
If the Arduino core author follows the API, then we will be able to use all the library in the same way while using different board? For example, we can use serial.print() for all different kind of board?

Correct.

pert:
All sketches must have at least one .ino file, and the default file extension is .ino but you're welcome to add .cpp, .h, .c, or .S files to your sketch as well, and the compiler will automatically compile them as C++, C, or assembly according to the file extension.

I think I don't understand this. What does the .ino file mean actually? Like .c tells us the source code is being written in C and .cpp tells us that the source code is being written in C++, what does the .ino mean then?

If I don't add additional file like .cpp or .c file, how does the compiler knows what language I am using?

It's the tail of Arduino

You need to stop overthinking this, especially at this stage. An .ino file is simply C++ code that undergoes some additional pre-processing (to make things easier for Newbies) before being handed to the compiler.

pauline95:
what does the .ino mean then?

.ino is the file extension of Arduino sketch files. The Arduino IDE does a special pre-processing operation on these files to make them valid C++, renames the resulting file with the .cpp extension, then compiles them as C++.

You can find a description of the sketch pre-processing process here:

pauline95:
how does the compiler knows what language I am using?

.ino files are always compiled as C++ after preprocessing no matter what.