From 376232dee8c44ef14bfb6fa62d93dfb8022a2011 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Wed, 24 Apr 2024 15:11:40 +0200 Subject: [PATCH 1/3] refactor: core stm32 header files move to SrcWrapper belong to sources. Signed-off-by: Frederic Pillon --- CI/update/stm32cube.py | 5 +-- CI/update/stm32wrapper.py | 2 +- License.md | 7 ++- cmake/set_base_arduino_config.cmake | 3 +- .../SrcWrapper/inc}/HardwareTimer.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_adc.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_bdma.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_bus.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_comp.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_cordic.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_cortex.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_crc.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_crs.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_dac.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_dcache.h | 0 .../inc}/LL/stm32yyxx_ll_delayblock.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_dlyb.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_dma.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_dma2d.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_dmamux.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_exti.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_fmac.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_fmc.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_fmpi2c.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_fsmc.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_gpio.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_hrtim.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_hsem.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_i2c.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_i3c.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_icache.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_ipcc.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_iwdg.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_lpgpio.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_lptim.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_lpuart.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_mdma.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_opamp.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_pka.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_pwr.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_rcc.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_rng.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_rtc.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_sdmmc.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_spi.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_swpmi.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_system.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_tim.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_ucpd.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_usart.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_usb.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_utils.h | 0 .../SrcWrapper/inc}/LL/stm32yyxx_ll_wwdg.h | 0 .../SrcWrapper/inc}/PeripheralPins.h | 0 .../SrcWrapper/inc}/PinAF_STM32F1.h | 0 .../SrcWrapper/inc}/PinConfigured.h | 0 .../SrcWrapper/inc}/PinNames.h | 12 +++++ .../SrcWrapper/inc}/PinNamesTypes.h | 0 .../SrcWrapper/inc}/PortNames.h | 0 .../SrcWrapper/inc}/analog.h | 0 .../SrcWrapper/inc}/backup.h | 0 .../SrcWrapper/inc}/bootloader.h | 0 .../SrcWrapper/inc}/clock.h | 0 .../SrcWrapper/inc}/core_callback.h | 0 .../SrcWrapper/inc}/digital_io.h | 0 .../stm32 => libraries/SrcWrapper/inc}/dwt.h | 0 .../SrcWrapper/inc}/hw_config.h | 0 .../SrcWrapper/inc}/interrupt.h | 0 .../SrcWrapper/inc}/lock_resource.h | 0 .../stm32 => libraries/SrcWrapper/inc}/otp.h | 0 .../SrcWrapper/inc}/pinconfig.h | 0 .../SrcWrapper/inc}/pinmap.h | 0 .../SrcWrapper/inc}/stm32_assert.h | 0 .../SrcWrapper/inc}/stm32_def.h | 0 .../SrcWrapper/inc}/timer.h | 0 .../stm32 => libraries/SrcWrapper/inc}/uart.h | 0 libraries/SrcWrapper/src/new.cpp | 44 +++++++++++-------- platform.txt | 3 +- tools/platformio/platformio-build.py | 3 +- 80 files changed, 51 insertions(+), 28 deletions(-) rename {cores/arduino => libraries/SrcWrapper/inc}/HardwareTimer.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_adc.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_bdma.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_bus.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_comp.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_cordic.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_cortex.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_crc.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_crs.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_dac.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_dcache.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_delayblock.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_dlyb.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_dma.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_dma2d.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_dmamux.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_exti.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_fmac.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_fmc.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_fmpi2c.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_fsmc.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_gpio.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_hrtim.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_hsem.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_i2c.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_i3c.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_icache.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_ipcc.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_iwdg.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_lpgpio.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_lptim.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_lpuart.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_mdma.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_opamp.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_pka.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_pwr.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_rcc.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_rng.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_rtc.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_sdmmc.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_spi.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_swpmi.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_system.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_tim.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_ucpd.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_usart.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_usb.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_utils.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/LL/stm32yyxx_ll_wwdg.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/PeripheralPins.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/PinAF_STM32F1.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/PinConfigured.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/PinNames.h (94%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/PinNamesTypes.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/PortNames.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/analog.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/backup.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/bootloader.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/clock.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/core_callback.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/digital_io.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/dwt.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/hw_config.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/interrupt.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/lock_resource.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/otp.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/pinconfig.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/pinmap.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/stm32_assert.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/stm32_def.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/timer.h (100%) rename {cores/arduino/stm32 => libraries/SrcWrapper/inc}/uart.h (100%) diff --git a/CI/update/stm32cube.py b/CI/update/stm32cube.py index edea98fba3..73162c26e6 100644 --- a/CI/update/stm32cube.py +++ b/CI/update/stm32cube.py @@ -123,9 +123,8 @@ def checkConfig(): stm32_def = ( repo_local_path / repo_core_name - / "cores" - / "arduino" - / "stm32" + / "libraries" + / "SrcWrapper" / stm32_def ) except IOError: diff --git a/CI/update/stm32wrapper.py b/CI/update/stm32wrapper.py index 1048f9ae2a..ac1d24d917 100644 --- a/CI/update/stm32wrapper.py +++ b/CI/update/stm32wrapper.py @@ -97,7 +97,7 @@ def checkConfig(arg_core, arg_cmsis): HALoutSrc_path = SrcWrapper_path / "src" / "HAL" LLoutSrc_path = SrcWrapper_path / "src" / "LL" - LLoutInc_path = core_path / "cores" / "arduino" / "stm32" / "LL" + LLoutInc_path = SrcWrapper_path / "inc" / "LL" if arg_cmsis is not None: CMSIS_path = Path(arg_cmsis).resolve() diff --git a/License.md b/License.md index ea67f79215..08a773ffcf 100644 --- a/License.md +++ b/License.md @@ -10,14 +10,17 @@ Note: most license information is available on top of each source file [BSD 3-Clause License](#bsd-3-clause-license) is used for: * cores/arduino/stm32/ mainly contains source from STMicroelectronics. -* system/Drivers/STM32*xx_HAL_Driver folders include the STMicroelectronics HAL Drivers. +* system/Drivers/STM32*xx_HAL_Driver folders include the STMicroelectronics HAL Drivers +* libraries/SrcWrapper/inc/PinName*.h [Ultimate Liberty License](#Ultimate-Liberty-License) is used for: * system/Middlewares/STM32_USB_*_Library/ folders [Apache License](#apache-license) is used for: * system/Drivers/CMSIS folder includes the STMicroelectronics CMSIS device -* cores/arduino/stm32/pinmap.* +* system/include/include/pinmap.h +* libraries/SrcWrapper/src/stm32/pinmap.c +* tools/platformio/platformio-build.py Note: * system/STM32*xx/system_stm32*xx.c uses same license than system/Drivers/ subfolders diff --git a/cmake/set_base_arduino_config.cmake b/cmake/set_base_arduino_config.cmake index ece885aeaf..0896d10373 100644 --- a/cmake/set_base_arduino_config.cmake +++ b/cmake/set_base_arduino_config.cmake @@ -55,11 +55,12 @@ target_include_directories(base_config INTERFACE "${BUILD_CORE_PATH}" "${BUILD_CORE_PATH}/avr" "${BUILD_CORE_PATH}/stm32" - "${BUILD_CORE_PATH}/stm32/LL" "${BUILD_CORE_PATH}/stm32/usb" "${BUILD_CORE_PATH}/stm32/OpenAMP" "${BUILD_CORE_PATH}/stm32/usb/hid" "${BUILD_CORE_PATH}/stm32/usb/cdc" + "${BUILD_LIB_PATH}/SrcWrapper/inc" + "${BUILD_LIB_PATH}/SrcWrapper/inc/LL" "${BUILD_SYSTEM_PATH}/Middlewares/ST/STM32_USB_Device_Library/Core/Inc" "${BUILD_SYSTEM_PATH}/Middlewares/ST/STM32_USB_Device_Library/Core/Src" "${CMSIS5_PATH}/CMSIS/DSP/Include" diff --git a/cores/arduino/HardwareTimer.h b/libraries/SrcWrapper/inc/HardwareTimer.h similarity index 100% rename from cores/arduino/HardwareTimer.h rename to libraries/SrcWrapper/inc/HardwareTimer.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_adc.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_adc.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_adc.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_adc.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_bdma.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_bdma.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_bdma.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_bdma.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_bus.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_bus.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_bus.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_bus.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_comp.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_comp.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_comp.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_comp.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_cordic.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_cordic.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_cordic.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_cordic.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_cortex.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_cortex.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_cortex.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_cortex.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_crc.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_crc.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_crc.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_crc.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_crs.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_crs.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_crs.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_crs.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_dac.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_dac.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_dac.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_dac.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_dcache.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_dcache.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_dcache.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_dcache.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_delayblock.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_delayblock.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_delayblock.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_delayblock.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_dlyb.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_dlyb.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_dlyb.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_dlyb.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_dma.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_dma.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_dma.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_dma.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_dma2d.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_dma2d.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_dma2d.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_dma2d.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_dmamux.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_dmamux.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_dmamux.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_dmamux.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_exti.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_exti.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_exti.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_exti.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_fmac.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_fmac.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_fmac.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_fmac.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_fmc.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_fmc.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_fmc.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_fmc.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_fmpi2c.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_fmpi2c.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_fmpi2c.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_fmpi2c.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_fsmc.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_fsmc.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_fsmc.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_fsmc.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_gpio.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_gpio.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_gpio.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_gpio.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_hrtim.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_hrtim.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_hrtim.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_hrtim.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_hsem.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_hsem.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_hsem.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_hsem.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_i2c.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_i2c.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_i2c.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_i2c.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_i3c.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_i3c.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_i3c.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_i3c.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_icache.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_icache.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_icache.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_icache.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_ipcc.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_ipcc.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_ipcc.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_ipcc.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_iwdg.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_iwdg.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_iwdg.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_iwdg.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_lpgpio.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_lpgpio.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_lpgpio.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_lpgpio.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_lptim.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_lptim.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_lptim.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_lptim.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_lpuart.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_lpuart.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_lpuart.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_lpuart.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_mdma.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_mdma.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_mdma.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_mdma.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_opamp.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_opamp.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_opamp.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_opamp.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_pka.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_pka.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_pka.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_pka.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_pwr.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_pwr.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_pwr.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_pwr.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_rcc.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_rcc.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_rcc.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_rcc.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_rng.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_rng.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_rng.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_rng.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_rtc.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_rtc.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_rtc.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_rtc.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_sdmmc.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_sdmmc.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_sdmmc.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_sdmmc.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_spi.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_spi.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_spi.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_spi.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_swpmi.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_swpmi.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_swpmi.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_swpmi.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_system.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_system.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_system.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_system.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_tim.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_tim.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_tim.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_tim.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_ucpd.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_ucpd.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_ucpd.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_ucpd.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_usart.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_usart.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_usart.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_usart.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_usb.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_usb.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_usb.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_usb.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_utils.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_utils.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_utils.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_utils.h diff --git a/cores/arduino/stm32/LL/stm32yyxx_ll_wwdg.h b/libraries/SrcWrapper/inc/LL/stm32yyxx_ll_wwdg.h similarity index 100% rename from cores/arduino/stm32/LL/stm32yyxx_ll_wwdg.h rename to libraries/SrcWrapper/inc/LL/stm32yyxx_ll_wwdg.h diff --git a/cores/arduino/stm32/PeripheralPins.h b/libraries/SrcWrapper/inc/PeripheralPins.h similarity index 100% rename from cores/arduino/stm32/PeripheralPins.h rename to libraries/SrcWrapper/inc/PeripheralPins.h diff --git a/cores/arduino/stm32/PinAF_STM32F1.h b/libraries/SrcWrapper/inc/PinAF_STM32F1.h similarity index 100% rename from cores/arduino/stm32/PinAF_STM32F1.h rename to libraries/SrcWrapper/inc/PinAF_STM32F1.h diff --git a/cores/arduino/stm32/PinConfigured.h b/libraries/SrcWrapper/inc/PinConfigured.h similarity index 100% rename from cores/arduino/stm32/PinConfigured.h rename to libraries/SrcWrapper/inc/PinConfigured.h diff --git a/cores/arduino/stm32/PinNames.h b/libraries/SrcWrapper/inc/PinNames.h similarity index 94% rename from cores/arduino/stm32/PinNames.h rename to libraries/SrcWrapper/inc/PinNames.h index 159fcf6edc..221dbb7512 100644 --- a/cores/arduino/stm32/PinNames.h +++ b/libraries/SrcWrapper/inc/PinNames.h @@ -1,3 +1,15 @@ +/* + ******************************************************************************* + * Copyright (c) 2016-2021, STMicroelectronics + * All rights reserved. + * + * This software component is licensed by ST under BSD 3-Clause license, + * the "License"; You may not use this file except in compliance with the + * License. You may obtain a copy of the License at: + * opensource.org/licenses/BSD-3-Clause + * + ******************************************************************************* + */ #ifndef _PINNAMES_H #define _PINNAMES_H diff --git a/cores/arduino/stm32/PinNamesTypes.h b/libraries/SrcWrapper/inc/PinNamesTypes.h similarity index 100% rename from cores/arduino/stm32/PinNamesTypes.h rename to libraries/SrcWrapper/inc/PinNamesTypes.h diff --git a/cores/arduino/stm32/PortNames.h b/libraries/SrcWrapper/inc/PortNames.h similarity index 100% rename from cores/arduino/stm32/PortNames.h rename to libraries/SrcWrapper/inc/PortNames.h diff --git a/cores/arduino/stm32/analog.h b/libraries/SrcWrapper/inc/analog.h similarity index 100% rename from cores/arduino/stm32/analog.h rename to libraries/SrcWrapper/inc/analog.h diff --git a/cores/arduino/stm32/backup.h b/libraries/SrcWrapper/inc/backup.h similarity index 100% rename from cores/arduino/stm32/backup.h rename to libraries/SrcWrapper/inc/backup.h diff --git a/cores/arduino/stm32/bootloader.h b/libraries/SrcWrapper/inc/bootloader.h similarity index 100% rename from cores/arduino/stm32/bootloader.h rename to libraries/SrcWrapper/inc/bootloader.h diff --git a/cores/arduino/stm32/clock.h b/libraries/SrcWrapper/inc/clock.h similarity index 100% rename from cores/arduino/stm32/clock.h rename to libraries/SrcWrapper/inc/clock.h diff --git a/cores/arduino/stm32/core_callback.h b/libraries/SrcWrapper/inc/core_callback.h similarity index 100% rename from cores/arduino/stm32/core_callback.h rename to libraries/SrcWrapper/inc/core_callback.h diff --git a/cores/arduino/stm32/digital_io.h b/libraries/SrcWrapper/inc/digital_io.h similarity index 100% rename from cores/arduino/stm32/digital_io.h rename to libraries/SrcWrapper/inc/digital_io.h diff --git a/cores/arduino/stm32/dwt.h b/libraries/SrcWrapper/inc/dwt.h similarity index 100% rename from cores/arduino/stm32/dwt.h rename to libraries/SrcWrapper/inc/dwt.h diff --git a/cores/arduino/stm32/hw_config.h b/libraries/SrcWrapper/inc/hw_config.h similarity index 100% rename from cores/arduino/stm32/hw_config.h rename to libraries/SrcWrapper/inc/hw_config.h diff --git a/cores/arduino/stm32/interrupt.h b/libraries/SrcWrapper/inc/interrupt.h similarity index 100% rename from cores/arduino/stm32/interrupt.h rename to libraries/SrcWrapper/inc/interrupt.h diff --git a/cores/arduino/stm32/lock_resource.h b/libraries/SrcWrapper/inc/lock_resource.h similarity index 100% rename from cores/arduino/stm32/lock_resource.h rename to libraries/SrcWrapper/inc/lock_resource.h diff --git a/cores/arduino/stm32/otp.h b/libraries/SrcWrapper/inc/otp.h similarity index 100% rename from cores/arduino/stm32/otp.h rename to libraries/SrcWrapper/inc/otp.h diff --git a/cores/arduino/stm32/pinconfig.h b/libraries/SrcWrapper/inc/pinconfig.h similarity index 100% rename from cores/arduino/stm32/pinconfig.h rename to libraries/SrcWrapper/inc/pinconfig.h diff --git a/cores/arduino/stm32/pinmap.h b/libraries/SrcWrapper/inc/pinmap.h similarity index 100% rename from cores/arduino/stm32/pinmap.h rename to libraries/SrcWrapper/inc/pinmap.h diff --git a/cores/arduino/stm32/stm32_assert.h b/libraries/SrcWrapper/inc/stm32_assert.h similarity index 100% rename from cores/arduino/stm32/stm32_assert.h rename to libraries/SrcWrapper/inc/stm32_assert.h diff --git a/cores/arduino/stm32/stm32_def.h b/libraries/SrcWrapper/inc/stm32_def.h similarity index 100% rename from cores/arduino/stm32/stm32_def.h rename to libraries/SrcWrapper/inc/stm32_def.h diff --git a/cores/arduino/stm32/timer.h b/libraries/SrcWrapper/inc/timer.h similarity index 100% rename from cores/arduino/stm32/timer.h rename to libraries/SrcWrapper/inc/timer.h diff --git a/cores/arduino/stm32/uart.h b/libraries/SrcWrapper/inc/uart.h similarity index 100% rename from cores/arduino/stm32/uart.h rename to libraries/SrcWrapper/inc/uart.h diff --git a/libraries/SrcWrapper/src/new.cpp b/libraries/SrcWrapper/src/new.cpp index 28ea466de1..3d12cf0aa6 100644 --- a/libraries/SrcWrapper/src/new.cpp +++ b/libraries/SrcWrapper/src/new.cpp @@ -1,21 +1,27 @@ -/* - Copyright (c) 2014 Arduino. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - +/* Teensyduino Core Library + * http://www.pjrc.com/teensy/ + * Copyright (c) 2017 PJRC.COM, LLC. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * 1. The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ #include void *operator new (size_t size) @@ -46,4 +52,4 @@ void operator delete (void *ptr, size_t /*size*/) void operator delete[](void *ptr, size_t /*size*/) { free(ptr); -} \ No newline at end of file +} diff --git a/platform.txt b/platform.txt index 4df3db3de5..6d4a6274bb 100644 --- a/platform.txt +++ b/platform.txt @@ -29,10 +29,11 @@ hal_dir={build.system.path}/Drivers/{build.series}_HAL_Driver cmsis_dir={runtime.tools.CMSIS-5.9.0.path}/CMSIS cmsis_dev_dir={build.system.path}/Drivers/CMSIS/Device/ST/{build.series} usbd_core_dir={build.system.path}/Middlewares/ST/STM32_USB_Device_Library/Core +SrcWrapper_include_dir={runtime.platform.path}/libraries/SrcWrapper/inc # STM compile variables # ---------------------- -compiler.stm.extra_include="-I{build.source.path}" "-I{build.core.path}/avr" "-I{core_stm32_dir}" "-I{core_stm32_dir}/LL" "-I{core_usb_dir}" "-I{core_stm32_dir}/OpenAMP" "-I{core_usb_dir}/hid" "-I{core_usb_dir}/cdc" "-I{hal_dir}/Inc" "-I{hal_dir}/Src" "-I{build.system.path}/{build.series}" "-I{usbd_core_dir}/Inc" "-I{usbd_core_dir}/Src" {build.virtio_extra_include} +compiler.stm.extra_include="-I{build.source.path}" "-I{build.core.path}/avr" "-I{core_stm32_dir}" "-I{core_stm32_dir}/LL" "-I{SrcWrapper_include_dir}" "-I{core_usb_dir}" "-I{core_stm32_dir}/OpenAMP" "-I{core_usb_dir}/hid" "-I{core_usb_dir}/cdc" "-I{hal_dir}/Inc" "-I{hal_dir}/Src" "-I{build.system.path}/{build.series}" "-I{usbd_core_dir}/Inc" "-I{usbd_core_dir}/Src" {build.virtio_extra_include} compiler.arm.cmsis.c.flags="-I{cmsis_dir}/Core/Include/" "-I{cmsis_dev_dir}/Include/" "-I{cmsis_dev_dir}/Source/Templates/gcc/" "-I{cmsis_dir}/DSP/Include" "-I{cmsis_dir}/DSP/PrivateInclude" compiler.warning_flags=-w diff --git a/tools/platformio/platformio-build.py b/tools/platformio/platformio-build.py index 89336ca215..42fe92eba3 100644 --- a/tools/platformio/platformio-build.py +++ b/tools/platformio/platformio-build.py @@ -258,11 +258,12 @@ def get_arduino_board_id(board_config, mcu): CPPPATH=[ join(FRAMEWORK_DIR, "cores", "arduino", "avr"), join(FRAMEWORK_DIR, "cores", "arduino", "stm32"), - join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "LL"), join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "usb"), join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "OpenAMP"), join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "usb", "hid"), join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "usb", "cdc"), + join(FRAMEWORK_DIR, "libraries", "SrcWrapper", "inc"), + join(FRAMEWORK_DIR, "libraries", "SrcWrapper", "inc", "LL"), join(FRAMEWORK_DIR, "system", "Drivers", series + "_HAL_Driver", "Inc"), join(FRAMEWORK_DIR, "system", "Drivers", series + "_HAL_Driver", "Src"), join(FRAMEWORK_DIR, "system", series), From 8136da7d2f5e942c963fe636aa8d1d085b92452f Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Mon, 17 Jun 2024 17:23:30 +0200 Subject: [PATCH 2/3] refactor(VirtIO): move VirtIOSerial as a built-in library Including OpenAMP. Signed-off-by: Frederic Pillon --- License.md | 15 ++++++ cmake/set_base_arduino_config.cmake | 2 +- cmake/templates/easy_cmake.cmake | 1 + cores/arduino/CMakeLists.txt | 24 --------- cores/arduino/WSerial.h | 4 +- libraries/CMakeLists.txt | 1 + libraries/VirtIO/CMakeLists.txt | 53 +++++++++++++++++++ .../VirtIO/examples/loopback/loopback.ino | 25 +++++++++ .../VirtIO/inc}/VirtIOSerial.h | 0 .../VirtIO/inc}/openamp.h | 0 .../VirtIO/inc}/openamp_conf.h | 0 .../VirtIO/inc}/virtio_buffer.h | 0 .../VirtIO/inc}/virtio_config.h | 0 .../VirtIO/inc}/virtio_log.h | 0 libraries/VirtIO/keywords.txt | 30 +++++++++++ libraries/VirtIO/library.properties | 9 ++++ libraries/VirtIO/src/VirtIO.h | 4 ++ .../VirtIO/src}/VirtIOSerial.cpp | 0 .../VirtIO/src}/libmetal/device.c | 0 .../VirtIO/src}/libmetal/generic/condition.c | 0 .../src}/libmetal/generic/cortexm/sys.c | 0 .../src}/libmetal/generic/generic_device.c | 0 .../src}/libmetal/generic/generic_init.c | 0 .../VirtIO/src}/libmetal/generic/generic_io.c | 0 .../src}/libmetal/generic/generic_shmem.c | 0 .../VirtIO/src}/libmetal/generic/time.c | 0 .../VirtIO/src}/libmetal/init.c | 0 .../VirtIO/src}/libmetal/io.c | 0 .../VirtIO/src}/libmetal/log.c | 0 .../VirtIO/src}/libmetal/shmem.c | 0 .../VirtIO/src}/mbox_ipcc.c | 0 .../VirtIO/src}/mbox_ipcc.h | 0 .../open-amp/remoteproc/remoteproc_virtio.c | 0 .../VirtIO/src}/open-amp/rpmsg/rpmsg.c | 0 .../VirtIO/src}/open-amp/rpmsg/rpmsg_virtio.c | 0 .../VirtIO/src}/openamp.c | 0 .../VirtIO/src}/rsc_table.c | 0 .../VirtIO/src}/rsc_table.h | 0 .../VirtIO/src}/virt_uart.c | 0 .../VirtIO/src}/virtio/virtio.c | 0 .../VirtIO/src}/virtio/virtqueue.c | 0 .../VirtIO/src}/virtio_buffer.c | 0 .../VirtIO/src}/virtio_log.c | 0 platform.txt | 5 +- system/extras/prebuild.sh | 7 ++- tools/platformio/platformio-build.py | 2 +- .../README.md | 16 +++--- 47 files changed, 160 insertions(+), 38 deletions(-) create mode 100644 libraries/VirtIO/CMakeLists.txt create mode 100644 libraries/VirtIO/examples/loopback/loopback.ino rename {cores/arduino => libraries/VirtIO/inc}/VirtIOSerial.h (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/inc}/openamp.h (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/inc}/openamp_conf.h (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/inc}/virtio_buffer.h (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/inc}/virtio_config.h (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/inc}/virtio_log.h (100%) create mode 100644 libraries/VirtIO/keywords.txt create mode 100644 libraries/VirtIO/library.properties create mode 100644 libraries/VirtIO/src/VirtIO.h rename {cores/arduino => libraries/VirtIO/src}/VirtIOSerial.cpp (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/src}/libmetal/device.c (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/src}/libmetal/generic/condition.c (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/src}/libmetal/generic/cortexm/sys.c (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/src}/libmetal/generic/generic_device.c (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/src}/libmetal/generic/generic_init.c (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/src}/libmetal/generic/generic_io.c (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/src}/libmetal/generic/generic_shmem.c (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/src}/libmetal/generic/time.c (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/src}/libmetal/init.c (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/src}/libmetal/io.c (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/src}/libmetal/log.c (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/src}/libmetal/shmem.c (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/src}/mbox_ipcc.c (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/src}/mbox_ipcc.h (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/src}/open-amp/remoteproc/remoteproc_virtio.c (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/src}/open-amp/rpmsg/rpmsg.c (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/src}/open-amp/rpmsg/rpmsg_virtio.c (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/src}/openamp.c (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/src}/rsc_table.c (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/src}/rsc_table.h (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/src}/virt_uart.c (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/src}/virtio/virtio.c (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/src}/virtio/virtqueue.c (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/src}/virtio_buffer.c (100%) rename {cores/arduino/stm32/OpenAMP => libraries/VirtIO/src}/virtio_log.c (100%) diff --git a/License.md b/License.md index 08a773ffcf..4205a386c4 100644 --- a/License.md +++ b/License.md @@ -11,6 +11,8 @@ Note: most license information is available on top of each source file * cores/arduino/stm32/ mainly contains source from STMicroelectronics. * system/Drivers/STM32*xx_HAL_Driver folders include the STMicroelectronics HAL Drivers +* system/Middlewares/OpenAMP +* libraries/VirtIO - except virtio implementation (see [MIT License](#mit-license)) * libraries/SrcWrapper/inc/PinName*.h [Ultimate Liberty License](#Ultimate-Liberty-License) is used for: @@ -22,6 +24,9 @@ Note: most license information is available on top of each source file * libraries/SrcWrapper/src/stm32/pinmap.c * tools/platformio/platformio-build.py +[MIT License](#mit-license) +* libraries/VirtIO/*/virtio* + Note: * system/STM32*xx/system_stm32*xx.c uses same license than system/Drivers/ subfolders * system/STM32*xx/stm32*xx_hal_conf_default.h uses same license than system/Drivers/CMSIS @@ -776,3 +781,13 @@ the License. You may obtain a copy of the License at: limitations under the License. ------------------------------------------------------------------------------- +## MIT License +The MIT License (MIT) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +------------------------------------------------------------------------------- diff --git a/cmake/set_base_arduino_config.cmake b/cmake/set_base_arduino_config.cmake index 0896d10373..d678bebb27 100644 --- a/cmake/set_base_arduino_config.cmake +++ b/cmake/set_base_arduino_config.cmake @@ -56,11 +56,11 @@ target_include_directories(base_config INTERFACE "${BUILD_CORE_PATH}/avr" "${BUILD_CORE_PATH}/stm32" "${BUILD_CORE_PATH}/stm32/usb" - "${BUILD_CORE_PATH}/stm32/OpenAMP" "${BUILD_CORE_PATH}/stm32/usb/hid" "${BUILD_CORE_PATH}/stm32/usb/cdc" "${BUILD_LIB_PATH}/SrcWrapper/inc" "${BUILD_LIB_PATH}/SrcWrapper/inc/LL" + "${BUILD_LIB_PATH}/VirtIO/inc" "${BUILD_SYSTEM_PATH}/Middlewares/ST/STM32_USB_Device_Library/Core/Inc" "${BUILD_SYSTEM_PATH}/Middlewares/ST/STM32_USB_Device_Library/Core/Src" "${CMSIS5_PATH}/CMSIS/DSP/Include" diff --git a/cmake/templates/easy_cmake.cmake b/cmake/templates/easy_cmake.cmake index 2d979dd920..66f5d89be6 100644 --- a/cmake/templates/easy_cmake.cmake +++ b/cmake/templates/easy_cmake.cmake @@ -91,6 +91,7 @@ build_sketch(TARGET "{{tgtname or "@binary_name_here@"}}" # SD # Wire # SPI + # VirtIO ) # STEP 4: optional features diff --git a/cores/arduino/CMakeLists.txt b/cores/arduino/CMakeLists.txt index 80865f8f58..ded62991cc 100644 --- a/cores/arduino/CMakeLists.txt +++ b/cores/arduino/CMakeLists.txt @@ -31,29 +31,6 @@ add_library(core_bin STATIC EXCLUDE_FROM_ALL pins_arduino.c Print.cpp RingBuffer.cpp - stm32/OpenAMP/libmetal/device.c - stm32/OpenAMP/libmetal/generic/condition.c - stm32/OpenAMP/libmetal/generic/cortexm/sys.c - stm32/OpenAMP/libmetal/generic/generic_device.c - stm32/OpenAMP/libmetal/generic/generic_init.c - stm32/OpenAMP/libmetal/generic/generic_io.c - stm32/OpenAMP/libmetal/generic/generic_shmem.c - stm32/OpenAMP/libmetal/generic/time.c - stm32/OpenAMP/libmetal/init.c - stm32/OpenAMP/libmetal/io.c - stm32/OpenAMP/libmetal/log.c - stm32/OpenAMP/libmetal/shmem.c - stm32/OpenAMP/mbox_ipcc.c - stm32/OpenAMP/open-amp/remoteproc/remoteproc_virtio.c - stm32/OpenAMP/open-amp/rpmsg/rpmsg.c - stm32/OpenAMP/open-amp/rpmsg/rpmsg_virtio.c - stm32/OpenAMP/openamp.c - stm32/OpenAMP/rsc_table.c - stm32/OpenAMP/virt_uart.c - stm32/OpenAMP/virtio/virtio.c - stm32/OpenAMP/virtio/virtqueue.c - stm32/OpenAMP/virtio_buffer.c - stm32/OpenAMP/virtio_log.c stm32/startup_stm32yyxx.S stm32/usb/cdc/cdc_queue.c stm32/usb/cdc/usbd_cdc.c @@ -70,7 +47,6 @@ add_library(core_bin STATIC EXCLUDE_FROM_ALL Stream.cpp Tone.cpp USBSerial.cpp - VirtIOSerial.cpp WInterrupts.cpp wiring_analog.c wiring_digital.c diff --git a/cores/arduino/WSerial.h b/cores/arduino/WSerial.h index 3a2766e2ce..4214fe6e1e 100644 --- a/cores/arduino/WSerial.h +++ b/cores/arduino/WSerial.h @@ -4,7 +4,9 @@ #include "variant.h" #include "HardwareSerial.h" #include "USBSerial.h" -#include "VirtIOSerial.h" +#if defined(VIRTIOCON) + #include "VirtIOSerial.h" +#endif /* VIRTIOCON */ #if defined (USBCON) && defined(USBD_USE_CDC) #ifndef DISABLE_GENERIC_SERIALUSB diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt index 791d8acaca..f6d31df11a 100644 --- a/libraries/CMakeLists.txt +++ b/libraries/CMakeLists.txt @@ -10,4 +10,5 @@ add_subdirectory(SPI) add_subdirectory(Servo) add_subdirectory(SoftwareSerial) add_subdirectory(SrcWrapper) +add_subdirectory(VirtIO) add_subdirectory(Wire) diff --git a/libraries/VirtIO/CMakeLists.txt b/libraries/VirtIO/CMakeLists.txt new file mode 100644 index 0000000000..ff6e242250 --- /dev/null +++ b/libraries/VirtIO/CMakeLists.txt @@ -0,0 +1,53 @@ +# v3.21 implemented semantic changes regarding $ +# See https://cmake.org/cmake/help/v3.21/command/target_link_libraries.html#linking-object-libraries-via-target-objects +cmake_minimum_required(VERSION 3.21) + +add_library(VirtIO INTERFACE) +add_library(VirtIO_usage INTERFACE) + +target_include_directories(VirtIO_usage INTERFACE + src +) + + +target_link_libraries(VirtIO_usage INTERFACE + base_config +) + +target_link_libraries(VirtIO INTERFACE VirtIO_usage) + + + +add_library(VirtIO_bin OBJECT EXCLUDE_FROM_ALL + src/libmetal/device.c + src/libmetal/generic/condition.c + src/libmetal/generic/cortexm/sys.c + src/libmetal/generic/generic_device.c + src/libmetal/generic/generic_init.c + src/libmetal/generic/generic_io.c + src/libmetal/generic/generic_shmem.c + src/libmetal/generic/time.c + src/libmetal/init.c + src/libmetal/io.c + src/libmetal/log.c + src/libmetal/shmem.c + src/mbox_ipcc.c + src/open-amp/remoteproc/remoteproc_virtio.c + src/open-amp/rpmsg/rpmsg.c + src/open-amp/rpmsg/rpmsg_virtio.c + src/openamp.c + src/rsc_table.c + src/virt_uart.c + src/virtio/virtio.c + src/virtio/virtqueue.c + src/virtio_buffer.c + src/virtio_log.c + src/VirtIOSerial.cpp +) +target_link_libraries(VirtIO_bin PUBLIC VirtIO_usage) + +target_link_libraries(VirtIO INTERFACE + VirtIO_bin + $ +) + diff --git a/libraries/VirtIO/examples/loopback/loopback.ino b/libraries/VirtIO/examples/loopback/loopback.ino new file mode 100644 index 0000000000..41e7b0f1e4 --- /dev/null +++ b/libraries/VirtIO/examples/loopback/loopback.ino @@ -0,0 +1,25 @@ +int available; +char buffer[1024]; + +unsigned long start_time = 0; + +void setup() { + Serial.begin(115200); + pinMode(LED_BUILTIN, OUTPUT); +} + +void loop() { + available = Serial.available(); + while (available > 0) { + int size = min(available, Serial.availableForWrite()); + Serial.readBytes(buffer, size); + Serial.write(buffer, size); + available -= size; + } + + // Heartbeat. If Arduino stops the LED won't flash anymore. + if ((millis() - start_time) > 1000) { + start_time = millis(); + digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); + } +} diff --git a/cores/arduino/VirtIOSerial.h b/libraries/VirtIO/inc/VirtIOSerial.h similarity index 100% rename from cores/arduino/VirtIOSerial.h rename to libraries/VirtIO/inc/VirtIOSerial.h diff --git a/cores/arduino/stm32/OpenAMP/openamp.h b/libraries/VirtIO/inc/openamp.h similarity index 100% rename from cores/arduino/stm32/OpenAMP/openamp.h rename to libraries/VirtIO/inc/openamp.h diff --git a/cores/arduino/stm32/OpenAMP/openamp_conf.h b/libraries/VirtIO/inc/openamp_conf.h similarity index 100% rename from cores/arduino/stm32/OpenAMP/openamp_conf.h rename to libraries/VirtIO/inc/openamp_conf.h diff --git a/cores/arduino/stm32/OpenAMP/virtio_buffer.h b/libraries/VirtIO/inc/virtio_buffer.h similarity index 100% rename from cores/arduino/stm32/OpenAMP/virtio_buffer.h rename to libraries/VirtIO/inc/virtio_buffer.h diff --git a/cores/arduino/stm32/OpenAMP/virtio_config.h b/libraries/VirtIO/inc/virtio_config.h similarity index 100% rename from cores/arduino/stm32/OpenAMP/virtio_config.h rename to libraries/VirtIO/inc/virtio_config.h diff --git a/cores/arduino/stm32/OpenAMP/virtio_log.h b/libraries/VirtIO/inc/virtio_log.h similarity index 100% rename from cores/arduino/stm32/OpenAMP/virtio_log.h rename to libraries/VirtIO/inc/virtio_log.h diff --git a/libraries/VirtIO/keywords.txt b/libraries/VirtIO/keywords.txt new file mode 100644 index 0000000000..caacdddcae --- /dev/null +++ b/libraries/VirtIO/keywords.txt @@ -0,0 +1,30 @@ +####################################### +# Syntax Coloring Map For VirtIO +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### +VirtIOSerial KEYWORD1 +VIRT_UART_HandleTypeDef KEYWORD1 +VirtIOSerialObj_t KEYWORD1 +virtio_buffer_t KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### +SerialVirtIO KEYWORD2 +begin KEYWORD2 +available KEYWORD2 +availableForWrite KEYWORD2 +peek KEYWORD2 +read KEYWORD2 +readBytes KEYWORD2 +write KEYWORD2 +flush KEYWORD2 +rxGenericCallback KEYWORD2 +rxCallback KEYWORD2 + +####################################### +# Constants (LITERAL1) +####################################### diff --git a/libraries/VirtIO/library.properties b/libraries/VirtIO/library.properties new file mode 100644 index 0000000000..dee2ebd8e8 --- /dev/null +++ b/libraries/VirtIO/library.properties @@ -0,0 +1,9 @@ +name=VirtIO +version=1.0.0 +author=Bumsik kim +maintainer=stm32duino +sentence=Enables serial communication between Cortex-A7 (Linux) and Cortex-M4 (Arduino) on STM32 MPUs via shared memory. +paragraph=Provide VirtIOSerial based on OpenAMP. +category=Communication +url=https://github.com/stm32duino/Arduino_Core_STM32 +architectures=stm32 diff --git a/libraries/VirtIO/src/VirtIO.h b/libraries/VirtIO/src/VirtIO.h new file mode 100644 index 0000000000..5d3a8e946f --- /dev/null +++ b/libraries/VirtIO/src/VirtIO.h @@ -0,0 +1,4 @@ +#ifndef __VIRTIO_H__ +#define __VIRTIO_H__ + +#endif /* __VIRTIO_H__ */ diff --git a/cores/arduino/VirtIOSerial.cpp b/libraries/VirtIO/src/VirtIOSerial.cpp similarity index 100% rename from cores/arduino/VirtIOSerial.cpp rename to libraries/VirtIO/src/VirtIOSerial.cpp diff --git a/cores/arduino/stm32/OpenAMP/libmetal/device.c b/libraries/VirtIO/src/libmetal/device.c similarity index 100% rename from cores/arduino/stm32/OpenAMP/libmetal/device.c rename to libraries/VirtIO/src/libmetal/device.c diff --git a/cores/arduino/stm32/OpenAMP/libmetal/generic/condition.c b/libraries/VirtIO/src/libmetal/generic/condition.c similarity index 100% rename from cores/arduino/stm32/OpenAMP/libmetal/generic/condition.c rename to libraries/VirtIO/src/libmetal/generic/condition.c diff --git a/cores/arduino/stm32/OpenAMP/libmetal/generic/cortexm/sys.c b/libraries/VirtIO/src/libmetal/generic/cortexm/sys.c similarity index 100% rename from cores/arduino/stm32/OpenAMP/libmetal/generic/cortexm/sys.c rename to libraries/VirtIO/src/libmetal/generic/cortexm/sys.c diff --git a/cores/arduino/stm32/OpenAMP/libmetal/generic/generic_device.c b/libraries/VirtIO/src/libmetal/generic/generic_device.c similarity index 100% rename from cores/arduino/stm32/OpenAMP/libmetal/generic/generic_device.c rename to libraries/VirtIO/src/libmetal/generic/generic_device.c diff --git a/cores/arduino/stm32/OpenAMP/libmetal/generic/generic_init.c b/libraries/VirtIO/src/libmetal/generic/generic_init.c similarity index 100% rename from cores/arduino/stm32/OpenAMP/libmetal/generic/generic_init.c rename to libraries/VirtIO/src/libmetal/generic/generic_init.c diff --git a/cores/arduino/stm32/OpenAMP/libmetal/generic/generic_io.c b/libraries/VirtIO/src/libmetal/generic/generic_io.c similarity index 100% rename from cores/arduino/stm32/OpenAMP/libmetal/generic/generic_io.c rename to libraries/VirtIO/src/libmetal/generic/generic_io.c diff --git a/cores/arduino/stm32/OpenAMP/libmetal/generic/generic_shmem.c b/libraries/VirtIO/src/libmetal/generic/generic_shmem.c similarity index 100% rename from cores/arduino/stm32/OpenAMP/libmetal/generic/generic_shmem.c rename to libraries/VirtIO/src/libmetal/generic/generic_shmem.c diff --git a/cores/arduino/stm32/OpenAMP/libmetal/generic/time.c b/libraries/VirtIO/src/libmetal/generic/time.c similarity index 100% rename from cores/arduino/stm32/OpenAMP/libmetal/generic/time.c rename to libraries/VirtIO/src/libmetal/generic/time.c diff --git a/cores/arduino/stm32/OpenAMP/libmetal/init.c b/libraries/VirtIO/src/libmetal/init.c similarity index 100% rename from cores/arduino/stm32/OpenAMP/libmetal/init.c rename to libraries/VirtIO/src/libmetal/init.c diff --git a/cores/arduino/stm32/OpenAMP/libmetal/io.c b/libraries/VirtIO/src/libmetal/io.c similarity index 100% rename from cores/arduino/stm32/OpenAMP/libmetal/io.c rename to libraries/VirtIO/src/libmetal/io.c diff --git a/cores/arduino/stm32/OpenAMP/libmetal/log.c b/libraries/VirtIO/src/libmetal/log.c similarity index 100% rename from cores/arduino/stm32/OpenAMP/libmetal/log.c rename to libraries/VirtIO/src/libmetal/log.c diff --git a/cores/arduino/stm32/OpenAMP/libmetal/shmem.c b/libraries/VirtIO/src/libmetal/shmem.c similarity index 100% rename from cores/arduino/stm32/OpenAMP/libmetal/shmem.c rename to libraries/VirtIO/src/libmetal/shmem.c diff --git a/cores/arduino/stm32/OpenAMP/mbox_ipcc.c b/libraries/VirtIO/src/mbox_ipcc.c similarity index 100% rename from cores/arduino/stm32/OpenAMP/mbox_ipcc.c rename to libraries/VirtIO/src/mbox_ipcc.c diff --git a/cores/arduino/stm32/OpenAMP/mbox_ipcc.h b/libraries/VirtIO/src/mbox_ipcc.h similarity index 100% rename from cores/arduino/stm32/OpenAMP/mbox_ipcc.h rename to libraries/VirtIO/src/mbox_ipcc.h diff --git a/cores/arduino/stm32/OpenAMP/open-amp/remoteproc/remoteproc_virtio.c b/libraries/VirtIO/src/open-amp/remoteproc/remoteproc_virtio.c similarity index 100% rename from cores/arduino/stm32/OpenAMP/open-amp/remoteproc/remoteproc_virtio.c rename to libraries/VirtIO/src/open-amp/remoteproc/remoteproc_virtio.c diff --git a/cores/arduino/stm32/OpenAMP/open-amp/rpmsg/rpmsg.c b/libraries/VirtIO/src/open-amp/rpmsg/rpmsg.c similarity index 100% rename from cores/arduino/stm32/OpenAMP/open-amp/rpmsg/rpmsg.c rename to libraries/VirtIO/src/open-amp/rpmsg/rpmsg.c diff --git a/cores/arduino/stm32/OpenAMP/open-amp/rpmsg/rpmsg_virtio.c b/libraries/VirtIO/src/open-amp/rpmsg/rpmsg_virtio.c similarity index 100% rename from cores/arduino/stm32/OpenAMP/open-amp/rpmsg/rpmsg_virtio.c rename to libraries/VirtIO/src/open-amp/rpmsg/rpmsg_virtio.c diff --git a/cores/arduino/stm32/OpenAMP/openamp.c b/libraries/VirtIO/src/openamp.c similarity index 100% rename from cores/arduino/stm32/OpenAMP/openamp.c rename to libraries/VirtIO/src/openamp.c diff --git a/cores/arduino/stm32/OpenAMP/rsc_table.c b/libraries/VirtIO/src/rsc_table.c similarity index 100% rename from cores/arduino/stm32/OpenAMP/rsc_table.c rename to libraries/VirtIO/src/rsc_table.c diff --git a/cores/arduino/stm32/OpenAMP/rsc_table.h b/libraries/VirtIO/src/rsc_table.h similarity index 100% rename from cores/arduino/stm32/OpenAMP/rsc_table.h rename to libraries/VirtIO/src/rsc_table.h diff --git a/cores/arduino/stm32/OpenAMP/virt_uart.c b/libraries/VirtIO/src/virt_uart.c similarity index 100% rename from cores/arduino/stm32/OpenAMP/virt_uart.c rename to libraries/VirtIO/src/virt_uart.c diff --git a/cores/arduino/stm32/OpenAMP/virtio/virtio.c b/libraries/VirtIO/src/virtio/virtio.c similarity index 100% rename from cores/arduino/stm32/OpenAMP/virtio/virtio.c rename to libraries/VirtIO/src/virtio/virtio.c diff --git a/cores/arduino/stm32/OpenAMP/virtio/virtqueue.c b/libraries/VirtIO/src/virtio/virtqueue.c similarity index 100% rename from cores/arduino/stm32/OpenAMP/virtio/virtqueue.c rename to libraries/VirtIO/src/virtio/virtqueue.c diff --git a/cores/arduino/stm32/OpenAMP/virtio_buffer.c b/libraries/VirtIO/src/virtio_buffer.c similarity index 100% rename from cores/arduino/stm32/OpenAMP/virtio_buffer.c rename to libraries/VirtIO/src/virtio_buffer.c diff --git a/cores/arduino/stm32/OpenAMP/virtio_log.c b/libraries/VirtIO/src/virtio_log.c similarity index 100% rename from cores/arduino/stm32/OpenAMP/virtio_log.c rename to libraries/VirtIO/src/virtio_log.c diff --git a/platform.txt b/platform.txt index 6d4a6274bb..b449bc06a5 100644 --- a/platform.txt +++ b/platform.txt @@ -30,10 +30,11 @@ cmsis_dir={runtime.tools.CMSIS-5.9.0.path}/CMSIS cmsis_dev_dir={build.system.path}/Drivers/CMSIS/Device/ST/{build.series} usbd_core_dir={build.system.path}/Middlewares/ST/STM32_USB_Device_Library/Core SrcWrapper_include_dir={runtime.platform.path}/libraries/SrcWrapper/inc +VirtIO_include_dir={runtime.platform.path}/libraries/VirtIO/inc # STM compile variables # ---------------------- -compiler.stm.extra_include="-I{build.source.path}" "-I{build.core.path}/avr" "-I{core_stm32_dir}" "-I{core_stm32_dir}/LL" "-I{SrcWrapper_include_dir}" "-I{core_usb_dir}" "-I{core_stm32_dir}/OpenAMP" "-I{core_usb_dir}/hid" "-I{core_usb_dir}/cdc" "-I{hal_dir}/Inc" "-I{hal_dir}/Src" "-I{build.system.path}/{build.series}" "-I{usbd_core_dir}/Inc" "-I{usbd_core_dir}/Src" {build.virtio_extra_include} +compiler.stm.extra_include="-I{build.source.path}" "-I{build.core.path}/avr" "-I{core_stm32_dir}" "-I{SrcWrapper_include_dir}" "-I{SrcWrapper_include_dir}/LL" "-I{core_usb_dir}" "-I{core_usb_dir}/hid" "-I{core_usb_dir}/cdc" "-I{hal_dir}/Inc" "-I{hal_dir}/Src" "-I{build.system.path}/{build.series}" "-I{usbd_core_dir}/Inc" "-I{usbd_core_dir}/Src" "-I{VirtIO_include_dir}" {build.virtio_extra_include} compiler.arm.cmsis.c.flags="-I{cmsis_dir}/Core/Include/" "-I{cmsis_dev_dir}/Include/" "-I{cmsis_dev_dir}/Source/Templates/gcc/" "-I{cmsis_dir}/DSP/Include" "-I{cmsis_dir}/DSP/PrivateInclude" compiler.warning_flags=-w @@ -145,7 +146,7 @@ build.opt.path={build.path}/sketch/{build.opt.name} extras.path={build.system.path}/extras # Create {build.opt} if not exists in the output sketch dir and force include of SrcWrapper library -recipe.hooks.prebuild.1.pattern="{busybox}" sh "{extras.path}/prebuild.sh" "{build.path}" "{build.source.path}" "{runtime.platform.path}" +recipe.hooks.prebuild.1.pattern="{busybox}" sh "{extras.path}/prebuild.sh" "{build.path}" "{build.source.path}" "{runtime.platform.path}" "{build.enable_virtio}" recipe.hooks.postbuild.1.pattern="{busybox}" sh "{extras.path}/postbuild.sh" "{build.path}" "{build.series}" "{runtime.platform.path}" # compile patterns diff --git a/system/extras/prebuild.sh b/system/extras/prebuild.sh index 8be41a9035..c4f2ce01c6 100755 --- a/system/extras/prebuild.sh +++ b/system/extras/prebuild.sh @@ -3,6 +3,7 @@ BUILD_PATH="$1" BUILD_SOURCE_PATH="$2" BOARD_PLATFORM_PATH="$3" +BUILD_VIRTIO="$4" # Create sketch dir if not exists if [ ! -f "$BUILD_PATH/sketch" ]; then @@ -43,4 +44,8 @@ esac printf '\n-fmacro-prefix-map="%s"=.' "${prefix}" >>"$BUILD_PATH/sketch/build.opt" # Force include of SrcWrapper library -echo "#include " >"$BUILD_PATH/sketch/SrcWrapper.cpp" +echo "#include " >"$BUILD_PATH/sketch/requiredLibraries.cpp" +# Force include of VirtIO library if required +if [ -n "${BUILD_VIRTIO#*=}" ]; then + echo "#include " >>"$BUILD_PATH/sketch/requiredLibraries.cpp" +fi diff --git a/tools/platformio/platformio-build.py b/tools/platformio/platformio-build.py index 42fe92eba3..6a154a826f 100644 --- a/tools/platformio/platformio-build.py +++ b/tools/platformio/platformio-build.py @@ -259,11 +259,11 @@ def get_arduino_board_id(board_config, mcu): join(FRAMEWORK_DIR, "cores", "arduino", "avr"), join(FRAMEWORK_DIR, "cores", "arduino", "stm32"), join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "usb"), - join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "OpenAMP"), join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "usb", "hid"), join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "usb", "cdc"), join(FRAMEWORK_DIR, "libraries", "SrcWrapper", "inc"), join(FRAMEWORK_DIR, "libraries", "SrcWrapper", "inc", "LL"), + join(FRAMEWORK_DIR, "libraries", "VirtIO", "inc"), join(FRAMEWORK_DIR, "system", "Drivers", series + "_HAL_Driver", "Inc"), join(FRAMEWORK_DIR, "system", "Drivers", series + "_HAL_Driver", "Src"), join(FRAMEWORK_DIR, "system", series), diff --git a/variants/STM32MP1xx/MP153AAC_MP153CAC_MP153DAC_MP153FAC_MP157AAC_MP157CAC_MP157DAC_MP157FAC/README.md b/variants/STM32MP1xx/MP153AAC_MP153CAC_MP153DAC_MP153FAC_MP157AAC_MP157CAC_MP157DAC_MP157FAC/README.md index 164eca6e2b..92eafcf7bd 100644 --- a/variants/STM32MP1xx/MP153AAC_MP153CAC_MP153DAC_MP153FAC_MP157AAC_MP157CAC_MP157DAC_MP157FAC/README.md +++ b/variants/STM32MP1xx/MP153AAC_MP153CAC_MP153DAC_MP153FAC_MP157AAC_MP157CAC_MP157DAC_MP157FAC/README.md @@ -103,9 +103,9 @@ See [OpenAMP] and [Linux RPMsg] to learn more. To increase the performance of SerialVirtIO you can resize the related buffer configurations. There are three definitions you can use: -* [`VRING_NUM_BUFFS`](/cores/arduino/stm32/OpenAMP/virtio_config.h) -* [`RPMSG_BUFFER_SIZE`](/cores/arduino/stm32/OpenAMP/virtio_config.h) -* [`VIRTIO_BUFFER_SIZE`](/cores/arduino/stm32/OpenAMP/virtio_buffer.h) +* [`VRING_NUM_BUFFS`](/libraries/VirtIO/inc/virtio_config.h) +* [`RPMSG_BUFFER_SIZE`](/libraries/VirtIO/inc/virtio_config.h) +* [`VIRTIO_BUFFER_SIZE`](/libraries/VirtIO/inc/virtio_buffer.h) The recommended option is to resize `VRING_NUM_BUFFS`. Be very cautious when resizing `RPMSG_BUFFER_SIZE`, which must be matched with the Linux kernel definition. Also `VIRTIO_BUFFER_SIZE` has the minimum required size depending on the other two. See their links above for further descriptions. @@ -122,7 +122,7 @@ Here is a basic echo example: int available; char buffer[1024]; -unsigned long time = 0; +unsigned long start_time = 0; void setup() { // You can SerialVirtIO.begin() and use SerialVirtIO later instead. @@ -140,8 +140,8 @@ void loop() { } // Heartbeat. If Arduino stops the LED won't flash anymore. - if ((millis() - time) > 1000) { - time = millis(); + if ((millis() - start_time) > 1000) { + start_time = millis(); digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); } } @@ -308,11 +308,11 @@ And then the Device Tree should enable TIM1 for the coprocessor, although this d [OpenAMP]: https://github.com/OpenAMP/open-amp/wiki/OpenAMP-Overview [Linux RPMsg]: https://wiki.st.com/stm32mpu/wiki/Linux_RPMsg_framework_overview -[a hard restriction of the write size]: /cores/arduino/VirtIOSerial.cpp#L148 +[a hard restriction of the write size]: /libraries/VirtIO/src/VirtIOSerial.cpp#L148 [build_opt.h]: https://github.com/stm32duino/Arduino_Core_STM32/wiki/Customize-build-options-using-build_opt.h [build_opt.h description in wiki]: https://github.com/stm32duino/Arduino_Core_STM32/wiki/Customize-build-options-using-build_opt.h -[virtio_log.h]: /cores/arduino/stm32/OpenAMP/virtio_log.h +[virtio_log.h]: /libraries/VirtIO/inc/virtio_log.h [`variant_STM32MP157_DK.h` of the board]: /variants/STM32MP1xx/MP153AAC_MP153CAC_MP153DAC_MP153FAC_MP157AAC_MP157CAC_MP157DAC_MP157FAC/variant_STM32MP157_DK.h From 66b29ba9729afa5e8eb65e90114465c2ba425b99 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Tue, 18 Jun 2024 16:54:16 +0200 Subject: [PATCH 3/3] refactor(USBDevice): move USB device support as a built-in library It could propbaly be splitted in 3 libraries: - USBDevice: base support - USBDCDC - USBDHID Signed-off-by: Frederic Pillon --- License.md | 4 +- cmake/set_base_arduino_config.cmake | 4 +- cmake/templates/easy_cmake.cmake | 1 + cores/arduino/CMakeLists.txt | 13 ------ cores/arduino/WSerial.h | 4 +- libraries/CMakeLists.txt | 1 + libraries/SrcWrapper/src/stm32/hw_config.c | 4 +- libraries/USBDevice/CMakeLists.txt | 42 ++++++++++++++++++ .../examples/BareMinimum/BareMinimum.ino | 9 ++++ .../USBDevice/inc}/USBSerial.h | 0 .../USBDevice/inc}/cdc_queue.h | 0 .../USBDevice/inc}/usbd_cdc.h | 0 .../USBDevice/inc}/usbd_cdc_if.h | 0 .../USBDevice/inc}/usbd_conf.h | 0 .../USBDevice/inc}/usbd_desc.h | 0 .../USBDevice/inc}/usbd_ep_conf.h | 0 .../USBDevice/inc}/usbd_hid_composite_if.h | 0 .../usb => libraries/USBDevice/inc}/usbd_if.h | 0 libraries/USBDevice/keywords.txt | 44 +++++++++++++++++++ libraries/USBDevice/library.properties | 9 ++++ libraries/USBDevice/src/USBDevice.h | 4 ++ .../USBDevice/src}/USBSerial.cpp | 0 .../USBDevice/src}/cdc/cdc_queue.c | 0 .../USBDevice/src}/cdc/usbd_cdc.c | 0 .../USBDevice/src}/cdc/usbd_cdc_if.c | 0 .../USBDevice/src}/hid/usbd_hid_composite.c | 0 .../USBDevice/src}/hid/usbd_hid_composite.h | 0 .../src}/hid/usbd_hid_composite_if.c | 0 .../USBDevice/src}/usb_device_core.c | 0 .../USBDevice/src}/usb_device_ctlreq.c | 0 .../USBDevice/src}/usb_device_ioreq.c | 0 .../USBDevice/src}/usbd_conf.c | 0 .../USBDevice/src}/usbd_desc.c | 0 .../USBDevice/src}/usbd_ep_conf.c | 0 .../usb => libraries/USBDevice/src}/usbd_if.c | 0 platform.txt | 7 +-- system/extras/prebuild.sh | 7 ++- tools/platformio/platformio-build.py | 4 +- 38 files changed, 130 insertions(+), 27 deletions(-) create mode 100644 libraries/USBDevice/CMakeLists.txt create mode 100644 libraries/USBDevice/examples/BareMinimum/BareMinimum.ino rename {cores/arduino => libraries/USBDevice/inc}/USBSerial.h (100%) rename {cores/arduino/stm32/usb/cdc => libraries/USBDevice/inc}/cdc_queue.h (100%) rename {cores/arduino/stm32/usb/cdc => libraries/USBDevice/inc}/usbd_cdc.h (100%) rename {cores/arduino/stm32/usb/cdc => libraries/USBDevice/inc}/usbd_cdc_if.h (100%) rename {cores/arduino/stm32/usb => libraries/USBDevice/inc}/usbd_conf.h (100%) rename {cores/arduino/stm32/usb => libraries/USBDevice/inc}/usbd_desc.h (100%) rename {cores/arduino/stm32/usb => libraries/USBDevice/inc}/usbd_ep_conf.h (100%) rename {cores/arduino/stm32/usb/hid => libraries/USBDevice/inc}/usbd_hid_composite_if.h (100%) rename {cores/arduino/stm32/usb => libraries/USBDevice/inc}/usbd_if.h (100%) create mode 100644 libraries/USBDevice/keywords.txt create mode 100644 libraries/USBDevice/library.properties create mode 100644 libraries/USBDevice/src/USBDevice.h rename {cores/arduino => libraries/USBDevice/src}/USBSerial.cpp (100%) rename {cores/arduino/stm32/usb => libraries/USBDevice/src}/cdc/cdc_queue.c (100%) rename {cores/arduino/stm32/usb => libraries/USBDevice/src}/cdc/usbd_cdc.c (100%) rename {cores/arduino/stm32/usb => libraries/USBDevice/src}/cdc/usbd_cdc_if.c (100%) rename {cores/arduino/stm32/usb => libraries/USBDevice/src}/hid/usbd_hid_composite.c (100%) rename {cores/arduino/stm32/usb => libraries/USBDevice/src}/hid/usbd_hid_composite.h (100%) rename {cores/arduino/stm32/usb => libraries/USBDevice/src}/hid/usbd_hid_composite_if.c (100%) rename {cores/arduino/stm32/usb => libraries/USBDevice/src}/usb_device_core.c (100%) rename {cores/arduino/stm32/usb => libraries/USBDevice/src}/usb_device_ctlreq.c (100%) rename {cores/arduino/stm32/usb => libraries/USBDevice/src}/usb_device_ioreq.c (100%) rename {cores/arduino/stm32/usb => libraries/USBDevice/src}/usbd_conf.c (100%) rename {cores/arduino/stm32/usb => libraries/USBDevice/src}/usbd_desc.c (100%) rename {cores/arduino/stm32/usb => libraries/USBDevice/src}/usbd_ep_conf.c (100%) rename {cores/arduino/stm32/usb => libraries/USBDevice/src}/usbd_if.c (100%) diff --git a/License.md b/License.md index 4205a386c4..16854d69c8 100644 --- a/License.md +++ b/License.md @@ -9,14 +9,14 @@ Note: most license information is available on top of each source file [BSD 3-Clause License](#bsd-3-clause-license) is used for: -* cores/arduino/stm32/ mainly contains source from STMicroelectronics. * system/Drivers/STM32*xx_HAL_Driver folders include the STMicroelectronics HAL Drivers * system/Middlewares/OpenAMP * libraries/VirtIO - except virtio implementation (see [MIT License](#mit-license)) * libraries/SrcWrapper/inc/PinName*.h [Ultimate Liberty License](#Ultimate-Liberty-License) is used for: -* system/Middlewares/STM32_USB_*_Library/ folders +* system/Middlewares/STM32_USB_*_Library folders +* libraries/USBDevice (see header) [Apache License](#apache-license) is used for: * system/Drivers/CMSIS folder includes the STMicroelectronics CMSIS device diff --git a/cmake/set_base_arduino_config.cmake b/cmake/set_base_arduino_config.cmake index d678bebb27..39e1ca3fcc 100644 --- a/cmake/set_base_arduino_config.cmake +++ b/cmake/set_base_arduino_config.cmake @@ -55,11 +55,9 @@ target_include_directories(base_config INTERFACE "${BUILD_CORE_PATH}" "${BUILD_CORE_PATH}/avr" "${BUILD_CORE_PATH}/stm32" - "${BUILD_CORE_PATH}/stm32/usb" - "${BUILD_CORE_PATH}/stm32/usb/hid" - "${BUILD_CORE_PATH}/stm32/usb/cdc" "${BUILD_LIB_PATH}/SrcWrapper/inc" "${BUILD_LIB_PATH}/SrcWrapper/inc/LL" + "${BUILD_LIB_PATH}/USBDevice/inc" "${BUILD_LIB_PATH}/VirtIO/inc" "${BUILD_SYSTEM_PATH}/Middlewares/ST/STM32_USB_Device_Library/Core/Inc" "${BUILD_SYSTEM_PATH}/Middlewares/ST/STM32_USB_Device_Library/Core/Src" diff --git a/cmake/templates/easy_cmake.cmake b/cmake/templates/easy_cmake.cmake index 66f5d89be6..d894c3da03 100644 --- a/cmake/templates/easy_cmake.cmake +++ b/cmake/templates/easy_cmake.cmake @@ -91,6 +91,7 @@ build_sketch(TARGET "{{tgtname or "@binary_name_here@"}}" # SD # Wire # SPI + # USBDevice # VirtIO ) diff --git a/cores/arduino/CMakeLists.txt b/cores/arduino/CMakeLists.txt index ded62991cc..3577e9d518 100644 --- a/cores/arduino/CMakeLists.txt +++ b/cores/arduino/CMakeLists.txt @@ -32,21 +32,8 @@ add_library(core_bin STATIC EXCLUDE_FROM_ALL Print.cpp RingBuffer.cpp stm32/startup_stm32yyxx.S - stm32/usb/cdc/cdc_queue.c - stm32/usb/cdc/usbd_cdc.c - stm32/usb/cdc/usbd_cdc_if.c - stm32/usb/hid/usbd_hid_composite.c - stm32/usb/hid/usbd_hid_composite_if.c - stm32/usb/usb_device_core.c - stm32/usb/usb_device_ctlreq.c - stm32/usb/usb_device_ioreq.c - stm32/usb/usbd_conf.c - stm32/usb/usbd_desc.c - stm32/usb/usbd_ep_conf.c - stm32/usb/usbd_if.c Stream.cpp Tone.cpp - USBSerial.cpp WInterrupts.cpp wiring_analog.c wiring_digital.c diff --git a/cores/arduino/WSerial.h b/cores/arduino/WSerial.h index 4214fe6e1e..44aed84409 100644 --- a/cores/arduino/WSerial.h +++ b/cores/arduino/WSerial.h @@ -3,7 +3,9 @@ #include "variant.h" #include "HardwareSerial.h" -#include "USBSerial.h" +#if defined (USBCON) && defined(USBD_USE_CDC) + #include "USBSerial.h" +#endif /* USBCON && USBD_USE_CDC */ #if defined(VIRTIOCON) #include "VirtIOSerial.h" #endif /* VIRTIOCON */ diff --git a/libraries/CMakeLists.txt b/libraries/CMakeLists.txt index f6d31df11a..ff0a3b0557 100644 --- a/libraries/CMakeLists.txt +++ b/libraries/CMakeLists.txt @@ -10,5 +10,6 @@ add_subdirectory(SPI) add_subdirectory(Servo) add_subdirectory(SoftwareSerial) add_subdirectory(SrcWrapper) +add_subdirectory(USBDevice) add_subdirectory(VirtIO) add_subdirectory(Wire) diff --git a/libraries/SrcWrapper/src/stm32/hw_config.c b/libraries/SrcWrapper/src/stm32/hw_config.c index 7a6d98a721..efdb1dcb5a 100644 --- a/libraries/SrcWrapper/src/stm32/hw_config.c +++ b/libraries/SrcWrapper/src/stm32/hw_config.c @@ -13,7 +13,9 @@ #include "dwt.h" #include "hw_config.h" #include "clock.h" -#include "usbd_if.h" +#if defined (USBCON) && defined(USBD_USE_CDC) + #include "usbd_if.h" +#endif #ifdef __cplusplus extern "C" { diff --git a/libraries/USBDevice/CMakeLists.txt b/libraries/USBDevice/CMakeLists.txt new file mode 100644 index 0000000000..cdf27f3bec --- /dev/null +++ b/libraries/USBDevice/CMakeLists.txt @@ -0,0 +1,42 @@ +# v3.21 implemented semantic changes regarding $ +# See https://cmake.org/cmake/help/v3.21/command/target_link_libraries.html#linking-object-libraries-via-target-objects +cmake_minimum_required(VERSION 3.21) + +add_library(USBDevice INTERFACE) +add_library(USBDevice_usage INTERFACE) + +target_include_directories(USBDevice_usage INTERFACE + src +) + + +target_link_libraries(USBDevice_usage INTERFACE + base_config +) + +target_link_libraries(USBDevice INTERFACE USBDevice_usage) + + + +add_library(USBDevice_bin OBJECT EXCLUDE_FROM_ALL + src/cdc/cdc_queue.c + src/cdc/usbd_cdc.c + src/cdc/usbd_cdc_if.c + src/hid/usbd_hid_composite.c + src/hid/usbd_hid_composite_if.c + src/usb_device_core.c + src/usb_device_ctlreq.c + src/usb_device_ioreq.c + src/usbd_conf.c + src/usbd_desc.c + src/usbd_ep_conf.c + src/usbd_if.c + src/USBSerial.cpp +) +target_link_libraries(USBDevice_bin PUBLIC USBDevice_usage) + +target_link_libraries(USBDevice INTERFACE + USBDevice_bin + $ +) + diff --git a/libraries/USBDevice/examples/BareMinimum/BareMinimum.ino b/libraries/USBDevice/examples/BareMinimum/BareMinimum.ino new file mode 100644 index 0000000000..95c2b6eb0a --- /dev/null +++ b/libraries/USBDevice/examples/BareMinimum/BareMinimum.ino @@ -0,0 +1,9 @@ +void setup() { + // put your setup code here, to run once: + +} + +void loop() { + // put your main code here, to run repeatedly: + +} diff --git a/cores/arduino/USBSerial.h b/libraries/USBDevice/inc/USBSerial.h similarity index 100% rename from cores/arduino/USBSerial.h rename to libraries/USBDevice/inc/USBSerial.h diff --git a/cores/arduino/stm32/usb/cdc/cdc_queue.h b/libraries/USBDevice/inc/cdc_queue.h similarity index 100% rename from cores/arduino/stm32/usb/cdc/cdc_queue.h rename to libraries/USBDevice/inc/cdc_queue.h diff --git a/cores/arduino/stm32/usb/cdc/usbd_cdc.h b/libraries/USBDevice/inc/usbd_cdc.h similarity index 100% rename from cores/arduino/stm32/usb/cdc/usbd_cdc.h rename to libraries/USBDevice/inc/usbd_cdc.h diff --git a/cores/arduino/stm32/usb/cdc/usbd_cdc_if.h b/libraries/USBDevice/inc/usbd_cdc_if.h similarity index 100% rename from cores/arduino/stm32/usb/cdc/usbd_cdc_if.h rename to libraries/USBDevice/inc/usbd_cdc_if.h diff --git a/cores/arduino/stm32/usb/usbd_conf.h b/libraries/USBDevice/inc/usbd_conf.h similarity index 100% rename from cores/arduino/stm32/usb/usbd_conf.h rename to libraries/USBDevice/inc/usbd_conf.h diff --git a/cores/arduino/stm32/usb/usbd_desc.h b/libraries/USBDevice/inc/usbd_desc.h similarity index 100% rename from cores/arduino/stm32/usb/usbd_desc.h rename to libraries/USBDevice/inc/usbd_desc.h diff --git a/cores/arduino/stm32/usb/usbd_ep_conf.h b/libraries/USBDevice/inc/usbd_ep_conf.h similarity index 100% rename from cores/arduino/stm32/usb/usbd_ep_conf.h rename to libraries/USBDevice/inc/usbd_ep_conf.h diff --git a/cores/arduino/stm32/usb/hid/usbd_hid_composite_if.h b/libraries/USBDevice/inc/usbd_hid_composite_if.h similarity index 100% rename from cores/arduino/stm32/usb/hid/usbd_hid_composite_if.h rename to libraries/USBDevice/inc/usbd_hid_composite_if.h diff --git a/cores/arduino/stm32/usb/usbd_if.h b/libraries/USBDevice/inc/usbd_if.h similarity index 100% rename from cores/arduino/stm32/usb/usbd_if.h rename to libraries/USBDevice/inc/usbd_if.h diff --git a/libraries/USBDevice/keywords.txt b/libraries/USBDevice/keywords.txt new file mode 100644 index 0000000000..ac76e14c8c --- /dev/null +++ b/libraries/USBDevice/keywords.txt @@ -0,0 +1,44 @@ +####################################### +# Syntax Coloring Map For USBDevice +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### +USBSerial KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### +SerialUSB KEYWORD2 +begin KEYWORD2 +available KEYWORD2 +availableForWrite KEYWORD2 +peek KEYWORD2 +read KEYWORD2 +readBytes KEYWORD2 +readBytesUntil +write KEYWORD2 +flush KEYWORD2 +baud KEYWORD2 +stopbits KEYWORD2 +paritytype KEYWORD2 +numbits KEYWORD2 +dtr KEYWORD2 +dtr KEYWORD2 +rts KEYWORD2 + +####################################### +# Constants (LITERAL1) +####################################### +USBD_VID LITERAL1 +USBD_PID LITERAL1 +USBD_MANUFACTURER_STRING LITERAL1 +ONE_STOP_BIT LITERAL1 +ONE_AND_HALF_STOP_BIT LITERAL1 +TWO_STOP_BITS LITERAL1 +NO_PARITY LITERAL1 +ODD_PARITY LITERAL1 +EVEN_PARITY LITERAL1 +MARK_PARITY LITERAL1 +SPACE_PARITY LITERAL1 diff --git a/libraries/USBDevice/library.properties b/libraries/USBDevice/library.properties new file mode 100644 index 0000000000..a919fcfd0c --- /dev/null +++ b/libraries/USBDevice/library.properties @@ -0,0 +1,9 @@ +name=USBDevice +version=1.0.0 +author=Frederic Pillon +maintainer=stm32duino +sentence=Enables USB device support (CDC or HID). +paragraph= +category=Communication +url=https://github.com/stm32duino/Arduino_Core_STM32 +architectures=stm32 diff --git a/libraries/USBDevice/src/USBDevice.h b/libraries/USBDevice/src/USBDevice.h new file mode 100644 index 0000000000..4cc007d556 --- /dev/null +++ b/libraries/USBDevice/src/USBDevice.h @@ -0,0 +1,4 @@ +#ifndef __USBD_H__ +#define __USBD_H__ + +#endif /* __USBD_H__ */ diff --git a/cores/arduino/USBSerial.cpp b/libraries/USBDevice/src/USBSerial.cpp similarity index 100% rename from cores/arduino/USBSerial.cpp rename to libraries/USBDevice/src/USBSerial.cpp diff --git a/cores/arduino/stm32/usb/cdc/cdc_queue.c b/libraries/USBDevice/src/cdc/cdc_queue.c similarity index 100% rename from cores/arduino/stm32/usb/cdc/cdc_queue.c rename to libraries/USBDevice/src/cdc/cdc_queue.c diff --git a/cores/arduino/stm32/usb/cdc/usbd_cdc.c b/libraries/USBDevice/src/cdc/usbd_cdc.c similarity index 100% rename from cores/arduino/stm32/usb/cdc/usbd_cdc.c rename to libraries/USBDevice/src/cdc/usbd_cdc.c diff --git a/cores/arduino/stm32/usb/cdc/usbd_cdc_if.c b/libraries/USBDevice/src/cdc/usbd_cdc_if.c similarity index 100% rename from cores/arduino/stm32/usb/cdc/usbd_cdc_if.c rename to libraries/USBDevice/src/cdc/usbd_cdc_if.c diff --git a/cores/arduino/stm32/usb/hid/usbd_hid_composite.c b/libraries/USBDevice/src/hid/usbd_hid_composite.c similarity index 100% rename from cores/arduino/stm32/usb/hid/usbd_hid_composite.c rename to libraries/USBDevice/src/hid/usbd_hid_composite.c diff --git a/cores/arduino/stm32/usb/hid/usbd_hid_composite.h b/libraries/USBDevice/src/hid/usbd_hid_composite.h similarity index 100% rename from cores/arduino/stm32/usb/hid/usbd_hid_composite.h rename to libraries/USBDevice/src/hid/usbd_hid_composite.h diff --git a/cores/arduino/stm32/usb/hid/usbd_hid_composite_if.c b/libraries/USBDevice/src/hid/usbd_hid_composite_if.c similarity index 100% rename from cores/arduino/stm32/usb/hid/usbd_hid_composite_if.c rename to libraries/USBDevice/src/hid/usbd_hid_composite_if.c diff --git a/cores/arduino/stm32/usb/usb_device_core.c b/libraries/USBDevice/src/usb_device_core.c similarity index 100% rename from cores/arduino/stm32/usb/usb_device_core.c rename to libraries/USBDevice/src/usb_device_core.c diff --git a/cores/arduino/stm32/usb/usb_device_ctlreq.c b/libraries/USBDevice/src/usb_device_ctlreq.c similarity index 100% rename from cores/arduino/stm32/usb/usb_device_ctlreq.c rename to libraries/USBDevice/src/usb_device_ctlreq.c diff --git a/cores/arduino/stm32/usb/usb_device_ioreq.c b/libraries/USBDevice/src/usb_device_ioreq.c similarity index 100% rename from cores/arduino/stm32/usb/usb_device_ioreq.c rename to libraries/USBDevice/src/usb_device_ioreq.c diff --git a/cores/arduino/stm32/usb/usbd_conf.c b/libraries/USBDevice/src/usbd_conf.c similarity index 100% rename from cores/arduino/stm32/usb/usbd_conf.c rename to libraries/USBDevice/src/usbd_conf.c diff --git a/cores/arduino/stm32/usb/usbd_desc.c b/libraries/USBDevice/src/usbd_desc.c similarity index 100% rename from cores/arduino/stm32/usb/usbd_desc.c rename to libraries/USBDevice/src/usbd_desc.c diff --git a/cores/arduino/stm32/usb/usbd_ep_conf.c b/libraries/USBDevice/src/usbd_ep_conf.c similarity index 100% rename from cores/arduino/stm32/usb/usbd_ep_conf.c rename to libraries/USBDevice/src/usbd_ep_conf.c diff --git a/cores/arduino/stm32/usb/usbd_if.c b/libraries/USBDevice/src/usbd_if.c similarity index 100% rename from cores/arduino/stm32/usb/usbd_if.c rename to libraries/USBDevice/src/usbd_if.c diff --git a/platform.txt b/platform.txt index b449bc06a5..95da081a8d 100644 --- a/platform.txt +++ b/platform.txt @@ -24,17 +24,18 @@ tools_bin_path.macosx={runtime.tools.STM32Tools.path}/macosx tools_bin_path.linux={runtime.tools.STM32Tools.path}/linux core_stm32_dir={build.core.path}/stm32 -core_usb_dir={core_stm32_dir}/usb hal_dir={build.system.path}/Drivers/{build.series}_HAL_Driver cmsis_dir={runtime.tools.CMSIS-5.9.0.path}/CMSIS cmsis_dev_dir={build.system.path}/Drivers/CMSIS/Device/ST/{build.series} usbd_core_dir={build.system.path}/Middlewares/ST/STM32_USB_Device_Library/Core SrcWrapper_include_dir={runtime.platform.path}/libraries/SrcWrapper/inc VirtIO_include_dir={runtime.platform.path}/libraries/VirtIO/inc +USBDevice_include_dir={runtime.platform.path}/libraries/USBDevice/inc + # STM compile variables # ---------------------- -compiler.stm.extra_include="-I{build.source.path}" "-I{build.core.path}/avr" "-I{core_stm32_dir}" "-I{SrcWrapper_include_dir}" "-I{SrcWrapper_include_dir}/LL" "-I{core_usb_dir}" "-I{core_usb_dir}/hid" "-I{core_usb_dir}/cdc" "-I{hal_dir}/Inc" "-I{hal_dir}/Src" "-I{build.system.path}/{build.series}" "-I{usbd_core_dir}/Inc" "-I{usbd_core_dir}/Src" "-I{VirtIO_include_dir}" {build.virtio_extra_include} +compiler.stm.extra_include="-I{build.source.path}" "-I{build.core.path}/avr" "-I{core_stm32_dir}" "-I{SrcWrapper_include_dir}" "-I{SrcWrapper_include_dir}/LL" "-I{hal_dir}/Inc" "-I{hal_dir}/Src" "-I{build.system.path}/{build.series}" "-I{USBDevice_include_dir}" "-I{usbd_core_dir}/Inc" "-I{usbd_core_dir}/Src" "-I{VirtIO_include_dir}" {build.virtio_extra_include} compiler.arm.cmsis.c.flags="-I{cmsis_dir}/Core/Include/" "-I{cmsis_dev_dir}/Include/" "-I{cmsis_dev_dir}/Source/Templates/gcc/" "-I{cmsis_dir}/DSP/Include" "-I{cmsis_dir}/DSP/PrivateInclude" compiler.warning_flags=-w @@ -146,7 +147,7 @@ build.opt.path={build.path}/sketch/{build.opt.name} extras.path={build.system.path}/extras # Create {build.opt} if not exists in the output sketch dir and force include of SrcWrapper library -recipe.hooks.prebuild.1.pattern="{busybox}" sh "{extras.path}/prebuild.sh" "{build.path}" "{build.source.path}" "{runtime.platform.path}" "{build.enable_virtio}" +recipe.hooks.prebuild.1.pattern="{busybox}" sh "{extras.path}/prebuild.sh" "{build.path}" "{build.source.path}" "{runtime.platform.path}" "usb={build.enable_usb}" "virtio={build.enable_virtio}" recipe.hooks.postbuild.1.pattern="{busybox}" sh "{extras.path}/postbuild.sh" "{build.path}" "{build.series}" "{runtime.platform.path}" # compile patterns diff --git a/system/extras/prebuild.sh b/system/extras/prebuild.sh index c4f2ce01c6..95faf81ce2 100755 --- a/system/extras/prebuild.sh +++ b/system/extras/prebuild.sh @@ -3,7 +3,8 @@ BUILD_PATH="$1" BUILD_SOURCE_PATH="$2" BOARD_PLATFORM_PATH="$3" -BUILD_VIRTIO="$4" +BUILD_USB="$4" +BUILD_VIRTIO="$5" # Create sketch dir if not exists if [ ! -f "$BUILD_PATH/sketch" ]; then @@ -45,6 +46,10 @@ printf '\n-fmacro-prefix-map="%s"=.' "${prefix}" >>"$BUILD_PATH/sketch/build.opt # Force include of SrcWrapper library echo "#include " >"$BUILD_PATH/sketch/requiredLibraries.cpp" +# Force include of USBDevice library if required +if [ -n "${BUILD_USB#*=}" ]; then + echo "#include " >>"$BUILD_PATH/sketch/requiredLibraries.cpp" +fi # Force include of VirtIO library if required if [ -n "${BUILD_VIRTIO#*=}" ]; then echo "#include " >>"$BUILD_PATH/sketch/requiredLibraries.cpp" diff --git a/tools/platformio/platformio-build.py b/tools/platformio/platformio-build.py index 6a154a826f..9d347ef818 100644 --- a/tools/platformio/platformio-build.py +++ b/tools/platformio/platformio-build.py @@ -258,11 +258,9 @@ def get_arduino_board_id(board_config, mcu): CPPPATH=[ join(FRAMEWORK_DIR, "cores", "arduino", "avr"), join(FRAMEWORK_DIR, "cores", "arduino", "stm32"), - join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "usb"), - join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "usb", "hid"), - join(FRAMEWORK_DIR, "cores", "arduino", "stm32", "usb", "cdc"), join(FRAMEWORK_DIR, "libraries", "SrcWrapper", "inc"), join(FRAMEWORK_DIR, "libraries", "SrcWrapper", "inc", "LL"), + join(FRAMEWORK_DIR, "libraries", "USBDevice", "inc"), join(FRAMEWORK_DIR, "libraries", "VirtIO", "inc"), join(FRAMEWORK_DIR, "system", "Drivers", series + "_HAL_Driver", "Inc"), join(FRAMEWORK_DIR, "system", "Drivers", series + "_HAL_Driver", "Src"),