Skip to content

Commit f600be8

Browse files
authored
Merge pull request #1410 from NickeZ/nickez/better-debug
DX: minor things
2 parents 5386733 + 738e083 commit f600be8

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

src/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,9 @@ if(CMAKE_CROSSCOMPILING)
532532
WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
533533
COMMENT "\nGenerating binary ${name}.bin"
534534
)
535-
# Fail on warnings for our builds
536-
target_compile_options(${name}.elf PRIVATE "-Werror")
535+
# Fail on warnings for our release builds
536+
if(NOT CMAKE_BUILD_TYPE STREQUAL "DEBUG")
537+
target_compile_options(${name}.elf PRIVATE "-Werror")
538+
endif()
537539
endforeach()
538540
endif()

src/hardfault.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#include "hardfault.h"
1616
#include "util.h"
17+
#include "utils_assert.h"
1718
#include <memory/memory.h>
1819
#include <platform_config.h>
1920
#include <screen.h>
@@ -43,6 +44,8 @@ void Abort(const char* msg)
4344
system_close_interfaces();
4445
#endif
4546
#endif
47+
// Break the program if we are debugging
48+
ASSERT(false);
4649
while (1) {
4750
}
4851
}

src/util.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ void util_uint8_to_hex(const uint8_t* in_bin, const size_t in_len, char* out)
4242
const char* util_dbg_hex(const uint8_t* bin, const size_t len)
4343
{
4444
if (len > UTIL_DBG_HEX_MAX_LEN) {
45-
util_log("len too large, %zu > %d", len, UTIL_DBG_HEX_MAX_LEN);
45+
util_log("len too large, %u > %d", (unsigned int)len, UTIL_DBG_HEX_MAX_LEN);
4646
}
4747
static char buf[UTIL_DBG_HEX_MAX_LEN * 2 + 1] = {0};
48-
util_uint8_to_hex(bin, len, buf);
48+
util_uint8_to_hex(bin, MIN(len, (unsigned int)UTIL_DBG_HEX_MAX_LEN), buf);
4949
return buf;
5050
}
5151

@@ -70,7 +70,7 @@ void util_cleanup_64(uint8_t** buf)
7070
}
7171

7272
// Max message size is MAX_LOG_LENGTH-1, becuase vsnprintf will always print a null character
73-
#define MAX_LOG_LENGTH 101
73+
#define MAX_LOG_LENGTH 200
7474

7575
void util_log(const char* fmt, ...)
7676
{

test/simulator/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ target_include_directories(
9494
bitbox_objects-simulator
9595
SYSTEM PUBLIC
9696
${CMAKE_SOURCE_DIR}/external
97+
${CMAKE_SOURCE_DIR}/external/asf4-drivers/hal/utils/include
9798
${CMAKE_SOURCE_DIR}/external/ctaes
9899
${CMAKE_SOURCE_DIR}/external/fatfs/source
99100
$<TARGET_PROPERTY:wallycore,INTERFACE_INCLUDE_DIRECTORIES>
@@ -113,6 +114,7 @@ target_include_directories(
113114
bitbox-simulator
114115
SYSTEM PUBLIC
115116
${CMAKE_SOURCE_DIR}/external
117+
${CMAKE_SOURCE_DIR}/external/asf4-drivers/hal/utils/include
116118
${CMAKE_SOURCE_DIR}/external/ctaes
117119
${CMAKE_SOURCE_DIR}/external/fatfs/source
118120
$<TARGET_PROPERTY:wallycore,INTERFACE_INCLUDE_DIRECTORIES>
@@ -140,13 +142,13 @@ add_dependencies(bitbox_objects-simulator
140142
target_link_libraries(bitbox-simulator PRIVATE ${LIBBITBOX02_RUST} "-lm")
141143

142144
target_compile_definitions(bitbox_objects-simulator PUBLIC "PRODUCT_BITBOX_MULTI=1" "APP_BTC=1" "APP_LTC=1" "APP_U2F=1" "APP_ETH=1")
143-
target_compile_definitions(bitbox_objects-simulator PUBLIC TESTING)
145+
target_compile_definitions(bitbox_objects-simulator PUBLIC TESTING _UNIT_TEST_)
144146

145147
# Since wallycore is an external projects we need to specify the dependency
146148
add_dependencies(bitbox_objects-simulator libwally-core)
147149

148150
target_compile_definitions(bitbox-simulator PUBLIC "PRODUCT_BITBOX_MULTI=1" "APP_BTC=1" "APP_LTC=1" "APP_U2F=1" "APP_ETH=1")
149-
target_compile_definitions(bitbox-simulator PUBLIC TESTING)
151+
target_compile_definitions(bitbox-simulator PUBLIC TESTING _UNIT_TEST_)
150152

151153
target_link_libraries(bitbox-simulator
152154
PUBLIC

test/unit-test/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ target_include_directories(
9999
bitbox_objects
100100
SYSTEM PUBLIC
101101
${CMAKE_SOURCE_DIR}/external
102+
${CMAKE_SOURCE_DIR}/external/asf4-drivers/hal/utils/include
102103
${CMAKE_SOURCE_DIR}/external/ctaes
103104
${CMAKE_SOURCE_DIR}/external/fatfs/source
104105
$<TARGET_PROPERTY:wallycore,INTERFACE_INCLUDE_DIRECTORIES>
@@ -118,6 +119,7 @@ target_include_directories(
118119
bitbox
119120
SYSTEM PUBLIC
120121
${CMAKE_SOURCE_DIR}/external
122+
${CMAKE_SOURCE_DIR}/external/asf4-drivers/hal/utils/include
121123
${CMAKE_SOURCE_DIR}/external/ctaes
122124
${CMAKE_SOURCE_DIR}/external/fatfs/source
123125
$<TARGET_PROPERTY:wallycore,INTERFACE_INCLUDE_DIRECTORIES>
@@ -145,13 +147,13 @@ add_dependencies(bitbox_objects
145147
target_link_libraries(bitbox PRIVATE ${LIBBITBOX02_RUST} "-lm")
146148

147149
target_compile_definitions(bitbox_objects PUBLIC "PRODUCT_BITBOX_MULTI=1" "APP_BTC=1" "APP_LTC=1" "APP_U2F=1" "APP_ETH=1")
148-
target_compile_definitions(bitbox_objects PUBLIC TESTING)
150+
target_compile_definitions(bitbox_objects PUBLIC TESTING _UNIT_TEST_)
149151

150152
# Since wallycore is an external projects we need to specify the dependency
151153
add_dependencies(bitbox_objects libwally-core)
152154

153155
target_compile_definitions(bitbox PUBLIC "PRODUCT_BITBOX_MULTI=1" "APP_BTC=1" "APP_LTC=1" "APP_U2F=1" "APP_ETH=1")
154-
target_compile_definitions(bitbox PUBLIC TESTING)
156+
target_compile_definitions(bitbox PUBLIC TESTING _UNIT_TEST_)
155157

156158
target_link_libraries(bitbox
157159
PUBLIC
@@ -195,7 +197,7 @@ target_include_directories(
195197
${INCLUDES}
196198
${CMAKE_BINARY_DIR}/src
197199
)
198-
target_compile_definitions(u2f-util PUBLIC "TESTING" PRODUCT_BITBOX_MULTI "APP_U2F=1" "APP_BTC=1" "APP_LTC=1" "APP_ETH=1")
200+
target_compile_definitions(u2f-util PUBLIC "TESTING" _UNIT_TEST_ PRODUCT_BITBOX_MULTI "APP_U2F=1" "APP_BTC=1" "APP_LTC=1" "APP_ETH=1")
199201
target_compile_definitions(u2f-util PUBLIC "USE_KECCAK")
200202

201203

0 commit comments

Comments
 (0)