Last active
April 28, 2020 02:54
-
-
Save k3wals/d48f49050c1d1914f8f0d3fb0314c851 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Links: | |
gc_activity.md (primary how-to guide) | |
output_gc_until_repl.txt | |
https://hackaday.io/project/86818-game-turbo/log/146645-debugging-circuitpython | |
https://gnu-mcu-eclipse.github.io/debug/jlink/install/ | |
https://devzone.nordicsemi.com/f/nordic-q-a/46383/nrf52840-dk-onboard-segger-j-link | |
NRF52 Dongle USB Segger Setup on Linux | |
Install USB extensions for VirtualBox | |
Passthrough USB Dongle (labeled “Segger”) | |
Goto https://www.segger.com/downloads/jlink?step=1&file=JLink_510d#J-LinkSoftwareAndDocumentationPack and download “J-Link Software and Documentation pack for Linux, DEB installer, 64-bit” | |
sudo dpkg -i JLink_Linux_x86_64.deb | |
Test function: nrfjprog -f nrf52 --reset | |
Debugging Steps (heap analysis) | |
Setup SWD and run GDB | |
Connect SWD debugger (NRF52 dongle appears to work) | |
cd circuitpython/ports/nrf | |
Uncomment “#define LOG_HEAP_ACTIVITY 1” in circuitpython/py/gc.c | |
append ‘-ggdb’ to CFLAGS in ports/nrf/mpconfigport.mk | |
Add `_rom_start = ${CIRCUITPY_FIRMWARE_START_ADDR};` to /ports/nrf/boards/common.template.ld | |
Adjust the following two lines in analyze_heap_dump.py | |
- rom_start = symbols["_sfixed"][0] | |
- ram_start = symbols["_srelocate"][0] | |
+ rom_start = symbols["_rom_start"][0] | |
+ ram_start = symbols["_ram_start"][0] | |
make -j10 BOARD=feather_nrf52840_express | |
Flash board with new UF2 | |
Optional: add “set breakpoint pending off” to gdb run script | |
Disconnect USB to PC or there will be a breakpoint resource issue with gdb | |
Start GDB server in another console: JLinkGDBServer -if SWD -device nRF52840_xxAA | |
uncomment and adjust append line to ‘append binary memory ram.bin &_ram_start &_estack’ | |
arm-none-eabi-gdb -x ../../tools/output_gc_until_repl.txt build-feather_nrf52840_express/firmware.elf | |
Processing memory output | |
python3 ../../tools/gc_activity_between_collects.py mylog.txt | |
Create Visual Outputs | |
sudo apt-get update | |
sudo apt-get install python3-setuptools | |
pip install wheel | |
sudo apt-get install python3-dev graphviz libgraphviz-dev pkg-config | |
pip3 install click | |
pip3 install graphviz | |
pip3 install pygraphviz | |
mkdir heapviz | |
python3 ../../tools/analyze_heap_dump.py ram.bin build-feather_nrf52840_express/firmware.bin build-feather_nrf52840_express/firmware.elf.map --print-heap-structure --draw-heap-ownership |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment