Forum Rule: Always post complete source code & details to reproduce any issue!
Page 2 of 2 FirstFirst 1 2
Results 26 to 33 of 33

Thread: Teensyduino 1.52 Beta #6

  1. #26
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    603
    Need to read something about "cache" and how it works for the different RAM regions including EXTMEM. Do you have any suggestions where I could find something (beginners level, please :-) . . .)

  2. #27
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    6,632
    Quote Originally Posted by DD4WH View Post
    Need to read something about "cache" and how it works for the different RAM regions including EXTMEM. Do you have any suggestions where I could find something (beginners level, please :-) . . .)
    I am not sure there is a beginners level To me it is totally clear as mud.

    When in doubt I typically look at the code. If you look in startup.c (Teensy4) at the function configure_cache

    It will tell you how each area of memory is configured.

    Code:
    	SCB_MPU_RBAR = 0x00000000 | REGION(i++); // trap NULL pointer deref
    	SCB_MPU_RASR =  DEV_NOCACHE | NOACCESS | SIZE_32B;
    
    	SCB_MPU_RBAR = 0x00200000 | REGION(i++); // Boot ROM
    	SCB_MPU_RASR = MEM_CACHE_WT | READONLY | SIZE_128K;
    
    	SCB_MPU_RBAR = 0x20000000 | REGION(i++); // DTCM
    	SCB_MPU_RASR = MEM_NOCACHE | READWRITE | NOEXEC | SIZE_512K;
    	
    	SCB_MPU_RBAR = ((uint32_t)&_ebss) | REGION(i++); // trap stack overflow
    	SCB_MPU_RASR = SCB_MPU_RASR_TEX(0) | NOACCESS | NOEXEC | SIZE_32B;
    
    	SCB_MPU_RBAR = 0x20200000 | REGION(i++); // RAM (AXI bus)
    	SCB_MPU_RASR = MEM_CACHE_WBWA | READWRITE | NOEXEC | SIZE_1M;
    
    	SCB_MPU_RBAR = 0x40000000 | REGION(i++); // Peripherals
    	SCB_MPU_RASR = DEV_NOCACHE | READWRITE | NOEXEC | SIZE_64M;
    
    	SCB_MPU_RBAR = 0x60000000 | REGION(i++); // QSPI Flash
    	SCB_MPU_RASR = MEM_CACHE_WBWA | READONLY | SIZE_16M;
    
    	SCB_MPU_RBAR = 0x70000000 | REGION(i++); // FlexSPI2
    	SCB_MPU_RASR = MEM_CACHE_WBWA | READONLY | NOEXEC | SIZE_256M;
    
    	SCB_MPU_RBAR = 0x70000000 | REGION(i++); // FlexSPI2
    	SCB_MPU_RASR = MEM_CACHE_WBWA | READWRITE | NOEXEC | SIZE_16M;
    From here you can see how each area is configured. And you will see that DTCM (where most variables go) is not cached. That is because it is the fast memory.
    You will then see most other areas are marked:MEM_CACHE_WBWA
    These constants are also defined in the same file:
    Code:
    #define MEM_CACHE_WT	SCB_MPU_RASR_TEX(0) | SCB_MPU_RASR_C
    #define MEM_CACHE_WB	SCB_MPU_RASR_TEX(0) | SCB_MPU_RASR_C | SCB_MPU_RASR_B
    #define MEM_CACHE_WBWA	SCB_MPU_RASR_TEX(1) | SCB_MPU_RASR_C | SCB_MPU_RASR_B
    #define MEM_NOCACHE	SCB_MPU_RASR_TEX(1)
    I don't remember the exact define of WBWA - Write Back, write ??? - By usage I know that it means that the Cache contents and the memory contents may not necessarily be the same. Normally you don't care as most instructions work through the cache. However there are some other things like DMA that talk directly to the memory and not the cache.

    So if your code is doing DMA into or out of these regions, there are things you need to do. Things like if you are writing out using dma, you need to tell the system to flush out the cache.... Likewise if you are reading stuff in by DMA, you need to tell system to delete the cache area...

    But again I am not sure this is answering your question and as I mentioned, clear as mud!

  3. #28
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,680
    Quote Originally Posted by DD4WH View Post
    Need to read something about "cache" and how it works for the different RAM regions including EXTMEM. Do you have any suggestions where I could find something (beginners level, please :-) . . .)
    Here is a site with general information about cache memory in general that I found with a google search:


    The Teensy 4.0 page has a better explanation of the memory layout right now than the 4.1 page (but it doesn't include the optional QSPI memory added in Teensy 4.1 at the moment):


    In case DMA is also confusing, here is the wikipedia entry for it:

  4. #29
    Senior Member DD4WH's Avatar
    Join Date
    Oct 2015
    Location
    Central Europe
    Posts
    603
    Thanks Kurt, thanks Michael! Excellent! Plugged out the Teensy and beginning to read now :-).

  5. #30
    Senior Member
    Join Date
    May 2018
    Posts
    104
    Hi!

    FYI:

    I tried 1.52#6 on Linux (Kubuntu 20.04) and Arduino-1.8.12: Installation ok.

    When I am trying to install my MicroDexed-project (which uses USBHost_t36.h) for Teensy-4.1, I am getting the following:
    Code:
    /usr/local/arduino-1.8.12-teensy/hardware/teensy/avr/libraries/USBHost_t36/adk.cpp: In member function 'void ADK::sendStr(Device_t*, uint8_t, char*)':
    /usr/local/arduino-1.8.12-teensy/hardware/teensy/avr/libraries/USBHost_t36/adk.cpp:229:36: warning: invalid conversion from 'uint8_t* {aka unsigned char*}' to 'char*' [-fpermissive]
      strcpy(adkbuf, (unsigned char*)str);
                                        ^
    In file included from /usr/local/arduino-1.8.12-teensy/hardware/tools/arm/arm-none-eabi/include/stdlib.h:11:0,
                     from /usr/local/arduino-1.8.12-teensy/hardware/teensy/avr/cores/teensy4/WProgram.h:34,
                     from /tmp/arduino_build_230358/pch/Arduino.h:6:
    /usr/local/arduino-1.8.12-teensy/hardware/tools/arm/arm-none-eabi/include/string.h:34:8: note:   initializing argument 1 of 'char* strcpy(char*, const char*)'
     char  *_EXFUN(strcpy,(char *__restrict, const char *__restrict));
            ^
    /usr/local/arduino-1.8.12-teensy/hardware/teensy/avr/libraries/USBHost_t36/adk.cpp:229:36: warning: invalid conversion from 'unsigned char*' to 'const char*' [-fpermissive]
      strcpy(adkbuf, (unsigned char*)str);
                                        ^
    In file included from /usr/local/arduino-1.8.12-teensy/hardware/tools/arm/arm-none-eabi/include/stdlib.h:11:0,
                     from /usr/local/arduino-1.8.12-teensy/hardware/teensy/avr/cores/teensy4/WProgram.h:34,
                     from /tmp/arduino_build_230358/pch/Arduino.h:6:
    /usr/local/arduino-1.8.12-teensy/hardware/tools/arm/arm-none-eabi/include/string.h:34:8: note:   initializing argument 2 of 'char* strcpy(char*, const char*)'
     char  *_EXFUN(strcpy,(char *__restrict, const char *__restrict));
            ^
    /usr/local/arduino-1.8.12-teensy/hardware/teensy/avr/libraries/USBHost_t36/adk.cpp: In member function 'void ADK::rx_data(const Transfer_t*)':
    /usr/local/arduino-1.8.12-teensy/hardware/teensy/avr/libraries/USBHost_t36/adk.cpp:314:42: warning: invalid conversion from 'const uint8_t* {aka const unsigned char*}' to 'uint8_t* {aka unsigned char*}' [-fpermissive]
      uint8_t *p = (const uint8_t *)transfer->buffer;
                                              ^
    For T_3.6 this works.

    Regards, Holger

  6. #31
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    21,825
    Quote Originally Posted by C0d3man View Post
    (which uses USBHost_t36.h) for Teensy-4.1, I am getting the following:
    Fixed
    https://github.com/PaulStoffregen/US...37461d0d25d6f0

  7. #32
    Senior Member
    Join Date
    May 2018
    Posts
    104
    Thanks @Paul (fixed minutes before 1.52 )

  8. #33
    Junior Member
    Join Date
    Oct 2018
    Posts
    8

    Arduino 1.8.12 / T1.52-b5 warnings

    I just happened to be moving from Arduino 1.8.8 to 1.8.12 with Teensyduino 1.52-b5 yesterday. I immediately ran into the need to do some edits because of changes in the ADC library. I found the solution in the forum easily. I managed to get things working again with the new environment but now have a few warnings that do not appear to be related to my project code. My project functions are now working again (USB keyboard, TFT / touch display, A/D input decoding "Morse Code"). Can anyone tell me if I can just ignore warnings like those below?

    Thanks, Chuck

    /private/var/folders/tt/hmrg1j897131t24r2zh4ccg00000gn/T/AppTranslocation/CFD3AB6C-2458-499E-B3E1-2AF23C9741AA/d/T-1.52-b5-Arduino1.8.12.app/Contents/Java/hardware/teensy/avr/libraries/USBHost_t36/adk.cpp:229:36: warning: invalid conversion from 'uint8_t* {aka unsigned char*}' to 'char*' [-fpermissive]

    strcpy(adkbuf, (unsigned char*)str);


    /private/var/folders/tt/hmrg1j897131t24r2zh4ccg00000gn/T/AppTranslocation/CFD3AB6C-2458-499E-B3E1-2AF23C9741AA/d/T-1.52-b5-Arduino1.8.12.app/Contents/Java/hardware/tools/arm/arm-none-eabi/include/string.h:34:8: note: initializing argument 1 of 'char* strcpy(char*, const char*)'

    char *_EXFUN(strcpy,(char *__restrict, const char *__restrict));


    /private/var/folders/tt/hmrg1j897131t24r2zh4ccg00000gn/T/AppTranslocation/CFD3AB6C-2458-499E-B3E1-2AF23C9741AA/d/T-1.52-b5-Arduino1.8.12.app/Contents/Java/hardware/teensy/avr/libraries/USBHost_t36/adk.cpp:314:42: warning: invalid conversion from 'const uint8_t* {aka const unsigned char*}' to 'uint8_t* {aka unsigned char*}' [-fpermissive]

    uint8_t *p = (const uint8_t *)transfer->buffer;


    Sketch uses 104416 bytes (9%) of program storage space. Maximum is 1048576 bytes.

    Global variables use 24616 bytes (9%) of dynamic memory, leaving 237528 bytes for local variables. Maximum is 262144 bytes.

Posting Permissions

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