mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-23 04:45:37 +08:00
58aa596ac9
The ADC was running at different frequencies, depending on which timer was used (e.g. TIM1 is on high speed APB2, TIM2 on low speed APB1). And seems it was running a LOT slower on F4. TRGO is used to trigger ADC conversion, which generated upon reaching period reload value. That was 0xFFFF on F4 and 0xFF on F1. So it seems that before this commit we had: F1: ---- All timers normally all run with 72MHz as we have set it up... * with prescaler of 8: we get 72MHz/9 = 8MHz timer freq * with period of 0xFF: ADC conversions at 8MHz / 255 = ~31kHz F4: ---- TIM1 is on ABP2 witch means twice as fast as e.g. TIM2 on APB1: timers run at 2xAPB frew: on high speed bus 168MHZ and on low speed with 84MHz * with prescaler of 0x53: 168MHz/84 = 2MHz timer freq for TIM1 (1MHz for TIM2) * with period of 0xFFFF: 2MHZ / 0xFFFF = ~30Hz (15Hz for TIM2) That is a difference of factor 1000 between F1 and F4!! Now it will run at same freq regarless of wich TIM is used (and same on F1/F4): default ADC update freq: ADC_TIMER_FREQUENCY / ADC_TIMER_PERIOD = 2MHz / 1000 = 2kHz
326 lines
9.1 KiB
Makefile
326 lines
9.1 KiB
Makefile
# Hey Emacs, this is a -*- makefile -*-
|
|
#
|
|
# Copyright (C) 2012 The Paparazzi Team
|
|
#
|
|
# This file is part of paparazzi.
|
|
#
|
|
# paparazzi is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2, or (at your option)
|
|
# any later version.
|
|
#
|
|
# paparazzi is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with paparazzi; see the file COPYING. If not, write to
|
|
# the Free Software Foundation, 59 Temple Place - Suite 330,
|
|
# Boston, MA 02111-1307, USA.
|
|
#
|
|
|
|
|
|
# Verify that libopencm3 is compiled with chibios compatible float abi
|
|
# correct abi is -mfloat-abi=softfp
|
|
# on non chibios branches, libopencm3 is compiled with more optimised -mfloat-abi=hard
|
|
TAG_ABI_VFP_COUNT= \
|
|
$(shell (readelf -A $(PAPARAZZI_SRC)/sw/ext/libopencm3/lib/libopencm3_stm32f4.a | \
|
|
grep -c Tag_ABI_VFP_args))
|
|
|
|
ifneq ($(TAG_ABI_VFP_COUNT),0)
|
|
$(error libopencm3_stm32f4.a is generated with chibios incompatible -mfloat-abi=hard, \
|
|
please recompile with -mfloat-abi=softfp))
|
|
endif
|
|
|
|
|
|
#
|
|
# This is the common Makefile for target using chibios
|
|
|
|
CHIBIOS_BOARD_DIR = $(PAPARAZZI_SRC)/sw/airborne/boards/$(BOARD)/chibios-libopencm3
|
|
CHIBIOS_LIB_DIR = $(PAPARAZZI_SRC)/sw/airborne/subsystems/chibios-libopencm3
|
|
CHIBIOS_EXT = $(PAPARAZZI_SRC)/sw/ext/chibios
|
|
OPENCM3_EXT = $(PAPARAZZI_SRC)/sw/ext/libopencm3
|
|
PPRZ_GENERATED = $(AIRCRAFT_BUILD_DIR)/$(AIRCRAFT)/$(TARGET)/generated
|
|
PPRZ_CHIBIOS_OCM3 = $(SRC_FIRMWARE)/chibios-libopencm3
|
|
|
|
# Launch with "make Q=''" to get full command display
|
|
Q=@
|
|
|
|
#
|
|
# General rules
|
|
#
|
|
|
|
$(TARGET).srcsnd = $(notdir $($(TARGET).srcs))
|
|
$(TARGET).objso = $($(TARGET).srcs:%.c=$(OBJDIR)/%.o)
|
|
$(TARGET).objs = $($(TARGET).objso:%.S=$(OBJDIR)/%.o)
|
|
|
|
|
|
|
|
##############################################################################
|
|
# Build global options
|
|
# NOTE: Can be overridden externally.
|
|
#
|
|
|
|
# Paparazzi options here.
|
|
ifeq ($(PPRZ_DEFINITION),)
|
|
PPRZ_DEFINITION = -DRTOS_IS_CHIBIOS -DUSE_ADC_WATCHDOG -DSYS_TIME_FREQUENCY=1000
|
|
endif
|
|
|
|
# Compiler options here.
|
|
ifeq ($(USE_OPT),)
|
|
# ChibiOS already define OPT
|
|
CH_OPT ?= 0 -g -ggdb3 -fno-inline
|
|
|
|
USE_OPT = -std=gnu11 -O$(CH_OPT) \
|
|
-falign-functions=16 -fno-omit-frame-pointer\
|
|
-W -Wall -Werror -Wno-error=unused-variable -Wno-error=format \
|
|
-Wno-error=unused-function -Wno-error=unused-parameter \
|
|
$(PPRZ_DEFINITION)
|
|
endif
|
|
|
|
|
|
# C specific options here (added to USE_OPT).
|
|
ifeq ($(USE_COPT),)
|
|
USE_COPT =
|
|
endif
|
|
|
|
# C++ specific options here (added to USE_OPT).
|
|
ifeq ($(USE_CPPOPT),)
|
|
USE_CPPOPT = -fno-rtti
|
|
endif
|
|
|
|
# Enable this if you want the linker to remove unused code and data
|
|
ifeq ($(USE_LINK_GC),)
|
|
USE_LINK_GC = yes
|
|
endif
|
|
|
|
# If enabled, this option allows to compile the application in THUMB mode.
|
|
ifeq ($(USE_THUMB),)
|
|
USE_THUMB = yes
|
|
endif
|
|
|
|
# Enable this if you want to see the full log while compiling.
|
|
ifeq ($(USE_VERBOSE_COMPILE),)
|
|
ifeq ($(Q),@)
|
|
USE_VERBOSE_COMPILE = no
|
|
else
|
|
USE_VERBOSE_COMPILE = yes
|
|
endif
|
|
endif
|
|
|
|
#
|
|
# Build global options
|
|
##############################################################################
|
|
|
|
##############################################################################
|
|
# Architecture or project specific options
|
|
#
|
|
|
|
# Enables the use of FPU on Cortex-M4.
|
|
ifeq ($(USE_FPU),)
|
|
USE_FPU = yes
|
|
endif
|
|
|
|
|
|
#
|
|
# Architecture or project specific options
|
|
##############################################################################
|
|
|
|
##############################################################################
|
|
# Project, sources and paths
|
|
#
|
|
|
|
# Define project name here
|
|
PROJECT = ap
|
|
|
|
# Imported source files and paths
|
|
|
|
CHIBIOS = $(CHIBIOS_EXT)
|
|
OPENCM3 = $(OPENCM3_EXT)
|
|
OPENCM3_INC = $(OPENCM3)/include
|
|
OPENCM3_LIB = $(OPENCM3)/lib/
|
|
|
|
include $(CHIBIOS_BOARD_DIR)/board.mk
|
|
include $(CHIBIOS)/os/hal/platforms/STM32F4xx/platform.mk
|
|
include $(CHIBIOS)/os/hal/hal.mk
|
|
include $(CHIBIOS)/os/ports/GCC/ARMCMx/STM32F4xx/port.mk
|
|
#include $(CHIBIOS)/os/various/fatfs_bindings/fatfs.mk
|
|
include $(PAPARAZZI_HOME)/conf/chibios/fatfs.mk
|
|
include $(PAPARAZZI_HOME)/conf/chibios/chibi_lib_for_pprz.mk
|
|
|
|
# HACK : in order to make chibios to work with opencm3, we need a specially crafted
|
|
# vector.c file, with some vectors for chibios, and others for opencm3
|
|
# shunting should be done in mcuconf.h
|
|
PORTSRC := $(subst $(CHIBIOS)/os/ports/GCC/ARMCMx/STM32F4xx/vectors.c,\
|
|
$(PAPARAZZI_SRC)/sw/airborne/arch/stm32/stm32f4_chibios_vectors.c,\
|
|
$(PORTSRC))
|
|
|
|
include $(CHIBIOS)/os/kernel/kernel.mk
|
|
|
|
# Define linker script file here
|
|
LDSCRIPT= $($(TARGET).LDSCRIPT)
|
|
|
|
|
|
# C sources that can be compiled in ARM or THUMB mode depending on the global
|
|
# setting.
|
|
CSRC = $(PORTSRC) \
|
|
$(KERNSRC) \
|
|
$(TESTSRC) \
|
|
$(HALSRC) \
|
|
$(PLATFORMSRC) \
|
|
$(BOARDSRC) \
|
|
$(FATFSSRC) \
|
|
$(CHIBIOSLIBSRC) \
|
|
$(CHIBIOS)/os/various/chrtclib.c \
|
|
$(CHIBIOS)/os/various/syscalls.c
|
|
|
|
ECSRC = $($(TARGET).srcs)
|
|
|
|
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
|
|
# setting.
|
|
CPPSRC =
|
|
|
|
# C sources to be compiled in ARM mode regardless of the global setting.
|
|
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
|
# option that results in lower performance and larger code size.
|
|
ACSRC =
|
|
|
|
# C++ sources to be compiled in ARM mode regardless of the global setting.
|
|
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
|
# option that results in lower performance and larger code size.
|
|
ACPPSRC =
|
|
|
|
# C sources to be compiled in THUMB mode regardless of the global setting.
|
|
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
|
# option that results in lower performance and larger code size.
|
|
TCSRC =
|
|
|
|
# C sources to be compiled in THUMB mode regardless of the global setting.
|
|
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
|
|
# option that results in lower performance and larger code size.
|
|
TCPPSRC =
|
|
|
|
# List ASM source files here
|
|
ASMSRC = $(PORTASM)
|
|
|
|
INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \
|
|
$(HALINC) $(PLATFORMINC) $(BOARDINC) \
|
|
$(CHIBIOS)/os/various $(OPENCM3_INC) \
|
|
$(CHIBIOS_BOARD_DIR) $(CHIBIOS_LIB_DIR) \
|
|
$(PPRZ_GENERATED) $(FATFSINC) \
|
|
$(PPRZ_CHIBIOS_OCM3)
|
|
|
|
BUILDDIR := $(OBJDIR)
|
|
#
|
|
# Project, sources and paths
|
|
##############################################################################
|
|
|
|
##############################################################################
|
|
# Compiler settings
|
|
#
|
|
|
|
MCU = cortex-m4
|
|
|
|
#TRGT = arm-elf-
|
|
TRGT = arm-none-eabi-
|
|
CC = $(TRGT)gcc
|
|
CPPC = $(TRGT)g++
|
|
# Enable loading with g++ only if you need C++ runtime support.
|
|
# NOTE: You can use C++ even without C++ support if you are careful. C++
|
|
# runtime support makes code size explode.
|
|
LD = $(TRGT)gcc
|
|
#LD = $(TRGT)g++
|
|
CP = $(TRGT)objcopy
|
|
AS = $(TRGT)gcc -x assembler-with-cpp
|
|
OD = $(TRGT)objdump
|
|
HEX = $(CP) -O ihex
|
|
BIN = $(CP) -O binary
|
|
|
|
# ARM-specific options here
|
|
AOPT =
|
|
|
|
# THUMB-specific options here
|
|
TOPT = -mthumb -DTHUMB
|
|
|
|
# Define C warning options here
|
|
CWARN = -Wall -Wextra -Wstrict-prototypes
|
|
|
|
# Define C++ warning options here
|
|
CPPWARN = -Wall -Wextra
|
|
|
|
#
|
|
# Compiler settings
|
|
##############################################################################
|
|
|
|
##############################################################################
|
|
# Start of default section
|
|
#
|
|
|
|
# List all default C defines here, like -D_DEBUG=1
|
|
DDEFS = -DSTM32F4
|
|
#DDEFS =
|
|
|
|
# List all default ASM defines here, like -D_DEBUG=1
|
|
DADEFS =
|
|
|
|
# List all default directories to look for include files here
|
|
DINCDIR =
|
|
|
|
# List the default directory to look for the libraries here
|
|
DLIBDIR = $(OPENCM3_LIB)
|
|
|
|
# List all default libraries here
|
|
DLIBS = -lm -lopencm3_stm32f4
|
|
#DLIBS = -lm -lc -lnosys -nostartfiles -Wl,--gc-sections
|
|
|
|
#
|
|
# End of default section
|
|
##############################################################################
|
|
|
|
##############################################################################
|
|
# Start of user section
|
|
#
|
|
|
|
# List all user C define here, like -D_DEBUG=1
|
|
UDEFS = $($(TARGET).CFLAGS) $(LOCAL_CFLAGS) -DUSE_OCM3_SYSTICK_INIT=0
|
|
|
|
# Define ASM defines here
|
|
UADEFS =
|
|
|
|
# List all user directories here
|
|
# remove -I before include dir because ChibiOS is adding them again
|
|
UINCDIR = $(patsubst -I%,%,$(INCLUDES))
|
|
|
|
# List the user directory to look for the libraries here
|
|
ULIBDIR =
|
|
|
|
# List all user libraries here
|
|
ULIBS =
|
|
|
|
#
|
|
# End of user defines
|
|
##############################################################################
|
|
|
|
#
|
|
# Include upload rules
|
|
##############################################################################
|
|
include $(PAPARAZZI_HOME)/conf/Makefile.arm-embedded-toolchain
|
|
include $(PAPARAZZI_HOME)/conf/Makefile.stm32-upload
|
|
|
|
|
|
ifeq ($(USE_FPU),yes)
|
|
USE_OPT += -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -fsingle-precision-constant
|
|
DDEFS += -DCORTEX_USE_FPU=TRUE
|
|
else
|
|
DDEFS += -DCORTEX_USE_FPU=FALSE
|
|
endif
|
|
|
|
EXTRA_RULES_INCLUDE_PATH = $(PAPARAZZI_HOME)/conf/chibios/chibios_extra_rules.mk
|
|
include $(PAPARAZZI_HOME)/conf/chibios/chibios_rules.mk
|
|
|
|
|
|
|
|
|
|
#include $(CHIBIOS_EXT)/os/ports/GCC/ARMCMx/rules.mk
|