Midgard¶
Midgard uses an easy to use STM32F7 Microcontroller, perfect for learning how to write embedded low-level software but still powerful enough for the majority of projects.
Setup¶
To start developing on the Yggdrasil platform using Midgard, the following things are needed:
See also
After starting the IDE for the first time, close the welcome screen and click on File -> Import...
.
Then import the Midgard Template using the Existing Project into Workspace
option.
Getting Started¶
For starting with embedded C development, simply open Core/main.c
, scroll down to find the main
function and in there scroll further down until you find a block
of code that looks like this:
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
All code goes between one of the /* USER CODE BEGIN XXX*/
and /*USER CODE END XXX*/
blocks. This is important since everything outside of these blocks
will be deleted when the project is regenerated with the .ioc file.
For starting with embedded C++ development, a few more things are needed.
First, create a new file called e.g cpp_main.cpp
in the Core/Src
folder. In there, include <yggdrasil.h>
and create a new function like this:
#include <yggdrasil.h>
C_LINKAGE void cpp_main() {
}
Then in main.c
again, add a function prototype to the top of the file:
void cpp_main(void);
Now call this function above the infinite loop in main
and add all your C++ code to the cpp_main
function.
Troubleshooting¶
Debugging works but execution doesn’t follow the code¶
If the wrong boot mode is selected, Midgard will start running code from the internal Boot ROM instead of the flash. These are mapped to the same addresses so when debugging, gdb thinks its executing your code but the actual executed code is the Boot ROM. Since your code and the Boot ROMs code differ, it looks as if your code jumps to seemingly random places at weird points.