diff --git a/bsp/ipc.h b/bsp/ipc.h index 8dd585c95..808d8ad7e 100644 --- a/bsp/ipc.h +++ b/bsp/ipc.h @@ -115,11 +115,6 @@ typedef struct __attribute__((packed)) { ipc_tdma_server_data_t tdma_server; ///< TDMA server drv shared data } ipc_shared_data_t; -/** - * @brief Variable in RAM containing the shared data structure - */ -volatile __attribute__((section(".ARM.__at_0x20004000"))) ipc_shared_data_t ipc_shared_data; - /** * @brief Lock the mutex, blocks until the mutex is locked */ @@ -134,36 +129,8 @@ static inline void mutex_unlock(void) { NRF_MUTEX->MUTEX[0] = 0; } -#if defined(NRF_APPLICATION) -static inline void db_ipc_network_call(ipc_req_t req) { - if (req != DB_IPC_REQ_NONE) { - ipc_shared_data.req = req; - NRF_IPC_S->TASKS_SEND[DB_IPC_CHAN_REQ] = 1; - } - while (!ipc_shared_data.net_ack) { - if (ipc_shared_data.req == DB_IPC_REQ_NONE) { - // Something went wrong and, the net-core deleted the request without fulfilling it. - // Re-send it - ipc_shared_data.req = req; - NRF_IPC_S->TASKS_SEND[DB_IPC_CHAN_REQ] = 1; - } - } - ipc_shared_data.net_ack = false; -}; - -static inline void release_network_core(void) { - // Do nothing if network core is already started and ready - if (!NRF_RESET_S->NETWORK.FORCEOFF && ipc_shared_data.net_ready) { - return; - } else if (!NRF_RESET_S->NETWORK.FORCEOFF) { - ipc_shared_data.net_ready = false; - } - - NRF_POWER_S->TASKS_CONSTLAT = 1; - NRF_RESET_S->NETWORK.FORCEOFF = (RESET_NETWORK_FORCEOFF_FORCEOFF_Release << RESET_NETWORK_FORCEOFF_FORCEOFF_Pos); - - while (!ipc_shared_data.net_ready) {} -} -#endif +void db_ipc_network_call(ipc_req_t req); + +void release_network_core(void); #endif diff --git a/bsp/nrf/i2c.c b/bsp/nrf/i2c.c index a382655d8..8f2023f33 100644 --- a/bsp/nrf/i2c.c +++ b/bsp/nrf/i2c.c @@ -171,11 +171,11 @@ static void _twim_isr(i2c_t i2c) { } #if defined(NRF5340_XXAA) -void SERIAL0_IRQHandler(void) { +__attribute__((weak)) void SERIAL0_IRQHandler(void) { _twim_isr(0); } -void SERIAL1_IRQHandler(void) { +__attribute__((weak)) void SERIAL1_IRQHandler(void) { _twim_isr(1); } #else diff --git a/bsp/nrf/radio_nrf5340_app.c b/bsp/nrf/radio_nrf5340_app.c index 515da9891..e175560da 100644 --- a/bsp/nrf/radio_nrf5340_app.c +++ b/bsp/nrf/radio_nrf5340_app.c @@ -25,6 +25,8 @@ static radio_cb_t _radio_callback = NULL; +extern volatile __attribute__((section(".shared_data"))) ipc_shared_data_t ipc_shared_data; + //=========================== public =========================================== void db_radio_init(radio_cb_t callback, db_radio_mode_t mode) { diff --git a/bsp/nrf/rng_nrf5340_app.c b/bsp/nrf/rng_nrf5340_app.c index 0e0bb6558..4cd6ef460 100644 --- a/bsp/nrf/rng_nrf5340_app.c +++ b/bsp/nrf/rng_nrf5340_app.c @@ -16,7 +16,9 @@ #include "rng.h" #include "tz.h" -//========================== functions ========================================= +//========================== variables ========================================= + +extern volatile __attribute__((section(".shared_data"))) ipc_shared_data_t ipc_shared_data; //=========================== public =========================================== diff --git a/dotbot-v1.emProject b/dotbot-v1.emProject index f22a185d9..1e3528ac4 100644 --- a/dotbot-v1.emProject +++ b/dotbot-v1.emProject @@ -6,21 +6,24 @@ Name="Common" Placement="Flash" arm_architecture="v7EM" + arm_assembler_variant="SEGGER" arm_compiler_variant="SEGGER" arm_core_type="Cortex-M4" arm_endian="Little" arm_fp_abi="Hard" arm_fpu_type="FPv4-SP-D16" + arm_keep_assembly="Yes" arm_library_optimization="Small" - arm_linker_heap_size="8192" + arm_linker_heap_size="1024" arm_linker_process_stack_size="0" - arm_linker_stack_size="8192" - arm_linker_variant="SEGGER" + arm_linker_stack_size="2048" + arm_linker_variant="GNU" arm_rtl_variant="SEGGER" arm_simulator_memory_simulation_parameter="ROM1;0x00000000;0x00080000;RAM1;0x00800000;0x00020000;RAM2;0x20000000;0x00020000;" arm_target_debug_interface_type="ADIv5" arm_target_device_name="nRF52833_xxAA" arm_target_interface_type="SWD" + arm_use_builtins="Yes" build_intermediate_directory="Output/$(BuildTarget)/$(Configuration)/Obj/$(ProjectName)" build_output_directory="Output/$(BuildTarget)/$(Configuration)/Exe" build_output_file_name="$(OutDir)/$(ProjectName)-$(BuildTarget)$(EXE)" @@ -28,17 +31,24 @@ c_additional_options="-Wno-missing-field-initializers" c_preprocessor_definitions="ARM_MATH_CM4;NRF52833_XXAA;__nRF_FAMILY;CONFIG_NFCT_PINS_AS_GPIOS;FLASH_PLACEMENT=1;BOARD_DOTBOT_V1;OTA_USE_CRYPTO" c_user_include_directories="$(SolutionDir)/../bsp;$(SolutionDir)/../crypto;$(SolutionDir)/../drv;$(PackagesDir)/nRF/Device/Include;$(PackagesDir)/CMSIS_5/CMSIS/Core/Include" + clang_machine_outliner="Yes" + compiler_color_diagnostics="Yes" debug_register_definition_file="$(PackagesDir)/nRF/XML/nrf52833_Registers.xml" debug_stack_pointer_start="__stack_end__" debug_start_from_entry_point_symbol="No" debug_target_connection="J-Link" + gcc_c_language_standard="gnu17" + gcc_cplusplus_language_standard="gnu++20" gcc_enable_all_warnings="Yes" - gcc_entry_point="Reset_Handler" - link_linker_script_file="$(ProjectDir)/../../nRF/nrf52833/nRF_Flash_Variant1.icf" + gcc_entry_point="reset_handler" + link_dedupe_code="Yes" link_time_optimization="No" linker_memory_map_file="$(PackagesDir)/nRF/XML/nRF52833_xxAA_MemoryMap.xml" linker_output_format="hex" - macros="BuildTarget=dotbot-v1;Lh2ImplementationFile=lh2.c;PwmImplementationFile=pwm.c;RadioImplementationFile=radio.c;RngImplementationFile=rng.c;TdmaClientImplementationFile=tdma_client.c;TdmaServerImplementationFile=tdma_server.c;DeviceHeaderFile=$(PackagesDir)/nRF/Device/Include/nrf52833.h;DeviceCommonHeaderFile=$(PackagesDir)/nRF/Device/Include/nrf.h;DeviceSystemFile=$(PackagesDir)/nRF/Device/Source/system_nrf52.c;DeviceVectorsFile=$(PackagesDir)/nRF/Source/nrf52833_Vectors.s;DeviceCommonVectorsFile=$(PackagesDir)/nRF/Source/nRF_Startup.s;SeggerThumbStartup=$(ProjectDir)/../../../nRF/SEGGER_THUMB_Startup.s;DeviceLinkerScript=$(ProjectDir)/../../../nRF/nrf5340/nRF_Flash_Variant1.icf;DeviceMemoryMap=$(PackagesDir)/nRF/XML/nRF52840_xxAA_MemoryMap.xml;DeviceLibraryIdentifier=M4lf;DeviceFamily=nRF;Target=nRF52833_xxAA;Placement=Flash" + linker_printf_fmt_level="int" + linker_printf_fp_enabled="Float" + linker_section_placement_file="$(ProjectDir)/../../nRF/Setup/nRF52833_xxAA_flash_placement.xml" + macros="BuildTarget=dotbot-v1;Lh2ImplementationFile=lh2.c;PwmImplementationFile=pwm.c;RadioImplementationFile=radio.c;RngImplementationFile=rng.c;TdmaClientImplementationFile=tdma_client.c;TdmaServerImplementationFile=tdma_server.c;DeviceLibraryIdentifier=M4lf;DeviceFamily=nRF;Target=nRF52833_xxAA;Placement=Flash" project_type="Executable" target_reset_script="Reset();" target_trace_initialize_script="EnableTrace("$(TraceInterfaceType)")" /> diff --git a/dotbot-v2.emProject b/dotbot-v2.emProject index f52c45572..ee65209a9 100644 --- a/dotbot-v2.emProject +++ b/dotbot-v2.emProject @@ -1,23 +1,28 @@ diff --git a/drv/tdma_client/tdma_client_nrf5340_app.c b/drv/tdma_client/tdma_client_nrf5340_app.c index cfde4812a..90932e3ff 100644 --- a/drv/tdma_client/tdma_client_nrf5340_app.c +++ b/drv/tdma_client/tdma_client_nrf5340_app.c @@ -25,6 +25,8 @@ static tdma_client_cb_t _tdma_client_callback = NULL; +extern volatile __attribute__((section(".shared_data"))) ipc_shared_data_t ipc_shared_data; + //=========================== public =========================================== void db_tdma_client_init(tdma_client_cb_t callback, db_radio_mode_t radio_mode, uint8_t radio_freq, application_type_t default_radio_app) { diff --git a/drv/tdma_server/tdma_server_nrf5340_app.c b/drv/tdma_server/tdma_server_nrf5340_app.c index 199fa5957..8a63655c5 100644 --- a/drv/tdma_server/tdma_server_nrf5340_app.c +++ b/drv/tdma_server/tdma_server_nrf5340_app.c @@ -26,6 +26,8 @@ static tdma_server_cb_t _tdma_server_callback = NULL; +extern volatile __attribute__((section(".shared_data"))) ipc_shared_data_t ipc_shared_data; + //=========================== public =========================================== void db_tdma_server_init(tdma_server_cb_t callback, db_radio_mode_t radio_mode, uint8_t radio_freq, application_type_t default_radio_app) { diff --git a/freebot-v1.0.emProject b/freebot-v1.0.emProject index 03f54c2c7..bf114725b 100644 --- a/freebot-v1.0.emProject +++ b/freebot-v1.0.emProject @@ -6,21 +6,24 @@ Name="Common" Placement="Flash" arm_architecture="v7EM" + arm_assembler_variant="SEGGER" arm_compiler_variant="SEGGER" arm_core_type="Cortex-M4" arm_endian="Little" arm_fp_abi="Hard" arm_fpu_type="FPv4-SP-D16" + arm_keep_assembly="Yes" arm_library_optimization="Small" arm_linker_heap_size="1024" arm_linker_process_stack_size="0" arm_linker_stack_size="2048" - arm_linker_variant="SEGGER" + arm_linker_variant="GNU" arm_rtl_variant="SEGGER" arm_simulator_memory_simulation_parameter="ROM1;0x00000000;0x00080000;RAM1;0x00800000;0x00020000;RAM2;0x20000000;0x00020000;" arm_target_debug_interface_type="ADIv5" arm_target_device_name="nRF52840_xxAA" arm_target_interface_type="SWD" + arm_use_builtins="Yes" build_intermediate_directory="Output/$(BuildTarget)/$(Configuration)/Obj/$(ProjectName)" build_output_directory="Output/$(BuildTarget)/$(Configuration)/Exe" build_output_file_name="$(OutDir)/$(ProjectName)-$(BuildTarget)$(EXE)" @@ -28,17 +31,25 @@ c_additional_options="-Wno-missing-field-initializers" c_preprocessor_definitions="ARM_MATH_CM4;NRF52840_XXAA;__nRF_FAMILY;CONFIG_NFCT_PINS_AS_GPIOS;FLASH_PLACEMENT=1;BOARD_FREEBOT_V1_0;OTA_USE_CRYPTO;USE_CRYPTOCELL" c_user_include_directories="$(SolutionDir)/../bsp;$(SolutionDir)/../crypto;$(SolutionDir)/../drv;$(PackagesDir)/nRF/Device/Include;$(PackagesDir)/CMSIS_5/CMSIS/Core/Include" + clang_machine_outliner="Yes" + compiler_color_diagnostics="Yes" debug_register_definition_file="$(PackagesDir)/nRF/XML/nrf52840_Registers.xml" debug_stack_pointer_start="__stack_end__" debug_start_from_entry_point_symbol="No" debug_target_connection="J-Link" + gcc_c_language_standard="gnu17" + gcc_cplusplus_language_standard="gnu++20" gcc_enable_all_warnings="Yes" - gcc_entry_point="Reset_Handler" - link_linker_script_file="$(ProjectDir)/../../nRF/nrf52840/nRF_Flash_Variant4.icf" + gcc_entry_point="reset_handler" + link_dedupe_code="Yes" + linker_additional_options="--gc-sections" link_time_optimization="No" - linker_memory_map_file="$(PackagesDir)/nRF/XML/nRF52840_xxAA_MemoryMap.xml" + linker_memory_map_file="$(ProjectDir)/../../nRF/Setup/nRF52840_xxAA_MemoryMap.xml" linker_output_format="hex" - macros="BuildTarget=freebot-v1.0;Lh2ImplementationFile=lh2.c;PwmImplementationFile=pwm.c;RadioImplementationFile=radio.c;RngImplementationFile=rng.c;TdmaClientImplementationFile=tdma_client.c;TdmaServerImplementationFile=tdma_server.c;DeviceHeaderFile=$(PackagesDir)/nRF/Device/Include/nrf52840.h;DeviceCommonHeaderFile=$(PackagesDir)/nRF/Device/Include/nrf.h;DeviceSystemFile=$(PackagesDir)/nRF/Device/Source/system_nrf52.c;DeviceVectorsFile=$(PackagesDir)/nRF/Source/nrf52840_Vectors.s;DeviceCommonVectorsFile=$(PackagesDir)/nRF/Source/nRF_Startup.s;SeggerThumbStartup=$(ProjectDir)/../../../nRF/SEGGER_THUMB_Startup.s;DeviceLinkerScript=$(ProjectDir)/../../../nRF/nrf5340/nRF_Flash_Variant4.icf;DeviceMemoryMap=$(PackagesDir)/nRF/XML/nRF52840_xxAA_MemoryMap.xml;DeviceLibraryIdentifier=M4lf;DeviceFamily=nRF;Target=nRF52840_xxAA;Placement=Flash" + linker_printf_fmt_level="int" + linker_printf_fp_enabled="Float" + linker_section_placement_file="$(ProjectDir)/../../nRF/Setup/nRF52840_xxAA_flash_placement.xml" + macros="BuildTarget=freebot-v1.0;Lh2ImplementationFile=lh2.c;PwmImplementationFile=pwm.c;RadioImplementationFile=radio.c;RngImplementationFile=rng.c;TdmaClientImplementationFile=tdma_client.c;TdmaServerImplementationFile=tdma_server.c;DeviceLibraryIdentifier=M4lf;DeviceFamily=nRF;Target=nRF52840_xxAA;Placement=Flash" project_type="Executable" target_reset_script="Reset();" target_trace_initialize_script="EnableTrace("$(TraceInterfaceType)")" /> diff --git a/lh2-mini-mote.emProject b/lh2-mini-mote.emProject index 949b5f5b5..2c69bc44e 100644 --- a/lh2-mini-mote.emProject +++ b/lh2-mini-mote.emProject @@ -6,21 +6,24 @@ Name="Common" Placement="Flash" arm_architecture="v7EM" + arm_assembler_variant="SEGGER" arm_compiler_variant="SEGGER" arm_core_type="Cortex-M4" arm_endian="Little" arm_fp_abi="Hard" arm_fpu_type="FPv4-SP-D16" + arm_keep_assembly="Yes" arm_library_optimization="Small" - arm_linker_heap_size="8192" + arm_linker_heap_size="1024" arm_linker_process_stack_size="0" - arm_linker_stack_size="8192" - arm_linker_variant="SEGGER" + arm_linker_stack_size="2048" + arm_linker_variant="GNU" arm_rtl_variant="SEGGER" arm_simulator_memory_simulation_parameter="ROM1;0x00000000;0x00080000;RAM1;0x00800000;0x00020000;RAM2;0x20000000;0x00020000;" arm_target_debug_interface_type="ADIv5" arm_target_device_name="nRF52833_xxAA" arm_target_interface_type="SWD" + arm_use_builtins="Yes" build_intermediate_directory="Output/$(BuildTarget)/$(Configuration)/Obj/$(ProjectName)" build_output_directory="Output/$(BuildTarget)/$(Configuration)/Exe" build_output_file_name="$(OutDir)/$(ProjectName)-$(BuildTarget)$(EXE)" @@ -28,17 +31,25 @@ c_additional_options="-Wno-missing-field-initializers" c_preprocessor_definitions="ARM_MATH_CM4;NRF52833_XXAA;__nRF_FAMILY;CONFIG_NFCT_PINS_AS_GPIOS;FLASH_PLACEMENT=1;BOARD_LH2_MINI_MOTE;OTA_USE_CRYPTO" c_user_include_directories="$(SolutionDir)/../bsp;$(SolutionDir)/../crypto;$(SolutionDir)/../drv;$(PackagesDir)/nRF/Device/Include;$(PackagesDir)/CMSIS_5/CMSIS/Core/Include" + clang_machine_outliner="Yes" + compiler_color_diagnostics="Yes" debug_register_definition_file="$(PackagesDir)/nRF/XML/nrf52833_Registers.xml" debug_stack_pointer_start="__stack_end__" debug_start_from_entry_point_symbol="No" debug_target_connection="J-Link" + gcc_c_language_standard="gnu17" + gcc_cplusplus_language_standard="gnu++20" gcc_enable_all_warnings="Yes" - gcc_entry_point="Reset_Handler" - link_linker_script_file="$(ProjectDir)/../../nRF/nrf52833/nRF_Flash_Variant1.icf" + gcc_entry_point="reset_handler" + link_dedupe_code="Yes" + linker_additional_options="--gc-sections" link_time_optimization="No" - linker_memory_map_file="$(PackagesDir)/nRF/XML/nRF52833_xxAA_MemoryMap.xml" + linker_memory_map_file="$(ProjectDir)/../../nRF/Setup/nRF52833_xxAA_MemoryMap.xml" linker_output_format="hex" - macros="BuildTarget=lh2-mini-mote;Lh2ImplementationFile=lh2.c;PwmImplementationFile=pwm.c;RadioImplementationFile=radio.c;RngImplementationFile=rng.c;TdmaClientImplementationFile=tdma_client.c;TdmaServerImplementationFile=tdma_server.c;DeviceHeaderFile=$(PackagesDir)/nRF/Device/Include/nrf52833.h;DeviceCommonHeaderFile=$(PackagesDir)/nRF/Device/Include/nrf.h;DeviceSystemFile=$(PackagesDir)/nRF/Device/Source/system_nrf52.c;DeviceVectorsFile=$(PackagesDir)/nRF/Source/nrf52833_Vectors.s;DeviceCommonVectorsFile=$(PackagesDir)/nRF/Source/nRF_Startup.s;SeggerThumbStartup=$(ProjectDir)/../../../nRF/SEGGER_THUMB_Startup.s;DeviceLinkerScript=$(ProjectDir)/../../../nRF/nrf5340/nRF_Flash_Variant1.icf;DeviceMemoryMap=$(PackagesDir)/nRF/XML/nRF52840_xxAA_MemoryMap.xml;DeviceLibraryIdentifier=M4lf;DeviceFamily=nRF;Target=nRF52833_xxAA;Placement=Flash" + linker_printf_fmt_level="int" + linker_printf_fp_enabled="Float" + linker_section_placement_file="$(ProjectDir)/../../nRF/Setup/nRF52833_xxAA_flash_placement.xml" + macros="BuildTarget=lh2-mini-mote;Lh2ImplementationFile=lh2.c;PwmImplementationFile=pwm.c;RadioImplementationFile=radio.c;RngImplementationFile=rng.c;TdmaClientImplementationFile=tdma_client.c;TdmaServerImplementationFile=tdma_server.c;DeviceLibraryIdentifier=M4lf;DeviceFamily=nRF;Target=nRF52833_xxAA;Placement=Flash" project_type="Executable" target_reset_script="Reset();" target_trace_initialize_script="EnableTrace("$(TraceInterfaceType)")" /> diff --git a/nRF/SEGGER_THUMB_Startup.s b/nRF/SEGGER_THUMB_Startup.s deleted file mode 100644 index 8ee8503f8..000000000 --- a/nRF/SEGGER_THUMB_Startup.s +++ /dev/null @@ -1,281 +0,0 @@ -/********************************************************************* -* SEGGER Microcontroller GmbH * -* The Embedded Experts * -********************************************************************** -* * -* (c) 2014 - 2022 SEGGER Microcontroller GmbH * -* * -* www.segger.com Support: support@segger.com * -* * -********************************************************************** -* * -* All rights reserved. * -* * -* Redistribution and use in source and binary forms, with or * -* without modification, are permitted provided that the following * -* condition is met: * -* * -* - Redistributions of source code must retain the above copyright * -* notice, this condition and the following disclaimer. * -* * -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * -* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * -* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * -* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * -* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * -* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * -* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * -* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * -* DAMAGE. * -* * -********************************************************************** - --------------------------- END-OF-HEADER ----------------------------- - -File : SEGGER_THUMB_Startup.s -Purpose : Generic runtime init startup code for ARM CPUs running - in THUMB mode. - Designed to work with the SEGGER linker to produce - smallest possible executables. - - This file does not normally require any customization. - -Additional information: - Preprocessor Definitions - FULL_LIBRARY - If defined then - - argc, argv are set up by calling SEGGER_SEMIHOST_GetArgs(). - - the exit symbol is defined and executes on return from main. - - the exit symbol calls destructors, atexit functions and then - calls SEGGER_SEMIHOST_Exit(). - - If not defined then - - argc and argv are not valid (main is assumed to not take parameters) - - the exit symbol is defined, executes on return from main and - halts in a loop. -*/ - - .syntax unified - -/********************************************************************* -* -* Defines, configurable -* -********************************************************************** -*/ - -#ifndef APP_ENTRY_POINT - #define APP_ENTRY_POINT main -#endif - -#ifndef ARGSSPACE - #define ARGSSPACE 128 -#endif - -/********************************************************************* -* -* Macros -* -********************************************************************** -*/ -// -// Declare a label as function symbol (without switching sections) -// -.macro MARK_FUNC Name - .global \Name - .thumb_func - .code 16 -\Name: -.endm -// -// Declare a regular function. -// Functions from the startup are placed in the init section. -// -.macro START_FUNC Name - .section .init.\Name, "ax" - .global \Name - .balign 2 - .thumb_func - .code 16 -\Name: -.endm - -// -// Declare a weak function -// -.macro WEAK_FUNC Name - .section .init.\Name, "ax", %progbits - .weak \Name - .balign 2 - .thumb_func - .code 16 -\Name: -.endm - -// -// Mark the end of a function and calculate its size -// -.macro END_FUNC name - .size \name,.-\name -.endm - -/********************************************************************* -* -* Externals -* -********************************************************************** -*/ - .extern APP_ENTRY_POINT // typically main - -/********************************************************************* -* -* Global functions -* -********************************************************************** -*/ -/********************************************************************* -* -* _start -* -* Function description -* Entry point for the startup code. -* Usually called by the reset handler. -* Performs all initialisation, based on the entries in the -* linker-generated init table, then calls main(). -* It is device independent, so there should not be any need for an -* end-user to modify it. -* -* Additional information -* At this point, the stack pointer should already have been -* initialized -* - by hardware (such as on Cortex-M), -* - by the device-specific reset handler, -* - or by the debugger (such as for RAM Code). -*/ -#undef L -#define L(label) .L_start_##label - -START_FUNC _start - // - // Call linker init functions which in turn performs the following: - // * Perform segment init - // * Perform heap init (if used) - // * Call constructors of global Objects (if any exist) - // - ldr R4, =__SEGGER_init_table__ // Set table pointer to start of initialization table -L(RunInit): - ldr R0, [R4] // Get next initialization function from table - adds R4, R4, #4 // Increment table pointer to point to function arguments - blx R0 // Call initialization function - b L(RunInit) - // -MARK_FUNC __SEGGER_init_done -MARK_FUNC __startup_complete - // - // Time to call main(), the application entry point. - // -#ifndef FULL_LIBRARY - // - // In a real embedded application ("Free-standing environment"), - // main() does not get any arguments, - // which means it is not necessary to init R0 and R1. - // - bl APP_ENTRY_POINT // Call to application entry point (usually main()) - -END_FUNC _start - // - // end of _start - // Fall-through to exit if main ever returns. - // -MARK_FUNC exit - // - // In a free-standing environment, if returned from application: - // Loop forever. - // - b . - .size exit,.-exit -#else - // - // In a hosted environment, - // we need to load R0 and R1 with argc and argv, in order to handle - // the command line arguments. - // This is required for some programs running under control of a - // debugger, such as automated tests. - // - movs R0, #ARGSSPACE - ldr R1, =__SEGGER_init_arg_data - bl SEGGER_SEMIHOST_GetArgs - ldr R1, =__SEGGER_init_arg_data - bl APP_ENTRY_POINT // Call to application entry point (usually main()) - bl exit // Call exit function - b . // If we unexpectedly return from exit, hang. -END_FUNC _start -#endif - // -#ifdef FULL_LIBRARY -/********************************************************************* -* -* exit -* -* Function description -* Exit of the system. -* Called on return from application entry point or explicit call -* to exit. -* -* Additional information -* In a hosted environment exit gracefully, by -* saving the return value, -* calling destructurs of global objects, -* calling registered atexit functions, -* and notifying the host/debugger. -*/ -#undef L -#define L(label) .L_exit_##label - -WEAK_FUNC exit - mov R5, R0 // Save the exit parameter/return result - // - // Call destructors - // - ldr R0, =__dtors_start__ // Pointer to destructor list - ldr R1, =__dtors_end__ -L(Loop): - cmp R0, R1 - beq L(End) // Reached end of destructor list? => Done - ldr R2, [R0] // Load current destructor address into R2 - adds R0, R0, #4 // Increment pointer - push {R0-R1} // Save R0 and R1 - blx R2 // Call destructor - pop {R0-R1} // Restore R0 and R1 - b L(Loop) -L(End): - // - // Call atexit functions - // - bl __SEGGER_RTL_execute_at_exit_fns - // - // Call debug_exit with return result/exit parameter - // - mov R0, R5 - bl SEGGER_SEMIHOST_Exit - // - // If execution is not terminated, loop forever - // -L(ExitLoop): - b L(ExitLoop) // Loop forever. -END_FUNC exit -#endif - -#ifdef FULL_LIBRARY - .bss -__SEGGER_init_arg_data: - .space ARGSSPACE - .size __SEGGER_init_arg_data, .-__SEGGER_init_arg_data - .type __SEGGER_init_arg_data, %object -#endif - -/*************************** End of file ****************************/ diff --git a/nRF/Setup/nRF52833_xxAA_MemoryMap.xml b/nRF/Setup/nRF52833_xxAA_MemoryMap.xml new file mode 100644 index 000000000..133defd5d --- /dev/null +++ b/nRF/Setup/nRF52833_xxAA_MemoryMap.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/nRF/Setup/nRF52833_xxAA_flash_placement.xml b/nRF/Setup/nRF52833_xxAA_flash_placement.xml new file mode 100644 index 000000000..65546794b --- /dev/null +++ b/nRF/Setup/nRF52833_xxAA_flash_placement.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nRF/Setup/nRF52840_xxAA_MemoryMap.xml b/nRF/Setup/nRF52840_xxAA_MemoryMap.xml new file mode 100644 index 000000000..851c62457 --- /dev/null +++ b/nRF/Setup/nRF52840_xxAA_MemoryMap.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/nRF/Setup/nRF52840_xxAA_flash_placement.xml b/nRF/Setup/nRF52840_xxAA_flash_placement.xml new file mode 100644 index 000000000..75ad78b42 --- /dev/null +++ b/nRF/Setup/nRF52840_xxAA_flash_placement.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nRF/Setup/nRF5340_xxAA_Application_MemoryMap.xml b/nRF/Setup/nRF5340_xxAA_Application_MemoryMap.xml new file mode 100644 index 000000000..78807854b --- /dev/null +++ b/nRF/Setup/nRF5340_xxAA_Application_MemoryMap.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/nRF/Setup/nRF5340_xxAA_Application_flash_placement.xml b/nRF/Setup/nRF5340_xxAA_Application_flash_placement.xml new file mode 100644 index 000000000..5e891a9cb --- /dev/null +++ b/nRF/Setup/nRF5340_xxAA_Application_flash_placement.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nRF/Setup/nRF5340_xxAA_Network_MemoryMap.xml b/nRF/Setup/nRF5340_xxAA_Network_MemoryMap.xml new file mode 100644 index 000000000..bd01fe264 --- /dev/null +++ b/nRF/Setup/nRF5340_xxAA_Network_MemoryMap.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/nRF/Setup/nRF5340_xxAA_Network_flash_placement.xml b/nRF/Setup/nRF5340_xxAA_Network_flash_placement.xml new file mode 100644 index 000000000..7ce0d9d01 --- /dev/null +++ b/nRF/Setup/nRF5340_xxAA_Network_flash_placement.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nRF/System/cpu.c b/nRF/System/cpu.c new file mode 100644 index 000000000..bb07cf1b2 --- /dev/null +++ b/nRF/System/cpu.c @@ -0,0 +1,168 @@ +/** + * @file + * @ingroup bsp_cpu + * + * @brief Generic implementation of the cpu support. + * + * @author Alexandre Abadie + * + * @copyright Inria, 2024-present + */ +#include +#include +#include + +/** + * @file + * @author Alexandre Abadie + * @brief Startup code and vectors definition + * + * @copyright Inria, 2024 + * + */ + +#include +#include +#include +#include + +extern __NO_RETURN int main(void); +extern void system_init(void); + +extern uint32_t __data_load_start__; +extern uint32_t __data_start__; +extern uint32_t __data_end__; +extern uint32_t __text_load_start__; +extern uint32_t __text_start__; +extern uint32_t __text_end__; +extern uint32_t __fast_load_start__; +extern uint32_t __fast_start__; +extern uint32_t __fast_end__; +extern uint32_t __ctors_load_start__; +extern uint32_t __ctors_start__; +extern uint32_t __ctors_end__; +extern uint32_t __dtors_load_start__; +extern uint32_t __dtors_start__; +extern uint32_t __dtors_end__; +extern uint32_t __rodata_load_start__; +extern uint32_t __rodata_start__; +extern uint32_t __rodata_end__; +extern uint32_t __tdata_load_start__; +extern uint32_t __tdata_start__; +extern uint32_t __tdata_end__; + +extern uint32_t __bss_start__; +extern uint32_t __bss_end__; +extern uint32_t __tbss_start__; +extern uint32_t __tbss_end__; + +extern uint32_t __heap_start__; +extern uint32_t __heap_end__; + +extern uint32_t __stack_start__; +extern uint32_t __stack_end__; +extern uint32_t __stack_process_start__; +extern uint32_t __stack_process_end__; +extern uint32_t __HEAPSIZE__; +extern uint32_t __STACKSIZE__; +extern uint32_t __STACKSIZE_PROCESS__; + +void HardFault_Handler(void); + +#if defined(NRF5340_XXAA) && defined(NRF_APPLICATION) +#include "nRF5340_xxAA_Application_cpu.c" +#elif defined(NRF5340_XXAA) && defined(NRF_NETWORK) +#include "nRF5340_xxAA_Network_cpu.c" +#elif defined(NRF52840_XXAA) +#include "nRF52840_xxAA_cpu.c" +#elif defined(NRF52833_XXAA) +#include "nRF52833_xxAA_cpu.c" +#else +#error "Unsupported CPU" +#endif + +// Fix compile issue with Thread-Local Storage (https://wiki.segger.com/Thread-Local_Storage) +void __aeabi_read_tp(void) {} + +static void _copy(uint32_t *dst, uint32_t *src, uint32_t *end) { + while(dst < end) { + *dst++ = *src++; + } +} + +static void _zero(uint32_t *dst, uint32_t *end) { + while(dst < end) { + *dst++ = 0; + } +} + +// Entry point +void reset_handler(void) { + SCB->CPACR |= ((3UL << 10 * 2) | (3UL << 11 * 2)); /* set CP10 and CP11 Full Access */ + +#if defined(NRF5340_XXAA) && defined(NRF_APPLICATION) + __set_MSP((uint32_t)&__stack_end__); + __set_PSP((uint32_t)&__stack_process_end__); + __set_CONTROL(0); +#endif + + _copy(&__data_start__, &__data_load_start__, &__data_end__); + + uint32_t *src; + uint32_t *dst; + +#if defined(DEBUG) + src = &__text_load_start__; + dst = &__text_start__; + while(dst < &__text_end__) { + if (dst == src) { + break; + } + *dst++ = *src++; + } +#endif + _copy(&__fast_start__, &__fast_load_start__, &__fast_end__); + _copy(&__ctors_start__, &__ctors_load_start__, &__ctors_end__); + _copy(&__dtors_start__, &__dtors_load_start__, &__dtors_end__); + +#if defined(DEBUG) + src = &__rodata_load_start__; + dst = &__rodata_start__; + while(dst < &__rodata_end__) { + if (dst == src) { + break; + } + *dst++ = *src++; + } +#endif + src = &__tdata_load_start__; + dst = &__tdata_start__; + while(dst < &__tdata_end__) { + if (dst == src) { + *dst++ = *src++; + } + } + + // Zeroing bss data + _zero(&__bss_start__, &__bss_end__); + _zero(&__tbss_start__, &__tbss_end__); + +#if defined(NRF5340_XXAA) && defined(NRF_APPLICATION) + extern uint32_t __shared_data_start__; + extern uint32_t __shared_data_end__; + _zero(&__shared_data_start__, &__shared_data_end__); +#endif + + // Calling constructors + typedef void (*ctor_func_t)(void); + ctor_func_t func = (ctor_func_t)&__ctors_start__; + while(&func < (ctor_func_t *)&__ctors_end__) { + func++(); + } + +#ifndef __NO_SYSTEM_INIT + system_init(); +#endif + + main(); +} diff --git a/nRF/System/nRF52833_xxAA_cpu.c b/nRF/System/nRF52833_xxAA_cpu.c new file mode 100644 index 000000000..d3f6fdebb --- /dev/null +++ b/nRF/System/nRF52833_xxAA_cpu.c @@ -0,0 +1,160 @@ +/** + * @file + * @ingroup bsp_cpu + * + * @brief Generic implementation of the cpu support. + * + * @author Alexandre Abadie + * + * @copyright Inria, 2024-present + */ + +#include +#include +#include +#include + +__NO_RETURN extern void reset_handler(void); +__NO_RETURN void dummy_handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void exit(int status); + +// Exceptions handlers +__attribute__ ((weak, alias("dummy_handler"))) void NMI_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void MemManage_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void BusFault_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void UsageFault_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SVC_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void DebugMon_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void PendSV_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SysTick_Handler(void); + +void HardFault_Handler(void); + +// External interrupts handlers +__attribute__ ((weak, alias("dummy_handler"))) void POWER_CLOCK_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void RADIO_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void UARTE0_UART0_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void NFCT_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void GPIOTE_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SAADC_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void TIMER0_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void TIMER1_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void TIMER2_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void RTC0_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void TEMP_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void RNG_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void ECB_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void CCM_AAR_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void WDT_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void RTC1_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void QDEC_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void COMP_LPCOMP_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SWI0_EGU0_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SWI1_EGU1_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SWI2_EGU2_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SWI3_EGU3_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SWI4_EGU4_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SWI5_EGU5_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void TIMER3_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void TIMER4_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void PWM0_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void PDM_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void MWU_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void PWM1_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void PWM2_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SPIM2_SPIS2_SPI2_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void RTC2_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void I2S_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void FPU_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void USBD_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void UARTE1_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void PWM3_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SPIM3_IRQHandler(void); + +// Vector table +extern uint32_t __stack_end__; +typedef void(*vector_table_t)(void); +extern const vector_table_t _vectors[64]; +const vector_table_t _vectors[64] __attribute__((used, section(".vectors"))) = { + (vector_table_t)&__stack_end__, // 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 SVCall Handler + DebugMon_Handler, // -4 Debug Monitor Handler + 0, // Reserved + PendSV_Handler, // -2 PendSV Handler + SysTick_Handler, // -1 SysTick Handler + + // External Interrupts + POWER_CLOCK_IRQHandler, + RADIO_IRQHandler, + UARTE0_UART0_IRQHandler, + SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler, + SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler, + NFCT_IRQHandler, + GPIOTE_IRQHandler, + SAADC_IRQHandler, + TIMER0_IRQHandler, + TIMER1_IRQHandler, + TIMER2_IRQHandler, + RTC0_IRQHandler, + TEMP_IRQHandler, + RNG_IRQHandler, + ECB_IRQHandler, + CCM_AAR_IRQHandler, + WDT_IRQHandler, + RTC1_IRQHandler, + QDEC_IRQHandler, + COMP_LPCOMP_IRQHandler, + SWI0_EGU0_IRQHandler, + SWI1_EGU1_IRQHandler, + SWI2_EGU2_IRQHandler, + SWI3_EGU3_IRQHandler, + SWI4_EGU4_IRQHandler, + SWI5_EGU5_IRQHandler, + TIMER3_IRQHandler, + TIMER4_IRQHandler, + PWM0_IRQHandler, + PDM_IRQHandler, + 0, + 0, + MWU_IRQHandler, + PWM1_IRQHandler, + PWM2_IRQHandler, + SPIM2_SPIS2_SPI2_IRQHandler, + RTC2_IRQHandler, + I2S_IRQHandler, + FPU_IRQHandler, + USBD_IRQHandler, + UARTE1_IRQHandler, + 0, + 0, + 0, + 0, + PWM3_IRQHandler, + 0, + SPIM3_IRQHandler, +}; + +// Exception handlers +void HardFault_Handler(void) { + while(1) { + __NOP(); + } +} + +void dummy_handler(void) { + while(1) { + __NOP(); + } +} diff --git a/nRF/System/nRF52833_xxAA_system_init.c b/nRF/System/nRF52833_xxAA_system_init.c new file mode 100644 index 000000000..71b9e4db9 --- /dev/null +++ b/nRF/System/nRF52833_xxAA_system_init.c @@ -0,0 +1,35 @@ +/* + +Copyright (c) 2010 - 2021, Nordic Semiconductor ASA All rights reserved. + +SPDX-License-Identifier: BSD-3-Clause + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +3. Neither the name of Nordic Semiconductor ASA nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include "nRF52_system_init.c" diff --git a/nRF/System/nRF52840_xxAA_cpu.c b/nRF/System/nRF52840_xxAA_cpu.c new file mode 100644 index 000000000..cf4474f3e --- /dev/null +++ b/nRF/System/nRF52840_xxAA_cpu.c @@ -0,0 +1,162 @@ +/** + * @file + * @ingroup bsp_cpu + * + * @brief Generic implementation of the cpu support. + * + * @author Alexandre Abadie + * + * @copyright Inria, 2024-present + */ + +#include +#include +#include +#include + +__NO_RETURN extern void reset_handler(void); +__NO_RETURN void dummy_handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void exit(int status); + +// Exceptions handlers +__attribute__ ((weak, alias("dummy_handler"))) void NMI_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void MemManage_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void BusFault_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void UsageFault_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SVC_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void DebugMon_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void PendSV_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SysTick_Handler(void); + +void HardFault_Handler(void); + +// External interrupts handlers +__attribute__ ((weak, alias("dummy_handler"))) void POWER_CLOCK_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void RADIO_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void UARTE0_UART0_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void NFCT_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void GPIOTE_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SAADC_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void TIMER0_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void TIMER1_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void TIMER2_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void RTC0_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void TEMP_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void RNG_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void ECB_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void CCM_AAR_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void WDT_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void RTC1_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void QDEC_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void COMP_LPCOMP_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SWI0_EGU0_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SWI1_EGU1_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SWI2_EGU2_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SWI3_EGU3_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SWI4_EGU4_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SWI5_EGU5_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void TIMER3_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void TIMER4_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void PWM0_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void PDM_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void MWU_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void PWM1_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void PWM2_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SPIM2_SPIS2_SPI2_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void RTC2_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void I2S_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void FPU_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void USBD_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void UARTE1_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void QSPI_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void CRYPTOCELL_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void PWM3_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SPIM3_IRQHandler(void); + +// Vector table +extern uint32_t __stack_end__; +typedef void(*vector_table_t)(void); +extern const vector_table_t _vectors[64]; +const vector_table_t _vectors[64] __attribute__((used, section(".vectors"))) = { + (vector_table_t)&__stack_end__, // 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 SVCall Handler + DebugMon_Handler, // -4 Debug Monitor Handler + 0, // Reserved + PendSV_Handler, // -2 PendSV Handler + SysTick_Handler, // -1 SysTick Handler + + // External Interrupts + POWER_CLOCK_IRQHandler, + RADIO_IRQHandler, + UARTE0_UART0_IRQHandler, + SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler, + SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler, + NFCT_IRQHandler, + GPIOTE_IRQHandler, + SAADC_IRQHandler, + TIMER0_IRQHandler, + TIMER1_IRQHandler, + TIMER2_IRQHandler, + RTC0_IRQHandler, + TEMP_IRQHandler, + RNG_IRQHandler, + ECB_IRQHandler, + CCM_AAR_IRQHandler, + WDT_IRQHandler, + RTC1_IRQHandler, + QDEC_IRQHandler, + COMP_LPCOMP_IRQHandler, + SWI0_EGU0_IRQHandler, + SWI1_EGU1_IRQHandler, + SWI2_EGU2_IRQHandler, + SWI3_EGU3_IRQHandler, + SWI4_EGU4_IRQHandler, + SWI5_EGU5_IRQHandler, + TIMER3_IRQHandler, + TIMER4_IRQHandler, + PWM0_IRQHandler, + PDM_IRQHandler, + 0, + 0, + MWU_IRQHandler, + PWM1_IRQHandler, + PWM2_IRQHandler, + SPIM2_SPIS2_SPI2_IRQHandler, + RTC2_IRQHandler, + I2S_IRQHandler, + FPU_IRQHandler, + USBD_IRQHandler, + UARTE1_IRQHandler, + QSPI_IRQHandler, + CRYPTOCELL_IRQHandler, + 0, + 0, + PWM3_IRQHandler, + 0, + SPIM3_IRQHandler, +}; + +// Exception handlers +void HardFault_Handler(void) { + while(1) { + __NOP(); + } +} + +void dummy_handler(void) { + while(1) { + __NOP(); + } +} diff --git a/nRF/System/nRF52840_xxAA_system_init.c b/nRF/System/nRF52840_xxAA_system_init.c new file mode 100644 index 000000000..71b9e4db9 --- /dev/null +++ b/nRF/System/nRF52840_xxAA_system_init.c @@ -0,0 +1,35 @@ +/* + +Copyright (c) 2010 - 2021, Nordic Semiconductor ASA All rights reserved. + +SPDX-License-Identifier: BSD-3-Clause + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +3. Neither the name of Nordic Semiconductor ASA nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +*/ + +#include "nRF52_system_init.c" diff --git a/nRF/System/nRF52_system_init.c b/nRF/System/nRF52_system_init.c new file mode 100644 index 000000000..28dcb07be --- /dev/null +++ b/nRF/System/nRF52_system_init.c @@ -0,0 +1,311 @@ +/* + +Copyright (c) 2009-2021 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. + +NOTICE: This file has been modified by Nordic Semiconductor ASA. + +*/ + +/* NOTE: Template files (including this one) are application specific and therefore expected to + be copied into the application project folder prior to its use! */ + +#include +#include +#include "nrf.h" +#include "nrf_peripherals.h" +#include "nrf52_erratas.h" +#include "system_nrf52.h" +#include "system_nrf52_approtect.h" + +/* Select correct reset pin */ +/* Handle DEVELOP_IN-targets first as they take precedence over the later macros */ +#if defined (DEVELOP_IN_NRF52805) \ + || defined (DEVELOP_IN_NRF52810) \ + || defined (DEVELOP_IN_NRF52811) \ + || defined (DEVELOP_IN_NRF52832) + #define RESET_PIN 21 +#elif defined (DEVELOP_IN_NRF52820) \ + || defined (DEVELOP_IN_NRF52833) \ + || defined (DEVELOP_IN_NRF52840) + #define RESET_PIN 18 +#elif defined (NRF52805_XXAA) \ + || defined (NRF52810_XXAA) \ + || defined (NRF52811_XXAA) \ + || defined (NRF52832_XXAA) \ + || defined (NRF52832_XXAB) + #define RESET_PIN 21 +#elif defined (NRF52820_XXAA) \ + || defined (NRF52833_XXAA) \ + || defined (NRF52840_XXAA) + #define RESET_PIN 18 +#else + #error "A supported device macro must be defined." +#endif + +/* -- NVMC utility functions -- */ +/* Waits until NVMC is done with the current pending action */ +void nvmc_wait(void) +{ + while (NRF_NVMC->READY == NVMC_READY_READY_Busy){} +} + +/* Configure the NVMC to "mode". + Mode must be an enumerator of field NVMC_CONFIG_WEN */ +void nvmc_config(uint32_t mode) +{ + NRF_NVMC->CONFIG = mode << NVMC_CONFIG_WEN_Pos; + nvmc_wait(); +} + +void system_init(void) +{ + /* Enable SWO trace functionality. If ENABLE_SWO is not defined, SWO pin will be used as GPIO (see Product + Specification to see which one). */ + #if defined (ENABLE_SWO) && defined(CLOCK_TRACECONFIG_TRACEMUX_Pos) + CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; + NRF_CLOCK->TRACECONFIG |= CLOCK_TRACECONFIG_TRACEMUX_Serial << CLOCK_TRACECONFIG_TRACEMUX_Pos; + NRF_P0->PIN_CNF[18] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); + #endif + + /* Enable Trace functionality. If ENABLE_TRACE is not defined, TRACE pins will be used as GPIOs (see Product + Specification to see which ones). */ + #if defined (ENABLE_TRACE) && defined(CLOCK_TRACECONFIG_TRACEMUX_Pos) + CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; + NRF_CLOCK->TRACECONFIG |= CLOCK_TRACECONFIG_TRACEMUX_Parallel << CLOCK_TRACECONFIG_TRACEMUX_Pos; + NRF_P0->PIN_CNF[14] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); + NRF_P0->PIN_CNF[15] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); + NRF_P0->PIN_CNF[16] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); + NRF_P0->PIN_CNF[18] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); + NRF_P0->PIN_CNF[20] = (GPIO_PIN_CNF_DRIVE_H0H1 << GPIO_PIN_CNF_DRIVE_Pos) | (GPIO_PIN_CNF_INPUT_Connect << GPIO_PIN_CNF_INPUT_Pos) | (GPIO_PIN_CNF_DIR_Output << GPIO_PIN_CNF_DIR_Pos); + #endif + + #if NRF52_ERRATA_12_ENABLE_WORKAROUND + /* Workaround for Errata 12 "COMP: Reference ladder not correctly calibrated" found at the Errata document + for your device located at https://infocenter.nordicsemi.com/index.jsp */ + if (nrf52_errata_12()){ + *(volatile uint32_t *)0x40013540 = (*(uint32_t *)0x10000324 & 0x00001F00) >> 8; + } + #endif + + #if NRF52_ERRATA_16_ENABLE_WORKAROUND + /* Workaround for Errata 16 "System: RAM may be corrupt on wakeup from CPU IDLE" found at the Errata document + for your device located at https://infocenter.nordicsemi.com/index.jsp */ + if (nrf52_errata_16()){ + *(volatile uint32_t *)0x4007C074 = 3131961357ul; + } + #endif + + #if NRF52_ERRATA_31_ENABLE_WORKAROUND + /* Workaround for Errata 31 "CLOCK: Calibration values are not correctly loaded from FICR at reset" found at the Errata document + for your device located at https://infocenter.nordicsemi.com/index.jsp */ + if (nrf52_errata_31()){ + *(volatile uint32_t *)0x4000053C = ((*(volatile uint32_t *)0x10000244) & 0x0000E000) >> 13; + } + #endif + + #if NRF52_ERRATA_32_ENABLE_WORKAROUND + /* Workaround for Errata 32 "DIF: Debug session automatically enables TracePort pins" found at the Errata document + for your device located at https://infocenter.nordicsemi.com/index.jsp */ + if (nrf52_errata_32()){ + CoreDebug->DEMCR &= ~CoreDebug_DEMCR_TRCENA_Msk; + } + #endif + + #if NRF52_ERRATA_36_ENABLE_WORKAROUND + /* Workaround for Errata 36 "CLOCK: Some registers are not reset when expected" found at the Errata document + for your device located at https://infocenter.nordicsemi.com/index.jsp */ + if (nrf52_errata_36()){ + NRF_CLOCK->EVENTS_DONE = 0; + NRF_CLOCK->EVENTS_CTTO = 0; + NRF_CLOCK->CTIV = 0; + } + #endif + + #if NRF52_ERRATA_37_ENABLE_WORKAROUND + /* Workaround for Errata 37 "RADIO: Encryption engine is slow by default" found at the Errata document + for your device located at https://infocenter.nordicsemi.com/index.jsp */ + if (nrf52_errata_37()){ + *(volatile uint32_t *)0x400005A0 = 0x3; + } + #endif + + #if NRF52_ERRATA_57_ENABLE_WORKAROUND + /* Workaround for Errata 57 "NFCT: NFC Modulation amplitude" found at the Errata document + for your device located at https://infocenter.nordicsemi.com/index.jsp */ + if (nrf52_errata_57()){ + *(volatile uint32_t *)0x40005610 = 0x00000005; + *(volatile uint32_t *)0x40005688 = 0x00000001; + *(volatile uint32_t *)0x40005618 = 0x00000000; + *(volatile uint32_t *)0x40005614 = 0x0000003F; + } + #endif + + #if NRF52_ERRATA_66_ENABLE_WORKAROUND + /* Workaround for Errata 66 "TEMP: Linearity specification not met with default settings" found at the Errata document + for your device located at https://infocenter.nordicsemi.com/index.jsp */ + if (nrf52_errata_66()){ + NRF_TEMP->A0 = NRF_FICR->TEMP.A0; + NRF_TEMP->A1 = NRF_FICR->TEMP.A1; + NRF_TEMP->A2 = NRF_FICR->TEMP.A2; + NRF_TEMP->A3 = NRF_FICR->TEMP.A3; + NRF_TEMP->A4 = NRF_FICR->TEMP.A4; + NRF_TEMP->A5 = NRF_FICR->TEMP.A5; + NRF_TEMP->B0 = NRF_FICR->TEMP.B0; + NRF_TEMP->B1 = NRF_FICR->TEMP.B1; + NRF_TEMP->B2 = NRF_FICR->TEMP.B2; + NRF_TEMP->B3 = NRF_FICR->TEMP.B3; + NRF_TEMP->B4 = NRF_FICR->TEMP.B4; + NRF_TEMP->B5 = NRF_FICR->TEMP.B5; + NRF_TEMP->T0 = NRF_FICR->TEMP.T0; + NRF_TEMP->T1 = NRF_FICR->TEMP.T1; + NRF_TEMP->T2 = NRF_FICR->TEMP.T2; + NRF_TEMP->T3 = NRF_FICR->TEMP.T3; + NRF_TEMP->T4 = NRF_FICR->TEMP.T4; + } + #endif + + #if NRF52_ERRATA_98_ENABLE_WORKAROUND + /* Workaround for Errata 98 "NFCT: Not able to communicate with the peer" found at the Errata document + for your device located at https://infocenter.nordicsemi.com/index.jsp */ + if (nrf52_errata_98()){ + *(volatile uint32_t *)0x4000568Cul = 0x00038148ul; + } + #endif + + #if NRF52_ERRATA_103_ENABLE_WORKAROUND && defined(CCM_MAXPACKETSIZE_MAXPACKETSIZE_Pos) + /* Workaround for Errata 103 "CCM: Wrong reset value of CCM MAXPACKETSIZE" found at the Errata document + for your device located at https://infocenter.nordicsemi.com/index.jsp */ + if (nrf52_errata_103()){ + NRF_CCM->MAXPACKETSIZE = 0xFBul; + } + #endif + + #if NRF52_ERRATA_108_ENABLE_WORKAROUND + /* Workaround for Errata 108 "RAM: RAM content cannot be trusted upon waking up from System ON Idle or System OFF mode" found at the Errata document + for your device located at https://infocenter.nordicsemi.com/index.jsp */ + if (nrf52_errata_108()){ + *(volatile uint32_t *)0x40000EE4ul = *(volatile uint32_t *)0x10000258ul & 0x0000004Ful; + } + #endif + + #if NRF52_ERRATA_115_ENABLE_WORKAROUND + /* Workaround for Errata 115 "RAM: RAM content cannot be trusted upon waking up from System ON Idle or System OFF mode" found at the Errata document + for your device located at https://infocenter.nordicsemi.com/index.jsp */ + if (nrf52_errata_115()){ + *(volatile uint32_t *)0x40000EE4 = (*(volatile uint32_t *)0x40000EE4 & 0xFFFFFFF0) | (*(uint32_t *)0x10000258 & 0x0000000F); + } + #endif + + #if NRF52_ERRATA_120_ENABLE_WORKAROUND + /* Workaround for Errata 120 "QSPI: Data read or written is corrupted" found at the Errata document + for your device located at https://infocenter.nordicsemi.com/index.jsp */ + if (nrf52_errata_120()){ + *(volatile uint32_t *)0x40029640ul = 0x200ul; + } + #endif + + #if NRF52_ERRATA_136_ENABLE_WORKAROUND + /* Workaround for Errata 136 "System: Bits in RESETREAS are set when they should not be" found at the Errata document + for your device located at https://infocenter.nordicsemi.com/index.jsp */ + if (nrf52_errata_136()){ + if (NRF_POWER->RESETREAS & POWER_RESETREAS_RESETPIN_Msk){ + NRF_POWER->RESETREAS = ~POWER_RESETREAS_RESETPIN_Msk; + } + } + #endif + + #if NRF52_ERRATA_182_ENABLE_WORKAROUND + /* Workaround for Errata 182 "RADIO: Fixes for anomalies #102, #106, and #107 do not take effect" found at the Errata document + for your device located at https://infocenter.nordicsemi.com/index.jsp */ + if (nrf52_errata_182()){ + *(volatile uint32_t *) 0x4000173C |= (0x1 << 10); + } + #endif + + #if NRF52_ERRATA_217_ENABLE_WORKAROUND + /* Workaround for Errata 217 "RAM: RAM content cannot be trusted upon waking up from System ON Idle or System OFF mode" found at the Errata document + for your device located at https://infocenter.nordicsemi.com/index.jsp */ + if (nrf52_errata_217()){ + *(volatile uint32_t *)0x40000EE4ul |= 0x0000000Ful; + } + #endif + + /* Enable the FPU if the compiler used floating point unit instructions. __FPU_USED is a MACRO defined by the + * compiler. Since the FPU consumes energy, remember to disable FPU use in the compiler if floating point unit + * operations are not used in your code. */ + #if (__FPU_USED == 1) + SCB->CPACR |= (3UL << 20) | (3UL << 22); + __DSB(); + __ISB(); + #endif + + nrf52_handle_approtect(); + + #if NRF52_CONFIGURATION_249_ENABLE && (defined(NRF52805_XXAA) || defined(NRF52810_XXAA) || defined(NRF52811_XXAA)) + if (nrf52_configuration_249() && (NRF_UICR->NRFMDK[0] == 0xFFFFFFFF || NRF_UICR->NRFMDK[1] == 0xFFFFFFFF)) + { + nvmc_config(NVMC_CONFIG_WEN_Wen); + NRF_UICR->NRFMDK[0] = 0; + nvmc_wait(); + NRF_UICR->NRFMDK[1] = 0; + nvmc_wait(); + nvmc_config(NVMC_CONFIG_WEN_Ren); + } + #endif + + /* Configure NFCT pins as GPIOs if NFCT is not to be used in your code. If CONFIG_NFCT_PINS_AS_GPIOS is not defined, + two GPIOs (see Product Specification to see which ones) will be reserved for NFC and will not be available as + normal GPIOs. */ + #if defined (CONFIG_NFCT_PINS_AS_GPIOS) && defined(NFCT_PRESENT) + if ((NRF_UICR->NFCPINS & UICR_NFCPINS_PROTECT_Msk) == (UICR_NFCPINS_PROTECT_NFC << UICR_NFCPINS_PROTECT_Pos)){ + nvmc_config(NVMC_CONFIG_WEN_Wen); + NRF_UICR->NFCPINS &= ~UICR_NFCPINS_PROTECT_Msk; + nvmc_wait(); + nvmc_config(NVMC_CONFIG_WEN_Ren); + NVIC_SystemReset(); + } + #endif + + /* Configure GPIO pads as pPin Reset pin if Pin Reset capabilities desired. If CONFIG_GPIO_AS_PINRESET is not + defined, pin reset will not be available. One GPIO (see Product Specification to see which one) will then be + reserved for PinReset and not available as normal GPIO. */ + #if defined (CONFIG_GPIO_AS_PINRESET) + if (((NRF_UICR->PSELRESET[0] & UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos)) || + ((NRF_UICR->PSELRESET[1] & UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Connected << UICR_PSELRESET_CONNECT_Pos))){ + nvmc_config(NVMC_CONFIG_WEN_Wen); + NRF_UICR->PSELRESET[0] = RESET_PIN; + nvmc_wait(); + NRF_UICR->PSELRESET[1] = RESET_PIN; + nvmc_wait(); + nvmc_config(NVMC_CONFIG_WEN_Ren); + NVIC_SystemReset(); + } + #endif + + /* When developing for nRF52810 on an nRF52832, or nRF52811 on an nRF52840, + make sure NFC pins are mapped as GPIO. */ + #if defined (DEVELOP_IN_NRF52832) && defined(NRF52810_XXAA) \ + || defined (DEVELOP_IN_NRF52840) && defined(NRF52811_XXAA) + if ((*((uint32_t *)0x1000120C) & (1 << 0)) != 0){ + nvmc_config(NVMC_CONFIG_WEN_Wen); + *((uint32_t *)0x1000120C) = 0; + nvmc_wait(); + nvmc_config(NVMC_CONFIG_WEN_Ren); + NVIC_SystemReset(); + } + #endif +} diff --git a/nRF/System/nRF5340_xxAA_Application_cpu.c b/nRF/System/nRF5340_xxAA_Application_cpu.c new file mode 100644 index 000000000..89a94a403 --- /dev/null +++ b/nRF/System/nRF5340_xxAA_Application_cpu.c @@ -0,0 +1,223 @@ +/** + * @file + * @ingroup bsp_cpu + * + * @brief Generic implementation of the cpu support. + * + * @author Alexandre Abadie + * + * @copyright Inria, 2024-present + */ + +#include +#include +#include +#include +#include "ipc.h" + +__NO_RETURN extern void reset_handler(void); +__NO_RETURN void dummy_handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void exit(int status); + +// Exceptions handlers +__attribute__ ((weak, alias("dummy_handler"))) void NMI_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void MemManage_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void BusFault_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void UsageFault_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SVC_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void DebugMon_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void PendSV_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SysTick_Handler(void); + +void HardFault_Handler(void); + +// External interrupts handlers +__attribute__ ((weak, alias("dummy_handler"))) void FPU_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void CACHE_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SPU_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void CLOCK_POWER_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SERIAL0_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SERIAL1_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SPIM4_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SERIAL2_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SERIAL3_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void GPIOTE0_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SAADC_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void TIMER0_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void TIMER1_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void TIMER2_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void RTC0_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void RTC1_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void WDT0_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void WDT1_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void COMP_LPCOMP_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void EGU0_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void EGU1_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void EGU2_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void EGU3_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void EGU4_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void EGU5_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void PWM0_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void PWM1_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void PWM2_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void PWM3_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void PDM0_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void I2S0_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void IPC_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void QSPI_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void NFCT_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void GPIOTE1_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void QDEC0_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void QDEC1_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void USBD_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void USBREGULATOR_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void KMU_IRQHandler(void); +__attribute__ ((weak, alias("dummy_handler"))) void CRYPTOCELL_IRQHandler(void); + +#ifndef NO_IPC +volatile __attribute__((section(".shared_data"))) ipc_shared_data_t ipc_shared_data; + +void db_ipc_network_call(ipc_req_t req) { + if (req != DB_IPC_REQ_NONE) { + ipc_shared_data.req = req; + NRF_IPC_S->TASKS_SEND[DB_IPC_CHAN_REQ] = 1; + } + while (!ipc_shared_data.net_ack) { + if (ipc_shared_data.req == DB_IPC_REQ_NONE) { + // Something went wrong and, the net-core deleted the request without fulfilling it. + // Re-send it + ipc_shared_data.req = req; + NRF_IPC_S->TASKS_SEND[DB_IPC_CHAN_REQ] = 1; + } + } + ipc_shared_data.net_ack = false; +}; + +void release_network_core(void) { + // Do nothing if network core is already started and ready + if (!NRF_RESET_S->NETWORK.FORCEOFF && ipc_shared_data.net_ready) { + return; + } else if (!NRF_RESET_S->NETWORK.FORCEOFF) { + ipc_shared_data.net_ready = false; + } + + NRF_POWER_S->TASKS_CONSTLAT = 1; + NRF_RESET_S->NETWORK.FORCEOFF = (RESET_NETWORK_FORCEOFF_FORCEOFF_Release << RESET_NETWORK_FORCEOFF_FORCEOFF_Pos); + + while (!ipc_shared_data.net_ready) {} +} +#endif + +// Vector table +extern uint32_t __stack_end__; +typedef void(*vector_table_t)(void); +#if defined(IRQ_VECTORS_SHORT) +#define VECTORS_SIZE 30 +#else +#define VECTORS_SIZE 85 +#endif +extern const vector_table_t _vectors[VECTORS_SIZE]; +const vector_table_t _vectors[] __attribute__((used, section(".vectors"))) = { + (vector_table_t)&__stack_end__, // 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 SVCall Handler + DebugMon_Handler, // -4 Debug Monitor Handler + 0, // Reserved + PendSV_Handler, // -2 PendSV Handler + SysTick_Handler, // -1 SysTick Handler + + // External Interrupts + FPU_IRQHandler, + CACHE_IRQHandler, + 0, + SPU_IRQHandler, + 0, + CLOCK_POWER_IRQHandler, + 0, + 0, + SERIAL0_IRQHandler, + SERIAL1_IRQHandler, + SPIM4_IRQHandler, + SERIAL2_IRQHandler, + SERIAL3_IRQHandler, + GPIOTE0_IRQHandler, +#if !defined(IRQ_VECTORS_SHORT) + SAADC_IRQHandler, + TIMER0_IRQHandler, + TIMER1_IRQHandler, + TIMER2_IRQHandler, + 0, + 0, + RTC0_IRQHandler, + RTC1_IRQHandler, + 0, + 0, + WDT0_IRQHandler, + WDT1_IRQHandler, + COMP_LPCOMP_IRQHandler, + EGU0_IRQHandler, + EGU1_IRQHandler, + EGU2_IRQHandler, + EGU3_IRQHandler, + EGU4_IRQHandler, + EGU5_IRQHandler, + PWM0_IRQHandler, + PWM1_IRQHandler, + PWM2_IRQHandler, + PWM3_IRQHandler, + 0, + PDM0_IRQHandler, + 0, + I2S0_IRQHandler, + 0, + IPC_IRQHandler, + QSPI_IRQHandler, + 0, + NFCT_IRQHandler, + 0, + GPIOTE1_IRQHandler, + 0, + 0, + 0, + QDEC0_IRQHandler, + QDEC1_IRQHandler, + 0, + USBD_IRQHandler, + USBREGULATOR_IRQHandler, + 0, + KMU_IRQHandler, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + CRYPTOCELL_IRQHandler, +#endif +}; + +// Exception handlers +void HardFault_Handler(void) { + while(1) { + __NOP(); + } +} + +void dummy_handler(void) { + while(1) { + __NOP(); + } +} diff --git a/nRF/System/nRF5340_xxAA_Application_system_init.c b/nRF/System/nRF5340_xxAA_Application_system_init.c new file mode 100644 index 000000000..bf2822604 --- /dev/null +++ b/nRF/System/nRF5340_xxAA_Application_system_init.c @@ -0,0 +1,249 @@ +/* + +Copyright (c) 2009-2021 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. + +NOTICE: This file has been modified by Nordic Semiconductor ASA. + +*/ + +/* NOTE: Template files (including this one) are application specific and therefore expected to + be copied into the application project folder prior to its use! */ + +#include +#include +#include "nrf.h" +#include "nrf_peripherals.h" +#include "nrf53_erratas.h" +#include "system_nrf5340_application.h" +#include "system_nrf53_approtect.h" + +/*lint ++flb "Enter library region" */ + +void SystemStoreFICRNS(void); +void SystemLockFICRNS(void); + +void system_init(void) +{ + /* Perform Secure-mode initialization routines. */ + + /* Set all ARM SAU regions to NonSecure if TrustZone extensions are enabled. + * Nordic SPU should handle Secure Attribution tasks */ + #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) + SAU->CTRL |= (1 << SAU_CTRL_ALLNS_Pos); + #endif + + /* Workaround for Errata 97 "ERASEPROTECT, APPROTECT, or startup problems" found at the Errata document + for your device located at https://infocenter.nordicsemi.com/index.jsp */ + if (nrf53_errata_97()) + { + if (*((volatile uint32_t *)0x50004A20ul) == 0) + { + *((volatile uint32_t *)0x50004A20ul) = 0xDul; + *((volatile uint32_t *)0x5000491Cul) = 0x1ul; + *((volatile uint32_t *)0x5000491Cul) = 0x0ul; + } + } + + /* Trimming of the device. Copy all the trimming values from FICR into the target addresses. Trim + until one ADDR is not initialized. */ + uint32_t index = 0; + for (index = 0; index < 32ul && NRF_FICR_S->TRIMCNF[index].ADDR != (uint32_t *)0xFFFFFFFFul; index++){ + #if defined ( __ICCARM__ ) + /* IAR will complain about the order of volatile pointer accesses. */ + #pragma diag_suppress=Pa082 + #endif + *((volatile uint32_t *)NRF_FICR_S->TRIMCNF[index].ADDR) = NRF_FICR_S->TRIMCNF[index].DATA; + #if defined ( __ICCARM__ ) + #pragma diag_default=Pa082 + #endif + } + + /* errata 64 must be before errata 42, as errata 42 is dependant on the changes in errata 64*/ + /* Workaround for Errata 64 "VREGMAIN has invalid configuration when CPU is running at 128 MHz" found at the Errata document + for your device located at https://infocenter.nordicsemi.com/index.jsp */ + if (nrf53_errata_64()) + { + *((volatile uint32_t *)0x5000470Cul) = 0x29ul; + *((volatile uint32_t *)0x5000473Cul) = 0x3ul; + } + + /* Workaround for Errata 42 "Reset value of HFCLKCTRL is invalid" found at the Errata document + for your device located at https://infocenter.nordicsemi.com/index.jsp */ + if (nrf53_errata_42()) + { + *((volatile uint32_t *)0x50039530ul) = 0xBEEF0044ul; + NRF_CLOCK_S->HFCLKCTRL = CLOCK_HFCLKCTRL_HCLK_Div2 << CLOCK_HFCLKCTRL_HCLK_Pos; + } + + /* Workaround for Errata 46 "Higher power consumption of LFRC" found at the Errata document + for your device located at https://infocenter.nordicsemi.com/index.jsp */ + if (nrf53_errata_46()) + { + *((volatile uint32_t *)0x5003254Cul) = 0; + } + + /* Workaround for Errata 49 "SLEEPENTER and SLEEPEXIT events asserted after pin reset" found at the Errata document + for your device located at https://infocenter.nordicsemi.com/index.jsp */ + if (nrf53_errata_49()) + { + if (NRF_RESET_S->RESETREAS & RESET_RESETREAS_RESETPIN_Msk) + { + NRF_POWER_S->EVENTS_SLEEPENTER = 0; + NRF_POWER_S->EVENTS_SLEEPEXIT = 0; + } + } + + /* Workaround for Errata 55 "Bits in RESETREAS are set when they should not be" found at the Errata document + for your device located at https://infocenter.nordicsemi.com/index.jsp */ + if (nrf53_errata_55()) + { + if (NRF_RESET_S->RESETREAS & RESET_RESETREAS_RESETPIN_Msk){ + NRF_RESET_S->RESETREAS = ~RESET_RESETREAS_RESETPIN_Msk; + } + } + + /* Workaround for Errata 69 "VREGMAIN configuration is not retained in System OFF" found at the Errata document + for your device located at https://infocenter.nordicsemi.com/index.jsp */ + if (nrf53_errata_69()) + { + *((volatile uint32_t *)0x5000470Cul) =0x65ul; + } + + #if !defined(NRF_SKIP_FICR_NS_COPY_TO_RAM) + SystemStoreFICRNS(); + #endif + + #if defined(CONFIG_NFCT_PINS_AS_GPIOS) + if ((NRF_UICR_S->NFCPINS & UICR_NFCPINS_PROTECT_Msk) == (UICR_NFCPINS_PROTECT_NFC << UICR_NFCPINS_PROTECT_Pos)) + { + NRF_NVMC_S->CONFIG = NVMC_CONFIG_WEN_Wen << NVMC_CONFIG_WEN_Pos; + while (NRF_NVMC_S->READY == NVMC_READY_READY_Busy); + NRF_UICR_S->NFCPINS &= ~UICR_NFCPINS_PROTECT_Msk; + while (NRF_NVMC_S->READY == NVMC_READY_READY_Busy); + NRF_NVMC_S->CONFIG = NVMC_CONFIG_WEN_Ren << NVMC_CONFIG_WEN_Pos; + while (NRF_NVMC_S->READY == NVMC_READY_READY_Busy); + NVIC_SystemReset(); + } + #endif + + /* Enable SWO trace functionality. If ENABLE_SWO is not defined, SWO pin will be used as GPIO (see Product + Specification to see which one). */ + #if defined (ENABLE_SWO) + // Enable Trace And Debug peripheral + NRF_TAD_S->ENABLE = TAD_ENABLE_ENABLE_Msk; + NRF_TAD_S->CLOCKSTART = TAD_CLOCKSTART_START_Msk; + // Set up Trace pad SPU firewall + NRF_SPU_S->GPIOPORT[0].PERM &= ~(1 << TRACE_TRACEDATA0_PIN); + // Configure trace port pad + NRF_P0_S->PIN_CNF[TRACE_TRACEDATA0_PIN] = TRACE_PIN_CNF_VALUE; + // Select trace pin + NRF_TAD_S->PSEL.TRACEDATA0 = TRACE_TRACEDATA0_PIN; + // Set trace port speed to 64 MHz + NRF_TAD_S->TRACEPORTSPEED = TAD_TRACEPORTSPEED_TRACEPORTSPEED_64MHz; + #endif + + /* Enable Trace functionality. If ENABLE_TRACE is not defined, TRACE pins will be used as GPIOs (see Product + Specification to see which ones). */ + #if defined (ENABLE_TRACE) + // Enable Trace And Debug peripheral + NRF_TAD_S->ENABLE = TAD_ENABLE_ENABLE_Msk; + NRF_TAD_S->CLOCKSTART = TAD_CLOCKSTART_START_Msk; + // Set up Trace pads SPU firewall + NRF_SPU_S->GPIOPORT[0].PERM &= ~(1 << TRACE_TRACECLK_PIN); + NRF_SPU_S->GPIOPORT[0].PERM &= ~(1 << TRACE_TRACEDATA0_PIN); + NRF_SPU_S->GPIOPORT[0].PERM &= ~(1 << TRACE_TRACEDATA1_PIN); + NRF_SPU_S->GPIOPORT[0].PERM &= ~(1 << TRACE_TRACEDATA2_PIN); + NRF_SPU_S->GPIOPORT[0].PERM &= ~(1 << TRACE_TRACEDATA3_PIN); + // Configure trace port pads + NRF_P0_S->PIN_CNF[TRACE_TRACECLK_PIN] = TRACE_PIN_CNF_VALUE; + NRF_P0_S->PIN_CNF[TRACE_TRACEDATA0_PIN] = TRACE_PIN_CNF_VALUE; + NRF_P0_S->PIN_CNF[TRACE_TRACEDATA1_PIN] = TRACE_PIN_CNF_VALUE; + NRF_P0_S->PIN_CNF[TRACE_TRACEDATA2_PIN] = TRACE_PIN_CNF_VALUE; + NRF_P0_S->PIN_CNF[TRACE_TRACEDATA3_PIN] = TRACE_PIN_CNF_VALUE; + // Select trace pins + NRF_TAD_S->PSEL.TRACECLK = TRACE_TRACECLK_PIN; + NRF_TAD_S->PSEL.TRACEDATA0 = TRACE_TRACEDATA0_PIN; + NRF_TAD_S->PSEL.TRACEDATA1 = TRACE_TRACEDATA1_PIN; + NRF_TAD_S->PSEL.TRACEDATA2 = TRACE_TRACEDATA2_PIN; + NRF_TAD_S->PSEL.TRACEDATA3 = TRACE_TRACEDATA3_PIN; + // Set trace port speed to 64 MHz + NRF_TAD_S->TRACEPORTSPEED = TAD_TRACEPORTSPEED_TRACEPORTSPEED_64MHz; + #endif + + /* Allow Non-Secure code to run FPU instructions. + * If only the secure code should control FPU power state these registers should be configured accordingly in the secure application code. */ + SCB->NSACR |= (3UL << 10); + + /* Handle fw-branch APPROTECT setup. */ + nrf53_handle_approtect(); + + /* Enable the FPU if the compiler used floating point unit instructions. __FPU_USED is a MACRO defined by the + * compiler. Since the FPU consumes energy, remember to disable FPU use in the compiler if floating point unit + * operations are not used in your code. */ + #if (__FPU_USED == 1) + SCB->CPACR |= (3UL << 20) | (3UL << 22); + __DSB(); + __ISB(); + #endif +} + +/* Workaround to allow NS code to access FICR. Override NRF_FICR_NS to move FICR_NS buffer. */ +#define FICR_SIZE 0x1000ul +#define RAM_BASE 0x20000000ul +#define RAM_END 0x2FFFFFFFul + +/* Copy FICR_S to FICR_NS RAM region */ +void SystemStoreFICRNS(void) +{ + if ((uint32_t)NRF_FICR_NS < RAM_BASE || (uint32_t)NRF_FICR_NS + FICR_SIZE > RAM_END) + { + /* FICR_NS is not in RAM. */ + return; + } + /* Copy FICR to NS-accessible RAM block. */ + volatile uint32_t * from = (volatile uint32_t *)((uint32_t)NRF_FICR_S + (FICR_SIZE - sizeof(uint32_t))); + volatile uint32_t * to = (volatile uint32_t *)((uint32_t)NRF_FICR_NS + (FICR_SIZE - sizeof(uint32_t))); + volatile uint32_t * copy_from_end = (volatile uint32_t *)NRF_FICR_S; + while (from >= copy_from_end) + { + *(to--) = *(from--); + } + + /* Make RAM region NS. */ + uint32_t ram_region = ((uint32_t)NRF_FICR_NS - (uint32_t)RAM_BASE) / SPU_RAMREGION_SIZE; + NRF_SPU_S->RAMREGION[ram_region].PERM &= ~(1 << SPU_RAMREGION_PERM_SECATTR_Pos); +} + +/* Block write and execute access to FICR RAM region */ +void SystemLockFICRNS(void) +{ + if ((uint32_t)NRF_FICR_NS < RAM_BASE || (uint32_t)NRF_FICR_NS + FICR_SIZE > RAM_END) + { + /* FICR_NS is not in RAM. */ + return; + } + + uint32_t ram_region = ((uint32_t)NRF_FICR_NS - (uint32_t)RAM_BASE) / SPU_RAMREGION_SIZE; + NRF_SPU_S->RAMREGION[ram_region].PERM &= + ~( + (1 << SPU_RAMREGION_PERM_WRITE_Pos) | + (1 << SPU_RAMREGION_PERM_EXECUTE_Pos) + ); + NRF_SPU_S->RAMREGION[ram_region].PERM |= 1 << SPU_RAMREGION_PERM_LOCK_Pos; +} + +/*lint --flb "Leave library region" */ diff --git a/nRF/System/nRF5340_xxAA_Network_cpu.c b/nRF/System/nRF5340_xxAA_Network_cpu.c new file mode 100644 index 000000000..3b8df0332 --- /dev/null +++ b/nRF/System/nRF5340_xxAA_Network_cpu.c @@ -0,0 +1,121 @@ +/** + * @file + * @ingroup bsp_cpu + * + * @brief Generic implementation of the cpu support. + * + * @author Alexandre Abadie + * + * @copyright Inria, 2024-present + */ + +#include +#include +#include +#include + +__NO_RETURN extern void reset_handler(void); +__NO_RETURN void dummy_handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void exit(int status); + +// Exceptions handlers +__attribute__ ((weak, alias("dummy_handler"))) void NMI_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void MemManage_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void BusFault_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void UsageFault_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SVC_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void DebugMon_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void PendSV_Handler(void); +__attribute__ ((weak, alias("dummy_handler"))) void SysTick_Handler(void); + +void HardFault_Handler(void); + +// External interrupts handlers + __attribute__ ((weak, alias("dummy_handler"))) void CLOCK_POWER_IRQHandler(void); + __attribute__ ((weak, alias("dummy_handler"))) void RADIO_IRQHandler(void); + __attribute__ ((weak, alias("dummy_handler"))) void RNG_IRQHandler(void); + __attribute__ ((weak, alias("dummy_handler"))) void GPIOTE_IRQHandler(void); + __attribute__ ((weak, alias("dummy_handler"))) void WDT_IRQHandler(void); + __attribute__ ((weak, alias("dummy_handler"))) void TIMER0_IRQHandler(void); + __attribute__ ((weak, alias("dummy_handler"))) void ECB_IRQHandler(void); + __attribute__ ((weak, alias("dummy_handler"))) void AAR_CCM_IRQHandler(void); + __attribute__ ((weak, alias("dummy_handler"))) void TEMP_IRQHandler(void); + __attribute__ ((weak, alias("dummy_handler"))) void RTC0_IRQHandler(void); + __attribute__ ((weak, alias("dummy_handler"))) void IPC_IRQHandler(void); + __attribute__ ((weak, alias("dummy_handler"))) void SERIAL0_IRQHandler(void); + __attribute__ ((weak, alias("dummy_handler"))) void EGU0_IRQHandler(void); + __attribute__ ((weak, alias("dummy_handler"))) void RTC1_IRQHandler(void); + __attribute__ ((weak, alias("dummy_handler"))) void TIMER1_IRQHandler(void); + __attribute__ ((weak, alias("dummy_handler"))) void TIMER2_IRQHandler(void); + __attribute__ ((weak, alias("dummy_handler"))) void SWI0_IRQHandler(void); + __attribute__ ((weak, alias("dummy_handler"))) void SWI1_IRQHandler(void); + __attribute__ ((weak, alias("dummy_handler"))) void SWI2_IRQHandler(void); + __attribute__ ((weak, alias("dummy_handler"))) void SWI3_IRQHandler(void); + +// Vector table +extern uint32_t __stack_end__; +typedef void(*vector_table_t)(void); +extern const vector_table_t _vectors[48]; +const vector_table_t _vectors[48] __attribute__((used, section(".vectors"))) = { + (vector_table_t)&__stack_end__, // 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 SVCall Handler + DebugMon_Handler, // -4 Debug Monitor Handler + 0, // Reserved + PendSV_Handler, // -2 PendSV Handler + SysTick_Handler, // -1 SysTick Handler + + // External Interrupts + 0, + 0, + 0, + 0, + 0, + CLOCK_POWER_IRQHandler, + 0, + 0, + RADIO_IRQHandler, + RNG_IRQHandler, + GPIOTE_IRQHandler, + WDT_IRQHandler, + TIMER0_IRQHandler, + ECB_IRQHandler, + AAR_CCM_IRQHandler, + 0, + TEMP_IRQHandler, + RTC0_IRQHandler, + IPC_IRQHandler, + SERIAL0_IRQHandler, + EGU0_IRQHandler, + 0, + RTC1_IRQHandler, + 0, + TIMER1_IRQHandler, + TIMER2_IRQHandler, + SWI0_IRQHandler, + SWI1_IRQHandler, + SWI2_IRQHandler, + SWI3_IRQHandler, +}; + +// Exception handlers +void HardFault_Handler(void) { + while(1) { + __NOP(); + } +} + +void dummy_handler(void) { + while(1) { + __NOP(); + } +} diff --git a/nRF/System/nRF5340_xxAA_Network_system_init.c b/nRF/System/nRF5340_xxAA_Network_system_init.c new file mode 100644 index 000000000..d81ec598d --- /dev/null +++ b/nRF/System/nRF5340_xxAA_Network_system_init.c @@ -0,0 +1,72 @@ +/* + +Copyright (c) 2009-2021 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. + +NOTICE: This file has been modified by Nordic Semiconductor ASA. + +*/ + +/* NOTE: Template files (including this one) are application specific and therefore expected to + be copied into the application project folder prior to its use! */ + +#include +#include +#include "nrf.h" +#include "nrf53_erratas.h" +#include "system_nrf5340_network.h" +#include "system_nrf53_approtect.h" + + +void system_init(void) +{ + /* Trimming of the device. Copy all the trimming values from FICR into the target addresses. Trim + until one ADDR is not initialized. */ + uint32_t index = 0; + for (index = 0; index < 32ul && NRF_FICR_NS->TRIMCNF[index].ADDR != (uint32_t *)0xFFFFFFFFul; index++){ + #if defined ( __ICCARM__ ) + /* IAR will complain about the order of volatile pointer accesses. */ + #pragma diag_suppress=Pa082 + #endif + *((volatile uint32_t *)NRF_FICR_NS->TRIMCNF[index].ADDR) = NRF_FICR_NS->TRIMCNF[index].DATA; + #if defined ( __ICCARM__ ) + #pragma diag_default=Pa082 + #endif + } + + /* Workaround for Errata 49 "SLEEPENTER and SLEEPEXIT events asserted after pin reset" found at the Errata document + for your device located at https://infocenter.nordicsemi.com/index.jsp */ + if (nrf53_errata_49()) + { + if (NRF_RESET_NS->RESETREAS & RESET_RESETREAS_RESETPIN_Msk) + { + NRF_POWER_NS->EVENTS_SLEEPENTER = 0; + NRF_POWER_NS->EVENTS_SLEEPEXIT = 0; + } + } + + /* Workaround for Errata 55 "Bits in RESETREAS are set when they should not be" found at the Errata document + for your device located at https://infocenter.nordicsemi.com/index.jsp */ + if (nrf53_errata_55()) + { + if (NRF_RESET_NS->RESETREAS & RESET_RESETREAS_RESETPIN_Msk){ + NRF_RESET_NS->RESETREAS = ~RESET_RESETREAS_RESETPIN_Msk; + } + } + + /* Handle fw-branch APPROTECT setup. */ + nrf53_handle_approtect(); +} diff --git a/nRF/nrf52833/nRF_Flash_Variant1.icf b/nRF/nrf52833/nRF_Flash_Variant1.icf deleted file mode 100644 index bc428379e..000000000 --- a/nRF/nrf52833/nRF_Flash_Variant1.icf +++ /dev/null @@ -1,128 +0,0 @@ -/********************************************************************* -* SEGGER Microcontroller GmbH * -* The Embedded Experts * -********************************************************************** -* * -* (c) 2014 - 2022 SEGGER Microcontroller GmbH * -* * -* www.segger.com Support: support@segger.com * -* * -********************************************************************** -* * -* All rights reserved. * -* * -* Redistribution and use in source and binary forms, with or * -* without modification, are permitted provided that the following * -* condition is met: * -* * -* - Redistributions of source code must retain the above copyright * -* notice, this condition and the following disclaimer. * -* * -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * -* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * -* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * -* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * -* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * -* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * -* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * -* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * -* DAMAGE. * -* * -********************************************************************** --------------------------- END-OF-HEADER ----------------------------- - -File : nRF_Flash_Variant1.icf -Purpose : nRF linker script for application placement in Flash, - for use with the SEGGER Linker. -Maps : nRF52805_xxAA, nRF52810_xxAA, nRF52811_xxAA, nRF52820_xxAA, - nRF52832_xxAA, nRF52832_xxAB, nRF52833_xxAA -Literature: - [1] SEGGER Linker User Guide (https://www.segger.com/doc/UM20005_Linker.html) - [2] SEGGER Linker Section Placement (https://wiki.segger.com/SEGGER_Linker_Script_Files) -*/ - -define memory with size = 4G; - -// -// Combined regions per memory type -// -define region FLASH = FLASH1; -define region RAM = RAM1; - -// -// Block definitions -// -define block vectors { section .vectors }; // Vector table section -define block vectors_ram { section .vectors_ram }; // Vector table section -define block ctors { section .ctors, section .ctors.*, block with alphabetical order { init_array } }; -define block dtors { section .dtors, section .dtors.*, block with reverse alphabetical order { fini_array } }; -define block exidx { section .ARM.exidx, section .ARM.exidx.* }; -define block tbss { section .tbss, section .tbss.* }; -define block tdata { section .tdata, section .tdata.* }; -define block tls with fixed order { block tbss, block tdata }; -define block tdata_load { copy of block tdata }; -define block heap with auto size = __HEAPSIZE__, alignment = 8, readwrite access { }; -define block stack with size = __STACKSIZE__, alignment = 8, readwrite access { }; - -// -// Explicit initialization settings for sections -// Packing options for initialize by copy: packing=auto/lzss/zpak/packbits -// -do not initialize { section .non_init, section .non_init.*, section .*.non_init, section .*.non_init.* }; -do not initialize { section .no_init, section .no_init.*, section .*.no_init, section .*.no_init.* }; // Legacy sections, kept for backwards compatibility -do not initialize { section .noinit, section .noinit.*, section .*.noinit, section .*.noinit.* }; // Legacy sections, used by some SDKs/HALs -do not initialize { block vectors_ram }; -initialize by copy with packing=auto { section .data, section .data.*, section .*.data, section .*.data.* }; // Static data sections -initialize by copy with packing=auto { section .fast, section .fast.*, section .*.fast, section .*.fast.* }; // "RAM Code" sections - -#define USES_ALLOC_FUNC \ - linked symbol malloc || linked symbol aligned_alloc || \ - linked symbol calloc || linked symbol realloc - -initialize by calling __SEGGER_init_heap if USES_ALLOC_FUNC { block heap }; // Init the heap if one is required -initialize by calling __SEGGER_init_ctors { block ctors }; // Call constructors for global objects which need to be constructed before reaching main (if any). Make sure this is done after setting up heap. - -//assert with warning "free() linked into application but there are no calls to an allocation function!" { -// linked symbol free => USES_ALLOC_FUNC -//}; - -assert with error "heap is too small!" { USES_ALLOC_FUNC => size of block heap >= 48 }; -assert with error "heap size not a multiple of 8!" { USES_ALLOC_FUNC => size of block heap % 8 == 0 }; -assert with error "heap not correctly aligned!" { USES_ALLOC_FUNC => start of block heap % 8 == 0 }; - -// -// Explicit placement in FLASHn -// -place in FLASH1 { section .FLASH1, section .FLASH1.* }; -// -// FLASH Placement -// -place at start of FLASH { block vectors }; // Vector table section -place in FLASH with minimum size order { block tdata_load, // Thread-local-storage load image - block exidx, // ARM exception unwinding block - block ctors, // Constructors block - block dtors, // Destructors block - readonly, // Catch-all for readonly data (e.g. .rodata, .srodata) - readexec // Catch-all for (readonly) executable code (e.g. .text) - }; - -// -// Explicit placement in RAMn -// -place in CODE_RAM1 { section .CODE_RAM1, section .CODE_RAM1.* }; // This region may be deactivated and not accessible -place in RAM1 { section .RAM1, section .RAM1.* }; -// -// RAM Placement -// -place at start of RAM { block vectors_ram }; -place in RAM { section .fast, section .fast.* }; // "ramfunc" section -place in RAM with auto order { block tls, // Thread-local-storage block - readwrite, // Catch-all for initialized/uninitialized data sections (e.g. .data, .noinit) - zeroinit // Catch-all for zero-initialized data sections (e.g. .bss) - }; -place in RAM { block heap }; // Heap reserved block -place at end of RAM { block stack }; // Stack reserved block at the end diff --git a/nRF/nrf52840/nRF_Flash_Variant4.icf b/nRF/nrf52840/nRF_Flash_Variant4.icf deleted file mode 100644 index e21ebf201..000000000 --- a/nRF/nrf52840/nRF_Flash_Variant4.icf +++ /dev/null @@ -1,128 +0,0 @@ -/********************************************************************* -* SEGGER Microcontroller GmbH * -* The Embedded Experts * -********************************************************************** -* * -* (c) 2014 - 2022 SEGGER Microcontroller GmbH * -* * -* www.segger.com Support: support@segger.com * -* * -********************************************************************** -* * -* All rights reserved. * -* * -* Redistribution and use in source and binary forms, with or * -* without modification, are permitted provided that the following * -* condition is met: * -* * -* - Redistributions of source code must retain the above copyright * -* notice, this condition and the following disclaimer. * -* * -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * -* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * -* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * -* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * -* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * -* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * -* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * -* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * -* DAMAGE. * -* * -********************************************************************** --------------------------- END-OF-HEADER ----------------------------- - -File : nRF_Flash_Variant4.icf -Purpose : nRF linker script for application placement in Flash, - for use with the SEGGER Linker. -Maps : nRF52840_xxAA -Literature: - [1] SEGGER Linker User Guide (https://www.segger.com/doc/UM20005_Linker.html) - [2] SEGGER Linker Section Placement (https://wiki.segger.com/SEGGER_Linker_Script_Files) -*/ - -define memory with size = 4G; - -// -// Combined regions per memory type -// -define region FLASH = FLASH1; -define region RAM = RAM1; - -// -// Block definitions -// -define block vectors { section .vectors }; // Vector table section -define block vectors_ram { section .vectors_ram }; // Vector table section -define block ctors { section .ctors, section .ctors.*, block with alphabetical order { init_array } }; -define block dtors { section .dtors, section .dtors.*, block with reverse alphabetical order { fini_array } }; -define block exidx { section .ARM.exidx, section .ARM.exidx.* }; -define block tbss { section .tbss, section .tbss.* }; -define block tdata { section .tdata, section .tdata.* }; -define block tls with fixed order { block tbss, block tdata }; -define block tdata_load { copy of block tdata }; -define block heap with auto size = __HEAPSIZE__, alignment = 8, readwrite access { }; -define block stack with size = __STACKSIZE__, alignment = 8, readwrite access { }; - -// -// Explicit initialization settings for sections -// Packing options for initialize by copy: packing=auto/lzss/zpak/packbits -// -do not initialize { section .non_init, section .non_init.*, section .*.non_init, section .*.non_init.* }; -do not initialize { section .no_init, section .no_init.*, section .*.no_init, section .*.no_init.* }; // Legacy sections, kept for backwards compatibility -do not initialize { section .noinit, section .noinit.*, section .*.noinit, section .*.noinit.* }; // Legacy sections, used by some SDKs/HALs -do not initialize { block vectors_ram }; -initialize by copy with packing=auto { section .data, section .data.*, section .*.data, section .*.data.* }; // Static data sections -initialize by copy with packing=auto { section .fast, section .fast.*, section .*.fast, section .*.fast.* }; // "RAM Code" sections - -#define USES_ALLOC_FUNC \ - linked symbol malloc || linked symbol aligned_alloc || \ - linked symbol calloc || linked symbol realloc - -initialize by calling __SEGGER_init_heap if USES_ALLOC_FUNC { block heap }; // Init the heap if one is required -initialize by calling __SEGGER_init_ctors { block ctors }; // Call constructors for global objects which need to be constructed before reaching main (if any). Make sure this is done after setting up heap. - -//assert with warning "free() linked into application but there are no calls to an allocation function!" { -// linked symbol free => USES_ALLOC_FUNC -//}; - -assert with error "heap is too small!" { USES_ALLOC_FUNC => size of block heap >= 48 }; -assert with error "heap size not a multiple of 8!" { USES_ALLOC_FUNC => size of block heap % 8 == 0 }; -assert with error "heap not correctly aligned!" { USES_ALLOC_FUNC => start of block heap % 8 == 0 }; - -// -// Explicit placement in FLASHn -// -place in EXT_FLASH1 { section .EXT_FLASH1, section .EXT_FLASH1.* }; // This region may be deactivated and not accessible -place in FLASH1 { section .FLASH1, section .FLASH1.* }; -// -// FLASH Placement -// -place at start of FLASH { block vectors }; // Vector table section -place in FLASH with minimum size order { block tdata_load, // Thread-local-storage load image - block exidx, // ARM exception unwinding block - block ctors, // Constructors block - block dtors, // Destructors block - readonly, // Catch-all for readonly data (e.g. .rodata, .srodata) - readexec // Catch-all for (readonly) executable code (e.g. .text) - }; - -// -// Explicit placement in RAMn -// -place in CODE_RAM1 { section .CODE_RAM1, section .CODE_RAM1.* }; // This region may be deactivated and not accessible -place in RAM1 { section .RAM1, section .RAM1.* }; -// -// RAM Placement -// -place at start of RAM { block vectors_ram }; -place in RAM { section .fast, section .fast.* }; // "ramfunc" section -place in RAM with auto order { block tls, // Thread-local-storage block - readwrite, // Catch-all for initialized/uninitialized data sections (e.g. .data, .noinit) - zeroinit // Catch-all for zero-initialized data sections (e.g. .bss) - }; -place in RAM { block heap }; // Heap reserved block -place at end of RAM { block stack }; // Stack reserved block at the end diff --git a/nRF/nrf5340/nRF_Flash_Variant2.icf b/nRF/nrf5340/nRF_Flash_Variant2.icf deleted file mode 100644 index 649216310..000000000 --- a/nRF/nrf5340/nRF_Flash_Variant2.icf +++ /dev/null @@ -1,128 +0,0 @@ -/********************************************************************* -* SEGGER Microcontroller GmbH * -* The Embedded Experts * -********************************************************************** -* * -* (c) 2014 - 2022 SEGGER Microcontroller GmbH * -* * -* www.segger.com Support: support@segger.com * -* * -********************************************************************** -* * -* All rights reserved. * -* * -* Redistribution and use in source and binary forms, with or * -* without modification, are permitted provided that the following * -* condition is met: * -* * -* - Redistributions of source code must retain the above copyright * -* notice, this condition and the following disclaimer. * -* * -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * -* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * -* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * -* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * -* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * -* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * -* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * -* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * -* DAMAGE. * -* * -********************************************************************** --------------------------- END-OF-HEADER ----------------------------- - -File : nRF_Flash_Variant2.icf -Purpose : nRF linker script for application placement in Flash, - for use with the SEGGER Linker. -Maps : nRF5340_xxAA_Application -Literature: - [1] SEGGER Linker User Guide (https://www.segger.com/doc/UM20005_Linker.html) - [2] SEGGER Linker Section Placement (https://wiki.segger.com/SEGGER_Linker_Script_Files) -*/ - -define memory with size = 4G; - -// -// Combined regions per memory type -// -define region FLASH = FLASH1; -define region RAM = RAM1; - -// -// Block definitions -// -define block vectors { section .vectors }; // Vector table section -define block vectors_ram { section .vectors_ram }; // Vector table section -define block ctors { section .ctors, section .ctors.*, block with alphabetical order { init_array } }; -define block dtors { section .dtors, section .dtors.*, block with reverse alphabetical order { fini_array } }; -define block exidx { section .ARM.exidx, section .ARM.exidx.* }; -define block tbss { section .tbss, section .tbss.* }; -define block tdata { section .tdata, section .tdata.* }; -define block tls with fixed order { block tbss, block tdata }; -define block tdata_load { copy of block tdata }; -define block heap with auto size = __HEAPSIZE__, alignment = 8, readwrite access { }; -define block stack with size = __STACKSIZE__, alignment = 8, readwrite access { }; - -// -// Explicit initialization settings for sections -// Packing options for initialize by copy: packing=auto/lzss/zpak/packbits -// -do not initialize { section .non_init, section .non_init.*, section .*.non_init, section .*.non_init.* }; -do not initialize { section .no_init, section .no_init.*, section .*.no_init, section .*.no_init.* }; // Legacy sections, kept for backwards compatibility -do not initialize { section .noinit, section .noinit.*, section .*.noinit, section .*.noinit.* }; // Legacy sections, used by some SDKs/HALs -do not initialize { block vectors_ram }; -initialize by copy with packing=auto { section .data, section .data.*, section .*.data, section .*.data.* }; // Static data sections -initialize by copy with packing=auto { section .fast, section .fast.*, section .*.fast, section .*.fast.* }; // "RAM Code" sections - -#define USES_ALLOC_FUNC \ - linked symbol malloc || linked symbol aligned_alloc || \ - linked symbol calloc || linked symbol realloc - -initialize by calling __SEGGER_init_heap if USES_ALLOC_FUNC { block heap }; // Init the heap if one is required -initialize by calling __SEGGER_init_ctors { block ctors }; // Call constructors for global objects which need to be constructed before reaching main (if any). Make sure this is done after setting up heap. - -//assert with warning "free() linked into application but there are no calls to an allocation function!" { -// linked symbol free => USES_ALLOC_FUNC -//}; - -assert with error "heap is too small!" { USES_ALLOC_FUNC => size of block heap >= 48 }; -assert with error "heap size not a multiple of 8!" { USES_ALLOC_FUNC => size of block heap % 8 == 0 }; -assert with error "heap not correctly aligned!" { USES_ALLOC_FUNC => start of block heap % 8 == 0 }; - -// -// Explicit placement in FLASHn -// -place in EXT_FLASH1 { section .EXT_FLASH1, section .EXT_FLASH1.* }; // This region may be deactivated and not accessible -place in FLASH1 { section .FLASH1, section .FLASH1.* }; -// -// FLASH Placement -// -place at start of FLASH { block vectors }; // Vector table section -place in FLASH with minimum size order { block tdata_load, // Thread-local-storage load image - block exidx, // ARM exception unwinding block - block ctors, // Constructors block - block dtors, // Destructors block - readonly, // Catch-all for readonly data (e.g. .rodata, .srodata) - readexec // Catch-all for (readonly) executable code (e.g. .text) - }; - -// -// Explicit placement in RAMn -// -place in RAM1 { section .RAM1, section .RAM1.* }; -place in RAM2 { section .RAM2, section .RAM2.* }; // This region may be deactivated and not accessible -// -// RAM Placement -// -place at start of RAM { block vectors_ram }; -place in RAM { section .fast, section .fast.* }; // "ramfunc" section -place in RAM with auto order { block tls, // Thread-local-storage block - readwrite, // Catch-all for initialized/uninitialized data sections (e.g. .data, .noinit) - zeroinit // Catch-all for zero-initialized data sections (e.g. .bss) - }; -place in RAM { block heap }; // Heap reserved block -place at end of RAM { block stack }; // Stack reserved block at the end diff --git a/nRF/nrf5340/nRF_Flash_Variant3.icf b/nRF/nrf5340/nRF_Flash_Variant3.icf deleted file mode 100644 index 73267eeff..000000000 --- a/nRF/nrf5340/nRF_Flash_Variant3.icf +++ /dev/null @@ -1,129 +0,0 @@ -/********************************************************************* -* SEGGER Microcontroller GmbH * -* The Embedded Experts * -********************************************************************** -* * -* (c) 2014 - 2022 SEGGER Microcontroller GmbH * -* * -* www.segger.com Support: support@segger.com * -* * -********************************************************************** -* * -* All rights reserved. * -* * -* Redistribution and use in source and binary forms, with or * -* without modification, are permitted provided that the following * -* condition is met: * -* * -* - Redistributions of source code must retain the above copyright * -* notice, this condition and the following disclaimer. * -* * -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND * -* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, * -* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * -* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * -* DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR * -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * -* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; * -* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * -* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * -* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * -* DAMAGE. * -* * -********************************************************************** --------------------------- END-OF-HEADER ----------------------------- - -File : nRF_Flash_Variant3.icf -Purpose : nRF linker script for application placement in Flash, - for use with the SEGGER Linker. -Maps : nRF5340_xxAA_Network -Literature: - [1] SEGGER Linker User Guide (https://www.segger.com/doc/UM20005_Linker.html) - [2] SEGGER Linker Section Placement (https://wiki.segger.com/SEGGER_Linker_Script_Files) -*/ - -define memory with size = 4G; - -// -// Combined regions per memory type -// -define region FLASH = FLASH1; -define region RAM = RAM1; - -// -// Block definitions -// -define block vectors { section .vectors }; // Vector table section -define block vectors_ram { section .vectors_ram }; // Vector table section -define block ctors { section .ctors, section .ctors.*, block with alphabetical order { init_array } }; -define block dtors { section .dtors, section .dtors.*, block with reverse alphabetical order { fini_array } }; -define block exidx { section .ARM.exidx, section .ARM.exidx.* }; -define block tbss { section .tbss, section .tbss.* }; -define block tdata { section .tdata, section .tdata.* }; -define block tls with fixed order { block tbss, block tdata }; -define block tdata_load { copy of block tdata }; -define block heap with auto size = __HEAPSIZE__, alignment = 8, readwrite access { }; -define block stack with size = __STACKSIZE__, alignment = 8, readwrite access { }; - -// -// Explicit initialization settings for sections -// Packing options for initialize by copy: packing=auto/lzss/zpak/packbits -// -do not initialize { section .non_init, section .non_init.*, section .*.non_init, section .*.non_init.* }; -do not initialize { section .no_init, section .no_init.*, section .*.no_init, section .*.no_init.* }; // Legacy sections, kept for backwards compatibility -do not initialize { section .noinit, section .noinit.*, section .*.noinit, section .*.noinit.* }; // Legacy sections, used by some SDKs/HALs -do not initialize { block vectors_ram }; -initialize by copy with packing=auto { section .data, section .data.*, section .*.data, section .*.data.* }; // Static data sections -initialize by copy with packing=auto { section .fast, section .fast.*, section .*.fast, section .*.fast.* }; // "RAM Code" sections - -#define USES_ALLOC_FUNC \ - linked symbol malloc || linked symbol aligned_alloc || \ - linked symbol calloc || linked symbol realloc - -initialize by calling __SEGGER_init_heap if USES_ALLOC_FUNC { block heap }; // Init the heap if one is required -initialize by calling __SEGGER_init_ctors { block ctors }; // Call constructors for global objects which need to be constructed before reaching main (if any). Make sure this is done after setting up heap. - -//assert with warning "free() linked into application but there are no calls to an allocation function!" { -// linked symbol free => USES_ALLOC_FUNC -//}; - -assert with error "heap is too small!" { USES_ALLOC_FUNC => size of block heap >= 48 }; -assert with error "heap size not a multiple of 8!" { USES_ALLOC_FUNC => size of block heap % 8 == 0 }; -assert with error "heap not correctly aligned!" { USES_ALLOC_FUNC => start of block heap % 8 == 0 }; - -// -// Explicit placement in FLASHn -// -place in EXT_FLASH1 { section .EXT_FLASH1, section .EXT_FLASH1.* }; // This region may be deactivated and not accessible -place in FLASH1 { section .FLASH1, section .FLASH1.* }; -// -// FLASH Placement -// -place at start of FLASH { block vectors }; // Vector table section -place in FLASH with minimum size order { block tdata_load, // Thread-local-storage load image - block exidx, // ARM exception unwinding block - block ctors, // Constructors block - block dtors, // Destructors block - readonly, // Catch-all for readonly data (e.g. .rodata, .srodata) - readexec // Catch-all for (readonly) executable code (e.g. .text) - }; - -// -// Explicit placement in RAMn -// -place in RAM1 { section .RAM1, section .RAM1.* }; -place in RAM2 { section .RAM2, section .RAM2.* }; // This region may be deactivated and not accessible -place in RAM3 { section .RAM3, section .RAM3.* }; // This region may be deactivated and not accessible -// -// RAM Placement -// -place at start of RAM { block vectors_ram }; -place in RAM { section .fast, section .fast.* }; // "ramfunc" section -place in RAM with auto order { block tls, // Thread-local-storage block - readwrite, // Catch-all for initialized/uninitialized data sections (e.g. .data, .noinit) - zeroinit // Catch-all for zero-initialized data sections (e.g. .bss) - }; -place in RAM { block heap }; // Heap reserved block -place at end of RAM { block stack }; // Stack reserved block at the end diff --git a/nrf52833dk.emProject b/nrf52833dk.emProject index e7996c5f7..7476ffbbf 100644 --- a/nrf52833dk.emProject +++ b/nrf52833dk.emProject @@ -6,21 +6,24 @@ Name="Common" Placement="Flash" arm_architecture="v7EM" + arm_assembler_variant="SEGGER" arm_compiler_variant="SEGGER" arm_core_type="Cortex-M4" arm_endian="Little" arm_fp_abi="Hard" arm_fpu_type="FPv4-SP-D16" + arm_keep_assembly="Yes" arm_library_optimization="Small" arm_linker_heap_size="1024" arm_linker_process_stack_size="0" arm_linker_stack_size="2048" - arm_linker_variant="SEGGER" + arm_linker_variant="GNU" arm_rtl_variant="SEGGER" arm_simulator_memory_simulation_parameter="ROM1;0x00000000;0x00080000;RAM1;0x00800000;0x00020000;RAM2;0x20000000;0x00020000;" arm_target_debug_interface_type="ADIv5" arm_target_device_name="nRF52833_xxAA" arm_target_interface_type="SWD" + arm_use_builtins="Yes" build_intermediate_directory="Output/$(BuildTarget)/$(Configuration)/Obj/$(ProjectName)" build_output_directory="Output/$(BuildTarget)/$(Configuration)/Exe" build_output_file_name="$(OutDir)/$(ProjectName)-$(BuildTarget)$(EXE)" @@ -28,19 +31,25 @@ c_additional_options="-Wno-missing-field-initializers" c_preprocessor_definitions="ARM_MATH_CM4;NRF52833_XXAA;__nRF_FAMILY;CONFIG_NFCT_PINS_AS_GPIOS;FLASH_PLACEMENT=1;BOARD_NRF52833DK;OTA_USE_CRYPTO;UPGATE_USE_CRYPTO" c_user_include_directories="$(SolutionDir)/../bsp;$(SolutionDir)/../crypto;$(SolutionDir)/../drv;$(PackagesDir)/nRF/Device/Include;$(PackagesDir)/CMSIS_5/CMSIS/Core/Include" + clang_machine_outliner="Yes" + compiler_color_diagnostics="Yes" debug_register_definition_file="$(PackagesDir)/nRF/XML/nrf52833_Registers.xml" debug_stack_pointer_start="__stack_end__" debug_start_from_entry_point_symbol="No" debug_target_connection="J-Link" + gcc_c_language_standard="gnu17" + gcc_cplusplus_language_standard="gnu++20" gcc_enable_all_warnings="Yes" - gcc_entry_point="Reset_Handler" - link_linker_script_file="$(ProjectDir)/../../nRF/nrf52833/nRF_Flash_Variant1.icf" + gcc_entry_point="reset_handler" + link_dedupe_code="Yes" + linker_additional_options="--gc-sections" link_time_optimization="No" - linker_memory_map_file="$(PackagesDir)/nRF/XML/nRF52833_xxAA_MemoryMap.xml" + linker_memory_map_file="$(ProjectDir)/../../nRF/Setup/nRF52833_xxAA_MemoryMap.xml" linker_output_format="hex" linker_printf_fmt_level="int" linker_printf_fp_enabled="Float" - macros="BuildTarget=nrf52833dk;Lh2ImplementationFile=lh2.c;PwmImplementationFile=pwm.c;RadioImplementationFile=radio.c;RngImplementationFile=rng.c;TdmaClientImplementationFile=tdma_client.c;TdmaServerImplementationFile=tdma_server.c;DeviceHeaderFile=$(PackagesDir)/nRF/Device/Include/nrf52833.h;DeviceCommonHeaderFile=$(PackagesDir)/nRF/Device/Include/nrf.h;DeviceSystemFile=$(PackagesDir)/nRF/Device/Source/system_nrf52.c;DeviceVectorsFile=$(PackagesDir)/nRF/Source/nrf52833_Vectors.s;DeviceCommonVectorsFile=$(PackagesDir)/nRF/Source/nRF_Startup.s;SeggerThumbStartup=$(ProjectDir)/../../../nRF/SEGGER_THUMB_Startup.s;DeviceLinkerScript=$(ProjectDir)/../../../nRF/nrf5340/nRF_Flash_Variant1.icf;DeviceMemoryMap=$(PackagesDir)/nRF/XML/nRF52833_xxAA_MemoryMap.xml;DeviceLibraryIdentifier=M4lf;DeviceFamily=nRF;Target=nRF52833_xxAA;Placement=Flash" + linker_section_placement_file="$(ProjectDir)/../../nRF/Setup/nRF52833_xxAA_flash_placement.xml" + macros="BuildTarget=nrf52833dk;Lh2ImplementationFile=lh2.c;PwmImplementationFile=pwm.c;RadioImplementationFile=radio.c;RngImplementationFile=rng.c;TdmaClientImplementationFile=tdma_client.c;TdmaServerImplementationFile=tdma_server.c;DeviceLibraryIdentifier=M4lf;DeviceFamily=nRF;Target=nRF52833_xxAA;Placement=Flash" project_type="Executable" target_reset_script="Reset();" target_trace_initialize_script="EnableTrace("$(TraceInterfaceType)")" /> diff --git a/nrf52840dk.emProject b/nrf52840dk.emProject index c0f3809b0..b8c1f7f4e 100644 --- a/nrf52840dk.emProject +++ b/nrf52840dk.emProject @@ -6,21 +6,23 @@ Name="Common" Placement="Flash" arm_architecture="v7EM" + arm_assembler_variant="SEGGER" arm_compiler_variant="SEGGER" arm_core_type="Cortex-M4" arm_endian="Little" arm_fp_abi="Hard" arm_fpu_type="FPv4-SP-D16" + arm_keep_assembly="Yes" arm_library_optimization="Small" - arm_linker_heap_size="1024" - arm_linker_process_stack_size="0" - arm_linker_stack_size="2048" - arm_linker_variant="SEGGER" + arm_linker_heap_size="2048" + arm_linker_stack_size="1024" + arm_linker_variant="GNU" arm_rtl_variant="SEGGER" arm_simulator_memory_simulation_parameter="ROM1;0x00000000;0x00080000;RAM1;0x00800000;0x00020000;RAM2;0x20000000;0x00020000;" arm_target_debug_interface_type="ADIv5" arm_target_device_name="nRF52840_xxAA" arm_target_interface_type="SWD" + arm_use_builtins="Yes" build_intermediate_directory="Output/$(BuildTarget)/$(Configuration)/Obj/$(ProjectName)" build_output_directory="Output/$(BuildTarget)/$(Configuration)/Exe" build_output_file_name="$(OutDir)/$(ProjectName)-$(BuildTarget)$(EXE)" @@ -28,19 +30,27 @@ c_additional_options="-Wno-missing-field-initializers" c_preprocessor_definitions="ARM_MATH_CM4;NRF52840_XXAA;__nRF_FAMILY;CONFIG_NFCT_PINS_AS_GPIOS;FLASH_PLACEMENT=1;BOARD_NRF52840DK;OTA_USE_CRYPTO;USE_CRYPTOCELL;UPGATE_USE_CRYPTO" c_user_include_directories="$(SolutionDir)/../bsp;$(SolutionDir)/../crypto;$(SolutionDir)/../drv;$(PackagesDir)/nRF/Device/Include;$(PackagesDir)/CMSIS_5/CMSIS/Core/Include" + clang_machine_outliner="Yes" + compiler_color_diagnostics="Yes" debug_register_definition_file="$(PackagesDir)/nRF/XML/nrf52840_Registers.xml" debug_stack_pointer_start="__stack_end__" debug_start_from_entry_point_symbol="No" debug_target_connection="J-Link" + gcc_c_language_standard="gnu17" + gcc_cplusplus_language_standard="gnu++20" gcc_enable_all_warnings="Yes" - gcc_entry_point="Reset_Handler" - link_linker_script_file="$(ProjectDir)/../../nRF/nrf52840/nRF_Flash_Variant4.icf" + gcc_entry_point="reset_handler" + gcc_strip_symbols="No" + link_dedupe_code="Yes" link_time_optimization="No" - linker_memory_map_file="$(PackagesDir)/nRF/XML/nRF52840_xxAA_MemoryMap.xml" + linker_additional_options="--gc-sections" + linker_memory_map_file="$(ProjectDir)/../../nRF/Setup/nRF52840_xxAA_MemoryMap.xml" linker_output_format="hex" linker_printf_fmt_level="int" linker_printf_fp_enabled="Float" - macros="BuildTarget=nrf52840dk;Lh2ImplementationFile=lh2.c;PwmImplementationFile=pwm.c;RadioImplementationFile=radio.c;RngImplementationFile=rng.c;TdmaClientImplementationFile=tdma_client.c;TdmaServerImplementationFile=tdma_server.c;DeviceHeaderFile=$(PackagesDir)/nRF/Device/Include/nrf52840.h;DeviceCommonHeaderFile=$(PackagesDir)/nRF/Device/Include/nrf.h;DeviceSystemFile=$(PackagesDir)/nRF/Device/Source/system_nrf52.c;DeviceVectorsFile=$(PackagesDir)/nRF/Source/nrf52840_Vectors.s;DeviceCommonVectorsFile=$(PackagesDir)/nRF/Source/nRF_Startup.s;SeggerThumbStartup=$(ProjectDir)/../../../nRF/SEGGER_THUMB_Startup.s;DeviceLinkerScript=$(ProjectDir)/../../../nRF/nrf5340/nRF_Flash_Variant4.icf;DeviceMemoryMap=$(PackagesDir)/nRF/XML/nRF52840_xxAA_MemoryMap.xml;DeviceLibraryIdentifier=M4lf;DeviceFamily=nRF;Target=nRF52840_xxAA;Placement=Flash" + linker_printf_width_precision_supported="Yes" + linker_section_placement_file="$(ProjectDir)/../../nRF/Setup/nRF52840_xxAA_flash_placement.xml" + macros="BuildTarget=nrf52840dk;Lh2ImplementationFile=lh2.c;PwmImplementationFile=pwm.c;RadioImplementationFile=radio.c;RngImplementationFile=rng.c;TdmaClientImplementationFile=tdma_client.c;TdmaServerImplementationFile=tdma_server.c;DeviceLibraryIdentifier=M4lf;DeviceFamily=nRF;Target=nRF52840_xxAA;Placement=Flash" project_type="Executable" target_reset_script="Reset();" target_trace_initialize_script="EnableTrace("$(TraceInterfaceType)")" /> @@ -59,14 +69,14 @@ + + - - - + diff --git a/nrf5340dk-app.emProject b/nrf5340dk-app.emProject index fbbe5e035..a1c66cdd5 100644 --- a/nrf5340dk-app.emProject +++ b/nrf5340dk-app.emProject @@ -1,44 +1,56 @@ @@ -57,13 +69,13 @@ + - + + - - - + diff --git a/nrf5340dk-net.emProject b/nrf5340dk-net.emProject index 5b79c4a77..ee4e63135 100644 --- a/nrf5340dk-net.emProject +++ b/nrf5340dk-net.emProject @@ -1,23 +1,28 @@ diff --git a/otap/bootloader.emProject b/otap/bootloader.emProject index a3e389150..45a9d0e68 100644 --- a/otap/bootloader.emProject +++ b/otap/bootloader.emProject @@ -9,19 +9,8 @@ project_dependencies="00bsp_gpio(bsp);00bsp_uart(bsp);00bsp_timer_hf(bsp);00bsp_partition(bsp);00bsp_nvmc(bsp);00drv_dotbot_hdlc(drv);00drv_ota(drv)" project_directory="bootloader" project_type="Executable" /> - - - - - - - - - - + + @@ -29,16 +18,12 @@ - + - - - - - - + + diff --git a/otap/dotbot-v1-bootloader.emProject b/otap/dotbot-v1-bootloader.emProject index 3bad2fe19..efe300118 100644 --- a/otap/dotbot-v1-bootloader.emProject +++ b/otap/dotbot-v1-bootloader.emProject @@ -1,26 +1,29 @@ - + diff --git a/otap/dotbot-v2-bootloader.emProject b/otap/dotbot-v2-bootloader.emProject index 5dda0f4e0..1c7e3022a 100644 --- a/otap/dotbot-v2-bootloader.emProject +++ b/otap/dotbot-v2-bootloader.emProject @@ -5,40 +5,48 @@ Name="Common" Target="nRF5340_xxAA_Application" arm_architecture="v8M_Mainline" + arm_assembler_variant="SEGGER" arm_compiler_variant="SEGGER" arm_core_type="Cortex-M33" arm_endian="Little" arm_fp_abi="Hard" arm_fpu_type="FPv5-SP-D16" + arm_keep_assembly="Yes" arm_linker_heap_size="1024" arm_linker_process_stack_size="0" arm_linker_stack_size="2048" - arm_linker_variant="SEGGER" + arm_linker_variant="GNU" arm_rtl_variant="SEGGER" arm_target_debug_interface_type="ADIv5" arm_target_device_name="nRF5340_xxAA_Application" arm_target_interface_type="SWD" + arm_use_builtins="Yes" build_intermediate_directory="Output/$(BuildTarget)/$(Configuration)/Obj/$(ProjectName)" build_output_directory="Output/$(BuildTarget)/$(Configuration)/Exe" build_output_file_name="$(OutDir)/$(ProjectName)-$(BuildTarget)$(EXE)" build_treat_warnings_as_errors="Yes" c_additional_options="-Wno-strict-prototypes" - c_preprocessor_definitions="ARM_MATH_ARMV8MML;NRF5340_XXAA;NRF_APPLICATION;__NRF_FAMILY;CONFIG_NFCT_PINS_AS_GPIOS;FLASH_PLACEMENT=1;BOARD_DOTBOT_V2" + c_preprocessor_definitions="__NO_SYSTEM_INIT;ARM_MATH_ARMV8MML;__NO_FPU_ENABLE;NRF5340_XXAA;NRF_APPLICATION;__NRF_FAMILY;CONFIG_NFCT_PINS_AS_GPIOS;FLASH_PLACEMENT=1;BOARD_DOTBOT_V2" c_user_include_directories="$(SolutionDir)/../bsp;$(SolutionDir)/../crypto;$(SolutionDir)/../drv;$(PackagesDir)/nRF/Device/Include;$(PackagesDir)/CMSIS_5/CMSIS/Core/Include" debug_register_definition_file="$(PackagesDir)/nRF/XML/nrf5340_application_Registers.xml" + compiler_color_diagnostics="Yes" debug_stack_pointer_start="__stack_end__" debug_start_from_entry_point_symbol="No" debug_target_connection="J-Link" + gcc_c_language_standard="gnu17" + gcc_cplusplus_language_standard="gnu++20" gcc_enable_all_warnings="Yes" - gcc_entry_point="Reset_Handler" - link_linker_script_file="$(ProjectDir)/../../nRF/nrf5340/nRF_Flash_Variant2.icf" + gcc_entry_point="reset_handler" + link_dedupe_code="Yes" + linker_additional_options="--gc-sections" link_time_optimization="No" - linker_memory_map_file="$(PackagesDir)/nRF/XML/nRF5340_xxAA_Application_MemoryMap.xml" + linker_memory_map_file="$(ProjectDir)/nRF5340_xxAA_Application_MemoryMap.xml" linker_output_format="hex" linker_printf_fmt_level="int" linker_printf_fp_enabled="Float" linker_printf_width_precision_supported="Yes" - macros="BuildTarget=dotbot-v2;Lh2ImplementationFile=lh2.c;PwmImplementationFile=pwm.c;RadioImplementationFile=radio_nrf5340_app.c;RngImplementationFile=rng_nrf5340_app.c;DeviceHeaderFile=$(PackagesDir)/nRF/Device/Include/nrf5340_application.h;DeviceCommonHeaderFile=$(PackagesDir)/nRF/Device/Include/nrf.h;DeviceSystemFile=$(PackagesDir)/nRF/Device/Source/system_nrf5340_application.c;DeviceVectorsFile=$(PackagesDir)/nRF/Source/nrf5340_application_Vectors.s;DeviceCommonVectorsFile=$(PackagesDir)/nRF/Source/nRF_Startup.s;SeggerThumbStartup=$(ProjectDir)/../../../nRF/SEGGER_THUMB_Startup.s;DeviceLinkerScript=$(ProjectDir)/../../../nRF/nrf5340/nRF_Flash_Variant2.icf;DeviceMemoryMap=$(PackagesDir)/nRF/XML/nRF5340_xxAA_Application_MemoryMap.xml;DeviceFamily=nRF;Target=nRF5340_xxAA_Application" + linker_section_placement_file="$(ProjectDir)/../../nRF/Setup/nRF5340_xxAA_Application_flash_placement.xml" + macros="BuildTarget=dotbot-v2;Lh2ImplementationFile=lh2.c;PwmImplementationFile=pwm.c;RadioImplementationFile=radio_nrf5340_app.c;RngImplementationFile=rng_nrf5340_app.c;DeviceFamily=nRF;Target=nRF5340_xxAA_Application" project_type="Executable" target_reset_script="Reset();" target_trace_initialize_script="EnableTrace("$(TraceInterfaceType)")" /> diff --git a/otap/nrf52833dk-bootloader.emProject b/otap/nrf52833dk-bootloader.emProject index 0d168cda2..ee5fcfee8 100644 --- a/otap/nrf52833dk-bootloader.emProject +++ b/otap/nrf52833dk-bootloader.emProject @@ -6,39 +6,48 @@ Name="Common" Placement="Flash" arm_architecture="v7EM" + arm_assembler_variant="SEGGER" arm_compiler_variant="SEGGER" arm_core_type="Cortex-M4" arm_endian="Little" arm_fp_abi="Hard" arm_fpu_type="FPv4-SP-D16" + arm_keep_assembly="Yes" arm_library_optimization="Small" arm_linker_heap_size="1024" arm_linker_process_stack_size="0" arm_linker_stack_size="2048" - arm_linker_variant="SEGGER" + arm_linker_variant="GNU" arm_rtl_variant="SEGGER" arm_simulator_memory_simulation_parameter="ROM1;0x00000000;0x00080000;RAM1;0x00800000;0x00020000;RAM2;0x20000000;0x00020000;" arm_target_debug_interface_type="ADIv5" arm_target_device_name="nRF52833_xxAA" arm_target_interface_type="SWD" + arm_use_builtins="Yes" build_intermediate_directory="Output/$(BuildTarget)/$(Configuration)/Obj/$(ProjectName)" build_output_directory="Output/$(BuildTarget)/$(Configuration)/Exe" build_output_file_name="$(OutDir)/$(ProjectName)-$(BuildTarget)$(EXE)" build_treat_warnings_as_errors="Yes" c_additional_options="-Wno-missing-field-initializers" - c_preprocessor_definitions="ARM_MATH_CM4;NRF52833_XXAA;__nRF_FAMILY;CONFIG_NFCT_PINS_AS_GPIOS;FLASH_PLACEMENT=1;BOARD_NRF52833DK" + c_preprocessor_definitions="__NO_SYSTEM_INIT;__NO_FPU_ENABLE;ARM_MATH_CM4;NRF52833_XXAA;__nRF_FAMILY;CONFIG_NFCT_PINS_AS_GPIOS;FLASH_PLACEMENT=1;BOARD_NRF52833DK" c_user_include_directories="$(SolutionDir)/../bsp;$(SolutionDir)/../crypto;$(SolutionDir)/../drv;$(PackagesDir)/nRF/Device/Include;$(PackagesDir)/CMSIS_5/CMSIS/Core/Include" + compiler_color_diagnostics="Yes" debug_register_definition_file="$(PackagesDir)/nRF/XML/nrf52833_Registers.xml" debug_stack_pointer_start="__stack_end__" debug_start_from_entry_point_symbol="No" debug_target_connection="J-Link" + gcc_c_language_standard="gnu17" + gcc_cplusplus_language_standard="gnu++20" gcc_enable_all_warnings="Yes" - gcc_entry_point="Reset_Handler" - link_linker_script_file="$(ProjectDir)/../../nRF/nrf52833/nRF_Flash_Variant1.icf" + gcc_entry_point="reset_handler" + link_dedupe_code="Yes" + linker_additional_options="--gc-sections" link_time_optimization="No" - linker_memory_map_file="$(PackagesDir)/nRF/XML/nRF52833_xxAA_MemoryMap.xml" - linker_output_format="hex" - macros="BuildTarget=nrf52833dk;Lh2ImplementationFile=lh2.c;PwmImplementationFile=pwm.c;RadioImplementationFile=radio.c;RngImplementationFile=rng.c;DeviceHeaderFile=$(PackagesDir)/nRF/Device/Include/nrf52833.h;DeviceCommonHeaderFile=$(PackagesDir)/nRF/Device/Include/nrf.h;DeviceSystemFile=$(PackagesDir)/nRF/Device/Source/system_nrf52.c;DeviceVectorsFile=$(PackagesDir)/nRF/Source/nrf52833_Vectors.s;DeviceCommonVectorsFile=$(PackagesDir)/nRF/Source/nRF_Startup.s;SeggerThumbStartup=$(ProjectDir)/../../../nRF/SEGGER_THUMB_Startup.s;DeviceLinkerScript=$(ProjectDir)/../../../nRF/nrf5340/nRF_Flash_Variant1.icf;DeviceMemoryMap=$(PackagesDir)/nRF/XML/nRF52833_xxAA_MemoryMap.xml;DeviceLibraryIdentifier=M4lf;DeviceFamily=nRF;Target=nRF52833_xxAA;Placement=Flash" + linker_memory_map_file="$(ProjectDir)/nRF52833_xxAA_MemoryMap.xml" + linker_printf_fmt_level="int" + linker_printf_fp_enabled="Float" + linker_section_placement_file="$(ProjectDir)/../../nRF/Setup/nRF52833_xxAA_flash_placement.xml" + macros="BuildTarget=dotbot-v1;Lh2ImplementationFile=lh2.c;PwmImplementationFile=pwm.c;RadioImplementationFile=radio.c;RngImplementationFile=rng.c;DeviceLibraryIdentifier=M4lf;DeviceFamily=nRF;Target=nRF52833_xxAA;Placement=Flash" project_type="Executable" target_reset_script="Reset();" target_trace_initialize_script="EnableTrace("$(TraceInterfaceType)")" /> diff --git a/otap/nrf52840dk-bootloader.emProject b/otap/nrf52840dk-bootloader.emProject index 01f1868d4..db83f8a24 100644 --- a/otap/nrf52840dk-bootloader.emProject +++ b/otap/nrf52840dk-bootloader.emProject @@ -2,25 +2,28 @@ diff --git a/otap/nrf5340dk-app-bootloader.emProject b/otap/nrf5340dk-app-bootloader.emProject index 3d3deac5d..86e654406 100644 --- a/otap/nrf5340dk-app-bootloader.emProject +++ b/otap/nrf5340dk-app-bootloader.emProject @@ -1,44 +1,48 @@ diff --git a/otap/otap.emProject b/otap/otap.emProject index 697acf10d..05d3ba0e1 100644 --- a/otap/otap.emProject +++ b/otap/otap.emProject @@ -10,19 +10,8 @@ project_dependencies="00bsp_gpio(bsp);00bsp_timer(bsp);00drv_ota(drv);00bsp_radio(bsp)" project_directory="partition0" project_type="Executable" /> - - - - - - - - - - + + @@ -30,16 +19,13 @@ - + - - - - - - + + + @@ -52,19 +38,8 @@ project_dependencies="00bsp_gpio(bsp);00bsp_timer(bsp);00bsp_radio(bsp);00drv_ota(drv)" project_directory="partition1" project_type="Executable" /> - - - - - - - - - - + + @@ -72,16 +47,13 @@ - + - - - - - - + + + diff --git a/otap/sailbot-v1-bootloader.emProject b/otap/sailbot-v1-bootloader.emProject index e72ee8605..1adf0babd 100644 --- a/otap/sailbot-v1-bootloader.emProject +++ b/otap/sailbot-v1-bootloader.emProject @@ -1,44 +1,53 @@ - + diff --git a/projects/03app_nrf5340_net/main.c b/projects/03app_nrf5340_net/main.c index 50f91225a..6e6f019c9 100644 --- a/projects/03app_nrf5340_net/main.c +++ b/projects/03app_nrf5340_net/main.c @@ -32,11 +32,13 @@ typedef struct { tdma_table_entry_t client; } nrf53_net_vars_t; -//=========================== variables ========================================= +//=========================== variables ======================================== + +volatile __attribute__((section(".shared_data"))) ipc_shared_data_t ipc_shared_data; static nrf53_net_vars_t _nrf53_net_vars = { 0 }; -//=========================== functions ========================================= +//=========================== functions ======================================== void radio_callback(uint8_t *packet, uint8_t length) { mutex_lock(); @@ -62,7 +64,7 @@ void tdma_server_callback(uint8_t *packet, uint8_t length) { _nrf53_net_vars._data_received = true; } -//=========================== main ============================================== +//=========================== main ============================================= int main(void) { diff --git a/projects/projects-bsp-drv.emProject b/projects/projects-bsp-drv.emProject index 2eb719c4d..683b5a648 100644 --- a/projects/projects-bsp-drv.emProject +++ b/projects/projects-bsp-drv.emProject @@ -5,37 +5,22 @@ Name="Common" project_directory="01bsp_device" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -44,37 +29,22 @@ project_dependencies="00bsp_gpio(bsp)" project_directory="01bsp_gpio" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -83,37 +53,22 @@ project_dependencies="00bsp_i2c(bsp);00bsp_dotbot_board(bsp);00bsp_timer_hf(bsp)" project_directory="01bsp_i2c" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -122,37 +77,22 @@ project_dependencies="00bsp_dotbot_board(bsp);00bsp_dotbot_lh2(bsp)" project_directory="01bsp_lighthouse" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -161,37 +101,22 @@ project_dependencies="00bsp_nvmc(bsp)" project_directory="01bsp_nvmc" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -200,37 +125,22 @@ project_dependencies="00bsp_qdec(bsp);00bsp_timer(bsp)" project_directory="01bsp_qdec" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -239,37 +149,22 @@ project_dependencies="00bsp_qspi(bsp)" project_directory="01bsp_qspi" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -278,28 +173,16 @@ project_dependencies="00bsp_dotbot_board(bsp);00bsp_radio(bsp);00bsp_gpio(bsp);00bsp_timer_hf(bsp)" project_directory="01bsp_radio_txrx" project_type="Executable" /> - - - - - - - - - - - - + + + - + @@ -307,12 +190,9 @@ - - - - - - + + + @@ -321,28 +201,16 @@ project_dependencies="00bsp_dotbot_board(bsp);00bsp_radio(bsp);00bsp_gpio(bsp);00bsp_timer_hf(bsp)" project_directory="01bsp_radio_txrx_ieee802154" project_type="Executable" /> - - - - - - - - - - - - + + + - + @@ -350,12 +218,9 @@ - - - - - - + + + @@ -364,28 +229,16 @@ project_dependencies="00bsp_dotbot_board(bsp);00bsp_radio(bsp);00bsp_gpio(bsp);00bsp_timer_hf(bsp)" project_directory="01bsp_radio_txrx_lr" project_type="Executable" /> - - - - - - - - - - - - + + + - + @@ -393,12 +246,9 @@ - - - - - - + + + @@ -407,37 +257,22 @@ project_dependencies="00bsp_rng(bsp);00bsp_timer_hf(bsp)" project_directory="01bsp_rng" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -446,37 +281,22 @@ project_dependencies="00bsp_dotbot_board(bsp);00bsp_dotbot_rpm(bsp);00bsp_timer(bsp)" project_directory="01bsp_rpm" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -485,37 +305,22 @@ project_dependencies="00bsp_saadc(bsp);00bsp_timer_hf(bsp)" project_directory="01bsp_saadc" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -524,37 +329,22 @@ project_dependencies="00bsp_spim(bsp)" project_directory="01bsp_spim" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -563,37 +353,22 @@ project_dependencies="00bsp_timer(bsp);00bsp_gpio(bsp)" project_directory="01bsp_timer" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -602,37 +377,22 @@ project_dependencies="00bsp_timer_hf(bsp);00bsp_gpio(bsp)" project_directory="01bsp_timer_hf" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -641,37 +401,22 @@ project_dependencies="00bsp_dotbot_board(bsp);00bsp_uart(bsp)" project_directory="01bsp_uart" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -680,40 +425,25 @@ project_dependencies="00bsp_wdt(bsp);00bsp_gpio(bsp);00bsp_timer_hf(bsp)" project_directory="01bsp_wdt" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -722,38 +452,22 @@ project_dependencies="00drv_as5048b(drv);00bsp_timer_hf(bsp)" project_directory="01drv_as5048b" project_type="Executable" /> - - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -762,38 +476,22 @@ project_dependencies="00drv_imu(drv)" project_directory="01drv_imu" project_type="Executable" /> - - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -802,37 +500,22 @@ project_dependencies="00drv_ism330(drv);00bsp_dotbot_board(bsp);00bsp_timer_hf(bsp)" project_directory="01drv_ism330" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -841,38 +524,22 @@ project_dependencies="00drv_lis2mdl(drv)" project_directory="01drv_lis2mdl" project_type="Executable" /> - - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -881,38 +548,22 @@ project_dependencies="00bsp_timer(bsp);00drv_lis3mdl(drv);00bsp_dotbot_board(bsp)" project_directory="01drv_lis3mdl" project_type="Executable" /> - - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -921,38 +572,22 @@ project_dependencies="00drv_lsm6ds(drv)" project_directory="01drv_lsm6ds" project_type="Executable" /> - - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -961,38 +596,23 @@ project_dependencies="00drv_lz4(drv)" project_directory="01drv_lz4" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -1001,37 +621,22 @@ project_dependencies="00bsp_dotbot_board(bsp);00bsp_timer(bsp);00drv_motors(drv)" project_directory="01drv_motors" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -1040,37 +645,22 @@ project_dependencies="00bsp_timer(bsp);00drv_move(drv)" project_directory="01drv_move" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -1079,37 +669,22 @@ project_dependencies="00drv_n25q128(drv)" project_directory="01drv_n25q128" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -1118,37 +693,22 @@ project_dependencies="00bsp_dotbot_board(bsp);00bsp_dotbot_rpm(bsp);00bsp_timer_hf(bsp);00drv_pid(drv);00drv_motors(drv)" project_directory="01drv_pid" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -1157,37 +717,22 @@ project_dependencies="00bsp_dotbot_board(bsp);00bsp_timer(bsp);00drv_rgbled(drv)" project_directory="01drv_rgbled" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -1196,37 +741,22 @@ project_dependencies="00bsp_dotbot_board(bsp);00bsp_timer(bsp);00drv_rgbled_pwm(drv)" project_directory="01drv_rgbled_pwm" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -1235,38 +765,23 @@ project_dependencies="00drv_uzlib(drv)" project_directory="01drv_uzlib" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -1275,38 +790,22 @@ project_dependencies="00drv_tdma_client(drv);00bsp_dotbot_board(bsp);00bsp_radio(bsp);00bsp_timer(bsp);00drv_dotbot_protocol(drv)" project_directory="01drv_tdma_client" project_type="Executable" /> - - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -1316,37 +815,22 @@ project_directory="01drv_tdma_server" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + diff --git a/projects/projects-crypto.emProject b/projects/projects-crypto.emProject index d31de8915..f4ab77a38 100644 --- a/projects/projects-crypto.emProject +++ b/projects/projects-crypto.emProject @@ -3,67 +3,38 @@ - - - - - - - - - - - - + + + - + - - - - - - + + + - - - - - - - - - - - - + + + @@ -74,12 +45,9 @@ - - - - - - + + + diff --git a/projects/projects-dotbot.emProject b/projects/projects-dotbot.emProject index 1e8ac9b63..bc01376fc 100644 --- a/projects/projects-dotbot.emProject +++ b/projects/projects-dotbot.emProject @@ -6,37 +6,22 @@ project_dependencies="00bsp_dotbot_board(bsp);00bsp_dotbot_lh2(bsp);00bsp_timer(bsp);00drv_dotbot_hdlc(drv);00drv_dotbot_protocol(drv);00bsp_radio(bsp);00drv_log_flash(drv);00drv_rgbled_pwm(drv);00drv_motors(drv);00drv_tdma_client(drv)" project_directory="03app_dotbot" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + diff --git a/projects/projects-freebot-v1.0.emProject b/projects/projects-freebot-v1.0.emProject index 5ea76d6f0..f6a380eb0 100644 --- a/projects/projects-freebot-v1.0.emProject +++ b/projects/projects-freebot-v1.0.emProject @@ -6,37 +6,22 @@ project_dependencies="00bsp_timer(bsp);00drv_dotbot_hdlc(drv);00drv_dotbot_protocol(drv);00bsp_radio(bsp);00bsp_pwm(bsp);00drv_tdma_client(drv)" project_directory="03app_freebot" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + diff --git a/projects/projects-gateway.emProject b/projects/projects-gateway.emProject index c4507aadb..39eae79a9 100644 --- a/projects/projects-gateway.emProject +++ b/projects/projects-gateway.emProject @@ -6,28 +6,16 @@ project_dependencies="00bsp_radio(bsp);00bsp_dotbot_board(bsp);00bsp_uart(bsp);00bsp_timer(bsp);00bsp_uart(bsp);00drv_dotbot_hdlc(drv);00drv_dotbot_protocol(drv);00bsp_gpio(bsp);00drv_tdma_server(drv)" project_directory="03app_dotbot_gateway" project_type="Executable" /> - - - - - - - - - - - - + + + - + @@ -35,12 +23,9 @@ - - - - - - + + + @@ -49,28 +34,16 @@ project_dependencies="00bsp_radio(bsp);00bsp_dotbot_board(bsp);00bsp_uart(bsp);00bsp_timer(bsp);00bsp_uart(bsp);00drv_dotbot_hdlc(drv);00drv_dotbot_protocol(drv);00bsp_gpio(bsp);00drv_tdma_server(drv)" project_directory="03app_dotbot_gateway_lr" project_type="Executable" /> - - - - - - - - - - - - + + + - + @@ -78,12 +51,9 @@ - - - - - - + + + diff --git a/projects/projects-lh2-minimote.emProject b/projects/projects-lh2-minimote.emProject index 517ea5bc3..9d1bd11a1 100644 --- a/projects/projects-lh2-minimote.emProject +++ b/projects/projects-lh2-minimote.emProject @@ -6,37 +6,22 @@ project_dependencies="00bsp_dotbot_board(bsp);00bsp_dotbot_lh2(bsp);00bsp_timer(bsp);00drv_dotbot_hdlc(drv);00drv_dotbot_protocol(drv);00bsp_radio(bsp);00drv_log_flash(drv);00drv_rgbled_pwm(drv);00drv_tdma_client(drv)" project_directory="03app_lh2_mini_mote_app" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + @@ -45,37 +30,22 @@ project_dependencies="00bsp_dotbot_board(bsp);00bsp_dotbot_lh2(bsp);00bsp_timer(bsp);00drv_dotbot_hdlc(drv);00drv_dotbot_protocol(drv);00bsp_radio(bsp);00drv_log_flash(drv);00drv_rgbled_pwm(drv);00drv_ism330(drv);00drv_tdma_client(drv)" project_directory="03app_lh2_mini_mote_test" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + diff --git a/projects/projects-log-dump.emProject b/projects/projects-log-dump.emProject index 53cc2a53a..010202bfa 100644 --- a/projects/projects-log-dump.emProject +++ b/projects/projects-log-dump.emProject @@ -6,37 +6,22 @@ project_dependencies="00drv_log_flash(drv);00bsp_timer_hf(bsp)" project_directory="03app_log_dump" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + diff --git a/projects/projects-nrf5340-app.emProject b/projects/projects-nrf5340-app.emProject index b3eb01f72..1474d1d20 100644 --- a/projects/projects-nrf5340-app.emProject +++ b/projects/projects-nrf5340-app.emProject @@ -6,37 +6,22 @@ project_dependencies="00bsp_clock(bsp)" project_directory="03app_nrf5340_app" project_type="Executable" /> - - - - - + + + + - - - - - - - - - + - - - - - - + + + diff --git a/projects/projects-nrf5340-net.emProject b/projects/projects-nrf5340-net.emProject index d12978311..a4892abc2 100644 --- a/projects/projects-nrf5340-net.emProject +++ b/projects/projects-nrf5340-net.emProject @@ -6,37 +6,22 @@ project_dependencies="00bsp_radio(bsp);00bsp_rng(bsp);00drv_tdma_client(drv);00drv_tdma_server(drv);" project_directory="03app_nrf5340_net" project_type="Executable" /> - - - - - + + + + - - - - - - - - - + - - - - - - + + + diff --git a/projects/projects-sailbot.emProject b/projects/projects-sailbot.emProject index 789e3e1fc..7a4e8ed76 100644 --- a/projects/projects-sailbot.emProject +++ b/projects/projects-sailbot.emProject @@ -6,28 +6,14 @@ project_dependencies="00bsp_radio(bsp);00bsp_uart(bsp);00drv_dotbot_protocol(drv);00bsp_pwm(bsp);00bsp_timer_hf(bsp);00bsp_timer(bsp);00bsp_i2c(bsp);00drv_imu(drv);00drv_as5048b(drv);00drv_tdma_client(drv)" project_directory="03app_sailbot" project_type="Executable" /> - - - - - - - - + + + - - - - - - - + @@ -35,12 +21,9 @@ - - - - - - + + + diff --git a/projects/projects-xgo.emProject b/projects/projects-xgo.emProject index 58cf18ba0..c6b4a0d88 100644 --- a/projects/projects-xgo.emProject +++ b/projects/projects-xgo.emProject @@ -6,37 +6,22 @@ project_dependencies="00bsp_uart(bsp);00drv_dotbot_hdlc(drv);00drv_dotbot_protocol(drv);00bsp_radio(bsp);00bsp_timer_hf(bsp);00drv_tdma_client(drv)" project_directory="03app_xgo" project_type="Executable" /> - - - - - - - - - - - - + + + - + - - - - - - + + + diff --git a/sailbot-v1.emProject b/sailbot-v1.emProject index 4ee948e6e..3429ecc51 100644 --- a/sailbot-v1.emProject +++ b/sailbot-v1.emProject @@ -6,21 +6,24 @@ Name="Common" Placement="Flash" arm_architecture="v7EM" + arm_assembler_variant="SEGGER" arm_compiler_variant="SEGGER" arm_core_type="Cortex-M4" arm_endian="Little" arm_fp_abi="Hard" arm_fpu_type="FPv4-SP-D16" + arm_keep_assembly="Yes" arm_library_optimization="Small" - arm_linker_heap_size="8192" + arm_linker_heap_size="1024" arm_linker_process_stack_size="0" - arm_linker_stack_size="8192" - arm_linker_variant="SEGGER" + arm_linker_stack_size="2048" + arm_linker_variant="GNU" arm_rtl_variant="SEGGER" arm_simulator_memory_simulation_parameter="ROM1;0x00000000;0x00080000;RAM1;0x00800000;0x00020000;RAM2;0x20000000;0x00020000;" arm_target_debug_interface_type="ADIv5" arm_target_device_name="nRF52833_xxAA" arm_target_interface_type="SWD" + arm_use_builtins="Yes" build_intermediate_directory="Output/$(BuildTarget)/$(Configuration)/Obj/$(ProjectName)" build_output_directory="Output/$(BuildTarget)/$(Configuration)/Exe" build_output_file_name="$(OutDir)/$(ProjectName)-$(BuildTarget)$(EXE)" @@ -28,17 +31,26 @@ c_additional_options="-Wno-missing-field-initializers" c_preprocessor_definitions="ARM_MATH_CM4;NRF52833_XXAA;__nRF_FAMILY;CONFIG_NFCT_PINS_AS_GPIOS;FLASH_PLACEMENT=1;BOARD_SAILBOT_V1;OTA_USE_CRYPTO" c_user_include_directories="$(SolutionDir)/../bsp;$(SolutionDir)/../crypto;$(SolutionDir)/../drv;$(PackagesDir)/nRF/Device/Include;$(PackagesDir)/CMSIS_5/CMSIS/Core/Include" + clang_machine_outliner="Yes" + compiler_color_diagnostics="Yes" debug_register_definition_file="$(PackagesDir)/nRF/XML/nrf52833_Registers.xml" debug_stack_pointer_start="__stack_end__" debug_start_from_entry_point_symbol="No" debug_target_connection="J-Link" + gcc_c_language_standard="gnu17" + gcc_cplusplus_language_standard="gnu++20" gcc_enable_all_warnings="Yes" - gcc_entry_point="Reset_Handler" - link_linker_script_file="$(ProjectDir)/../../nRF/nrf52833/nRF_Flash_Variant1.icf" + gcc_entry_point="reset_handler" + link_dedupe_code="Yes" link_time_optimization="No" - linker_memory_map_file="$(PackagesDir)/nRF/XML/nRF52833_xxAA_MemoryMap.xml" + linker_additional_options="--gc-sections" + linker_memory_map_file="$(ProjectDir)/../../nRF/Setup/nRF52833_xxAA_MemoryMap.xml" linker_output_format="hex" - macros="BuildTarget=sailbot-v1;Lh2ImplementationFile=lh2.c;PwmImplementationFile=pwm.c;RadioImplementationFile=radio.c;RngImplementationFile=rng.c;TdmaClientImplementationFile=tdma_client.c;TdmaServerImplementationFile=tdma_server.c;DeviceHeaderFile=$(PackagesDir)/nRF/Device/Include/nrf52833.h;DeviceCommonHeaderFile=$(PackagesDir)/nRF/Device/Include/nrf.h;DeviceSystemFile=$(PackagesDir)/nRF/Device/Source/system_nrf52.c;DeviceVectorsFile=$(PackagesDir)/nRF/Source/nrf52833_Vectors.s;DeviceCommonVectorsFile=$(PackagesDir)/nRF/Source/nRF_Startup.s;SeggerThumbStartup=$(ProjectDir)/../../../nRF/SEGGER_THUMB_Startup.s;DeviceLinkerScript=$(ProjectDir)/../../../nRF/nrf5340/nRF_Flash_Variant1.icf;DeviceMemoryMap=$(PackagesDir)/nRF/XML/nRF52840_xxAA_MemoryMap.xml;DeviceLibraryIdentifier=M4lf;DeviceFamily=nRF;Target=nRF52833_xxAA;Placement=Flash" + linker_printf_fmt_level="int" + linker_printf_fp_enabled="Float" + linker_printf_width_precision_supported="Yes" + linker_section_placement_file="$(ProjectDir)/../../nRF/Setup/nRF52833_xxAA_flash_placement.xml" + macros="BuildTarget=sailbot-v1;Lh2ImplementationFile=lh2.c;PwmImplementationFile=pwm.c;RadioImplementationFile=radio.c;RngImplementationFile=rng.c;TdmaClientImplementationFile=tdma_client.c;TdmaServerImplementationFile=tdma_server.c;DeviceLibraryIdentifier=M4lf;DeviceFamily=nRF;Target=nRF52833_xxAA;Placement=Flash" project_type="Executable" target_reset_script="Reset();" target_trace_initialize_script="EnableTrace("$(TraceInterfaceType)")" /> @@ -57,9 +69,9 @@ + - diff --git a/upgate/upgate.emProject b/upgate/upgate.emProject index 742f72944..819160a7a 100644 --- a/upgate/upgate.emProject +++ b/upgate/upgate.emProject @@ -8,36 +8,22 @@ project_dependencies="00bsp_gpio(bsp);00drv_upgate(drv);00bsp_radio(bsp);00bsp_uart(bsp);00drv_dotbot_hdlc(drv)" project_directory="application" project_type="Executable" /> - - - - - - - - - - - + + + - + - - - - - - + + + diff --git a/xgo-v1.emProject b/xgo-v1.emProject index 2bcb3bb04..9c4d4b4b6 100644 --- a/xgo-v1.emProject +++ b/xgo-v1.emProject @@ -6,21 +6,24 @@ Name="Common" Placement="Flash" arm_architecture="v7EM" + arm_assembler_variant="SEGGER" arm_compiler_variant="SEGGER" arm_core_type="Cortex-M4" arm_endian="Little" arm_fp_abi="Hard" arm_fpu_type="FPv4-SP-D16" + arm_keep_assembly="Yes" arm_library_optimization="Small" arm_linker_heap_size="1024" arm_linker_process_stack_size="0" arm_linker_stack_size="2048" - arm_linker_variant="SEGGER" + arm_linker_variant="GNU" arm_rtl_variant="SEGGER" arm_simulator_memory_simulation_parameter="ROM1;0x00000000;0x00080000;RAM1;0x00800000;0x00020000;RAM2;0x20000000;0x00020000;" arm_target_debug_interface_type="ADIv5" arm_target_device_name="nRF52833_xxAA" arm_target_interface_type="SWD" + arm_use_builtins="Yes" build_intermediate_directory="Output/$(BuildTarget)/$(Configuration)/Obj/$(ProjectName)" build_output_directory="Output/$(BuildTarget)/$(Configuration)/Exe" build_output_file_name="$(OutDir)/$(ProjectName)-$(BuildTarget)$(EXE)" @@ -28,17 +31,25 @@ c_additional_options="-Wno-missing-field-initializers" c_preprocessor_definitions="ARM_MATH_CM4;NRF52833_XXAA;__nRF_FAMILY;CONFIG_NFCT_PINS_AS_GPIOS;FLASH_PLACEMENT=1;BOARD_XGO_V1" c_user_include_directories="$(SolutionDir)/../bsp;$(SolutionDir)/../drv;$(PackagesDir)/nRF/Device/Include;$(PackagesDir)/CMSIS_5/CMSIS/Core/Include" + clang_machine_outliner="Yes" + compiler_color_diagnostics="Yes" debug_register_definition_file="$(PackagesDir)/nRF/XML/nrf52833_Registers.xml" debug_stack_pointer_start="__stack_end__" debug_start_from_entry_point_symbol="No" debug_target_connection="J-Link" + gcc_c_language_standard="gnu17" + gcc_cplusplus_language_standard="gnu++20" gcc_enable_all_warnings="Yes" - gcc_entry_point="Reset_Handler" - link_linker_script_file="$(ProjectDir)/../../nRF/nrf52833/nRF_Flash_Variant1.icf" + gcc_entry_point="reset_handler" + link_dedupe_code="Yes" + linker_additional_options="--gc-sections" link_time_optimization="No" - linker_memory_map_file="$(PackagesDir)/nRF/XML/nRF52833_xxAA_MemoryMap.xml" + linker_memory_map_file="$(ProjectDir)/../../nRF/Setup/nRF52833_xxAA_MemoryMap.xml" linker_output_format="hex" - macros="BuildTarget=xgo-v1;Lh2ImplementationFile=lh2.c;PwmImplementationFile=pwm.c;RadioImplementationFile=radio.c;RngImplementationFile=rng.c;TdmaClientImplementationFile=tdma_client.c;TdmaServerImplementationFile=tdma_server.c;DeviceHeaderFile=$(PackagesDir)/nRF/Device/Include/nrf52833.h;DeviceCommonHeaderFile=$(PackagesDir)/nRF/Device/Include/nrf.h;DeviceSystemFile=$(PackagesDir)/nRF/Device/Source/system_nrf52.c;DeviceVectorsFile=$(PackagesDir)/nRF/Source/nrf52833_Vectors.s;DeviceCommonVectorsFile=$(PackagesDir)/nRF/Source/nRF_Startup.s;SeggerThumbStartup=$(ProjectDir)/../../../nRF/SEGGER_THUMB_Startup.s;DeviceLinkerScript=$(ProjectDir)/../../../nRF/nrf5340/nRF_Flash_Variant1.icf;DeviceMemoryMap=$(PackagesDir)/nRF/XML/nRF52840_xxAA_MemoryMap.xml;DeviceLibraryIdentifier=M4lf;DeviceFamily=nRF;Target=nRF52833_xxAA;Placement=Flash" + linker_printf_fmt_level="int" + linker_printf_fp_enabled="Float" + linker_section_placement_file="$(ProjectDir)/../../nRF/Setup/nRF52833_xxAA_flash_placement.xml" + macros="BuildTarget=xgo-v1;Lh2ImplementationFile=lh2.c;PwmImplementationFile=pwm.c;RadioImplementationFile=radio.c;RngImplementationFile=rng.c;TdmaClientImplementationFile=tdma_client.c;TdmaServerImplementationFile=tdma_server.c;DeviceLibraryIdentifier=M4lf;DeviceFamily=nRF;Target=nRF52833_xxAA;Placement=Flash" project_type="Executable" target_reset_script="Reset();" target_trace_initialize_script="EnableTrace("$(TraceInterfaceType)")" /> diff --git a/xgo-v2.emProject b/xgo-v2.emProject index 7e582ec5e..f0722b5d9 100644 --- a/xgo-v2.emProject +++ b/xgo-v2.emProject @@ -6,21 +6,24 @@ Name="Common" Placement="Flash" arm_architecture="v7EM" + arm_assembler_variant="SEGGER" arm_compiler_variant="SEGGER" arm_core_type="Cortex-M4" arm_endian="Little" arm_fp_abi="Hard" arm_fpu_type="FPv4-SP-D16" + arm_keep_assembly="Yes" arm_library_optimization="Small" arm_linker_heap_size="1024" arm_linker_process_stack_size="0" arm_linker_stack_size="2048" - arm_linker_variant="SEGGER" + arm_linker_variant="GNU" arm_rtl_variant="SEGGER" arm_simulator_memory_simulation_parameter="ROM1;0x00000000;0x00080000;RAM1;0x00800000;0x00020000;RAM2;0x20000000;0x00020000;" arm_target_debug_interface_type="ADIv5" arm_target_device_name="nRF52833_xxAA" arm_target_interface_type="SWD" + arm_use_builtins="Yes" build_intermediate_directory="Output/$(BuildTarget)/$(Configuration)/Obj/$(ProjectName)" build_output_directory="Output/$(BuildTarget)/$(Configuration)/Exe" build_output_file_name="$(OutDir)/$(ProjectName)-$(BuildTarget)$(EXE)" @@ -28,17 +31,25 @@ c_additional_options="-Wno-missing-field-initializers" c_preprocessor_definitions="ARM_MATH_CM4;NRF52833_XXAA;__nRF_FAMILY;CONFIG_NFCT_PINS_AS_GPIOS;FLASH_PLACEMENT=1;BOARD_XGO_V2" c_user_include_directories="$(SolutionDir)/../bsp;$(SolutionDir)/../drv;$(PackagesDir)/nRF/Device/Include;$(PackagesDir)/CMSIS_5/CMSIS/Core/Include" + clang_machine_outliner="Yes" + compiler_color_diagnostics="Yes" debug_register_definition_file="$(PackagesDir)/nRF/XML/nrf52833_Registers.xml" debug_stack_pointer_start="__stack_end__" debug_start_from_entry_point_symbol="No" debug_target_connection="J-Link" + gcc_c_language_standard="gnu17" + gcc_cplusplus_language_standard="gnu++20" gcc_enable_all_warnings="Yes" - gcc_entry_point="Reset_Handler" - link_linker_script_file="$(ProjectDir)/../../nRF/nrf52833/nRF_Flash_Variant1.icf" + gcc_entry_point="reset_handler" + link_dedupe_code="Yes" + linker_additional_options="--gc-sections" link_time_optimization="No" - linker_memory_map_file="$(PackagesDir)/nRF/XML/nRF52833_xxAA_MemoryMap.xml" + linker_memory_map_file="$(ProjectDir)/../../nRF/Setup/nRF52833_xxAA_MemoryMap.xml" linker_output_format="hex" - macros="BuildTarget=xgo-v2;Lh2ImplementationFile=lh2.c;PwmImplementationFile=pwm.c;RadioImplementationFile=radio.c;RngImplementationFile=rng.c;TdmaClientImplementationFile=tdma_client.c;TdmaServerImplementationFile=tdma_server.c;DeviceHeaderFile=$(PackagesDir)/nRF/Device/Include/nrf52833.h;DeviceCommonHeaderFile=$(PackagesDir)/nRF/Device/Include/nrf.h;DeviceSystemFile=$(PackagesDir)/nRF/Device/Source/system_nrf52.c;DeviceVectorsFile=$(PackagesDir)/nRF/Source/nrf52833_Vectors.s;DeviceCommonVectorsFile=$(PackagesDir)/nRF/Source/nRF_Startup.s;SeggerThumbStartup=$(ProjectDir)/../../../nRF/SEGGER_THUMB_Startup.s;DeviceLinkerScript=$(ProjectDir)/../../../nRF/nrf5340/nRF_Flash_Variant1.icf;DeviceMemoryMap=$(PackagesDir)/nRF/XML/nRF52840_xxAA_MemoryMap.xml;DeviceLibraryIdentifier=M4lf;DeviceFamily=nRF;Target=nRF52833_xxAA;Placement=Flash" + linker_printf_fmt_level="int" + linker_printf_fp_enabled="Float" + linker_section_placement_file="$(ProjectDir)/../../nRF/Setup/nRF52833_xxAA_flash_placement.xml" + macros="BuildTarget=xgo-v2;Lh2ImplementationFile=lh2.c;PwmImplementationFile=pwm.c;RadioImplementationFile=radio.c;RngImplementationFile=rng.c;TdmaClientImplementationFile=tdma_client.c;TdmaServerImplementationFile=tdma_server.c;DeviceLibraryIdentifier=M4lf;DeviceFamily=nRF;Target=nRF52833_xxAA;Placement=Flash" project_type="Executable" target_reset_script="Reset();" target_trace_initialize_script="EnableTrace("$(TraceInterfaceType)")" />