forked from platformio/platformio-core
		
	
		
			
				
	
	
		
			98 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			98 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| # Copyright (C) Ivan Kravets <me@ikravets.com>
 | |
| # See LICENSE for details.
 | |
| 
 | |
| """
 | |
|     Base for ARM microcontrollers.
 | |
| """
 | |
| 
 | |
| from SCons.Script import Builder, DefaultEnvironment
 | |
| 
 | |
| env = DefaultEnvironment()
 | |
| 
 | |
| env.Replace(
 | |
|     AR="arm-none-eabi-ar",
 | |
|     AS="arm-none-eabi-as",
 | |
|     CC="arm-none-eabi-gcc",
 | |
|     CXX="arm-none-eabi-g++",
 | |
|     OBJCOPY="arm-none-eabi-objcopy",
 | |
|     RANLIB="arm-none-eabi-ranlib",
 | |
|     SIZETOOL="arm-none-eabi-size",
 | |
| 
 | |
|     ARFLAGS=["rcs"],
 | |
| 
 | |
|     ASPPFLAGS=["-x", "assembler-with-cpp"],
 | |
| 
 | |
|     CPPFLAGS=[
 | |
|         "-g",   # include debugging info (so errors include line numbers)
 | |
|         "-Os",  # optimize for size
 | |
|         "-ffunction-sections",  # place each function in its own section
 | |
|         "-fdata-sections",
 | |
|         "-Wall",
 | |
|         "-mthumb",
 | |
|         "-mcpu=${BOARD_OPTIONS['build']['cpu']}",
 | |
|         "-nostdlib",
 | |
|         "-MMD"  # output dependancy info
 | |
|     ],
 | |
| 
 | |
|     CXXFLAGS=[
 | |
|         "-fno-rtti",
 | |
|         "-fno-exceptions"
 | |
|     ],
 | |
| 
 | |
|     CPPDEFINES=[
 | |
|         "F_CPU=$BOARD_F_CPU"
 | |
|     ],
 | |
| 
 | |
|     LINKFLAGS=[
 | |
|         "-Os",
 | |
|         "-Wl,--gc-sections,--relax",
 | |
|         "-mthumb",
 | |
|         "-mcpu=${BOARD_OPTIONS['build']['cpu']}",
 | |
|         "--specs=nano.specs"
 | |
|     ],
 | |
| 
 | |
|     LIBS=["c", "gcc", "m"],
 | |
| 
 | |
|     SIZEPRINTCMD='"$SIZETOOL" -B -d $SOURCES'
 | |
| )
 | |
| 
 | |
| if env.get("BOARD_OPTIONS", {}).get("build", {}).get(
 | |
|         "cpu", "")[-2:] == "m4" and env.get("BOARD") != "frdm_k20d50m":
 | |
|     env.Append(
 | |
|         CPPFLAGS=[
 | |
|             "-mfloat-abi=hard",
 | |
|             "-mfpu=fpv4-sp-d16",
 | |
|             "-fsingle-precision-constant"
 | |
|         ],
 | |
|         LINKFLAGS=[
 | |
|             "-mfloat-abi=hard",
 | |
|             "-mfpu=fpv4-sp-d16",
 | |
|             "-fsingle-precision-constant"
 | |
|         ]
 | |
|     )
 | |
| 
 | |
| env.Append(
 | |
|     BUILDERS=dict(
 | |
|         ElfToBin=Builder(
 | |
|             action=" ".join([
 | |
|                 "$OBJCOPY",
 | |
|                 "-O",
 | |
|                 "binary",
 | |
|                 "$SOURCES",
 | |
|                 "$TARGET"]),
 | |
|             suffix=".bin"
 | |
|         ),
 | |
|         ElfToHex=Builder(
 | |
|             action=" ".join([
 | |
|                 "$OBJCOPY",
 | |
|                 "-O",
 | |
|                 "ihex",
 | |
|                 "-R",
 | |
|                 ".eeprom",
 | |
|                 "$SOURCES",
 | |
|                 "$TARGET"]),
 | |
|             suffix=".hex"
 | |
|         )
 | |
|     )
 | |
| )
 |