Skip to content

Commit

Permalink
build system: refactor to use c style initialization and GNU Linker
Browse files Browse the repository at this point in the history
  • Loading branch information
aabadie committed Sep 20, 2024
1 parent d4aa095 commit 21d0fba
Show file tree
Hide file tree
Showing 60 changed files with 2,390 additions and 2,010 deletions.
7 changes: 7 additions & 0 deletions bsp/bsp.emProject
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@
<file file_name="nrf/board.c" />
<file file_name="board.h" />
</project>
<project Name="00bsp_cpu">
<configuration
Name="Common"
project_directory="."
project_type="Library" />
<file file_name="nrf/cpu.c" />
</project>
<project Name="00bsp_dotbot_lh2">
<configuration
Name="Common"
Expand Down
30 changes: 2 additions & 28 deletions bsp/ipc.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ typedef struct __attribute__((packed)) {
ipc_rng_data_t rng; ///< Rng share 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
*/
Expand All @@ -92,29 +87,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) {}
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);
void db_ipc_network_call(ipc_req_t req);

while (!ipc_shared_data.net_ready) {}
}
#endif
void release_network_core(void);

#endif
4 changes: 2 additions & 2 deletions bsp/nrf/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions bsp/nrf/radio_nrf5340_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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_ble_mode_t mode) {
Expand Down
2 changes: 2 additions & 0 deletions bsp/nrf/rng_nrf5340_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "rng.h"
#include "tz.h"

extern volatile __attribute__((section(".shared_data"))) ipc_shared_data_t ipc_shared_data;

//========================== functions =========================================

//=========================== public ===========================================
Expand Down
24 changes: 17 additions & 7 deletions dotbot-v1.emProject
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,49 @@
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)"
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_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"
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=dotbot-v1;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/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;DeviceLibraryIdentifier=M4lf;DeviceFamily=nRF;Target=nRF52833_xxAA;Placement=Flash"
project_type="Executable"
target_reset_script="Reset();"
target_trace_initialize_script="EnableTrace(&quot;$(TraceInterfaceType)&quot;)" />
Expand Down
22 changes: 16 additions & 6 deletions dotbot-v2.emProject
Original file line number Diff line number Diff line change
@@ -1,44 +1,54 @@
<!DOCTYPE CrossStudio_Project_File>
<solution Name="dotbot-firmware-dotbot-v2" target="8" version="2">
<configuration
CMSIS_CORE="Yes"
LIBRARY_IO_TYPE="RTT"
Name="Common"
Target="nRF5340_xxAA_Application"
Placement="Flash"
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"
arm_v8M_has_cmse="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;OTA_USE_CRYPTO"
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/nrf5340_application_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/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)/../../nRF/Setup/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;Placement=Flash"
project_type="Executable"
target_reset_script="Reset();"
target_trace_initialize_script="EnableTrace(&quot;$(TraceInterfaceType)&quot;)" />
Expand Down
20 changes: 15 additions & 5 deletions freebot-v1.0.emProject
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,49 @@
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)"
build_treat_warnings_as_errors="Yes"
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"
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;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;DeviceLibraryIdentifier=M4lf;DeviceFamily=nRF;Target=nRF52840_xxAA;Placement=Flash"
project_type="Executable"
target_reset_script="Reset();"
target_trace_initialize_script="EnableTrace(&quot;$(TraceInterfaceType)&quot;)" />
Expand Down
24 changes: 17 additions & 7 deletions lh2-mini-mote.emProject
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,49 @@
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)"
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_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"
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;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;DeviceLibraryIdentifier=M4lf;DeviceFamily=nRF;Target=nRF52833_xxAA;Placement=Flash"
project_type="Executable"
target_reset_script="Reset();"
target_trace_initialize_script="EnableTrace(&quot;$(TraceInterfaceType)&quot;)" />
Expand Down
Loading

0 comments on commit 21d0fba

Please sign in to comment.