summaryrefslogtreecommitdiff
path: root/source/application/hal/platforms/bare-metal/bsp/cmsis-device
diff options
context:
space:
mode:
authorKshitij Sisodia <kshitij.sisodia@arm.com>2021-05-07 16:08:14 +0100
committerKshitij Sisodia <kshitij.sisodia@arm.com>2021-05-07 17:28:51 +0100
commitf9c19eaa9ab11e4409679fc6d2862c89410493a7 (patch)
treeb791a4c03f1fe986a2ac32593a3dc817ae3f247a /source/application/hal/platforms/bare-metal/bsp/cmsis-device
parent2181d0ac35f30202985a877950c88325ff665f6b (diff)
downloadml-embedded-evaluation-kit-f9c19eaa9ab11e4409679fc6d2862c89410493a7.tar.gz
MLECO-1860: Support for Arm GNU Embedded Toolchain
This patch enables compilation of ML use cases bare-metal applications using Arm GNU Embedded Toolchain. The GNU toolchain can be used instead of the Arm Compiler that was already supported. The GNU toolchain is also set as the default toolchain when building applications for the MPS3 target. Note: The version of GNU toolchain must be 10.2.1 or higher. Change-Id: I5fff242f0f52d2db6c75d292f9fa990df1aec978 Signed-off-by: Kshitij Sisodia <kshitij.sisodia@arm.com>
Diffstat (limited to 'source/application/hal/platforms/bare-metal/bsp/cmsis-device')
-rw-r--r--source/application/hal/platforms/bare-metal/bsp/cmsis-device/cmsis.c22
-rw-r--r--source/application/hal/platforms/bare-metal/bsp/cmsis-device/irqs.c90
2 files changed, 44 insertions, 68 deletions
diff --git a/source/application/hal/platforms/bare-metal/bsp/cmsis-device/cmsis.c b/source/application/hal/platforms/bare-metal/bsp/cmsis-device/cmsis.c
index c9cf53d..b7f318c 100644
--- a/source/application/hal/platforms/bare-metal/bsp/cmsis-device/cmsis.c
+++ b/source/application/hal/platforms/bare-metal/bsp/cmsis-device/cmsis.c
@@ -24,9 +24,6 @@ extern void *__Vectors; /* see irqs.c */
#define __XTAL (25000000) /* Oscillator frequency */
#define __SYSTEM_CLOCK (__XTAL)
-#define STR(x) #x
-#define RESET_REG(n) __ASM volatile("MOV " STR(r##n) ", #0" : : : STR(r##n))
-
#if defined(CPU_CORTEX_M55)
#define CCR_DL (1 << 19)
#else
@@ -69,25 +66,6 @@ void SystemInit(void)
(3U << 11U*2U) );
#endif
- /* Initialise registers r0-r12 and LR(=r14)
- * They must have a valid value before being potentially pushed to stack by
- * C calling convention or by context saving in exception handling
- */
- RESET_REG(0);
- RESET_REG(1);
- RESET_REG(2);
- RESET_REG(3);
- RESET_REG(4);
- RESET_REG(5);
- RESET_REG(6);
- RESET_REG(7);
- RESET_REG(8);
- RESET_REG(9);
- RESET_REG(10);
- RESET_REG(11);
- RESET_REG(12);
- RESET_REG(14);
-
#if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U)
SCB->VTOR = (uint32_t) &__Vectors;
#endif
diff --git a/source/application/hal/platforms/bare-metal/bsp/cmsis-device/irqs.c b/source/application/hal/platforms/bare-metal/bsp/cmsis-device/irqs.c
index c6f54b1..7c9f4b8 100644
--- a/source/application/hal/platforms/bare-metal/bsp/cmsis-device/irqs.c
+++ b/source/application/hal/platforms/bare-metal/bsp/cmsis-device/irqs.c
@@ -23,24 +23,36 @@ extern "C"
#include "cmsis.h"
#include <stdio.h>
+#include <inttypes.h>
static uint64_t cpu_cycle_count = 0;
/**
+ * External references
+ */
+extern uint32_t __INITIAL_SP;
+extern uint32_t __STACK_LIMIT;
+
+#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
+ extern uint32_t __STACK_SEAL;
+#endif
+
+extern __NO_RETURN void __PROGRAM_START(void);
+
+/**
* @brief Dump core registers on stdout
*/
static void LogCoreCPURegisters(void)
{
- printf("CTRL : 0x%08x\n", __get_CONTROL());
- printf("IPSR : 0x%08x\n", __get_IPSR());
- printf("APSR : 0x%08x\n", __get_APSR());
- printf("xPSR : 0x%08x\n", __get_xPSR());
- printf("PSP : 0x%08x\n", __get_PSP());
- printf("MSP : 0x%08x\n", __get_MSP());
- printf("PRIMASK : 0x%08x\n", __get_PRIMASK());
- printf("BASEPRI : 0x%08x\n", __get_BASEPRI());
- printf("FAULTMSK: 0x%08x\n", __get_FAULTMASK());
- printf("PC : 0x%08x\n", __current_pc());
+ printf("CTRL : 0x%08" PRIx32 "\n", __get_CONTROL());
+ printf("IPSR : 0x%08" PRIx32 "\n", __get_IPSR());
+ printf("APSR : 0x%08" PRIx32 "\n", __get_APSR());
+ printf("xPSR : 0x%08" PRIx32 "\n", __get_xPSR());
+ printf("PSP : 0x%08" PRIx32 "\n", __get_PSP());
+ printf("MSP : 0x%08" PRIx32 "\n", __get_MSP());
+ printf("PRIMASK : 0x%08" PRIx32 "\n", __get_PRIMASK());
+ printf("BASEPRI : 0x%08" PRIx32 "\n", __get_BASEPRI());
+ printf("FAULTMSK: 0x%08" PRIx32 "\n", __get_FAULTMASK());
}
/**
@@ -158,6 +170,9 @@ void SysTick_Handler(void)
cpu_cycle_count += SysTick->LOAD + 1;
}
+/**
+ * Gets the current SysTick derived counter value
+ */
uint64_t Get_SysTick_Cycle_Count(void)
{
uint32_t systick_val;
@@ -169,47 +184,27 @@ uint64_t Get_SysTick_Cycle_Count(void)
return cpu_cycle_count + (SysTick->LOAD - systick_val);
}
-
-/**
- * These symbols are provided by the ARM lib - needs the stack and heap
- * regions in the scatter file.
- */
-extern void Image$$ARM_LIB_STACK$$ZI$$Base();
-extern void Image$$ARM_LIB_STACK$$ZI$$Limit();
-extern void Image$$ARM_LIB_HEAP$$ZI$$Base();
-extern void Image$$ARM_LIB_HEAP$$ZI$$Limit();
-extern __attribute__((noreturn)) void __main();
-
-__attribute__((naked, used)) void __user_setup_stackheap()
-{
- __ASM volatile("LDR r0, =Image$$ARM_LIB_HEAP$$ZI$$Base");
- __ASM volatile("LDR r1, =Image$$ARM_LIB_STACK$$ZI$$Limit");
- __ASM volatile("LDR r2, =Image$$ARM_LIB_HEAP$$ZI$$Limit");
- __ASM volatile("LDR r3, =Image$$ARM_LIB_STACK$$ZI$$Base");
- __ASM volatile("bx lr");
-}
-
/**
* Interrupt vector table.
*/
-irq_vec_type __Vectors[] __attribute__((section("RESET"), used)) = {
- &Image$$ARM_LIB_STACK$$ZI$$Limit, /* 0 Initial SP */
- &Reset_Handler , /* 1 Initial PC, set to entry point */
-
- &NMI_Handler , /* 2 (-14) NMI Handler */
- &HardFault_Handler , /* 3 (-13) Hard Fault Handler */
- &MemManage_Handler , /* 4 (-12) MPU Fault Handler */
- &BusFault_Handler , /* 5 (-11) Bus Fault Handler */
- &UsageFault_Handler , /* 6 (-10) Usage Fault Handler */
- &SecureFault_Handler, /* 7 ( -9) Secure Fault Handler */
+irq_vec_type __VECTOR_TABLE[] __VECTOR_TABLE_ATTRIBUTE = {
+ (irq_vec_type)(&__INITIAL_SP), /* Initial Stack Pointer */
+ Reset_Handler , /* 1 Initial PC, set to entry point */
+
+ NMI_Handler , /* 2 (-14) NMI Handler */
+ HardFault_Handler , /* 3 (-13) Hard Fault Handler */
+ MemManage_Handler , /* 4 (-12) MPU Fault Handler */
+ BusFault_Handler , /* 5 (-11) Bus Fault Handler */
+ UsageFault_Handler , /* 6 (-10) Usage Fault Handler */
+ SecureFault_Handler, /* 7 ( -9) Secure Fault Handler */
0 , /* 8 ( -8) Reserved */
0 , /* 9 ( -7) Reserved */
0 , /* 10 ( -6) Reserved */
- &SVC_Handler , /* 11 ( -5) SVCall Handler */
- &DebugMon_Handler , /* 12 ( -4) Debug Monitor Handler */
+ SVC_Handler , /* 11 ( -5) SVCall Handler */
+ DebugMon_Handler , /* 12 ( -4) Debug Monitor Handler */
0 , /* 13 ( -3) Reserved */
- &PendSV_Handler , /* 14 ( -2) PendSV Handler */
- &SysTick_Handler , /* 15 ( -1) SysTick Handler */
+ PendSV_Handler , /* 14 ( -2) PendSV Handler */
+ SysTick_Handler , /* 15 ( -1) SysTick Handler */
/* External sources to be populated by user. */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0 - 16 */
@@ -222,6 +217,9 @@ irq_vec_type __Vectors[] __attribute__((section("RESET"), used)) = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 112 - 128 */
};
+/**
+ * SysTick initialisation
+ */
int Init_SysTick(void)
{
const uint32_t ticks_10ms = GetSystemCoreClock()/100 + 1;
@@ -252,8 +250,8 @@ __attribute__((used)) void Reset_Handler(void)
/* Configure the system tick. */
Init_SysTick();
- /* libcxx supplied entry point. */
- __main();
+ /* cmsis supplied entry point. */
+ __PROGRAM_START();
}
#ifdef __cplusplus