Using ChibiOS/RT

From uGFX Wiki
Revision as of 14:55, 1 July 2014 by Tectu (Talk | contribs) (Example)

Jump to: navigation, search

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. # Compiler options here.
  6. ifeq ($(USE_OPT),)
  7.   USE_OPT = -O3 -ggdb -fomit-frame-pointer -falign-functions=16
  8. endif
  9. # C specific options here (added to USE_OPT).
  10. ifeq ($(USE_COPT),)
  11.   USE_COPT = 
  12. endif
  13. # C++ specific options here (added to USE_OPT).
  14. ifeq ($(USE_CPPOPT),)
  15.   USE_CPPOPT = -fno-rtti
  16. endif
  17. # Enable this if you want the linker to remove unused code and data
  18. ifeq ($(USE_LINK_GC),)
  19.   USE_LINK_GC = yes
  20. endif
  21. # If enabled, this option allows to compile the application in THUMB mode.
  22. ifeq ($(USE_THUMB),)
  23.   USE_THUMB = yes
  24. endif
  25. # Enable this if you want to see the full log while compiling.
  26. ifeq ($(USE_VERBOSE_COMPILE),)
  27.   USE_VERBOSE_COMPILE = no
  28. endif
  29. #
  30. # Build global options
  31. ##############################################################################
  32. ##############################################################################
  33. # Architecture or project specific options
  34. #
  35. # Enables the use of FPU on Cortex-M4.
  36. # Enable this if you really want to use the STM FWLib.
  37. ifeq ($(USE_FPU),)
  38.   USE_FPU = yes
  39. endif
  40. # Enable this if you really want to use the STM FWLib.
  41. ifeq ($(USE_FWLIB),)
  42.   USE_FWLIB = no
  43. endif
  44. #
  45. # Architecture or project specific options
  46. ##############################################################################
  47. ##############################################################################
  48. # Project, sources and paths
  49. #
  50. # Define project name here
  51. PROJECT = ch
  52. # Imported source files and paths
  53. CHIBIOS = /path/to/your/chibios-rt
  54. GFXLIB = /path/to/your/ugfx
  55. include $(CHIBIOS)/os/hal/platforms/STM32F4xx/platform.mk
  56. include $(CHIBIOS)/os/hal/hal.mk
  57. include $(CHIBIOS)/os/ports/GCC/ARMCMx/STM32F4xx/port.mk
  58. include $(CHIBIOS)/os/kernel/kernel.mk
  59. include $(GFXLIB)/gfx.mk
  60. include $(GFXLIB)/boards/base/Olimex-STM32-LCD/board.mk		# your board
  61. # Define linker script file here
  62. LDSCRIPT= $(PORTLD)/STM32F407xG.ld
  63. #LDSCRIPT= $(PORTLD)/STM32F407xG_CCM.ld
  64. # C sources that can be compiled in ARM or THUMB mode depending on the global
  65. # setting.
  66. CSRC =	$(PORTSRC) \
  67. 	$(KERNSRC) \
  68.        	$(TESTSRC) \
  69.        	$(HALSRC) \
  70.        	$(PLATFORMSRC) \
  71.        	$(BOARDSRC) \
  72. 	$(GFXSRC) \
  73.        	$(CHIBIOS)/os/various/devices_lib/accel/lis302dl.c \
  74.        	$(CHIBIOS)/os/various/chprintf.c \
  75.        	main.c
  76. # C++ sources that can be compiled in ARM or THUMB mode depending on the global
  77. # setting.
  78. CPPSRC =
  79. # C sources to be compiled in ARM mode regardless of the global setting.
  80. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
  81. #       option that results in lower performance and larger code size.
  82. ACSRC =
  83. # C++ sources to be compiled in ARM mode regardless of the global setting.
  84. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
  85. #       option that results in lower performance and larger code size.
  86. ACPPSRC =
  87. # C sources to be compiled in THUMB mode regardless of the global setting.
  88. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
  89. #       option that results in lower performance and larger code size.
  90. TCSRC =
  91. # C sources to be compiled in THUMB mode regardless of the global setting.
  92. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
  93. #       option that results in lower performance and larger code size.
  94. TCPPSRC =
  95. # List ASM source files here
  96. ASMSRC = $(PORTASM)
  97. INCDIR = $(PORTINC) \
  98. 	 $(KERNINC) \
  99. 	 $(TESTINC) \
  100.          $(HALINC) \
  101. 	 $(PLATFORMINC) \
  102. 	 $(BOARDINC) \
  103. 	 $(GFXINC) \
  104.          $(CHIBIOS)/os/various/devices_lib/accel \
  105.          $(CHIBIOS)/os/various \
  106. 	 include 
  107. #
  108. # Project, sources and paths
  109. ##############################################################################
  110. ##############################################################################
  111. # Compiler settings
  112. #
  113. MCU  = cortex-m4
  114. #TRGT = arm-elf-
  115. TRGT = arm-none-eabi-
  116. CC   = $(TRGT)gcc
  117. CPPC = $(TRGT)g++
  118. # Enable loading with g++ only if you need C++ runtime support.
  119. # NOTE: You can use C++ even without C++ support if you are careful. C++
  120. #       runtime support makes code size explode.
  121. LD   = $(TRGT)gcc
  122. #LD   = $(TRGT)g++
  123. CP   = $(TRGT)objcopy
  124. AS   = $(TRGT)gcc -x assembler-with-cpp
  125. OD   = $(TRGT)objdump
  126. HEX  = $(CP) -O ihex
  127. BIN  = $(CP) -O binary
  128. # ARM-specific options here
  129. AOPT =
  130. # THUMB-specific options here
  131. TOPT = -mthumb -DTHUMB
  132. # Define C warning options here
  133. CWARN = -Wall -Wextra -Wstrict-prototypes
  134. # Define C++ warning options here
  135. CPPWARN = -Wall -Wextra
  136. #
  137. # Compiler settings
  138. ##############################################################################
  139. ##############################################################################
  140. # Start of default section
  141. #
  142. # List all default C defines here, like -D_DEBUG=1
  143. DDEFS =
  144. # List all default ASM defines here, like -D_DEBUG=1
  145. DADEFS =
  146. # List all default directories to look for include files here
  147. DINCDIR =
  148. # List the default directory to look for the libraries here
  149. DLIBDIR =
  150. # List all default libraries here
  151. DLIBS =
  152. #
  153. # End of default section
  154. ##############################################################################
  155. ##############################################################################
  156. # Start of user section
  157. #
  158. # List all user C define here, like -D_DEBUG=1
  159. UDEFS =
  160. # Define ASM defines here
  161. UADEFS =
  162. # List all user directories here
  163. UINCDIR =
  164. # List the user directory to look for the libraries here
  165. ULIBDIR =
  166. # List all user libraries here
  167. ULIBS = -lm
  168. #
  169. # End of user defines
  170. ##############################################################################
  171. ifeq ($(USE_FPU),yes)
  172.   USE_OPT += -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -fsingle-precision-constant
  173.   DDEFS += -DCORTEX_USE_FPU=TRUE
  174. else
  175.   DDEFS += -DCORTEX_USE_FPU=FALSE
  176. endif
  177. ifeq ($(USE_FWLIB),yes)
  178.   include $(CHIBIOS)/ext/stm32lib/stm32lib.mk
  179.   CSRC += $(STM32SRC)
  180.   INCDIR += $(STM32INC)
  181.   USE_OPT += -DUSE_STDPERIPH_DRIVER
  182. endif
  183. include $(CHIBIOS)/os/ports/GCC/ARMCMx/rules.mk