-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A bug of MemTool in GUI that can be fixed (and some script engine issues) #23
Comments
Another interesting problem: a script file saved by the text editor in Linux (Unix LF) cannot be executed correctly by the script engine on Windows. I don't know how to fix it in function |
both linux and windows line returns are supported. I think that this is more an utf8 compatibility issue. |
Important note: why don't warn people about the read/write size limitation determined by I found a problem in the script engine: However, I'm unfamiliar with the structure of this project (written in C89 style, lacking documentation), and decided not to patch it by myself. I switched to I'm trying to execute custom commands for the flash memory (vendor-specific features / hidden sector, TopJTAG Flash can't do it) through 2 devices in the JTAG chain. Here's my test script merely reading Flash CFI information (by single JTAG device), but it doesn't work correctly because of the behavior described above. PS: when the script below is saved in Unix LF mode, the executor (on Windows) reports something like
|
from jtagbs import jtagbs
from jtagbs.viveris import jtagcore
# Memory read/write procedures were translated from `memoryoverjtag.c` in libjtagcore
# Requires `jtag`, `device`, `addr_pins`, `data_pins`, `cs_pin`, `we_pin`, `oe_pin`
def mem_write(addr, data):
par_set_data(device, addr_pins, addr)
par_set_data(device, data_pins, data) # sets OE for data pins
# assumes all control signals are disabled here (Output 1)
jtag.scan()
device.set_pin_state(cs_pin, 0) # enable CS
device.set_pin_state(we_pin, 0) # enable WE
jtag.scan()
device.set_pin_state(we_pin, 1) # disable WE
jtag.scan()
device.set_pin_state(cs_pin, 1) # disable CS
par_reset_oe(device, data_pins)
jtag.scan()
# Requires `jtag`, `device`, `addr_pins`, `data_pins`, `cs_pin`, `we_pin`, `oe_pin`
def mem_read(addr):
par_set_data(device, addr_pins, addr)
par_reset_oe(device, data_pins)
# assumes all control signals are disabled here (Output 1)
jtag.scan()
device.set_pin_state(cs_pin, 0) # enable CS
jtag.scan()
device.set_pin_state(oe_pin, 0) # enable OE
jtag.scan()
jtag.scan()
data = par_get_data(device, data_pins)
device.set_pin_state(oe_pin, 1) # disable OE
device.set_pin_state(cs_pin, 1) # disable CS
jtag.scan()
return data
def par_get_data(device, pins):
pin_states = device.get_pin_state(pins)
data = 0
for i, val in enumerate(pin_states):
data += (val << i)
return data
def par_set_data(device, pins, data):
new_states = []
for i in range(len(pins)):
new_states.append((data >> i) & 1) # 1 => True, 0 => False
device.set_pin_state(pins, new_states) # sets OE for pins
def par_reset_oe(device, pins):
device.set_pin_state(pins, list(None for i in range(len(pins)))) # disables OE
# main --------------------------------------------------------------
if __name__ == '__main__':
interface = jtagcore.JTAGCore()
jtag = jtagbs.JTAGBS(interface)
probes = jtag.list_available_probes()
jtag.open_probe('JLINK')
jtag.init_scanchain()
devices = jtag.list_devices()
for i, dev in enumerate(devices):
print("Device {} is from {}".format(i, dev['manufacturer']))
pxa255 = jtag.get_device(0)
pxa255.set_bsdl(r"../bsdl_files/pxa255.bsd")
addr_pins = ['ma(1)', 'ma(2)', 'ma(3)', 'ma(4)', 'ma(5)', \
'ma(6)', 'ma(7)', 'ma(8)', 'ma(9)', 'ma(10)', \
'ma(11)', 'ma(12)', 'ma(13)', 'ma(14)', 'ma(15)', \
'ma(16)', 'ma(17)', 'ma(18)', 'ma(19)', 'ma(20)', 'ma(21)']
data_pins = ['md(0)', 'md(1)', 'md(2)', 'md(3)', 'md(4)', 'md(5)', 'md(6)', 'md(7)', \
'md(8)', 'md(9)', 'md(10)', 'md(11)', 'md(12)', 'md(13)', 'md(14)', 'md(15)']
cs_pin, we_pin, oe_pin = ('ncs_0', 'nwe', 'noe')
pxa255.set_scan_mode('active') # EXTEST
pxa255.autoscan = False # call `JTAGBS.scan()` to update inputs and outputs
device = pxa255
# sets OE for control pins, disables control siginals
pxa255.set_pin_state([cs_pin, we_pin, oe_pin], [True, True, True])
jtag.scan()
mem_write(0x55, 0x0098)
cfi_data = bytearray()
for i in range(0x10, 0x4C + 1):
word_read = mem_read(i)
cfi_data.append(word_read & 0xff)
print(cfi_data) |
Fixed in the v2.6.6.1
This is the script max length per line, currently set to 1024. Can you tell which use case need more than this ?
This is fixed in the v2.6.6.1. The issue was related to the use of "atoi" function to convert numbers while the internal string numbers are in hexadecimal.
I still suspect an utf8 compatibility issue. Can you share the script file ? |
Thanks for fixing both bugs. And I realized that I had got something wrong: variables are handled by My script usage is already posted here, but I have already switched to
|
Please fix the problem that prevents MemTool from handling the external memory chip connected to a device that have an non-zero index in the current JTAG chain:
https://github.com/viveris/jtag-boundary-scanner/blob/d2b44e81b3eaaa18b899af9c9f631dd70dce9d67/jtag_boundary_scanner_gui/win32/JTAGBoundaryScanner.c
In
JTAGBoundaryScanner.c
,set_mem_pins()
, at lines 1974 and 2005, changeto
However, the GUI is still incapable of controlling a flash memory through 2 devices in the JTAG chain.
The text was updated successfully, but these errors were encountered: