mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-07 07:12:34 +00:00
cleanup pb2py, add debug to emu.sh
This commit is contained in:
parent
0a8870f110
commit
ee3614ae6a
5
Makefile
5
Makefile
@ -41,5 +41,8 @@ gdb: ## start remote gdb session which connects to the openocd
|
|||||||
|
|
||||||
load: ## load contents of src into mass storage of trezor
|
load: ## load contents of src into mass storage of trezor
|
||||||
rm -rf /run/media/${USER}/PYBFLASH/*
|
rm -rf /run/media/${USER}/PYBFLASH/*
|
||||||
cp -a src/* /run/media/${USER}/PYBFLASH/
|
cp -a src/lib /run/media/${USER}/PYBFLASH/
|
||||||
|
cp -a src/playground /run/media/${USER}/PYBFLASH/
|
||||||
|
cp -a src/trezor /run/media/${USER}/PYBFLASH/
|
||||||
|
cp -a src/*.py /run/media/${USER}/PYBFLASH/
|
||||||
sync
|
sync
|
||||||
|
7
emu.sh
7
emu.sh
@ -1,5 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
cd `dirname $0`/src
|
cd `dirname $0`/src
|
||||||
rm -f ../pipe.*
|
rm -f ../pipe.*
|
||||||
../vendor/micropython/unix/micropython $* -O0 -X heapsize=100000 main.py
|
if [ "$1" == -d ]; then
|
||||||
|
shift
|
||||||
|
gdb --args ../vendor/micropython/unix/micropython $* -O0 -X heapsize=100000 main.py
|
||||||
|
else
|
||||||
|
../vendor/micropython/unix/micropython $* -O0 -X heapsize=100000 main.py
|
||||||
|
fi
|
||||||
rm -f ../pipe.*
|
rm -f ../pipe.*
|
||||||
|
1
src/trezor/messages/.gitignore
vendored
Normal file
1
src/trezor/messages/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
[ABCDEFGHIJKLMNOPQRSTUVWXYZ]*.py
|
@ -28,6 +28,6 @@ BLUE_GRAY = rgbcolor(0x60, 0x7D, 0x8B)
|
|||||||
BLACK = rgbcolor(0x00, 0x00, 0x00)
|
BLACK = rgbcolor(0x00, 0x00, 0x00)
|
||||||
WHITE = rgbcolor(0xFF, 0xFF, 0xFF)
|
WHITE = rgbcolor(0xFF, 0xFF, 0xFF)
|
||||||
|
|
||||||
MONO = 0
|
MONO = const(0)
|
||||||
NORMAL = 1
|
NORMAL = const(1)
|
||||||
BOLD = 2
|
BOLD = const(2)
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
CURDIR=$(pwd)
|
CURDIR=$(pwd)
|
||||||
|
|
||||||
|
for i in types messages storage ; do
|
||||||
for i in messages types storage ; do
|
|
||||||
|
|
||||||
# Compile .proto files to python2 modules using google protobuf library
|
# Compile .proto files to python2 modules using google protobuf library
|
||||||
cd $CURDIR/../../trezor-common/protob
|
cd $CURDIR/../../trezor-common/protob
|
||||||
protoc --python_out=$CURDIR/pb2/ -I/usr/include -I. $i.proto
|
protoc --python_out=$CURDIR/pb2/ -I/usr/include -I. $i.proto
|
||||||
@ -12,4 +10,3 @@ for i in messages types storage ; do
|
|||||||
cd $CURDIR
|
cd $CURDIR
|
||||||
./pb2py $i ../src/trezor/messages/
|
./pb2py $i ../src/trezor/messages/
|
||||||
done
|
done
|
||||||
|
|
||||||
|
2
tools/pb2/.gitignore
vendored
Normal file
2
tools/pb2/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
*_pb2.py
|
||||||
|
*.pyc
|
17
tools/pb2py
17
tools/pb2py
@ -10,19 +10,16 @@ def process_type(t, cls):
|
|||||||
|
|
||||||
out = ["t = p.MessageType()", ]
|
out = ["t = p.MessageType()", ]
|
||||||
|
|
||||||
print("Processing type %s" % t)
|
print(" * type %s" % t)
|
||||||
|
|
||||||
TYPE_STRING = 9
|
TYPE_STRING = 9
|
||||||
TYPE_BYTES = 12
|
TYPE_BYTES = 12
|
||||||
|
|
||||||
TYPE_MESSAGE = 11
|
TYPE_MESSAGE = 11
|
||||||
|
|
||||||
for k, v in cls.DESCRIPTOR.fields_by_name.items():
|
for v in sorted(cls.DESCRIPTOR.fields_by_name.values(), key=lambda x: x.number):
|
||||||
|
|
||||||
#print k
|
|
||||||
|
|
||||||
number = v.number
|
number = v.number
|
||||||
fieldname = k
|
fieldname = v.name
|
||||||
type = None
|
type = None
|
||||||
repeated = v.label == 3
|
repeated = v.label == 3
|
||||||
required = v.label == 2
|
required = v.label == 2
|
||||||
@ -85,7 +82,7 @@ def process_type(t, cls):
|
|||||||
def process_enum(t, cls):
|
def process_enum(t, cls):
|
||||||
out = []
|
out = []
|
||||||
|
|
||||||
print("Processing enum %s" % t)
|
print(" * enum %s" % t)
|
||||||
|
|
||||||
for k, v in cls.items():
|
for k, v in cls.items():
|
||||||
# Remove type name from the beginning of the constant
|
# Remove type name from the beginning of the constant
|
||||||
@ -98,11 +95,13 @@ def process_enum(t, cls):
|
|||||||
if t.endswith("Type") and k.startswith("%s_" % t.replace("Type", '')):
|
if t.endswith("Type") and k.startswith("%s_" % t.replace("Type", '')):
|
||||||
k = k.replace("%s_" % t.replace("Type", ''), '')
|
k = k.replace("%s_" % t.replace("Type", ''), '')
|
||||||
|
|
||||||
out.append("%s = %s" % (k, v))
|
out.append("%s = const(%s)" % (k, v))
|
||||||
|
|
||||||
return out
|
return out
|
||||||
|
|
||||||
def process_module(mod, genpath):
|
def process_module(mod, genpath):
|
||||||
|
|
||||||
|
print("Processing module %s" % mod.__name__)
|
||||||
types = dict([(name, cls) for name, cls in mod.__dict__.items() if isinstance(cls, type)])
|
types = dict([(name, cls) for name, cls in mod.__dict__.items() if isinstance(cls, type)])
|
||||||
|
|
||||||
for t, cls in types.iteritems():
|
for t, cls in types.iteritems():
|
||||||
@ -118,7 +117,7 @@ def process_module(mod, genpath):
|
|||||||
def write_to_file(genpath, t, out):
|
def write_to_file(genpath, t, out):
|
||||||
# Write generated sourcecode to given file
|
# Write generated sourcecode to given file
|
||||||
f = open(os.path.join(genpath, "%s.py" % t), 'w')
|
f = open(os.path.join(genpath, "%s.py" % t), 'w')
|
||||||
out = ["# Automatically generated by ./pb2py"] + out
|
out = ["# Automatically generated by pb2py"] + out
|
||||||
|
|
||||||
data = "\n".join(out)
|
data = "\n".join(out)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user