Skip to content

Commit bfc2691

Browse files
authored
Merge pull request #67 from pmundt/xilinx-pynq
Add support for Xilinx PYNQ dev boards (Z1 and Z2)
2 parents c93449d + ed5313c commit bfc2691

File tree

5 files changed

+42
-0
lines changed

5 files changed

+42
-0
lines changed

adafruit_platformdetect/board.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ def id(self):
6767
board_id = boards.ONION_OMEGA
6868
elif chip_id == chips.MIPS24KEC:
6969
board_id = boards.ONION_OMEGA2
70+
elif chip_id == chips.ZYNQ7000:
71+
board_id = self._pynq_id()
7072
elif chip_id == chips.A64:
7173
board_id = self._pine64_id()
7274
return board_id
@@ -232,6 +234,22 @@ def _pine64_id(self):
232234
board = boards.PINEPHONE
233235
return board
234236

237+
# pylint: disable=no-self-use
238+
def _pynq_id(self):
239+
"""Try to detect the id for Xilinx PYNQ boards."""
240+
try:
241+
with open("/proc/device-tree/chosen/pynq_board", "r") as board_file:
242+
board_model = board_file.read()
243+
match = board_model.upper().replace('-', '_').rstrip('\x00')
244+
for model in boards._PYNQ_IDS:
245+
if model == match:
246+
return model
247+
248+
return None
249+
250+
except FileNotFoundError:
251+
return None
252+
235253
@property
236254
def any_96boards(self):
237255
"""Check whether the current board is any 96boards board."""
@@ -267,6 +285,11 @@ def any_coral_board(self):
267285
"""Check whether the current board is any defined Coral."""
268286
return self.CORAL_EDGE_TPU_DEV
269287

288+
@property
289+
def any_pynq_board(self):
290+
"""Check whether the current board is any defined PYNQ Board."""
291+
return self.id in boards._PYNQ_IDS
292+
270293
@property
271294
def any_giant_board(self):
272295
"""Check whether the current board is any defined Giant Board."""
@@ -306,6 +329,7 @@ def any_embedded_linux(self):
306329
self.any_giant_board, self.any_jetson_board, self.any_coral_board,
307330
self.any_odroid_40_pin, self.any_96boards, self.any_sifive_board,
308331
self.any_onion_omega_board, self.any_pine64_board,
332+
self.any_pynq_board,
309333
]
310334
)
311335

adafruit_platformdetect/chip.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ def _linux_id(self): # pylint: disable=too-many-branches,too-many-statements
121121
linux_id = chips.A64
122122
elif "sun50iw1p1" in hardware:
123123
linux_id = chips.A64
124+
elif "Xilinx Zynq" in hardware:
125+
compatible = self.detector.get_device_compatible()
126+
if compatible and 'xlnx,zynq-7000' in compatible:
127+
linux_id = chips.ZYNQ7000
124128
else:
125129
if isinstance(hardware, str):
126130
if hardware.upper() in chips.BCM_RANGE:

adafruit_platformdetect/constants/boards.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
# Google Coral dev board
4444
CORAL_EDGE_TPU_DEV = "CORAL_EDGE_TPU_DEV"
4545

46+
# Xilinx PYNQ FPGA dev boards
47+
PYNQ_Z1 = "PYNQ_Z1"
48+
PYNQ_Z2 = "PYNQ_Z2"
49+
4650
# Various Raspberry Pi models
4751
RASPBERRY_PI_B_REV1 = "RASPBERRY_PI_B_REV1"
4852
RASPBERRY_PI_B_REV2 = "RASPBERRY_PI_B_REV2"
@@ -98,6 +102,11 @@
98102
CORAL_EDGE_TPU_DEV,
99103
)
100104

105+
_PYNQ_IDS = (
106+
PYNQ_Z1,
107+
PYNQ_Z2,
108+
)
109+
101110
_JETSON_IDS = {
102111
JETSON_TX1: (
103112
'nvidia,p2371-2180',

adafruit_platformdetect/constants/chips.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
BINHO = "BINHO"
2222
MIPS24KC = "MIPS24KC"
2323
MIPS24KEC = "MIPS24KEC"
24+
ZYNQ7000 = "ZYNQ7000"
2425
A64 = "A64"
2526

2627
BCM_RANGE = {'BCM2708', 'BCM2709', 'BCM2711', 'BCM2835', 'BCM2837'}

bin/detect.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
print("Is this a Giant Board?", detector.board.GIANT_BOARD)
1919
print("Is this a Coral Edge TPU?", detector.board.CORAL_EDGE_TPU_DEV)
2020
print("Is this a SiFive Unleashed? ", detector.board.SIFIVE_UNLEASHED)
21+
print("Is this a PYNQ Board?", detector.board.PYNQ_Z1 | detector.board.PYNQ_Z2)
2122
print("Is this an embedded Linux system?", detector.board.any_embedded_linux)
2223
print("Is this a generic Linux PC?", detector.board.GENERIC_LINUX_PC)
2324
print("Is this an OS environment variable special case?", detector.board.FTDI_FT232H |
@@ -29,6 +30,9 @@
2930
if detector.board.any_jetson_board:
3031
print("Jetson platform detected.")
3132

33+
if detector.board.any_pynq_board:
34+
print("PYNQ platform detected.")
35+
3236
if detector.board.any_orange_pi:
3337
print("Orange Pi detected.")
3438

0 commit comments

Comments
 (0)