From 045add2539ac000f41341ee93e37fab0ce190174 Mon Sep 17 00:00:00 2001 From: Joseph Morrow Date: Thu, 2 Apr 2015 13:48:02 -0400 Subject: [PATCH] Allow upload to an Arduino Due device from root of repo scons build. Support to upload to an Arduino Due device was only added to the internal CA Layer scons build. This commit mitigates this issue. Change-Id: I7ffe3d38976b9de12fa987235d0ed1fe5305b6aa Signed-off-by: Joseph Morrow Reviewed-on: https://gerrit.iotivity.org/gerrit/615 Tested-by: jenkins-iotivity Reviewed-by: Jon A. Cruz Reviewed-by: Erich Keane --- build_common/arduino/SConscript | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/build_common/arduino/SConscript b/build_common/arduino/SConscript index 756a9b4..6237df7 100644 --- a/build_common/arduino/SConscript +++ b/build_common/arduino/SConscript @@ -153,7 +153,7 @@ def __create_bin(env, source): else: hex = env.Command(name + '.hex', source, 'arm-none-eabi-objcopy -O binary $SOURCE $TARGET') -#Currently supporting only megaADK build +#Currently supporting only mega (ie. Arduino ATMega2560) and arduino_due_x/arduino_due_x_dbg (i.e. Arduino Due) builds def __upload(env, binary): if target_arch == 'avr': protocol = __get_board_info(board, '.upload.protocol') @@ -161,10 +161,16 @@ def __upload(env, binary): port = '/dev/ttyACM0' upload_cmd = arduino_home + '/hardware/tools/avr/bin/avrdude -C' + arduino_home +'/hardware/tools/avr/etc/avrdude.conf -p' \ + mcu + ' -c' + protocol + ' -P' + port + ' -b' + speed + ' -D -Uflash:w:' + binary + ':i' - print "Upload command: %s" %upload_cmd install_cmd = env.Command('install_cmd', None, upload_cmd) env.Default('install_cmd') + elif target_arch == 'arm': + protocol = __get_board_info(board, '.upload.protocol') + speed = __get_board_info(board, '.upload.speed') + port = 'ttyACM0' + uu = __get_board_info(board, '.upload.native_usb') + os.system('stty -F /dev/' + port + ' speed 1200 cs8 -cstopb -parenb') + os.system(arduino_home + '/hardware/tools/bossac -i --port=' + port + ' -U false -e -w -b ' + binary + ' -R') # Print the command line that to upload binary to the board def __upload_help(env): @@ -351,11 +357,13 @@ else: else: cpu_flag = '-mcpu=' + mcu - comm_flag = [cpu_flag, '-DF_CPU=' + f_cpu, '-DARDUINO=' + version, '-DARDUINO_' + __get_board_info(board, '.build.board'), '-std=gnu99'] + comm_flag = [cpu_flag, '-DF_CPU=' + f_cpu, '-DARDUINO=' + version, '-DARDUINO_' + __get_board_info(board, '.build.board')] if target_arch == 'arm': - comm_flag.extend(['-DARDUINO_ARCH_SAM']) + # As of 1.5.8 the arduino headers for arm had _asm_ bugs with ARM and + # require gnu99 to be used + comm_flag.extend(['-std=gnu99', '-DARDUINO_ARCH_SAM']) else: - comm_flag.extend(['-DARDUINO_ARCH_AVR']) + comm_flag.extend(['-std=c99', '-DARDUINO_ARCH_AVR']) compiler_path = platform_info.get('compiler.path') compiler_path = compiler_path.replace('{runtime.ide.path}', arduino_home) -- 2.7.4