Toolchain update, 4.7.2 to 4.8.4

PaulStoffregen

Well-known member
I'm feeling like it's probably time to update our aging ARM toolchain.

Edit: Here is a first test version with the new toolchain:


Linux 32 bit:
http://www.pjrc.com/teensy/td_121-test1/teensyduino.32bit

Linux 64 bit:
http://www.pjrc.com/teensy/td_121-test1/teensyduino.64bit

Mac OS-X:
http://www.pjrc.com/teensy/td_121-test1/teensyduino.dmg

Windows:
http://www.pjrc.com/teensy/td_121-test1/teensyduino.exe


The version we've been using is basically the same 4.7.2 since Teensy 3.0's release, with a only fix to the linker (thanks Andrew!).

Much has happened over the last 2 years. There's now a really well maintained toolchain:

https://launchpad.net/gcc-arm-embedded

The only minor seems to be a lack of a tarball for 64 bit Linux.
 
Last edited:
Yes, this toolchain works good. I'm using it for some time now. A little bit confusing is,that the sketches need a bit more RAM (?) - according to the messages after compile. Maye, the estimate is better/worse. Don't know.
The updated lib has advantages too, like a m4-spezialized fast memcpy for example.
 
The toolchain is in the hardware/tool/arm-none-eabi folder. To try a different one, all you have to do is replace the contents of that folder with a copy from https://launchpad.net/gcc-arm-embedded

Indeed, the memory usage is higher. I do not know why (yet).

Old 4.7.2 version:

Code:
Binary sketch size: 10,672 bytes (of a 262,144 byte maximum)
Estimated memory use: 2,572 bytes (of a 65,536 byte maximum)

New 4.8.4 version

Code:
Binary sketch size: 12,780 bytes (of a 262,144 byte maximum)
Estimated memory use: 4,744 bytes (of a 65,536 byte maximum)

Test done compiling this:

Code:
int led = 13;

void setup() {
  pinMode(led, OUTPUT);     
}

int count=0;

void loop() {
  Serial.print("test");
  Serial.println(count++);
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}
 
I could not get the new toolchain to work on Win 7. Tried both the zipped and exec versions. When I try to compile Paul's
test program above I get the following errors:

c:/arduino/hardware/tools/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/bin/ld.exe: cannot find -larm_cortexM4l_math
collect2.exe: error: ld returned 1 exit status
 
Looks like nearly all the extra RAM usage is due to the default newlib provided with the new toolchain.

Here's a section of the symbol table from generated code.

Code:
1fff87dc D usb_string_product_name_default
1fff87dc V usb_string_product_name
1fff87f2 D string0
1fff87f6 D usb_string_serial_number_default
1fff87f6 V usb_string_serial_number
1fff8810 d impure_data    <----------- 1064 bytes
1fff8c38 D _impure_ptr    
1fff8c3c D __malloc_av_   <----------- 1032 bytes
1fff9044 D __malloc_trim_threshold
1fff9048 D __malloc_sbrk_base
1fff904c b completed.7863
1fff904c B _sbss
1fff904c D _edata

Looks like nearly all the extra space is from 2 symbols: impure_data and __malloc_av_

Apparently there are different linker options to use newlib-nano. I'm digging into this now....
 
c:/arduino/hardware/tools/arm-none-eabi/bin/../lib/gcc/arm-none-eabi/4.8.4/../../../../arm-none-eabi/bin/ld.exe: cannot find -larm_cortexM4l_math
collect2.exe: error: ld returned 1 exit status

Find libarm_cortexM4l_math.a in the old version and simply copy it to the same location within the new one.
 
Paul , would you upload the new newlib , if you compile it ?
Edit:
Or, better, a short explanation how to compile it :)
 
Last edited:
Thanks guys.....that seems to have done the trick. I found 'larm_cortexM4l_math.a' in this folder:
C:\Arduino\hardware\tools\arm-none-eabi\arm-none-eabi\lib. Copied it to the same in the new
toolchain and tried Paul's test prog plus many of my own for both T3.0 and T3.1 and all
compiled ok. Thanks again :)
 
Confirmed it works on my Mac. Had to copy the libarm_cortexM4l_math.a to /Applications/Arduino.app/Contents/Resources/Java/hardware/tools/arm-none-eabi/arm-none-eabi/lib

My download size is larger than the old one (Teensy 3.0), but not the same as Paul's:
Binary sketch size: 12,444 bytes (of a 131,072 byte maximum)
Estimated memory use: 4,492 bytes (of a 16,384 byte maximum)

With the old toolchain, the size is:
Binary sketch size: 10,328 bytes (of a 131,072 byte maximum)
Estimated memory use: 2,320 bytes (of a 16,384 byte maximum)

After editing the boards.txt file (in 2 places -- once for Teensy 3.1 and once for Teensy 3.0), I get a smaller size (again - I'm using Teensy 3.0).

Binary sketch size: 10,244 bytes (of a 131,072 byte maximum)
Estimated memory use: 3,376 bytes (of a 16,384 byte maximum)

teensy31.build.linkoption2=--specs=nano.specs
teensy3.build.linkoption2=--specs=nano.specs
 
Last edited:
I'm going to work on getting a 64 bit linux copy prepared, then post a 1.21-test1 installer, so everyone can try this more easily.

Newlib nano is optimized for size. The main differences seem to be in printf, malloc, and discarding some posix compliance stuff that's only needed for programs running on conventional operating systems,

This new printf is a LOT smaller, but it doesn't support float. Worse, it seems to crash on %f. So far, I do not know what to do about that....
 
Binary sketch size: 10,244 bytes (of a 131,072 byte maximum)
Estimated memory use: 3,376 bytes (of a 16,384 byte maximum)

I'm getting this on Linux:

Binary sketch size: 10,200 bytes (of a 131,072 byte maximum)
Estimated memory use: 2,316 bytes (of a 16,384 byte maximum)
 
printf() works for me (OSX):
Code:
const int LED = 13;
int i=1, j=1;
double series=0;

void setup() {                
  pinMode(LED, OUTPUT);     
  while (!Serial);
}

void loop() {
  digitalWrite(LED, HIGH);  delay(10);
  series += 1.0/((double)j*(double)j);
  j+=2;
  Serial.printf("Iteration %3d is %16.13f\n", i++, sqrt(8*series));
  digitalWrite(LED, LOW); delay(90);           
}
 
Well, I was hoping to "cheat" and pull the linux 64 bit version of the Ubuntu PPA. Sadly, it's dynamically linked against libraries that aren't installed by default. That stuff is all statically linked in the 32 bit tarball.
 
Ok, after a few false starts earlier today, I think I've finally got the newer toolchain build running for 64 bit linux. At least it's chewing up a lot of CPU time....

Hopefully soon I'll be able to post a test update with the new toolchain, and other minor changes since 1.20.
 
I've posted the first 1.21-test1 installers, with the new toolchain. See the first message in this thread for the links.
 
I tried your new Teensyduino.exe
RAW_HID & MIDI ar not compiling anymore:
Code:
Arduino: 1.0.6 + Td: 1.21-test1 (Windows 7), Board: "Teensy 3.1"
C:\Arduino\hardware\tools\arm\bin\arm-none-eabi-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mcpu=cortex-m4 -DF_CPU=96000000 -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106 -mthumb -nostdlib -D__MK20DX256__ -DTEENSYDUINO=120 -fno-rtti -felide-constructors -std=gnu++0x -DUSB_RAWHID -DLAYOUT_US_ENGLISH -IC:\Arduino\hardware\teensy\cores\teensy3 -IC:\Arduino\libraries\Audio -IC:\Arduino\libraries\Wire -IC:\Arduino\libraries\SPI -IC:\Arduino\libraries\SD -IC:\Users\Frank\Documents\Arduino\libraries\Helix C:\Users\Frank\AppData\Local\Temp\build6538177232181520882.tmp\Mp3FilePlayer.cpp -o C:\Users\Frank\AppData\Local\Temp\build6538177232181520882.tmp\Mp3FilePlayer.cpp.o 

In file included from C:\Arduino\hardware\teensy\cores\teensy3/WProgram.h:25:0,
                 from C:\Arduino\hardware\teensy\cores\teensy3/Arduino.h:1,
                 from C:\Arduino\hardware\teensy\cores\teensy3/AudioStream.h:34,
                 from C:\Arduino\libraries\Audio/analyze_fft256.h:30,
                 from C:\Arduino\libraries\Audio/Audio.h:61,
                 from Mp3FilePlayer.ino:8:
C:\Arduino\hardware\teensy\cores\teensy3/usb_seremu.h:88:25: error: conflicting declaration 'usb_seremu_class Serial'
 extern usb_seremu_class Serial;
                         ^
In file included from C:\Arduino\hardware\teensy\cores\teensy3/WProgram.h:24:0,
                 from C:\Arduino\hardware\teensy\cores\teensy3/Arduino.h:1,
                 from C:\Arduino\hardware\teensy\cores\teensy3/AudioStream.h:34,
                 from C:\Arduino\libraries\Audio/analyze_fft256.h:30,
                 from C:\Arduino\libraries\Audio/Audio.h:61,
                 from Mp3FilePlayer.ino:8:
C:\Arduino\hardware\teensy\cores\teensy3/usb_serial.h:139:25: error: 'Serial' has a previous declaration as 'usb_serial_class Serial'
 extern usb_serial_class Serial;
                         ^
 
This code:
Code:
Stream &myDebug2 = Serial2;

void setup()
{
  // reassign pins 26 and 31 to use the ALT3 configuration
  // which makes them  Serial port 2 Rx(26) and Tx(31)
  CORE_PIN26_CONFIG = PORT_PCR_MUX(3);
  CORE_PIN31_CONFIG = PORT_PCR_MUX(3);
  Serial2.begin(115200);
}

void loop()
{
  myDebug2.print("hello world");
  delay(1000);
}

Throws this error:
Arduino: 1.0.6 + Td: 1.21-test1 (Linux), Board: "Teensy 3.1"
/home/jimm/teensyduino21-test/hardware/tools/arm/bin/arm-none-eabi-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mcpu=cortex-m4 -DF_CPU=96000000 -MMD -DUSB_VID=null -DUSB_PID=null -DARDUINO=106 -mthumb -nostdlib -D__MK20DX256__ -DTEENSYDUINO=120 -fno-rtti -felide-constructors -std=gnu++0x -DUSB_RAWHID -DLAYOUT_US_ENGLISH -I/home/jimm/teensyduino21-test/hardware/teensy/cores/teensy3 /tmp/build5040146050508403536.tmp/sketch_dec01a.cpp -o /tmp/build5040146050508403536.tmp/sketch_dec01a.cpp.o
In file included from /home/jimm/teensyduino21-test/hardware/teensy/cores/teensy3/WProgram.h:25:0,
from /home/jimm/teensyduino21-test/hardware/teensy/cores/teensy3/Arduino.h:1,
from sketch_dec01a.ino:2:
/home/jimm/teensyduino21-test/hardware/teensy/cores/teensy3/usb_seremu.h:88:25: error: conflicting declaration 'usb_seremu_class Serial'
extern usb_seremu_class Serial;
^
In file included from /home/jimm/teensyduino21-test/hardware/teensy/cores/teensy3/WProgram.h:24:0,
from /home/jimm/teensyduino21-test/hardware/teensy/cores/teensy3/Arduino.h:1,
from sketch_dec01a.ino:2:
/home/jimm/teensyduino21-test/hardware/teensy/cores/teensy3/usb_serial.h:139:25: error: 'Serial' has a previous declaration as 'usb_serial_class Serial'
extern usb_serial_class Serial;
^

Same code compiles with no error in 1.20
 
Compiled for me:
Binary sketch size: 10,596 bytes (of a 262,144 byte maximum)
Estimated memory use: 3,636 bytes (of a 65,536 byte maximum)
 
Back
Top