| 
									
										
										
										
											2015-02-18 20:11:52 +02:00
										 |  |  | # Copyright (C) Ivan Kravets <me@ikravets.com> | 
					
						
							|  |  |  | # See LICENSE for details. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | """
 | 
					
						
							|  |  |  |     Base for Atmel AVR series of microcontrollers | 
					
						
							|  |  |  | """
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-23 21:02:40 +02:00
										 |  |  | from SCons.Script import Builder, DefaultEnvironment | 
					
						
							| 
									
										
										
										
											2015-02-18 20:11:52 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-23 21:02:40 +02:00
										 |  |  | env = DefaultEnvironment() | 
					
						
							| 
									
										
										
										
											2015-02-18 20:11:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | env.Replace( | 
					
						
							|  |  |  |     AR="avr-ar", | 
					
						
							|  |  |  |     AS="avr-gcc", | 
					
						
							|  |  |  |     CC="avr-gcc", | 
					
						
							|  |  |  |     CXX="avr-g++", | 
					
						
							|  |  |  |     OBJCOPY="avr-objcopy", | 
					
						
							|  |  |  |     RANLIB="avr-ranlib", | 
					
						
							|  |  |  |     SIZETOOL="avr-size", | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-23 22:36:57 +02:00
										 |  |  |     ASCOM=("$AS -o $TARGET -c -x assembler-with-cpp " | 
					
						
							|  |  |  |            "$CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES"), | 
					
						
							| 
									
										
										
										
											2015-02-18 20:11:52 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-02-23 22:36:57 +02:00
										 |  |  |     ARFLAGS=["rcs"], | 
					
						
							| 
									
										
										
										
											2015-02-18 20:11:52 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     CCFLAGS=[ | 
					
						
							|  |  |  |         "-g",  # include debugging info (so errors include line numbers) | 
					
						
							|  |  |  |         "-Os",  # optimize for size | 
					
						
							|  |  |  |         "-Wall",  # show warnings | 
					
						
							|  |  |  |         "-ffunction-sections",  # place each function in its own section | 
					
						
							|  |  |  |         "-fdata-sections", | 
					
						
							|  |  |  |         "-MMD",  # output dependency info | 
					
						
							|  |  |  |         "-mmcu=$BOARD_MCU" | 
					
						
							|  |  |  |     ], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     CXXFLAGS=[ | 
					
						
							|  |  |  |         "-fno-exceptions", | 
					
						
							|  |  |  |         "-fno-threadsafe-statics" | 
					
						
							|  |  |  |     ], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     CPPDEFINES=[ | 
					
						
							|  |  |  |         "F_CPU=$BOARD_F_CPU" | 
					
						
							|  |  |  |     ], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     LINKFLAGS=[ | 
					
						
							|  |  |  |         "-Os", | 
					
						
							|  |  |  |         "-mmcu=$BOARD_MCU", | 
					
						
							|  |  |  |         "-Wl,--gc-sections" | 
					
						
							|  |  |  |     ], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     SIZEPRINTCMD='"$SIZETOOL" --mcu=$BOARD_MCU -C -d $SOURCES' | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if "UPLOAD_SPEED" in env: | 
					
						
							|  |  |  |     env.Append(UPLOADERFLAGS=["-b", "$UPLOAD_SPEED"]) | 
					
						
							|  |  |  | if env.subst("$UPLOAD_PROTOCOL") != "usbtiny": | 
					
						
							|  |  |  |     env.Append(UPLOADERFLAGS=["-P", "$UPLOAD_PORT"]) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | env.Append( | 
					
						
							|  |  |  |     BUILDERS=dict( | 
					
						
							|  |  |  |         ElfToEep=Builder( | 
					
						
							|  |  |  |             action=" ".join([ | 
					
						
							|  |  |  |                 "$OBJCOPY", | 
					
						
							|  |  |  |                 "-O", | 
					
						
							|  |  |  |                 "ihex", | 
					
						
							|  |  |  |                 "-j", | 
					
						
							|  |  |  |                 ".eeprom", | 
					
						
							|  |  |  |                 '--set-section-flags=.eeprom="alloc,load"', | 
					
						
							|  |  |  |                 "--no-change-warnings", | 
					
						
							|  |  |  |                 "--change-section-lma", | 
					
						
							|  |  |  |                 ".eeprom=0", | 
					
						
							|  |  |  |                 "$SOURCES", | 
					
						
							|  |  |  |                 "$TARGET"]), | 
					
						
							|  |  |  |             suffix=".eep" | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ElfToHex=Builder( | 
					
						
							|  |  |  |             action=" ".join([ | 
					
						
							|  |  |  |                 "$OBJCOPY", | 
					
						
							|  |  |  |                 "-O", | 
					
						
							|  |  |  |                 "ihex", | 
					
						
							|  |  |  |                 "-R", | 
					
						
							|  |  |  |                 ".eeprom", | 
					
						
							|  |  |  |                 "$SOURCES", | 
					
						
							|  |  |  |                 "$TARGET"]), | 
					
						
							|  |  |  |             suffix=".hex" | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |     ) | 
					
						
							|  |  |  | ) |