constants.py 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. """Information that should be available to the python library.
  2. """
  3. from os import environ
  4. from datetime import date
  5. from pathlib import Path
  6. # The root of the qmk_firmware tree.
  7. QMK_FIRMWARE = Path.cwd()
  8. # Upstream repo url
  9. QMK_FIRMWARE_UPSTREAM = 'qmk/qmk_firmware'
  10. # This is the number of directories under `qmk_firmware/keyboards` that will be traversed. This is currently a limitation of our make system.
  11. MAX_KEYBOARD_SUBFOLDERS = 5
  12. # Supported processor types
  13. CHIBIOS_PROCESSORS = 'cortex-m0', 'cortex-m0plus', 'cortex-m3', 'cortex-m4', 'MKL26Z64', 'MK20DX128', 'MK20DX256', 'MK64FX512', 'MK66FX1M0', 'RP2040', 'STM32F042', 'STM32F072', 'STM32F103', 'STM32F303', 'STM32F401', 'STM32F405', 'STM32F407', 'STM32F411', 'STM32F446', 'STM32G431', 'STM32G474', 'STM32H723', 'STM32H733', 'STM32L412', 'STM32L422', 'STM32L432', 'STM32L433', 'STM32L442', 'STM32L443', 'GD32VF103', 'WB32F3G71', 'WB32FQ95'
  14. LUFA_PROCESSORS = 'at90usb162', 'atmega16u2', 'atmega32u2', 'atmega16u4', 'atmega32u4', 'at90usb646', 'at90usb647', 'at90usb1286', 'at90usb1287', None
  15. VUSB_PROCESSORS = 'atmega32a', 'atmega328p', 'atmega328', 'attiny85'
  16. # Bootloaders of the supported processors
  17. MCU2BOOTLOADER = {
  18. "RP2040": "rp2040",
  19. "MKL26Z64": "halfkay",
  20. "MK20DX128": "halfkay",
  21. "MK20DX256": "halfkay",
  22. "MK66FX1M0": "halfkay",
  23. "STM32F042": "stm32-dfu",
  24. "STM32F072": "stm32-dfu",
  25. "STM32F103": "stm32duino",
  26. "STM32F303": "stm32-dfu",
  27. "STM32F401": "stm32-dfu",
  28. "STM32F405": "stm32-dfu",
  29. "STM32F407": "stm32-dfu",
  30. "STM32F411": "stm32-dfu",
  31. "STM32F446": "stm32-dfu",
  32. "STM32G431": "stm32-dfu",
  33. "STM32G474": "stm32-dfu",
  34. "STM32H723": "stm32-dfu",
  35. "STM32H733": "stm32-dfu",
  36. "STM32L412": "stm32-dfu",
  37. "STM32L422": "stm32-dfu",
  38. "STM32L432": "stm32-dfu",
  39. "STM32L433": "stm32-dfu",
  40. "STM32L442": "stm32-dfu",
  41. "STM32L443": "stm32-dfu",
  42. "GD32VF103": "gd32v-dfu",
  43. "WB32F3G71": "wb32-dfu",
  44. "WB32FQ95": "wb32-dfu",
  45. "atmega16u2": "atmel-dfu",
  46. "atmega32u2": "atmel-dfu",
  47. "atmega16u4": "atmel-dfu",
  48. "atmega32u4": "atmel-dfu",
  49. "at90usb162": "atmel-dfu",
  50. "at90usb646": "atmel-dfu",
  51. "at90usb647": "atmel-dfu",
  52. "at90usb1286": "atmel-dfu",
  53. "at90usb1287": "atmel-dfu",
  54. "atmega32a": "bootloadhid",
  55. "atmega328p": "usbasploader",
  56. "atmega328": "usbasploader",
  57. }
  58. # Map of legacy keycodes that can be automatically updated
  59. LEGACY_KEYCODES = { # Comment here is to force multiline formatting
  60. 'RESET': 'QK_BOOT'
  61. }
  62. # Map VID:PID values to bootloaders
  63. BOOTLOADER_VIDS_PIDS = {
  64. 'atmel-dfu': {
  65. ("03eb", "2fef"), # ATmega16U2
  66. ("03eb", "2ff0"), # ATmega32U2
  67. ("03eb", "2ff3"), # ATmega16U4
  68. ("03eb", "2ff4"), # ATmega32U4
  69. ("03eb", "2ff9"), # AT90USB64
  70. ("03eb", "2ffa"), # AT90USB162
  71. ("03eb", "2ffb") # AT90USB128
  72. },
  73. 'kiibohd': {("1c11", "b007")},
  74. 'stm32-dfu': {
  75. ("1eaf", "0003"), # STM32duino
  76. ("0483", "df11") # STM32 DFU
  77. },
  78. 'apm32-dfu': {("314b", "0106")},
  79. 'gd32v-dfu': {("28e9", "0189")},
  80. 'wb32-dfu': {("342d", "dfa0")},
  81. 'bootloadhid': {("16c0", "05df")},
  82. 'usbasploader': {("16c0", "05dc")},
  83. 'usbtinyisp': {("1782", "0c9f")},
  84. 'md-boot': {("03eb", "6124")},
  85. 'caterina': {
  86. # pid.codes shared PID
  87. ("1209", "2302"), # Keyboardio Atreus 2 Bootloader
  88. # Spark Fun Electronics
  89. ("1b4f", "9203"), # Pro Micro 3V3/8MHz
  90. ("1b4f", "9205"), # Pro Micro 5V/16MHz
  91. ("1b4f", "9207"), # LilyPad 3V3/8MHz (and some Pro Micro clones)
  92. # Pololu Electronics
  93. ("1ffb", "0101"), # A-Star 32U4
  94. # Arduino SA
  95. ("2341", "0036"), # Leonardo
  96. ("2341", "0037"), # Micro
  97. # Adafruit Industries LLC
  98. ("239a", "000c"), # Feather 32U4
  99. ("239a", "000d"), # ItsyBitsy 32U4 3V3/8MHz
  100. ("239a", "000e"), # ItsyBitsy 32U4 5V/16MHz
  101. # dog hunter AG
  102. ("2a03", "0036"), # Leonardo
  103. ("2a03", "0037") # Micro
  104. },
  105. 'hid-bootloader': {
  106. ("03eb", "2067"), # QMK HID
  107. ("16c0", "0478") # PJRC halfkay
  108. }
  109. }
  110. # Common format strings
  111. DATE_FORMAT = '%Y-%m-%d'
  112. DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S %Z'
  113. TIME_FORMAT = '%H:%M:%S'
  114. # Used when generating matrix locations
  115. COL_LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijilmnopqrstuvwxyz'
  116. ROW_LETTERS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnop'
  117. # Constants that should match their counterparts in make
  118. BUILD_DIR = environ.get('BUILD_DIR', '.build')
  119. INTERMEDIATE_OUTPUT_PREFIX = f'{BUILD_DIR}/obj_'
  120. # Headers for generated files
  121. GPL2_HEADER_C_LIKE = f'''\
  122. // Copyright {date.today().year} QMK
  123. // SPDX-License-Identifier: GPL-2.0-or-later
  124. '''
  125. GPL2_HEADER_SH_LIKE = f'''\
  126. # Copyright {date.today().year} QMK
  127. # SPDX-License-Identifier: GPL-2.0-or-later
  128. '''
  129. GENERATED_HEADER_C_LIKE = '''\
  130. /*******************************************************************************
  131. 88888888888 888 d8b .d888 d8b 888 d8b
  132. 888 888 Y8P d88P" Y8P 888 Y8P
  133. 888 888 888 888
  134. 888 88888b. 888 .d8888b 888888 888 888 .d88b. 888 .d8888b
  135. 888 888 "88b 888 88K 888 888 888 d8P Y8b 888 88K
  136. 888 888 888 888 "Y8888b. 888 888 888 88888888 888 "Y8888b.
  137. 888 888 888 888 X88 888 888 888 Y8b. 888 X88
  138. 888 888 888 888 88888P' 888 888 888 "Y8888 888 88888P'
  139. 888 888
  140. 888 888
  141. 888 888
  142. .d88b. .d88b. 88888b. .d88b. 888d888 8888b. 888888 .d88b. .d88888
  143. d88P"88b d8P Y8b 888 "88b d8P Y8b 888P" "88b 888 d8P Y8b d88" 888
  144. 888 888 88888888 888 888 88888888 888 .d888888 888 88888888 888 888
  145. Y88b 888 Y8b. 888 888 Y8b. 888 888 888 Y88b. Y8b. Y88b 888
  146. "Y88888 "Y8888 888 888 "Y8888 888 "Y888888 "Y888 "Y8888 "Y88888
  147. 888
  148. Y8b d88P
  149. "Y88P"
  150. *******************************************************************************/
  151. '''
  152. GENERATED_HEADER_SH_LIKE = '''\
  153. ################################################################################
  154. #
  155. # 88888888888 888 d8b .d888 d8b 888 d8b
  156. # 888 888 Y8P d88P" Y8P 888 Y8P
  157. # 888 888 888 888
  158. # 888 88888b. 888 .d8888b 888888 888 888 .d88b. 888 .d8888b
  159. # 888 888 "88b 888 88K 888 888 888 d8P Y8b 888 88K
  160. # 888 888 888 888 "Y8888b. 888 888 888 88888888 888 "Y8888b.
  161. # 888 888 888 888 X88 888 888 888 Y8b. 888 X88
  162. # 888 888 888 888 88888P' 888 888 888 "Y8888 888 88888P'
  163. #
  164. # 888 888
  165. # 888 888
  166. # 888 888
  167. # .d88b. .d88b. 88888b. .d88b. 888d888 8888b. 888888 .d88b. .d88888
  168. # d88P"88b d8P Y8b 888 "88b d8P Y8b 888P" "88b 888 d8P Y8b d88" 888
  169. # 888 888 88888888 888 888 88888888 888 .d888888 888 88888888 888 888
  170. # Y88b 888 Y8b. 888 888 Y8b. 888 888 888 Y88b. Y8b. Y88b 888
  171. # "Y88888 "Y8888 888 888 "Y8888 888 "Y888888 "Y888 "Y8888 "Y88888
  172. # 888
  173. # Y8b d88P
  174. # "Y88P"
  175. #
  176. ################################################################################
  177. '''
  178. LICENSE_TEXTS = [
  179. (
  180. 'GPL-2.0-or-later', [
  181. """\
  182. This program is free software; you can redistribute it and/or
  183. modify it under the terms of the GNU General Public License
  184. as published by the Free Software Foundation; either version 2
  185. of the License, or (at your option) any later version.
  186. """, """\
  187. This program is free software; you can redistribute it and/or
  188. modify it under the terms of the GNU General Public License
  189. as published by the Free Software Foundation; either version 2
  190. of the License, or any later version.
  191. """
  192. ]
  193. ),
  194. ('GPL-2.0-only', ["""\
  195. This program is free software; you can redistribute it and/or
  196. modify it under the terms of the GNU General Public License as
  197. published by the Free Software Foundation; version 2.
  198. """]),
  199. (
  200. 'GPL-3.0-or-later', [
  201. """\
  202. This program is free software: you can redistribute it and/or
  203. modify it under the terms of the GNU General Public License as
  204. published by the Free Software Foundation, either version 3 of
  205. the License, or (at your option) any later version.
  206. """, """\
  207. This program is free software: you can redistribute it and/or
  208. modify it under the terms of the GNU General Public License as
  209. published by the Free Software Foundation, either version 3 of
  210. the License, or any later version.
  211. """
  212. ]
  213. ),
  214. ('GPL-3.0-only', ["""\
  215. This program is free software: you can redistribute it and/or
  216. modify it under the terms of the GNU General Public License as
  217. published by the Free Software Foundation, version 3.
  218. """]),
  219. (
  220. 'LGPL-2.1-or-later', [
  221. """\
  222. This program is free software; you can redistribute it and/or
  223. modify it under the terms of the GNU Lesser General Public License
  224. as published by the Free Software Foundation; either version 2.1
  225. of the License, or (at your option) any later version.
  226. """, """\
  227. This program is free software; you can redistribute it and/or
  228. modify it under the terms of the GNU Lesser General Public License
  229. as published by the Free Software Foundation; either version 2.1
  230. of the License, or any later version.
  231. """, """\
  232. This library is free software; you can redistribute it and/or
  233. modify it under the terms of the GNU Lesser General Public License
  234. as published by the Free Software Foundation; either version 2.1
  235. of the License, or (at your option) any later version.
  236. """, """\
  237. This library is free software; you can redistribute it and/or
  238. modify it under the terms of the GNU Lesser General Public License
  239. as published by the Free Software Foundation; either version 2.1
  240. of the License, or any later version.
  241. """
  242. ]
  243. ),
  244. (
  245. 'LGPL-2.1-only', [
  246. """\
  247. This program is free software; you can redistribute it and/or
  248. modify it under the terms of the GNU Lesser General Public License as
  249. published by the Free Software Foundation; version 2.1.
  250. """, """\
  251. This library is free software; you can redistribute it and/or
  252. modify it under the terms of the GNU Lesser General Public License as
  253. published by the Free Software Foundation; version 2.1.
  254. """
  255. ]
  256. ),
  257. (
  258. 'LGPL-3.0-or-later', [
  259. """\
  260. This program is free software; you can redistribute it and/or
  261. modify it under the terms of the GNU Lesser General Public License
  262. as published by the Free Software Foundation; either version 3
  263. of the License, or (at your option) any later version.
  264. """, """\
  265. This program is free software; you can redistribute it and/or
  266. modify it under the terms of the GNU Lesser General Public License
  267. as published by the Free Software Foundation; either version 3
  268. of the License, or any later version.
  269. """, """\
  270. This library is free software; you can redistribute it and/or
  271. modify it under the terms of the GNU Lesser General Public License
  272. as published by the Free Software Foundation; either version 3
  273. of the License, or (at your option) any later version.
  274. """, """\
  275. This library is free software; you can redistribute it and/or
  276. modify it under the terms of the GNU Lesser General Public License
  277. as published by the Free Software Foundation; either version 3
  278. of the License, or any later version.
  279. """
  280. ]
  281. ),
  282. (
  283. 'LGPL-3.0-only', [
  284. """\
  285. This program is free software; you can redistribute it and/or
  286. modify it under the terms of the GNU Lesser General Public License as
  287. published by the Free Software Foundation; version 3.
  288. """, """\
  289. This library is free software; you can redistribute it and/or
  290. modify it under the terms of the GNU Lesser General Public License as
  291. published by the Free Software Foundation; version 3.
  292. """
  293. ]
  294. ),
  295. ('Apache-2.0', ["""\
  296. Licensed under the Apache License, Version 2.0 (the "License");
  297. you may not use this file except in compliance with the License.
  298. """]),
  299. ]