Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
Conv TTL Blocking
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
5
Issues
5
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Conv TTL Blocking
Commits
c4f821f6
Commit
c4f821f6
authored
Oct 23, 2014
by
Theodor-Adrian Stana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sw: Removed read flash script, this will be part of multiboot script
parent
b6c633a6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
149 deletions
+0
-149
readflash.py
software/multiboot/readflash.py
+0
-149
No files found.
software/multiboot/readflash.py
deleted
100755 → 0
View file @
b6c633a6
#!/usr/bin/python
#===============================================================================
# CERN (BE-CO-HT)
# Read the converter board flash via MultiBoot logic
#===============================================================================
# author: Theodor Stana (t.stana@cern.ch)
#
# date of creation:
#
# version: 1.0
#
# description:
# This script uses the wb_xil_multiboot module implemented inside a converter
# board FPGA to read the contents of the on-board flash between two addresses
# choosed by the user.
#
#===============================================================================
# GNU LESSER GENERAL PUBLIC LICENSE
#===============================================================================
# This source file is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by the
# Free Software Foundation; either version 2.1 of the License, or (at your
# option) any later version. This source 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 Lesser General Public License for more details. You should have
# received a copy of the GNU Lesser General Public License along with this
# source; if not, download it from http://www.gnu.org/licenses/lgpl-2.1.html
#===============================================================================
# last changes:
#===============================================================================
# TODO: -
#===============================================================================
import
sys
sys
.
path
.
append
(
"../ei2c"
)
from
ei2c
import
*
import
ei2cdefine
MB_BASE
=
0x100
MB_CR_OFS
=
0x00
MB_SR_OFS
=
0x04
MB_GBBAR_OFS
=
0x08
MB_MBBAR_OFS
=
0x0C
MB_FAR_OFS
=
0x10
def
spi_transfer
(
nbytes
,
cs
,
dat
):
retval
=
0
wval
=
[]
# control byte, to be shifted left by 24
ctrl
=
((
cs
<<
3
)
|
0x4
)
|
(
nbytes
-
1
)
# Use appropriate command by type
#
# write - we send up to three data bytes in one FAR register write
# writemregs - we send up to 24 data bytes in eight FAR register writes
if
isinstance
(
dat
,
int
):
testelma
.
write
(
slot
,
MB_BASE
+
MB_FAR_OFS
,
(
ctrl
<<
24
)
|
dat
)
else
:
for
i
in
xrange
(
len
(
dat
)):
wval
.
append
((
ctrl
<<
24
)
|
dat
[
i
])
testelma
.
writemregs
(
slot
,
MB_BASE
+
MB_FAR_OFS
,
wval
)
# Read the data and prepare the return value
while
(
retval
&
(
1
<<
28
)
==
0
):
retval
=
testelma
.
read
(
slot
,
MB_BASE
+
MB_FAR_OFS
)
return
retval
&
0xFFFFFF
def
flash_read
(
addr
,
nrbytes
):
ret
=
[]
spi_transfer
(
1
,
1
,
0x0b
)
# send address in reverse order
addr
=
((
addr
&
0xff0000
)
>>
16
)
|
(((
addr
&
0xff00
)
>>
8
)
<<
8
)
|
((
addr
&
0xff
)
<<
16
)
spi_transfer
(
3
,
1
,
addr
)
spi_transfer
(
1
,
1
,
0
)
# Read bytes in groups of three
for
i
in
range
(
nrbytes
):
ret
.
append
(
spi_transfer
(
1
,
1
,
0
))
spi_transfer
(
1
,
0
,
0
)
return
ret
if
__name__
==
"__main__"
:
# Get the IP, user and password for the ELMA crate from ei2cdefine.py
ip
=
ei2cdefine
.
HNAME
user
=
ei2cdefine
.
USER
pwd
=
ei2cdefine
.
PWD
testelma
=
EI2C
(
ip
,
user
,
pwd
)
testelma
.
open
()
# Ask for slot number
while
1
:
try
:
slot
=
raw_input
(
"Slot no.: "
)
slot
=
int
(
slot
)
break
except
TypeError
as
e
:
print
(
"Please input a decimal slot number."
)
except
SlotError
as
e
:
print
(
e
.
strerror
)
except
KeyboardInterrupt
:
sys
.
exit
();
except
:
print
(
"Unexpected error: "
,
sys
.
exc_info
()[
0
])
# Get start address
while
1
:
try
:
sa
=
int
(
raw_input
(
"Start address : 0x"
),
16
)
break
except
ValueError
as
e
:
print
(
"Please input a hexadecimal address!"
)
except
KeyboardInterrupt
:
print
(
"KeyboardInterrupt"
)
sys
.
exit
()
except
:
print
(
"Unexpected error: "
,
sys
.
exc_info
()[
0
])
# Get end address
while
1
:
try
:
ea
=
int
(
raw_input
(
"End address : 0x"
),
16
)
break
except
ValueError
as
e
:
print
(
"Please input a hexadecimal address!"
)
except
KeyboardInterrupt
:
print
(
"KeyboardInterrupt"
)
sys
.
exit
()
except
:
print
(
"Unexpected error: "
,
sys
.
exc_info
()[
0
])
# Start reading
dat
=
[]
for
i
in
range
(
sa
,
ea
,
256
):
dat
+=
flash_read
(
i
,
256
)
print
(
"0x
%06
x"
%
i
)
dat
=
''
.
join
(
map
(
chr
,
dat
))
f
=
open
(
"flash.bin"
,
"wb"
)
f
.
write
(
dat
)
f
.
close
()
testelma
.
close
()
print
(
"DONE!"
)
print
(
"Output stored to flash.bin"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment