diff --git a/ci_config.json b/ci_config.json index 32fb01d79..f860e591b 100644 --- a/ci_config.json +++ b/ci_config.json @@ -272,6 +272,14 @@ "libxkbcommon-dev" ] }, + "freertos": { + "build_on": { + "windows": false, + "alpine": false, + "darwin": false, + "msys2": false + } + }, "fuse": { "_comment": "- relies on Linux and BSD specific APIs", "build_on": { diff --git a/releases.json b/releases.json index e3f141bea..dfb3d34cb 100644 --- a/releases.json +++ b/releases.json @@ -985,6 +985,14 @@ "3.4.0-1" ] }, + "freertos": { + "dependency_names": [ + "freertos" + ], + "versions": [ + "11.2.0-1" + ] + }, "freetype2": { "dependency_names": [ "freetype2", diff --git a/subprojects/freertos.wrap b/subprojects/freertos.wrap new file mode 100644 index 000000000..52c83a277 --- /dev/null +++ b/subprojects/freertos.wrap @@ -0,0 +1,9 @@ +[wrap-file] +directory = FreeRTOS-Kernel-11.2.0 +source_url = https://github.com/FreeRTOS/FreeRTOS-Kernel/archive/refs/tags/V11.2.0.zip +source_filename = freertos-11.2.0.zip +source_hash = faeabe1e7443208d83232870a6072ec72982ddd219a8dfa74eda8c1eadb97819 +patch_directory = freertos + +[provide] +dependency_names = freertos diff --git a/subprojects/packagefiles/freertos/meson.build b/subprojects/packagefiles/freertos/meson.build new file mode 100644 index 000000000..b3de84fcf --- /dev/null +++ b/subprojects/packagefiles/freertos/meson.build @@ -0,0 +1,72 @@ +project( + 'freertos', + 'c', + 'cpp', + license: 'MIT', + meson_version: '>=0.63.0', + version: '11.2.0', + default_options: ['b_staticpic=false', 'default_library=static'], +) + +# FreeRTOSConfig.h must be specified as dependency like that: +# +# freertos_config_dep = declare_dependency( +# sources: 'configs/FreeRTOSConfig.h', +# include_directories: 'configs', +# ) +# meson.override_dependency('freertos-config', freertos_config_dep) +# +# If not specified then we use config from examples as fallback. +freertos_config_dep = dependency( + 'freertos-config', + required: false, +) +if not freertos_config_dep.found() + freertos_config_dep = declare_dependency( + sources: 'examples/template_configuration/FreeRTOSConfig.h', + include_directories: 'examples/template_configuration', + ) +endif + +inc = [include_directories('include')] +src = files( + 'croutine.c', + 'event_groups.c', + 'list.c', + 'queue.c', + 'stream_buffer.c', + 'tasks.c', + 'timers.c', +) + +# Dependency with custom port on unknown arch +freertos_port_dep = dependency( + 'freertos-custom-port', + required: false, +) +if not freertos_port_dep.found() + subdir('portable') +endif + +# Dependency with custom heap implementation +freertos_heap_dep = dependency( + 'freertos-custom-heap', + required: false, +) +if not freertos_heap_dep.found() + heap_number = get_option('heap_number') + src += files(f'portable/MemMang/heap_@heap_number@.c') +endif + +freertos_lib = library( + 'freertos_kernel', + src, + include_directories: inc, + dependencies: [freertos_config_dep, freertos_port_dep, freertos_heap_dep], +) +freertos_dep = declare_dependency( + include_directories: inc, + link_with: freertos_lib, + dependencies: [freertos_config_dep, freertos_port_dep], +) +meson.override_dependency('freertos', freertos_dep) diff --git a/subprojects/packagefiles/freertos/meson_options.txt b/subprojects/packagefiles/freertos/meson_options.txt new file mode 100644 index 000000000..6a30ff01d --- /dev/null +++ b/subprojects/packagefiles/freertos/meson_options.txt @@ -0,0 +1,174 @@ +option( + 'heap_number', + description: 'Heap implementation variant', + type: 'integer', + min: 1, + max: 5, + value: 4, +) +option( + 'port', + description: 'Kernel port', + type: 'combo', + choices: [ + 'auto', + # 'bcc_16bit_dos_flsh186', + # 'bcc_16bit_dos_pc', + # 'ccs_arm_cm3', + # 'ccs_arm_cm4f', + # 'ccs_arm_cr4', + # 'ccs_msp430x', + # 'codewarrior_coldfire_v1', + # 'codewarrior_coldfire_v2', + # 'codewarrior_hcs12', + # 'gcc_arm_ca9', + # 'gcc_arm_aarch64', + # 'gcc_arm_aarch64_sre', + 'gcc_arm_cm0', + 'gcc_arm_cm3', + 'gcc_arm_cm3_mpu', + 'gcc_arm_cm4_mpu', + 'gcc_arm_cm4f', + 'gcc_arm_cm7', + # 'gcc_arm_cm23_nonsecure', + # 'gcc_arm_cm23_secure', + # 'gcc_arm_cm23_ntz_nonsecure', + # 'gcc_arm_cm33_nonsecure', + # 'gcc_arm_cm33_secure', + # 'gcc_arm_cm33_ntz_nonsecure', + # 'gcc_arm_cm33_tfm', + # 'gcc_arm_cm35p_nonsecure', + # 'gcc_arm_cm35p_secure', + # 'gcc_arm_cm35p_ntz_nonsecure', + # 'gcc_arm_cm55_nonsecure', + # 'gcc_arm_cm55_secure', + # 'gcc_arm_cm55_ntz_nonsecure', + # 'gcc_arm_cm55_tfm', + # 'gcc_arm_cm85_nonsecure', + # 'gcc_arm_cm85_secure', + # 'gcc_arm_cm85_ntz_nonsecure', + # 'gcc_arm_cm85_tfm', + # 'gcc_arm_cr5', + # 'gcc_arm_crx_mpu', + # 'gcc_arm_crx_nogic', + # 'gcc_arm7_at91fr40008', + # 'gcc_arm7_at91sam7s', + # 'gcc_arm7_lpc2000', + # 'gcc_arm7_lpc23xx', + # 'gcc_atmega323', + # 'gcc_avr32_uc3', + # 'gcc_coldfire_v2', + # 'gcc_cortus_aps3', + # 'gcc_h8s2329', + # 'gcc_hcs12', + # 'gcc_ia32_flat', + # 'gcc_microblaze', + # 'gcc_microblaze_v8', + # 'gcc_microblaze_v9', + # 'gcc_msp430f449', + # 'gcc_niosii', + # 'gcc_ppc405_xilinx', + # 'gcc_ppc440_xilinx', + # 'gcc_risc_v', + # 'gcc_risc_v_pulpino_vega_rv32m1rm', + # 'gcc_risc_v_generic', + # 'gcc_rl78', + # 'gcc_rx100', + # 'gcc_rx200', + # 'gcc_rx600', + # 'gcc_rx600_v2', + # 'gcc_rx700_v3_dpfpu', + # 'gcc_str75x', + # 'gcc_tricore_1782', + # 'gcc_arc_em_hs', + # 'gcc_arc_v1', + # 'gcc_atmega', + 'gcc_posix', + # 'gcc_rp2040', + # 'gcc_xtensa_esp32', + # 'gcc_avrdx', + # 'gcc_avr_mega0', + # 'iar_78k0k', + # 'iar_arm_ca5_nogic', + # 'iar_arm_ca9', + # 'iar_arm_cm0', + # 'iar_arm_cm3', + # 'iar_arm_cm4f', + # 'iar_arm_cm4f_mpu', + # 'iar_arm_cm7', + # 'iar_arm_cm23_nonsecure', + # 'iar_arm_cm23_secure', + # 'iar_arm_cm23_ntz_nonsecure', + # 'iar_arm_cm33_nonsecure', + # 'iar_arm_cm33_secure', + # 'iar_arm_cm33_ntz_nonsecure', + # 'iar_arm_cm33_tfm', + # 'iar_arm_cm35p_nonsecure', + # 'iar_arm_cm35p_secure', + # 'iar_arm_cm35p_ntz_nonsecure', + # 'iar_arm_cm55_nonsecure', + # 'iar_arm_cm55_secure', + # 'iar_arm_cm55_ntz_nonsecure', + # 'iar_arm_cm55_tfm', + # 'iar_arm_cm85_nonsecure', + # 'iar_arm_cm85_secure', + # 'iar_arm_cm85_ntz_nonsecure', + # 'iar_arm_cm85_tfm', + # 'iar_arm_crx_nogic', + # 'iar_atmega323', + # 'iar_atmel_sam7s64', + # 'iar_atmel_sam9xe', + # 'iar_avr_avrdx', + # 'iar_avr_mega0', + # 'iar_avr32_uc3', + # 'iar_lpc2000', + # 'iar_msp430', + # 'iar_msp430x', + # 'iar_risc_v', + # 'iar_risc_v_generic', + # 'iar_rl78', + # 'iar_rx100', + # 'iar_rx600', + # 'iar_rx700_v3_dpfpu', + # 'iar_rx_v2', + # 'iar_str71x', + # 'iar_str75x', + # 'iar_str91x', + # 'iar_v850es_fx3', + # 'iar_v850es_hx3', + # 'mikroc_arm_cm4f', + # 'mplab_pic18f', + # 'mplab_pic24', + # 'mplab_pic32mec14xx', + # 'mplab_pic32mx', + # 'mplab_pic32mz', + # 'msvc_mingw', + # 'owatcom_16bit_dos_flsh186', + # 'owatcom_16bit_dos_pc', + # 'paradigm_tern_ee_large', + # 'paradigm_tern_ee_small', + # 'renesas_rx100', + # 'renesas_rx200', + # 'renesas_rx600', + # 'renesas_rx600_v2', + # 'renesas_rx700_v3_dpfpu', + # 'renesas_sh2a_fpu', + # 'rowley_msp430f449', + # 'rvds_arm_ca9', + # 'rvds_arm_cm0', + # 'rvds_arm_cm3', + # 'rvds_arm_cm4_mpu', + # 'rvds_arm_cm4f', + # 'rvds_arm_cm7', + # 'rvds_arm7_lpc21xx', + # 'sdcc_cygnal', + # 'softune_mb91460', + # 'softune_mb96340', + # 'tasking_arm_cm4f', + 'template', + # 'cdk_thead_ck802', + # 'xcc_xtensa', + # 'wizc_pic18', + ], + value: 'auto', +) diff --git a/subprojects/packagefiles/freertos/portable/meson.build b/subprojects/packagefiles/freertos/portable/meson.build new file mode 100644 index 000000000..c094f38ed --- /dev/null +++ b/subprojects/packagefiles/freertos/portable/meson.build @@ -0,0 +1,212 @@ +ports = { + #'bcc_16bit_dos_flsh186': + #'bcc_16bit_dos_pc': + #'ccs_arm_cm3': + #'ccs_arm_cm4f': + #'ccs_arm_cr4': + #'ccs_msp430x': + #'codewarrior_coldfire_v1': + #'codewarrior_coldfire_v2': + #'codewarrior_hcs12': + #'gcc_arm_ca9': + #'gcc_arm_aarch64': + #'gcc_arm_aarch64_sre': + 'gcc_arm_cm0': [ + files( + 'GCC/ARM_CM0/mpu_wrappers_v2_asm.c', + 'GCC/ARM_CM0/port.c', + 'GCC/ARM_CM0/portasm.c', + ), + include_directories('GCC/ARM_CM0'), + ], + 'gcc_arm_cm3': [ + files('GCC/ARM_CM3/port.c'), + include_directories('GCC/ARM_CM3'), + ], + 'gcc_arm_cm3_mpu': [ + files('GCC/ARM_CM3_MPU/mpu_wrappers_v2_asm.c', 'GCC/ARM_CM3_MPU/port.c'), + include_directories('GCC/ARM_CM3_MPU'), + ], + 'gcc_arm_cm4_mpu': [ + files('GCC/ARM_CM4_MPU/mpu_wrappers_v2_asm.c', 'GCC/ARM_CM4_MPU/port.c'), + include_directories('GCC/ARM_CM4_MPU'), + ], + 'gcc_arm_cm4f': [ + files('GCC/ARM_CM4F/port.c'), + include_directories('GCC/ARM_CM4F'), + ], + 'gcc_arm_cm7': [ + files('GCC/ARM_CM7/r0p1/port.c'), + include_directories('GCC/ARM_CM7/r0p1'), + ], + #'gcc_arm_cm23_nonsecure': + #'gcc_arm_cm23_secure': + #'gcc_arm_cm23_ntz_nonsecure': + #'gcc_arm_cm33_nonsecure': + #'gcc_arm_cm33_secure': + #'gcc_arm_cm33_ntz_nonsecure': + #'gcc_arm_cm33_tfm': + #'gcc_arm_cm35p_nonsecure': + #'gcc_arm_cm35p_secure': + #'gcc_arm_cm35p_ntz_nonsecure': + #'gcc_arm_cm55_nonsecure': + #'gcc_arm_cm55_secure': + #'gcc_arm_cm55_ntz_nonsecure': + #'gcc_arm_cm55_tfm': + #'gcc_arm_cm85_nonsecure': + #'gcc_arm_cm85_secure': + #'gcc_arm_cm85_ntz_nonsecure': + #'gcc_arm_cm85_tfm': + #'gcc_arm_cr5': + #'gcc_arm_crx_mpu': + #'gcc_arm_crx_nogic': + #'gcc_arm7_at91fr40008': + #'gcc_arm7_at91sam7s': + #'gcc_arm7_lpc2000': + #'gcc_arm7_lpc23xx': + #'gcc_atmega323': + #'gcc_avr32_uc3': + #'gcc_coldfire_v2': + #'gcc_cortus_aps3': + #'gcc_h8s2329': + #'gcc_hcs12': + #'gcc_ia32_flat': + #'gcc_microblaze': + #'gcc_microblaze_v8': + #'gcc_microblaze_v9': + #'gcc_msp430f449': + #'gcc_niosii': + #'gcc_ppc405_xilinx': + #'gcc_ppc440_xilinx': + #'gcc_risc_v': + #'gcc_risc_v_pulpino_vega_rv32m1rm': + #'gcc_risc_v_generic': + #'gcc_rl78': + #'gcc_rx100': + #'gcc_rx200': + #'gcc_rx600': + #'gcc_rx600_v2': + #'gcc_rx700_v3_dpfpu': + #'gcc_str75x': + #'gcc_tricore_1782': + #'gcc_arc_em_hs': + #'gcc_arc_v1': + #'gcc_atmega': + 'gcc_posix': [ + files( + 'ThirdParty/GCC/Posix/port.c', + 'ThirdParty/GCC/Posix/utils/wait_for_event.c', + ), + include_directories('ThirdParty/GCC/Posix', 'ThirdParty/GCC/Posix/utils'), + ], + #'gcc_rp2040': + #'gcc_xtensa_esp32': + #'gcc_avrdx': + #'gcc_avr_mega0': + #'iar_78k0k': + #'iar_arm_ca5_nogic': + #'iar_arm_ca9': + #'iar_arm_cm0': + #'iar_arm_cm3': + #'iar_arm_cm4f': + #'iar_arm_cm4f_mpu': + #'iar_arm_cm7': + #'iar_arm_cm23_nonsecure': + #'iar_arm_cm23_secure': + #'iar_arm_cm23_ntz_nonsecure': + #'iar_arm_cm33_nonsecure': + #'iar_arm_cm33_secure': + #'iar_arm_cm33_ntz_nonsecure': + #'iar_arm_cm33_tfm': + #'iar_arm_cm35p_nonsecure': + #'iar_arm_cm35p_secure': + #'iar_arm_cm35p_ntz_nonsecure': + #'iar_arm_cm55_nonsecure': + #'iar_arm_cm55_secure': + #'iar_arm_cm55_ntz_nonsecure': + #'iar_arm_cm55_tfm': + #'iar_arm_cm85_nonsecure': + #'iar_arm_cm85_secure': + #'iar_arm_cm85_ntz_nonsecure': + #'iar_arm_cm85_tfm': + #'iar_arm_crx_nogic': + #'iar_atmega323': + #'iar_atmel_sam7s64': + #'iar_atmel_sam9xe': + #'iar_avr_avrdx': + #'iar_avr_mega0': + #'iar_avr32_uc3': + #'iar_lpc2000': + #'iar_msp430': + #'iar_msp430x': + #'iar_risc_v': + #'iar_risc_v_generic': + #'iar_rl78': + #'iar_rx100': + #'iar_rx600': + #'iar_rx700_v3_dpfpu': + #'iar_rx_v2': + #'iar_str71x': + #'iar_str75x': + #'iar_str91x': + #'iar_v850es_fx3': + #'iar_v850es_hx3': + #'mikroc_arm_cm4f': + #'mplab_pic18f': + #'mplab_pic24': + #'mplab_pic32mec14xx': + #'mplab_pic32mx': + #'mplab_pic32mz': + #'msvc_mingw': + #'owatcom_16bit_dos_flsh186': + #'owatcom_16bit_dos_pc': + #'paradigm_tern_ee_large': + #'paradigm_tern_ee_small': + #'renesas_rx100': + #'renesas_rx200': + #'renesas_rx600': + #'renesas_rx600_v2': + #'renesas_rx700_v3_dpfpu': + #'renesas_sh2a_fpu': + #'rowley_msp430f449': + #'rvds_arm_ca9': + #'rvds_arm_cm0': + #'rvds_arm_cm3': + #'rvds_arm_cm4_mpu': + #'rvds_arm_cm4f': + #'rvds_arm_cm7': + #'rvds_arm7_lpc21xx': + #'sdcc_cygnal': + #'softune_mb91460': + #'softune_mb96340': + #'tasking_arm_cm4f': + 'template': [files('template/port.c'), include_directories('template')], + #'cdk_thead_ck802': + #'xcc_xtensa': + #'wizc_pic18': +} + +port_opt = get_option('port') +cc = meson.get_compiler('c') +if port_opt == 'auto' + port_frags = [cc.get_id()] + if host_machine.system() == 'none' + port_frags += host_machine.cpu_family() + if host_machine.cpu() == 'cortex-m0' + port_frags += 'cm0' + elif host_machine.cpu() == 'cortex-m7' + port_frags += 'cm7' + endif + elif host_machine.system() == 'linux' or host_machine.system() == 'darwin' + port_frags += 'posix' + endif + port_opt = '_'.join(port_frags) + assert( + ports.has_key(port_opt), + 'Cannot autodetect port, please specify "port" option value for your host machine', + ) +endif +port_properties = ports[port_opt] +message('FreeRTOS port: ' + port_opt) +src += port_properties[0] +inc += port_properties[1]