File tree 5 files changed +29
-6
lines changed
libraries/SrcWrapper/src/stm32
5 files changed +29
-6
lines changed Original file line number Diff line number Diff line change 1
1
#ifndef _CORE_DEBUG_H
2
2
#define _CORE_DEBUG_H
3
- #ifdef CORE_DEBUG
3
+ #if !defined( NDEBUG )
4
4
#include <stdio.h>
5
5
#include <stdarg.h>
6
- #endif /* CORE_DEBUG */
6
+ #endif /* NDEBUG */
7
7
8
8
#ifdef __cplusplus
9
9
extern "C" {
@@ -18,14 +18,14 @@ extern "C" {
18
18
*/
19
19
static inline void core_debug (const char * format , ...)
20
20
{
21
- #ifdef CORE_DEBUG
21
+ #if !defined( NDEBUG )
22
22
va_list args ;
23
23
va_start (args , format );
24
24
vfprintf (stderr , format , args );
25
25
va_end (args );
26
26
#else
27
27
(void )(format );
28
- #endif /* CORE_DEBUG */
28
+ #endif /* NDEBUG */
29
29
}
30
30
31
31
#ifdef __cplusplus
Original file line number Diff line number Diff line change @@ -77,9 +77,22 @@ extern "C" {
77
77
// weaked functions declaration
78
78
void SystemClock_Config (void );
79
79
80
- void _Error_Handler (const char * , int );
80
+ #if defined(NDEBUG )
81
+ #if !defined(_Error_Handler )
82
+ #define _Error_Handler (str , value ); \
83
+ while (1) {\
84
+ }
85
+ #endif
86
+ #if !defined(Error_Handler )
87
+ #define Error_Handler () \
88
+ while (1) {\
89
+ }
90
+ #endif
91
+ #else
92
+ void _Error_Handler (const char * , int );
81
93
82
- #define Error_Handler () _Error_Handler(__FILE__, __LINE__)
94
+ #define Error_Handler () _Error_Handler(__FILE__, __LINE__)
95
+ #endif
83
96
84
97
#ifdef __cplusplus
85
98
} // extern "C"
Original file line number Diff line number Diff line change
1
+
1
2
#include "stm32_def.h"
2
3
#include "core_debug.h"
3
4
@@ -10,13 +11,15 @@ extern "C" {
10
11
* @param None
11
12
* @retval None
12
13
*/
14
+ #if !defined(NDEBUG )
13
15
WEAK void _Error_Handler (const char * msg , int val )
14
16
{
15
17
/* User can add his own implementation to report the HAL error return state */
16
18
core_debug ("Error: %s (%i)\n" , msg , val );
17
19
while (1 ) {
18
20
}
19
21
}
22
+ #endif
20
23
21
24
#ifdef __cplusplus
22
25
}
Original file line number Diff line number Diff line change @@ -99,6 +99,7 @@ build.enable_virtio=
99
99
build.startup_file=
100
100
build.flags.fp=
101
101
build.flags.optimize=-Os
102
+ build.flags.debug=-DNDEBUG
102
103
build.flags.ldspecs=--specs=nano.specs
103
104
build.flash_offset=0
104
105
Original file line number Diff line number Diff line change 2
2
3
3
BUILD_PATH=" $1 "
4
4
BUILD_SOURCE_PATH=" $2 "
5
+ BOARD_PLATFORM_PATH=" $3 "
5
6
6
7
# Create sketch dir if not exists
7
8
if [ ! -f " $BUILD_PATH /sketch" ]; then
@@ -13,5 +14,10 @@ if [ ! -f "$BUILD_SOURCE_PATH/build_opt.h" ]; then
13
14
touch " $BUILD_PATH /sketch/build_opt.h"
14
15
fi
15
16
17
+ # Append -fmacro-prefix-map option to change __FILE__ absolute path of the board
18
+ # platform folder to a relative path by using '.'.
19
+ # (i.e. the folder containing boards.txt)
20
+ printf ' \n-fmacro-prefix-map=%s=.' " ${BOARD_PLATFORM_PATH// \\ / \\\\ } " > " $BUILD_PATH /sketch/build.opt"
21
+
16
22
# Force include of SrcWrapper library
17
23
echo " #include <SrcWrapper.h>" > " $BUILD_PATH /sketch/SrcWrapper.cpp"
You can’t perform that action at this time.
0 commit comments