From 211254ed6c5a945be18334aa540de55db885000c Mon Sep 17 00:00:00 2001 From: inmarket Date: Mon, 6 Oct 2014 17:05:16 +1000 Subject: [PATCH] Add support for FreeRTOS into make system --- .../Drivers => FreeRTOS}/bcm2835_intc.h | 0 .../main.c => FreeRTOS/freertos_main.c} | 34 ++---- .../Drivers => FreeRTOS}/gpio.c | 0 .../Drivers => FreeRTOS}/gpio.h | 0 .../Drivers => FreeRTOS}/interrupts.c | 0 .../Drivers => FreeRTOS}/interrupts.h | 0 .../Drivers => FreeRTOS}/mmio.h | 0 .../raspberrypi.ld | 0 .../{example-FreeRTOS => FreeRTOS}/startup.s | 4 +- .../Drivers => FreeRTOS}/uart.c | 0 .../Drivers => FreeRTOS}/uart.h | 0 .../RaspberryPi/example-FreeRTOS/Makefile | 110 ++++++++---------- tools/gmake_scripts/cpu_armv6.mk | 18 +++ tools/gmake_scripts/cpu_raspberrypi.mk | 18 +++ tools/gmake_scripts/os_freertos.mk | 36 ++++++ tools/gmake_scripts/readme.txt | 2 +- 16 files changed, 128 insertions(+), 94 deletions(-) rename boards/base/RaspberryPi/{example-FreeRTOS/Drivers => FreeRTOS}/bcm2835_intc.h (100%) rename boards/base/RaspberryPi/{example-FreeRTOS/main.c => FreeRTOS/freertos_main.c} (64%) rename boards/base/RaspberryPi/{example-FreeRTOS/Drivers => FreeRTOS}/gpio.c (100%) rename boards/base/RaspberryPi/{example-FreeRTOS/Drivers => FreeRTOS}/gpio.h (100%) rename boards/base/RaspberryPi/{example-FreeRTOS/Drivers => FreeRTOS}/interrupts.c (100%) rename boards/base/RaspberryPi/{example-FreeRTOS/Drivers => FreeRTOS}/interrupts.h (100%) rename boards/base/RaspberryPi/{example-FreeRTOS/Drivers => FreeRTOS}/mmio.h (100%) rename boards/base/RaspberryPi/{example-FreeRTOS => FreeRTOS}/raspberrypi.ld (100%) rename boards/base/RaspberryPi/{example-FreeRTOS => FreeRTOS}/startup.s (96%) rename boards/base/RaspberryPi/{example-FreeRTOS/Drivers => FreeRTOS}/uart.c (100%) rename boards/base/RaspberryPi/{example-FreeRTOS/Drivers => FreeRTOS}/uart.h (100%) create mode 100644 tools/gmake_scripts/cpu_armv6.mk create mode 100644 tools/gmake_scripts/cpu_raspberrypi.mk create mode 100644 tools/gmake_scripts/os_freertos.mk diff --git a/boards/base/RaspberryPi/example-FreeRTOS/Drivers/bcm2835_intc.h b/boards/base/RaspberryPi/FreeRTOS/bcm2835_intc.h similarity index 100% rename from boards/base/RaspberryPi/example-FreeRTOS/Drivers/bcm2835_intc.h rename to boards/base/RaspberryPi/FreeRTOS/bcm2835_intc.h diff --git a/boards/base/RaspberryPi/example-FreeRTOS/main.c b/boards/base/RaspberryPi/FreeRTOS/freertos_main.c similarity index 64% rename from boards/base/RaspberryPi/example-FreeRTOS/main.c rename to boards/base/RaspberryPi/FreeRTOS/freertos_main.c index 3a64a7bb..821a679b 100644 --- a/boards/base/RaspberryPi/example-FreeRTOS/main.c +++ b/boards/base/RaspberryPi/FreeRTOS/freertos_main.c @@ -3,43 +3,23 @@ #include "Drivers/interrupts.h" -#include "gfx.h" +extern int main(void); -static void displayTask(void *pvParameters) { - coord_t width, height; - // Get the screen size - width = gdispGetWidth(); - height = gdispGetHeight(); - - // Code Here - gdispDrawBox(10, 10, width/2, height/2, Yellow); - gdispFillArea(width/2, height/2, width/2-10, height/2-10, Blue); - gdispDrawLine(5, 30, width-50, height-40, Red); - - while(1) - { - vTaskDelay(1000); - } - - return; +static void mainTask(void *pvParameters) { + (void) pvParameters; + main(); } /** * This is the systems main entry, some call it a boot thread. - * - * -- Absolutely nothing wrong with this being called main(), just it doesn't have - * -- the same prototype as you'd see in a linux program. **/ -int main(void) { +int FreeRTOS_Main(void) { DisableInterrupts(); InitInterruptController(); - // Initialize and clear the display - gfxInit(); - - xTaskCreate(displayTask, - (portCHAR *)"Display Task", + xTaskCreate(mainTask, + (portCHAR *)"Main Task", 128, NULL, 0, diff --git a/boards/base/RaspberryPi/example-FreeRTOS/Drivers/gpio.c b/boards/base/RaspberryPi/FreeRTOS/gpio.c similarity index 100% rename from boards/base/RaspberryPi/example-FreeRTOS/Drivers/gpio.c rename to boards/base/RaspberryPi/FreeRTOS/gpio.c diff --git a/boards/base/RaspberryPi/example-FreeRTOS/Drivers/gpio.h b/boards/base/RaspberryPi/FreeRTOS/gpio.h similarity index 100% rename from boards/base/RaspberryPi/example-FreeRTOS/Drivers/gpio.h rename to boards/base/RaspberryPi/FreeRTOS/gpio.h diff --git a/boards/base/RaspberryPi/example-FreeRTOS/Drivers/interrupts.c b/boards/base/RaspberryPi/FreeRTOS/interrupts.c similarity index 100% rename from boards/base/RaspberryPi/example-FreeRTOS/Drivers/interrupts.c rename to boards/base/RaspberryPi/FreeRTOS/interrupts.c diff --git a/boards/base/RaspberryPi/example-FreeRTOS/Drivers/interrupts.h b/boards/base/RaspberryPi/FreeRTOS/interrupts.h similarity index 100% rename from boards/base/RaspberryPi/example-FreeRTOS/Drivers/interrupts.h rename to boards/base/RaspberryPi/FreeRTOS/interrupts.h diff --git a/boards/base/RaspberryPi/example-FreeRTOS/Drivers/mmio.h b/boards/base/RaspberryPi/FreeRTOS/mmio.h similarity index 100% rename from boards/base/RaspberryPi/example-FreeRTOS/Drivers/mmio.h rename to boards/base/RaspberryPi/FreeRTOS/mmio.h diff --git a/boards/base/RaspberryPi/example-FreeRTOS/raspberrypi.ld b/boards/base/RaspberryPi/FreeRTOS/raspberrypi.ld similarity index 100% rename from boards/base/RaspberryPi/example-FreeRTOS/raspberrypi.ld rename to boards/base/RaspberryPi/FreeRTOS/raspberrypi.ld diff --git a/boards/base/RaspberryPi/example-FreeRTOS/startup.s b/boards/base/RaspberryPi/FreeRTOS/startup.s similarity index 96% rename from boards/base/RaspberryPi/example-FreeRTOS/startup.s rename to boards/base/RaspberryPi/FreeRTOS/startup.s index 286f396c..d865439f 100644 --- a/boards/base/RaspberryPi/example-FreeRTOS/startup.s +++ b/boards/base/RaspberryPi/FreeRTOS/startup.s @@ -4,7 +4,7 @@ .extern vFreeRTOS_ISR .extern vPortYieldProcessor .extern DisableInterrupts -.extern main +.extern FreeRTOS_Main .section .init .globl _start ;; @@ -79,7 +79,7 @@ zero_loop: ;@ mov sp,#0x1000000 - b main ;@ We're ready?? Lets start main execution! + b FreeRTOS_Main ;@ We're ready?? Lets start main execution! .section .text undefined_instruction: diff --git a/boards/base/RaspberryPi/example-FreeRTOS/Drivers/uart.c b/boards/base/RaspberryPi/FreeRTOS/uart.c similarity index 100% rename from boards/base/RaspberryPi/example-FreeRTOS/Drivers/uart.c rename to boards/base/RaspberryPi/FreeRTOS/uart.c diff --git a/boards/base/RaspberryPi/example-FreeRTOS/Drivers/uart.h b/boards/base/RaspberryPi/FreeRTOS/uart.h similarity index 100% rename from boards/base/RaspberryPi/example-FreeRTOS/Drivers/uart.h rename to boards/base/RaspberryPi/FreeRTOS/uart.h diff --git a/boards/base/RaspberryPi/example-FreeRTOS/Makefile b/boards/base/RaspberryPi/example-FreeRTOS/Makefile index c1751204..a8d64ad0 100644 --- a/boards/base/RaspberryPi/example-FreeRTOS/Makefile +++ b/boards/base/RaspberryPi/example-FreeRTOS/Makefile @@ -1,73 +1,55 @@ -# build environment -PREFIX ?= /your compiler path/gcc-arm-none-eabi-4_8-2014q1 -ARCH ?= $(PREFIX)/bin/arm-none-eabi +# Possible Targets: all clean Debug cleanDebug Release cleanRelease -CC = ${ARCH}-gcc -CPP = ${ARCH}-g++ -AS = ${ARCH}-as -LD = ${ARCH}-ld -AR = ${ARCH}-ar -OBJCOPY = ${ARCH}-objcopy +############################################################################################## +# Settings +# -PLATFORM = raspi -LINKER_SCRIPT = raspberrypi.ld +# General settings + # See $(GFXLIB)/tools/gmake_scripts/readme.txt for the list of variables + OPT_OS = freertos + OPT_THUMB = yes + OPT_LINK_OPTIMIZE = yes + # For the raspberry pi we can either use the generic armv6 cpu or the highly optimized raspberrypi settings + OPT_CPU = raspberrypi -CFLAGS = -march=armv6z -g -Wall -Wextra -ASFLAGS = -g +# uGFX settings + # See $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk for the list of variables + GFXLIB = ../uGFX + GFXBOARD = RaspberryPi + GFXDEMO = modules/gdisp/basics -CFLAGS_FOR_TARGET = #-mcpu=arm1176jzf-s -ASFLAGS_FOR_TARGET = #-mcpu=arm1176jzf-s -LDFLAGS = #--error-unresolved-symbols +# FreeRTOS settings +ifeq ($(OPT_OS),freertos) + # See $(GFXLIB)/tools/gmake_scripts/os_freertos.mk for the list of variables + FREERTOS = ../FreeRTOS + FREERTOS_BOARD = RaspberryPi + FREERTOS_MODULES = $(GFXLIB)/boards/base/RaspberryPi/FreeRTOS + FREERTOS_LDSCRIPT = $(GFXLIB)/boards/base/RaspberryPi/FreeRTOS/raspberrypi.ld +endif -GFXLIB := ../uGFX -include $(GFXLIB)/gfx.mk -include $(GFXLIB)/drivers/gdisp/framebuffer/driver.mk +############################################################################################## +# Set these for your project +# -OSLIB := ../FreeRTOS -MODULES := $(OSLIB)/Source/portable/GCC/RaspberryPi -MODULES += $(OSLIB)/Source/portable/MemMang -MODULES += $(OSLIB)/Source -MODULES += Drivers - -SRC_DIR := $(MODULES) -INC_DIR := $(addsuffix /include,$(SRC_DIR)) -BUILD_DIR := $(addsuffix /build,$(SRC_DIR)) - -INCLUDEDIRS := $(OSLIB)/Source/portable/GCC/RaspberryPi -INCLUDEDIRS += $(OSLIB)/Source/include -INCLUDEDIRS += Drivers -INCLUDEDIRS += $(GFXINC) - -INCLUDES := $(addprefix -I,$(INCLUDEDIRS)) - -ASRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.s)) -AOBJ := $(ASRC:.s=.o) -CSRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c)) -CSRC += $(GFXSRC) -COBJ := $(CSRC:.c=.o) - -vpath %.c $(SRC_DIR) -vpath %.cpp $(SRC_DIR) -vpath %.s $(SRC_DIR) - -%.o: %.c - $(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) $(CFLAGS) -c -o $*.o $< - -%.o: %.s - $(AS) $(ASFLAGS_FOR_TARGET) $(INCLUDES) $(ASFLAGS) -o $*.o $< - -OBJ = $(AOBJ) $(COBJ) - -bin/kernel.img: bin/kernel.elf - ${OBJCOPY} -O binary $< $@ - -bin/kernel.elf: LDFLAGS += -L "$(PREFIX)/lib/gcc/arm-none-eabi/4.8.3" -lgcc -bin/kernel.elf: LDFLAGS += -L "$(PREFIX)/arm-none-eabi/lib" -lc -bin/kernel.elf: $(OBJ) - ${LD} $(OBJ) -Map bin/kernel.map -o $@ -T $(LINKER_SCRIPT) ${LDFLAGS} - -clean: - rm -f bin/*.elf bin/*.img bin/*.map $(OBJ) +ARCH = arm-none-eabi- +SRCFLAGS = -ggdb -O0 +CFLAGS = +CXXFLAGS = -fno-rtti +ASFLAGS = +LDFLAGS = +SRC = +OBJS = +DEFS = +LIBS = +INCPATH = +LIBPATH = +############################################################################################## +# These should be at the end +# +include $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk +include $(GFXLIB)/tools/gmake_scripts/os_$(OPT_OS).mk +include $(GFXLIB)/tools/gmake_scripts/compiler_gcc.mk +# *** EOF *** diff --git a/tools/gmake_scripts/cpu_armv6.mk b/tools/gmake_scripts/cpu_armv6.mk new file mode 100644 index 00000000..0fa5867e --- /dev/null +++ b/tools/gmake_scripts/cpu_armv6.mk @@ -0,0 +1,18 @@ +# +# This file is subject to the terms of the GFX License. If a copy of +# the license was not distributed with this file, you can obtain one at: +# +# http://ugfx.org/license.html +# + +# +# See readme.txt for the make API +# + +# Requirements: +# +# NONE +# + +SRCFLAGS += -march=armv6 -mfpu=vfp -mfloat-abi=hard +LDFLAGS += -march=armv6 -mfpu=vfp -mfloat-abi=hard diff --git a/tools/gmake_scripts/cpu_raspberrypi.mk b/tools/gmake_scripts/cpu_raspberrypi.mk new file mode 100644 index 00000000..b31c35e9 --- /dev/null +++ b/tools/gmake_scripts/cpu_raspberrypi.mk @@ -0,0 +1,18 @@ +# +# This file is subject to the terms of the GFX License. If a copy of +# the license was not distributed with this file, you can obtain one at: +# +# http://ugfx.org/license.html +# + +# +# See readme.txt for the make API +# + +# Requirements: +# +# NONE +# + +SRCFLAGS += -march=armv6zk -mcpu=arm1176jzf-s -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard +LDFLAGS += -march=armv6zk -mcpu=arm1176jzf-s -mtune=arm1176jzf-s -mfpu=vfp -mfloat-abi=hard diff --git a/tools/gmake_scripts/os_freertos.mk b/tools/gmake_scripts/os_freertos.mk new file mode 100644 index 00000000..5cbd5be0 --- /dev/null +++ b/tools/gmake_scripts/os_freertos.mk @@ -0,0 +1,36 @@ +# +# This file is subject to the terms of the GFX License. If a copy of +# the license was not distributed with this file, you can obtain one at: +# +# http://ugfx.org/license.html +# + +# See readme.txt for the make API + +# Requirements: +# +# FREERTOS: The location of the FreeRTOS code eg FREERTOS=../FreeRTOS +# FREERTOS_BOARD The board name eg FREERTOS_BOARD=RaspberryPi +# + +# Optional: +# +# FREERTOS_MODULES A list of directories containing FreeRTOS source (eg drivers, startup etc) - default is "" +# FREERTOS_LDSCRIPT The loader script - default is "" +# + +PATHLIST += FREERTOS + +FREERTOS_MODULES += $(FREERTOS)/Source/portable/GCC/$(FREERTOS_BOARD) +FREERTOS_MODULES += $(FREERTOS)/Source/portable/MemMang +FREERTOS_MODULES += $(FREERTOS)/Source + +INCPATH += $(FREERTOS)/Source/portable/GCC/$(FREERTOS_BOARD) \ + $(FREERTOS)/Source/include + +SRC += $(foreach sdir,$(FREERTOS_MODULES),$(wildcard $(sdir)/*.s)) +SRC += $(foreach sdir,$(FREERTOS_MODULES),$(wildcard $(sdir)/*.c)) + +ifeq ($(LDSCRIPT),) + LDSCRIPT= $(FREERTOS_LDSCRIPT) +endif diff --git a/tools/gmake_scripts/readme.txt b/tools/gmake_scripts/readme.txt index eec7dd95..67206ed9 100644 --- a/tools/gmake_scripts/readme.txt +++ b/tools/gmake_scripts/readme.txt @@ -16,7 +16,7 @@ OPT_COPY_EXE=no|yes - Copy the final program to the local project directory - OPT_NONSTANDARD_FLAGS=no - Turn off adding the standard compiler language flags - default no OPT_LINK_OPTIMIZE=no - Remove unused code/data during link - default no OPT_OS=win32|win32.chibios|linux|osx|chibios|freertos|ecos|raw32|rawrtos - Mandatory: The operating system -OPT_CPU=x86|x64|stm32m4|at91sam7 - Add some cpu dependant flags +OPT_CPU=x86|x64|stm32m4|at91sam7|armv6|raspberrypi - Add some cpu dependant flags BUILDDIR - Build Directory - default is ".build" or "bin/Debug" or "bin/Release" depending on the target PROJECT - Project Name - default is the name of the project directory