Writing Makefiles for firmware projects
The focus of this section is to write a Makefile and successfully test it. Let’s begin.
In our workspace folder, let’s make a new folder named 4_Makefiles
. In this folder, create a file called Makefile
. This file must start with a capital M and should have no extension.
If you’re using Windows and it asks whether you really want to change the file extension, click Yes. Then, right-click the file and open it with a basic text editor, such as Notepad++.
Our objectives with the Makefile can be summarized as follows:
- The compilation of source code: We want to compile source files (
main.c
andstm32f411_startup.c
) into object files (main.o
andstm32f411_startup.o
). - Linking object files into an executable: Then, link the compiled object files, along with setting a specific memory layout using the linker script, (
stm32_ls.ld
) to create a final executable (4_makefile_project.elf
). - Loading and cleaning:
- Invoke...