Skip to content

Commit 20fbda4

Browse files
authored
Merge pull request #1322 from NickeZ/nickez/remove-semihosting
Nickez/remove semihosting
2 parents 735b280 + 8ff9ad4 commit 20fbda4

File tree

11 files changed

+13
-179
lines changed

11 files changed

+13
-179
lines changed

.ci/ci

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ make -j8 firmware
6060
make -j8 firmware-btc
6161
make -j8 factory-setup
6262

63-
# Semihosting
64-
make -j8 bootloader-semihosting
65-
make -j8 firmware-semihosting
66-
6763
# Disallow some symbols in the final binary that we don't want.
6864
if arm-none-eabi-nm build/bin/firmware.elf | grep -q "float_to_decimal_common_shortest"; then
6965
echo "Rust fmt float formatting like {.1} adds significant binary bloat."

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

Makefile

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ build-build-rust-unit-tests/Makefile:
3838
cd build-build-rust-unit-tests && cmake .. -DCOVERAGE=OFF -DSANITIZE_ADDRESS=OFF -DSANITIZE_UNDEFINED=OFF
3939
$(MAKE) -C py/bitbox02
4040

41-
build-semihosting/Makefile:
42-
mkdir -p build-semihosting
43-
cd build-semihosting && cmake .. -DCMAKE_TOOLCHAIN_FILE=arm.cmake -DSEMIHOSTING=ON
44-
${MAKE} -C py/bitbox02
45-
4641
# Directory for building for "host" machine according to gcc convention
4742
build: build/Makefile
4843

@@ -54,20 +49,13 @@ build-build: build-build/Makefile
5449
# address santizers when they link code compiled with gcc.
5550
build-build-rust-unit-tests: build-build-rust-unit-tests/Makefile
5651

57-
# Directory for building for "host" machine but with semihosting enbled
58-
build-semihosting: build-semihosting/Makefile
59-
6052
firmware: | build
6153
# Generate python bindings for protobuf for test scripts
6254
$(MAKE) -C build firmware.elf
63-
firmware-semihosting: | build-semihosting
64-
$(MAKE) -C build-semihosting firmware.elf
6555
firmware-btc: | build
6656
$(MAKE) -C build firmware-btc.elf
6757
bootloader: | build
6858
$(MAKE) -C build bootloader.elf
69-
bootloader-semihosting: | build-semihosting
70-
$(MAKE) -C build-semihosting bootloader-development.elf
7159
bootloader-development: | build
7260
$(MAKE) -C build bootloader-development.elf
7361
bootloader-development-locked: | build
@@ -110,8 +98,6 @@ flash-dev-firmware:
11098
./py/load_firmware.py build/bin/firmware.bin --debug
11199
jlink-flash-bootloader-development: | build
112100
JLinkExe -if SWD -device ATSAMD51J20 -speed 4000 -autoconnect 1 -CommanderScript ./build/scripts/bootloader-development.jlink
113-
jlink-flash-bootloader-semihosting: | build-semihosting
114-
JLinkExe -if SWD -device ATSAMD51J20 -speed 4000 -autoconnect 1 -CommanderScript ./build-semihosting/scripts/bootloader-development.jlink
115101
jlink-flash-bootloader-development-locked: | build
116102
JLinkExe -if SWD -device ATSAMD51J20 -speed 4000 -autoconnect 1 -CommanderScript ./build/scripts/bootloader-development-locked.jlink
117103
jlink-flash-bootloader: | build
@@ -126,8 +112,6 @@ jlink-flash-firmware-btc: | build
126112
JLinkExe -if SWD -device ATSAMD51J20 -speed 4000 -autoconnect 1 -CommanderScript ./build/scripts/firmware-btc.jlink
127113
jlink-flash-factory-setup: | build
128114
JLinkExe -if SWD -device ATSAMD51J20 -speed 4000 -autoconnect 1 -CommanderScript ./build/scripts/factory-setup.jlink
129-
jlink-flash-firmware-semihosting: | build-semihosting
130-
JLinkExe -if SWD -device ATSAMD51J20 -speed 4000 -autoconnect 1 -CommanderScript ./build-semihosting/scripts/firmware.jlink
131115
dockerinit:
132116
./scripts/container.sh build --pull --force-rm --no-cache -t shiftcrypto/firmware_v2:$(shell cat .containerversion) .
133117
dockerpull:
@@ -144,4 +128,4 @@ prepare-tidy: | build build-build
144128
make -C build rust-cbindgen
145129
make -C build-build rust-cbindgen
146130
clean:
147-
rm -rf build build-build build-semihosting build-build-rust-unit-tests
131+
rm -rf build build-build build-build-rust-unit-tests

scripts/jlink-gdb-debug/.gdbinit

Lines changed: 0 additions & 8 deletions
This file was deleted.

scripts/jlink-gdb-debug/README.md

Lines changed: 0 additions & 71 deletions
This file was deleted.

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));

0 commit comments

Comments
 (0)