Forum Rule: Always post complete source code & details to reproduce any issue!

Search:

Type: Posts; User: ftrias

Page 1 of 3 1 2 3

Search: Search took 0.00 seconds.

  1. Replies
    12
    Views
    2,947

    Compiling Rust code is possible, but not within...

    Compiling Rust code is possible, but not within the Arduino IDE [1]. You need to create a Makefile.

    For example, if you want to include a function from rust, you would code it as follows:


    ...
  2. Replies
    418
    Views
    84,193

    Looking at it now, it does seem like the priority...

    Looking at it now, it does seem like the priority thread support is not implemented very efficiently. If I recall, I added it at a later time. It was really just a way to give a boost to threads that...
  3. Replies
    17
    Views
    309

    Very interesting. You can, of course, add your...

    Very interesting. You can, of course, add your own implementation of the TeensyProf_open(), TeensyProf_close() and TeensyProf_write() functions to send the output to where you want. They're very...
  4. Replies
    17
    Views
    309

    You can look at TeensyFile.cpp for the very...

    You can look at TeensyFile.cpp for the very simple format used.

    You can also configure it to write out the file using hexadecimal and then use something like hex2bin to convert it to a file.
  5. Replies
    17
    Views
    309

    Yes. Don't use -pg on c or S files. Have you...

    Yes. Don't use -pg on c or S files.

    Have you tried it with the Arduino app, as described in README.md?

    Also, I'd like to see the complete command line options used for each compile to see if...
  6. Replies
    418
    Views
    84,193

    I suppose we could test more frequently, but it...

    I suppose we could test more frequently, but it may not make a difference. gprof is a sampling profiler so it relies on statistical distributions. If you run it for 1 minutes (60000 samples), it will...
  7. Replies
    17
    Views
    309

    That's a sophisticated Makefile. As a first...

    That's a sophisticated Makefile.

    As a first pass, remove FLAGS_COM from C_FLAGS and S_FLAGS. You probably don't want to put instrumentation on the core teensy files.

    Can you remove the "@"...
  8. Replies
    17
    Views
    309

    One theory: I believe this happens when you use...

    One theory: I believe this happens when you use the "-pg" option in the link stage. This is why the "boards.txt" file adds a new parameter "profile" with "-O0 -pg" and then only adds it in...
  9. Replies
    418
    Views
    84,193

    I think it would still be useful to see...

    I think it would still be useful to see per-thread CPU usage, but profiling is probably more useful.

    FYI, I just created a new TeensyGProf that's even better than TeensyProf. See...
  10. Replies
    17
    Views
    309

    Unsatisfied with the limits of this library, I...

    Unsatisfied with the limits of this library, I decided to do a more complete implementation of gprof. I used this previous work by Erich Styger as a guide:...
  11. Replies
    17
    Views
    309

    I forgot to mention this other modification: ...

    I forgot to mention this other modification:

    Modify `imxrt1062.ld` in the directory Arduino.../Contents/Java/hardware/teensy/avr/cores/teensy4. All references to `.text.itcm` must be changed to...
  12. Replies
    17
    Views
    309

    I should have explained more. When compiling...

    I should have explained more. When compiling ends, it copies the elf file to /tmp/build.elf. Then the program uploads and runs as normal. When the profiling ends, the Teensy (using the library) sends...
  13. Replies
    17
    Views
    309

    Profiling using gprof on Teensy 4

    I created a project to partially support gprof-style profiling of applications on Teensy 4. This shows how much time is spent in each function. In theory, this could also work on Teensy 3, but it...
  14. Replies
    418
    Views
    84,193

    This is an excellent idea. I committed a change...

    This is an excellent idea. I committed a change along your suggestion: https://github.com/ftrias/TeensyThreads/commit/ef3ef46441ea79d4849a674325685c7cb531905e

    If you uncomment '#define DEBUG' in...
  15. Replies
    418
    Views
    84,193

    I committed this to my github:...

    I committed this to my github: https://github.com/ftrias/TeensyThreads/commit/d61579a76428e59e9548204312a7b36da85df59c

    For Teensy 3, it works the same as before. For Teensy 4, it uses an unused...
  16. Replies
    418
    Views
    84,193

    The problem is the the context_switch_isr()...

    The problem is the the context_switch_isr() function as written must be called directly as an interrupt. It will unroll the special interrupt call stack frame to figure out where it was called from...
  17. Replies
    418
    Views
    84,193

    Paul was kind enough to send me a Teensy 4 so I...

    Paul was kind enough to send me a Teensy 4 so I was able to look into porting TeensyThreads. As a starting point, I used @mjs513's excellent code at...
  18. Replies
    418
    Views
    84,193

    Thanks, @mjs513, for porting the library to the...

    Thanks, @mjs513, for porting the library to the T4. Your changes look great. However, I do not currently own a T4 so I haven't tested them. I will try to buy one soon and try it out.
  19. Replies
    418
    Views
    84,193

    Thank you for looking at the code and pointing...

    Thank you for looking at the code and pointing out these very interesting optimizations. It has been over 2 years since I wrote this code so I'm don't recall many of the specifics. Can you create a...
  20. Faint high pitch noise when using Audio Board & USB

    There is a very faint continuous high pitch noise when I'm using the Teensy Audio board and USB Audio as an input device to the computer.

    I have a Teensy 3.1. Arduino 1.8.8. Teensyduino 1.4.5....
  21. Replies
    418
    Views
    84,193

    noInterrupts()/interrupts() will stop all thread...

    noInterrupts()/interrupts() will stop all thread switches (and all other interrupts). So it should be ok.
  22. Semihosting and creating files on host computer

    Is there a simple way to have Teensy open and write files on a connected computer, similar to the way Semihosting (http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0471g/Bgbjjgij.html)...
  23. Replies
    418
    Views
    84,193

    Yes because they do different things. Maybe it...

    Yes because they do different things. Maybe it was a mistake to call it "threads.yield()". The "yield()" function in Teensy flushes out the serial devices and does other housekeeping chores. It's...
  24. Thread: Arduino Events

    by ftrias
    Replies
    118
    Views
    40,479

    Due to a long-forgotten modification in my test...

    Due to a long-forgotten modification in my test environment I didn't catch a problem with "chaining" the svcall_isr() interrupt. The default interrupt handler is unused_isr() and it causes the CPU to...
  25. Replies
    418
    Views
    84,193

    I don't think it's thread-safe. But if you call...

    I don't think it's thread-safe. But if you call it from only one thread, that should be OK. As far as I can see, yield() still calls Serial objects and it can't be run on two threads simultaneously....
  26. Thread: Arduino Events

    by ftrias
    Replies
    118
    Views
    40,479

    For the time being, I updated the TeensyThreads...

    For the time being, I updated the TeensyThreads library in github to save the previous systick_isr() and call it before doing it's thing, similar to the "chaining" discussed earlier in this thread....
  27. Thread: Arduino Events

    by ftrias
    Replies
    118
    Views
    40,479

    Although I did advocate for "chaining" interrupts...

    Although I did advocate for "chaining" interrupts before, UNCHAINING is a bad idea. This causes problems in the scenario where you chain an interrupt, and then another interrupt chains on yours. If...
  28. Replies
    32
    Views
    5,252

    That's right. It's the simplest implementation of...

    That's right. It's the simplest implementation of a Mutex and it provides no queueing or prioritization like a proper RTOS would provide.
  29. Replies
    32
    Views
    5,252

    // Long ago you could install your own systick...

    // Long ago you could install your own systick interrupt handler by just
    // creating your own systick_isr() function. No longer. But if you
    // *really* want to commandeer systick, you can still do...
  30. Replies
    32
    Views
    5,252

    In my experiences writing the TeensyThreads...

    In my experiences writing the TeensyThreads library, which provides pre-emptive multithreading, there are two basic problems that are solvable in the long run.

    1. System code is not thread safe
    ...
  31. Thread: Arduino Events

    by ftrias
    Replies
    118
    Views
    40,479

    Hooking systick_isr() is useful in many...

    Hooking systick_isr() is useful in many situations such as this (and in TeensyThreads and many others). Even with this approach of accessing _VectorsRam directly there is still a problem if two...
  32. Replies
    418
    Views
    84,193

    Detect stack overflow

    I'm considering adding support to detect stack overflows. With Teensy's small memory footprint, optimizing memory use seems important because it's easy to introduce undetected bugs if the stack...
  33. Replies
    418
    Views
    84,193

    The macro is a bit of a cludge that relies on...

    The macro is a bit of a cludge that relies on compiler tricks. It's there so you don't have to change all your calls to try the library. First, it hasn't been tested very well, so please let us all...
  34. Replies
    418
    Views
    84,193

    Returning to the problem of using too much memory...

    Returning to the problem of using too much memory for unused threads, I have made a small change in the library on Github. Before this change, the library would statically allocate the memory needed...
  35. Replies
    418
    Views
    84,193

    That's what it does right now. But perhaps...

    That's what it does right now.

    But perhaps there is some confusion. There are two things that need space. (1) The stack that stores variables as functions get called. So as one function calls...
  36. Replies
    418
    Views
    84,193

    Thanks for all your ideas. I guess 12K of storage...

    Thanks for all your ideas. I guess 12K of storage is a bit much if you're not using it all. Of course, the part between `__ARM_PCS_VFP ` is only compiled for CPUs with floating point, so for the...
  37. Replies
    418
    Views
    84,193

    Are you referring to the structure that holds the...

    Are you referring to the structure that holds the thread info that is now just a fixed-length array? Or something else?

    If there is demand for more than 10 simultaneous threads, then it might be...
  38. Replies
    418
    Views
    84,193

    What would also be helpful is if you can show the...

    What would also be helpful is if you can show the exact gcc command being executed. Since you are using a different build environment, it could be not passing the right -D or other options.
  39. Replies
    418
    Views
    84,193

    @Detroit_Aristo - thanks for the additional info....

    @Detroit_Aristo - thanks for the additional info. I think generally in this forum we assume people are using Arduino and the Teensyduino libraries and compiler, and unmodified libraries, so if...
  40. Replies
    418
    Views
    84,193

    Are you referring to the color of keywords being...

    Are you referring to the color of keywords being off in the lower screen? This could be a problem in the code syntax in the headers or perhaps conflicting #defines. What editor are you using? Is it...
  41. Replies
    418
    Views
    84,193

    Although I haven't tried it from an ISR, if you...

    Although I haven't tried it from an ISR, if you pass the `stack` and `stack_size` parameters to the addThread(), there won't be any calls to malloc/new. You just need to allocate and delete it...
  42. Replies
    418
    Views
    84,193

    This should be possible. You can create...

    This should be possible. You can create std::thread objects using the "new" operator.

    However, there are a few problems with your code. First, the function you call has to be static. That means it...
  43. Replies
    418
    Views
    84,193

    I did not see Zilch when I looked at the problem...

    I did not see Zilch when I looked at the problem of threading before creating TeensyThreads. As you note, the difference is that TeensyThreads is pre-emptive and more akin to threads in desktop...
  44. Replies
    418
    Views
    84,193

    In a case like this, you might be better off with...

    In a case like this, you might be better off with accessing the Mutex directly.



    void readSensor() {
    while (1) {
    wire_lock.lock()
    my3IMU.getYawPitchRoll(ypr);
    ...
  45. Replies
    418
    Views
    84,193

    If you are just dealing with sharing simple data...

    If you are just dealing with sharing simple data types, you may also want to consider using 'std::atomic'. I haven't used it on Teensy, so I'm not sure it really works, but it's in there:
    ...
  46. Replies
    418
    Views
    84,193

    That's what it is. I think that kind of thing is...

    That's what it is. I think that kind of thing is usually done in databases and the like, where the cost of waiting is very high. In a C++ program, waiting for simple variables is probably...
  47. Replies
    418
    Views
    84,193

    Thanks for the heads up about LTO. I replaced the...

    Thanks for the heads up about LTO. I replaced the CPSI instructions with __disable_irq() and __enable_irq(), which already contain the memory barrier. I probably should have done this from day 1....
  48. Replies
    418
    Views
    84,193

    While you are thinking up all these interesting...

    While you are thinking up all these interesting ways to make locking easier, you might want to look at this summary of different types of locks to see if anything else is suitable:
    ...
  49. Replies
    418
    Views
    84,193

    If you are locking the same mutex then it's a...

    If you are locking the same mutex then it's a deadlock.



    Some platforms have recursive mutexes. But it's an advanced topic. I'm not sure it's suitable for a simple platform like Teensy so I...
  50. Replies
    418
    Views
    84,193

    That's right, as @tni pointed out, mutex locks...

    That's right, as @tni pointed out, mutex locks generally are not "recursive".

    To use the bathroom analogy, a mutex is like the lock on a bathroom door. Once you go in, you lock the door. Then no...
Results 1 to 50 of 130
Page 1 of 3 1 2 3