-
Notifications
You must be signed in to change notification settings - Fork 2
/
PromOS-programmer-smd
189 lines (161 loc) · 6.27 KB
/
PromOS-programmer-smd
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#!/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-smd")
cmd_jverify = os.path.join(programmer_root, "xenium-flash/bin/xenium-verify-smd")
# Data Files
flash_jed = os.path.join(programmer_root, "xenium-bin/xeniumflash.jed")
xenium_os = os.path.join(programmer_root, "xenium-bin/promOS.bin")
xenium_jed= os.path.join(programmer_root, "xenium-bin/openxenium.jed")
# LED Pins
led1 = 19
led2 = 6
led3 = 7
S1led = 10
S2led = 9
S3led = 11
S4led = 26
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 S1():
GPIO.output(S1led, GPIO.HIGH)
GPIO.output(S2led, GPIO.LOW)
GPIO.output(S3led, GPIO.LOW)
GPIO.output(S4led, GPIO.LOW)
def S2():
GPIO.output(S1led, GPIO.LOW)
GPIO.output(S2led, GPIO.HIGH)
GPIO.output(S3led, GPIO.LOW)
GPIO.output(S4led, GPIO.LOW)
def S3():
GPIO.output(S1led, GPIO.LOW)
GPIO.output(S2led, GPIO.LOW)
GPIO.output(S3led, GPIO.HIGH)
GPIO.output(S4led, GPIO.LOW)
def S4():
GPIO.output(S1led, GPIO.LOW)
GPIO.output(S2led, GPIO.LOW)
GPIO.output(S3led, GPIO.LOW)
GPIO.output(S4led, 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)
GPIO.output(S1led, GPIO.HIGH)
time.sleep(0.1)
GPIO.output(S2led, GPIO.HIGH)
time.sleep(0.1)
GPIO.output(S3led, GPIO.HIGH)
time.sleep(0.1)
GPIO.output(S4led, 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)
GPIO.setup(S1led, GPIO.OUT)
GPIO.setup(S2led, GPIO.OUT)
GPIO.setup(S3led, GPIO.OUT)
GPIO.setup(S4led, GPIO.OUT)
set_init()
# Program CPLD with BitBus Flash Writer code.
set_busy()
S1()
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()
S2()
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()
S3()
# Verify OpenXenium OS on Flash Chip
print("---------------------------")
print("VERIFYING FLASH: XENIUM OS")
print("---------------------------", flush=True)
sub_proc = subprocess.run([cmd_jverify, xenium_os, "-y"])
if sub_proc.returncode == 0:
set_ok()
set_busy()
S4()
# 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()
GPIO.output(S4led, GPIO.LOW)
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 Verifying XeniumOS on OpenXenium Flash memory!")
print("Please double check your LPC Header connection and wires!", flush=True)
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)