Teensyduino 1.54 Beta #8

Status
Not open for further replies.
Yes, confirmed, I am able to reproduce the memcpy bug. Working on it now....





I also have no idea. I didn't change it. Committed a fix to never use unaligned access.

https://github.com/PaulStoffregen/cores/commit/a648248ae0adade4155c886a4e71d93dace89f91


But this alone is not enough to solve the problem. Looks like gcc is sometimes replacing "memcpy" with "__builtin_mempy", which also seems to do unaligned access. I'm trying different fixes now....

I know I should and probably will look it up, but what does: -mno-unaligned-access
do?

That is what does this do when you have structures defined with with __attribute__((packed))
and the items are not aligned?
 
@luni
Followed the instructions to install arm9 (installed the 9-2020-q2-update) and changed the following in the boards.txt file to
Code:
#teensy41.build.toolchain=arm/bin/
teensy41.build.toolchain=arm9/bin/
using IDE 1.8.14beta8 and then reran the example but it seems to work for me:
Code:
first
second
answer
only tested on a T4.1 though.

EDIT: These are the instructions that I followed:

Thanks for testing. I had a hard time reproducing the bug myself until I remembered that I "simplified" the test code before posting by replacing std::string with char*. Not a good idea because the char* version does compile indeed.

Here the original test version which generates the compile errors mentioned above. Doesn't compile with Arduino 1.8.13, TD 1.54b7 and GCC9. Works with TD1.53 and GCC9. With GCC 5.4 (standard TD compiler) it works in any case. Works with GCC 9 if I unwind the core files changes before this commit: https://github.com/PaulStoffregen/cores/commit/dc567880488dc53ba2e71eb07e04356bda7e2a7e

Code:
#include <map>
#include <string>

void setup()
{
    while(!Serial){}

    std::map<int,std::string>m {{1,"first"}, {2,"second"}, {42,"answer"}};
    Serial.println(m[42].c_str());
}

void loop(){
}
 
Last edited:
Thanks for testing. I had a hard time reproducing the bug myself until I remembered that I "simplified" the test code before posting by replacing std::string with char*. Not a good idea because the char* version does compile indeed.

Here the original test version which generates the compile errors mentioned above. Doesn't compile with Arduino 1.8.13, TD 1.54b7 and GCC9. Works with TD1.53 and GCC9. With GCC 5.4 (standard TD compiler) it works in any case. Works with GCC 9 if I unwind the core files changes before this commit: https://github.com/PaulStoffregen/cores/commit/dc567880488dc53ba2e71eb07e04356bda7e2a7e

Code:
#include <map>
#include <string>

void setup()
{
    while(!Serial){}

    std::map<int,std::string>m {{1,"first"}, {2,"second"}, {42,"answer"}};
    Serial.println(m[42].c_str());
}

void loop(){
}

Ok - just retested with 1.8.14b8 and 1.8.15b9 with GCC9 and yes it does fail to compile but as you said it compiles fine with the default gcc. Saw they GCC10 is out as well. So tempted.
 
I have the GCC9... And I do get a failure... Currently it looks like:
Code:
Linking everything together...
"C:\\arduino-1.8.15\\hardware\\teensy/../tools/arm9/bin/arm-none-eabi-gcc" -O2 -Wl,--gc-sections,--relax "-TC:\\arduino-1.8.15\\hardware\\teensy\\avr\\cores\\teensy4/imxrt1062.ld" -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -o "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino_build_553006/foo.ino.elf" "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino_build_553006\\sketch\\foo.ino.cpp.o" "C:\\Users\\kurte\\AppData\\Local\\Temp\\arduino_build_553006/core\\core.a" "-LC:\\Users\\kurte\\AppData\\Local\\Temp\\arduino_build_553006" -larm_cortexM7lfsp_math -lm -lstdc++
c:/arduino-1.8.15/hardware/tools/arm9/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld.exe: cannot find -larm_cortexM7lfsp_math
collect2.exe: error: ld returned 1 exit status
Error compiling for board Teensy 4.0.

Same with T4.1 Did I miss a step or is this the same error you are receiving?
 
You first need to copy the math libraries to the gcc folder as explained in the WIKI.

Here the error messages I get. They are from the linker not from the compiler and are related to the changes in the linker script introduced in the referenced commit. I don't know if this is an issue introduced by GCC9 or if GCC 5.4 simply doesn't report the underlying problem.

Code:
Linking everything together...
"C:\\Program Files\\Arduino\\arduino-1.8.13\\hardware\\teensy/../tools/arm9/bin/arm-none-eabi-gcc" -O2 -Wl,--gc-sections,--relax "-TC:\\Program Files\\Arduino\\arduino-1.8.13\\hardware\\teensy\\avr\\cores\\teensy4/imxrt1062_t41.ld" -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -o "C:\\Users\\lutz\\AppData\\Local\\Temp\\arduino_build_844573/Blink.ino.elf" "C:\\Users\\lutz\\AppData\\Local\\Temp\\arduino_build_844573\\sketch\\Blink.ino.cpp.o" "C:\\Users\\lutz\\AppData\\Local\\Temp\\arduino_build_844573/core\\core.a" "-LC:\\Users\\lutz\\AppData\\Local\\Temp\\arduino_build_844573" -larm_cortexM7lfsp_math -lm -lstdc++
c:/program files/arduino/arduino-1.8.13/hardware/tools/arm9/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+dp/hard\libstdc++.a(functexcept.o):(.ARM.exidx.text.unlikely._ZSt17__throw_bad_allocv+0x4): relocation truncated to fit: R_ARM_PREL31 against `.ARM.extab.text.unlikely._ZSt17__throw_bad_allocv'
c:/program files/arduino/arduino-1.8.13/hardware/tools/arm9/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+dp/hard\libstdc++.a(functexcept.o):(.ARM.extab.text.unlikely._ZSt19__throw_logic_errorPKc+0x0): relocation truncated to fit: R_ARM_PREL31 against symbol `__gxx_personality_v0' defined in .text.__gxx_personality_v0 section in c:/program files/arduino/arduino-1.8.13/hardware/tools/arm9/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+dp/hard\libstdc++.a(eh_personality.o)
c:/program files/arduino/arduino-1.8.13/hardware/tools/arm9/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+dp/hard\libstdc++.a(functexcept.o):(.ARM.exidx.text.unlikely._ZSt19__throw_logic_errorPKc+0x4): relocation truncated to fit: R_ARM_PREL31 against `.ARM.extab.text.unlikely._ZSt19__throw_logic_errorPKc'
c:/program files/arduino/arduino-1.8.13/hardware/tools/arm9/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+dp/hard\libstdc++.a(functexcept.o):(.ARM.extab.text.unlikely._ZSt20__throw_length_errorPKc+0x0): relocation truncated to fit: R_ARM_PREL31 against symbol `__gxx_personality_v0' defined in .text.__gxx_personality_v0 section in c:/program files/arduino/arduino-1.8.13/hardware/tools/arm9/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+dp/hard\libstdc++.a(eh_personality.o)
c:/program files/arduino/arduino-1.8.13/hardware/tools/arm9/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+dp/hard\libstdc++.a(functexcept.o):(.ARM.exidx.text.unlikely._ZSt20__throw_length_errorPKc+0x4): relocation truncated to fit: R_ARM_PREL31 against `.ARM.extab.text.unlikely._ZSt20__throw_length_errorPKc'
c:/program files/arduino/arduino-1.8.13/hardware/tools/arm9/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+dp/hard\libstdc++.a(string-inst.o):(.ARM.exidx.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERjj[_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERjj]+0x4): relocation truncated to fit: R_ARM_PREL31 against `.ARM.extab.text._ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_createERjj'
c:/program files/arduino/arduino-1.8.13/hardware/tools/arm9/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+dp/hard\libstdc++.a(eh_catch.o):(.ARM.extab.text.__cxa_begin_catch+0x0): relocation truncated to fit: R_ARM_PREL31 against symbol `__gxx_personality_v0' defined in .text.__gxx_personality_v0 section in c:/program files/arduino/arduino-1.8.13/hardware/tools/arm9/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+dp/hard\libstdc++.a(eh_personality.o)
c:/program files/arduino/arduino-1.8.13/hardware/tools/arm9/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+dp/hard\libstdc++.a(eh_catch.o):(.ARM.exidx.text.__cxa_begin_catch+0x4): relocation truncated to fit: R_ARM_PREL31 against `.ARM.extab.text.__cxa_begin_catch'
c:/program files/arduino/arduino-1.8.13/hardware/tools/arm9/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+dp/hard\libstdc++.a(eh_personality.o):(.ARM.exidx.text._ZL21base_of_encoded_valuehP15_Unwind_Context+0x4): relocation truncated to fit: R_ARM_PREL31 against `.ARM.extab.text._ZL21base_of_encoded_valuehP15_Unwind_Context'
c:/program files/arduino/arduino-1.8.13/hardware/tools/arm9/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+dp/hard\libstdc++.a(eh_personality.o):(.ARM.extab.text.__gxx_personality_v0+0x0): relocation truncated to fit: R_ARM_PREL31 against symbol `__gxx_personality_v0' defined in .text.__gxx_personality_v0 section in c:/program files/arduino/arduino-1.8.13/hardware/tools/arm9/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+dp/hard\libstdc++.a(eh_personality.o)
c:/program files/arduino/arduino-1.8.13/hardware/tools/arm9/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/lib/thumb/v7e-m+dp/hard\libstdc++.a(eh_personality.o):(.ARM.exidx.text.__gxx_personality_v0+0x4): additional relocation overflows omitted from the output
collect2.exe: error: ld returned 1 exit status
Error compiling for board Teensy 4.1.
 
You first need to copy the math libraries to the gcc folder as explained in the WIKI.

Here the error messages I get. They are from the linker not from the compiler and are related to the changes in the linker script introduced in the referenced commit. I don't know if this is an issue introduced by GCC9 or if GCC 5.4 simply doesn't report the underlying problem.

Thanks, I might be missing the copy of math libraries as I am building with Arduino and I only saw the copy of stuff mentioned under VisualTeensy

But will take a look again

Ooops - I installed in new directory... did not copy old one first ...
 
Thanks, I might be missing the copy of math libraries as I am building with Arduino and I only saw the copy of stuff mentioned under VisualTeensy

But will take a look again

Ooops - I installed in new directory... did not copy old one first ...

At the end both methods do the same. Either overwrite an existing copy with the new files or just copy the 4 missing math libraries to a new installation.
 
Thanks,
I just redid it following the instructions... And now it fails the same way you mentioned :D
 
Status
Not open for further replies.
Back
Top