-
Notifications
You must be signed in to change notification settings - Fork 0
Makefiles
The stack uses Makefiles, with each application having a Makefile for the application settings.
This Makefile links to the Makefile.core, which will link to all the required makefiles of the drivers, shields and platforms.
The end user should only come into contact with the Application Makefile. If this file is set up correctly, the rest should be automated.
[[TOC]]
This file contains the high level settings of the application, such as the name, platform and the required shields.
The application name is defined as follows, and will end up being the name of the target binary.
# name of your application
APPLICATION = hello-worldThe application version is defined as follows.
# version of your application
APPLICATION_VERSION = 0.1.0The platform is defined as follows, with currently only the main octa platform being supported.
# platform for which the application will be built
PLATFORM ?= octaIf floats have to be printed of sprinted, some extra libraries have to be included. To do this, PRINT_FLOATS has to be set to 1.
# Set PRINT_FLOATS to 1 to enable linker flags enabling float printf & sprintf
PRINT_FLOATS = 1To use a shield in the application, the user has to define the name of the shield and a header connector in the application makefile. This connector number is passed to the code as a define using a -D parameter when compiling.
# SigFox
SHIELDS += SigFox
SIGFOX_CONNECTOR = 1An OCTA_header struct will to be passed to the driver. This struct contains UART, I2C, SPI and GPIO Handles.
These structs are defined during the platform initalization e.g. P1_header, P2_header, ...
It is up to the shield driver to initialize the required handle with the driver's specific settings.
struct OCTA_header{
uint8_t number;
UART_HandleTypeDef *uartHandle;
I2C_HandleTypeDef *i2cHandle;
SPI_HandleTypeDef *spiHandle;
struct OCTA_GPIO *DIO1;
struct OCTA_GPIO *DIO2;
struct OCTA_GPIO *DIO3;
struct OCTA_GPIO *DIO4;
struct OCTA_GPIO *DIO5;
struct OCTA_GPIO *DIO6;
uint8_t active;
};To use the FOTA SBSFU bootloader in the application, this has to be set in the Makefile as follows.
Some bootloader specific code also has to be implemented in the application, shown in the bootloader-minimal-example application.
# use the SBSFU bootloader
BOOTLOADER ?= 1To enable or disable the step up pin, the ENABLE_STEPUP variable has to be set to 1 or 0 respectively. This will step up the battery voltage to 5V to the octa headers.
# enable the stepup pin
ENABLE_STEPUP ?= 1To tell the code, mainly certain drivers, if the scheduler is used or not, the USE_RTOS variable has to be set to 1 or 0 respectively. If it is not defined, it defaulted to 1. Some drivers have RTOS specific functions (e.g. Murata), and need to know wether to use these functions or their non RTOS alternatives.
# don't use RTOS scheduler for this example
USE_RTOS_SCHEDULER = 0Log serial messages on FTDI uart instead of debug USB uart.
# log serial messages on FTDI uart instead of debug USB uart
USE_FTDI_LOGGING = 1Choose between different low power modes
# use low power mode 1
LOW_POWER = 1When enabling the debug mode, more debug messages will be logged to the serial port. This should be set to 0 when deploying an application.
# use debug mode during development
DEBUG = 1Finally, the link to the Makefile.core has to be made.
# Path to the octa-stack base directory:
STACKBASE ?= ../..
include $(STACKBASE)/core/Makefile.coreThe Makefile.core file is, as the name suggests, the core of every application.
First of all, the link to the selected platform, drivers and shields makefiles made.
After the source files, header files, startup files and linker script are defined, the code is compiled to application-name.hex,bin,elf.
Furthermore, make flash support is provided.
Both J-Link and ST-Link are supported by using make flash-jlink and make flash-st respectively.
In the Makefile.platform file, a check is done on the platform name of the application Makefile. If not valid, the make command will throw an error. If valid, the Makefile.include file of the common platform folder is included as well as the Makefile.include of said platform.
This file sets some platform specific setting such as the CPU type, platform specific source and header files, startup file and linker scripts.
A PLATFORM_DEFINE define is also created, which is passed to the code in the Makefile.core file.
# platform define var, passed to code when compiling in Makefile.core
PLATFORM_DEFINE += -D$(addprefix platform_,$(PLATFORM))The purpose of this file is to include every source and header file in the core/drivers/* folder.
This file will make sure that for every shield defined in the application Makefile, its Makefile.include file is included.
These files contain the source and header files of each shield respectively. It also serves as a way to not having to include every shield driver in every application.