You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

615 lines
19 KiB

  1. """Detect boards."""
  2. import os
  3. import re
  4. import adafruit_platformdetect.chip as ap_chip
  5. # Allow for aligned constant definitions:
  6. # pylint: disable=bad-whitespace
  7. BEAGLEBONE = 'BEAGLEBONE'
  8. BEAGLEBONE_BLACK = 'BEAGLEBONE_BLACK'
  9. BEAGLEBONE_BLUE = 'BEAGLEBONE_BLUE'
  10. BEAGLEBONE_BLACK_WIRELESS = 'BEAGLEBONE_BLACK_WIRELESS'
  11. BEAGLEBONE_POCKETBEAGLE = 'BEAGLEBONE_POCKETBEAGLE'
  12. BEAGLEBONE_GREEN = 'BEAGLEBONE_GREEN'
  13. BEAGLEBONE_GREEN_WIRELESS = 'BEAGLEBONE_GREEN_WIRELESS'
  14. BEAGLEBONE_BLACK_INDUSTRIAL = 'BEAGLEBONE_BLACK_INDUSTRIAL'
  15. BEAGLEBONE_ENHANCED = 'BEAGLEBONE_ENHANCED'
  16. BEAGLEBONE_USOMIQ = 'BEAGLEBONE_USOMIQ'
  17. BEAGLEBONE_AIR = 'BEAGLEBONE_AIR'
  18. BEAGLEBONE_POCKETBONE = 'BEAGLEBONE_POCKETBONE'
  19. BEAGLELOGIC_STANDALONE = 'BEAGLELOGIC_STANDALONE'
  20. OSD3358_DEV_BOARD = 'OSD3358_DEV_BOARD'
  21. OSD3358_SM_RED = 'OSD3358_SM_RED'
  22. FEATHER_HUZZAH = "FEATHER_HUZZAH"
  23. FEATHER_M0_EXPRESS = "FEATHER_M0_EXPRESS"
  24. GENERIC_LINUX_PC = "GENERIC_LINUX_PC"
  25. PYBOARD = "PYBOARD"
  26. NODEMCU = "NODEMCU"
  27. GIANT_BOARD = "GIANT_BOARD"
  28. # Orange Pi boards
  29. ORANGE_PI_PC = "ORANGE_PI_PC"
  30. ORANGE_PI_R1 = "ORANGE_PI_R1"
  31. ORANGE_PI_ZERO = "ORANGE_PI_ZERO"
  32. ORANGE_PI_ONE = "ORANGE_PI_ONE"
  33. ORANGE_PI_LITE = "ORANGE_PI_LITE"
  34. ORANGE_PI_PC_PLUS = "ORANGE_PI_PC_PLUS"
  35. # NVIDIA Jetson boards
  36. JETSON_TX1 = 'JETSON_TX1'
  37. JETSON_TX2 = 'JETSON_TX2'
  38. JETSON_XAVIER = 'JETSON_XAVIER'
  39. JETSON_NANO = 'JETSON_NANO'
  40. # Google Coral dev board
  41. CORAL_EDGE_TPU_DEV = "CORAL_EDGE_TPU_DEV"
  42. # Various Raspberry Pi models
  43. RASPBERRY_PI_B_REV1 = "RASPBERRY_PI_B_REV1"
  44. RASPBERRY_PI_B_REV2 = "RASPBERRY_PI_B_REV2"
  45. RASPBERRY_PI_B_PLUS = "RASPBERRY_PI_B_PLUS"
  46. RASPBERRY_PI_A = "RASPBERRY_PI_A"
  47. RASPBERRY_PI_A_PLUS = "RASPBERRY_PI_A_PLUS"
  48. RASPBERRY_PI_CM1 = "RASPBERRY_PI_CM1"
  49. RASPBERRY_PI_ZERO = "RASPBERRY_PI_ZERO"
  50. RASPBERRY_PI_ZERO_W = "RASPBERRY_PI_ZERO_W"
  51. RASPBERRY_PI_2B = "RASPBERRY_PI_2B"
  52. RASPBERRY_PI_3B = "RASPBERRY_PI_3B"
  53. RASPBERRY_PI_3B_PLUS = "RASPBERRY_PI_3B_PLUS"
  54. RASPBERRY_PI_CM3 = "RASPBERRY_PI_CM3"
  55. RASPBERRY_PI_3A_PLUS = "RASPBERRY_PI_3A_PLUS"
  56. RASPBERRY_PI_CM3_PLUS = "RASPBERRY_PI_CM3_PLUS"
  57. RASPBERRY_PI_4B = "RASPBERRY_PI_4B"
  58. ODROID_C1 = "ODROID_C1"
  59. ODROID_C1_PLUS = "ODROID_C1_PLUS"
  60. ODROID_C2 = "ODROID_C2"
  61. ODROID_N2 = "ODROID_N2"
  62. FTDI_FT232H = "FTDI_FT232H"
  63. DRAGONBOARD_410C = "DRAGONBOARD_410C"
  64. SIFIVE_UNLEASHED = "SIFIVE_UNLEASHED"
  65. MICROCHIP_MCP2221 = "MICROCHIP_MCP2221"
  66. BINHO_NOVA = "BINHO_NOVA"
  67. ONION_OMEGA = "ONION_OMEGA"
  68. ONION_OMEGA2 = "ONION_OMEGA2"
  69. PINE64 = "PINE64"
  70. PINEBOOK = "PINEBOOK"
  71. PINEPHONE = "PINEPHONE"
  72. # pylint: enable=bad-whitespace
  73. #OrangePI
  74. _ORANGE_PI_IDS = (
  75. ORANGE_PI_PC,
  76. ORANGE_PI_R1,
  77. ORANGE_PI_ZERO,
  78. ORANGE_PI_ONE,
  79. ORANGE_PI_LITE,
  80. ORANGE_PI_LITE
  81. )
  82. _CORAL_IDS = (
  83. CORAL_EDGE_TPU_DEV,
  84. )
  85. _JETSON_IDS = (
  86. JETSON_TX1,
  87. JETSON_TX2,
  88. JETSON_XAVIER,
  89. JETSON_NANO
  90. )
  91. _RASPBERRY_PI_40_PIN_IDS = (
  92. RASPBERRY_PI_B_PLUS,
  93. RASPBERRY_PI_A_PLUS,
  94. RASPBERRY_PI_ZERO,
  95. RASPBERRY_PI_ZERO_W,
  96. RASPBERRY_PI_2B,
  97. RASPBERRY_PI_3B,
  98. RASPBERRY_PI_3B_PLUS,
  99. RASPBERRY_PI_3A_PLUS,
  100. RASPBERRY_PI_4B
  101. )
  102. _RASPBERRY_PI_CM_IDS = (
  103. RASPBERRY_PI_CM1,
  104. RASPBERRY_PI_CM3,
  105. RASPBERRY_PI_CM3_PLUS
  106. )
  107. _ODROID_40_PIN_IDS = (
  108. ODROID_C1,
  109. ODROID_C1_PLUS,
  110. ODROID_C2,
  111. ODROID_N2
  112. )
  113. _BEAGLEBONE_IDS = (
  114. BEAGLEBONE,
  115. BEAGLEBONE_BLACK,
  116. BEAGLEBONE_BLUE,
  117. BEAGLEBONE_BLACK_WIRELESS,
  118. BEAGLEBONE_POCKETBEAGLE,
  119. BEAGLEBONE_GREEN,
  120. BEAGLEBONE_GREEN_WIRELESS,
  121. BEAGLEBONE_BLACK_INDUSTRIAL,
  122. BEAGLEBONE_ENHANCED,
  123. BEAGLEBONE_USOMIQ,
  124. BEAGLEBONE_AIR,
  125. BEAGLEBONE_POCKETBONE,
  126. BEAGLELOGIC_STANDALONE,
  127. OSD3358_DEV_BOARD,
  128. OSD3358_SM_RED,
  129. )
  130. _LINARO_96BOARDS_IDS = (
  131. DRAGONBOARD_410C,
  132. )
  133. _SIFIVE_IDS = (
  134. SIFIVE_UNLEASHED,
  135. )
  136. # BeagleBone eeprom board ids from:
  137. # https://github.com/beagleboard/image-builder
  138. # Thanks to zmatt on freenode #beagle for pointers.
  139. _BEAGLEBONE_BOARD_IDS = {
  140. # Original bone/white:
  141. BEAGLEBONE: (
  142. ('A4', 'A335BONE00A4'),
  143. ('A5', 'A335BONE00A5'),
  144. ('A6', 'A335BONE00A6'),
  145. ('A6A', 'A335BONE0A6A'),
  146. ('A6B', 'A335BONE0A6B'),
  147. ('B', 'A335BONE000B'),
  148. ),
  149. BEAGLEBONE_BLACK: (
  150. ('A5', 'A335BNLT00A5'),
  151. ('A5A', 'A335BNLT0A5A'),
  152. ('A5B', 'A335BNLT0A5B'),
  153. ('A5C', 'A335BNLT0A5C'),
  154. ('A6', 'A335BNLT00A6'),
  155. ('C', 'A335BNLT000C'),
  156. ('C', 'A335BNLT00C0'),
  157. ),
  158. BEAGLEBONE_BLUE: (
  159. ('A2', 'A335BNLTBLA2'),
  160. ),
  161. BEAGLEBONE_BLACK_WIRELESS: (
  162. ('A5', 'A335BNLTBWA5'),
  163. ),
  164. BEAGLEBONE_POCKETBEAGLE: (
  165. ('A2', 'A335PBGL00A2'),
  166. ),
  167. BEAGLEBONE_GREEN: (
  168. ('1A', 'A335BNLT....'),
  169. ('UNKNOWN', 'A335BNLTBBG1'),
  170. ),
  171. BEAGLEBONE_GREEN_WIRELESS: (
  172. ('W1A', 'A335BNLTGW1A'),
  173. ),
  174. BEAGLEBONE_BLACK_INDUSTRIAL: (
  175. ('A0', 'A335BNLTAIA0'), # Arrow
  176. ('A0', 'A335BNLTEIA0'), # Element14
  177. ),
  178. BEAGLEBONE_ENHANCED: (
  179. ('A', 'A335BNLTSE0A'),
  180. ),
  181. BEAGLEBONE_USOMIQ: (
  182. ('6', 'A335BNLTME06'),
  183. ),
  184. BEAGLEBONE_AIR: (
  185. ('A0', 'A335BNLTNAD0'),
  186. ),
  187. BEAGLEBONE_POCKETBONE: (
  188. ('0', 'A335BNLTBP00'),
  189. ),
  190. OSD3358_DEV_BOARD: (
  191. ('0.1', 'A335BNLTGH01'),
  192. ),
  193. OSD3358_SM_RED: (
  194. ('0', 'A335BNLTOS00'),
  195. ),
  196. BEAGLELOGIC_STANDALONE: (
  197. ('A', 'A335BLGC000A'),
  198. )
  199. }
  200. # Pi revision codes from:
  201. # https://www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md
  202. # Each tuple here contains both the base codes, and the versions that indicate
  203. # the Pi is overvolted / overclocked - for 4-digit codes, this will be prefixed
  204. # with 1000, and for 6-digit codes it'll be prefixed with 1. These are placed
  205. # on separate lines.
  206. _PI_REV_CODES = {
  207. RASPBERRY_PI_B_REV1: (
  208. # Regular codes:
  209. '0002', '0003',
  210. # Overvolted/clocked versions:
  211. '1000002', '1000003',
  212. ),
  213. RASPBERRY_PI_B_REV2: (
  214. '0005', '0006', '000d', '000e', '000f',
  215. '1000005', '1000006', '100000d', '100000e', '100000f',
  216. ),
  217. RASPBERRY_PI_B_PLUS: (
  218. '0010', '0013', '900032',
  219. '1000010', '1000013', '1900032',
  220. ),
  221. RASPBERRY_PI_A: (
  222. '0007', '0008', '0009',
  223. '1000007', '1000008', '1000009',
  224. ),
  225. RASPBERRY_PI_A_PLUS: (
  226. '0012', '0015', '900021',
  227. '1000012', '1000015', '1900021',
  228. ),
  229. RASPBERRY_PI_CM1: (
  230. '0011', '0014',
  231. '10000011', '10000014',
  232. ),
  233. RASPBERRY_PI_ZERO: (
  234. '900092', '920092', '900093', '920093',
  235. '1900092', '1920092', '1900093', '1920093', # warranty bit 24
  236. '2900092', '2920092', '2900093', '2920093', # warranty bit 25
  237. ),
  238. RASPBERRY_PI_ZERO_W: (
  239. '9000c1',
  240. '19000c1', '29000c1', # warranty bits
  241. ),
  242. RASPBERRY_PI_2B: (
  243. 'a01040', 'a01041', 'a21041', 'a22042',
  244. '1a01040', '1a01041', '1a21041', '1a22042', # warranty bit 24
  245. '2a01040', '2a01041', '2a21041', '2a22042', # warranty bit 25
  246. ),
  247. RASPBERRY_PI_3B: (
  248. 'a02082', 'a22082', 'a32082', 'a52082',
  249. '1a02082', '1a22082', '1a32082', '1a52082', # warranty bit 24
  250. '2a02082', '2a22082', '2a32082', '2a52082', # warranty bit 25
  251. ),
  252. RASPBERRY_PI_3B_PLUS: (
  253. 'a020d3',
  254. '1a020d3', '2a020d3', # warranty bits
  255. ),
  256. RASPBERRY_PI_CM3: (
  257. 'a020a0', 'a220a0',
  258. '1a020a0', '2a020a0', # warranty bits
  259. '1a220a0', '2a220a0',
  260. ),
  261. RASPBERRY_PI_3A_PLUS: (
  262. '9020e0',
  263. '19020e0', '29020e0', # warranty bits
  264. ),
  265. RASPBERRY_PI_CM3_PLUS: (
  266. 'a02100',
  267. '1a02100', '2a02100', # warranty bits
  268. ),
  269. RASPBERRY_PI_4B: (
  270. 'a03111', 'b03111', 'c03111',
  271. 'a03112', 'b03112', 'c03112',
  272. '1a03111', '2a03111', '1b03111', '2b03111', # warranty bits
  273. '1c03111', '2c03111', '1a03112', '2a03112',
  274. '1b03112', '2b03112', '1c03112', '2c03112',
  275. ),
  276. }
  277. # Onion omega boards
  278. _ONION_OMEGA_BOARD_IDS = (
  279. ONION_OMEGA,
  280. ONION_OMEGA2,
  281. )
  282. # Pine64 boards and devices
  283. _PINE64_DEV_IDS = (
  284. PINE64,
  285. PINEBOOK,
  286. PINEPHONE
  287. )
  288. class Board:
  289. """Attempt to detect specific boards."""
  290. def __init__(self, detector):
  291. self.detector = detector
  292. # pylint: disable=invalid-name, too-many-branches
  293. @property
  294. def id(self):
  295. """Return a unique id for the detected board, if any."""
  296. # There are some times we want to trick the platform detection
  297. # say if a raspberry pi doesn't have the right ID, or for testing
  298. try:
  299. return os.environ['BLINKA_FORCEBOARD']
  300. except KeyError: # no forced board, continue with testing!
  301. pass
  302. chip_id = self.detector.chip.id
  303. board_id = None
  304. if chip_id == ap_chip.BCM2XXX:
  305. board_id = self._pi_id()
  306. elif chip_id == ap_chip.AM33XX:
  307. board_id = self._beaglebone_id()
  308. elif chip_id == ap_chip.GENERIC_X86:
  309. board_id = GENERIC_LINUX_PC
  310. elif chip_id == ap_chip.SUN8I:
  311. board_id = self._armbian_id()
  312. elif chip_id == ap_chip.SAMA5:
  313. board_id = self._sama5_id()
  314. elif chip_id == ap_chip.IMX8MX:
  315. board_id = self._imx8mx_id()
  316. elif chip_id == ap_chip.ESP8266:
  317. board_id = FEATHER_HUZZAH
  318. elif chip_id == ap_chip.SAMD21:
  319. board_id = FEATHER_M0_EXPRESS
  320. elif chip_id == ap_chip.STM32:
  321. board_id = PYBOARD
  322. elif chip_id == ap_chip.S805:
  323. board_id = ODROID_C1
  324. elif chip_id == ap_chip.S905:
  325. board_id = ODROID_C2
  326. elif chip_id == ap_chip.S922X:
  327. board_id = ODROID_N2
  328. elif chip_id == ap_chip.FT232H:
  329. board_id = FTDI_FT232H
  330. elif chip_id == ap_chip.APQ8016:
  331. board_id = DRAGONBOARD_410C
  332. elif chip_id in (ap_chip.T210, ap_chip.T186, ap_chip.T194):
  333. board_id = self._tegra_id()
  334. elif chip_id == ap_chip.HFU540:
  335. board_id = self._sifive_id()
  336. elif chip_id == ap_chip.MCP2221:
  337. board_id = MICROCHIP_MCP2221
  338. elif chip_id == ap_chip.BINHO:
  339. board_id = BINHO_NOVA
  340. elif chip_id == ap_chip.MIPS24KC:
  341. board_id = ONION_OMEGA
  342. elif chip_id == ap_chip.MIPS24KEC:
  343. board_id = ONION_OMEGA2
  344. elif chip_id == ap_chip.A64:
  345. board_id = self._pine64_id()
  346. return board_id
  347. # pylint: enable=invalid-name
  348. def _pi_id(self):
  349. """Try to detect id of a Raspberry Pi."""
  350. # Check for Pi boards:
  351. pi_rev_code = self._pi_rev_code()
  352. if pi_rev_code:
  353. for model, codes in _PI_REV_CODES.items():
  354. if pi_rev_code in codes:
  355. return model
  356. # We may be on a non-Raspbian OS, so try to lazily determine
  357. # the version based on `get_device_model`
  358. else:
  359. pi_model = self.detector.get_device_model()
  360. if pi_model:
  361. pi_model = pi_model.upper().replace(' ', '_')
  362. if "PLUS" in pi_model:
  363. re_model = re.search(r'(RASPBERRY_PI_\d).*([AB]_*)(PLUS)',
  364. pi_model)
  365. elif "CM" in pi_model: # untested for Compute Module
  366. re_model = re.search(r'(RASPBERRY_PI_CM)(\d)',
  367. pi_model)
  368. else: # untested for non-plus models
  369. re_model = re.search(r'(RASPBERRY_PI_\d).*([AB]_*)',
  370. pi_model)
  371. if re_model:
  372. pi_model = "".join(re_model.groups())
  373. available_models = _PI_REV_CODES.keys()
  374. for model in available_models:
  375. if model == pi_model:
  376. return model
  377. return None
  378. def _pi_rev_code(self):
  379. """Attempt to find a Raspberry Pi revision code for this board."""
  380. # 2708 is Pi 1
  381. # 2709 is Pi 2
  382. # 2835 is Pi 3 (or greater) on 4.9.x kernel
  383. # Anything else is not a Pi.
  384. if self.detector.chip.id != ap_chip.BCM2XXX:
  385. # Something else, not a Pi.
  386. return None
  387. return self.detector.get_cpuinfo_field('Revision')
  388. # pylint: disable=no-self-use
  389. def _beaglebone_id(self):
  390. """Try to detect id of a Beaglebone."""
  391. try:
  392. with open("/sys/bus/nvmem/devices/0-00500/nvmem", "rb") as eeprom:
  393. eeprom_bytes = eeprom.read(16)
  394. except FileNotFoundError:
  395. return None
  396. if eeprom_bytes[:4] != b'\xaaU3\xee':
  397. return None
  398. id_string = eeprom_bytes[4:].decode("ascii")
  399. for model, bb_ids in _BEAGLEBONE_BOARD_IDS.items():
  400. for bb_id in bb_ids:
  401. if id_string == bb_id[1]:
  402. return model
  403. return None
  404. # pylint: enable=no-self-use
  405. # pylint: disable=too-many-return-statements
  406. def _armbian_id(self):
  407. """Check whether the current board is an OrangePi PC or OrangePI R1."""
  408. board_value = self.detector.get_armbian_release_field('BOARD')
  409. if board_value == "orangepipc":
  410. return ORANGE_PI_PC
  411. if board_value == "orangepi-r1":
  412. return ORANGE_PI_R1
  413. if board_value == "orangepizero":
  414. return ORANGE_PI_ZERO
  415. if board_value == "orangepione":
  416. return ORANGE_PI_ONE
  417. if board_value == "orangepilite":
  418. return ORANGE_PI_LITE
  419. if board_value == "orangepipcplus":
  420. return ORANGE_PI_PC_PLUS
  421. if board_value == "pinebook-a64":
  422. return PINEBOOK
  423. return None
  424. # pylint: enable=too-many-return-statements
  425. def _sama5_id(self):
  426. """Check what type sama5 board."""
  427. board_value = self.detector.get_device_model()
  428. if "Giant Board" in board_value:
  429. return GIANT_BOARD
  430. return None
  431. def _imx8mx_id(self):
  432. """Check what type iMX8M board."""
  433. board_value = self.detector.get_device_model()
  434. if "Phanbell" in board_value:
  435. return CORAL_EDGE_TPU_DEV
  436. return None
  437. def _tegra_id(self):
  438. """Try to detect the id of aarch64 board."""
  439. board_value = self.detector.get_device_model()
  440. board = None
  441. if 'tx1' in board_value.lower():
  442. board = JETSON_TX1
  443. elif 'quill' in board_value or "storm" in board_value or "lightning" in board_value:
  444. board = JETSON_TX2
  445. elif 'xavier' in board_value.lower() or 'agx' in board_value.lower():
  446. board = JETSON_XAVIER
  447. elif 'nano' in board_value.lower():
  448. board = JETSON_NANO
  449. return board
  450. def _sifive_id(self):
  451. """Try to detect the id for Sifive RISCV64 board."""
  452. board_value = self.detector.get_device_model()
  453. if 'hifive-unleashed-a00' in board_value:
  454. return SIFIVE_UNLEASHED
  455. return None
  456. def _pine64_id(self):
  457. """Try to detect the id for Pine64 board or device."""
  458. board_value = self.detector.get_device_model()
  459. board = None
  460. if 'pine64' in board_value.lower():
  461. board = PINE64
  462. elif 'pinebook' in board_value.lower():
  463. board = PINEBOOK
  464. elif 'pinephone' in board_value.lower():
  465. board = PINEPHONE
  466. return board
  467. @property
  468. def any_96boards(self):
  469. """Check whether the current board is any 96boards board."""
  470. return self.id in _LINARO_96BOARDS_IDS
  471. @property
  472. def any_raspberry_pi(self):
  473. """Check whether the current board is any Raspberry Pi."""
  474. return self._pi_rev_code() is not None
  475. @property
  476. def any_raspberry_pi_40_pin(self):
  477. """Check whether the current board is any 40-pin Raspberry Pi."""
  478. return self.id in _RASPBERRY_PI_40_PIN_IDS
  479. @property
  480. def any_raspberry_pi_cm(self):
  481. """Check whether the current board is any Compute Module Raspberry Pi."""
  482. return self.id in _RASPBERRY_PI_CM_IDS
  483. @property
  484. def any_beaglebone(self):
  485. """Check whether the current board is any Beaglebone-family system."""
  486. return self.id in _BEAGLEBONE_IDS
  487. @property
  488. def any_orange_pi(self):
  489. """Check whether the current board is any defined Orange Pi."""
  490. return self.id in _ORANGE_PI_IDS
  491. @property
  492. def any_coral_board(self):
  493. """Check whether the current board is any defined Coral."""
  494. return self.CORAL_EDGE_TPU_DEV
  495. @property
  496. def any_giant_board(self):
  497. """Check whether the current board is any defined Giant Board."""
  498. return self.GIANT_BOARD
  499. @property
  500. def any_odroid_40_pin(self):
  501. """Check whether the current board is any defined 40-pin Odroid."""
  502. return self.id in _ODROID_40_PIN_IDS
  503. @property
  504. def any_jetson_board(self):
  505. """Check whether the current board is any defined Jetson Board."""
  506. return self.id in _JETSON_IDS
  507. @property
  508. def any_sifive_board(self):
  509. """Check whether the current board is any defined Jetson Board."""
  510. return self.id in _SIFIVE_IDS
  511. @property
  512. def any_onion_omega_board(self):
  513. """Check whether the current board is any defined OpenWRT board."""
  514. return self.id in _ONION_OMEGA_BOARD_IDS
  515. @property
  516. def any_pine64_board(self):
  517. """Check whether the current board is any Pine64 device."""
  518. return self.id in _PINE64_DEV_IDS
  519. @property
  520. def any_embedded_linux(self):
  521. """Check whether the current board is any embedded Linux device."""
  522. return self.any_raspberry_pi or self.any_beaglebone or \
  523. self.any_orange_pi or self.any_giant_board or self.any_jetson_board or \
  524. self.any_coral_board or self.any_odroid_40_pin or self.any_96boards or \
  525. self.any_sifive_board or self.any_onion_omega_board or self.any_pine64_board
  526. @property
  527. def ftdi_ft232h(self):
  528. """Check whether the current board is an FTDI FT232H."""
  529. return self.id == FTDI_FT232H
  530. @property
  531. def microchip_mcp2221(self):
  532. """Check whether the current board is a Microchip MCP2221."""
  533. return self.id == MICROCHIP_MCP2221
  534. @property
  535. def binho_nova(self):
  536. """Check whether the current board is an BINHO NOVA."""
  537. return self.id == BINHO_NOVA
  538. def __getattr__(self, attr):
  539. """
  540. Detect whether the given attribute is the currently-detected board. See list
  541. of constants at the top of this module for available options.
  542. """
  543. if self.id == attr:
  544. return True
  545. return False