Introduction to the architecture

Makefile Introduction

Each project has its own makefile file (already explained above), and they all include the compiler_config.mk in the top-level directory, and the compiler_config.mk file contains other .mk files.

Here we introduce the following important .mk files, if you understand them, it is not a problem for you to do DIY.

  • compiler_config.mk:

In a word, it defines the appropriate rules to compile the .elf file and convert it into .hex and .bin firmware for burning according to the appropriate compilation process.

Important code segments

ifeq "$(strip $(BOOTLOADER_MODE))" "enable"
DDEFS           += -DBOOTLOADER_ENABLE
endif

Parse BootLoader enablement and define global macros to characterize enablement disablement.

ARMGCC        = $(TOP_PATH)/5_Development_Toolchain/gcc-arm-none-eabi-5_4-2016q2/bin/arm-none-eabi-gcc
ifeq ($(ARMGCC),$(wildcard $(ARMGCC)))
CCPREFIX    ?= $(TOP_PATH)/5_Development_Toolchain/gcc-arm-none-eabi-5_4-2016q2/bin/arm-none-eabi-
else
 CCPREFIX    ?= arm-none-eabi-
endif
  • Look for the compiler in the specified directory, and if it is not found, enable the compiler installed in your computer. It's mainly for the convenience of internal developers, and may not be useful for everyone. *OPT += -O0

  • Optimization level of ARMGCC cross-compilation, optional parameters are 0, 1, 2, s. It is recommended to enable 0-level optimization during debug, which can solve many potential problems of the program, and enable s-level optimization after successful compilation to reduce the size of the file generated after compilation.

ifeq "$(strip $(CPU_TYPE))" "STM32F1"
FPU_STATE       == disable
endif
ifeq "$(strip $(CPU_TYPE))" "STM32F4"
FPU_STATE       == enable
endif
ifeq "$(strip $(FPU_STATE))" "enable"
OPT     += -mfloat-abi=hard
OPT     += -mfpu=fpv4-sp-d16
endif
  • Depending on the chip model, decide whether to enable the FPU (floating point unit) or not. Then choose whether to use other corresponding compilation options such as hardware floating point, depending on whether to enable FPU or not. *

  • system_para.mk:

    This file is mainly a parameter setting file for board hardware resource allocation. At present, it is mainly to solve the communication port resource allocation.

ifeq "$(strip $(BOARD_TYPE))" "control_unit_mini"
DEBUG_PRINTF_INTERFACE ?= usart_interface_4
PC_INTERFACE ?= usart_interface_1
RADIO_INTERFACE ?= usart_interface_4
endif
  • The function of the three code segments at the beginning is to set the specific hardware resource allocation according to the current board model (already determined in the top-level makefile). For example, the above code means that serial port 4 is used as the communication port for debug, serial port 1 is used as the communication port between the pc side and the main control board, and serial port 4 is also used as the communication port between the main control and the remote control. *

    What comes after this is to set up global macro definitions to be passed into the program based on the parameters determined before.

  • board.mk:
ifeq "$(strip $(BOARD_TYPE))" "control_unit_mini"
DDEFS           += -DCONTROL_UNIT_MINI -DSTM32F10X
DDEFS           += -DHSE_VALUE=8000000 -DUSE_STDPERIPH_DRIVER
MCU             ?= cortex-m3
CPU_TYPE        ?= STM32F1
BOARD_ABSTRACT  += $(TOP_PATH)/1_Processor/BoardAbstract/control_unit_mini.cpp
endif
  • package.mk:
CXX_SRC+=$(foreachn,$(PAKG),$(wildcard$(PACKAGE_PATH)/$(n)/* .cpp))

The function of the above code segment is to parse the PAKG variable of the makefile and include its source file and path whenever it is a dependent package.

Write robot programs based on OpenRE and HandsFree master

results matching ""

    No results matching ""