In Arduino 1.6.5, Teensyduino 1.25, I was able to add .S (assembly) files to my project, which worked very well.
With Arduino 1.6.9, Teensyduino 1.29, this functionality appears to have broken. I get link errors stating that the functions defined in the .S files are not found. The .S files are compiled, but the linker command line doesn't mention the corresponding .o files anymore.
Minimal testcase:
asm_test.ino
asm.s
Under 1.6.5:
Under 1.6.9:
The functional program will print out 42 once per second to the serial console.
I am using OS X 10.11 with a Teensy 3.2. The same computer and Teensy was used for both tests.
With Arduino 1.6.9, Teensyduino 1.29, this functionality appears to have broken. I get link errors stating that the functions defined in the .S files are not found. The .S files are compiled, but the linker command line doesn't mention the corresponding .o files anymore.
Minimal testcase:
asm_test.ino
Code:
extern "C" {
int asm_foo(void);
}
void setup() {
Serial.begin(115200);
}
void loop() {
Serial.println(asm_foo());
delay(1000);
}
asm.s
Code:
.syntax unified
.thumb
.thumb_func
.global asm_foo
asm_foo:
mov r0, 42
bx lr
Under 1.6.5:
Code:/Applications/Arduino.app/Contents/Java/hardware/tools/arm/bin/arm-none-eabi-gcc -c -O -g -Wall -ffunction-sections -fdata-sections -MMD -nostdlib -x assembler-with-cpp -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=125 -DARDUINO=10605 -DF_CPU=96000000 -DARDUINO_ARCH_AVR -DUSB_SERIAL -DLAYOUT_US_ENGLISH -I/Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3 /var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/build1028514802181735731.tmp/asm.S -o /var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/build1028514802181735731.tmp/asm.S.o /Applications/Arduino.app/Contents/Java/hardware/tools/arm/bin/arm-none-eabi-g++ -c -O -g -Wall -ffunction-sections -fdata-sections -MMD -nostdlib -fno-exceptions -felide-constructors -std=gnu++0x -fno-rtti -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=125 -DARDUINO=10605 -DF_CPU=96000000 -DARDUINO_ARCH_AVR -DUSB_SERIAL -DLAYOUT_US_ENGLISH -I/Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3 /var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/build1028514802181735731.tmp/asm_test.cpp -o /var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/build1028514802181735731.tmp/asm_test.cpp.o /Applications/Arduino.app/Contents/Java/hardware/tools/arm/bin/arm-none-eabi-gcc -c -O -g -Wall -ffunction-sections -fdata-sections -MMD -nostdlib -x assembler-with-cpp -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=125 -DARDUINO=10605 -DF_CPU=96000000 -DARDUINO_ARCH_AVR -DUSB_SERIAL -DLAYOUT_US_ENGLISH -I/Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3 /Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3/memcpy-armv7m.S -o /var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/build1028514802181735731.tmp/memcpy-armv7m.S.o [snip] /Applications/Arduino.app/Contents/Java/hardware/tools/arm/bin/arm-none-eabi-ar rcs /var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/build1028514802181735731.tmp/core.a /var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/build1028514802181735731.tmp/yield.cpp.o /Applications/Arduino.app/Contents/Java/hardware/tools/arm/bin/arm-none-eabi-gcc -O -Wl,--gc-sections,--relax,--defsym=__rtc_localtime=1471372214 -T/Applications/Arduino.app/Contents/Java/hardware/teensy/avr/cores/teensy3/mk20dx256.ld -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -o /var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/build1028514802181735731.tmp/asm_test.cpp.elf /var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/build1028514802181735731.tmp/asm.S.o /var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/build1028514802181735731.tmp/asm_test.cpp.o /var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/build1028514802181735731.tmp/core.a -L/var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/build1028514802181735731.tmp -larm_cortexM4l_math -lm /Applications/Arduino.app/Contents/Java/hardware/tools/arm/bin/arm-none-eabi-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 /var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/build1028514802181735731.tmp/asm_test.cpp.elf /var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/build1028514802181735731.tmp/asm_test.cpp.eep /Applications/Arduino.app/Contents/Java/hardware/tools/arm/bin/arm-none-eabi-objcopy -O ihex -R .eeprom /var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/build1028514802181735731.tmp/asm_test.cpp.elf /var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/build1028514802181735731.tmp/asm_test.cpp.hex /Applications/Arduino.app/Contents/Java/hardware/tools/teensy_post_compile -file=asm_test.cpp -path=/var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/build1028514802181735731.tmp -tools=/Applications/Arduino.app/Contents/Java/hardware/tools -board=TEENSY31 Sketch uses 15,472 bytes (5%) of program storage space. Maximum is 262,144 bytes. Global variables use 4,612 bytes (7%) of dynamic memory, leaving 60,924 bytes for local variables. Maximum is 65,536 bytes.
Under 1.6.9:
Code:/Applications/Arduino_1.6.9.app/Contents/Java/arduino-builder -dump-prefs -logger=machine -hardware "/Applications/Arduino_1.6.9.app/Contents/Java/hardware" -hardware "/Users/user/Documents/Arduino/hardware" -tools "/Applications/Arduino_1.6.9.app/Contents/Java/tools-builder" -tools "/Applications/Arduino_1.6.9.app/Contents/Java/hardware/tools/avr" -built-in-libraries "/Applications/Arduino_1.6.9.app/Contents/Java/libraries" -libraries "/Users/user/Documents/Arduino/libraries" -fqbn=teensy:avr:teensy31:usb=serial,speed=96opt,keys=en-us -ide-version=10609 -build-path "/var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/builded8bd4843e4fdee0b5e9b4c78deb97e9.tmp" -warnings=none -verbose "/Users/user/devel/asm_test/asm_test.ino" /Applications/Arduino_1.6.9.app/Contents/Java/arduino-builder -compile -logger=machine -hardware "/Applications/Arduino_1.6.9.app/Contents/Java/hardware" -hardware "/Users/user/Documents/Arduino/hardware" -tools "/Applications/Arduino_1.6.9.app/Contents/Java/tools-builder" -tools "/Applications/Arduino_1.6.9.app/Contents/Java/hardware/tools/avr" -built-in-libraries "/Applications/Arduino_1.6.9.app/Contents/Java/libraries" -libraries "/Users/user/Documents/Arduino/libraries" -fqbn=teensy:avr:teensy31:usb=serial,speed=96opt,keys=en-us -ide-version=10609 -build-path "/var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/builded8bd4843e4fdee0b5e9b4c78deb97e9.tmp" -warnings=none -verbose "/Users/user/devel/asm_test/asm_test.ino" "/Applications/Arduino_1.6.9.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -fno-exceptions -felide-constructors -std=gnu++0x -fno-rtti -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=129 -DARDUINO=10609 -DF_CPU=96000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-I/Applications/Arduino_1.6.9.app/Contents/Java/hardware/teensy/avr/cores/teensy3" "/var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/builded8bd4843e4fdee0b5e9b4c78deb97e9.tmp/sketch/asm_test.ino.cpp" -o "/dev/null" "/Applications/Arduino_1.6.9.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -fno-exceptions -felide-constructors -std=gnu++0x -fno-rtti -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=129 -DARDUINO=10609 -DF_CPU=96000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-I/Applications/Arduino_1.6.9.app/Contents/Java/hardware/teensy/avr/cores/teensy3" "/var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/builded8bd4843e4fdee0b5e9b4c78deb97e9.tmp/sketch/asm.s" -o "/dev/null" "/Applications/Arduino_1.6.9.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -fno-exceptions -felide-constructors -std=gnu++0x -fno-rtti -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=129 -DARDUINO=10609 -DF_CPU=96000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-I/Applications/Arduino_1.6.9.app/Contents/Java/hardware/teensy/avr/cores/teensy3" "/var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/builded8bd4843e4fdee0b5e9b4c78deb97e9.tmp/sketch/asm_test.ino.cpp" -o "/dev/null" "/Applications/Arduino_1.6.9.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -fno-exceptions -felide-constructors -std=gnu++0x -fno-rtti -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=129 -DARDUINO=10609 -DF_CPU=96000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-I/Applications/Arduino_1.6.9.app/Contents/Java/hardware/teensy/avr/cores/teensy3" "/var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/builded8bd4843e4fdee0b5e9b4c78deb97e9.tmp/sketch/asm_test.ino.cpp" -o "/var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/builded8bd4843e4fdee0b5e9b4c78deb97e9.tmp/preproc/ctags_target_for_gcc_minus_e.cpp" "/Applications/Arduino_1.6.9.app/Contents/Java/tools-builder/ctags/5.8-arduino10/ctags" -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives "/var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/builded8bd4843e4fdee0b5e9b4c78deb97e9.tmp/preproc/ctags_target_for_gcc_minus_e.cpp" "/Applications/Arduino_1.6.9.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-g++" -c -O -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -fno-exceptions -felide-constructors -std=gnu++0x -fno-rtti -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=129 -DARDUINO=10609 -DF_CPU=96000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-I/Applications/Arduino_1.6.9.app/Contents/Java/hardware/teensy/avr/cores/teensy3" "/var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/builded8bd4843e4fdee0b5e9b4c78deb97e9.tmp/sketch/asm_test.ino.cpp" -o "/var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/builded8bd4843e4fdee0b5e9b4c78deb97e9.tmp/sketch/asm_test.ino.cpp.o" "/Applications/Arduino_1.6.9.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-gcc" -c -O -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -x assembler-with-cpp -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -D__MK20DX256__ -DTEENSYDUINO=129 -DARDUINO=10609 -DF_CPU=96000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-I/Applications/Arduino_1.6.9.app/Contents/Java/hardware/teensy/avr/cores/teensy3" "/Applications/Arduino_1.6.9.app/Contents/Java/hardware/teensy/avr/cores/teensy3/memcpy-armv7m.S" -o "/var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/builded8bd4843e4fdee0b5e9b4c78deb97e9.tmp/core/memcpy-armv7m.S.o" [snip] "/Applications/Arduino_1.6.9.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-ar" rcs "/var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/builded8bd4843e4fdee0b5e9b4c78deb97e9.tmp/core/core.a" "/var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/builded8bd4843e4fdee0b5e9b4c78deb97e9.tmp/core/yield.cpp.o" "/Applications/Arduino_1.6.9.app/Contents/Java/hardware/teensy/../tools/arm/bin/arm-none-eabi-gcc" -O -Wl,--gc-sections,--relax,--defsym=__rtc_localtime=1471372195 "-T/Applications/Arduino_1.6.9.app/Contents/Java/hardware/teensy/avr/cores/teensy3/mk20dx256.ld" -mthumb -mcpu=cortex-m4 -fsingle-precision-constant -o "/var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/builded8bd4843e4fdee0b5e9b4c78deb97e9.tmp/asm_test.ino.elf" "/var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/builded8bd4843e4fdee0b5e9b4c78deb97e9.tmp/sketch/asm_test.ino.cpp.o" "/var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/builded8bd4843e4fdee0b5e9b4c78deb97e9.tmp/core/core.a" "-L/var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/builded8bd4843e4fdee0b5e9b4c78deb97e9.tmp" -larm_cortexM4l_math -lm /var/folders/qz/7q3wkh5j62g8bhxq85khstgh000f9d/T/builded8bd4843e4fdee0b5e9b4c78deb97e9.tmp/sketch/asm_test.ino.cpp.o: In function `loop': /Users/user/devel/asm_test/asm_test.ino:10: undefined reference to `asm_foo' collect2: error: ld returned 1 exit status Error compiling for board Teensy 3.2 / 3.1.
The functional program will print out 42 once per second to the serial console.
I am using OS X 10.11 with a Teensy 3.2. The same computer and Teensy was used for both tests.
Last edited: