SConscript 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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_stm32l4xx.c')]
  10. # Map microcontroller units (MCUs) to their corresponding startup files
  11. mcu_startup_files = {
  12. 'STM32L412xx': 'startup_stm32l412xx.s',
  13. 'STM32L422xx': 'startup_stm32l422xx.s',
  14. 'STM32L431xx': 'startup_stm32l431xx.s',
  15. 'STM32L432xx': 'startup_stm32l432xx.s',
  16. 'STM32L433xx': 'startup_stm32l433xx.s',
  17. 'STM32L442xx': 'startup_stm32l442xx.s',
  18. 'STM32L443xx': 'startup_stm32l443xx.s',
  19. 'STM32L451xx': 'startup_stm32l451xx.s',
  20. 'STM32L452xx': 'startup_stm32l452xx.s',
  21. 'STM32L462xx': 'startup_stm32l462xx.s',
  22. 'STM32L471xx': 'startup_stm32l471xx.s',
  23. 'STM32L475xx': 'startup_stm32l475xx.s',
  24. 'STM32L476xx': 'startup_stm32l476xx.s',
  25. 'STM32L485xx': 'startup_stm32l485xx.s',
  26. 'STM32L486xx': 'startup_stm32l486xx.s',
  27. 'STM32L496xx': 'startup_stm32l496xx.s',
  28. 'STM32L4A6xx': 'startup_stm32l4a6xx.s',
  29. 'STM32L4P5xx': 'startup_stm32l4p5xx.s',
  30. 'STM32L4Q5xx': 'startup_stm32l4q5xx.s',
  31. 'STM32L4R5xx': 'startup_stm32l4r5xx.s',
  32. 'STM32L4R7xx': 'startup_stm32l4r7xx.s',
  33. 'STM32L4R9xx': 'startup_stm32l4r9xx.s',
  34. 'STM32L4S5xx': 'startup_stm32l4s5xx.s',
  35. 'STM32L4S7xx': 'startup_stm32l4s7xx.s',
  36. 'STM32L4S9xx': 'startup_stm32l4s9xx.s',
  37. }
  38. # Check each defined MCU, match the platform and append the appropriate startup file
  39. cpp_defines_tuple = env.get('CPPDEFINES', [])
  40. cpp_defines_list = [item[0] if isinstance(item, tuple) else item for item in cpp_defines_tuple]
  41. for mcu, startup_file in mcu_startup_files.items():
  42. if mcu in cpp_defines_list:
  43. if rtconfig.PLATFORM in ['gcc', 'llvm-arm']:
  44. src += [os.path.join(cwd, 'Source', 'Templates', 'gcc', startup_file)]
  45. elif rtconfig.PLATFORM in ['armcc', 'armclang']:
  46. src += [os.path.join(cwd, 'Source', 'Templates', 'arm', startup_file)]
  47. elif rtconfig.PLATFORM in ['iccarm']:
  48. src += [os.path.join(cwd, 'Source', 'Templates', 'iar', startup_file)]
  49. break
  50. # Define the build group
  51. group = DefineGroup('STM32L4-CMSIS', src, depend=['PKG_USING_STM32L4_CMSIS_DRIVER'], CPPPATH=path)
  52. # Return the build group
  53. Return('group')