Difference between revisions of "Using ChibiOS/RT"

From uGFX Wiki
Jump to: navigation, search
(Created page with "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:...")
 
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
''If you're using the ChibiStudio IDE, please follow this guide: [[Using ChibiStudio]].''
 +
 
It is fairly easy to include µGFX into your ChibiOS/RT project as ChibiOS/RT uses Makefiles internally as well.
 
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:
 
The ChibiOS/RT Makefile has to be modified as the following:
 
 
# Include the µGFX top-level Makefile
 
# Include the µGFX top-level Makefile
 
# Include the driver or board Makefiles that match your hardware
 
# Include the driver or board Makefiles that match your hardware
 
# Add '''GFXSRC''' to the '''CSRC''' variable
 
# Add '''GFXSRC''' to the '''CSRC''' variable
# Add '''GFXINC''' to the '''INCDIR'''' variable
+
# Add '''GFXINC''' to the '''INCDIR''' variable
 
+
  
 
== 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 highlight="53,58">
+
<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 = -O3 -ggdb -fomit-frame-pointer -falign-functions=16
+
   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.
+
 
# Enable this if you really want to use the STM FWLib.
+
# Enables the use of FPU on Cortex-M4 (no, softfp, hard).
 
ifeq ($(USE_FPU),)
 
ifeq ($(USE_FPU),)
   USE_FPU = yes
+
   USE_FPU = no
endif
+
# Enable this if you really want to use the STM FWLib.
+
ifeq ($(USE_FWLIB),)
+
  USE_FWLIB = 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 = ch
+
PROJECT = ugfx
 +
 
 
# Imported source files and paths
 
# Imported source files and paths
CHIBIOS = /path/to/your/chibios-rt
+
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/Olimex-STM32-LCD/board.mk # your board
+
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) \
+
      $(KERNSRC) \
      $(TESTSRC) \
+
      $(TESTSRC) \
      $(HALSRC) \
+
      $(HALSRC) \
      $(PLATFORMSRC) \
+
      $(PLATFORMSRC) \
      $(BOARDSRC) \
+
      $(BOARDSRC) \
$(GFXSRC) \
+
      $(CHIBIOS)/os/various/evtimer.c \
      $(CHIBIOS)/os/various/devices_lib/accel/lis302dl.c \
+
      $(CHIBIOS)/os/various/chprintf.c \
      $(CHIBIOS)/os/various/chprintf.c \
+
      $(CHIBIOS)/os/various/shell.c \
src/usb_shell.c \
+
      $(CHIBIOS)/os/various/syscalls.c \
      main.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) \
+
 
$(KERNINC) \
+
INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \
$(TESTINC) \
+
         $(HALINC) $(PLATFORMINC) $(BOARDINC) \
         $(HALINC) \
+
$(PLATFORMINC) \
+
$(BOARDINC) \
+
$(GFXINC) \
+
        $(CHIBIOS)/os/various/devices_lib/accel \
+
 
         $(CHIBIOS)/os/various \
 
         $(CHIBIOS)/os/various \
include  
+
        $(GFXINC) \
 +
        include
 +
 
 
#
 
#
 
# 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 137: 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 = -lm
+
ULIBS =
 +
 
 
#
 
#
 
# End of user defines
 
# End of user defines
 
##############################################################################
 
##############################################################################
ifeq ($(USE_FPU),yes)
+
 
  USE_OPT += -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -fsingle-precision-constant
+
RULESPATH = $(CHIBIOS)/os/ports/GCC/ARMCMx
  DDEFS += -DCORTEX_USE_FPU=TRUE
+
include $(RULESPATH)/rules.mk
else
+
</syntaxhighlight>
  DDEFS += -DCORTEX_USE_FPU=FALSE
+
endif
+
ifeq ($(USE_FWLIB),yes)
+
  include $(CHIBIOS)/ext/stm32lib/stm32lib.mk
+
  CSRC += $(STM32SRC)
+
  INCDIR += $(STM32INC)
+
  USE_OPT += -DUSE_STDPERIPH_DRIVER
+
endif
+
include $(CHIBIOS)/os/ports/GCC/ARMCMx/rules.mk</syntaxhighlight>
+

Latest revision as of 17:56, 8 December 2015

If you're using the ChibiStudio IDE, please follow this guide: Using ChibiStudio.

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:

  1. Include the µGFX top-level Makefile
  2. Include the driver or board Makefiles that match your hardware
  3. Add GFXSRC to the CSRC variable
  4. 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.

  1. ##############################################################################
  2. # Build global options
  3. # NOTE: Can be overridden externally.
  4. #
  5.  
  6. # Compiler options here.
  7. ifeq ($(USE_OPT),)
  8.   USE_OPT = -O0 -ggdb -fomit-frame-pointer -falign-functions=16
  9. endif
  10.  
  11. # C specific options here (added to USE_OPT).
  12. ifeq ($(USE_COPT),)
  13.   USE_COPT = 
  14. endif
  15.  
  16. # C++ specific options here (added to USE_OPT).
  17. ifeq ($(USE_CPPOPT),)
  18.   USE_CPPOPT = -fno-rtti
  19. endif
  20.  
  21. # Enable this if you want the linker to remove unused code and data
  22. ifeq ($(USE_LINK_GC),)
  23.   USE_LINK_GC = yes
  24. endif
  25.  
  26. # Linker extra options here.
  27. ifeq ($(USE_LDOPT),)
  28.   USE_LDOPT = 
  29. endif
  30.  
  31. # Enable this if you want link time optimizations (LTO)
  32. ifeq ($(USE_LTO),)
  33.   USE_LTO = no
  34. endif
  35.  
  36. # If enabled, this option allows to compile the application in THUMB mode.
  37. ifeq ($(USE_THUMB),)
  38.   USE_THUMB = yes
  39. endif
  40.  
  41. # Enable this if you want to see the full log while compiling.
  42. ifeq ($(USE_VERBOSE_COMPILE),)
  43.   USE_VERBOSE_COMPILE = no
  44. endif
  45.  
  46. #
  47. # Build global options
  48. ##############################################################################
  49.  
  50. ##############################################################################
  51. # Architecture or project specific options
  52. #
  53.  
  54. # Enables the use of FPU on Cortex-M4 (no, softfp, hard).
  55. ifeq ($(USE_FPU),)
  56.   USE_FPU = no
  57. endif
  58.  
  59. #
  60. # Architecture or project specific options
  61. ##############################################################################
  62.  
  63. ##############################################################################
  64. # Project, sources and paths
  65. #
  66.  
  67. # Define project name here
  68. PROJECT = ugfx
  69.  
  70. # Imported source files and paths
  71. CHIBIOS = /path/to/your/chibios
  72. GFXLIB = /path/to/your/ugfx
  73. include $(CHIBIOS)/os/hal/platforms/STM32F4xx/platform.mk
  74. include $(CHIBIOS)/os/hal/hal.mk
  75. include $(CHIBIOS)/os/ports/GCC/ARMCMx/STM32F4xx/port.mk
  76. include $(CHIBIOS)/os/kernel/kernel.mk
  77. include $(CHIBIOS)/test/test.mk
  78. include $(GFXLIB)/gfx.mk
  79. include $(GFXLIB)/boards/base/Embest-STM32-DMSTF4BB/board.mk       # board
  80. include $(GFXLIB)/drivers/gaudio/vs1053/driver.mk                  # additional driver
  81.  
  82. # Define linker script file here
  83. LDSCRIPT= $(PORTLD)/STM32F407xG.ld
  84. #LDSCRIPT= $(PORTLD)/STM32F407xG_CCM.ld
  85.  
  86. # C sources that can be compiled in ARM or THUMB mode depending on the global
  87. # setting.
  88. CSRC = $(PORTSRC) \
  89.        $(KERNSRC) \
  90.        $(TESTSRC) \
  91.        $(HALSRC) \
  92.        $(PLATFORMSRC) \
  93.        $(BOARDSRC) \
  94.        $(CHIBIOS)/os/various/evtimer.c \
  95.        $(CHIBIOS)/os/various/chprintf.c \
  96.        $(CHIBIOS)/os/various/shell.c \
  97.        $(CHIBIOS)/os/various/syscalls.c \
  98.        $(GFXSRC) \
  99.        main.c
  100.  
  101. # C++ sources that can be compiled in ARM or THUMB mode depending on the global
  102. # setting.
  103. CPPSRC =
  104.  
  105. # C sources to be compiled in ARM mode regardless of the global setting.
  106. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
  107. #       option that results in lower performance and larger code size.
  108. ACSRC =
  109.  
  110. # C++ sources to be compiled in ARM mode regardless of the global setting.
  111. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
  112. #       option that results in lower performance and larger code size.
  113. ACPPSRC =
  114.  
  115. # C sources to be compiled in THUMB mode regardless of the global setting.
  116. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
  117. #       option that results in lower performance and larger code size.
  118. TCSRC =
  119.  
  120. # C sources to be compiled in THUMB mode regardless of the global setting.
  121. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
  122. #       option that results in lower performance and larger code size.
  123. TCPPSRC =
  124.  
  125. # List ASM source files here
  126. ASMSRC = $(PORTASM)
  127.  
  128. INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \
  129.          $(HALINC) $(PLATFORMINC) $(BOARDINC) \
  130.          $(CHIBIOS)/os/various \
  131.          $(GFXINC) \
  132.          include
  133.  
  134. #
  135. # Project, sources and paths
  136. ##############################################################################
  137.  
  138. ##############################################################################
  139. # Compiler settings
  140. #
  141.  
  142. MCU  = cortex-m4
  143.  
  144. #TRGT = arm-elf-
  145. TRGT = arm-none-eabi-
  146. CC   = $(TRGT)gcc
  147. CPPC = $(TRGT)g++
  148. # Enable loading with g++ only if you need C++ runtime support.
  149. # NOTE: You can use C++ even without C++ support if you are careful. C++
  150. #       runtime support makes code size explode.
  151. LD   = $(TRGT)gcc
  152. #LD   = $(TRGT)g++
  153. CP   = $(TRGT)objcopy
  154. AS   = $(TRGT)gcc -x assembler-with-cpp
  155. OD   = $(TRGT)objdump
  156. SZ   = $(TRGT)size
  157. HEX  = $(CP) -O ihex
  158. BIN  = $(CP) -O binary
  159.  
  160. # ARM-specific options here
  161. AOPT =
  162.  
  163. # THUMB-specific options here
  164. TOPT = -mthumb -DTHUMB
  165.  
  166. # Define C warning options here
  167. CWARN = -Wall -Wextra -Wstrict-prototypes
  168.  
  169. # Define C++ warning options here
  170. CPPWARN = -Wall -Wextra
  171.  
  172. #
  173. # Compiler settings
  174. ##############################################################################
  175.  
  176. ##############################################################################
  177. # Start of default section
  178. #
  179.  
  180. # List all default C defines here, like -D_DEBUG=1
  181. DDEFS =
  182.  
  183. # List all default ASM defines here, like -D_DEBUG=1
  184. DADEFS =
  185.  
  186. # List all default directories to look for include files here
  187. DINCDIR =
  188.  
  189. # List the default directory to look for the libraries here
  190. DLIBDIR =
  191.  
  192. # List all default libraries here
  193. DLIBS =
  194.  
  195. #
  196. # End of default section
  197. ##############################################################################
  198.  
  199. ##############################################################################
  200. # Start of user section
  201. #
  202.  
  203. # List all user C define here, like -D_DEBUG=1
  204. UDEFS =
  205.  
  206. # Define ASM defines here
  207. UADEFS =
  208.  
  209. # List all user directories here
  210. UINCDIR =
  211.  
  212. # List the user directory to look for the libraries here
  213. ULIBDIR =
  214.  
  215. # List all user libraries here
  216. ULIBS =
  217.  
  218. #
  219. # End of user defines
  220. ##############################################################################
  221.  
  222. RULESPATH = $(CHIBIOS)/os/ports/GCC/ARMCMx
  223. include $(RULESPATH)/rules.mk