Skip to content

Commit

Permalink
Merge pull request #297 from Nitrokey/sz-nrf52-debug
Browse files Browse the repository at this point in the history
NRF52 debug tools update
  • Loading branch information
szszszsz committed Jun 22, 2023
2 parents a184d9a + bd71660 commit 218cdb6
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 2 deletions.
4 changes: 3 additions & 1 deletion utils/nrf-bootloader/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ UPLOAD_SH = $(BL_DIR)/upload.sh

FW_SIGNED = fw_signed_update.zip
FW_RAW = fw_unsigned.hex
TTYDEV = /dev/ttyACM1
TTYDEV := $(wildcard /dev/serial/by-id/usb-Nitrokey_Nitrokey_3_Bootloader*)
# /dev/serial/by-id/usb-Nitrokey_Nitrokey_3-if02
# /dev/serial/by-id/usb-Nitrokey_Nitrokey_3_Bootloader_F95AF80A9E98-if00

fw-assemble-dfu: $(FW_SIGNED)

Expand Down
2 changes: 1 addition & 1 deletion utils/nrf-builder/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ ALL_ARTIFACTS := $(FW_NAME_RELEASE) $(FW_NAME_PROVISIONER) $(FW_NAME_DEVELOP) \

SRCS = $(shell find $(FW_RUNNER)/src -name "*.rs" )

TTY := $(shell ls -1rt /dev/ttyACM* | tail -n 1 | xargs)
TTY := $(wildcard /dev/serial/by-id/usb-Nitrokey_Nitrokey_3_Bootloader*)

EXTRA_FEATURES :=

Expand Down
1 change: 1 addition & 0 deletions utils/nrf-debugging/binary.elf
25 changes: 25 additions & 0 deletions utils/nrf-debugging/gdb-stack.cmds
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
set pagination off
set logging file gdb.txt
set logging on

set architecture arm
set endian little
set arm fallback-mode thumb
set arm force-mode thumb
set style enabled off
file binary.elf
target remote :3333


define stepinf
while(1)
p $msp
step
end
end

# Automatically start tracing upon reaching the following line
# b transport.rs:181
# commands
# stepinf
# end
36 changes: 36 additions & 0 deletions utils/nrf-debugging/graph_stack.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from matplotlib import pyplot as plt

"""
Quickly graph gdb msp prints.
rg -F "= (*mut ()) " gdb.txt > gdb.txt.stack
Expected format is like:
...
$38057 = (*mut ()) 0x2001b478
$38058 = (*mut ()) 0x2001b478
...
"""

PATH = 'gdb.txt.stack'

def main():
data = []
with open(PATH, 'r') as f:
for line in f:
num = int(line.split()[-1], 16)
num = num - 0x20000000
num = num // 1024
data.append(num)

print(len(data))
plt.plot(data)
plt.ylabel('free stack memory left [kB]')
plt.xlabel('sample no.')
plt.show()


if __name__ == '__main__':
main()

0 comments on commit 218cdb6

Please sign in to comment.