Goal of this issue is to be able to disable HAL module if not used in the sketch in order to reduce binary size.
HAL_EXTI_MODULE_DISABLEDSystemClock_Config()Mainly useful for MCU with smallflash size (See #165)
handle a default HAL conf file which could be override by end user at sketch level or variant.
~PeripheralPins arrays could also use new switch to force an array to be disable even if the HAL module is enabled.~
Extra HAL module can be enabled/disabled in variant.h if required or in a file named (at sketch level): hal_conf_extra.h
HAL_PPP_MODULE_ENABLED with PPP the peripheral to enable.HAL_ADC_MODULE_DISABLEDHAL_I2C_MODULE_DISABLEDHAL_RTC_MODULE_DISABLEDHAL_SPI_MODULE_DISABLEDHAL_DAC_MODULE_DISABLEDHAL_ETH_MODULE_DISABLEDHAL_SD_MODULE_DISABLEDHAL_QSPI_MODULE_DISABLEDHAL_EXTI_MODULE_DISABLEDHAL_TIM_MODULE_DISABLEDHAL_UART_MODULE_ENABLED and HAL_PCD_MODULE_ENABLED are handled thanks Arduino menu.Custom HAL configuration file can replace the default one by adding a file named (at sketch level):
hal_conf_custom.h .
With "small flash size" do you consider also the blue pill and similar 48pins f1 boards?
As you know it should be 64kb, even if we use it as a 128kb i think that a smaller bin would be safer
This will be available for all variants. It's a core feature not specific to a variant.
Anyway, depending of the feature used, the HAL part is not embed if not used.
Example for SPI or I2C if SPI.h or Wire.h is not include, the HAL part is removed by the compiler as it is not used. Only the pinmap array is kept but it should be removed if not used to save some space.
Serial can now be enabled or not:
https://github.com/stm32duino/Arduino_Core_STM32/commit/83d872ff42c3d4988ffed7295199b22a453c9362
This allow to build without HAL_UART_MODULE_ENABLED (save memory)
HAL_UART_MODULE_ENABLED should not be defined in stm32yyxx_hal_conf.h
Shouldn't RCC also be on the list here, e.g., following the comment https://github.com/stm32duino/Arduino_Core_STM32/issues/165#issuecomment-373646769 ("I've generate the code with CubeMx to use LL instead of HAL for RCC") ?
This could.
hi @fpistm ,
for this points:
ADC: be able to build without HAL_ADC_MODULE_ENABLED
DAC: it's already possible to build without HAL_DAC_MODULE_ENABLED, maybe a menu could be proposed to enable or not the feature...
PWM: be able to build without HAL_PWM_MODULE_ENABLED
we need menu and some ifdef "only", right?
Hi @Adminius,
probably yes, I have to find a nice and easiest way to do this.
Most helpful comment
This will be available for all variants. It's a core feature not specific to a variant.
Anyway, depending of the feature used, the HAL part is not embed if not used.
Example for SPI or I2C if SPI.h or Wire.h is not include, the HAL part is removed by the compiler as it is not used. Only the pinmap array is kept but it should be removed if not used to save some space.