summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKshitij Sisodia <kshitij.sisodia@arm.com>2022-03-01 10:23:11 +0000
committerKshitij Sisodia <kshitij.sisodia@arm.com>2022-03-01 10:23:11 +0000
commitacc6b85c0086ff4a37d2108ec9edfb8faf6f43e6 (patch)
tree1984577ca6ff33fd6f26e9f6370668c66e73fda8
parentee4920b338f7d1e690377093bcfaaf0ba203bff0 (diff)
downloadml-embedded-evaluation-kit-acc6b85c0086ff4a37d2108ec9edfb8faf6f43e6.tar.gz
MLECO-2983: Preliminary support to allow semihosting
Adding basic support to allow applications to build with semihosting support. Default state is always disabled. Signed-off-by: Kshitij Sisodia <kshitij.sisodia@arm.com> Change-Id: I1d34c3a246560aaffcb34eee801e1a87d887d559
-rw-r--r--scripts/cmake/toolchains/bare-metal-armclang.cmake6
-rw-r--r--scripts/cmake/toolchains/bare-metal-gcc.cmake12
-rw-r--r--source/hal/cmsis_device/CMakeLists.txt7
-rw-r--r--source/hal/platform/mps3/source/platform_drivers.c2
-rw-r--r--source/hal/profiles/bare-metal/bsp/retarget.c3
5 files changed, 27 insertions, 3 deletions
diff --git a/scripts/cmake/toolchains/bare-metal-armclang.cmake b/scripts/cmake/toolchains/bare-metal-armclang.cmake
index 065395b..9752053 100644
--- a/scripts/cmake/toolchains/bare-metal-armclang.cmake
+++ b/scripts/cmake/toolchains/bare-metal-armclang.cmake
@@ -96,6 +96,12 @@ add_link_options(
--xref
"$<$<CONFIG:RELEASE>:--no_debug>")
+function(configure_semihosting TARGET_NAME SEMIHOSTING)
+ if (${SEMIHOSTING})
+ target_compile_definitions(${TARGET_NAME} PUBLIC USE_SEMIHOSTING)
+ endif()
+endfunction()
+
# Function to add a map file output for the linker to dump diagnostic information to.
function(add_target_map_file TARGET_NAME MAP_FILE_PATH)
target_link_options(${TARGET_NAME} PUBLIC
diff --git a/scripts/cmake/toolchains/bare-metal-gcc.cmake b/scripts/cmake/toolchains/bare-metal-gcc.cmake
index 89201fb..a5688d6 100644
--- a/scripts/cmake/toolchains/bare-metal-gcc.cmake
+++ b/scripts/cmake/toolchains/bare-metal-gcc.cmake
@@ -85,11 +85,21 @@ add_link_options(
-mcpu=${CPU_NAME}
-mfloat-abi=${FLOAT_ABI}
-mlittle-endian
- --specs=nosys.specs
--stats
"SHELL:-Xlinker --gc-sections"
"$<$<CONFIG:RELEASE>:--no-debug>")
+function(configure_semihosting TARGET_NAME SEMIHOSTING)
+ if (${SEMIHOSTING})
+ target_link_options(${TARGET_NAME} PUBLIC "--specs=rdimon.specs")
+ target_compile_options(${TARGET_NAME} PUBLIC "--specs=rdimon.specs")
+ target_compile_definitions(${TARGET_NAME} PUBLIC USE_SEMIHOSTING)
+ else()
+ target_link_options(${TARGET_NAME} PUBLIC --specs=nosys.specs)
+ target_compile_options(${TARGET_NAME} PUBLIC "--specs=nosys.specs")
+ endif()
+endfunction()
+
# Function to add a map file output for the linker to dump diagnostic information to.
function(add_target_map_file TARGET_NAME MAP_FILE_PATH)
target_link_options(${TARGET_NAME} PUBLIC
diff --git a/source/hal/cmsis_device/CMakeLists.txt b/source/hal/cmsis_device/CMakeLists.txt
index 255bd30..b98feb2 100644
--- a/source/hal/cmsis_device/CMakeLists.txt
+++ b/source/hal/cmsis_device/CMakeLists.txt
@@ -56,13 +56,18 @@ target_sources(${CMSIS_DEVICE_TARGET}
# Device definition needs to be set, is checked in source files to include correct header
target_compile_definitions(${CMSIS_DEVICE_TARGET} PUBLIC ${ARM_CPU})
-
# Tell linker that reset interrupt handler is our entry point
target_link_options(
${CMSIS_DEVICE_TARGET}
INTERFACE
--entry Reset_Handler)
+# Check if semihosting configuration is available
+if (COMMAND configure_semihosting)
+ option(USE_SEMIHOSTING "Enable/disable semihosting option" OFF)
+ configure_semihosting(${CMSIS_DEVICE_TARGET} ${USE_SEMIHOSTING})
+endif()
+
# 4 Display status:
message(STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR})
message(STATUS "*******************************************************")
diff --git a/source/hal/platform/mps3/source/platform_drivers.c b/source/hal/platform/mps3/source/platform_drivers.c
index 3046c12..fc119ab 100644
--- a/source/hal/platform/mps3/source/platform_drivers.c
+++ b/source/hal/platform/mps3/source/platform_drivers.c
@@ -17,9 +17,9 @@
#include "platform_drivers.h"
-#include "uart_stdout.h" /* stdout over UART. */
#include "log_macros.h" /* Logging functions */
#include "device_mps3.h" /* FPGA level definitions and functions. */
+#include "uart_stdout.h" /* stdout over UART. */
#include <string.h> /* For strncpy */
diff --git a/source/hal/profiles/bare-metal/bsp/retarget.c b/source/hal/profiles/bare-metal/bsp/retarget.c
index dfef62c..9ed3004 100644
--- a/source/hal/profiles/bare-metal/bsp/retarget.c
+++ b/source/hal/profiles/bare-metal/bsp/retarget.c
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+#if !defined(USE_SEMIHOSTING)
#include "uart_stdout.h"
@@ -266,3 +267,5 @@ int ferror(FILE *f)
}
#endif /* #ifndef ferror */
+
+#endif /* !defined(USE_SEMIHOSTING) */