From 6c0e1186be9b8a7cff26fa8514d3ce7cdde4ea22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20T=C3=B6rnblom?= Date: Thu, 18 Nov 2021 09:46:24 +0100 Subject: [PATCH] DSP: Add IAR tool chain (#1367) Signed-off-by: TTornblom --- Platforms/FVP/ARMCM0/Include/system_ARMCM0.h | 15 +- Platforms/FVP/ARMCM0/LinkScripts/IAR/lnk.icf | 175 ++++++++++++++ .../FVP/ARMCM0/LinkScripts/IAR/mem_ARMCM0.h | 38 +++ .../FVP/ARMCM0/Startup/IAR/startup_ARMCM0.c | 146 ++++++++++++ Platforms/FVP/ARMCM0/system_ARMCM0.c | 130 +++++----- .../FVP/ARMCM33/Include/system_ARMCM33.h | 15 +- Platforms/FVP/ARMCM33/LinkScripts/IAR/lnk.icf | 55 +++++ .../FVP/ARMCM33/LinkScripts/IAR/mem_ARMCM33.h | 38 +++ .../FVP/ARMCM33/Startup/IAR/startup_ARMCM33.c | 170 +++++++++++++ Platforms/FVP/ARMCM33/system_ARMCM33.c | 14 ++ Platforms/FVP/ARMCM4/Include/system_ARMCM4.h | 15 +- Platforms/FVP/ARMCM4/LinkScripts/IAR/lnk.icf | 175 ++++++++++++++ .../FVP/ARMCM4/LinkScripts/IAR/mem_ARMCM4.h | 38 +++ .../FVP/ARMCM4/Startup/IAR/startup_ARMCM4.c | 152 ++++++++++++ Platforms/FVP/ARMCM4/system_ARMCM4.c | 8 + Platforms/FVP/ARMCM7/Include/system_ARMCM7.h | 15 +- Platforms/FVP/ARMCM7/LinkScripts/IAR/lnk.icf | 55 +++++ .../FVP/ARMCM7/LinkScripts/IAR/mem_ARMCM7.h | 38 +++ .../FVP/ARMCM7/Startup/IAR/startup_ARMCM7.c | 154 ++++++++++++ Platforms/FVP/ARMCM7/system_ARMCM7.c | 10 +- .../FVP/ARMv81MML/Include/system_ARMv81MML.h | 14 +- .../FVP/ARMv81MML/LinkScripts/IAR/lnk.icf | 55 +++++ .../ARMv81MML/LinkScripts/IAR/mem_ARMv81MML.h | 38 +++ .../ARMv81MML/Startup/IAR/startup_ARMv81MML.c | 164 +++++++++++++ Platforms/FVP/ARMv81MML/system_ARMv81MML.c | 10 + Toolchain/ICCARM.cmake | 225 ++++++++++++++++++ Toolchain/Tools.cmake | 6 +- iccarm.cmake | 62 +++++ 28 files changed, 1948 insertions(+), 82 deletions(-) create mode 100644 Platforms/FVP/ARMCM0/LinkScripts/IAR/lnk.icf create mode 100644 Platforms/FVP/ARMCM0/LinkScripts/IAR/mem_ARMCM0.h create mode 100644 Platforms/FVP/ARMCM0/Startup/IAR/startup_ARMCM0.c create mode 100644 Platforms/FVP/ARMCM33/LinkScripts/IAR/lnk.icf create mode 100644 Platforms/FVP/ARMCM33/LinkScripts/IAR/mem_ARMCM33.h create mode 100644 Platforms/FVP/ARMCM33/Startup/IAR/startup_ARMCM33.c create mode 100644 Platforms/FVP/ARMCM4/LinkScripts/IAR/lnk.icf create mode 100644 Platforms/FVP/ARMCM4/LinkScripts/IAR/mem_ARMCM4.h create mode 100644 Platforms/FVP/ARMCM4/Startup/IAR/startup_ARMCM4.c create mode 100644 Platforms/FVP/ARMCM7/LinkScripts/IAR/lnk.icf create mode 100644 Platforms/FVP/ARMCM7/LinkScripts/IAR/mem_ARMCM7.h create mode 100644 Platforms/FVP/ARMCM7/Startup/IAR/startup_ARMCM7.c create mode 100644 Platforms/FVP/ARMv81MML/LinkScripts/IAR/lnk.icf create mode 100644 Platforms/FVP/ARMv81MML/LinkScripts/IAR/mem_ARMv81MML.h create mode 100644 Platforms/FVP/ARMv81MML/Startup/IAR/startup_ARMv81MML.c create mode 100644 Toolchain/ICCARM.cmake create mode 100644 iccarm.cmake diff --git a/Platforms/FVP/ARMCM0/Include/system_ARMCM0.h b/Platforms/FVP/ARMCM0/Include/system_ARMCM0.h index 7fe7e914..b6ccb315 100755 --- a/Platforms/FVP/ARMCM0/Include/system_ARMCM0.h +++ b/Platforms/FVP/ARMCM0/Include/system_ARMCM0.h @@ -2,11 +2,11 @@ * @file system_ARMCM0.h * @brief CMSIS Device System Header File for * ARMCM0 Device - * @version V5.3.1 - * @date 09. July 2018 + * @version V5.3.2 + * @date 15. November 2019 ******************************************************************************/ /* - * Copyright (c) 2009-2018 Arm Limited. All rights reserved. + * Copyright (c) 2009-2019 Arm Limited. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * @@ -30,8 +30,15 @@ extern "C" { #endif -extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + \brief Exception / Interrupt Handler Function Prototype +*/ +typedef void(*VECTOR_TABLE_Type)(void); +/** + \brief System Clock Frequency (Core Clock) +*/ +extern uint32_t SystemCoreClock; /** \brief Setup the microcontroller system. diff --git a/Platforms/FVP/ARMCM0/LinkScripts/IAR/lnk.icf b/Platforms/FVP/ARMCM0/LinkScripts/IAR/lnk.icf new file mode 100644 index 00000000..113198fb --- /dev/null +++ b/Platforms/FVP/ARMCM0/LinkScripts/IAR/lnk.icf @@ -0,0 +1,175 @@ +/*###ICF### Section handled by ICF editor, don't touch! ****/ +/*-Editor annotation file-*/ +/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\a_v1_1.xml" */ +/*-Specials-*/ +define symbol __ICFEDIT_intvec_start__ = 0x00000000; +/*-Memory Regions-*/ +define symbol __ICFEDIT_region_IROM1_start__ = 0x00000080; +define symbol __ICFEDIT_region_IROM1_end__ = 0x002FFFFF; +define symbol __ICFEDIT_region_IROM2_start__ = 0x0; +define symbol __ICFEDIT_region_IROM2_end__ = 0x0; +define symbol __ICFEDIT_region_EROM1_start__ = 0x0; +define symbol __ICFEDIT_region_EROM1_end__ = 0x0; +define symbol __ICFEDIT_region_EROM2_start__ = 0x0; +define symbol __ICFEDIT_region_EROM2_end__ = 0x0; +define symbol __ICFEDIT_region_EROM3_start__ = 0x0; +define symbol __ICFEDIT_region_EROM3_end__ = 0x0; +define symbol __ICFEDIT_region_IRAM1_start__ = 0x20000000; +define symbol __ICFEDIT_region_IRAM1_end__ = 0x001FFFFF; +define symbol __ICFEDIT_region_IRAM2_start__ = 0x0; +define symbol __ICFEDIT_region_IRAM2_end__ = 0x0; +define symbol __ICFEDIT_region_ERAM1_start__ = 0x0; +define symbol __ICFEDIT_region_ERAM1_end__ = 0x0; +define symbol __ICFEDIT_region_ERAM2_start__ = 0x0; +define symbol __ICFEDIT_region_ERAM2_end__ = 0x0; +define symbol __ICFEDIT_region_ERAM3_start__ = 0x0; +define symbol __ICFEDIT_region_ERAM3_end__ = 0x0; +/*-Sizes-*/ +define symbol __ICFEDIT_size_cstack__ = 0x2000; +define symbol __ICFEDIT_size_svcstack__ = 0x100; +define symbol __ICFEDIT_size_irqstack__ = 0x100; +define symbol __ICFEDIT_size_fiqstack__ = 0x100; +define symbol __ICFEDIT_size_undstack__ = 0x100; +define symbol __ICFEDIT_size_abtstack__ = 0x100; +define symbol __ICFEDIT_size_heap__ = 0x8000; +/**** End of ICF editor section. ###ICF###*/ + +define memory mem with size = 4G; +define symbol use_IROM1 = (__ICFEDIT_region_IROM1_start__ != 0x0 || __ICFEDIT_region_IROM1_end__ != 0x0); +define symbol use_IROM2 = (__ICFEDIT_region_IROM2_start__ != 0x0 || __ICFEDIT_region_IROM2_end__ != 0x0); +define symbol use_EROM1 = (__ICFEDIT_region_EROM1_start__ != 0x0 || __ICFEDIT_region_EROM1_end__ != 0x0); +define symbol use_EROM2 = (__ICFEDIT_region_EROM2_start__ != 0x0 || __ICFEDIT_region_EROM2_end__ != 0x0); +define symbol use_EROM3 = (__ICFEDIT_region_EROM3_start__ != 0x0 || __ICFEDIT_region_EROM3_end__ != 0x0); +define symbol use_IRAM1 = (__ICFEDIT_region_IRAM1_start__ != 0x0 || __ICFEDIT_region_IRAM1_end__ != 0x0); +define symbol use_IRAM2 = (__ICFEDIT_region_IRAM2_start__ != 0x0 || __ICFEDIT_region_IRAM2_end__ != 0x0); +define symbol use_ERAM1 = (__ICFEDIT_region_ERAM1_start__ != 0x0 || __ICFEDIT_region_ERAM1_end__ != 0x0); +define symbol use_ERAM2 = (__ICFEDIT_region_ERAM2_start__ != 0x0 || __ICFEDIT_region_ERAM2_end__ != 0x0); +define symbol use_ERAM3 = (__ICFEDIT_region_ERAM3_start__ != 0x0 || __ICFEDIT_region_ERAM3_end__ != 0x0); + +if (use_IROM1) +{ + define region IROM1_region = mem:[from __ICFEDIT_region_IROM1_start__ to __ICFEDIT_region_IROM1_end__]; +} +else +{ + define region IROM1_region = []; +} + +if (use_IROM2) +{ + define region IROM2_region = mem:[from __ICFEDIT_region_IROM2_start__ to __ICFEDIT_region_IROM2_end__]; +} +else +{ + define region IROM2_region = []; +} +define region IROM_region = IROM1_region | IROM2_region; + +if (use_EROM1) +{ + define region EROM1_region = mem:[from __ICFEDIT_region_EROM1_start__ to __ICFEDIT_region_EROM1_end__]; +} +else +{ + define region EROM1_region = []; +} +if (use_EROM2) +{ + define region EROM2_region = mem:[from __ICFEDIT_region_EROM2_start__ to __ICFEDIT_region_EROM2_end__]; +} +else +{ + define region EROM2_region = []; +} +if (use_EROM3) +{ + define region EROM3_region = mem:[from __ICFEDIT_region_EROM3_start__ to __ICFEDIT_region_EROM3_end__]; +} +else +{ + define region EROM3_region = []; +} +define region EROM_region = EROM1_region | EROM2_region | EROM3_region; + +if (use_IRAM1) +{ + define region IRAM1_region = mem:[from __ICFEDIT_region_IRAM1_start__ to __ICFEDIT_region_IRAM1_end__]; +} +else +{ + define region IRAM1_region = []; +} +if (use_IRAM2) +{ + define region IRAM2_region = mem:[from __ICFEDIT_region_IRAM2_start__ to __ICFEDIT_region_IRAM2_end__]; +} +else +{ + define region IRAM2_region = []; +} +define region IRAM_region = IRAM1_region | IRAM2_region; + +if (use_ERAM1) +{ + define region ERAM1_region = mem:[from __ICFEDIT_region_ERAM1_start__ to __ICFEDIT_region_ERAM1_end__]; +} +else +{ + define region ERAM1_region = []; +} +if (use_ERAM2) +{ + define region ERAM2_region = mem:[from __ICFEDIT_region_ERAM2_start__ to __ICFEDIT_region_ERAM2_end__]; +} +else +{ + define region ERAM2_region = []; +} +if (use_ERAM3) +{ + define region ERAM3_region = mem:[from __ICFEDIT_region_ERAM3_start__ to __ICFEDIT_region_ERAM3_end__]; +} +else +{ + define region ERAM3_region = []; +} +define region ERAM_region = ERAM1_region | ERAM2_region | ERAM3_region; + +do not initialize { section .noinit }; +initialize by copy { readwrite }; +if (isdefinedsymbol(__USE_DLIB_PERTHREAD)) +{ + // Required in a multi-threaded application + initialize by copy with packing = none { section __DLIB_PERTHREAD }; +} + +place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec }; + +if (!isempty(IROM_region)) +{ + place in IROM_region { readonly }; +} + +if (!isempty(EROM_region)) +{ + place in EROM_region { readonly section application_specific_ro }; +} + +if (!isempty(IRAM_region)) +{ + define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { }; + define block SVC_STACK with alignment = 8, size = __ICFEDIT_size_svcstack__ { }; + define block IRQ_STACK with alignment = 8, size = __ICFEDIT_size_irqstack__ { }; + define block FIQ_STACK with alignment = 8, size = __ICFEDIT_size_fiqstack__ { }; + define block UND_STACK with alignment = 8, size = __ICFEDIT_size_undstack__ { }; + define block ABT_STACK with alignment = 8, size = __ICFEDIT_size_abtstack__ { }; + define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { }; + place in IRAM_region { readwrite, + block CSTACK, block SVC_STACK, block IRQ_STACK, block FIQ_STACK, + block UND_STACK, block ABT_STACK, block HEAP }; +} + +if (!isempty(ERAM_region)) +{ + place in ERAM_region { readwrite section application_specific_rw }; +} diff --git a/Platforms/FVP/ARMCM0/LinkScripts/IAR/mem_ARMCM0.h b/Platforms/FVP/ARMCM0/LinkScripts/IAR/mem_ARMCM0.h new file mode 100644 index 00000000..84a1ff1d --- /dev/null +++ b/Platforms/FVP/ARMCM0/LinkScripts/IAR/mem_ARMCM0.h @@ -0,0 +1,38 @@ +/**************************************************************************//** + * @file mem_ARMCM7.h + * @brief Memory base and size definitions (used in scatter file) + * @version V1.1.0 + * @date 15. May 2019 + * + * @note + * + ******************************************************************************/ +/* + * Copyright (c) 2009-2019 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __MEM_ARMCM7_H +#define __MEM_ARMCM7_H + + + +#define STACK_SIZE 0x00003000 +#define HEAP_SIZE 0x00100000 + + + +#endif /* __MEM_ARMCM7_H */ diff --git a/Platforms/FVP/ARMCM0/Startup/IAR/startup_ARMCM0.c b/Platforms/FVP/ARMCM0/Startup/IAR/startup_ARMCM0.c new file mode 100644 index 00000000..fb321109 --- /dev/null +++ b/Platforms/FVP/ARMCM0/Startup/IAR/startup_ARMCM0.c @@ -0,0 +1,146 @@ +/****************************************************************************** + * @file startup_ARMCM0.c + * @brief CMSIS-Core(M) Device Startup File for a Cortex-M0 Device + * @version V2.0.3 + * @date 31. March 2020 + ******************************************************************************/ +/* + * Copyright (c) 2009-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined (ARMCM0) + #include "ARMCM0.h" +#else + #error device not specified! +#endif + +/*---------------------------------------------------------------------------- + External References + *----------------------------------------------------------------------------*/ +extern uint32_t __INITIAL_SP; + +extern __NO_RETURN void __PROGRAM_START(void); + +/*---------------------------------------------------------------------------- + Internal References + *----------------------------------------------------------------------------*/ +__NO_RETURN void Reset_Handler (void); + void Default_Handler(void); + +/*---------------------------------------------------------------------------- + Exception / Interrupt Handler + *----------------------------------------------------------------------------*/ +/* Exceptions */ +void NMI_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void HardFault_Handler (void) __attribute__ ((weak)); +void SVC_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void PendSV_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void SysTick_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); + +void Interrupt0_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt1_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt2_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt3_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt4_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt5_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt6_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt7_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt8_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt9_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); + + +/*---------------------------------------------------------------------------- + Exception / Interrupt Vector table + *----------------------------------------------------------------------------*/ + +#if defined ( __GNUC__ ) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpedantic" +#endif + +extern const VECTOR_TABLE_Type __VECTOR_TABLE[48]; + const VECTOR_TABLE_Type __VECTOR_TABLE[48] __VECTOR_TABLE_ATTRIBUTE = { + (VECTOR_TABLE_Type)(&__INITIAL_SP), /* Initial Stack Pointer */ + Reset_Handler, /* Reset Handler */ + NMI_Handler, /* -14 NMI Handler */ + HardFault_Handler, /* -13 Hard Fault Handler */ + 0, /* Reserved */ + 0, /* Reserved */ + 0, /* Reserved */ + 0, /* Reserved */ + 0, /* Reserved */ + 0, /* Reserved */ + 0, /* Reserved */ + SVC_Handler, /* -5 SVCall Handler */ + 0, /* Reserved */ + 0, /* Reserved */ + PendSV_Handler, /* -2 PendSV Handler */ + SysTick_Handler, /* -1 SysTick Handler */ + + /* Interrupts */ + Interrupt0_Handler, /* 0 Interrupt 0 */ + Interrupt1_Handler, /* 1 Interrupt 1 */ + Interrupt2_Handler, /* 2 Interrupt 2 */ + Interrupt3_Handler, /* 3 Interrupt 3 */ + Interrupt4_Handler, /* 4 Interrupt 4 */ + Interrupt5_Handler, /* 5 Interrupt 5 */ + Interrupt6_Handler, /* 6 Interrupt 6 */ + Interrupt7_Handler, /* 7 Interrupt 7 */ + Interrupt8_Handler, /* 8 Interrupt 8 */ + Interrupt9_Handler /* 9 Interrupt 9 */ + /* Interrupts 10..31 are left out */ +}; + +#if defined ( __GNUC__ ) +#pragma GCC diagnostic pop +#endif + +/*---------------------------------------------------------------------------- + Reset Handler called on controller reset + *----------------------------------------------------------------------------*/ +__NO_RETURN void Reset_Handler(void) +{ + SystemInit(); /* CMSIS System Initialization */ + __PROGRAM_START(); /* Enter PreMain (C library entry point) */ +} + + +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wmissing-noreturn" +#endif + +/*---------------------------------------------------------------------------- + Hard Fault Handler + *----------------------------------------------------------------------------*/ +void HardFault_Handler(void) +{ + while(1); +} + +/*---------------------------------------------------------------------------- + Default Handler for Exceptions / Interrupts + *----------------------------------------------------------------------------*/ +void Default_Handler(void) +{ + while(1); +} + +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic pop +#endif + diff --git a/Platforms/FVP/ARMCM0/system_ARMCM0.c b/Platforms/FVP/ARMCM0/system_ARMCM0.c index 00230143..b63c3682 100755 --- a/Platforms/FVP/ARMCM0/system_ARMCM0.c +++ b/Platforms/FVP/ARMCM0/system_ARMCM0.c @@ -33,11 +33,13 @@ #include #else #define GCCCOMPILER +#if !defined(__ICCARM__) struct __FILE {int handle;}; FILE __stdout; FILE __stdin; FILE __stderr; #endif +#endif #include "ARMCM0.h" @@ -90,8 +92,12 @@ void SystemInit (void) #if 1 int stdout_putchar(char txchar) { - SERIAL_DATA = txchar; - return(txchar); +#if defined(__ICCARM__) + putchar(txchar); +#else + SERIAL_DATA = txchar; +#endif + return(txchar); } int stderr_putchar(char txchar) @@ -112,21 +118,22 @@ __asm(".global __ARM_use_no_argv\n\t"); #endif +#if !defined(__ICCARM__) /** Writes the character specified by c (converted to an unsigned char) to the output stream pointed to by stream, at the position indicated by the associated file position indicator (if defined), and advances the indicator appropriately. If the file position indicator is not defined, the character is appended to the output stream. - + \param[in] c Character \param[in] stream Stream handle - + \return The character written. If a write error occurs, the error indicator is set and fputc returns EOF. */ __attribute__((weak)) -int fputc (int c, FILE * stream) +int fputc (int c, FILE * stream) { if (stream == &__stdout) { return (stdout_putchar(c)); @@ -138,6 +145,7 @@ int fputc (int c, FILE * stream) return (-1); } +#endif #ifndef GCCCOMPILER /* IO device file handles. */ @@ -154,17 +162,17 @@ const char __stderr_name[] = ":STDERR"; #define RTE_Compiler_IO_STDERR 1 /** Defined in rt_sys.h, this function opens a file. - + The _sys_open() function is required by fopen() and freopen(). These functions in turn are required if any file input/output function is to be used. The openmode parameter is a bitmap whose bits mostly correspond directly to the ISO mode specification. Target-dependent extensions are possible, but freopen() must also be extended. - + \param[in] name File name \param[in] openmode Mode specification bitmap - + \return The return value is ?1 if an error occurs. */ #ifdef RETARGET_SYS @@ -173,11 +181,11 @@ FILEHANDLE _sys_open (const char *name, int openmode) { #if (!defined(RTE_Compiler_IO_File)) (void)openmode; #endif - + if (name == NULL) { return (-1); } - + if (name[0] == ':') { if (strcmp(name, ":STDIN") == 0) { return (FH_STDIN); @@ -190,7 +198,7 @@ FILEHANDLE _sys_open (const char *name, int openmode) { } return (-1); } - + #ifdef RTE_Compiler_IO_File #ifdef RTE_Compiler_IO_File_FS return (__sys_open(name, openmode)); @@ -200,23 +208,23 @@ FILEHANDLE _sys_open (const char *name, int openmode) { #endif } #endif - - + + /** Defined in rt_sys.h, this function closes a file previously opened with _sys_open(). - + This function must be defined if any input/output function is to be used. - + \param[in] fh File handle - + \return The return value is 0 if successful. A nonzero value indicates an error. */ #ifdef RETARGET_SYS __attribute__((weak)) int _sys_close (FILEHANDLE fh) { - + switch (fh) { case FH_STDIN: return (0); @@ -225,7 +233,7 @@ int _sys_close (FILEHANDLE fh) { case FH_STDERR: return (0); } - + #ifdef RTE_Compiler_IO_File #ifdef RTE_Compiler_IO_File_FS return (__sys_close(fh)); @@ -235,20 +243,20 @@ int _sys_close (FILEHANDLE fh) { #endif } #endif - - + + /** Defined in rt_sys.h, this function writes the contents of a buffer to a file previously opened with _sys_open(). - + \note The mode parameter is here for historical reasons. It contains nothing useful and must be ignored. - + \param[in] fh File handle \param[in] buf Data buffer \param[in] len Data length \param[in] mode Ignore this parameter - + \return The return value is either: - a positive number representing the number of characters not written (so any nonzero return value denotes a failure of @@ -265,7 +273,7 @@ int _sys_write (FILEHANDLE fh, const uint8_t *buf, uint32_t len, int mode) { (void)len; #endif (void)mode; - + switch (fh) { case FH_STDIN: return (-1); @@ -288,7 +296,7 @@ int _sys_write (FILEHANDLE fh, const uint8_t *buf, uint32_t len, int mode) { #endif return (0); } - + #ifdef RTE_Compiler_IO_File #ifdef RTE_Compiler_IO_File_FS return (__sys_write(fh, buf, len)); @@ -298,11 +306,11 @@ int _sys_write (FILEHANDLE fh, const uint8_t *buf, uint32_t len, int mode) { #endif } #endif - - + + /** Defined in rt_sys.h, this function reads the contents of a file into a buffer. - + Reading up to and including the last byte of data does not turn on the EOF indicator. The EOF indicator is only reached when an attempt is made to read beyond the last byte of data. The target-independent code is capable of @@ -311,15 +319,15 @@ int _sys_write (FILEHANDLE fh, const uint8_t *buf, uint32_t len, int mode) { of data that precede the EOF - the EOF indicator being returned on its own after the remaining bytes of data have been returned in a previous read. - + \note The mode parameter is here for historical reasons. It contains nothing useful and must be ignored. - + \param[in] fh File handle \param[in] buf Data buffer \param[in] len Data length \param[in] mode Ignore this parameter - + \return The return value is one of the following: - The number of bytes not read (that is, len - result number of bytes were read). @@ -337,7 +345,7 @@ int _sys_read (FILEHANDLE fh, uint8_t *buf, uint32_t len, int mode) { (void)len; #endif (void)mode; - + switch (fh) { case FH_STDIN: #ifdef RTE_Compiler_IO_STDIN @@ -359,7 +367,7 @@ int _sys_read (FILEHANDLE fh, uint8_t *buf, uint32_t len, int mode) { case FH_STDERR: return (-1); } - + #ifdef RTE_Compiler_IO_File #ifdef RTE_Compiler_IO_File_FS return (__sys_read(fh, buf, len)); @@ -369,21 +377,21 @@ int _sys_read (FILEHANDLE fh, uint8_t *buf, uint32_t len, int mode) { #endif } #endif - - - - + + + + /** Defined in rt_sys.h, this function determines if a file handle identifies a terminal. - + When a file is connected to a terminal device, this function is used to provide unbuffered behavior by default (in the absence of a call to set(v)buf) and to prohibit seeking. - + \param[in] fh File handle - + \return The return value is one of the following values: - 0: There is no interactive device. - 1: There is an interactive device. @@ -392,7 +400,7 @@ int _sys_read (FILEHANDLE fh, uint8_t *buf, uint32_t len, int mode) { #ifdef RETARGET_SYS __attribute__((weak)) int _sys_istty (FILEHANDLE fh) { - + switch (fh) { case FH_STDIN: return (1); @@ -401,22 +409,22 @@ int _sys_istty (FILEHANDLE fh) { case FH_STDERR: return (1); } - + return (0); } #endif - - + + /** Defined in rt_sys.h, this function puts the file pointer at offset pos from the beginning of the file. - + This function sets the current read or write position to the new location pos relative to the start of the current file fh. - + \param[in] fh File handle \param[in] pos File pointer offset - + \return The result is: - non-negative if no error occurs - negative if an error occurs @@ -427,7 +435,7 @@ int _sys_seek (FILEHANDLE fh, long pos) { #if (!defined(RTE_Compiler_IO_File)) (void)pos; #endif - + switch (fh) { case FH_STDIN: return (-1); @@ -436,7 +444,7 @@ int _sys_seek (FILEHANDLE fh, long pos) { case FH_STDERR: return (-1); } - + #ifdef RTE_Compiler_IO_File #ifdef RTE_Compiler_IO_File_FS return (__sys_seek(fh, (uint32_t)pos)); @@ -446,27 +454,27 @@ int _sys_seek (FILEHANDLE fh, long pos) { #endif } #endif - - + + /** Defined in rt_sys.h, this function returns the current length of a file. - + This function is used by _sys_seek() to convert an offset relative to the end of a file into an offset relative to the beginning of the file. You do not have to define _sys_flen() if you do not intend to use fseek(). If you retarget at system _sys_*() level, you must supply _sys_flen(), even if the underlying system directly supports seeking relative to the end of a file. - + \param[in] fh File handle - + \return This function returns the current length of the file fh, or a negative error indicator. */ #ifdef RETARGET_SYS __attribute__((weak)) long _sys_flen (FILEHANDLE fh) { - + switch (fh) { case FH_STDIN: return (0); @@ -475,7 +483,7 @@ long _sys_flen (FILEHANDLE fh) { case FH_STDERR: return (0); } - + #ifdef RTE_Compiler_IO_File #ifdef RTE_Compiler_IO_File_FS return (__sys_flen(fh)); @@ -493,7 +501,7 @@ int _write(int file, { int i; (void)file; - + for(i=0; i < len;i++) { stdout_putchar(*ptr++); @@ -502,7 +510,7 @@ int _write(int file, } #endif - + #define log_str(...) \ do { \ const char *pchSrc = __VA_ARGS__; \ @@ -532,13 +540,13 @@ void _sys_exit(int n) stdout_putchar(4); while(1); } -#endif +#endif extern void ttywrch (int ch); __attribute__((weak)) -void _ttywrch (int ch) +void _ttywrch (int ch) { ttywrch(ch); } -#endif \ No newline at end of file +#endif diff --git a/Platforms/FVP/ARMCM33/Include/system_ARMCM33.h b/Platforms/FVP/ARMCM33/Include/system_ARMCM33.h index 42d07ec5..f9123103 100644 --- a/Platforms/FVP/ARMCM33/Include/system_ARMCM33.h +++ b/Platforms/FVP/ARMCM33/Include/system_ARMCM33.h @@ -2,11 +2,11 @@ * @file system_ARMCM33.h * @brief CMSIS Device System Header File for * ARMCM33 Device - * @version V5.3.1 - * @date 09. July 2018 + * @version V5.3.2 + * @date 15. November 2019 ******************************************************************************/ /* - * Copyright (c) 2009-2018 Arm Limited. All rights reserved. + * Copyright (c) 2009-2019 Arm Limited. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * @@ -30,8 +30,15 @@ extern "C" { #endif -extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + \brief Exception / Interrupt Handler Function Prototype +*/ +typedef void(*VECTOR_TABLE_Type)(void); +/** + \brief System Clock Frequency (Core Clock) +*/ +extern uint32_t SystemCoreClock; /** \brief Setup the microcontroller system. diff --git a/Platforms/FVP/ARMCM33/LinkScripts/IAR/lnk.icf b/Platforms/FVP/ARMCM33/LinkScripts/IAR/lnk.icf new file mode 100644 index 00000000..a8fb6377 --- /dev/null +++ b/Platforms/FVP/ARMCM33/LinkScripts/IAR/lnk.icf @@ -0,0 +1,55 @@ +/*###ICF### Section handled by ICF editor, don't touch! ****/ +/*-Editor annotation file-*/ +/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v2_1.xml" */ +/*-Specials-*/ +define symbol __ICFEDIT_intvec_start__ = 0x00004000; +/*-Memory Regions-*/ +define symbol __ICFEDIT_region_IROM1_start__ = 0x0; +define symbol __ICFEDIT_region_IROM1_end__ = 0x0; +define symbol __ICFEDIT_region_IROM2_start__ = 0x0; +define symbol __ICFEDIT_region_IROM2_end__ = 0x0; +define symbol __ICFEDIT_region_EROM1_start__ = 0x0; +define symbol __ICFEDIT_region_EROM1_end__ = 0x0; +define symbol __ICFEDIT_region_EROM2_start__ = 0x0; +define symbol __ICFEDIT_region_EROM2_end__ = 0x0; +define symbol __ICFEDIT_region_EROM3_start__ = 0x0; +define symbol __ICFEDIT_region_EROM3_end__ = 0x0; +define symbol __ICFEDIT_region_IRAM1_start__ = 0x00004000; +define symbol __ICFEDIT_region_IRAM1_end__ = 0x007FFFFF; +define symbol __ICFEDIT_region_IRAM2_start__ = 0x20000000; +define symbol __ICFEDIT_region_IRAM2_end__ = 0x207FFFFF; +define symbol __ICFEDIT_region_ERAM1_start__ = 0x0; +define symbol __ICFEDIT_region_ERAM1_end__ = 0x0; +define symbol __ICFEDIT_region_ERAM2_start__ = 0x0; +define symbol __ICFEDIT_region_ERAM2_end__ = 0x0; +define symbol __ICFEDIT_region_ERAM3_start__ = 0x0; +define symbol __ICFEDIT_region_ERAM3_end__ = 0x0; +/*-Sizes-*/ +define symbol __ICFEDIT_size_cstack__ = 0x400; +define symbol __ICFEDIT_size_proc_s_stack__ = 0x0; +define symbol __ICFEDIT_size_main_ns_stack__ = 0x0; +define symbol __ICFEDIT_size_proc_ns_stack__ = 0x0; +define symbol __ICFEDIT_size_heap__ = 0x800; +/**** End of ICF editor section. ###ICF###*/ + +define memory mem with size = 4G; +define region IRAM_region = mem:[from __ICFEDIT_region_IRAM1_start__ to __ICFEDIT_region_IRAM1_end__] + | mem:[from __ICFEDIT_region_IRAM2_start__ to __ICFEDIT_region_IRAM2_end__]; +define region ERAM_region = mem:[from __ICFEDIT_region_ERAM1_start__ to __ICFEDIT_region_ERAM1_end__] + | mem:[from __ICFEDIT_region_ERAM2_start__ to __ICFEDIT_region_ERAM2_end__] + | mem:[from __ICFEDIT_region_ERAM3_start__ to __ICFEDIT_region_ERAM3_end__]; + +define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { }; +define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { }; + +do not initialize { section .noinit }; +initialize by copy { readwrite }; +if (isdefinedsymbol(__USE_DLIB_PERTHREAD)) +{ + // Required in a multi-threaded application + initialize by copy with packing = none { section __DLIB_PERTHREAD }; +} + +place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec }; +place in IRAM_region { readonly }; +place in IRAM_region { readwrite, block CSTACK, block HEAP }; diff --git a/Platforms/FVP/ARMCM33/LinkScripts/IAR/mem_ARMCM33.h b/Platforms/FVP/ARMCM33/LinkScripts/IAR/mem_ARMCM33.h new file mode 100644 index 00000000..19ec60e1 --- /dev/null +++ b/Platforms/FVP/ARMCM33/LinkScripts/IAR/mem_ARMCM33.h @@ -0,0 +1,38 @@ +/**************************************************************************//** + * @file mem_ARMCM7.h + * @brief Memory base and size definitions (used in scatter file) + * @version V1.1.0 + * @date 15. May 2019 + * + * @note + * + ******************************************************************************/ +/* + * Copyright (c) 2009-2019 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __MEM_ARMCM33_H +#define __MEM_ARMCM33_H + + + +#define STACK_SIZE 0x00003000 +#define HEAP_SIZE 0x00100000 + + + +#endif /* __MEM_ARMCM33_H */ diff --git a/Platforms/FVP/ARMCM33/Startup/IAR/startup_ARMCM33.c b/Platforms/FVP/ARMCM33/Startup/IAR/startup_ARMCM33.c new file mode 100644 index 00000000..044feb7c --- /dev/null +++ b/Platforms/FVP/ARMCM33/Startup/IAR/startup_ARMCM33.c @@ -0,0 +1,170 @@ +/****************************************************************************** + * @file startup_ARMCM33.c + * @brief CMSIS-Core Device Startup File for Cortex-M33 Device + * @version V2.1.0 + * @date 16. December 2020 + ******************************************************************************/ +/* + * Copyright (c) 2009-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined (ARMCM33) + #include "ARMCM33.h" +#elif defined (ARMCM33_TZ) + #include "ARMCM33_TZ.h" +#elif defined (ARMCM33_DSP_FP) + #include "ARMCM33_DSP_FP.h" +#elif defined (ARMCM33_DSP_FP_TZ) + #include "ARMCM33_DSP_FP_TZ.h" +#else + #error device not specified! +#endif + +/*---------------------------------------------------------------------------- + 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); + +/*---------------------------------------------------------------------------- + Internal References + *----------------------------------------------------------------------------*/ +__NO_RETURN void Reset_Handler (void); + void Default_Handler(void); + +/*---------------------------------------------------------------------------- + Exception / Interrupt Handler + *----------------------------------------------------------------------------*/ +/* Exceptions */ +void NMI_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void HardFault_Handler (void) __attribute__ ((weak)); +void MemManage_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void BusFault_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void UsageFault_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void SecureFault_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void SVC_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void DebugMon_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void PendSV_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void SysTick_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); + +void Interrupt0_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt1_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt2_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt3_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt4_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt5_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt6_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt7_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt8_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt9_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); + + +/*---------------------------------------------------------------------------- + Exception / Interrupt Vector table + *----------------------------------------------------------------------------*/ + +#if defined ( __GNUC__ ) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpedantic" +#endif + +extern const VECTOR_TABLE_Type __VECTOR_TABLE[496]; + const VECTOR_TABLE_Type __VECTOR_TABLE[496] __VECTOR_TABLE_ATTRIBUTE = { + (VECTOR_TABLE_Type)(&__INITIAL_SP), /* Initial Stack Pointer */ + Reset_Handler, /* Reset Handler */ + NMI_Handler, /* -14 NMI Handler */ + HardFault_Handler, /* -13 Hard Fault Handler */ + MemManage_Handler, /* -12 MPU Fault Handler */ + BusFault_Handler, /* -11 Bus Fault Handler */ + UsageFault_Handler, /* -10 Usage Fault Handler */ + SecureFault_Handler, /* -9 Secure Fault Handler */ + 0, /* Reserved */ + 0, /* Reserved */ + 0, /* Reserved */ + SVC_Handler, /* -5 SVCall Handler */ + DebugMon_Handler, /* -4 Debug Monitor Handler */ + 0, /* Reserved */ + PendSV_Handler, /* -2 PendSV Handler */ + SysTick_Handler, /* -1 SysTick Handler */ + + /* Interrupts */ + Interrupt0_Handler, /* 0 Interrupt 0 */ + Interrupt1_Handler, /* 1 Interrupt 1 */ + Interrupt2_Handler, /* 2 Interrupt 2 */ + Interrupt3_Handler, /* 3 Interrupt 3 */ + Interrupt4_Handler, /* 4 Interrupt 4 */ + Interrupt5_Handler, /* 5 Interrupt 5 */ + Interrupt6_Handler, /* 6 Interrupt 6 */ + Interrupt7_Handler, /* 7 Interrupt 7 */ + Interrupt8_Handler, /* 8 Interrupt 8 */ + Interrupt9_Handler /* 9 Interrupt 9 */ + /* Interrupts 10 .. 480 are left out */ +}; + +#if defined ( __GNUC__ ) +#pragma GCC diagnostic pop +#endif + +/*---------------------------------------------------------------------------- + Reset Handler called on controller reset + *----------------------------------------------------------------------------*/ +__NO_RETURN void Reset_Handler(void) +{ + __set_PSP((uint32_t)(&__INITIAL_SP)); + + __set_MSPLIM((uint32_t)(&__STACK_LIMIT)); + __set_PSPLIM((uint32_t)(&__STACK_LIMIT)); + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + __TZ_set_STACKSEAL_S((uint32_t *)(&__STACK_SEAL)); +#endif + + SystemInit(); /* CMSIS System Initialization */ + __PROGRAM_START(); /* Enter PreMain (C library entry point) */ +} + + +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wmissing-noreturn" +#endif + +/*---------------------------------------------------------------------------- + Hard Fault Handler + *----------------------------------------------------------------------------*/ +void HardFault_Handler(void) +{ + while(1); +} + +/*---------------------------------------------------------------------------- + Default Handler for Exceptions / Interrupts + *----------------------------------------------------------------------------*/ +void Default_Handler(void) +{ + while(1); +} + +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic pop +#endif + diff --git a/Platforms/FVP/ARMCM33/system_ARMCM33.c b/Platforms/FVP/ARMCM33/system_ARMCM33.c index ea64ed59..b165ff2d 100644 --- a/Platforms/FVP/ARMCM33/system_ARMCM33.c +++ b/Platforms/FVP/ARMCM33/system_ARMCM33.c @@ -33,11 +33,13 @@ #include #else #define GCCCOMPILER +#if !defined(__ICCARM__) struct __FILE {int handle;}; FILE __stdout; FILE __stdin; FILE __stderr; #endif +#endif #if defined (ARMCM33) #include "ARMCM33.h" @@ -274,7 +276,11 @@ typedef struct int stdout_putchar(char txchar) { +#if defined(__ICCARM__) + putchar(txchar); +#else SERIAL_DATA = txchar; +#endif return(txchar); } @@ -314,7 +320,9 @@ void SystemInit (void) SystemCoreClock = SYSTEM_CLOCK; } +#if !defined(__ICCARM__) __attribute__((constructor(255))) +#endif void platform_init(void) { printf("\n_[TEST START]____________________________________________________\n"); @@ -328,6 +336,7 @@ __asm(".global __ARM_use_no_argv\n\t"); # endif #endif +#if !defined(__ICCARM__) /** Writes the character specified by c (converted to an unsigned char) to the output stream pointed to by stream, at the position indicated by the @@ -354,6 +363,7 @@ int fputc (int c, FILE * stream) return (-1); } +#endif #ifndef GCCCOMPILER /* IO device file handles. */ @@ -736,7 +746,9 @@ void _exit(int return_code) log_str("\n"); log_str("_[TEST COMPLETE]_________________________________________________\n"); log_str("\n\n"); +#if !defined(__ICCARM__) *((volatile unsigned *) (SERIAL_BASE_ADDRESS-0x10000)) = 0xa; +#endif while(1); } #else @@ -746,7 +758,9 @@ void _sys_exit(int n) log_str("\n"); log_str("_[TEST COMPLETE]_________________________________________________\n"); log_str("\n\n"); +#if !defined(__ICCARM__) *((volatile unsigned *) (SERIAL_BASE_ADDRESS-0x10000)) = 0xa; +#endif while(1); } #endif diff --git a/Platforms/FVP/ARMCM4/Include/system_ARMCM4.h b/Platforms/FVP/ARMCM4/Include/system_ARMCM4.h index 25573902..1080bacf 100644 --- a/Platforms/FVP/ARMCM4/Include/system_ARMCM4.h +++ b/Platforms/FVP/ARMCM4/Include/system_ARMCM4.h @@ -2,11 +2,11 @@ * @file system_ARMCM4.h * @brief CMSIS Device System Header File for * ARMCM4 Device - * @version V5.3.1 - * @date 09. July 2018 + * @version V5.3.2 + * @date 15. November 2019 ******************************************************************************/ /* - * Copyright (c) 2009-2018 Arm Limited. All rights reserved. + * Copyright (c) 2009-2019 Arm Limited. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * @@ -30,8 +30,15 @@ extern "C" { #endif -extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + \brief Exception / Interrupt Handler Function Prototype +*/ +typedef void(*VECTOR_TABLE_Type)(void); +/** + \brief System Clock Frequency (Core Clock) +*/ +extern uint32_t SystemCoreClock; /** \brief Setup the microcontroller system. diff --git a/Platforms/FVP/ARMCM4/LinkScripts/IAR/lnk.icf b/Platforms/FVP/ARMCM4/LinkScripts/IAR/lnk.icf new file mode 100644 index 00000000..ed96fe2a --- /dev/null +++ b/Platforms/FVP/ARMCM4/LinkScripts/IAR/lnk.icf @@ -0,0 +1,175 @@ +/*###ICF### Section handled by ICF editor, don't touch! ****/ +/*-Editor annotation file-*/ +/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\a_v1_1.xml" */ +/*-Specials-*/ +define symbol __ICFEDIT_intvec_start__ = 0x00000000; +/*-Memory Regions-*/ +define symbol __ICFEDIT_region_IROM1_start__ = 0x00000080; +define symbol __ICFEDIT_region_IROM1_end__ = 0x0007FFFF; +define symbol __ICFEDIT_region_IROM2_start__ = 0x0; +define symbol __ICFEDIT_region_IROM2_end__ = 0x0; +define symbol __ICFEDIT_region_EROM1_start__ = 0x0; +define symbol __ICFEDIT_region_EROM1_end__ = 0x0; +define symbol __ICFEDIT_region_EROM2_start__ = 0x0; +define symbol __ICFEDIT_region_EROM2_end__ = 0x0; +define symbol __ICFEDIT_region_EROM3_start__ = 0x0; +define symbol __ICFEDIT_region_EROM3_end__ = 0x0; +define symbol __ICFEDIT_region_IRAM1_start__ = 0x00100000; +define symbol __ICFEDIT_region_IRAM1_end__ = 0x001FFFFF; +define symbol __ICFEDIT_region_IRAM2_start__ = 0x0; +define symbol __ICFEDIT_region_IRAM2_end__ = 0x0; +define symbol __ICFEDIT_region_ERAM1_start__ = 0x0; +define symbol __ICFEDIT_region_ERAM1_end__ = 0x0; +define symbol __ICFEDIT_region_ERAM2_start__ = 0x0; +define symbol __ICFEDIT_region_ERAM2_end__ = 0x0; +define symbol __ICFEDIT_region_ERAM3_start__ = 0x0; +define symbol __ICFEDIT_region_ERAM3_end__ = 0x0; +/*-Sizes-*/ +define symbol __ICFEDIT_size_cstack__ = 0x2000; +define symbol __ICFEDIT_size_svcstack__ = 0x100; +define symbol __ICFEDIT_size_irqstack__ = 0x100; +define symbol __ICFEDIT_size_fiqstack__ = 0x100; +define symbol __ICFEDIT_size_undstack__ = 0x100; +define symbol __ICFEDIT_size_abtstack__ = 0x100; +define symbol __ICFEDIT_size_heap__ = 0x8000; +/**** End of ICF editor section. ###ICF###*/ + +define memory mem with size = 4G; +define symbol use_IROM1 = (__ICFEDIT_region_IROM1_start__ != 0x0 || __ICFEDIT_region_IROM1_end__ != 0x0); +define symbol use_IROM2 = (__ICFEDIT_region_IROM2_start__ != 0x0 || __ICFEDIT_region_IROM2_end__ != 0x0); +define symbol use_EROM1 = (__ICFEDIT_region_EROM1_start__ != 0x0 || __ICFEDIT_region_EROM1_end__ != 0x0); +define symbol use_EROM2 = (__ICFEDIT_region_EROM2_start__ != 0x0 || __ICFEDIT_region_EROM2_end__ != 0x0); +define symbol use_EROM3 = (__ICFEDIT_region_EROM3_start__ != 0x0 || __ICFEDIT_region_EROM3_end__ != 0x0); +define symbol use_IRAM1 = (__ICFEDIT_region_IRAM1_start__ != 0x0 || __ICFEDIT_region_IRAM1_end__ != 0x0); +define symbol use_IRAM2 = (__ICFEDIT_region_IRAM2_start__ != 0x0 || __ICFEDIT_region_IRAM2_end__ != 0x0); +define symbol use_ERAM1 = (__ICFEDIT_region_ERAM1_start__ != 0x0 || __ICFEDIT_region_ERAM1_end__ != 0x0); +define symbol use_ERAM2 = (__ICFEDIT_region_ERAM2_start__ != 0x0 || __ICFEDIT_region_ERAM2_end__ != 0x0); +define symbol use_ERAM3 = (__ICFEDIT_region_ERAM3_start__ != 0x0 || __ICFEDIT_region_ERAM3_end__ != 0x0); + +if (use_IROM1) +{ + define region IROM1_region = mem:[from __ICFEDIT_region_IROM1_start__ to __ICFEDIT_region_IROM1_end__]; +} +else +{ + define region IROM1_region = []; +} + +if (use_IROM2) +{ + define region IROM2_region = mem:[from __ICFEDIT_region_IROM2_start__ to __ICFEDIT_region_IROM2_end__]; +} +else +{ + define region IROM2_region = []; +} +define region IROM_region = IROM1_region | IROM2_region; + +if (use_EROM1) +{ + define region EROM1_region = mem:[from __ICFEDIT_region_EROM1_start__ to __ICFEDIT_region_EROM1_end__]; +} +else +{ + define region EROM1_region = []; +} +if (use_EROM2) +{ + define region EROM2_region = mem:[from __ICFEDIT_region_EROM2_start__ to __ICFEDIT_region_EROM2_end__]; +} +else +{ + define region EROM2_region = []; +} +if (use_EROM3) +{ + define region EROM3_region = mem:[from __ICFEDIT_region_EROM3_start__ to __ICFEDIT_region_EROM3_end__]; +} +else +{ + define region EROM3_region = []; +} +define region EROM_region = EROM1_region | EROM2_region | EROM3_region; + +if (use_IRAM1) +{ + define region IRAM1_region = mem:[from __ICFEDIT_region_IRAM1_start__ to __ICFEDIT_region_IRAM1_end__]; +} +else +{ + define region IRAM1_region = []; +} +if (use_IRAM2) +{ + define region IRAM2_region = mem:[from __ICFEDIT_region_IRAM2_start__ to __ICFEDIT_region_IRAM2_end__]; +} +else +{ + define region IRAM2_region = []; +} +define region IRAM_region = IRAM1_region | IRAM2_region; + +if (use_ERAM1) +{ + define region ERAM1_region = mem:[from __ICFEDIT_region_ERAM1_start__ to __ICFEDIT_region_ERAM1_end__]; +} +else +{ + define region ERAM1_region = []; +} +if (use_ERAM2) +{ + define region ERAM2_region = mem:[from __ICFEDIT_region_ERAM2_start__ to __ICFEDIT_region_ERAM2_end__]; +} +else +{ + define region ERAM2_region = []; +} +if (use_ERAM3) +{ + define region ERAM3_region = mem:[from __ICFEDIT_region_ERAM3_start__ to __ICFEDIT_region_ERAM3_end__]; +} +else +{ + define region ERAM3_region = []; +} +define region ERAM_region = ERAM1_region | ERAM2_region | ERAM3_region; + +do not initialize { section .noinit }; +initialize by copy { readwrite }; +if (isdefinedsymbol(__USE_DLIB_PERTHREAD)) +{ + // Required in a multi-threaded application + initialize by copy with packing = none { section __DLIB_PERTHREAD }; +} + +place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec }; + +if (!isempty(IROM_region)) +{ + place in IROM_region { readonly }; +} + +if (!isempty(EROM_region)) +{ + place in EROM_region { readonly section application_specific_ro }; +} + +if (!isempty(IRAM_region)) +{ + define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { }; + define block SVC_STACK with alignment = 8, size = __ICFEDIT_size_svcstack__ { }; + define block IRQ_STACK with alignment = 8, size = __ICFEDIT_size_irqstack__ { }; + define block FIQ_STACK with alignment = 8, size = __ICFEDIT_size_fiqstack__ { }; + define block UND_STACK with alignment = 8, size = __ICFEDIT_size_undstack__ { }; + define block ABT_STACK with alignment = 8, size = __ICFEDIT_size_abtstack__ { }; + define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { }; + place in IRAM_region { readwrite, + block CSTACK, block SVC_STACK, block IRQ_STACK, block FIQ_STACK, + block UND_STACK, block ABT_STACK, block HEAP }; +} + +if (!isempty(ERAM_region)) +{ + place in ERAM_region { readwrite section application_specific_rw }; +} diff --git a/Platforms/FVP/ARMCM4/LinkScripts/IAR/mem_ARMCM4.h b/Platforms/FVP/ARMCM4/LinkScripts/IAR/mem_ARMCM4.h new file mode 100644 index 00000000..84a1ff1d --- /dev/null +++ b/Platforms/FVP/ARMCM4/LinkScripts/IAR/mem_ARMCM4.h @@ -0,0 +1,38 @@ +/**************************************************************************//** + * @file mem_ARMCM7.h + * @brief Memory base and size definitions (used in scatter file) + * @version V1.1.0 + * @date 15. May 2019 + * + * @note + * + ******************************************************************************/ +/* + * Copyright (c) 2009-2019 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __MEM_ARMCM7_H +#define __MEM_ARMCM7_H + + + +#define STACK_SIZE 0x00003000 +#define HEAP_SIZE 0x00100000 + + + +#endif /* __MEM_ARMCM7_H */ diff --git a/Platforms/FVP/ARMCM4/Startup/IAR/startup_ARMCM4.c b/Platforms/FVP/ARMCM4/Startup/IAR/startup_ARMCM4.c new file mode 100644 index 00000000..2d7ca211 --- /dev/null +++ b/Platforms/FVP/ARMCM4/Startup/IAR/startup_ARMCM4.c @@ -0,0 +1,152 @@ +/****************************************************************************** + * @file startup_ARMCM4.c + * @brief CMSIS-Core(M) Device Startup File for a Cortex-M4 Device + * @version V2.0.3 + * @date 31. March 2020 + ******************************************************************************/ +/* + * Copyright (c) 2009-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined (ARMCM4) + #include "ARMCM4.h" +#elif defined (ARMCM4_FP) + #include "ARMCM4_FP.h" +#else + #error device not specified! +#endif + +/*---------------------------------------------------------------------------- + External References + *----------------------------------------------------------------------------*/ +extern uint32_t __INITIAL_SP; + +extern __NO_RETURN void __PROGRAM_START(void); + +/*---------------------------------------------------------------------------- + Internal References + *----------------------------------------------------------------------------*/ +__NO_RETURN void Reset_Handler (void); + void Default_Handler(void); + +/*---------------------------------------------------------------------------- + Exception / Interrupt Handler + *----------------------------------------------------------------------------*/ +/* Exceptions */ +void NMI_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void HardFault_Handler (void) __attribute__ ((weak)); +void MemManage_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void BusFault_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void UsageFault_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void SVC_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void DebugMon_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void PendSV_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void SysTick_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); + +void Interrupt0_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt1_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt2_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt3_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt4_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt5_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt6_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt7_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt8_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt9_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); + + +/*---------------------------------------------------------------------------- + Exception / Interrupt Vector table + *----------------------------------------------------------------------------*/ + +#if defined ( __GNUC__ ) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpedantic" +#endif + +extern const VECTOR_TABLE_Type __VECTOR_TABLE[240]; + const VECTOR_TABLE_Type __VECTOR_TABLE[240] __VECTOR_TABLE_ATTRIBUTE = { + (VECTOR_TABLE_Type)(&__INITIAL_SP), /* Initial Stack Pointer */ + Reset_Handler, /* Reset Handler */ + NMI_Handler, /* -14 NMI Handler */ + HardFault_Handler, /* -13 Hard Fault Handler */ + MemManage_Handler, /* -12 MPU Fault Handler */ + BusFault_Handler, /* -11 Bus Fault Handler */ + UsageFault_Handler, /* -10 Usage Fault Handler */ + 0, /* Reserved */ + 0, /* Reserved */ + 0, /* Reserved */ + 0, /* Reserved */ + SVC_Handler, /* -5 SVC Handler */ + DebugMon_Handler, /* -4 Debug Monitor Handler */ + 0, /* Reserved */ + PendSV_Handler, /* -2 PendSV Handler */ + SysTick_Handler, /* -1 SysTick Handler */ + + /* Interrupts */ + Interrupt0_Handler, /* 0 Interrupt 0 */ + Interrupt1_Handler, /* 1 Interrupt 1 */ + Interrupt2_Handler, /* 2 Interrupt 2 */ + Interrupt3_Handler, /* 3 Interrupt 3 */ + Interrupt4_Handler, /* 4 Interrupt 4 */ + Interrupt5_Handler, /* 5 Interrupt 5 */ + Interrupt6_Handler, /* 6 Interrupt 6 */ + Interrupt7_Handler, /* 7 Interrupt 7 */ + Interrupt8_Handler, /* 8 Interrupt 8 */ + Interrupt9_Handler /* 9 Interrupt 9 */ + /* Interrupts 10 .. 223 are left out */ +}; + +#if defined ( __GNUC__ ) +#pragma GCC diagnostic pop +#endif + +/*---------------------------------------------------------------------------- + Reset Handler called on controller reset + *----------------------------------------------------------------------------*/ +__NO_RETURN void Reset_Handler(void) +{ + SystemInit(); /* CMSIS System Initialization */ + __PROGRAM_START(); /* Enter PreMain (C library entry point) */ +} + + +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wmissing-noreturn" +#endif + +/*---------------------------------------------------------------------------- + Hard Fault Handler + *----------------------------------------------------------------------------*/ +void HardFault_Handler(void) +{ + while(1); +} + +/*---------------------------------------------------------------------------- + Default Handler for Exceptions / Interrupts + *----------------------------------------------------------------------------*/ +void Default_Handler(void) +{ + while(1); +} + +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic pop +#endif + diff --git a/Platforms/FVP/ARMCM4/system_ARMCM4.c b/Platforms/FVP/ARMCM4/system_ARMCM4.c index 6e377131..3a887856 100644 --- a/Platforms/FVP/ARMCM4/system_ARMCM4.c +++ b/Platforms/FVP/ARMCM4/system_ARMCM4.c @@ -33,11 +33,13 @@ #include #else #define GCCCOMPILER +#if !defined(__ICCARM__) struct __FILE {int handle;}; FILE __stdout; FILE __stdin; FILE __stderr; #endif +#endif #if defined (ARMCM4) @@ -90,7 +92,11 @@ uint32_t SystemCoreClock = SYSTEM_CLOCK; /* System Core Clock Frequency */ int stdout_putchar(char txchar) { +#if defined(__ICCARM__) + putchar(txchar); +#else SERIAL_DATA = txchar; +#endif return(txchar); } @@ -145,6 +151,7 @@ __asm(".global __ARM_use_no_argv\n\t"); # endif #endif +#if !defined(__ICCARM__) /** Writes the character specified by c (converted to an unsigned char) to the output stream pointed to by stream, at the position indicated by the @@ -171,6 +178,7 @@ int fputc (int c, FILE * stream) return (-1); } +#endif #ifndef GCCCOMPILER /* IO device file handles. */ diff --git a/Platforms/FVP/ARMCM7/Include/system_ARMCM7.h b/Platforms/FVP/ARMCM7/Include/system_ARMCM7.h index ec831e09..f5763de5 100644 --- a/Platforms/FVP/ARMCM7/Include/system_ARMCM7.h +++ b/Platforms/FVP/ARMCM7/Include/system_ARMCM7.h @@ -2,11 +2,11 @@ * @file system_ARMCM7.h * @brief CMSIS Device System Header File for * ARMCM7 Device - * @version V5.3.1 - * @date 09. July 2018 + * @version V5.3.2 + * @date 15. November 2019 ******************************************************************************/ /* - * Copyright (c) 2009-2018 Arm Limited. All rights reserved. + * Copyright (c) 2009-2019 Arm Limited. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * @@ -30,8 +30,15 @@ extern "C" { #endif -extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + \brief Exception / Interrupt Handler Function Prototype +*/ +typedef void(*VECTOR_TABLE_Type)(void); +/** + \brief System Clock Frequency (Core Clock) +*/ +extern uint32_t SystemCoreClock; /** \brief Setup the microcontroller system. diff --git a/Platforms/FVP/ARMCM7/LinkScripts/IAR/lnk.icf b/Platforms/FVP/ARMCM7/LinkScripts/IAR/lnk.icf new file mode 100644 index 00000000..a8fb6377 --- /dev/null +++ b/Platforms/FVP/ARMCM7/LinkScripts/IAR/lnk.icf @@ -0,0 +1,55 @@ +/*###ICF### Section handled by ICF editor, don't touch! ****/ +/*-Editor annotation file-*/ +/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v2_1.xml" */ +/*-Specials-*/ +define symbol __ICFEDIT_intvec_start__ = 0x00004000; +/*-Memory Regions-*/ +define symbol __ICFEDIT_region_IROM1_start__ = 0x0; +define symbol __ICFEDIT_region_IROM1_end__ = 0x0; +define symbol __ICFEDIT_region_IROM2_start__ = 0x0; +define symbol __ICFEDIT_region_IROM2_end__ = 0x0; +define symbol __ICFEDIT_region_EROM1_start__ = 0x0; +define symbol __ICFEDIT_region_EROM1_end__ = 0x0; +define symbol __ICFEDIT_region_EROM2_start__ = 0x0; +define symbol __ICFEDIT_region_EROM2_end__ = 0x0; +define symbol __ICFEDIT_region_EROM3_start__ = 0x0; +define symbol __ICFEDIT_region_EROM3_end__ = 0x0; +define symbol __ICFEDIT_region_IRAM1_start__ = 0x00004000; +define symbol __ICFEDIT_region_IRAM1_end__ = 0x007FFFFF; +define symbol __ICFEDIT_region_IRAM2_start__ = 0x20000000; +define symbol __ICFEDIT_region_IRAM2_end__ = 0x207FFFFF; +define symbol __ICFEDIT_region_ERAM1_start__ = 0x0; +define symbol __ICFEDIT_region_ERAM1_end__ = 0x0; +define symbol __ICFEDIT_region_ERAM2_start__ = 0x0; +define symbol __ICFEDIT_region_ERAM2_end__ = 0x0; +define symbol __ICFEDIT_region_ERAM3_start__ = 0x0; +define symbol __ICFEDIT_region_ERAM3_end__ = 0x0; +/*-Sizes-*/ +define symbol __ICFEDIT_size_cstack__ = 0x400; +define symbol __ICFEDIT_size_proc_s_stack__ = 0x0; +define symbol __ICFEDIT_size_main_ns_stack__ = 0x0; +define symbol __ICFEDIT_size_proc_ns_stack__ = 0x0; +define symbol __ICFEDIT_size_heap__ = 0x800; +/**** End of ICF editor section. ###ICF###*/ + +define memory mem with size = 4G; +define region IRAM_region = mem:[from __ICFEDIT_region_IRAM1_start__ to __ICFEDIT_region_IRAM1_end__] + | mem:[from __ICFEDIT_region_IRAM2_start__ to __ICFEDIT_region_IRAM2_end__]; +define region ERAM_region = mem:[from __ICFEDIT_region_ERAM1_start__ to __ICFEDIT_region_ERAM1_end__] + | mem:[from __ICFEDIT_region_ERAM2_start__ to __ICFEDIT_region_ERAM2_end__] + | mem:[from __ICFEDIT_region_ERAM3_start__ to __ICFEDIT_region_ERAM3_end__]; + +define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { }; +define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { }; + +do not initialize { section .noinit }; +initialize by copy { readwrite }; +if (isdefinedsymbol(__USE_DLIB_PERTHREAD)) +{ + // Required in a multi-threaded application + initialize by copy with packing = none { section __DLIB_PERTHREAD }; +} + +place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec }; +place in IRAM_region { readonly }; +place in IRAM_region { readwrite, block CSTACK, block HEAP }; diff --git a/Platforms/FVP/ARMCM7/LinkScripts/IAR/mem_ARMCM7.h b/Platforms/FVP/ARMCM7/LinkScripts/IAR/mem_ARMCM7.h new file mode 100644 index 00000000..84a1ff1d --- /dev/null +++ b/Platforms/FVP/ARMCM7/LinkScripts/IAR/mem_ARMCM7.h @@ -0,0 +1,38 @@ +/**************************************************************************//** + * @file mem_ARMCM7.h + * @brief Memory base and size definitions (used in scatter file) + * @version V1.1.0 + * @date 15. May 2019 + * + * @note + * + ******************************************************************************/ +/* + * Copyright (c) 2009-2019 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __MEM_ARMCM7_H +#define __MEM_ARMCM7_H + + + +#define STACK_SIZE 0x00003000 +#define HEAP_SIZE 0x00100000 + + + +#endif /* __MEM_ARMCM7_H */ diff --git a/Platforms/FVP/ARMCM7/Startup/IAR/startup_ARMCM7.c b/Platforms/FVP/ARMCM7/Startup/IAR/startup_ARMCM7.c new file mode 100644 index 00000000..509cd338 --- /dev/null +++ b/Platforms/FVP/ARMCM7/Startup/IAR/startup_ARMCM7.c @@ -0,0 +1,154 @@ +/****************************************************************************** + * @file startup_ARMCM7.c + * @brief CMSIS-Core(M) Device Startup File for a Cortex-M7 Device + * @version V2.0.3 + * @date 31. March 2020 + ******************************************************************************/ +/* + * Copyright (c) 2009-2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined (ARMCM7) + #include "ARMCM7.h" +#elif defined (ARMCM7_SP) + #include "ARMCM7_SP.h" +#elif defined (ARMCM7_DP) + #include "ARMCM7_DP.h" +#else + #error device not specified! +#endif + +/*---------------------------------------------------------------------------- + External References + *----------------------------------------------------------------------------*/ +extern uint32_t __INITIAL_SP; + +extern __NO_RETURN void __PROGRAM_START(void); + +/*---------------------------------------------------------------------------- + Internal References + *----------------------------------------------------------------------------*/ +__NO_RETURN void Reset_Handler (void); + void Default_Handler(void); + +/*---------------------------------------------------------------------------- + Exception / Interrupt Handler + *----------------------------------------------------------------------------*/ +/* Exceptions */ +void NMI_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void HardFault_Handler (void) __attribute__ ((weak)); +void MemManage_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void BusFault_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void UsageFault_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void SVC_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void DebugMon_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void PendSV_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void SysTick_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); + +void Interrupt0_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt1_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt2_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt3_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt4_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt5_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt6_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt7_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt8_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt9_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); + + +/*---------------------------------------------------------------------------- + Exception / Interrupt Vector table + *----------------------------------------------------------------------------*/ + +#if defined ( __GNUC__ ) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpedantic" +#endif + +extern const VECTOR_TABLE_Type __VECTOR_TABLE[240]; + const VECTOR_TABLE_Type __VECTOR_TABLE[240] __VECTOR_TABLE_ATTRIBUTE = { + (VECTOR_TABLE_Type)(&__INITIAL_SP), /* Initial Stack Pointer */ + Reset_Handler, /* Reset Handler */ + NMI_Handler, /* -14 NMI Handler */ + HardFault_Handler, /* -13 Hard Fault Handler */ + MemManage_Handler, /* -12 MPU Fault Handler */ + BusFault_Handler, /* -11 Bus Fault Handler */ + UsageFault_Handler, /* -10 Usage Fault Handler */ + 0, /* Reserved */ + 0, /* Reserved */ + 0, /* Reserved */ + 0, /* Reserved */ + SVC_Handler, /* -5 SVC Handler */ + DebugMon_Handler, /* -4 Debug Monitor Handler */ + 0, /* Reserved */ + PendSV_Handler, /* -2 PendSV Handler */ + SysTick_Handler, /* -1 SysTick Handler */ + + /* Interrupts */ + Interrupt0_Handler, /* 0 Interrupt 0 */ + Interrupt1_Handler, /* 1 Interrupt 1 */ + Interrupt2_Handler, /* 2 Interrupt 2 */ + Interrupt3_Handler, /* 3 Interrupt 3 */ + Interrupt4_Handler, /* 4 Interrupt 4 */ + Interrupt5_Handler, /* 5 Interrupt 5 */ + Interrupt6_Handler, /* 6 Interrupt 6 */ + Interrupt7_Handler, /* 7 Interrupt 7 */ + Interrupt8_Handler, /* 8 Interrupt 8 */ + Interrupt9_Handler /* 9 Interrupt 9 */ + /* Interrupts 10 .. 223 are left out */ +}; + +#if defined ( __GNUC__ ) +#pragma GCC diagnostic pop +#endif + +/*---------------------------------------------------------------------------- + Reset Handler called on controller reset + *----------------------------------------------------------------------------*/ +__NO_RETURN void Reset_Handler(void) +{ + SystemInit(); /* CMSIS System Initialization */ + __PROGRAM_START(); /* Enter PreMain (C library entry point) */ +} + + +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wmissing-noreturn" +#endif + +/*---------------------------------------------------------------------------- + Hard Fault Handler + *----------------------------------------------------------------------------*/ +void HardFault_Handler(void) +{ + while(1); +} + +/*---------------------------------------------------------------------------- + Default Handler for Exceptions / Interrupts + *----------------------------------------------------------------------------*/ +void Default_Handler(void) +{ + while(1); +} + +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic pop +#endif + diff --git a/Platforms/FVP/ARMCM7/system_ARMCM7.c b/Platforms/FVP/ARMCM7/system_ARMCM7.c index 5f07216b..ae6cc0da 100644 --- a/Platforms/FVP/ARMCM7/system_ARMCM7.c +++ b/Platforms/FVP/ARMCM7/system_ARMCM7.c @@ -33,11 +33,13 @@ #include #else #define GCCCOMPILER +#if !defined(__ICCARM__) struct __FILE {int handle;}; FILE __stdout; FILE __stdin; FILE __stderr; #endif +#endif #if defined (ARMCM7) @@ -103,7 +105,11 @@ void stop_ipss_measurement() int stdout_putchar(char txchar) { - SERIAL_DATA = txchar; +#if defined(__ICCARM__) + putchar(txchar); +#else + SERIAL_DATA = txchar; +#endif return(txchar); } @@ -146,6 +152,7 @@ __asm(".global __ARM_use_no_argv\n\t"); # endif #endif +#if !defined(__ICCARM__) /** Writes the character specified by c (converted to an unsigned char) to the output stream pointed to by stream, at the position indicated by the @@ -172,6 +179,7 @@ int fputc (int c, FILE * stream) return (-1); } +#endif #ifndef GCCCOMPILER /* IO device file handles. */ diff --git a/Platforms/FVP/ARMv81MML/Include/system_ARMv81MML.h b/Platforms/FVP/ARMv81MML/Include/system_ARMv81MML.h index 43218c6a..237f1b46 100755 --- a/Platforms/FVP/ARMv81MML/Include/system_ARMv81MML.h +++ b/Platforms/FVP/ARMv81MML/Include/system_ARMv81MML.h @@ -2,8 +2,8 @@ * @file system_ARMv81MML.h * @brief CMSIS Device System Header File for * Armv8.1-M Mainline Device Series - * @version V1.0.0 - * @date 25. February 2019 + * @version V1.0.1 + * @date 15. Novemer 2019 ******************************************************************************/ /* * Copyright (c) 2009-2019 Arm Limited. All rights reserved. @@ -30,7 +30,15 @@ extern "C" { #endif -extern uint32_t SystemCoreClock; /*!< System Clock Frequency (Core Clock) */ +/** + \brief Exception / Interrupt Handler Function Prototype +*/ +typedef void(*VECTOR_TABLE_Type)(void); + +/** + \brief System Clock Frequency (Core Clock) +*/ +extern uint32_t SystemCoreClock; /** diff --git a/Platforms/FVP/ARMv81MML/LinkScripts/IAR/lnk.icf b/Platforms/FVP/ARMv81MML/LinkScripts/IAR/lnk.icf new file mode 100644 index 00000000..a8fb6377 --- /dev/null +++ b/Platforms/FVP/ARMv81MML/LinkScripts/IAR/lnk.icf @@ -0,0 +1,55 @@ +/*###ICF### Section handled by ICF editor, don't touch! ****/ +/*-Editor annotation file-*/ +/* IcfEditorFile="$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v2_1.xml" */ +/*-Specials-*/ +define symbol __ICFEDIT_intvec_start__ = 0x00004000; +/*-Memory Regions-*/ +define symbol __ICFEDIT_region_IROM1_start__ = 0x0; +define symbol __ICFEDIT_region_IROM1_end__ = 0x0; +define symbol __ICFEDIT_region_IROM2_start__ = 0x0; +define symbol __ICFEDIT_region_IROM2_end__ = 0x0; +define symbol __ICFEDIT_region_EROM1_start__ = 0x0; +define symbol __ICFEDIT_region_EROM1_end__ = 0x0; +define symbol __ICFEDIT_region_EROM2_start__ = 0x0; +define symbol __ICFEDIT_region_EROM2_end__ = 0x0; +define symbol __ICFEDIT_region_EROM3_start__ = 0x0; +define symbol __ICFEDIT_region_EROM3_end__ = 0x0; +define symbol __ICFEDIT_region_IRAM1_start__ = 0x00004000; +define symbol __ICFEDIT_region_IRAM1_end__ = 0x007FFFFF; +define symbol __ICFEDIT_region_IRAM2_start__ = 0x20000000; +define symbol __ICFEDIT_region_IRAM2_end__ = 0x207FFFFF; +define symbol __ICFEDIT_region_ERAM1_start__ = 0x0; +define symbol __ICFEDIT_region_ERAM1_end__ = 0x0; +define symbol __ICFEDIT_region_ERAM2_start__ = 0x0; +define symbol __ICFEDIT_region_ERAM2_end__ = 0x0; +define symbol __ICFEDIT_region_ERAM3_start__ = 0x0; +define symbol __ICFEDIT_region_ERAM3_end__ = 0x0; +/*-Sizes-*/ +define symbol __ICFEDIT_size_cstack__ = 0x400; +define symbol __ICFEDIT_size_proc_s_stack__ = 0x0; +define symbol __ICFEDIT_size_main_ns_stack__ = 0x0; +define symbol __ICFEDIT_size_proc_ns_stack__ = 0x0; +define symbol __ICFEDIT_size_heap__ = 0x800; +/**** End of ICF editor section. ###ICF###*/ + +define memory mem with size = 4G; +define region IRAM_region = mem:[from __ICFEDIT_region_IRAM1_start__ to __ICFEDIT_region_IRAM1_end__] + | mem:[from __ICFEDIT_region_IRAM2_start__ to __ICFEDIT_region_IRAM2_end__]; +define region ERAM_region = mem:[from __ICFEDIT_region_ERAM1_start__ to __ICFEDIT_region_ERAM1_end__] + | mem:[from __ICFEDIT_region_ERAM2_start__ to __ICFEDIT_region_ERAM2_end__] + | mem:[from __ICFEDIT_region_ERAM3_start__ to __ICFEDIT_region_ERAM3_end__]; + +define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { }; +define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { }; + +do not initialize { section .noinit }; +initialize by copy { readwrite }; +if (isdefinedsymbol(__USE_DLIB_PERTHREAD)) +{ + // Required in a multi-threaded application + initialize by copy with packing = none { section __DLIB_PERTHREAD }; +} + +place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec }; +place in IRAM_region { readonly }; +place in IRAM_region { readwrite, block CSTACK, block HEAP }; diff --git a/Platforms/FVP/ARMv81MML/LinkScripts/IAR/mem_ARMv81MML.h b/Platforms/FVP/ARMv81MML/LinkScripts/IAR/mem_ARMv81MML.h new file mode 100644 index 00000000..84a1ff1d --- /dev/null +++ b/Platforms/FVP/ARMv81MML/LinkScripts/IAR/mem_ARMv81MML.h @@ -0,0 +1,38 @@ +/**************************************************************************//** + * @file mem_ARMCM7.h + * @brief Memory base and size definitions (used in scatter file) + * @version V1.1.0 + * @date 15. May 2019 + * + * @note + * + ******************************************************************************/ +/* + * Copyright (c) 2009-2019 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __MEM_ARMCM7_H +#define __MEM_ARMCM7_H + + + +#define STACK_SIZE 0x00003000 +#define HEAP_SIZE 0x00100000 + + + +#endif /* __MEM_ARMCM7_H */ diff --git a/Platforms/FVP/ARMv81MML/Startup/IAR/startup_ARMv81MML.c b/Platforms/FVP/ARMv81MML/Startup/IAR/startup_ARMv81MML.c new file mode 100644 index 00000000..72c73241 --- /dev/null +++ b/Platforms/FVP/ARMv81MML/Startup/IAR/startup_ARMv81MML.c @@ -0,0 +1,164 @@ +/****************************************************************************** + * @file startup_ARMCM55.c + * @brief CMSIS-Core Device Startup File for Cortex-M55 Device + * @version V1.1.0 + * @date 16. December 2020 + ******************************************************************************/ +/* + * Copyright (c) 2020 Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the License); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#if defined (ARMv81MML_DSP_DP_MVE_FP) + #include "ARMv81MML_DSP_DP_MVE_FP.h" +#else + #error device not specified! +#endif + +/*---------------------------------------------------------------------------- + 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); + +/*---------------------------------------------------------------------------- + Internal References + *----------------------------------------------------------------------------*/ +__NO_RETURN void Reset_Handler (void); + void Default_Handler(void); + +/*---------------------------------------------------------------------------- + Exception / Interrupt Handler + *----------------------------------------------------------------------------*/ +/* Exceptions */ +void NMI_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void HardFault_Handler (void) __attribute__ ((weak)); +void MemManage_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void BusFault_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void UsageFault_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void SecureFault_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void SVC_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void DebugMon_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void PendSV_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void SysTick_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); + +void Interrupt0_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt1_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt2_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt3_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt4_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt5_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt6_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt7_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt8_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); +void Interrupt9_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); + + +/*---------------------------------------------------------------------------- + Exception / Interrupt Vector table + *----------------------------------------------------------------------------*/ + +#if defined ( __GNUC__ ) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpedantic" +#endif + +extern const VECTOR_TABLE_Type __VECTOR_TABLE[496]; + const VECTOR_TABLE_Type __VECTOR_TABLE[496] __VECTOR_TABLE_ATTRIBUTE = { + (VECTOR_TABLE_Type)(&__INITIAL_SP), /* Initial Stack Pointer */ + Reset_Handler, /* Reset Handler */ + NMI_Handler, /* -14 NMI Handler */ + HardFault_Handler, /* -13 Hard Fault Handler */ + MemManage_Handler, /* -12 MPU Fault Handler */ + BusFault_Handler, /* -11 Bus Fault Handler */ + UsageFault_Handler, /* -10 Usage Fault Handler */ + SecureFault_Handler, /* -9 Secure Fault Handler */ + 0, /* Reserved */ + 0, /* Reserved */ + 0, /* Reserved */ + SVC_Handler, /* -5 SVC Handler */ + DebugMon_Handler, /* -4 Debug Monitor Handler */ + 0, /* Reserved */ + PendSV_Handler, /* -2 PendSV Handler */ + SysTick_Handler, /* -1 SysTick Handler */ + + /* Interrupts */ + Interrupt0_Handler, /* 0 Interrupt 0 */ + Interrupt1_Handler, /* 1 Interrupt 1 */ + Interrupt2_Handler, /* 2 Interrupt 2 */ + Interrupt3_Handler, /* 3 Interrupt 3 */ + Interrupt4_Handler, /* 4 Interrupt 4 */ + Interrupt5_Handler, /* 5 Interrupt 5 */ + Interrupt6_Handler, /* 6 Interrupt 6 */ + Interrupt7_Handler, /* 7 Interrupt 7 */ + Interrupt8_Handler, /* 8 Interrupt 8 */ + Interrupt9_Handler /* 9 Interrupt 9 */ + /* Interrupts 10 .. 480 are left out */ +}; + +#if defined ( __GNUC__ ) +#pragma GCC diagnostic pop +#endif + +/*---------------------------------------------------------------------------- + Reset Handler called on controller reset + *----------------------------------------------------------------------------*/ +__NO_RETURN void Reset_Handler(void) +{ + __set_PSP((uint32_t)(&__INITIAL_SP)); + + __set_MSPLIM((uint32_t)(&__STACK_LIMIT)); + __set_PSPLIM((uint32_t)(&__STACK_LIMIT)); + +#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + __TZ_set_STACKSEAL_S((uint32_t *)(&__STACK_SEAL)); +#endif + + SystemInit(); /* CMSIS System Initialization */ + __PROGRAM_START(); /* Enter PreMain (C library entry point) */ +} + + +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wmissing-noreturn" +#endif + +/*---------------------------------------------------------------------------- + Hard Fault Handler + *----------------------------------------------------------------------------*/ +void HardFault_Handler(void) +{ + while(1); +} + +/*---------------------------------------------------------------------------- + Default Handler for Exceptions / Interrupts + *----------------------------------------------------------------------------*/ +void Default_Handler(void) +{ + while(1); +} + +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) + #pragma clang diagnostic pop +#endif + diff --git a/Platforms/FVP/ARMv81MML/system_ARMv81MML.c b/Platforms/FVP/ARMv81MML/system_ARMv81MML.c index 4a7cdca5..3c513c3a 100644 --- a/Platforms/FVP/ARMv81MML/system_ARMv81MML.c +++ b/Platforms/FVP/ARMv81MML/system_ARMv81MML.c @@ -33,11 +33,13 @@ #include #else #define GCCCOMPILER +#if !defined(__ICCARM__) struct __FILE {int handle;}; FILE __stdout; FILE __stdin; FILE __stderr; #endif +#endif #if defined (ARMv81MML_DSP_DP_MVE_FP) @@ -263,7 +265,11 @@ void stop_ipss_measurement() int stdout_putchar(char txchar) { +#if defined(__ICCARM__) + putchar(txchar); +#else SERIAL_DATA = txchar; +#endif return(txchar); } @@ -311,7 +317,9 @@ void SystemInit (void) } +#if !defined(__ICCARM__) __attribute__((constructor(255))) +#endif void platform_init(void) { printf("\n_[TEST START]____________________________________________________\n"); @@ -325,6 +333,7 @@ __asm(".global __ARM_use_no_argv\n\t"); # endif #endif +#if !defined(__ICCARM__) /** Writes the character specified by c (converted to an unsigned char) to the output stream pointed to by stream, at the position indicated by the @@ -351,6 +360,7 @@ int fputc (int c, FILE * stream) return (-1); } +#endif #ifndef GCCCOMPILER /* IO device file handles. */ diff --git a/Toolchain/ICCARM.cmake b/Toolchain/ICCARM.cmake new file mode 100644 index 00000000..c53a6228 --- /dev/null +++ b/Toolchain/ICCARM.cmake @@ -0,0 +1,225 @@ +function(compilerVersion) + execute_process(COMMAND "${CMAKE_C_COMPILER}" -dumpversion + OUTPUT_VARIABLE CVERSION + ERROR_VARIABLE CVERSION + ) + SET(COMPILERVERSION ${CVERSION} PARENT_SCOPE) + #cmake_print_variables(CVERSION) + #cmake_print_variables(CMAKE_C_COMPILER) + #MESSAGE( STATUS "CMD_OUTPUT:" ${CVERSION}) +endfunction() + +function(compilerSpecificCompileOptions PROJECTNAME ROOT) + get_target_property(DISABLEOPTIM ${PROJECTNAME} DISABLEOPTIMIZATION) + + # Add support for the type __fp16 even if there is no HW + # support for it. +# if (FLOAT16) +# target_compile_options(${PROJECTNAME} PUBLIC "-mfp16-format=ieee") +# endif() + + if ((OPTIMIZED) AND (NOT DISABLEOPTIM)) + target_compile_options(${PROJECTNAME} PUBLIC "-Oh") + endif() + +# if (FASTMATHCOMPUTATIONS) +# target_compile_options(${PROJECTNAME} PUBLIC "-ffast-math") +# endif() + +# if (HARDFP) +# target_compile_options(${PROJECTNAME} PUBLIC "-mfloat-abi=hard") +# target_link_options(${PROJECTNAME} PUBLIC "-mfloat-abi=hard") +# endif() + + if (LITTLEENDIAN) + target_compile_options(${PROJECTNAME} PUBLIC --endian little) + endif() + + if (CORTEXM OR CORTEXR) + target_compile_options(${PROJECTNAME} PUBLIC --thumb) + endif() + + target_link_options(${PROJECTNAME} PUBLIC "--cpu=${ARM_CPU}") + + if (ARM_CPU STREQUAL "cortex-m55" ) + target_compile_options(${PROJECTNAME} PUBLIC --fpu=vfpv5_d16) + target_link_options(${PROJECTNAME} PUBLIC --fpu=fpv5_d16) + endif() + + if (ARM_CPU STREQUAL "cortex-m55+nomve.fp+nofp" ) + target_compile_options(${PROJECTNAME} PUBLIC "-march=armv8.1-m.main+dsp+fp.dp") + target_compile_options(${PROJECTNAME} PUBLIC "-mfpu=fpv5_d16") + target_link_options(${PROJECTNAME} PUBLIC "-mfpu=fpv5_d16") + endif() + + + if (ARM_CPU STREQUAL "cortex-m33" ) + target_compile_options(${PROJECTNAME} PUBLIC --fpu=fpv5_sp) + target_link_options(${PROJECTNAME} PUBLIC --fpu=fpv5_sp) + endif() + + if (ARM_CPU STREQUAL "cortex-m7" ) + target_compile_options(${PROJECTNAME} PUBLIC --fpu=vfpv5_d16) + target_link_options(${PROJECTNAME} PUBLIC --fpu=vfpv5_d16) + endif() + + if (ARM_CPU STREQUAL "cortex-m4" ) + target_compile_options(${PROJECTNAME} PUBLIC --fpu=fpv4_sp) + target_link_options(${PROJECTNAME} PUBLIC --fpu=fpv4_sp) + endif() + + #if (ARM_CPU STREQUAL "cortex-m0" ) + # target_compile_options(${PROJECTNAME} PUBLIC "") + # target_link_options(${PROJECTNAME} PUBLIC "") + #endif() + + if (ARM_CPU STREQUAL "cortex-a32" ) + if (NOT (NEON OR NEONEXPERIMENTAL)) + target_compile_options(${PROJECTNAME} PUBLIC --cpu=cortex-a32 --fpu=vfpv3_d16) + target_link_options(${PROJECTNAME} PUBLIC --cpucortex-a32 --fpu=vfpv3_d16) + endif() + endif() + + if (ARM_CPU STREQUAL "cortex-a9" ) + if (NOT (NEON OR NEONEXPERIMENTAL)) + target_compile_options(${PROJECTNAME} PUBLIC "-march=armv7-a;-mfpu=vfpv3_d16") + target_link_options(${PROJECTNAME} PUBLIC "-march=armv7-a;-mfpu=vfpv3_d16") + endif() + endif() + + if (ARM_CPU STREQUAL "cortex-a7" ) + if (NOT (NEON OR NEONEXPERIMENTAL)) + target_compile_options(${PROJECTNAME} PUBLIC "-march=armv7-a;-mfpu=vfpv3_d16") + target_link_options(${PROJECTNAME} PUBLIC "-march=armv7-a;-mfpu=vfpv3_d16") + endif() + endif() + + if (ARM_CPU STREQUAL "cortex-a5" ) + if ((NEON OR NEONEXPERIMENTAL)) + target_compile_options(${PROJECTNAME} PUBLIC "-march=armv7-a;-mfpu=neon-vfpv4") + target_link_options(${PROJECTNAME} PUBLIC "-march=armv7-a;-mfpu=neon-vfpv4") + else() + target_compile_options(${PROJECTNAME} PUBLIC "-march=armv7-a;-mfpu=vfpv3_d16") + target_link_options(${PROJECTNAME} PUBLIC "-march=armv7-a;-mfpu=vfpv3_d16") + endif() + endif() + +endfunction() + +function(preprocessScatter CORE PLATFORMFOLDER SCATTERFILE) + + + file(REMOVE ${SCATTERFILE}) + + # Copy the mem file to the build directory + # so that it can be find when preprocessing the scatter file + # since we cannot pass an include path to armlink + add_custom_command( + OUTPUT + ${SCATTERFILE} + COMMAND + ${CMAKE_C_COMPILER} -I${PLATFORMFOLDER}/${CORE}/LinkScripts/IAR --silent --preprocess=n ${SCATTERFILE} ${PLATFORMFOLDER}/${CORE}/LinkScripts/IAR/lnk.icf + COMMAND + python ${ROOT}/CMSIS/DSP/filterLinkScript.py ${SCATTERFILE} + DEPENDS + "${PLATFORMFOLDER}/${CORE}/LinkScripts/IAR/lnk.icf;${PLATFORMFOLDER}/${CORE}/LinkScripts/IAR/mem_${CORE}.h" + ) + + add_custom_target( + scatter ALL + DEPENDS "${SCATTERFILE};${PLATFORMFOLDER}/${CORE}/LinkScripts/IAR/mem_${CORE}.h" + ) + + add_dependencies(${PROJECTNAME} scatter) +endfunction() + +function(toolchainSpecificLinkForCortexM PROJECTNAME ROOT CORE PLATFORMFOLDER HASCSTARTUP) + if (HASCSTARTUP) + target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/IAR/startup_${CORE}.c) + else() + target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/IAR/startup_${CORE}.s) + endif() + + target_include_directories(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/LinkScripts/IAR) + + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tempLink) + set(SCATTERFILE ${CMAKE_CURRENT_BINARY_DIR}/tempLink/lnk.icf) + preprocessScatter(${CORE} ${PLATFORMFOLDER} ${SCATTERFILE}) + + set_target_properties(${PROJECTNAME} PROPERTIES LINK_DEPENDS "${SCATTERFILE}") + + target_link_options(${PROJECTNAME} PRIVATE --entry=Reset_Handler --config ${SCATTERFILE}) +endfunction() + +function(toolchainSpecificLinkForCortexA PROJECTNAME ROOT CORE PLATFORMFOLDER) + target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/IAR/startup_${CORE}.c) + + # RTE Components + target_include_directories(${PROJECTNAME} PRIVATE ${ROOT}/CMSIS/DSP/Testing) + target_include_directories(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/LinkScripts/IAR) + + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tempLink) + set(SCATTERFILE ${CMAKE_CURRENT_BINARY_DIR}/tempLink/lnk.icf) + preprocessScatter(${CORE} ${PLATFORMFOLDER} ${SCATTERFILE}) + + + set_target_properties(${PROJECTNAME} PROPERTIES LINK_DEPENDS "${SCATTERFILE}") + + target_link_options(${PROJECTNAME} PRIVATE --entry=Reset_Handler --config ${SCATTERFILE}) +endfunction() + +function(toolchainSpecificLinkForCortexR PROJECTNAME ROOT CORE PLATFORMFOLDER) + target_sources(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/Startup/IAR/startup_${CORE}.c) + + # RTE Components + target_include_directories(${PROJECTNAME} PRIVATE ${ROOT}/CMSIS/DSP/Testing) + target_include_directories(${PROJECTNAME} PRIVATE ${PLATFORMFOLDER}/${CORE}/LinkScripts/IAR) + + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tempLink) + set(SCATTERFILE ${CMAKE_CURRENT_BINARY_DIR}/tempLink/lnk.icf) + preprocessScatter(${CORE} ${PLATFORMFOLDER} ${SCATTERFILE}) + + + set_target_properties(${PROJECTNAME} PROPERTIES LINK_DEPENDS "${SCATTERFILE}") + + target_link_options(${PROJECTNAME} PRIVATE --entry=Reset_Handler --config ${SCATTERFILE}) +endfunction() + +function(compilerSpecificPlatformConfigLibForM PROJECTNAME ROOT) + if (SEMIHOSTING) + target_link_options(${PROJECTNAME} PRIVATE --semihosting) + endif() +endfunction() + +function(compilerSpecificPlatformConfigLibForA PROJECTNAME ROOT) + if (SEMIHOSTING) + target_link_options(${PROJECTNAME} PRIVATE --semihosting) + endif() +endfunction() + +function(compilerSpecificPlatformConfigLibForR PROJECTNAME ROOT) + if (SEMIHOSTING) + target_link_options(${PROJECTNAME} PRIVATE --semihosting) + endif() +endfunction() + +function(compilerSpecificPlatformConfigAppForM PROJECTNAME ROOT) + if (SEMIHOSTING) + target_link_options(${PROJECTNAME} PRIVATE --semihosting) + endif() + +endfunction() + +function(compilerSpecificPlatformConfigAppForA PROJECTNAME ROOT) + if (SEMIHOSTING) + target_link_options(${PROJECTNAME} PRIVATE --semihosting) + endif() + +endfunction() + +function(compilerSpecificPlatformConfigAppForR PROJECTNAME ROOT) + if (SEMIHOSTING) + target_link_options(${PROJECTNAME} PRIVATE --semihosting) + endif() + +endfunction() diff --git a/Toolchain/Tools.cmake b/Toolchain/Tools.cmake index a4efcb6a..6dabb64d 100644 --- a/Toolchain/Tools.cmake +++ b/Toolchain/Tools.cmake @@ -12,7 +12,11 @@ if (GCC) include(Toolchain/GCC) endif() +if (ICCARM) + include(Toolchain/ICCARM) +endif() + if ((MSVC) OR (HOST)) function(compilerSpecificCompileOptions PROJECTNAME ROOT) endfunction() -endif() \ No newline at end of file +endif() diff --git a/iccarm.cmake b/iccarm.cmake new file mode 100644 index 00000000..264353ec --- /dev/null +++ b/iccarm.cmake @@ -0,0 +1,62 @@ +# Setting Linux is forcing th extension to be .o instead of .obj when building on WIndows. +# It is important because armlink is failing when files have .obj extensions (error with +# scatter file section not found) +SET(CMAKE_SYSTEM_NAME Linux) +SET(CMAKE_SYSTEM_PROCESSOR arm) + +#SET(CMAKE_C_COMPILER "${tools}/bin/arm-none-eabi-gcc") +#SET(CMAKE_CXX_COMPILER "${tools}/bin/arm-none-eabi-g++") +#SET(CMAKE_ASM_COMPILER "${tools}/bin/arm-none-eabi-gcc") + +find_program(CMAKE_C_COMPILER NAMES iccarm iccarm.exe) +find_program(CMAKE_CXX_COMPILER NAMES iccarm iccarm.exe) +find_program(CMAKE_ASM_COMPILER NAMES iasmarm iasmarm.exe) + + +if (NOT ("${tools}" STREQUAL "")) +message(STATUS "Tools path is set") +SET(CMAKE_AR "${tools}/bin/iarchive") +SET(CMAKE_CXX_COMPILER_AR "${tools}/bin/iarchive") +SET(CMAKE_C_COMPILER_AR "${tools}/bin/iarchive") +else() +find_program(CMAKE_AR NAMES iarchive iarchive.exe ) +find_program(CMAKE_CXX_COMPILER_AR NAMES iarchive iarchive.exe) +find_program(CMAKE_C_COMPILER_AR NAMES iarchive iarchive.exe) +endif() + +#SET(CMAKE_LINKER "${tools}/bin/arm-none-eabi-g++") +find_program(CMAKE_LINKER NAMES ilinkarm ilinkarm.exe) + +SET(CMAKE_C_LINK_EXECUTABLE " -o ") +SET(CMAKE_CXX_LINK_EXECUTABLE " -o ") +SET(CMAKE_C_OUTPUT_EXTENSION .o) +SET(CMAKE_CXX_OUTPUT_EXTENSION .o) +SET(CMAKE_ASM_OUTPUT_EXTENSION .o) +# When library defined as STATIC, this line is needed to describe how the .a file must be +# create. Some changes to the line may be needed. +SET(CMAKE_C_CREATE_STATIC_LIBRARY " -crs " ) +SET(CMAKE_CXX_CREATE_STATIC_LIBRARY " -crs " ) + +set(ICCARM ON) +# default core + +if(NOT ARM_CPU) + set( + ARM_CPU "cortex-a5" + CACHE STRING "Set ARM CPU. Default : cortex-a5" + ) +endif(NOT ARM_CPU) + +SET(CMAKE_C_FLAGS "--cpu=${ARM_CPU} -r" CACHE INTERNAL "C compiler common flags") +SET(CMAKE_CXX_FLAGS "--cpu=${ARM_CPU} --c++" CACHE INTERNAL "C compiler common flags") +SET(CMAKE_ASM_FLAGS "--cpu=${ARM_CPU}" CACHE INTERNAL "ASM compiler common flags") +SET(CMAKE_EXE_LINKER_FLAGS "--cpu=${ARM_CPU}" CACHE INTERNAL "linker flags") + +# Where is the target environment +#SET(CMAKE_FIND_ROOT_PATH "${tools}") +# Search for programs in the build host directories +SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +# For libraries and headers in the target directories +SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +