Skip to content

Disable HAL feature when not used in the sketch #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
13 tasks done
fpistm opened this issue Mar 16, 2018 · 7 comments
Closed
13 tasks done

Disable HAL feature when not used in the sketch #228

fpistm opened this issue Mar 16, 2018 · 7 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@fpistm
Copy link
Member

fpistm commented Mar 16, 2018

Goal of this issue is to be able to disable HAL module if not used in the sketch in order to reduce binary size.

  • I2C: done thanks 07dcdc4
  • SPI: done thanks c41d8af
  • ADC: done thanks e4b1121
  • DAC: done thanks 68d3450
  • TIM: done thanks b10696d
  • UART: done thanks 83d872f
  • ETH: done thanks 680e01b
  • SD: done thanks e0e90cc
  • QSPI: done thanks 4e25050
  • RTC: done thanks 0753358
  • USB: done thanks Arduino menu.
  • EXTI: done thanks 0e1f5a7. Interrupt API does not used HAL EXTI module anyway API is cleaned with HAL_EXTI_MODULE_DISABLED
  • RCC: mandatory. User can use LL to override SystemClock_Config()

Mainly useful for MCU with smallflash size (See #165)

Proposition:

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.

Implementation done thanks #518

  • Extra HAL module can be enabled/disabled in variant.h if required or in a file named (at sketch level): hal_conf_extra.h

    • To enable a HAL modules use the standard HAL definition: HAL_PPP_MODULE_ENABLED with PPP the peripheral to enable.
    • To disable a HAL modules use one or more following values:
      • HAL_ADC_MODULE_DISABLED
      • HAL_I2C_MODULE_DISABLED
      • HAL_RTC_MODULE_DISABLED
      • HAL_SPI_MODULE_DISABLED
      • HAL_DAC_MODULE_DISABLED
      • HAL_ETH_MODULE_DISABLED
      • HAL_SD_MODULE_DISABLED
      • HAL_QSPI_MODULE_DISABLED
      • HAL_EXTI_MODULE_DISABLED
      • HAL_TIM_MODULE_DISABLED
        Note: HAL_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 .

@fpistm fpistm added the enhancement New feature or request label Mar 16, 2018
@aster94
Copy link

aster94 commented Apr 7, 2018

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

@fpistm
Copy link
Member Author

fpistm commented Apr 9, 2018

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.

@fpistm
Copy link
Member Author

fpistm commented Jun 15, 2018

Serial can now be enabled or not:
83d872f

This allow to build without HAL_UART_MODULE_ENABLED (save memory)
HAL_UART_MODULE_ENABLED should not be defined in stm32yyxx_hal_conf.h

@tve
Copy link

tve commented Aug 5, 2018

Shouldn't RCC also be on the list here, e.g., following the comment #165 (comment) ("I've generate the code with CubeMx to use LL instead of HAL for RCC") ?

@fpistm
Copy link
Member Author

fpistm commented Aug 6, 2018

This could.

@Adminius
Copy link
Contributor

Adminius commented Nov 2, 2018

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?

@fpistm
Copy link
Member Author

fpistm commented Nov 2, 2018

Hi @Adminius,
probably yes, I have to find a nice and easiest way to do this.

@fpistm fpistm self-assigned this May 7, 2019
@fpistm fpistm added the on going Currently work on this label May 7, 2019
@fpistm fpistm added this to the 1.6.0 milestone May 7, 2019
@fpistm fpistm removed the on going Currently work on this label May 15, 2019
@fpistm fpistm closed this as completed May 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants