SConscript 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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_stm32f3xx.c')]
  10. # Map microcontroller units (MCUs) to their corresponding startup files
  11. mcu_startup_files = {
  12. 'STM32F301x8': 'startup_stm32f301x8.s',
  13. 'STM32F302x8': 'startup_stm32f302x8.s',
  14. 'STM32F302xC': 'startup_stm32f302xc.s',
  15. 'STM32F302xE': 'startup_stm32f302xe.s',
  16. 'STM32F303x8': 'startup_stm32f303x8.s',
  17. 'STM32F303xC': 'startup_stm32f303xc.s',
  18. 'STM32F303xE': 'startup_stm32f303xe.s',
  19. 'STM32F318xx': 'startup_stm32f318xx.s',
  20. 'STM32F328xx': 'startup_stm32f328xx.s',
  21. 'STM32F334x8': 'startup_stm32f334x8.s',
  22. 'STM32F358xx': 'startup_stm32f358xx.s',
  23. 'STM32F373xC': 'startup_stm32f373xc.s',
  24. 'STM32F378xx': 'startup_stm32f378xx.s',
  25. 'STM32F398xx': 'startup_stm32f398xx.s',
  26. }
  27. # Check each defined MCU, match the platform and append the appropriate startup file
  28. for mcu, startup_file in mcu_startup_files.items():
  29. if mcu in env.get('CPPDEFINES', []):
  30. if rtconfig.PLATFORM in ['gcc', 'llvm-arm']:
  31. src += [os.path.join(cwd, 'Source', 'Templates', 'gcc', startup_file)]
  32. elif rtconfig.PLATFORM in ['armcc', 'armclang']:
  33. src += [os.path.join(cwd, 'Source', 'Templates', 'arm', startup_file)]
  34. elif rtconfig.PLATFORM in ['iccarm']:
  35. src += [os.path.join(cwd, 'Source', 'Templates', 'iar', startup_file)]
  36. break
  37. # Define the build group
  38. group = DefineGroup('STM32F3-CMSIS', src, depend=['PKG_USING_STM32F3_CMSIS_DRIVER'], CPPPATH=path)
  39. # Return the build group
  40. Return('group')