Skip to content
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

Add some new decoders from sigrok #539

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
8bc228e
Add decoder for cJTAG from sigrok
abougouffa Aug 8, 2022
93d7e09
Add SBUS (Futaba) decoder from sigrok
abougouffa Aug 8, 2022
625e614
Update ADE77xx decoder
abougouffa Aug 8, 2022
882369c
Update ADF435x decoder
abougouffa Aug 8, 2022
f548966
Update ANDS5020 decoder
abougouffa Aug 8, 2022
c654ed0
Update AM230x decoder
abougouffa Aug 8, 2022
5a5476e
Update ARM ITM decoder
abougouffa Aug 8, 2022
1e944be
Update ADx1345 decoder
abougouffa Aug 8, 2022
c765215
Update ARM ETMv3 decoder
abougouffa Aug 8, 2022
e244c18
Update ARM TPIU decoder
abougouffa Aug 8, 2022
c2ed14e
Update AVR ISP decoder
abougouffa Aug 8, 2022
9fd93d5
Update Caliper decoder
abougouffa Aug 8, 2022
451790e
Update CAN decoder (now supports CAN-FD)
abougouffa Aug 8, 2022
691401c
Update CC1101 decoder
abougouffa Aug 8, 2022
369f8c2
Update Dali decoder
abougouffa Aug 8, 2022
79a1bb5
Update DCF77 decoder
abougouffa Aug 8, 2022
50ac697
Update DMx512 decoder
abougouffa Aug 8, 2022
2871e02
Update DS1307 decoder
abougouffa Aug 8, 2022
e16012a
Update DS2408 decoder
abougouffa Aug 8, 2022
391dcb7
Update DS243x decoder
abougouffa Aug 8, 2022
17abc96
Update DS28EA00 decoder
abougouffa Aug 8, 2022
e27ab19
Update DSI decoder
abougouffa Aug 8, 2022
d27025e
Update EDID decoder
abougouffa Aug 8, 2022
79dd966
Update EEPROM24xx decoder
abougouffa Aug 8, 2022
e5d9b5a
Update EEPROM93xx decoder
abougouffa Aug 8, 2022
12205ae
Update ENC28J60 decoder
abougouffa Aug 8, 2022
09cf6d7
Update FlexRay decoder
abougouffa Aug 8, 2022
b47fa89
Update I2C filter decoder
abougouffa Aug 8, 2022
0c38af0
Update IEEE488 decoder
abougouffa Aug 8, 2022
7c9a11f
Update Gray Code decoder
abougouffa Aug 8, 2022
6d9661f
Update IR IRMP decoder
abougouffa Aug 8, 2022
acd5f6c
Update IR NEC decoder
abougouffa Aug 8, 2022
2dd49d2
Update IR RC5 decoder
abougouffa Aug 8, 2022
23c424c
Update IR RC6 decoder
abougouffa Aug 8, 2022
73d5188
Update Jitter decoder
abougouffa Aug 8, 2022
a01127c
Update JTAG EJTAG decoder
abougouffa Aug 8, 2022
f5fa68c
Update LFast decoder
abougouffa Aug 8, 2022
4c1d709
Update LIN decoder
abougouffa Aug 8, 2022
f826edb
Update LM75 decoder
abougouffa Aug 8, 2022
3921a7b
Update MAPLE Bus decoder
abougouffa Aug 8, 2022
8aaaa42
Update MAX7219 decoder
abougouffa Aug 8, 2022
9adb126
Update MCS48 decoder
abougouffa Aug 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions libsigrokdecode4DSL/decoders/ade77xx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
## 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
## along with this program; if not, see <http://www.gnu.org/licenses/>.
##

'''
Expand Down
14 changes: 7 additions & 7 deletions libsigrokdecode4DSL/decoders/ade77xx/pd.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ class Decoder(srd.Decoder):
outputs = []
tags = ['Analog/digital', 'IC', 'Sensor']
annotations = (
('read', 'Register read commands'),
('write', 'Register write commands'),
('warning', 'Warnings'),
('read', 'Register read'),
('write', 'Register write'),
('warning', 'Warning'),
)
annotation_rows = (
('read', 'Read', (0,)),
('write', 'Write', (1,)),
('reads', 'Reads', (0,)),
('writes', 'Writes', (1,)),
('warnings', 'Warnings', (2,)),
)

Expand Down Expand Up @@ -124,8 +124,8 @@ def decode(self, ss, es, data):
vali = self.miso_bytes[1]

if write:
self.putx([1, ['%s: {$}' % rblob[0], '@%02X' % valo]])
self.putx([1, ['%s: %#x' % (rblob[0], valo)]])
else:
self.putx([0, ['%s: {$}' % rblob[0], '@%02X' % valo]])
self.putx([0, ['%s: %#x' % (rblob[0], vali)]])

self.reset_data()
4 changes: 2 additions & 2 deletions libsigrokdecode4DSL/decoders/adf435x/pd.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ class Decoder(srd.Decoder):
tags = ['Clock/timing', 'IC', 'Wireless/RF']
annotations = (
# Sent from the host to the chip.
('register', 'Register written to the device'),
('write', 'Register write'),
)
annotation_rows = (
('registers', 'Register writes', (ANN_REG,)),
('writes', 'Register writes', (ANN_REG,)),
)

def __init__(self):
Expand Down
15 changes: 7 additions & 8 deletions libsigrokdecode4DSL/decoders/adns5020/pd.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ class Decoder(srd.Decoder):
outputs = []
tags = ['IC', 'PC', 'Sensor']
annotations = (
('read', 'Register read commands'),
('write', 'Register write commands'),
('warning', 'Warnings'),
('read', 'Register read'),
('write', 'Register write'),
('warning', 'Warning'),
)
annotation_rows = (
('read', 'Read', (0,)),
('write', 'Write', (1,)),
('reads', 'Reads', (0,)),
('writes', 'Writes', (1,)),
('warnings', 'Warnings', (2,)),
)

Expand Down Expand Up @@ -108,10 +108,9 @@ def decode(self, ss, es, data):
reg_desc = regs.get(reg, 'Reserved %#x' % reg)
if reg > 0x63:
reg_desc = 'Unknown'

if write:
self.putx([1, ['%s: {$}' % reg_desc, '@%02X' % arg]])
self.putx([1, ['%s: %#x' % (reg_desc, arg)]])
else:
self.putx([0, ['%s: {$}' % reg_desc, '@%02X' % arg]])
self.putx([0, ['%s: %d' % (reg_desc, arg)]])

self.mosi_bytes = []
3 changes: 2 additions & 1 deletion libsigrokdecode4DSL/decoders/adxl345/pd.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,8 @@ def decode(self, ss, es, data):
self.address <<= 1
self.address >>= 1
self.put(start_sample, addr_bit[2], self.out_ann,
[Ann.REG_ADDRESS, ['ADDRESS: {$}', 'ADDR: {$}', '{$}', '@%02X' % self.address]])
[Ann.REG_ADDRESS, ['ADDRESS: 0x%02X' % self.address, 'ADDR: 0x%02X'
% self.address, '0x%02X' % self.address]])
self.ss = -1
self.state = St.DATA

Expand Down
4 changes: 2 additions & 2 deletions libsigrokdecode4DSL/decoders/am230x/pd.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class Decoder(srd.Decoder):
('bit', 'Bit'),
('end', 'End'),
('byte', 'Byte'),
('humidity', 'Relative humidity in percent'),
('temperature', 'Temperature in degrees Celsius'),
('humidity', 'Relative humidity'),
('temperature', 'Temperature'),
('checksum', 'Checksum'),
)
annotation_rows = (
Expand Down
22 changes: 11 additions & 11 deletions libsigrokdecode4DSL/decoders/arm_etmv3/pd.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,26 +138,26 @@ class Decoder(srd.Decoder):
tags = ['Debug/trace']
annotations = (
('trace', 'Trace info'),
('branch', 'Branches'),
('exception', 'Exceptions'),
('branch', 'Branch'),
('exception', 'Exception'),
('execution', 'Instruction execution'),
('data', 'Data access'),
('pc', 'Program counter'),
('instr_e', 'Executed instructions'),
('instr_n', 'Not executed instructions'),
('instr_e', 'Executed instruction'),
('instr_n', 'Not executed instruction'),
('source', 'Source code'),
('location', 'Current location'),
('function', 'Current function'),
)
annotation_rows = (
('trace', 'Trace info', (0,)),
('traces', 'Trace info', (0,)),
('flow', 'Code flow', (1, 2, 3,)),
('data', 'Data access', (4,)),
('pc', 'Program counter', (5,)),
('instruction', 'Instructions', (6, 7,)),
('source', 'Source code', (8,)),
('location', 'Current location', (9,)),
('function', 'Current function', (10,)),
('data-vals', 'Data access', (4,)),
('pc-vals', 'Program counters', (5,)),
('instructions', 'Instructions', (6, 7,)),
('sources', 'Source code', (8,)),
('locations', 'Current locations', (9,)),
('functions', 'Current functions', (10,)),
)
options = (
{'id': 'objdump', 'desc': 'objdump path',
Expand Down
20 changes: 10 additions & 10 deletions libsigrokdecode4DSL/decoders/arm_itm/pd.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Decoder(srd.Decoder):
'default': ''},
)
annotations = (
('trace', 'Trace information'),
('trace', 'Trace info'),
('timestamp', 'Timestamp'),
('software', 'Software message'),
('dwt_event', 'DWT event'),
Expand All @@ -69,15 +69,15 @@ class Decoder(srd.Decoder):
('function', 'Current function'),
)
annotation_rows = (
('trace', 'Trace information', (0, 1)),
('software', 'Software trace', (2,)),
('dwt_event', 'DWT event', (3,)),
('dwt_watchpoint', 'DWT watchpoint', (4,)),
('dwt_exc', 'Exception trace', (5,)),
('dwt_pc', 'Program counter', (6,)),
('mode', 'Current mode', (7, 8, 9)),
('location', 'Current location', (10,)),
('function', 'Current function', (11,)),
('traces', 'Trace info', (0, 1)),
('softwares', 'Software traces', (2,)),
('dwt_events', 'DWT events', (3,)),
('dwt_watchpoints', 'DWT watchpoints', (4,)),
('dwt_excs', 'Exception traces', (5,)),
('dwt_pcs', 'Program counters', (6,)),
('modes', 'Current modes', (7, 8, 9)),
('locations', 'Current locations', (10,)),
('functions', 'Current functions', (11,)),
)

def __init__(self):
Expand Down
4 changes: 2 additions & 2 deletions libsigrokdecode4DSL/decoders/arm_tpiu/pd.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class Decoder(srd.Decoder):
('data', 'Stream data'),
)
annotation_rows = (
('stream', 'Current stream', (0,)),
('data', 'Stream data', (1,)),
('streams', 'Current streams', (0,)),
('data-vals', 'Stream data', (1,)),
)

def __init__(self):
Expand Down
104 changes: 83 additions & 21 deletions libsigrokdecode4DSL/decoders/avr_isp/pd.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
import sigrokdecode as srd
from .parts import *

class Ann:
PE, RSB0, RSB1, RSB2, CE, RFB, RHFB, REFB, \
RLB, REEM, RP, LPMP, WP, WARN, DEV, = range(15)

VENDOR_CODE_ATMEL = 0x1e

class Decoder(srd.Decoder):
Expand All @@ -41,14 +45,20 @@ class Decoder(srd.Decoder):
('rfb', 'Read fuse bits'),
('rhfb', 'Read high fuse bits'),
('refb', 'Read extended fuse bits'),
('warnings', 'Warnings'),
('rlb', 'Read lock bits'),
('reem', 'Read EEPROM memory'),
('rp', 'Read program memory'),
('lpmp' , 'Load program memory page'),
('wp', 'Write program memory'),
('warning', 'Warning'),
('dev', 'Device'),
)
annotation_rows = (
('bits', 'Bits', ()),
('commands', 'Commands', tuple(range(7 + 1))),
('warnings', 'Warnings', (8,)),
('dev', 'Device', (9,)),
('commands', 'Commands', (Ann.PE, Ann.RSB0, Ann.RSB1, Ann.RSB2,
Ann.CE, Ann.RFB, Ann.RHFB, Ann.REFB,
Ann.RLB, Ann.REEM, Ann.RP, Ann.LPMP, Ann.WP,)),
('warnings', 'Warnings', (Ann.WARN,)),
('devs', 'Devices', (Ann.DEV,)),
)

def __init__(self):
Expand All @@ -70,17 +80,17 @@ def putx(self, data):
def handle_cmd_programming_enable(self, cmd, ret):
# Programming enable.
# Note: The chip doesn't send any ACK for 'Programming enable'.
self.putx([0, ['Programming enable']])
self.putx([Ann.PE, ['Programming enable']])

# Sanity check on reply.
if ret[1:4] != [0xac, 0x53, cmd[2]]:
self.putx([8, ['Warning: Unexpected bytes in reply!']])
self.putx([Ann.WARN, ['Warning: Unexpected bytes in reply!']])

def handle_cmd_read_signature_byte_0x00(self, cmd, ret):
# Signature byte 0x00: vendor code.
self.vendor_code = ret[3]
v = vendor_code[self.vendor_code]
self.putx([1, ['Vendor code: 0x%02x (%s)' % (ret[3], v)]])
self.putx([Ann.RSB0, ['Vendor code: 0x%02x (%s)' % (ret[3], v)]])

# Store for later.
self.xx = cmd[1] # Same as ret[2].
Expand All @@ -89,74 +99,116 @@ def handle_cmd_read_signature_byte_0x00(self, cmd, ret):

# Sanity check on reply.
if ret[1] != 0x30 or ret[2] != cmd[1]:
self.putx([8, ['Warning: Unexpected bytes in reply!']])
self.putx([Ann.WARN, ['Warning: Unexpected bytes in reply!']])

# Sanity check for the vendor code.
if self.vendor_code != VENDOR_CODE_ATMEL:
self.putx([8, ['Warning: Vendor code was not 0x1e (Atmel)!']])
self.putx([Ann.WARN, ['Warning: Vendor code was not 0x1e (Atmel)!']])

def handle_cmd_read_signature_byte_0x01(self, cmd, ret):
# Signature byte 0x01: part family and memory size.
self.part_fam_flash_size = ret[3]
self.putx([2, ['Part family / memory size: 0x%02x' % ret[3]]])
self.putx([Ann.RSB1, ['Part family / memory size: 0x%02x' % ret[3]]])

# Store for later.
self.mm = cmd[3]
self.ss_device = self.ss_cmd

# Sanity check on reply.
if ret[1] != 0x30 or ret[2] != cmd[1] or ret[0] != self.yy:
self.putx([8, ['Warning: Unexpected bytes in reply!']])
self.putx([Ann.WARN, ['Warning: Unexpected bytes in reply!']])

def handle_cmd_read_signature_byte_0x02(self, cmd, ret):
# Signature byte 0x02: part number.
self.part_number = ret[3]
self.putx([3, ['Part number: 0x%02x' % ret[3]]])
self.putx([Ann.RSB2, ['Part number: 0x%02x' % ret[3]]])

p = part[(self.part_fam_flash_size, self.part_number)]
data = [9, ['Device: Atmel %s' % p]]
data = [Ann.DEV, ['Device: Atmel %s' % p]]
self.put(self.ss_device, self.es_cmd, self.out_ann, data)

# Sanity check on reply.
if ret[1] != 0x30 or ret[2] != self.xx or ret[0] != self.mm:
self.putx([8, ['Warning: Unexpected bytes in reply!']])
self.putx([Ann.WARN, ['Warning: Unexpected bytes in reply!']])

self.xx, self.yy, self.zz, self.mm = 0, 0, 0, 0

def handle_cmd_chip_erase(self, cmd, ret):
# Chip erase (erases both flash an EEPROM).
# Upon successful chip erase, the lock bits will also be erased.
# The only way to end a Chip Erase cycle is to release RESET#.
self.putx([4, ['Chip erase']])
self.putx([Ann.CE, ['Chip erase']])

# TODO: Check/handle RESET#.

# Sanity check on reply.
bit = (ret[2] & (1 << 7)) >> 7
if ret[1] != 0xac or bit != 1 or ret[3] != cmd[2]:
self.putx([8, ['Warning: Unexpected bytes in reply!']])
self.putx([Ann.WARN, ['Warning: Unexpected bytes in reply!']])

def handle_cmd_read_fuse_bits(self, cmd, ret):
# Read fuse bits.
self.putx([5, ['Read fuse bits: 0x%02x' % ret[3]]])
self.putx([Ann.RFB, ['Read fuse bits: 0x%02x' % ret[3]]])

# TODO: Decode fuse bits.
# TODO: Sanity check on reply.

def handle_cmd_read_fuse_high_bits(self, cmd, ret):
# Read fuse high bits.
self.putx([6, ['Read fuse high bits: 0x%02x' % ret[3]]])
self.putx([Ann.RHFB, ['Read fuse high bits: 0x%02x' % ret[3]]])

# TODO: Decode fuse bits.
# TODO: Sanity check on reply.

def handle_cmd_read_extended_fuse_bits(self, cmd, ret):
# Read extended fuse bits.
self.putx([7, ['Read extended fuse bits: 0x%02x' % ret[3]]])
self.putx([Ann.REFB, ['Read extended fuse bits: 0x%02x' % ret[3]]])

# TODO: Decode fuse bits.
# TODO: Sanity check on reply.

def handle_cmd_read_lock_bits(self, cmd, ret):
# Read lock bits
self.putx([Ann.RLB, ['Read lock bits: 0x%02x' % ret[3]]])

def handle_cmd_read_eeprom_memory(self, cmd, ret):
# Read EEPROM Memory
_addr = ((cmd[1] & 1) << 8) + cmd[2]
self.putx([Ann.REEM, ['Read EEPROM Memory: [0x%03x]: 0x%02x' % (_addr, ret[3])]])

def handle_cmd_read_program_memory(self, cmd, ret):
# Read Program Memory
_HL = 'Low'
_H = 'L'
if cmd[0] & 0x08:
_HL = 'High'
_H = 'H'
_addr = ((cmd[1] & 0x0f) << 8) + cmd[2]
self.putx([Ann.RP, [
'Read program memory %s: [0x%03x]: 0x%02x' % (_HL, _addr, ret[3]),
'[%03x%s]:%02x' % (_addr, _H, ret[3]),
'%02x' % ret[3]
]])

def handle_cmd_load_program_memory_page(self, cmd, ret):
# Load Program Memory Page
_HL = 'Low'
_H = 'L'
if cmd[0] & 0x08:
_HL = 'High'
_H = 'H'
_addr = cmd[2] & 0x1F
self.putx([Ann.LPMP, [
'Load program memory page %s: [0x%03x]: 0x%02x' % (_HL, _addr, cmd[3]),
'[%03x%s]=%02x' % (_addr, _H, cmd[3]),
'%02x' % cmd[3]
]])

def handle_cmd_write_program_memory_page(self, cmd, ret):
# Write Program Memory Page
_addr = ((cmd[1] & 0x0F) << 3) + (cmd[2] << 5)
self.putx([Ann.WP, ['Write program memory page: 0x%02x' % _addr]])

def handle_command(self, cmd, ret):
if cmd[:2] == [0xac, 0x53]:
self.handle_cmd_programming_enable(cmd, ret)
Expand All @@ -174,10 +226,20 @@ def handle_command(self, cmd, ret):
self.handle_cmd_read_signature_byte_0x01(cmd, ret)
elif cmd[0] == 0x30 and cmd[2] == 0x02:
self.handle_cmd_read_signature_byte_0x02(cmd, ret)
elif cmd[:2] == [0x58, 0x00]:
self.handle_cmd_read_lock_bits(cmd,ret)
elif cmd[0] == 0xa0 and (cmd[1] & (3 << 6)) == (0 << 6):
self.handle_cmd_read_eeprom_memory(cmd, ret)
elif (cmd[0] == 0x20 or cmd[0] == 0x28) and ((cmd[1] & 0xf0) == 0x00):
self.handle_cmd_read_program_memory(cmd, ret)
elif (cmd[0] == 0x40 or cmd[0] == 0x48) and ((cmd[1] & 0xf0) == 0x00):
self.handle_cmd_load_program_memory_page(cmd, ret)
elif (cmd[0] == 0x4C and ((cmd[1] & 0xf0) == 0x00)):
self.handle_cmd_write_program_memory_page(cmd, ret)
else:
c = '%02x %02x %02x %02x' % tuple(cmd)
r = '%02x %02x %02x %02x' % tuple(ret)
self.putx([0, ['Unknown command: %s (reply: %s)!' % (c, r)]])
self.putx([Ann.WARN, ['Unknown command: %s (reply: %s)!' % (c, r)]])

def decode(self, ss, es, data):
ptype, mosi, miso = data
Expand Down
Loading