Using ChibiOS/RT

From uGFX Wiki
Revision as of 17:56, 8 December 2015 by Tectu (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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