Skip to content

Commit 590f5f0

Browse files
author
Seppo Takalo
committed
Allow boot messages on SWO instead of serial port.
1 parent 02e85d1 commit 590f5f0

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

mbed_lib.json

+5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
"value": 1,
3333
"macro_name": "SHOW_SERIAL_OUTPUT"
3434
},
35+
"show-swo-output": {
36+
"help": "Show boot status and progress on SWO output instead of serial.",
37+
"value": 0,
38+
"macro_name": "SHOW_SWO_OUTPUT"
39+
},
3540
"use-kvstore-rot": {
3641
"help": "use nvstore implementation of the ROT to authenticate firmware headers",
3742
"value": 1,

source/bootloader_common.c renamed to source/bootloader_common.cpp

+12-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
// ----------------------------------------------------------------------------
1818

1919
#include "bootloader_common.h"
20+
#include "mbed.h"
21+
#include "hal/serial_api.h"
22+
#include "SerialWireOutput.h"
2023

2124
/* buffer used in storage operations */
2225
uint8_t buffer_array[BUFFER_SIZE];
@@ -29,9 +32,7 @@ const char hexTable[16] = {'0', '1', '2', '3', '4', '5', '6', '7',
2932

3033
#if DEVICE_SERIAL && SHOW_SERIAL_OUTPUT
3134

32-
#include "hal/serial_api.h"
33-
34-
static serial_t uart = { 0 };
35+
static serial_t uart = {};
3536

3637
/* module variable for keeping track of initialization */
3738
static bool not_initialized = true;
@@ -68,6 +69,14 @@ void boot_debug(const char *s)
6869
}
6970
}
7071

72+
#elif DEVICE_ITM && SHOW_SWO_OUTPUT
73+
74+
void boot_debug(const char *s)
75+
{
76+
static SerialWireOutput swo;
77+
swo.write(s, strlen(s));
78+
}
79+
7180
#else
7281

7382
/**

0 commit comments

Comments
 (0)