Skip to content
This repository was archived by the owner on Mar 7, 2026. It is now read-only.

Commit ea67caa

Browse files
authored
Merge branch 'blackmagic-debug:main' into pic32cm
2 parents bb7a433 + f7985cf commit ea67caa

55 files changed

Lines changed: 1174 additions & 322 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-and-upload.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ concurrency:
1414
group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }}
1515
cancel-in-progress: true
1616

17+
permissions:
18+
contents: read
19+
actions: write
20+
1721
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1822
jobs:
1923
# This workflow contains a job for each supported OS in the form `build-<os>`
@@ -98,6 +102,12 @@ jobs:
98102
meson setup build --cross-file cross-file/${{ matrix.probe }}.ini
99103
meson compile -C build
100104
mkdir src/artefacts
105+
case "${{ matrix.probe }}" in
106+
native-*)
107+
mv build/blackmagic_native_firmware.elf build/blackmagic_${{ matrix.probe }}_firmware.elf
108+
mv build/blackmagic_native_firmware.bin build/blackmagic_${{ matrix.probe }}_firmware.bin
109+
;;
110+
esac
101111
mv build/blackmagic_*_firmware.{elf,bin} src/artefacts
102112
103113
# Package up the artefacts and upload them

.github/workflows/build-pr.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ concurrency:
1414
group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }}
1515
cancel-in-progress: true
1616

17+
permissions:
18+
contents: read
19+
pull-requests: read
20+
1721
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1822
jobs:
1923
# This workflow contains a job for each supported OS in the form `build-<os>`
@@ -80,7 +84,9 @@ jobs:
8084

8185
# Install BMDA's deps (libftdi1, hidapi-hidraw)
8286
- name: Install BMDA dependencies
83-
run: sudo apt-get -y install libftdi1-dev libhidapi-dev libudev-dev
87+
run: |
88+
sudo apt update
89+
sudo apt-get -y install libftdi1-dev libhidapi-dev libudev-dev
8490
8591
# Record the versions of all the tools used in the build
8692
- name: Version tools

.github/workflows/lint.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ on:
99

1010
workflow_dispatch:
1111

12+
permissions:
13+
contents: read
14+
pull-requests: read
15+
1216
jobs:
1317
pre-commit:
1418
runs-on: ubuntu-latest

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
all:
2-
@echo "Makefile build system is depricated."
2+
@echo "Makefile build system is deprecated."
33
@echo ""
44
@echo "Please use Meson build system instead."
55
@echo ""

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,15 @@ You should now see the resulting binaries in `build`, in this case:
227227

228228
These are the binary files you will use to flash to your probe.
229229

230+
#### Building the bootloader
231+
232+
If your probe hardware does not already have a bootloader on it, after building firmware as described above
233+
you can build the appropriate bootloader with the following command:
234+
235+
```sh
236+
meson compile -C build boot-bin
237+
```
238+
230239
##### region `rom' overflowed
231240

232241
It may happen, while working with non default configurations or the project's latest version from Git,

meson.build

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# This file is part of the Black Magic Debug project.
22
#
3-
# Copyright (C) 2023 1BitSquared <info@1bitsquared.com>
3+
# Copyright (C) 2023-2025 1BitSquared <info@1bitsquared.com>
44
# Written by Rafael Silva <perigoso@riseup.net>
5+
# Modified by Rachel Mant <git@dragonmux.network>
56
#
67
# Redistribution and use in source and binary forms, with or without
78
# modification, are permitted provided that the following conditions are met:
@@ -31,7 +32,7 @@
3132
project(
3233
'Black Magic Debug',
3334
'c',
34-
version: '1.10.0',
35+
version: '2.0.0',
3536
license: 'GPL-3.0-or-later OR BSD-3-Clause OR MIT',
3637
# license_files: ['COPYING', 'COPYING-BSD', 'COPYING-MIT'], # Only available in meson 1.1.0
3738
default_options: [
@@ -258,17 +259,31 @@ If you did not touch the build system this is not your fault, please report it
258259
## Utility targets
259260
## _______________
260261

261-
# Black Magic Probe Firmware Manager
262-
bmputil = find_program('bmputil', required: false)
262+
# Black Magic Probe companion utility
263+
bmputil = find_program('bmputil-cli', required: false)
263264
if bmputil.found()
264265
message('Adding target for firmware update')
265266

266267
# Firmware update target
267268
run_target(
268269
'flash',
269-
command: [bmputil, 'flash', bmf_elf.full_path()],
270+
command: [bmputil, 'probe', 'update', bmf_elf.full_path()],
270271
depends: bmf_elf,
271272
)
273+
# If we couldn't find the utility, look for the older pre-v1.0 version of it
274+
else
275+
# Black Magic Probe Firmware Manager
276+
bmputil = find_program('bmputil', required: false)
277+
if bmputil.found()
278+
message('Adding target for firmware update')
279+
280+
# Firmware update target
281+
run_target(
282+
'flash',
283+
command: [bmputil, 'flash', bmf_elf.full_path()],
284+
depends: bmf_elf,
285+
)
286+
endif
272287
endif
273288
endif
274289

src/command.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Copyright (C) 2011 Black Sphere Technologies Ltd.
55
* Written by Gareth McMullin <gareth@blacksphere.co.nz>
66
* Copyright (C) 2021 Uwe Bonnes (bon@elektron.ikp.physik.tu-darmstadt.de)
7-
* Copyright (C) 2023 1BitSquared <info@1bitsquared.com>
7+
* Copyright (C) 2023-2025 1BitSquared <info@1bitsquared.com>
88
* Modified by Rachel Mant <git@dragonmux.network>
99
*
1010
* This program is free software: you can redistribute it and/or modify
@@ -70,6 +70,9 @@ static bool cmd_target_power(target_s *target, int argc, const char **argv);
7070
#ifdef PLATFORM_HAS_BATTERY
7171
static bool cmd_target_battery(target_s *t, int argc, const char **argv);
7272
#endif
73+
#ifdef PLATFORM_HAS_WIFI
74+
static bool cmd_wifi(target_s *t, int argc, const char **argv);
75+
#endif
7376
#ifdef PLATFORM_HAS_TRACESWO
7477
static bool cmd_swo(target_s *target, int argc, const char **argv);
7578
#endif
@@ -109,6 +112,9 @@ const command_s cmd_list[] = {
109112
#ifdef PLATFORM_HAS_BATTERY
110113
{"battery", cmd_target_battery, "Reads the battery state"},
111114
#endif
115+
#ifdef PLATFORM_HAS_WIFI
116+
{"wifi", cmd_wifi, "Show/Set Wi-Fi connection [AP name,passphrase]"},
117+
#endif
112118
#ifdef ENABLE_RTT
113119
{"rtt", cmd_rtt,
114120
"[enable|disable|status|channel [0..15 ...]|ident [STR]|cblock|ram [RAM_START RAM_END]|poll [MAXMS MINMS "
@@ -202,7 +208,7 @@ bool cmd_version(target_s *target, int argc, const char **argv)
202208
#endif
203209
gdb_outf(", Hardware Version %d\n", platform_hwversion());
204210
#endif
205-
gdb_out("Copyright (C) 2010-2024 Black Magic Debug Project\n");
211+
gdb_out("Copyright (C) 2010-2025 Black Magic Debug Project\n");
206212
gdb_out("License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n\n");
207213

208214
return true;
@@ -541,6 +547,15 @@ static bool cmd_target_battery(target_s *t, int argc, const char **argv)
541547
return true;
542548
}
543549
#endif
550+
#ifdef PLATFORM_HAS_WIFI
551+
static bool cmd_wifi(target_s *t, int argc, const char **argv)
552+
{
553+
(void)t;
554+
gdb_out(platform_wifi_state(argc, argv));
555+
return true;
556+
}
557+
#endif
558+
544559
#ifdef ENABLE_RTT
545560
static const char *on_or_off(const bool value)
546561
{

src/gdb_main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ int32_t gdb_main_loop(target_controller_s *const tc, const gdb_packet_s *const p
133133
/**
134134
* Register data is unavailable
135135
* See: https://sourceware.org/gdb/current/onlinedocs/gdb.html/Packets.html#read-registers-packet
136-
*
136+
*
137137
* ... the stub may also return a string of literal ‘x’ in place of the register data digits,
138138
* to indicate that the corresponding register’s value is unavailable.
139139
*/
@@ -258,7 +258,7 @@ int32_t gdb_main_loop(target_controller_s *const tc, const gdb_packet_s *const p
258258
/**
259259
* Register data is unavailable
260260
* See: https://sourceware.org/gdb/current/onlinedocs/gdb.html/Packets.html#read-registers-packet
261-
*
261+
*
262262
* ... the stub may also return a string of literal ‘x’ in place of the register data digits,
263263
* to indicate that the corresponding register’s value is unavailable.
264264
*/
@@ -466,7 +466,7 @@ static void exec_q_supported(const char *packet, const size_t length)
466466
* This might be the first packet of a GDB connection, If NoAckMode is enabled it might
467467
* be because the previous session was terminated abruptly, and we need to acknowledge
468468
* the first packet of the new session.
469-
*
469+
*
470470
* If NoAckMode was intentionally enabled before (e.g. LLDB enables NoAckMode first),
471471
* the acknowledgment should be safely ignored.
472472
*/
@@ -773,7 +773,7 @@ static void exec_v_cont(const char *packet, const size_t length)
773773
*
774774
* TODO: Support the 't' (stop) action needed for non-stop debug so GDB can request a halt.
775775
*/
776-
gdb_put_packet_str("vCont;c;C;s;t");
776+
gdb_put_packet_str("vCont;c;C;s;S;t");
777777
return;
778778
}
779779

src/include/buffer_utils.h

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,27 +61,32 @@ static inline void write_be4(uint8_t *const buffer, const size_t offset, const u
6161

6262
static inline uint16_t read_le2(const uint8_t *const buffer, const size_t offset)
6363
{
64-
return buffer[offset + 0U] | ((uint16_t)buffer[offset + 1U] << 8U);
64+
uint8_t data[2U];
65+
memcpy(data, buffer + offset, 2U);
66+
return data[0U] | ((uint16_t)data[1U] << 8U);
6567
}
6668

6769
static inline uint32_t read_le4(const uint8_t *const buffer, const size_t offset)
6870
{
69-
return buffer[offset + 0U] | ((uint32_t)buffer[offset + 1U] << 8U) | ((uint32_t)buffer[offset + 2U] << 16U) |
70-
((uint32_t)buffer[offset + 3U] << 24U);
71+
uint8_t data[4U];
72+
memcpy(data, buffer + offset, 4U);
73+
return data[0U] | ((uint32_t)data[1U] << 8U) | ((uint32_t)data[2U] << 16U) | ((uint32_t)data[3U] << 24U);
7174
}
7275

7376
static inline uint32_t read_be4(const uint8_t *const buffer, const size_t offset)
7477
{
75-
return ((uint32_t)buffer[offset + 0U] << 24U) | ((uint32_t)buffer[offset + 1U] << 16U) |
76-
((uint32_t)buffer[offset + 2U] << 8U) | buffer[offset + 3U];
78+
uint8_t data[4U];
79+
memcpy(data, buffer + offset, 4U);
80+
return ((uint32_t)data[0U] << 24U) | ((uint32_t)data[1U] << 16U) | ((uint32_t)data[2U] << 8U) | data[3U];
7781
}
7882

7983
static inline uint64_t read_be8(const uint8_t *const buffer, const size_t offset)
8084
{
81-
return ((uint64_t)buffer[offset + 0] << 56U) | ((uint64_t)buffer[offset + 1] << 48U) |
82-
((uint64_t)buffer[offset + 2] << 40U) | ((uint64_t)buffer[offset + 3] << 32U) |
83-
((uint64_t)buffer[offset + 4] << 24U) | ((uint64_t)buffer[offset + 5] << 16U) |
84-
((uint64_t)buffer[offset + 6] << 8U) | buffer[offset + 7];
85+
uint8_t data[8U];
86+
memcpy(data, buffer + offset, 8U);
87+
return ((uint64_t)data[0] << 56U) | ((uint64_t)data[1] << 48U) | ((uint64_t)data[2] << 40U) |
88+
((uint64_t)data[3] << 32U) | ((uint64_t)data[4] << 24U) | ((uint64_t)data[5] << 16U) |
89+
((uint64_t)data[6] << 8U) | data[7];
8590
}
8691

8792
static inline size_t write_char(char *const buffer, const size_t buffer_size, const size_t offset, const char c)

src/include/platform_support.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ void platform_max_frequency_set(uint32_t frequency);
7070
uint32_t platform_max_frequency_get(void);
7171

7272
void platform_target_clk_output_enable(bool enable);
73+
void platform_ospeed_update(uint32_t frequency);
7374

7475
#if CONFIG_BMDA == 0
7576
bool platform_spi_init(spi_bus_e bus);

0 commit comments

Comments
 (0)