Forum Rule: Always post complete source code & details to reproduce any issue!
Page 8 of 8 FirstFirst ... 6 7 8
Results 176 to 186 of 186

Thread: Teensyduino 1.54 Beta #5

  1. #176
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,462
    Quote Originally Posted by Frank B View Post
    But, really, I don't know what the plan is.
    I do have a plan (kinda 2 plans), but so far haven't written anything....

    1: For the wav file player and other file-based audio library stuff, I'm planning to add a useFilesystem(FS &filesys) function, which would store "filesys" into a FS pointer, and of course use that pointer rather than hard coding SD.

    2: For a unified unix-like virtual filesystem, which as I understand is done on ESP and maybe circuit python, I'm imagining another library which inherits FS and its own specialization of File. You would still create instances of SD, LittleFS, SerialFlash (when/if it's ported to FS & File) and then give references to those and mount folder strings to this special wrapper filesystem. Whether we really ever need that, I do not know.

    The main plan is to use #1 and so #2 isn't necessarily needed just for libraries like Audio, unless we really want a unix-like virtual filesystem for something #1 can't do.

  2. #177
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    7,642
    That sounds like a good plan.
    Perhaps I can add the SPIFFS then, too.. in a few months.
    Actually, it should be possible to integrate USB drives, simple network file systems, etc. with it...

  3. #178
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    6,111
    Quote Originally Posted by PaulStoffregen View Post
    I do have a plan (kinda 2 plans), but so far haven't written anything....

    1: For the wav file player and other file-based audio library stuff, I'm planning to add a useFilesystem(FS &filesys) function, which would store "filesys" into a FS pointer, and of course use that pointer rather than hard coding SD.

    2: For a unified unix-like virtual filesystem, which as I understand is done on ESP and maybe circuit python, I'm imagining another library which inherits FS and its own specialization of File. You would still create instances of SD, LittleFS, SerialFlash (when/if it's ported to FS & File) and then give references to those and mount folder strings to this special wrapper filesystem. Whether we really ever need that, I do not know.

    The main plan is to use #1 and so #2 isn't necessarily needed just for libraries like Audio, unless we really want a unix-like virtual filesystem for something #1 can't do.
    #1 I think is along the same lines as was done in MTP in the storage class:
    Code:
     
      uint32_t addFilesystem(FS &fs, const char *name) {return sd_addFilesystem(fs, name);}
    ........
       uint32_t sd_addFilesystem(FS &fs, const char *name) {
          if (fsCount < MTPD_MAX_FILESYSTEMS) {
            sd_name[fsCount] = name;
            sdx[fsCount] = &fs;
            return fsCount++;
          }
          return 0xFFFFFFFFUL;  // no room left
        }
    but of course much simpler. Agree with Frank - sounds like a plan.

  4. #179
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    7,642
    Quote Originally Posted by defragster View Post
    Things like that seem like a good addition to take the mystery out of a Teensy that 'just stops' - it doesn't generally happen - but when such things do happen it is an opaque puzzle.

    And future more complex Teensy might even have more use for it.
    I have an Idea.. I could extend the Hardfaults for a kind of "user" exceptions.
    It would need a macro that prints the userdefined text together with the GCC macros
    __FILE__, __func__, __LINE__

    It would work like the existing Hardfaults I proposed, and could be used in the core, too (I think, the core - and libraries - are the main use-case - on other places a simple "printf" would do it too.)

    So it would be possible to do something like die("No DMA Channel available"); or die("Hardwareserial: Wrong Pin#")...and we can use Watchdogs, which die("Watchdog starved")

    Edit: And look like
    Code:
    c:\foo\greatest_off_all_c_file.c
    Line: 47
    Function: "setup" died. 
    Last words: "Negative Baudrates not supported by Hardwareserial"
    Last edited by Frank B; 01-16-2021 at 11:34 PM.

  5. #180
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    13,182
    Quote Originally Posted by Frank B View Post
    I have an Idea.. I could extend the Hardfaults for a kind of "user" exceptions.
    It would need a macro that prints the userdefined text together with the GCC macros
    __FILE__, __func__, __LINE__

    It would work like the existing Hardfaults I proposed, and could be used in the core, too (I think, the core - and libraries - are the main use-case - on other places a simple "printf" would do it too.)

    So it would be possible to do something like die("No DMA Channel available"); or die("Hardwareserial: Wrong Pin#")...and we can use Watchdogs, which die("Watchdog starved")
    Anything that provides simple info logging would be cool. As noted your On_Restart T_4 display is an awesome extension for HardFaults.

    That's where I got bogged down - tying to add generic debug stuff to HardFault handing and trying to print in either case - which often worked ...

    "die" is cool Would be nice to have an Assert too - though that isn't always fatal.

    Not seeing a lot of folks jumping up and down about how cool this is - not often needed - but when it would help it can save lots of wonder about the trouble and help with a quick resolution.

  6. #181
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,462
    Quote Originally Posted by Frank B View Post
    Actually, it should be possible to integrate USB drives, simple network file systems, etc. with it...
    Yup, that's been the plan all along.

  7. #182
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    7,642
    Quote Originally Posted by Frank B View Post
    I have an Idea.. I could extend the Hardfaults for a kind of "user" exceptions.
    It would need a macro that prints the userdefined text together with the GCC macros
    __FILE__, __func__, __LINE__
    Probably similar to this:
    Code:
    //Macro test
    //#define DIE_WITH_PATH
    
    #if !defined(DIE_WITH_PATH)
    #define _FILENAME_ (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 : (__builtin_strrchr(__FILE__, '\\') ? __builtin_strrchr(__FILE__, '\\') + 1 : __FILE__) )
    #define DIE(msg) _die(_FILENAME_, __func__, __LINE__, msg)
    #else
    #define DIE(msg) _die(__FILE__, __func__, __LINE__, msg)
    #endif
    
    FLASHMEM
    void _die(const char *file, const char *func, unsigned line, const char *msg)
    {
    //Testing only. This should reset and print these texts _after_that.
    //Does not use printf on purpose.
     while(!Serial);
     Serial.println(file); 
     Serial.print("Function \"");
     Serial.print(func);
     Serial.print("\" died in line ");
     Serial.println(line);
     if ( msg != nullptr ) {
      Serial.print("Last words:\"");
      Serial.print(msg);
      Serial.print("\"\n");
     } 
     while(1) asm("wfi");
    }
    
    void setup() {DIE("I felt it was time.");}
    void loop() {}
    Last edited by Frank B; 01-17-2021 at 10:03 AM.

  8. #183
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    7,642
    I added DIE:
    https://github.com/FrankBoesing/cores/tree/hardfaults

    Code:
    void setup() { DIE("I felt it was time."); }
    void loop() {}
    resets and prints:
    Code:
    sketch_jan17a.ino
    Function "setup" died in line 1
    Last words:"I felt it was time."
    stopping working,commenting at this, and disturbing this thread until its clear that this gets merged or not
    I don't care that much if in the end it will be my solution or something different. But we need *something*. It will greatly reduce amount of forum questions where Teensy just dies silently.
    Maybe we need to add something for USB-Types where Serial is not available.
    Last edited by Frank B; 01-17-2021 at 11:36 AM.

  9. #184
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    7,642

    Teensy LC Audio, Input Slave with SGTL

    Hi Paul,

    i *think* the I2S slave-input works now, too.
    I have some problems with my hardware.. need to check the soldering of the microphone or have to connect a line-in somehow (I never use the input)
    I've just uploaded - I think it is not *that* important and maybe check it later. I hear some noise and can hear when I touch the microphone. So far a good sign - maybe it works
    maybe you want to check it when you have more time.
    Code:
    //Teensy LC SGTL-5000 test *input*
    #include <Audio.h>
    
    AudioInputI2Sslave       i2sslave1;
    AudioOutputI2Sslave      i2sslave2;
    AudioConnection          patchCord2(i2sslave1, 0, i2sslave2, 0);
    AudioConnection          patchCord3(i2sslave1, 1, i2sslave2, 1);
    AudioControlSGTL5000     sgtl5000_1;
    
    void setup() {  
      AudioMemory(8);
      sgtl5000_1.enable();
      sgtl5000_1.inputSelect(AUDIO_INPUT_MIC);
      //sgtl5000_1.micGain(63);
      sgtl5000_1.volume(0.7);
    }
    
    void loop() {}
    Code:
    Globale Variablen verwenden 6744 Bytes (82%) des dynamischen Speichers, 1448 Bytes für lokale Variablen verbleiben. Das Maximum sind 8192 Bytes.
    I2S input as "Master" is still TBD. Is there any use-case for this? (16MHz MCLK)


    Edit: Fixed the Mic. The I2S-slave code works.
    Edit: I2S-Master-Input added, but is untested.
    Last edited by Frank B; 01-18-2021 at 02:11 PM.

  10. #185
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    7,642

  11. #186
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany
    Posts
    7,642
    Hi Paul

    do you have some time next week to merge some PRs?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •