S&B Volcano vaporizer remote control with Pi Pico W
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

CMakeLists.txt 8.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. # ----------------------------------------------------------------------------
  2. # Copyright (c) 2023 Thomas Buck (thomas@xythobuz.de)
  3. #
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # See <http://www.gnu.org/licenses/>.
  15. # ----------------------------------------------------------------------------
  16. cmake_minimum_required(VERSION 3.5)
  17. # build MCUFont encoder host tool and convert included example fonts
  18. execute_process(COMMAND make
  19. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/mcufont/encoder
  20. )
  21. execute_process(COMMAND make
  22. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/mcufont/fonts
  23. )
  24. # build lwip httpd fs
  25. # TODO should use C version instead of Perl script, for
  26. # TODO added file compression. but how to compile it?
  27. set(MAKE_FS_DATA_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/pico-sdk/lib/lwip/src/apps/http/makefsdata/makefsdata)
  28. execute_process(
  29. COMMAND perl ${MAKE_FS_DATA_SCRIPT}
  30. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  31. ECHO_OUTPUT_VARIABLE
  32. ECHO_ERROR_VARIABLE
  33. )
  34. file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/fsdata.c ${CMAKE_CURRENT_BINARY_DIR}/httpd_fsdata.c)
  35. # initialize pico-sdk from submodule
  36. include(pico-sdk/pico_sdk_init.cmake)
  37. project(gadget C CXX)
  38. set(CMAKE_C_STANDARD 11)
  39. set(CMAKE_CXX_STANDARD 17)
  40. set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
  41. # initialize the Raspberry Pi Pico SDK
  42. pico_sdk_init()
  43. # copy FatFS source files to build dir, so we can use our own ffconf.h
  44. configure_file(
  45. ${CMAKE_CURRENT_SOURCE_DIR}/fatfs/source/ff.c
  46. ${CMAKE_CURRENT_BINARY_DIR}/fatfs/ff.c
  47. COPYONLY
  48. )
  49. configure_file(
  50. ${CMAKE_CURRENT_SOURCE_DIR}/fatfs/source/ff.h
  51. ${CMAKE_CURRENT_BINARY_DIR}/fatfs/ff.h
  52. COPYONLY
  53. )
  54. configure_file(
  55. ${CMAKE_CURRENT_SOURCE_DIR}/fatfs/source/diskio.h
  56. ${CMAKE_CURRENT_BINARY_DIR}/fatfs/diskio.h
  57. COPYONLY
  58. )
  59. configure_file(
  60. ${CMAKE_CURRENT_SOURCE_DIR}/fatfs/source/ffunicode.c
  61. ${CMAKE_CURRENT_BINARY_DIR}/fatfs/ffunicode.c
  62. COPYONLY
  63. )
  64. add_executable(gadget)
  65. target_sources(gadget PUBLIC
  66. src/main.c
  67. src/console.c
  68. src/log.c
  69. src/util.c
  70. src/usb.c
  71. src/usb_cdc.c
  72. src/usb_descriptors.c
  73. src/usb_msc.c
  74. src/fat_disk.c
  75. src/debug_disk.c
  76. src/buttons.c
  77. src/lipo.c
  78. src/ble.c
  79. src/lcd.c
  80. src/text.c
  81. src/image.c
  82. src/state.c
  83. src/volcano.c
  84. src/serial.c
  85. src/ring.c
  86. src/models.c
  87. src/state_scan.c
  88. src/workflow.c
  89. src/menu.c
  90. src/state_workflow.c
  91. src/state_volcano_run.c
  92. src/crafty.c
  93. src/state_crafty.c
  94. src/mem.c
  95. src/state_edit_workflow.c
  96. src/workflow_default.c
  97. src/state_settings.c
  98. src/state_about.c
  99. src/state_value.c
  100. src/textbox.c
  101. src/state_volcano_conf.c
  102. src/wifi.c
  103. src/venty.c
  104. src/state_venty.c
  105. src/state_wifi.c
  106. src/state_wifi_edit.c
  107. src/state_string.c
  108. src/http.c
  109. src/cache.c
  110. ${CMAKE_CURRENT_BINARY_DIR}/fatfs/ff.c
  111. ${CMAKE_CURRENT_BINARY_DIR}/fatfs/ffunicode.c
  112. st7789/src/driver_st7789.c
  113. mcufont/decoder/mf_encoding.c
  114. mcufont/decoder/mf_font.c
  115. mcufont/decoder/mf_justify.c
  116. mcufont/decoder/mf_kerning.c
  117. mcufont/decoder/mf_rlefont.c
  118. mcufont/decoder/mf_bwfont.c
  119. mcufont/decoder/mf_scaledfont.c
  120. mcufont/decoder/mf_wordwrap.c
  121. picowota/dhcpserver/dhcpserver.c
  122. )
  123. # external dependency include directories
  124. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/conf)
  125. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)
  126. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/fatfs)
  127. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/st7789/src)
  128. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/st7789/interface)
  129. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/mcufont/decoder)
  130. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/data)
  131. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/build)
  132. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
  133. target_include_directories(gadget PUBLIC ${CMAKE_CURRENT_LIST_DIR}/picowota/dhcpserver)
  134. # compress source code and stuff we want to include
  135. add_custom_target(pack bash -c "./pack_data.sh ${CMAKE_CURRENT_BINARY_DIR}"
  136. WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
  137. BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/fat_fs.o"
  138. )
  139. add_dependencies(gadget pack)
  140. # enable generous warnings
  141. target_compile_options(gadget PUBLIC
  142. -Wall
  143. -Wextra
  144. -Werror
  145. -Wshadow
  146. )
  147. # suppress some warnings for borked 3rd party files in Pico SDK
  148. set_source_files_properties(pico-sdk/lib/btstack/src/ble/sm.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
  149. set_source_files_properties(pico-sdk/lib/btstack/src/btstack_hid_parser.c PROPERTIES COMPILE_FLAGS -Wno-maybe-uninitialized)
  150. set_source_files_properties(pico-sdk/src/rp2_common/pico_cyw43_driver/cyw43_driver.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
  151. set_source_files_properties(pico-sdk/lib/btstack/src/classic/avdtp_util.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
  152. set_source_files_properties(pico-sdk/lib/btstack/src/classic/goep_client.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
  153. set_source_files_properties(pico-sdk/lib/btstack/src/classic/goep_server.c PROPERTIES COMPILE_FLAGS -Wno-unused-parameter)
  154. set_source_files_properties(pico-sdk/src/rp2_common/hardware_flash/flash.c PROPERTIES COMPILE_FLAGS -Wno-shadow)
  155. # pull in common dependencies
  156. target_link_libraries(gadget
  157. pico_stdlib
  158. pico_unique_id
  159. tinyusb_device
  160. tinyusb_board
  161. hardware_spi
  162. hardware_adc
  163. hardware_gpio
  164. hardware_pwm
  165. pico_btstack_ble
  166. pico_btstack_cyw43
  167. pico_cyw43_arch_lwip_threadsafe_background
  168. hardware_flash
  169. pico_flash
  170. picowota_reboot
  171. pico_lwip_http
  172. )
  173. pico_set_linker_script(gadget ${CMAKE_CURRENT_SOURCE_DIR}/conf/memmap_custom.ld)
  174. # fix for Errata RP2040-E5 (the fix requires use of GPIO 15)
  175. target_compile_definitions(gadget PUBLIC PICO_RP2040_USB_DEVICE_ENUMERATION_FIX=1)
  176. set(PICOWOTA_WIFI_SSID "WIFI_SSID_HERE")
  177. set(PICOWOTA_WIFI_PASS "WIFI_PASS_HERE")
  178. set(PICOWOTA_WIFI_AP 0)
  179. target_compile_definitions(gadget PUBLIC
  180. RUNNING_AS_CLIENT=1
  181. DEFAULT_WIFI_SSID="${PICOWOTA_WIFI_SSID}"
  182. DEFAULT_WIFI_PASS="${PICOWOTA_WIFI_PASS}"
  183. CYW43_HOST_NAME="pico-volcano"
  184. )
  185. set(PICOWOTA_ADDITIONAL_SOURCES
  186. ${CMAKE_CURRENT_SOURCE_DIR}/src/wifi.c
  187. ${CMAKE_CURRENT_SOURCE_DIR}/src/lcd.c
  188. ${CMAKE_CURRENT_SOURCE_DIR}/src/log.c
  189. ${CMAKE_CURRENT_SOURCE_DIR}/src/mem.c
  190. ${CMAKE_CURRENT_SOURCE_DIR}/src/ring.c
  191. ${CMAKE_CURRENT_SOURCE_DIR}/src/textbox.c
  192. ${CMAKE_CURRENT_SOURCE_DIR}/src/text.c
  193. ${CMAKE_CURRENT_SOURCE_DIR}/src/ota_shim.c
  194. ${CMAKE_CURRENT_SOURCE_DIR}/src/workflow_default.c
  195. ${CMAKE_CURRENT_SOURCE_DIR}/src/buttons.c
  196. ${CMAKE_CURRENT_SOURCE_DIR}/src/util.c
  197. ${CMAKE_CURRENT_SOURCE_DIR}/src/usb_descriptors.c
  198. ${CMAKE_CURRENT_SOURCE_DIR}/st7789/src/driver_st7789.c
  199. ${CMAKE_CURRENT_SOURCE_DIR}/mcufont/decoder/mf_encoding.c
  200. ${CMAKE_CURRENT_SOURCE_DIR}/mcufont/decoder/mf_font.c
  201. ${CMAKE_CURRENT_SOURCE_DIR}/mcufont/decoder/mf_justify.c
  202. ${CMAKE_CURRENT_SOURCE_DIR}/mcufont/decoder/mf_kerning.c
  203. ${CMAKE_CURRENT_SOURCE_DIR}/mcufont/decoder/mf_rlefont.c
  204. ${CMAKE_CURRENT_SOURCE_DIR}/mcufont/decoder/mf_bwfont.c
  205. ${CMAKE_CURRENT_SOURCE_DIR}/mcufont/decoder/mf_scaledfont.c
  206. ${CMAKE_CURRENT_SOURCE_DIR}/mcufont/decoder/mf_wordwrap.c
  207. )
  208. set(PICOWOTA_ADDITIONAL_INCLUDES
  209. ${CMAKE_CURRENT_SOURCE_DIR}/include
  210. ${CMAKE_CURRENT_SOURCE_DIR}/conf
  211. ${CMAKE_CURRENT_SOURCE_DIR}/data
  212. ${CMAKE_CURRENT_SOURCE_DIR}/st7789/src
  213. ${CMAKE_CURRENT_SOURCE_DIR}/st7789/interface
  214. ${CMAKE_CURRENT_SOURCE_DIR}/mcufont/decoder
  215. ${CMAKE_CURRENT_BINARY_DIR}/fatfs
  216. ${CMAKE_CURRENT_SOURCE_DIR}/pico-sdk/src/rp2_common/pico_btstack/include
  217. ${CMAKE_CURRENT_SOURCE_DIR}/pico-sdk/lib/btstack/platform/embedded
  218. )
  219. set(PICOWOTA_ADDITIONAL_LIBS
  220. hardware_spi
  221. hardware_pwm
  222. hardware_flash
  223. pico_flash
  224. )
  225. add_subdirectory(picowota)
  226. picowota_build_combined(gadget)