Difference between revisions of "Using ChibiOS/RT"
From uGFX Wiki
(→Example) |
(→Example) |
||
Line 10: | Line 10: | ||
== Example == | == Example == | ||
The following Makefile is just an example showing how an existing Makefile has to be modified following the steps above. Please DO NOT copy the entire Makfile. The relevant parts have been highlighted. | The following Makefile is just an example showing how an existing Makefile has to be modified following the steps above. Please DO NOT copy the entire Makfile. The relevant parts have been highlighted. | ||
− | <syntaxhighlight lang=make line start="1" highlight=" | + | <syntaxhighlight lang=make line start="1" highlight="72,78,79,80,98,131"> |
############################################################################## | ############################################################################## | ||
# Build global options | # Build global options | ||
# NOTE: Can be overridden externally. | # NOTE: Can be overridden externally. | ||
# | # | ||
+ | |||
# Compiler options here. | # Compiler options here. | ||
ifeq ($(USE_OPT),) | ifeq ($(USE_OPT),) | ||
− | USE_OPT = - | + | USE_OPT = -O0 -ggdb -fomit-frame-pointer -falign-functions=16 |
endif | endif | ||
+ | |||
# C specific options here (added to USE_OPT). | # C specific options here (added to USE_OPT). | ||
ifeq ($(USE_COPT),) | ifeq ($(USE_COPT),) | ||
USE_COPT = | USE_COPT = | ||
endif | endif | ||
+ | |||
# C++ specific options here (added to USE_OPT). | # C++ specific options here (added to USE_OPT). | ||
ifeq ($(USE_CPPOPT),) | ifeq ($(USE_CPPOPT),) | ||
USE_CPPOPT = -fno-rtti | USE_CPPOPT = -fno-rtti | ||
endif | endif | ||
+ | |||
# Enable this if you want the linker to remove unused code and data | # Enable this if you want the linker to remove unused code and data | ||
ifeq ($(USE_LINK_GC),) | ifeq ($(USE_LINK_GC),) | ||
USE_LINK_GC = yes | USE_LINK_GC = yes | ||
endif | endif | ||
+ | |||
+ | # Linker extra options here. | ||
+ | ifeq ($(USE_LDOPT),) | ||
+ | USE_LDOPT = | ||
+ | endif | ||
+ | |||
+ | # Enable this if you want link time optimizations (LTO) | ||
+ | ifeq ($(USE_LTO),) | ||
+ | USE_LTO = no | ||
+ | endif | ||
+ | |||
# If enabled, this option allows to compile the application in THUMB mode. | # If enabled, this option allows to compile the application in THUMB mode. | ||
ifeq ($(USE_THUMB),) | ifeq ($(USE_THUMB),) | ||
USE_THUMB = yes | USE_THUMB = yes | ||
endif | endif | ||
+ | |||
# Enable this if you want to see the full log while compiling. | # Enable this if you want to see the full log while compiling. | ||
ifeq ($(USE_VERBOSE_COMPILE),) | ifeq ($(USE_VERBOSE_COMPILE),) | ||
USE_VERBOSE_COMPILE = no | USE_VERBOSE_COMPILE = no | ||
endif | endif | ||
+ | |||
# | # | ||
# Build global options | # Build global options | ||
############################################################################## | ############################################################################## | ||
+ | |||
############################################################################## | ############################################################################## | ||
# Architecture or project specific options | # Architecture or project specific options | ||
# | # | ||
− | # Enables the use of FPU on Cortex-M4 | + | |
− | + | # Enables the use of FPU on Cortex-M4 (no, softfp, hard). | |
ifeq ($(USE_FPU),) | ifeq ($(USE_FPU),) | ||
− | USE_FPU | + | USE_FPU = no |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
endif | endif | ||
+ | |||
# | # | ||
# Architecture or project specific options | # Architecture or project specific options | ||
############################################################################## | ############################################################################## | ||
+ | |||
############################################################################## | ############################################################################## | ||
# Project, sources and paths | # Project, sources and paths | ||
# | # | ||
+ | |||
# Define project name here | # Define project name here | ||
− | PROJECT = | + | PROJECT = ugfx |
+ | |||
# Imported source files and paths | # Imported source files and paths | ||
− | CHIBIOS = /path/to/your/chibios | + | CHIBIOS = /path/to/your/chibios |
GFXLIB = /path/to/your/ugfx | GFXLIB = /path/to/your/ugfx | ||
include $(CHIBIOS)/os/hal/platforms/STM32F4xx/platform.mk | include $(CHIBIOS)/os/hal/platforms/STM32F4xx/platform.mk | ||
Line 69: | Line 87: | ||
include $(CHIBIOS)/os/ports/GCC/ARMCMx/STM32F4xx/port.mk | include $(CHIBIOS)/os/ports/GCC/ARMCMx/STM32F4xx/port.mk | ||
include $(CHIBIOS)/os/kernel/kernel.mk | include $(CHIBIOS)/os/kernel/kernel.mk | ||
+ | include $(CHIBIOS)/test/test.mk | ||
include $(GFXLIB)/gfx.mk | include $(GFXLIB)/gfx.mk | ||
− | include $(GFXLIB)/boards/base/ | + | include $(GFXLIB)/boards/base/Embest-STM32-DMSTF4BB/board.mk # board |
+ | include $(GFXLIB)/drivers/gaudio/vs1053/driver.mk # additional driver | ||
+ | |||
# Define linker script file here | # Define linker script file here | ||
LDSCRIPT= $(PORTLD)/STM32F407xG.ld | LDSCRIPT= $(PORTLD)/STM32F407xG.ld | ||
#LDSCRIPT= $(PORTLD)/STM32F407xG_CCM.ld | #LDSCRIPT= $(PORTLD)/STM32F407xG_CCM.ld | ||
+ | |||
# C sources that can be compiled in ARM or THUMB mode depending on the global | # C sources that can be compiled in ARM or THUMB mode depending on the global | ||
# setting. | # setting. | ||
− | CSRC = $(PORTSRC) \ | + | CSRC = $(PORTSRC) \ |
− | + | $(KERNSRC) \ | |
− | + | $(TESTSRC) \ | |
− | + | $(HALSRC) \ | |
− | + | $(PLATFORMSRC) \ | |
− | + | $(BOARDSRC) \ | |
− | + | $(CHIBIOS)/os/various/evtimer.c \ | |
− | + | $(CHIBIOS)/os/various/chprintf.c \ | |
− | + | $(CHIBIOS)/os/various/shell.c \ | |
− | + | $(CHIBIOS)/os/various/syscalls.c \ | |
+ | $(GFXSRC) \ | ||
+ | main.c | ||
+ | |||
# C++ sources that can be compiled in ARM or THUMB mode depending on the global | # C++ sources that can be compiled in ARM or THUMB mode depending on the global | ||
# setting. | # setting. | ||
CPPSRC = | CPPSRC = | ||
+ | |||
# C sources to be compiled in ARM mode regardless of the global setting. | # C sources to be compiled in ARM mode regardless of the global setting. | ||
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler | # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler | ||
# option that results in lower performance and larger code size. | # option that results in lower performance and larger code size. | ||
ACSRC = | ACSRC = | ||
+ | |||
# C++ sources to be compiled in ARM mode regardless of the global setting. | # C++ sources to be compiled in ARM mode regardless of the global setting. | ||
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler | # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler | ||
# option that results in lower performance and larger code size. | # option that results in lower performance and larger code size. | ||
ACPPSRC = | ACPPSRC = | ||
+ | |||
# C sources to be compiled in THUMB mode regardless of the global setting. | # C sources to be compiled in THUMB mode regardless of the global setting. | ||
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler | # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler | ||
# option that results in lower performance and larger code size. | # option that results in lower performance and larger code size. | ||
TCSRC = | TCSRC = | ||
+ | |||
# C sources to be compiled in THUMB mode regardless of the global setting. | # C sources to be compiled in THUMB mode regardless of the global setting. | ||
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler | # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler | ||
# option that results in lower performance and larger code size. | # option that results in lower performance and larger code size. | ||
TCPPSRC = | TCPPSRC = | ||
+ | |||
# List ASM source files here | # List ASM source files here | ||
ASMSRC = $(PORTASM) | ASMSRC = $(PORTASM) | ||
− | INCDIR = $(PORTINC) | + | |
− | + | INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \ | |
− | + | $(HALINC) $(PLATFORMINC) $(BOARDINC) \ | |
− | $(HALINC) | + | $(CHIBIOS)/os/various |
− | + | $(GFXINC) \ | |
− | + | include | |
− | + | ||
− | $(CHIBIOS)/os/various | + | |
− | $( | + | |
− | + | ||
# | # | ||
# Project, sources and paths | # Project, sources and paths | ||
############################################################################## | ############################################################################## | ||
+ | |||
############################################################################## | ############################################################################## | ||
# Compiler settings | # Compiler settings | ||
# | # | ||
+ | |||
MCU = cortex-m4 | MCU = cortex-m4 | ||
+ | |||
#TRGT = arm-elf- | #TRGT = arm-elf- | ||
TRGT = arm-none-eabi- | TRGT = arm-none-eabi- | ||
Line 136: | Line 166: | ||
AS = $(TRGT)gcc -x assembler-with-cpp | AS = $(TRGT)gcc -x assembler-with-cpp | ||
OD = $(TRGT)objdump | OD = $(TRGT)objdump | ||
+ | SZ = $(TRGT)size | ||
HEX = $(CP) -O ihex | HEX = $(CP) -O ihex | ||
BIN = $(CP) -O binary | BIN = $(CP) -O binary | ||
+ | |||
# ARM-specific options here | # ARM-specific options here | ||
AOPT = | AOPT = | ||
+ | |||
# THUMB-specific options here | # THUMB-specific options here | ||
TOPT = -mthumb -DTHUMB | TOPT = -mthumb -DTHUMB | ||
+ | |||
# Define C warning options here | # Define C warning options here | ||
CWARN = -Wall -Wextra -Wstrict-prototypes | CWARN = -Wall -Wextra -Wstrict-prototypes | ||
+ | |||
# Define C++ warning options here | # Define C++ warning options here | ||
CPPWARN = -Wall -Wextra | CPPWARN = -Wall -Wextra | ||
+ | |||
# | # | ||
# Compiler settings | # Compiler settings | ||
############################################################################## | ############################################################################## | ||
+ | |||
############################################################################## | ############################################################################## | ||
# Start of default section | # Start of default section | ||
# | # | ||
+ | |||
# List all default C defines here, like -D_DEBUG=1 | # List all default C defines here, like -D_DEBUG=1 | ||
DDEFS = | DDEFS = | ||
+ | |||
# List all default ASM defines here, like -D_DEBUG=1 | # List all default ASM defines here, like -D_DEBUG=1 | ||
DADEFS = | DADEFS = | ||
+ | |||
# List all default directories to look for include files here | # List all default directories to look for include files here | ||
DINCDIR = | DINCDIR = | ||
+ | |||
# List the default directory to look for the libraries here | # List the default directory to look for the libraries here | ||
DLIBDIR = | DLIBDIR = | ||
+ | |||
# List all default libraries here | # List all default libraries here | ||
DLIBS = | DLIBS = | ||
+ | |||
# | # | ||
# End of default section | # End of default section | ||
############################################################################## | ############################################################################## | ||
+ | |||
############################################################################## | ############################################################################## | ||
# Start of user section | # Start of user section | ||
# | # | ||
+ | |||
# List all user C define here, like -D_DEBUG=1 | # List all user C define here, like -D_DEBUG=1 | ||
UDEFS = | UDEFS = | ||
+ | |||
# Define ASM defines here | # Define ASM defines here | ||
UADEFS = | UADEFS = | ||
+ | |||
# List all user directories here | # List all user directories here | ||
UINCDIR = | UINCDIR = | ||
+ | |||
# List the user directory to look for the libraries here | # List the user directory to look for the libraries here | ||
ULIBDIR = | ULIBDIR = | ||
+ | |||
# List all user libraries here | # List all user libraries here | ||
− | ULIBS = | + | ULIBS = |
+ | |||
# | # | ||
# End of user defines | # End of user defines | ||
############################################################################## | ############################################################################## | ||
− | + | ||
− | + | RULESPATH = $(CHIBIOS)/os/ports/GCC/ARMCMx | |
− | + | include $(RULESPATH)/rules.mk | |
− | + | </syntaxhighlight> | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | include $( | + |
Revision as of 15:27, 1 July 2014
It is fairly easy to include µGFX into your ChibiOS/RT project as ChibiOS/RT uses Makefiles internally as well. The ChibiOS/RT Makefile has to be modified as the following:
- Include the µGFX top-level Makefile
- Include the driver or board Makefiles that match your hardware
- Add GFXSRC to the CSRC variable
- Add GFXINC to the INCDIR' variable
Example
The following Makefile is just an example showing how an existing Makefile has to be modified following the steps above. Please DO NOT copy the entire Makfile. The relevant parts have been highlighted.
##############################################################################
# Build global options
# NOTE: Can be overridden externally.
#
# Compiler options here.
ifeq ($(USE_OPT),)
USE_OPT = -O0 -ggdb -fomit-frame-pointer -falign-functions=16
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
# Linker extra options here.
ifeq ($(USE_LDOPT),)
USE_LDOPT =
endif
# Enable this if you want link time optimizations (LTO)
ifeq ($(USE_LTO),)
USE_LTO = no
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),)
USE_VERBOSE_COMPILE = no
endif
#
# Build global options
##############################################################################
##############################################################################
# Architecture or project specific options
#
# Enables the use of FPU on Cortex-M4 (no, softfp, hard).
ifeq ($(USE_FPU),)
USE_FPU = no
endif
#
# Architecture or project specific options
##############################################################################
##############################################################################
# Project, sources and paths
#
# Define project name here
PROJECT = ugfx
# Imported source files and paths
CHIBIOS = /path/to/your/chibios
GFXLIB = /path/to/your/ugfx
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/kernel/kernel.mk
include $(CHIBIOS)/test/test.mk
include $(GFXLIB)/gfx.mk
include $(GFXLIB)/boards/base/Embest-STM32-DMSTF4BB/board.mk # board
include $(GFXLIB)/drivers/gaudio/vs1053/driver.mk # additional driver
# Define linker script file here
LDSCRIPT= $(PORTLD)/STM32F407xG.ld
#LDSCRIPT= $(PORTLD)/STM32F407xG_CCM.ld
# C sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
CSRC = $(PORTSRC) \
$(KERNSRC) \
$(TESTSRC) \
$(HALSRC) \
$(PLATFORMSRC) \
$(BOARDSRC) \
$(CHIBIOS)/os/various/evtimer.c \
$(CHIBIOS)/os/various/chprintf.c \
$(CHIBIOS)/os/various/shell.c \
$(CHIBIOS)/os/various/syscalls.c \
$(GFXSRC) \
main.c
# 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
$(GFXINC) \
include
#
# 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
SZ = $(TRGT)size
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 =
# 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 =
# List all default libraries here
DLIBS =
#
# End of default section
##############################################################################
##############################################################################
# Start of user section
#
# List all user C define here, like -D_DEBUG=1
UDEFS =
# Define ASM defines here
UADEFS =
# List all user directories here
UINCDIR =
# List the user directory to look for the libraries here
ULIBDIR =
# List all user libraries here
ULIBS =
#
# End of user defines
##############################################################################
RULESPATH = $(CHIBIOS)/os/ports/GCC/ARMCMx
include $(RULESPATH)/rules.mk