SConscript 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. from building import *
  2. import os
  3. # Import environment variables
  4. Import('env')
  5. # Get the current working directory
  6. cwd = GetCurrentDir()
  7. # Initialize include paths and source files list
  8. path = [os.path.join(cwd, 'Include')]
  9. src = [os.path.join(cwd, 'Source', 'Templates', 'system_stm32f4xx.c')]
  10. # Map microcontroller units (MCUs) to their corresponding startup files
  11. mcu_startup_files = {
  12. 'STM32F401xC': 'startup_stm32f401xc.s',
  13. 'STM32F401xE': 'startup_stm32f401xe.s',
  14. 'STM32F405xx': 'startup_stm32f405xx.s',
  15. 'STM32F407xx': 'startup_stm32f407xx.s',
  16. 'STM32F410Cx': 'startup_stm32f410cx.s',
  17. 'STM32F410Rx': 'startup_stm32f410rx.s',
  18. 'STM32F410Tx': 'startup_stm32f410tx.s',
  19. 'STM32F411xE': 'startup_stm32f411xe.s',
  20. 'STM32F412Cx': 'startup_stm32f412cx.s',
  21. 'STM32F412Rx': 'startup_stm32f412rx.s',
  22. 'STM32F412Vx': 'startup_stm32f412vx.s',
  23. 'STM32F412Zx': 'startup_stm32f412zx.s',
  24. 'STM32F413xx': 'startup_stm32f413xx.s',
  25. 'STM32F415xx': 'startup_stm32f415xx.s',
  26. 'STM32F417xx': 'startup_stm32f417xx.s',
  27. 'STM32F423xx': 'startup_stm32f423xx.s',
  28. 'STM32F427xx': 'startup_stm32f427xx.s',
  29. 'STM32F429xx': 'startup_stm32f429xx.s',
  30. 'STM32F437xx': 'startup_stm32f437xx.s',
  31. 'STM32F439xx': 'startup_stm32f439xx.s',
  32. 'STM32F446xx': 'startup_stm32f446xx.s',
  33. 'STM32F469xx': 'startup_stm32f469xx.s',
  34. 'STM32F479xx': 'startup_stm32f479xx.s',
  35. }
  36. # Check each defined MCU, match the platform and append the appropriate startup file
  37. cpp_defines_tuple = env.get('CPPDEFINES', [])
  38. cpp_defines_list = [item[0] if isinstance(item, tuple) else item for item in cpp_defines_tuple]
  39. for mcu, startup_file in mcu_startup_files.items():
  40. if mcu in cpp_defines_list:
  41. if rtconfig.PLATFORM in ['gcc', 'llvm-arm']:
  42. src += [os.path.join(cwd, 'Source', 'Templates', 'gcc', startup_file)]
  43. elif rtconfig.PLATFORM in ['armcc', 'armclang']:
  44. src += [os.path.join(cwd, 'Source', 'Templates', 'arm', startup_file)]
  45. elif rtconfig.PLATFORM in ['iccarm']:
  46. src += [os.path.join(cwd, 'Source', 'Templates', 'iar', startup_file)]
  47. break
  48. # Define the build group
  49. group = DefineGroup('STM32F4-CMSIS', src, depend=['PKG_USING_STM32F4_CMSIS_DRIVER'], CPPPATH=path)
  50. # Return the build group
  51. Return('group')