5 Programming
(Englisch)
5.1 Memory Sections
In Figure 5.1 you see the different FLASH and SRAM sections of the STM32L4. Also have a look at the “starter” source code:
https://gitlab.com/hhoegl-tha/es/f446/starter
The memory sections are defined in the linker script STM32L476RG_FLASH.ld.
The first two entries in the vector table are important for the right program start:
Entry 0: initial stack pointer (sp). This vector table entry is the only vector which is not a “real vector”, which means, it is not a pointer to executable code.
Entry 1: initial program counter (pc)
You can print these two values with a GDB command:
(arm-gdb) x/2xw 0x08000000
5.2 Levels of abstraction
The following items are arranged from low to high abstraction level.
Standalone C, C++ or assembler program without dependencies to other libraries. This is the stronger definition of bare-metal programming. A more general definition is programming without operating system, but with additional libraries.
CMSIS: Abstraction of the Cortex M3 core and core peripherals. In addition a vendor specific part abstracts the microcontroller peripherals. CMSIS consists of a bunch of C header files.
STM32 Cube: Software framework with “hardware abstraction layer” (HAL) and “low layer” (LL). Cube also include the CMSIS layer.
libc: Standard C library (or libc++)
Middleware Libraries for graphical user interfaces, TCP/IP networking, file systems, realtime operating systems and so on.
High-level interpreters - for example JavaScript or Python.
The layers are often used in combinations:
Levels of programming
An overview of different programming techniques gives [YIUWAYS]. It covers Java, MatLab/SimuLink, Labview, Arduino, mbed, Finite State Machines and other programming languages like Ada, Pascal, BASIC.
Higher-level interpreted programming languages are more and more ported to microcontrollers. A few examples are JerryScript (https://jerryscript.net), eLua (https://www.eluaproject.net), Espruino (https://www.espruino.com) and Micropython (http://micropython.org).
5.3 CMSIS
Cortex Microcontroller Software Interface Standard
https://developer.arm.com/embedded/cmsis

CMSIS Blockdiagramm
Templates for startup code. The standard startup file in CMSIS is written in assembler (
startup_stm32l476xx.s). The startup code callsSystemInitwhich is defined insystem_stm32l4xx.c.Documentation in Cube Library
STM32Cube_FW_L4_V1.8.0/Drivers/CMSIS/Documentation/Core/html/Essential CMSIS files of version 4.30.

CMSIS Files You find the CMSIS file tree in one of the CMSIS projects ending with
-cmsis, e.g.starter-cmsisorgpio-intr-cmsis.
Literature
5.4 Cube L4
It consists of
- Hardware Abstraction Layer (HAL)
- Board Support Packages (BSP)
- CMSIS
- Middleware
- Example programs
A smaller version in which I removed some unneeded material is here:
https://hhoegl.informatik.hs-augsburg.de/es2/tools
See the file
stm32cubel4-1.8.0-small.tar.bz2(ca. 110 MByte)Cube F4 overview (from Getting started with STM32CubeF4 firmware package (UM1730))

STM32Cube Overview The diagram comes from Release Notes for STM32CubeL4 Firmware Package, which is contained in the Cube package.
5.5 Standard C library
Typical embedded system standard C libraries are
- Newlib https://sourceware.org/newlib
- Newlib-nano https://keithp.com/newlib-nano
- Picolibc https://keithp.com/picolibc, https://github.com/picolibc/picolibc
XXX to do