Skip to content

Commit 5c9832a

Browse files
committed
Update uhk60 dev commands.
1 parent 2093d79 commit 5c9832a

2 files changed

Lines changed: 38 additions & 17 deletions

File tree

build.sh

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ usage: ./build DEVICE1 DEVICE2 ... ACTION1 ACTION2 ...
1414
1515
DEVICE is in { uhk-80-left | uhk-80-right | uhk-60-right | uhk-dongle }
1616
there are also these aliases: { left | right | dongle | all }
17-
ACTION is in { clean | setup | update | build | make | flash | flashUsb | shell | uart | addrline <address> }
17+
ACTION is in { clean | setup | update | build | make | flash | flashUsb | shell | uart | addrline <address>... }
1818
1919
setup initialize submodules and set up zephyr environment
2020
clean removes zephyr libraries
@@ -23,6 +23,8 @@ usage: ./build DEVICE1 DEVICE2 ... ACTION1 ACTION2 ...
2323
make just recompile / relink the binary
2424
flash make and then flash
2525
flashUsb just flash via USB
26+
addrline resolve addresses to source lines in the device's elf
27+
(build with DEBUG=1 for symbols; accepts a whole backtrace)
2628
shell open build shell
2729
uart open uhk shell
2830
switchMcux switch to UHK60 build environment
@@ -89,16 +91,14 @@ function processArguments() {
8991
;;
9092
addrline)
9193
shift
92-
ADDR=$1
93-
shift
94-
for device in $DEVICES
94+
ADDRS=""
95+
# consume all following addresses (a whole backtrace can be passed at once)
96+
while [ $# -gt 0 ] && [[ "$1" =~ ^(0x)?[0-9a-fA-F]+$ ]]
9597
do
96-
echo "addrline for $ADDR:"
97-
printf " "
98-
# addr2line -e device/build/$device/zephyr/zephyr.elf $ADDR
99-
arm-none-eabi-addr2line -e device/build/$device/device/zephyr/zephyr.elf $ADDR
98+
ADDRS="$ADDRS $1"
99+
shift
100100
done
101-
exit 0
101+
MULTIPLEXED_ACTIONS="$MULTIPLEXED_ACTIONS addrline"
102102
;;
103103
uart)
104104
TERMINAL_ACTIONS="$TERMINAL_ACTIONS $1"
@@ -172,20 +172,23 @@ function dealiasDeviceMcux() {
172172
VARIANT="v1-$BUILD_TYPE"
173173
BUILD_DIR="right/build/$VARIANT"
174174
DEVICE_DIR="right"
175+
DEVICE_ELF="uhk-60-right.elf"
175176
USBDEVICEARG="--vid=0x37a8 --pid=1"
176177
;;
177178
uhk-60v2-right|rightv2|right)
178179
DEVICE="uhk-60v2-right"
179180
VARIANT="v2-$BUILD_TYPE"
180181
BUILD_DIR="right/build/$VARIANT"
181182
DEVICE_DIR="right"
183+
DEVICE_ELF="uhk-60-right.elf"
182184
USBDEVICEARG="--vid=0x37a8 --pid=3"
183185
;;
184186
trackpoint|trackball|keycluster|left)
185187
DEVICE="$DEVICE"
186188
VARIANT="release"
187189
BUILD_DIR="$DEVICE/build/$VARIANT"
188190
DEVICE_DIR="$DEVICE"
191+
DEVICE_ELF="uhk-$DEVICE.elf"
189192
DEVICEARG="-SelectEmuBySN $DEVICEID_UHK_MODULE"
190193
;;
191194
*)
@@ -302,9 +305,28 @@ function performMcuxAction() {
302305
mutex unlock
303306
exitOnFail $?
304307
;;
308+
addrline)
309+
addrline "$BUILD_DIR/$DEVICE_ELF" "$ADDRS"
310+
;;
305311
esac
306312
}
307313

314+
function addrline() {
315+
ELF=$1
316+
ADDRS=$2
317+
318+
if [ ! -f "$ELF" ]; then
319+
echo "$ELF not found - build the device first (DEBUG=1 for symbols)."
320+
return 1
321+
fi
322+
323+
for ADDR in $ADDRS
324+
do
325+
printf "%s: " "$ADDR"
326+
arm-none-eabi-addr2line -f -p -C -e "$ELF" "$ADDR"
327+
done
328+
}
329+
308330
function exitOnFail() {
309331
if [ $1 -ne 0 ]
310332
then
@@ -348,6 +370,9 @@ function performZephyrAction() {
348370
west agent --build-dir $BUILD_DIR
349371
mutex unlock
350372
;;
373+
addrline)
374+
addrline "$ROOT/device/build/$DEVICE/device/zephyr/zephyr.elf" "$ADDRS"
375+
;;
351376
esac
352377
}
353378

@@ -408,7 +433,7 @@ function performAction() {
408433
west config manifest.file west_nrfsdk.yml
409434
upgradeEnv
410435
;;
411-
make|build|flash|flashUsb)
436+
make|build|flash|flashUsb|addrline)
412437
if [ `west config manifest.file` == "west_nrfsdk.yml" ]
413438
then
414439
performZephyrAction $DEVICE $ACTION
@@ -428,8 +453,6 @@ function performAction() {
428453
uart)
429454
setupUartMonitor
430455
;;
431-
addrline)
432-
;;
433456
*)
434457
help
435458
;;

doc-dev/development/gdb_uhk60.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ Compile and flash the firmware with debug symbols:
22

33
```
44
export DEBUG=1
5-
cd firmware/right/uhk60v2
6-
make clean
7-
make flash
5+
./build.sh rightv2 build flash
86
```
97

108
Start gdb server against UHK60:
@@ -16,8 +14,8 @@ Start gdb server against UHK60:
1614
Start gdb client against UHK60:
1715

1816
```
19-
cd firmware/right/uhk60v2/build_make
20-
/opt/arm-gnu-toolchain-11.3.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gdb -tui -ex "target remote 127.0.0.1:2331" *.axf
17+
cd firmware/right/build/v2-debug
18+
cd $PWD; /opt/arm-gnu-toolchain-15.2.rel1-x86_64-arm-none-eabi/bin/arm-none-eabi-gdb -tui -ex "target remote 127.0.0.1:2331" *.elf
2119
```
2220

2321

0 commit comments

Comments
 (0)