Skip to content

Commit d4e769c

Browse files
finikorgjhedberg
authored andcommitted
boards: up_squared_adsp: Update logging frontend
Update frontend moving general library code to appropriate place. Signed-off-by: Andrei Emeltchenko <[email protected]>
1 parent 7d74a19 commit d4e769c

File tree

2 files changed

+49
-48
lines changed

2 files changed

+49
-48
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Copyright (c) 2019 Intel Corporation
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
7+
from ctypes import string_at
8+
9+
MAGIC = 0x55aa
10+
SLOT_LEN = 64
11+
SLOT_NUM = int(8192 / SLOT_LEN)
12+
13+
def read_bytes(buffer):
14+
return int.from_bytes(buffer, byteorder='little')
15+
16+
class Loglist:
17+
"""Loglist class"""
18+
19+
def __init__(self, argument):
20+
"""Constructor for the loglist takes argument filename or buffer"""
21+
22+
if isinstance(argument, str):
23+
f = open(argument, "rb")
24+
self.buffer = f.read(SLOT_NUM * SLOT_LEN)
25+
elif isinstance(argument, int):
26+
self.buffer = string_at(argument, SLOT_NUM * SLOT_LEN)
27+
else:
28+
return
29+
30+
self.loglist = []
31+
self.parse()
32+
33+
def parse_slot(self, slot):
34+
magic = read_bytes(slot[0:2])
35+
36+
if magic == MAGIC:
37+
id_num = read_bytes(slot[2:4])
38+
logstr = slot[4:].decode(errors='replace').split('\r', 1)[0]
39+
self.loglist.append((id_num, logstr))
40+
41+
def parse(self):
42+
for x in range(0, SLOT_NUM):
43+
slot = self.buffer[x * SLOT_LEN : (x + 1) * SLOT_LEN]
44+
self.parse_slot(slot)
45+
46+
def print(self):
47+
for pair in sorted(self.loglist):
48+
print('{} : {}'.format(*pair))

boards/xtensa/up_squared_adsp/tools/logtool.py

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -9,58 +9,11 @@
99
import argparse
1010
import os
1111
import sys
12-
from ctypes import string_at
12+
from lib.loglist import Loglist
1313

1414
QEMU_ETRACE = "/dev/shm/qemu-bridge-hp-sram-mem"
1515
SOF_ETRACE = "/sys/kernel/debug/sof/etrace"
1616

17-
QEMU_OFFSET = 0x8000
18-
SOF_OFFSET = 0x0
19-
20-
MAGIC = 0x55aa
21-
SLOT_LEN = 64
22-
SLOT_NUM = int(8192 / SLOT_LEN)
23-
24-
25-
def read_bytes(buffer):
26-
return int.from_bytes(buffer, byteorder='little')
27-
28-
29-
class Loglist:
30-
"""Loglist class"""
31-
32-
def __init__(self, argument):
33-
"""Constructor for the loglist takes argument filename or buffer"""
34-
35-
if isinstance(argument, str):
36-
f = open(argument, "rb")
37-
self.buffer = f.read(SLOT_NUM * SLOT_LEN)
38-
elif isinstance(argument, int):
39-
self.buffer = string_at(argument, SLOT_NUM * SLOT_LEN)
40-
else:
41-
return
42-
43-
self.loglist = []
44-
self.parse()
45-
46-
def parse_slot(self, slot):
47-
magic = read_bytes(slot[0:2])
48-
49-
if magic == MAGIC:
50-
id_num = read_bytes(slot[2:4])
51-
logstr = slot[4:].decode(errors='replace').split('\r', 1)[0]
52-
self.loglist.append((id_num, logstr))
53-
54-
def parse(self):
55-
for x in range(0, SLOT_NUM):
56-
slot = self.buffer[x * SLOT_LEN : (x + 1) * SLOT_LEN]
57-
self.parse_slot(slot)
58-
59-
def print(self):
60-
for pair in sorted(self.loglist):
61-
print('{} : {}'.format(*pair))
62-
63-
6417
def parse_args():
6518
"""Parsing command line arguments"""
6619

0 commit comments

Comments
 (0)