-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathxenium-programmer-pi
executable file
·131 lines (109 loc) · 4.61 KB
/
xenium-programmer-pi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/python3
# Python wrapper for Xenium programming using Pi-ZeroW PC-Board
#
# Copyright (C) 2019 Koos du Preez ([email protected])
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import os
import subprocess
import RPi.GPIO as GPIO
import time
print("▒██ ██▒▓█████ ███▄ █ ██▓ █ ██ ███▄ ▄███▓")
print("▒▒ █ █ ▒░▓█ ▀ ██ ▀█ █ ▓██▒ ██ ▓██▒▓██▒▀█▀ ██▒")
print("░░ █ ░▒███ ▓██ ▀█ ██▒▒██▒▓██ ▒██░▓██ ▓██░")
print(" ░ █ █ ▒ ▒▓█ ▄ ▓██▒ ▐▌██▒░██░▓▓█ ░██░▒██ ▒██ ")
print("▒██▒ ▒██▒░▒████▒▒██░ ▓██░░██░▒▒█████▓ ▒██▒ ░██▒")
print("▒▒ ░ ░▓ ░░░ ▒░ ░░ ▒░ ▒ ▒ ░▓ ░▒▓▒ ▒ ▒ ░ ▒░ ░ ░")
print("░░ ░▒ ░ ░ ░ ░░ ░░ ░ ▒░ ▒ ░░░▒Programmer░ ░")
print(" ░ ░ ░ ░ ░ ░ ▒kooscode@github ░ ")
print(" ░ ░ ░ ░ ░ ░ ░ ░ ", flush=True)
# git root folder.
programmer_root = os.getcwd()
# Commands
cmd_jtag = os.path.join(programmer_root, "xenium-flash/bin/xenium-jtag")
cmd_jflash = os.path.join(programmer_root, "xenium-flash/bin/xenium-flash")
# Data Files
flash_jed = os.path.join(programmer_root, "xenium-bin/xeniumflash.jed")
xenium_os = os.path.join(programmer_root, "xenium-bin/xenium_blue.bin")
xenium_jed= os.path.join(programmer_root, "xenium-bin/openxenium.jed")
# LED Pins
led1 = 19
led2 = 6
led3 = 7
def set_ok():
GPIO.output(led1, GPIO.HIGH)
GPIO.output(led2, GPIO.LOW)
GPIO.output(led3, GPIO.LOW)
def set_busy():
GPIO.output(led1, GPIO.LOW)
GPIO.output(led2, GPIO.HIGH)
GPIO.output(led3, GPIO.LOW)
def set_error():
GPIO.output(led1, GPIO.LOW)
GPIO.output(led2, GPIO.LOW)
GPIO.output(led3, GPIO.HIGH)
def set_init():
GPIO.output(led1, GPIO.HIGH)
time.sleep(0.1)
GPIO.output(led2, GPIO.HIGH)
time.sleep(0.1)
GPIO.output(led3, GPIO.HIGH)
time.sleep(0.1)
#using Broadcom pin numbering.
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
#setup pin as output
GPIO.setup(led1, GPIO.OUT)
GPIO.setup(led2, GPIO.OUT)
GPIO.setup(led3, GPIO.OUT)
set_init()
# Program CPLD with BitBus Flash Writer code.
set_busy()
print("-------------------------------------")
print("PROGRAMMING XILINX CPLD: BITBUS BRIDGE")
print("--------------------------------------", flush=True)
sub_proc = subprocess.run([cmd_jtag, flash_jed])
if sub_proc.returncode == 0:
set_ok()
# Write OpenXenium OS to Flash Chip
set_busy()
print("-----------------------------")
print("PROGRAMMING FLASH : XENIUM OS")
print("-----------------------------", flush=True)
sub_proc = subprocess.run([cmd_jflash, xenium_os, "-y"])
if sub_proc.returncode == 0:
set_ok()
set_busy()
# Program CPLD with OpenXenium Firmware.
print("---------------------------------------------")
print("PROGRAMMING XILINX CPLD: OPEN XENIUM FIRMWARE")
print("---------------------------------------------", flush=True)
sub_proc = subprocess.run([cmd_jtag, xenium_jed])
if sub_proc.returncode == 0:
set_ok()
else:
print("ERROR Programming the Xilinx CPLD!")
print("Please double check your JTAG connection and wires!", flush=True)
set_error()
else:
set_error()
print("ERROR Loading XeniumOS into OpenXenium Flash memory!")
print("Please double check your LPC Header connection and wires!", flush=True)
else:
set_error()
print("ERROR Programming the Xilinx CPLD!")
print("Please double check your JTAG connection and wires!", flush=True)
# # cleanup GPIO
# GPIO.cleanup()