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:...")
 
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 highlight="53,58">
+
<syntaxhighlight lang=make line start="1" highlight="53,58">
 
##############################################################################
 
##############################################################################
 
# Build global options
 
# Build global options

Revision as of 14:54, 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:

  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. 	src/usb_shell.c \
  76.        	main.c
  77. # C++ sources that can be compiled in ARM or THUMB mode depending on the global
  78. # setting.
  79. CPPSRC =
  80. # C sources to be compiled in ARM mode regardless of the global setting.
  81. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
  82. #       option that results in lower performance and larger code size.
  83. ACSRC =
  84. # C++ sources to be compiled in ARM mode regardless of the global setting.
  85. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
  86. #       option that results in lower performance and larger code size.
  87. ACPPSRC =
  88. # C sources to be compiled in THUMB mode regardless of the global setting.
  89. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
  90. #       option that results in lower performance and larger code size.
  91. TCSRC =
  92. # C sources to be compiled in THUMB mode regardless of the global setting.
  93. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
  94. #       option that results in lower performance and larger code size.
  95. TCPPSRC =
  96. # List ASM source files here
  97. ASMSRC = $(PORTASM)
  98. INCDIR = $(PORTINC) \
  99. 	 $(KERNINC) \
  100. 	 $(TESTINC) \
  101.          $(HALINC) \
  102. 	 $(PLATFORMINC) \
  103. 	 $(BOARDINC) \
  104. 	 $(GFXINC) \
  105.          $(CHIBIOS)/os/various/devices_lib/accel \
  106.          $(CHIBIOS)/os/various \
  107. 	 include 
  108. #
  109. # Project, sources and paths
  110. ##############################################################################
  111. ##############################################################################
  112. # Compiler settings
  113. #
  114. MCU  = cortex-m4
  115. #TRGT = arm-elf-
  116. TRGT = arm-none-eabi-
  117. CC   = $(TRGT)gcc
  118. CPPC = $(TRGT)g++
  119. # Enable loading with g++ only if you need C++ runtime support.
  120. # NOTE: You can use C++ even without C++ support if you are careful. C++
  121. #       runtime support makes code size explode.
  122. LD   = $(TRGT)gcc
  123. #LD   = $(TRGT)g++
  124. CP   = $(TRGT)objcopy
  125. AS   = $(TRGT)gcc -x assembler-with-cpp
  126. OD   = $(TRGT)objdump
  127. HEX  = $(CP) -O ihex
  128. BIN  = $(CP) -O binary
  129. # ARM-specific options here
  130. AOPT =
  131. # THUMB-specific options here
  132. TOPT = -mthumb -DTHUMB
  133. # Define C warning options here
  134. CWARN = -Wall -Wextra -Wstrict-prototypes
  135. # Define C++ warning options here
  136. CPPWARN = -Wall -Wextra
  137. #
  138. # Compiler settings
  139. ##############################################################################
  140. ##############################################################################
  141. # Start of default section
  142. #
  143. # List all default C defines here, like -D_DEBUG=1
  144. DDEFS =
  145. # List all default ASM defines here, like -D_DEBUG=1
  146. DADEFS =
  147. # List all default directories to look for include files here
  148. DINCDIR =
  149. # List the default directory to look for the libraries here
  150. DLIBDIR =
  151. # List all default libraries here
  152. DLIBS =
  153. #
  154. # End of default section
  155. ##############################################################################
  156. ##############################################################################
  157. # Start of user section
  158. #
  159. # List all user C define here, like -D_DEBUG=1
  160. UDEFS =
  161. # Define ASM defines here
  162. UADEFS =
  163. # List all user directories here
  164. UINCDIR =
  165. # List the user directory to look for the libraries here
  166. ULIBDIR =
  167. # List all user libraries here
  168. ULIBS = -lm
  169. #
  170. # End of user defines
  171. ##############################################################################
  172. ifeq ($(USE_FPU),yes)
  173.   USE_OPT += -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -fsingle-precision-constant
  174.   DDEFS += -DCORTEX_USE_FPU=TRUE
  175. else
  176.   DDEFS += -DCORTEX_USE_FPU=FALSE
  177. endif
  178. ifeq ($(USE_FWLIB),yes)
  179.   include $(CHIBIOS)/ext/stm32lib/stm32lib.mk
  180.   CSRC += $(STM32SRC)
  181.   INCDIR += $(STM32INC)
  182.   USE_OPT += -DUSE_STDPERIPH_DRIVER
  183. endif
  184. include $(CHIBIOS)/os/ports/GCC/ARMCMx/rules.mk