Skip to content

Commit 8ff9ad4

Browse files
committed
Remove semihosting define
1 parent 5c5644d commit 8ff9ad4

File tree

7 files changed

+12
-79
lines changed

7 files changed

+12
-79
lines changed

CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,9 @@ option(COVERAGE "Compile with test coverage flags." OFF)
6161
option(SANITIZE_ADDRESS "Compile with asan." OFF)
6262
option(SANITIZE_UNDEFINED "Compile with ubsan." OFF)
6363
option(CMAKE_VERBOSE_MAKEFILE "Verbose build." OFF)
64-
option(SEMIHOSTING "Enable semihosting." OFF)
6564
# Generate compile_command.json (for tidy and other tools)
6665
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
6766

68-
if(SEMIHOSTING AND NOT CMAKE_CROSSCOMPILING)
69-
message(FATAL_ERROR "It doesn't make sense to semihost for the build machine")
70-
endif()
71-
7267
#-----------------------------------------------------------------------------
7368
# Force out-of-source build
7469

src/CMakeLists.txt

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -418,15 +418,8 @@ if(CMAKE_CROSSCOMPILING)
418418
# Select the smaller version of libc called nano.
419419
target_compile_options(${elf} PRIVATE --specs=nano.specs)
420420
target_link_libraries(${elf} PRIVATE --specs=nano.specs)
421-
if(SEMIHOSTING)
422-
# Select an implementation of the system calls that can communicate with the debugger
423-
target_compile_options(${elf} PRIVATE --specs=rdimon.specs)
424-
target_link_libraries(${elf} PRIVATE --specs=rdimon.specs)
425-
target_compile_definitions(${elf} PRIVATE SEMIHOSTING)
426-
else()
427-
target_compile_options(${elf} PRIVATE --specs=nosys.specs)
428-
target_link_libraries(${elf} PRIVATE --specs=nosys.specs)
429-
endif()
421+
target_compile_options(${elf} PRIVATE --specs=nosys.specs)
422+
target_link_libraries(${elf} PRIVATE --specs=nosys.specs)
430423
endforeach(bootloader)
431424

432425
foreach(bootloader ${BOOTLOADERS-BITBOX02})
@@ -475,15 +468,8 @@ if(CMAKE_CROSSCOMPILING)
475468
# Select the smaller version of libc called nano.
476469
target_compile_options(${elf} PRIVATE --specs=nano.specs)
477470
target_link_libraries(${elf} PRIVATE --specs=nano.specs)
478-
if(SEMIHOSTING)
479-
# Select an implementation of the system calls that can communicate with the debugger
480-
target_compile_options(${elf} PRIVATE --specs=rdimon.specs)
481-
target_link_libraries(${elf} PRIVATE --specs=rdimon.specs)
482-
target_compile_definitions(${elf} PRIVATE SEMIHOSTING)
483-
else()
484-
target_compile_options(${elf} PRIVATE --specs=nosys.specs)
485-
target_link_libraries(${elf} PRIVATE --specs=nosys.specs)
486-
endif()
471+
target_compile_options(${elf} PRIVATE --specs=nosys.specs)
472+
target_link_libraries(${elf} PRIVATE --specs=nosys.specs)
487473

488474
target_link_libraries(${elf} PRIVATE ${firmware}_rust_c)
489475
endforeach(firmware)

src/firmware.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "qtouch.h"
2323
#include "screen.h"
2424
#include "ui/screen_stack.h"
25-
#include "util.h"
2625
#include "workflow/idle_workflow.h"
2726
#include "workflow/orientation_screen.h"
2827

@@ -39,7 +38,6 @@ int main(void)
3938
qtouch_init();
4039
common_main();
4140
bitbox02_smarteeprom_init();
42-
traceln("%s", "Device initialized");
4341
orientation_screen_blocking();
4442
idle_workflow_blocking();
4543
firmware_main_loop();

src/hardfault.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ void MemManage_Handler(void)
3535
void Abort(const char* msg)
3636
{
3737
screen_print_debug(msg, 0);
38-
traceln("Aborted: %s", msg);
3938
usb_stop();
4039
#if !defined(TESTING)
4140
#if defined(BOOTLOADER)

src/platform/platform_init.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,9 @@
1818
#if !defined(BOOTLOADER)
1919
#include "sd_mmc/sd_mmc_start.h"
2020
#endif
21-
#include "util.h"
22-
23-
extern void initialise_monitor_handles(void);
2421

2522
void platform_init(void)
2623
{
27-
#if defined(SEMIHOSTING)
28-
initialise_monitor_handles();
29-
traceln("%s", "Semihosting enabled");
30-
#endif
3124
oled_init();
3225
#if !defined(BOOTLOADER)
3326
sd_mmc_start();

src/util.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,15 @@ void util_zero(volatile void* dst, size_t len)
2929
// the data type.
3030
#pragma GCC diagnostic push
3131
#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
32+
// ifdef here so that we don't have to use -Wno-unknown-pragmas on GCC
33+
#ifdef __clang__
34+
#pragma clang diagnostic push
35+
#pragma clang diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers"
36+
#endif
3237
rust_util_zero(rust_util_bytes_mut(dst, len));
38+
#ifdef __clang__
39+
#pragma clang diagnostic pop
40+
#endif
3341
#pragma GCC diagnostic pop
3442
}
3543

@@ -39,16 +47,6 @@ void util_uint8_to_hex(const uint8_t* in_bin, const size_t in_len, char* out)
3947
rust_util_bytes(in_bin, in_len), rust_util_bytes_mut((uint8_t*)out, in_len * 2 + 1));
4048
}
4149

42-
#if defined(SEMIHOSTING)
43-
char* util_uint8_to_hex_alloc(const uint8_t* in_bin, const size_t in_len)
44-
{
45-
void* out = malloc(in_len * 2 + 1);
46-
rust_util_uint8_to_hex(
47-
rust_util_bytes(in_bin, in_len), rust_util_bytes_mut((uint8_t*)out, in_len * 2 + 1));
48-
return (char*)out;
49-
}
50-
#endif
51-
5250
void util_cleanup_str(char** str)
5351
{
5452
util_zero(*str, strlens(*str));

src/util.h

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ void util_zero(volatile void* dst, size_t len);
6161
// `out` must be of size in_len*2+1. Use BB_HEX_SIZE() to compute the size.
6262
void util_uint8_to_hex(const uint8_t* in_bin, size_t in_len, char* out);
6363

64-
// This function is only compiled when we compile with SEMIHOSTING, it is convenient when debugging
65-
// to print byte arrays as hex.
66-
char* util_uint8_to_hex_alloc(const uint8_t* in_bin, size_t in_len);
67-
6864
#define BB_HEX_SIZE(in_bin) (sizeof((in_bin)) * 2 + 1)
6965

7066
void util_cleanup_str(char** str);
@@ -85,38 +81,6 @@ void util_cleanup_64(uint8_t** buf);
8581
uint8_t* __attribute__((__cleanup__(util_cleanup_64))) var##_clean __attribute__((unused)) = \
8682
var;
8783

88-
/**
89-
* Tracing tools. Only enabled in semihosting builds
90-
*
91-
* Since we are using C99 it is necessary to provide at least 1 argument to "...". To print a
92-
* string, provide the format string "%s" and your string as the second argument.
93-
*
94-
* "do {} while" is a hack to make a macro work like a function in some cases.
95-
*
96-
* stderr is not buffered and takes forever to print stdout is used instead.
97-
*
98-
* SOURCE_PATH_SIZE is a definition provided from the command line which is the length of the path
99-
* to the project directory.
100-
*/
101-
102-
#if defined(SEMIHOSTING)
103-
#define LOG_LEVEL 1
104-
#else
105-
#define LOG_LEVEL 0
106-
#endif
107-
#define FILENAME (&__FILE__[SOURCE_PATH_SIZE])
108-
109-
#define trace(format, ...) \
110-
do { \
111-
if (LOG_LEVEL > 0) fprintf(stdout, "%s:%d: " format, FILENAME, __LINE__, __VA_ARGS__); \
112-
} while (0)
113-
114-
#define traceln(format, ...) \
115-
do { \
116-
if (LOG_LEVEL > 0) \
117-
fprintf(stdout, "%s:%d: " format "\n", FILENAME, __LINE__, __VA_ARGS__); \
118-
} while (0)
119-
12084
/**
12185
* Struct definining a rw buffer (buffer + length).
12286
*/

0 commit comments

Comments
 (0)