Teensyduino 1.58 Released

mjs513:
I have been getting this warning in PlatformIO using 1.57 ever since I started to build MTP:

Code:
lib/MTP_Teensy/src/MTP_Teensy.cpp: In member function 'uint32_t MTP_class::GetObjectInfo(MTP_class::MTPContainer&)':
lib/MTP_Teensy/src/MTP_Teensy.cpp:523:34: warning: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
   #pragma GCC diagnostic ignored "-Wformat-truncation" /* Or "-Wformat-truncation" */
                                  ^

I pretty much have just ignored it for quite some time.
Regards,
Ed
 
mjs513:
I have been getting this warning in PlatformIO using 1.57 ever since I started to build MTP:

Code:
lib/MTP_Teensy/src/MTP_Teensy.cpp: In member function 'uint32_t MTP_class::GetObjectInfo(MTP_class::MTPContainer&)':
lib/MTP_Teensy/src/MTP_Teensy.cpp:523:34: warning: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
   #pragma GCC diagnostic ignored "-Wformat-truncation" /* Or "-Wformat-truncation" */
                                  ^

I pretty much have just ignored it for quite some time.
Regards,
Ed

the pragma messages were added as a result of going to an updated toolchain in 1.58. 1.57 still uses the old toolchain. You should probably update to 1.58 now that its been released. Paul did issue a PlatformIO update method - maybe you should try.

I am using 1.59beta1 in 2.0.5 nightly and only am seeing
Code:
d:\Users\Merli\Documents\Arduino\libraries\MTP_Teensy-main\src\MTP_USBFS_Callbacks.cpp: In static member function 'static bool MTP_USBFS_Callback::checkUSBFSChangedState(uint8_t, FS*)':
d:\Users\Merli\Documents\Arduino\libraries\MTP_Teensy-main\src\MTP_USBFS_Callbacks.cpp:110:149: warning: '%s' directive output may be truncated writing up to 19 bytes into a region of size 15 [-Wformat-truncation=]
  110 |                                                         snprintf(s_map_fs_mtp[index].storage_name, sizeof(s_map_fs_mtp[index].storage_name), "MSC%d-%s", index, volName);
      |                                                                                                                                                     ^~          ~~~~~~~
d:\Users\Merli\Documents\Arduino\libraries\MTP_Teensy-main\src\MTP_USBFS_Callbacks.cpp:110:65: note: 'snprintf' output between 6 and 25 bytes into a destination of size 20
  110 |                                                         snprintf(s_map_fs_mtp[index].storage_name, sizeof(s_map_fs_mtp[index].storage_name), "MSC%d-%s", index, volName);
      |                                                         ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Opening Teensy Load

Same thing when I used 1.8.19 with 1.58
 
I just installed TD 1.58 on Arduino 2.04 on an M1 Mac Mini running MacOS Ventura (13.3). My program compiled successfully, but I'm getting a lot of warnings concerning snprintf() in MTP_Teensy:

Code:
/Users/markborgerson/Documents/Arduino/libraries/MTP_Teensy-main/src/MTP_Teensy.cpp:522:42: note: directive argument in the range [0, 255]
/Users/markborgerson/Documents/Arduino/libraries/MTP_Teensy-main/src/MTP_Teensy.cpp:522:13: note: 'snprintf' output between 16 and 21 bytes into a destination of size 16
  522 |     snprintf(ctimebuf, sizeof(ctimebuf), "%04u%02u%02uT%02u%02u%02u",
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  523 |              dtf.year + 1900, dtf.mon + 1, dtf.mday, dtf.hour, dtf.min,
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  524 |              dtf.sec);
      |              ~~~~~~~~

/Users/markborgerson/Documents/Arduino/libraries/MTP_Teensy-main/src/MTP_Teensy.cpp:530:60: warning: '%02u' directive output may be truncated writing between 2 and 3 bytes into a region of size between 2 and 5 [-Wformat-truncation=]
  530 |     snprintf(mtimebuf, sizeof(mtimebuf), "%04u%02u%02uT%02u%02u%02u",
      |                                                            ^~~~
/Users/markborgerson/Documents/Arduino/libraries/MTP_Teensy-main/src/MTP_Teensy.cpp:530:42: note: directive argument in the range [0, 255]
  530 |     snprintf(mtimebuf, sizeof(mtimebuf), "%04u%02u%02uT%02u%02u%02u",
      |                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~

I like to get my programs to the warning-free state, but I'm reluctant to start editing the MTP_Teensy library. I can't believe I'm the first to see these warnings. Are they discussed elsewhere?

My guess is that you have not synced up to the current version of MTP_Teensy. Remember it is not intalled by the Teensy installs, but must be manually downloaded and/or synced.

Current build this morning (after I had to delete part of %temp%)
Code:
"C:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\tools\\teensy-compile\\11.3.1/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++17 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=159 -DARDUINO=10607 -DARDUINO_TEENSY41 -DF_CPU=600000000 -DUSB_MTPDISK -DLAYOUT_US_ENGLISH "-IC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\hardware\\avr\\0.59.1\\cores\\teensy4" "-IC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\hardware\\avr\\0.59.1\\libraries\\SPI" "-IC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\hardware\\avr\\0.59.1\\libraries\\SD\\src" "-IC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\hardware\\avr\\0.59.1\\libraries\\SdFat\\src" "-Ic:\\Users\\kurte\\Documents\\Arduino\\libraries\\MTP_Teensy\\src" "-Ic:\\Users\\kurte\\Documents\\Arduino\\libraries\\JPEGDEC\\src" "-Ic:\\Users\\kurte\\Documents\\Arduino\\libraries\\PNGdec\\src" "-Ic:\\Users\\kurte\\Documents\\Arduino\\libraries\\Ra8876LiteTeensy\\src" "-IC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\hardware\\avr\\0.59.1\\libraries\\Wire" [COLOR="#FF0000"]"c:\\Users\\kurte\\Documents\\Arduino\\libraries\\MTP_Teensy\\src\\MTP_Teensy.cpp" -o nul[/COLOR]
"C:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\tools\\teensy-compile\\11.3.1/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections -nostdlib -std=gnu++17 -fno-exceptions -fpermissive -fno-rtti -fno-threadsafe-statics -felide-constructors -Wno-error=narrowing -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -D__IMXRT1062__ -DTEENSYDUINO=159 -DARDUINO=10607 -DARDUINO_TEENSY41 -DF_CPU=600000000 -DUSB_MTPDISK -DLAYOUT_US_ENGLISH "-IC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\hardware\\avr\\0.59.1\\cores\\teensy4" "-IC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\hardware\\avr\\0.59.1\\libraries\\SPI" "-IC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\hardware\\avr\\0.59.1\\libraries\\SD\\src" "-IC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\hardware\\avr\\0.59.1\\libraries\\SdFat\\src" "-Ic:\\Users\\kurte\\Documents\\Arduino\\libraries\\MTP_Teensy\\src" "-Ic:\\Users\\kurte\\Documents\\Arduino\\libraries\\JPEGDEC\\src" "-Ic:\\Users\\kurte\\Documents\\Arduino\\libraries\\PNGdec\\src" "-Ic:\\Users\\kurte\\Documents\\Arduino\\libraries\\Ra8876LiteTeensy\\src" "-IC:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\hardware\\avr\\0.59.1\\libraries\\Wire" "c:\\Users\\kurte\\Documents\\Arduino\\libraries\\MTP_Teensy\\src\\MTP_USBFS_Callbacks.cpp" -o nul
"C:\\Users\\kurte\\AppData\\Local\\Arduino15\\packages\\teensy\\tools\\teensy-compile\\11.3.1/arm/bin/arm-none-eabi-g++" -E -CC -x c++ -w -g -Wall -ffunction-sections -fdata-sections

Current sources:
Code:
  #pragma GCC diagnostic push
  #pragma GCC diagnostic ignored "-Wformat-truncation" /* Or "-Wformat-truncation" */
  if (storage_.getCreateTime(handle, dt)) {
    breakTime(dt, dtf);
    snprintf(ctimebuf, sizeof(ctimebuf), "%04u%02u%02uT%02u%02u%02u",
             dtf.year + 1900, dtf.mon + 1, dtf.mday, dtf.hour, dtf.min,
             dtf.sec);
  } else {
    ctimebuf[0] = 0;
  }
  if (storage_.getModifyTime(handle, dt)) {
    breakTime(dt, dtf);
    snprintf(mtimebuf, sizeof(mtimebuf), "%04u%02u%02uT%02u%02u%02u",
             dtf.year + 1900, dtf.mon + 1, dtf.mday, dtf.hour, dtf.min,
             dtf.sec);
  } else {
    mtimebuf[0] = 0;
  }
#pragma GCC diagnostic pop

Edit: Looks like @mjs513 is in different file... will check again. Also t
he beta build with LTO opend up whole other cans of worms with stuff...
But that is different subject.

EDIT2: Not getting in the other file either:
Code there:
Code:
  						#pragma GCC diagnostic push
  						#pragma GCC diagnostic ignored "-Wformat-truncation" /* Or "-Wformat-truncation" */
						if (pusbfs->getVolumeLabel(volName, sizeof(volName)))
							snprintf(s_map_fs_mtp[index].storage_name, sizeof(s_map_fs_mtp[index].storage_name), "MSC%d-%s", index, volName);
						else
							snprintf(s_map_fs_mtp[index].storage_name, sizeof(s_map_fs_mtp[index].storage_name), "MSC%d", index);
						s_map_fs_mtp[index].storage_name[sizeof(s_map_fs_mtp[index].storage_name) - 1] = 0; // make sure null terminated
						#pragma GCC diagnostic pop
 
Last edited:
My guess is that you have not synced up to the current version of MTP_Teensy. Remember it is not intalled by the Teensy installs, but must be manually downloaded and/or synced.

OK, I'll reinstall MTP_Teensy and see if that solves the problem.
 
OK, I'll reinstall MTP_Teensy and see if that solves the problem.

I replaced the MTP_Teensy-Main folder in my libraries folder with the latest version of GitHub. The snprintf warnings are gone---except for a few that popped up from my own usage.

I need to research that warning and decide how to handle it in my own code or with the #pragmas in the MTP Code.

I recently found another MTP issue that is annoying, but not critical: When I have two Teensys running MTP plugged in at the same time, I get two devices named "Teensy" and two volumes named "SD Card". Both seem work as expected, but it can be difficult to keep straight which volume is on which hardware. Can I solve that with non-default device or volume names? Or, is this something I have to handle when I format the sd card?
 
I am experiencing an odd issue after upgrading to Arduino IDE 2.04 (from 2.03) and Teensyduino 1.58 and I can't seem to figure it out. I'm running on a Teensy 4.1 with ethernet.

Some background: I've made a programmable doorbell that plays custom WAV files for the bell tones (among other things). I'm storing WAV files on the SD card. Prior to upgrading, the following code snippet worked:

Code:
#include <SD.h>
#include <vector>
#include <QNEthernet.h>

std::vector<String> bellFileList;

using namespace qindesign::network;

// Use these with the Teensy Audio Shield
#define SDCARD_CS_PIN    10
#define SDCARD_MOSI_PIN  7
#define SDCARD_SCK_PIN   14

void setup() {

  // start serial connection (for debugging purposes)
  Serial.begin(9600);
  stdPrint = &Serial;  // Make printf work (a QNEthernet feature)

  SPI.setMOSI(SDCARD_MOSI_PIN);
  SPI.setSCK(SDCARD_SCK_PIN);
  if (!(SD.begin(SDCARD_CS_PIN))) {
    printf("no SD card found, using internal sounds.\r\n");
  }
  else {
    // access root directory and get file list
    File dir, currentEntry;
    dir = SD.open("/");
    printf("getting wav file list for bell files\r\n");
    getWavFileList(dir, bellFileList);
  }
  printf("back\r\n");

}

void loop() {
  // put your main code here, to run repeatedly:

}

bool getWavFileList(File &dir, std::vector<String> &fileList)
{
  printf("rewind");
  dir.rewindDirectory();

  printf(" opennext");
  File currentEntry=dir.openNextFile();
  while(currentEntry) {
    if(!currentEntry.isDirectory()) {
      String temp = currentEntry.name();
      temp.toLowerCase();
      if(temp.lastIndexOf(".wav")>0) {
        printf("emplace ");
        printf(temp.c_str());
        printf("\r\n");
        fileList.emplace_back(temp);
      }
      else {
        printf("skipping file %s\r\n", temp.c_str());
      }
    }
    printf("opennext2\r\n");
    currentEntry=dir.openNextFile();
  }
  printf("returning\r\n");
}

After upgrading to the 2.04/1.58, the code runs, I see the fileList getting populated, but getWavFileList never returns - instead, the teensy just reboots, over and over.

Is there some way to check that I have the right libraries, tools, etc. installed? I already tried uninstalling everything and reinstalling, but that didn't fix anything.
 
@jal142 Side fact: If you're just using QNEthernet for its `printf` implementation, Teensyduino 1.58 has new `printf` support, so you don't need to do the `stdPrint = &Serial` thing anymore. (For simple cases, that is.) :)

I also noticed that you don't check the returned value of `SD.open("/")` (`dir`).
 
@jal142 Side fact: If you're just using QNEthernet for its `printf` implementation, Teensyduino 1.58 has new `printf` support, so you don't need to do the `stdPrint = &Serial` thing anymore. (For simple cases, that is.) :)

I also noticed that you don't check the returned value of `SD.open("/")` (`dir`).

I was using QNEthernet to connect the doorbell to my HomeAssistant server so I can get notifications forwarded to my phone. The printf was a bonus.

I guess I should check the SD.open() call's return status. I had assumed that if the SD.begin() worked, the root directory would be available.
 
Error installing using Arduino IDE (1.8.19)
Screenshot from 2023-04-08 23-14-23.jpg

Tried a few times same error.
 
Error installing using Arduino IDE (1.8.19)

Tried a few times same error.

For IDE 1.8.19 the TeensyInstaller.exe of TeensyDuino is required.

Board Manager support was added for IDE 2.

For TD 1.58 see downloads link on PJRC.com - found in the announcements forum on release

For TD 1.59 beta #2 current (for today at least) in Announcement for that release
 
To explain further (now that I have a little more time to write a better message), Arduino 1.8.19 Boards Manager can't be used, for a few good reasons beyond this simple error.

1: 1.8.19 lacks pluggable monitor. The installer adds a Teensy-specific monitor, so the non-Serial USB Type options can work.

2: 1.8.19 has old pluggable discovery, Teensy package supports only pluggable discovery 1.0. Starting around 1.8.15 or 1.8.16, an earlier version of pluggable discovery was added, inspired by the Teensy-specific discover the installers added to the older IDEs. But pre-2.0.0 pluggable discovery used a different protocol. The Boards Manager package files have a new pluggable discovery tool which doesn't support the old version which Arduino never documented (other than of course publishing the Java source code).

3: Java serial monitor is far too slow. On Windows the whole IDE crashes if Teensy 4 runs a simple program which prints at maximum speed. The installer adds a huge patch to allow the serial monitor to keep up (more or less, imperfect as data loss can occur, but it keeps the IDE from running out of memory and crashing).

Arduino 2.0.0 (and the many beta tests leading up to it) was the first version of Arduino IDE to provide enough functionality for Teensy to use the Boards Manager packaging. All prior versions need the installer to patch the Java code.
 
Well pooh,
Found a little issue with new toolchain?. running blink on bare 4.0

Code:
MHz	1.8.15	2.0.5/1.58
24	34mA	106mA
600	96mA	110mA

Stranger, a very large program draws ~96mA
 
Any reason why FASTRUN is not working anymore on 1.58?

I get this error:
Code:
sketch_apr12b:11:1: error: 'FASTRUN' does not name a type

Was the attribute removed from 1.58?
It's a MacbookPro 16" M1 Pro with a fresh installed on Teensyduino 1.58
 
FASTRUN has little use on T_4.x as all code defaults to processor speed RAM in ITCM RAM1.

FASTRUN does have placement specifics at times. Is the code syntactically correct?

This builds here in IDE 2.0.4 to a T_4.1 and also IDE 1.8.19 both with TD 1.59b2:
Code:
FASTRUN void aFoo() {
  Serial.println("aFoo here ");
}

elapsedMillis timeout;

void setup() {
  Serial.begin(115200);
  while (!Serial && millis() < 4000)
    ;
  Serial.println("\n" __FILE__ " " __DATE__ " " __TIME__);
  pinMode(13, OUTPUT);
  Serial.print("begin loop speed test, F_CPU = ");
  Serial.println(F_CPU);
  timeout = 0;
}

void loop() {
  static unsigned int loopcount = 0;
  loopcount++;
  digitalToggleFast(13);  // measure pin 13 frequency
  if (timeout >= 1000) {
    timeout = 0;
    Serial.print("loop/sec = ");
    Serial.println(loopcount);
    loopcount = 0;
    aFoo();
  }
}

Code:
C:\Users\Tim\AppData\Local\Temp\.arduinoIDE-unsaved2023311-65972-8zop9n.gpzgr\sketch_apr11b\sketch_apr11b.ino Apr 12 2023 00:02:58
begin loop speed test, F_CPU = 24000000
loop/sec = 599218
aFoo here 
loop/sec = 599222
aFoo here 
...
 
I suspect that I did not select the Teensy board and that’s why
It was late and I was definitely (and still am) missing sleep hours
 
Putting LIN lin(&Serial3, 19200); inside the setup works ok but I can't access it in the main loop.

I have to recompile the code and comment out the LIN lin(&Serial3, 19200) and upload again to get the crash report.

Code:
CrashReport:
  A problem occurred at (system time) 19:17:32
  Code was executing from address 0x620
  CFSR: 82
    (DACCVIOL) Data Access Violation
    (MMARVALID) Accessed Address: 0x10 (nullptr)
      Check code at 0x620 - very likely a bug!
      Run "addr2line -e mysketch.ino.elf 0x620" for filename & line number.
  Temperature inside the chip was 50.69 °C
  Startup CPU clock speed is 600MHz

Library is updated with the code from KurtE
 
Problem to get a teensy++2 recognized (Arduino2.2.0, Teensyduino 1.58, Win10)

Hello,

I encounter a problem on a win10 laptop to get a teensy++2 recognized:

- I have installed Aduino IDE 2.2.0
- I have downloaded TeensyduinoInstall.exe (from https://www.pjrc.com/teensy/td_158/) and I did run it.
- I have copied the link "https://www.pjrc.com/teensy/package_teensy_index.json" to "additional board manager URL's" within the "preference" of arduino2.2
When I launch Arduino 2.2.0, is asks for the com port; I then plug a teensy++2 . It is seen as com3 on the Arduino IDE.
But on the "board manager", the keyword "teensy" gives no result:

-> I am unable to get the board recognized.

help !
 
Hello,

I precisely did that !

- I have pasted the link https://www.pjrc.com/teensy/package_teensy_index.json to "additional board manager URL's" within the "preference" of arduino2.2
- and in the main Arduino2.0 window, opened the Boards Manager by clicking the left-side board icon;

But the search for "teensy" gives no result... hence impossible to and click "Install".
 
Sorry, you said that you had downloaded Teensduino.exe. You don't need that for Arduino 2.
I am still on Arduino 1.18, with VisualMicro, so I will be unable to help further, not having experienced Arduino 2.
Sorry.
 
Back
Top