Commit 6245b689 authored by Ian McInerney's avatar Ian McInerney

Baseline firmware version

parent 07245a50
^bin/dep/all
bin/*
.cproject
.project
.settings/*
*~
config.mk
cflie.*
# CrazyFlie's Makefile
# Copyright (c) 2011,2012 Bitcraze AB
# This Makefile compiles all the objet file to ./bin/ and the resulting firmware
# image in ./cflie.elf and ./cflie.bin
#Put your personal build config in config.mk and DO NOT COMMIT IT!
-include config.mk
######### JTAG and environment configuration ##########
OPENOCD ?= openocd
OPENOCD_INTERFACE ?= interface/stlink-v2.cfg
OPENOCD_TARGET ?= target/stm32f4x_stlink.cfg
CROSS_COMPILE ?= arm-none-eabi-
PYTHON2 ?= python2
DFU_UTIL ?= dfu-util
CLOAD ?= 1
F405 ?= 1
USE_FPU ?= 0
DEBUG ?= 0
CLOAD_SCRIPT ?= ../crazyflie-clients-python/bin/cfloader
# Now needed for SYSLINK
CFLAGS += -DUSE_RADIOLINK_CRTP # Set CRTP link to radio
CFLAGS += -DENABLE_UART # To enable the uart
## Flag that can be added to config.mk
# CFLAGS += -DUSE_ESKYLINK # Set CRTP link to E-SKY receiver
# CFLAGS += -DDEBUG_PRINT_ON_UART # Redirect the console output to the UART
REV ?= E
#OpenOCD conf
RTOS_DEBUG ?= 0
############### Location configuration ################
FREERTOS = lib/FreeRTOS
ifeq ($(USE_FPU), 1)
PORT = $(FREERTOS)/portable/GCC/ARM_CM4F
else
PORT = $(FREERTOS)/portable/GCC/ARM_CM3
endif
ifeq ($(F405), 1)
LINKER_DIR = scripts/F405/linker
ST_OBJ_DIR = scripts/F405
else
LINKER_DIR = scripts/F103/linker
ST_OBJ_DIR = scripts/F103
endif
STLIB = lib
################ Build configuration ##################
# St Lib
ifeq ($(F405), 1)
VPATH += $(STLIB)/CMSIS/STM32F4xx/Source/
VPATH += $(STLIB)/STM32_CPAL_Driver/src
VPATH += $(STLIB)/STM32_USB_Device_Library/Core/src
VPATH += $(STLIB)/STM32_USB_OTG_Driver/src
VPATH += $(STLIB)/STM32_CPAL_Driver/devices/stm32f4xx
CRT0 = startup_stm32f40xx.o system_stm32f4xx.o
endif
# Should maybe be in separate file?
-include $(ST_OBJ_DIR)/st_obj.mk
ifeq ($(F405), 1)
ST_OBJ += cpal_hal.o cpal_i2c.o cpal_usercallback_template.o cpal_i2c_hal_stm32f4xx.o
# USB obj
ST_OBJ += usb_core.o usb_dcd_int.o usb_dcd.o
# USB Device obj
ST_OBJ += usbd_ioreq.o usbd_req.o usbd_core.o
endif
# FreeRTOS
VPATH += $(PORT)
PORT_OBJ=port.o
VPATH += $(FREERTOS)/portable/MemMang
MEMMANG_OBJ = heap_4.o
VPATH += $(FREERTOS)
FREERTOS_OBJ = list.o tasks.o queue.o timers.o $(MEMMANG_OBJ)
# Crazyflie
ifeq ($(F405), 1)
VPATH += init hal/src modules/src utils/src drivers/src platform/cf2
else
VPATH += init hal/src modules/src utils/src drivers/src
endif
############### Source files configuration ################
# Init
ifeq ($(F405), 1)
PROJ_OBJ = main.o platform_cf2.o
else
PROJ_OBJ = main.o
endif
# Drivers
PROJ_OBJ += led.o exti.o nvic.o
ifeq ($(F405), 1)
PROJ_OBJ += mpu6500.o motors_f405.o i2cdev_f405.o ws2812.o lps25h.o ak8963.o eeprom.o
PROJ_OBJ += uart_syslink.o swd.o
# USB Files
PROJ_OBJ += usbd_usr.o usb_bsp.o usblink.o usbd_desc.o usb.o
else
PROJ_OBJ += mpu6050.o motors.o hmc5883l.o ms5611.o
endif
# Hal
PROJ_OBJ += crtp.o ledseq.o freeRTOSdebug.o syslink.o
ifeq ($(F405), 1)
PROJ_OBJ += imu_cf2.o pm_f405.o radiolink.o ow.o
else
PROJ_OBJ += imu.o pm.o
endif
# Modules
PROJ_OBJ += system.o comm.o console.o pid.o crtpservice.o param.o mem.o platformservice.o
PROJ_OBJ += commander.o controller.o sensfusion6.o stabilizer.o
PROJ_OBJ += log.o worker.o neopixelring.o expbrd.o
# Expansion boards
PROJ_OBJ += exptest.o
# Utilities
PROJ_OBJ += filter.o cpuid.o cfassert.o configblockeeprom.o eprintf.o crc.o fp16.o debug.o
PROJ_OBJ += version.o
OBJ = $(CRT0) $(FREERTOS_OBJ) $(PORT_OBJ) $(ST_OBJ) $(PROJ_OBJ)
ifdef P
C_PROFILE = -D P_$(P)
endif
############### Compilation configuration ################
AS = $(CROSS_COMPILE)as
CC = $(CROSS_COMPILE)gcc
LD = $(CROSS_COMPILE)gcc
SIZE = $(CROSS_COMPILE)size
OBJCOPY = $(CROSS_COMPILE)objcopy
INCLUDES = -I$(FREERTOS)/include -I$(PORT) -I.
INCLUDES+= -Iconfig -Ihal/interface -Imodules/interface
INCLUDES+= -Iutils/interface -Idrivers/interface -Iplatform
INCLUDES+= -I$(STLIB)/CMSIS/Include
ifeq ($(F405), 1)
INCLUDES+= -I$(STLIB)/STM32F4xx_StdPeriph_Driver/inc
INCLUDES+= -I$(STLIB)/STM32_CPAL_Driver/inc
INCLUDES+= -I$(STLIB)/STM32_USB_Device_Library/Core/inc
INCLUDES+= -I$(STLIB)/STM32_USB_OTG_Driver/inc
INCLUDES+= -I$(STLIB)/STM32_CPAL_Driver/devices/stm32f4xx
INCLUDES+= -I$(STLIB)/CMSIS/STM32F4xx/Include
endif
ifeq ($(USE_FPU), 1)
PROCESSOR = -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16
else
PROCESSOR = -mcpu=cortex-m4 -mthumb
endif
#Flags required by the ST library
ifeq ($(F405), 1)
STFLAGS = -DSTM32F4XX -DSTM32F40_41xxx -DHSE_VALUE=8000000 -DUSE_STDPERIPH_DRIVER
else
STFLAGS = -DSTM32F10X_MD -DHSE_VALUE=16000000 -include stm32f10x_conf.h
endif
ifeq ($(DEBUG), 1)
CFLAGS += -O0 -g3
else
CFLAGS += -Os -g3
endif
ifeq ($(LTO), 1)
CFLAGS += -flto
endif
ifeq ($(USE_ESKYLINK), 1)
CFLAGS += -DUSE_ESKYLINK
endif
CFLAGS += -DBOARD_REV_$(REV)
CFLAGS += $(PROCESSOR) $(INCLUDES) $(STFLAGS) -Wall -fno-strict-aliasing $(C_PROFILE)
# Compiler flags to generate dependency files:
CFLAGS += -MD -MP -MF $(BIN)/dep/$(@).d -MQ $(@)
#Permits to remove un-used functions and global variables from output file
CFLAGS += -ffunction-sections -fdata-sections
ASFLAGS = $(PROCESSOR) $(INCLUDES)
LDFLAGS = $(PROCESSOR) -Wl,-Map=$(PROG).map,--cref,--gc-sections
#Flags required by the ST library
ifeq ($(CLOAD), 1)
LDFLAGS += -T $(LINKER_DIR)/FLASH_CLOAD.ld
LOAD_ADDRESS = 0x8004000
else
LDFLAGS += -T $(LINKER_DIR)/FLASH.ld
LOAD_ADDRESS = 0x8000000
endif
ifeq ($(LTO), 1)
LDFLAGS += -Os -flto -fuse-linker-plugin
endif
#Program name
PROG = cflie
#Where to compile the .o
BIN = bin
VPATH += $(BIN)
#Dependency files to include
DEPS := $(foreach o,$(OBJ),$(BIN)/dep/$(o).d)
##################### Misc. ################################
ifeq ($(SHELL),/bin/sh)
COL_RED=\033[1;31m
COL_GREEN=\033[1;32m
COL_RESET=\033[m
endif
#################### Targets ###############################
all: build
build: clean_version compile print_version size
compile: clean_version $(PROG).hex $(PROG).bin $(PROG).dfu
clean_version:
ifeq ($(SHELL),/bin/sh)
@echo " CLEAN_VERSION"
@rm -f version.c
endif
print_version: compile
ifeq ($(SHELL),/bin/sh)
@./scripts/print_revision.sh
endif
ifeq ($(CLOAD), 1)
@echo "CrazyLoader build!"
endif
size: compile
@$(SIZE) -B $(PROG).elf
#Radio bootloader
cload:
ifeq ($(CLOAD), 1)
$(CLOAD_SCRIPT) flash cflie.bin stm32-fw
else
@echo "Only cload build can be bootloaded. Launch build and cload with CLOAD=1"
endif
#Flash the stm.
flash:
$(OPENOCD) -d2 -f $(OPENOCD_INTERFACE) -f $(OPENOCD_TARGET) -c init -c targets -c "reset halt" \
-c "flash write_image erase cflie.elf" -c "verify_image cflie.elf" -c "reset run" -c shutdown
flash_dfu:
$(DFU_UTIL) -a 0 -D cflie.dfu
#STM utility targets
halt:
$(OPENOCD) -d0 -f $(OPENOCD_INTERFACE) -f $(OPENOCD_TARGET) -c init -c targets -c "halt" -c shutdown
reset:
$(OPENOCD) -d0 -f $(OPENOCD_INTERFACE) -f $(OPENOCD_TARGET) -c init -c targets -c "reset" -c shutdown
openocd:
$(OPENOCD) -d2 -f $(OPENOCD_INTERFACE) -f $(OPENOCD_TARGET) -c init -c targets
#Print preprocessor #defines
prep:
@$(CC) -dD
include scripts/targets.mk
#include dependencies
-include $(DEPS)
#Crazyflie 2.0 Firmware
This project contains the source code for the Crazyflie 2.0 firmware. More information can be found on the
[Bitcraze wiki](http://wiki.bitcraze.se/projects:crazyflie2:index)
####Folder description
```
./ | Root, contains the Makefile
+ init | Contains the main.c
+ config | Configuration files
+ drivers | Hardware driver layer
| + src | Drivers source code
| + interface | Drivers header files. Interface to the HAL layer
+ hal | Hardware abstaction layer
| + src | HAL source code
| + interface | HAL header files. Interface with the other parts of the program
+ modules | Firmware operating code and headers
| + src | Firmware tasks source code and main.c
| + interface | Operating headers. Configure the firmware environement
+ utils | Utils code. Implement utility block like the console.
| + src | Utils source code
| + interface | Utils header files. Interface with the other parts of the program
+ platform | Platform specific files. Not really used yet
+ scripts | Misc. scripts for LD, OpenOCD, make, version control, ...
| | *** The two following folders contains the unmodified files ***
+ lib | Libraries
| + FreeRTOS | Source FreeRTOS folder. Cleaned up from the useless files
| + STM32... | Library folders of the ST STM32 peripheral libs
| + CMSIS | Core abstraction layer
```
####Make targets
```
all : Shortcut for build
compile : Compile cflie.hex. WARNING: Do NOT update version.c
build : Update version.c and compile cflie.elf/hex
clean_o : Clean only the Objects files, keep the executables (ie .elf, .hex)
clean : Clean every compiled files
mrproper : Clean every compiled files and the classical editors backup files
cload : If the crazyflie-clients-python is placed on the same directory level and the Crazyradio/Crazyradio PA
is inserted it will try to flash the firmware using the wireless bootloader.
flash : Flash cflie.elf using OpenOCD
halt : Halt the target using OpenOCD
reset : Reset the target using OpenOCD
openocd : Launch OpenOCD
```
/*
FreeRTOS V6.0.0 - Copyright (C) 2009 Real Time Engineers Ltd.
***************************************************************************
* *
* If you are: *
* *
* + New to FreeRTOS, *
* + Wanting to learn FreeRTOS or multitasking in general quickly *
* + Looking for basic training, *
* + Wanting to improve your FreeRTOS skills and productivity *
* *
* then take a look at the FreeRTOS eBook *
* *
* "Using the FreeRTOS Real Time Kernel - a Practical Guide" *
* http://www.FreeRTOS.org/Documentation *
* *
* A pdf reference manual is also available. Both are usually delivered *
* to your inbox within 20 minutes to two hours when purchased between 8am *
* and 8pm GMT (although please allow up to 24 hours in case of *
* exceptional circumstances). Thank you for your support! *
* *
***************************************************************************
This file is part of the FreeRTOS distribution.
FreeRTOS is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License (version 2) as published by the
Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
***NOTE*** The exception to the GPL is included to allow you to distribute
a combined work that includes FreeRTOS without being obliged to provide the
source code for proprietary components outside of the FreeRTOS kernel.
FreeRTOS 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 and the FreeRTOS license exception along with FreeRTOS; if not it
can be viewed here: http://www.freertos.org/a00114.html and also obtained
by writing to Richard Barry, contact details for whom are available on the
FreeRTOS WEB site.
1 tab == 4 spaces!
http://www.FreeRTOS.org - Documentation, latest information, license and
contact details.
http://www.SafeRTOS.com - A version that is certified for use in safety
critical systems.
http://www.OpenRTOS.com - Commercial support, development, porting,
licensing and training services.
*/
#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H
#include "cfassert.h"
/*-----------------------------------------------------------
* Application specific definitions.
*
* These definitions should be adjusted for your particular hardware and
* application requirements.
*
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
*
* See http://www.freertos.org/a00110.html.
*----------------------------------------------------------*/
#define configUSE_PREEMPTION 1
#define configUSE_IDLE_HOOK 1
#define configUSE_TICK_HOOK 0
#define configCPU_CLOCK_HZ ( ( unsigned long ) 168000000 )
#define configTICK_RATE_HZ ( ( portTickType ) 1000 )
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 100 )
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 20000 ) )
#define configMAX_TASK_NAME_LEN ( 10 )
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 0
#define configUSE_CO_ROUTINES 0
#define configCHECK_FOR_STACK_OVERFLOW 1
#define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY 1
#define configTIMER_QUEUE_LENGTH 20
#define configUSE_MALLOC_FAILED_HOOK 1
#define configTIMER_TASK_STACK_DEPTH configMINIMAL_STACK_SIZE
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 )
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */
#define INCLUDE_vTaskPrioritySet 0
#define INCLUDE_uxTaskPriorityGet 0
#define INCLUDE_vTaskDelete 0
#define INCLUDE_vTaskCleanUpResources 0
#define INCLUDE_vTaskSuspend 0
#define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1
#define INCLUDE_uxTaskGetStackHighWaterMark 1
#define configUSE_MUTEXES 1
#define configKERNEL_INTERRUPT_PRIORITY 255
//#define configMAX_SYSCALL_INTERRUPT_PRIORITY 1
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 0x5F /* equivalent to 0x05, or priority 5. */
//Map the port handler to the crt0 interruptions handlers
#define xPortPendSVHandler PendSV_Handler
#define xPortSysTickHandler tickFreeRTOS
#define vPortSVCHandler SVC_Handler
//Milliseconds to OS Ticks
#define M2T(X) ((unsigned int)(X*(configTICK_RATE_HZ/1000.0)))
#define F2T(X) ((unsigned int)((configTICK_RATE_HZ/X)))
// DEBUG SECTION