debugging.......

Status
Not open for further replies.

snowsh

Well-known member
looking for pointers....

So I have a project that has got pretty large.

Apart from Serial.print to dump out debug info, how can I get more insight into what is going on in my program. As I code I have moments where the whole thing slows down, write some more code and the slow down vanishes. I am at about 43% dynamic memory usage, only 2% or program storage space.

Are there any tips on how to identify if memory is getting shifted around in the cache maybe?
 
You can add lots of timing calls before and after subroutines or sections of code. Eventually you will know where it's spending so much time.
 
Not indicated what Teensy model #.# ??

The only model with real cache is T_4.x and all RAM1 code and Data are full speed not cached - only RAM2/DMAMEM goes through cache
 
Not indicated what Teensy model #.# ??

The only model with real cache is T_4.x and all RAM1 code and Data are full speed not cached - only RAM2/DMAMEM goes through cache

4.1 with 8meg EXTRAM upgrade. I have had these odd moments throughout the last 4 months of developing this code. sometimes it just hits these lags, I continue and it goes away. I am reaching a point I really need to understand why.
 
sometimes it just hits these lags

Update to version 1.54.

Frank fixed a bug where we had overlapping MPU regions which caused some programs to experience a 1.7 second stall. Difficult to say if that's really the cause of the lags you're seeing - but it's a known bug in 1.53 and earlier which has been fixed in 1.54.
 
Update to version 1.54.

Frank fixed a bug where we had overlapping MPU regions which caused some programs to experience a 1.7 second stall. Difficult to say if that's really the cause of the lags you're seeing - but it's a known bug in 1.53 and earlier which has been fixed in 1.54.

ah, I will check that right now...
 
fileSystem: In function 'void saveConfigToSD()':
fileSystem:1135: error: 'File' was not declared in this scope
File sdfile; // File object
^
fileSystem:1138: error: 'sdfile' was not declared in this scope
sdfile = SD.open( fname, FILE_WRITE );
^

why would updating teensyduino cause this?
 
From deleted post:
Code:
Multiple libraries were found for "SdFat.h"
Used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SdFat

fileSystem: In function 'void saveConfigToSD()':
fileSystem:1135: error: 'File' was not declared in this scope
File sdfile; // File object
^
fileSystem:1138: error: 'sdfile' was not declared in this scope
sdfile = SD.open( fname, FILE_WRITE );
^

why would updating teensyduino cause this?

TD 1.54 also integrated SdFat into use wrapped by standard SD.h

Is there a local copy of SdFat in sketchbook\libraries? If so remove that. Done?

Show the verbose list of Libraries "Used: ..."
 
can of worms! So I have done a full fresh install of the latest arduino IDE, teensyduino......

here are my includes:


Code:
//------------------------------------------------------------------------  includes

#include <WS2812Serial.h>
#include <Wire.h>
#include <SPI.h>

//#include <SD.h>
#include <SdFat.h>
SdFat SD;

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <MIDI.h>
#include <USBHost_t36.h>

I compile and get this these errors:

Code:
fileSystem: In function 'void saveConfigToSD()':
fileSystem:1135: error: 'File' was not declared in this scope
   File  sdfile;                                                             // File object
   ^
fileSystem:1138: error: 'sdfile' was not declared in this scope
   sdfile = SD.open( fname, FILE_WRITE );
   ^
fileSystem: In function 'void saveChannelToSd(uint8_t)':
fileSystem:1151: error: 'File' was not declared in this scope
   File  sdfile;                                                             // File object
   ^
fileSystem:1154: error: 'sdfile' was not declared in this scope
   sdfile = SD.open( fname, FILE_WRITE );
   ^
fileSystem: In function 'void saveGenerativeToSD(int)':
fileSystem:1166: error: 'File' was not declared in this scope
   File  sdfile;                                                             // File object
   ^
fileSystem:1169: error: 'sdfile' was not declared in this scope
   sdfile = SD.open( fname, FILE_WRITE );
   ^
fileSystem: In function 'void saveAsciiPatternToSd(uint8_t)':
fileSystem:1181: error: 'File' was not declared in this scope
   File  sdfile;                                                             // File object
   ^
fileSystem:1184: error: 'sdfile' was not declared in this scope
   sdfile = SD.open( fname, FILE_WRITE );
   ^
fileSystem: In function 'void saveEuclideanToSd(uint8_t)':
fileSystem:1196: error: 'File' was not declared in this scope
   File  sdfile;                                                             // File object
   ^
fileSystem:1199: error: 'sdfile' was not declared in this scope
   sdfile = SD.open( fname, FILE_WRITE );
   ^
fileSystem: In function 'void saveVennEuclideanColliderToSd(uint8_t)':
fileSystem:1211: error: 'File' was not declared in this scope
   File  sdfile;                                                             // File object
   ^
fileSystem:1214: error: 'sdfile' was not declared in this scope
   sdfile = SD.open( fname, FILE_WRITE );
   ^
fileSystem: In function 'void savePlanetaryToSD(uint8_t)':
fileSystem:1231: error: 'File' was not declared in this scope
   File  sdfile;                                                             // File object
   ^
fileSystem:1234: error: 'sdfile' was not declared in this scope
   sdfile = SD.open( fname, FILE_WRITE );
   ^
fileSystem: In function 'void saveParticlesToSD(uint8_t)':
fileSystem:1246: error: 'File' was not declared in this scope
   File  sdfile;                                                             // File object
   ^
fileSystem:1249: error: 'sdfile' was not declared in this scope
   sdfile = SD.open( fname, FILE_WRITE );
   ^
fileSystem: In function 'void saveDrummerPatternSD(int)':
fileSystem:1278: error: 'File' was not declared in this scope
   File  sdfile;                                                                   // File object
   ^
fileSystem:1286: error: 'sdfile' was not declared in this scope
   sdfile = SD.open( fname, FILE_WRITE );
   ^
fileSystem: In function 'void saveDrummerKitSD(int)':
fileSystem:1303: error: 'File' was not declared in this scope
   File  sdfile;                                                                   // File object
   ^
fileSystem:1307: error: 'sdfile' was not declared in this scope
   sdfile = SD.open( fname, FILE_WRITE );
   ^
fileSystem: In function 'void save303PatternSD(int)':
fileSystem:1321: error: 'File' was not declared in this scope
   File  sdfile;                                                             // File object
   ^
fileSystem:1324: error: 'sdfile' was not declared in this scope
   sdfile = SD.open( fname, FILE_WRITE );
   ^
fileSystem: In function 'void saveTicTacToeSettingsToSd(uint8_t)':
fileSystem:1366: error: 'File' was not declared in this scope
   File  sdfile;                                                             // File object
   ^
fileSystem:1369: error: 'sdfile' was not declared in this scope
   sdfile = SD.open( fname, FILE_WRITE );
   ^
fileSystem: In function 'void saveTicTacToeGamesToSd(uint8_t)':
fileSystem:1381: error: 'File' was not declared in this scope
   File  sdfile;                                                             // File object
   ^
fileSystem:1384: error: 'sdfile' was not declared in this scope
   sdfile = SD.open( fname, FILE_WRITE );
   ^
fileSystem: In function 'void saveDrummerPatternSD_WORKINPROGRESS(int)':
fileSystem:1418: error: 'File' was not declared in this scope
   File  sdfile;                                                                   // File object
   ^
fileSystem:1450: error: 'sdfile' was not declared in this scope
   sdfile = SD.open( fname, FILE_WRITE );
   ^
fileSystem: In function 'void sdOpenInitFile()':
fileSystem:1539: error: 'File' was not declared in this scope
   File  sdfile;                                                                   // File object
   ^
fileSystem:1543: error: 'sdfile' was not declared in this scope
   sdfile = SD.open( INIT_PATH, FILE_READ );                                           // try to open text.asq  // ========== SD open file to read ====================================
   ^
fileSystem: In function 'void sdOpenConfigFile(int)':
fileSystem:1595: error: 'File' was not declared in this scope
   File  sdfile;                                                                   // File object
   ^
fileSystem:1602: error: 'sdfile' was not declared in this scope
   sdfile = SD.open( fname, FILE_READ );                                           // try to open text.asq  // ========== SD open file to read ====================================
   ^
fileSystem: In function 'void sdOpen303File(int, int)':
fileSystem:1636: error: 'File' was not declared in this scope
   File  sdfile;                                                                   // File object
   ^
fileSystem:1640: error: 'sdfile' was not declared in this scope
   sdfile = SD.open( fname, FILE_READ );                                           // try to open text.asq  // ========== SD open file to read ====================================
   ^
fileSystem: In function 'void sdOpenDrummerFile(int, int)':
fileSystem:1674: error: 'File' was not declared in this scope
   File  sdfile;                                                                   // File object
   ^
fileSystem:1678: error: 'sdfile' was not declared in this scope
   sdfile = SD.open( fname, FILE_READ );                                           // try to open text.asq  // ========== SD open file to read ====================================
   ^
fileSystem: In function 'void sdOpenDrummerKitFile(int, int)':
fileSystem:1820: error: 'File' was not declared in this scope
   File  sdfile;                                                                   // File object
   ^
fileSystem:1824: error: 'sdfile' was not declared in this scope
   sdfile = SD.open( fname, FILE_READ );                                           // try to open text.asq  // ========== SD open file to read ====================================
   ^
fileSystem: In function 'void writeNames(int)':
fileSystem:2032: error: 'File' was not declared in this scope
   File  sdfile;                                                             // File object
   ^
fileSystem:2036: error: 'sdfile' was not declared in this scope
   sdfile = SD.open( fname, FILE_WRITE );
   ^
fileSystem: In function 'void sdOpenFile(int, int)':
fileSystem:2048: error: 'File' was not declared in this scope
   File  sdfile;
   ^
fileSystem:2052: error: 'sdfile' was not declared in this scope
   sdfile = SD.open( fname, FILE_READ );
   ^
fileSystem: In function 'void writeInitFile()':
fileSystem:2091: error: 'File' was not declared in this scope
   File  sdfile;
   ^
fileSystem:2093: error: 'sdfile' was not declared in this scope
   sdfile = SD.open( INIT_PATH, FILE_WRITE );
   ^
Multiple libraries were found for "SdFat.h"
 Used: C:\Users\nick\OneDrive\Documents\Arduino\libraries\SdFat
 Not used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SdFat
'File' was not declared in this scope



If I adjust the includes:

Code:
//------------------------------------------------------------------------  includes

#include <WS2812Serial.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
//#include <SdFat.h>
//SdFat SD;


#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <MIDI.h>
#include <USBHost_t36.h>

I get this:

Code:
display: In function 'void displaySaveSong()':
display:878: error: no matching function for call to 'SDClass::begin(SdioConfig)'
     cardStatus = SD.begin(SdioConfig(FIFO_SDIO));                             // try to begins a new SD session
                                                ^
In file included from C:\Users\nick\OneDrive\Documents\Arduino\projects\ASeqCII project\ASeqCII_V1_26072021\ASeqCII_V1_26072021.ino:21:0:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\src/SD.h:149:7: note: candidate: bool SDClass::begin(uint8_t)
  bool begin(uint8_t csPin = 10) {
       ^
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\src/SD.h:149:7: note:   no known conversion for argument 1 from 'SdioConfig' to 'uint8_t {aka unsigned char}'
display: In function 'void displayLoadSong()':
display:898: error: no matching function for call to 'SDClass::begin(SdioConfig)'
     cardStatus = SD.begin(SdioConfig(FIFO_SDIO));                             // try to begins a new SD session
                                                ^
In file included from C:\Users\nick\OneDrive\Documents\Arduino\projects\ASeqCII project\ASeqCII_V1_26072021\ASeqCII_V1_26072021.ino:21:0:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\src/SD.h:149:7: note: candidate: bool SDClass::begin(uint8_t)
  bool begin(uint8_t csPin = 10) {
       ^
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\src/SD.h:149:7: note:   no known conversion for argument 1 from 'SdioConfig' to 'uint8_t {aka unsigned char}'
fileSystem: In function 'void mySdBegin()':
fileSystem:280: error: no matching function for call to 'SDClass::begin(SdioConfig)'
   cardStatus = SD.begin(SdioConfig(FIFO_SDIO));
                                              ^
In file included from C:\Users\nick\OneDrive\Documents\Arduino\projects\ASeqCII project\ASeqCII_V1_26072021\ASeqCII_V1_26072021.ino:21:0:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\src/SD.h:149:7: note: candidate: bool SDClass::begin(uint8_t)
  bool begin(uint8_t csPin = 10) {
       ^
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\src/SD.h:149:7: note:   no known conversion for argument 1 from 'SdioConfig' to 'uint8_t {aka unsigned char}'
Multiple libraries were found for "SD.h"
 Used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD
 Not used: C:\Program Files (x86)\Arduino\libraries\SD
Multiple libraries were found for "SdFat.h"
 Used: C:\Users\nick\OneDrive\Documents\Arduino\libraries\SdFat
 Not used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SdFat
no matching function for call to 'SDClass::begin(SdioConfig)'

3rd variation:

Code:
//------------------------------------------------------------------------  includes

#include <WS2812Serial.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
//#include <SdFat.h>
SdFat SD;

//#include "SdFat.h"
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <MIDI.h>
#include <USBHost_t36.h>

errors:

Code:
ASeqCII_V1_26072021:23: error: conflicting declaration 'SdFat SD'
 SdFat SD;
       ^
In file included from C:\Users\nick\OneDrive\Documents\Arduino\projects\ASeqCII project\ASeqCII_V1_26072021\ASeqCII_V1_26072021.ino:21:0:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\src/SD.h:194:16: note: previous declaration as 'SDClass SD'
 extern SDClass SD;
                ^
display: In function 'void displaySaveSong()':
display:878: error: no matching function for call to 'SDClass::begin(SdioConfig)'
     cardStatus = SD.begin(SdioConfig(FIFO_SDIO));                             // try to begins a new SD session
                                                ^
In file included from C:\Users\nick\OneDrive\Documents\Arduino\projects\ASeqCII project\ASeqCII_V1_26072021\ASeqCII_V1_26072021.ino:21:0:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\src/SD.h:149:7: note: candidate: bool SDClass::begin(uint8_t)
  bool begin(uint8_t csPin = 10) {
       ^
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\src/SD.h:149:7: note:   no known conversion for argument 1 from 'SdioConfig' to 'uint8_t {aka unsigned char}'
display: In function 'void displayLoadSong()':
display:898: error: no matching function for call to 'SDClass::begin(SdioConfig)'
     cardStatus = SD.begin(SdioConfig(FIFO_SDIO));                             // try to begins a new SD session
                                                ^
In file included from C:\Users\nick\OneDrive\Documents\Arduino\projects\ASeqCII project\ASeqCII_V1_26072021\ASeqCII_V1_26072021.ino:21:0:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\src/SD.h:149:7: note: candidate: bool SDClass::begin(uint8_t)
  bool begin(uint8_t csPin = 10) {
       ^
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\src/SD.h:149:7: note:   no known conversion for argument 1 from 'SdioConfig' to 'uint8_t {aka unsigned char}'
fileSystem: In function 'void mySdBegin()':
fileSystem:280: error: no matching function for call to 'SDClass::begin(SdioConfig)'
   cardStatus = SD.begin(SdioConfig(FIFO_SDIO));
                                              ^
In file included from C:\Users\nick\OneDrive\Documents\Arduino\projects\ASeqCII project\ASeqCII_V1_26072021\ASeqCII_V1_26072021.ino:21:0:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\src/SD.h:149:7: note: candidate: bool SDClass::begin(uint8_t)
  bool begin(uint8_t csPin = 10) {
       ^
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\src/SD.h:149:7: note:   no known conversion for argument 1 from 'SdioConfig' to 'uint8_t {aka unsigned char}'
Multiple libraries were found for "SD.h"
 Used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD
 Not used: C:\Program Files (x86)\Arduino\libraries\SD
Multiple libraries were found for "SdFat.h"
 Used: C:\Users\nick\OneDrive\Documents\Arduino\libraries\SdFat
 Not used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SdFat
conflicting declaration 'SdFat SD'


I have gone cross eyed.....
 
Last edited:
Update to version 1.54.

Frank fixed a bug where we had overlapping MPU regions which caused some programs to experience a 1.7 second stall. Difficult to say if that's really the cause of the lags you're seeing - but it's a known bug in 1.53 and earlier which has been fixed in 1.54.

I think Paul is on the right track here... "overlapping MPU regions" Since working with WS2812Serial and DMA I have been seeing some weird things happen. memory getting overwritten where it shouldnt etc.... So I hope this new TD version will solve allot of my issues.....
 
I removed C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SdFat

Code:
//------------------------------------------------------------------------  includes

#include <WS2812Serial.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
//#include <SdFat.h>
SdFat SD;

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <MIDI.h>
#include <USBHost_t36.h>

now this:

Code:
ASeqCII_V1_26072021:23: error: conflicting declaration 'SdFat SD'
 SdFat SD;
       ^
In file included from C:\Users\nick\OneDrive\Documents\Arduino\projects\ASeqCII project\ASeqCII_V1_26072021\ASeqCII_V1_26072021.ino:21:0:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\src/SD.h:194:16: note: previous declaration as 'SDClass SD'
 extern SDClass SD;
                ^
display: In function 'void displaySaveSong()':
display:878: error: no matching function for call to 'SDClass::begin(SdioConfig)'
     cardStatus = SD.begin(SdioConfig(FIFO_SDIO));                             // try to begins a new SD session
                                                ^
In file included from C:\Users\nick\OneDrive\Documents\Arduino\projects\ASeqCII project\ASeqCII_V1_26072021\ASeqCII_V1_26072021.ino:21:0:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\src/SD.h:149:7: note: candidate: bool SDClass::begin(uint8_t)
  bool begin(uint8_t csPin = 10) {
       ^
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\src/SD.h:149:7: note:   no known conversion for argument 1 from 'SdioConfig' to 'uint8_t {aka unsigned char}'
display: In function 'void displayLoadSong()':
display:898: error: no matching function for call to 'SDClass::begin(SdioConfig)'
     cardStatus = SD.begin(SdioConfig(FIFO_SDIO));                             // try to begins a new SD session
                                                ^
In file included from C:\Users\nick\OneDrive\Documents\Arduino\projects\ASeqCII project\ASeqCII_V1_26072021\ASeqCII_V1_26072021.ino:21:0:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\src/SD.h:149:7: note: candidate: bool SDClass::begin(uint8_t)
  bool begin(uint8_t csPin = 10) {
       ^
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\src/SD.h:149:7: note:   no known conversion for argument 1 from 'SdioConfig' to 'uint8_t {aka unsigned char}'
fileSystem: In function 'void mySdBegin()':
fileSystem:280: error: no matching function for call to 'SDClass::begin(SdioConfig)'
   cardStatus = SD.begin(SdioConfig(FIFO_SDIO));
                                              ^
In file included from C:\Users\nick\OneDrive\Documents\Arduino\projects\ASeqCII project\ASeqCII_V1_26072021\ASeqCII_V1_26072021.ino:21:0:
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\src/SD.h:149:7: note: candidate: bool SDClass::begin(uint8_t)
  bool begin(uint8_t csPin = 10) {
       ^
C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD\src/SD.h:149:7: note:   no known conversion for argument 1 from 'SdioConfig' to 'uint8_t {aka unsigned char}'
Multiple libraries were found for "SD.h"
 Used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\SD
 Not used: C:\Program Files (x86)\Arduino\libraries\SD
conflicting declaration 'SdFat SD'
 
got it.....

Looked at the new examples for SD....... SdFat_Usage.ino

needed to update:

Code:
SD.begin

to

Code:
  // Access the built in SD card on Teensy 3.5, 3.6, 4.1 using FIFO
  //ok = SD.sdfs.begin(SdioConfig(FIFO_SDIO));

SD.sdfs.begin

Oh! Look at all that new info from TD!:


Code:
Memory Usage on Teensy 4.1:
  FLASH: code:175236, data:50636, headers:8620   free for files:7891972
   RAM1: variables:70624, code:163400, padding:440   free for local variables:289824
   RAM2: variables:21024  free for malloc/new:503264
 EXTRAM: variables:175456

good stuff..... Noticed on Arduino there is V2 coming.... Im not going to bother with the Beta but certainly the list of new features looks exciting.

Well, it compiled... now to spend the rest of the day testing......
 
Great you got to a solution!
Reply a bit short as was time to go offline here when posted - you found the Nice example of ... SdFat_Usage.ino

PJRC hasn't committed to Arduino V2 AFAIK ... but until that appears it won't work for Teensy - at least not as a standard supported IDE.
 
Great you got to a solution!
Reply a bit short as was time to go offline here when posted - you found the Nice example of ... SdFat_Usage.ino

PJRC hasn't committed to Arduino V2 AFAIK ... but until that appears it won't work for Teensy - at least not as a standard supported IDE.

Well I got it to complie. But I am still having a slow down. I have isolated to one section of my project, wading through now.
 
well I found this particular issue. This week I added serial midi with 5 pin din. I had been using just usb until now. I was working on another area in my project and of course neglected to test all areas after adding support for serial midi too.

one of my all notes off functions was being funny - not at all noticable over USB but when being used over the serial midi, it just caused the program to crawl.

Moral - developing is a pain. It is easy to move ahead to the next part without fully testing. this then leads to times of headscratching. I was about to pull the latest version of the code and go back a few days to. Instead I took a long walk - eyes off the screen and time to just think it over.....
 
Status
Not open for further replies.
Back
Top