Teensy 4.0 First Beta Test

Status
Not open for further replies.
Last night I cleaned up the I2S code, testing on both Teensy 3.6 and 4.0.

Right now I'm working on putting the native SD code back to polling mode. It's working great on Teensy 3.6 with the audio lib (as it used to in version 1.45), but that breaks it on Teensy 4.0. So far, I can't figure out why...

Today is my first day since release where we're not frantically shipping orders. I hope to clean the rest of the immediate software issue up later today.
 
Right now I'm working on putting the native SD code back to polling mode. It's working great on Teensy 3.6 with the audio lib (as it used to in version 1.45), but that breaks it on Teensy 4.0. So far, I can't figure out why...
Re: WavFilePlayer and BUILTIN_SDCARD
Yeah, a few weeks back I tried to figure out how to get SD lib to do polling again, even just polling on DMA done, but it was above my pay grade.

Good work on getting the T4 out to the world.
 
What is a 'section type conflict' that shows up with 1.47-beta5 only on T4

Code:
PROGMEM const int mphTable[] = {
0,100,90,80,75,60,
4,1,1,1,1,1,
5,1,1,1,1,1,
6,1,1,1,1,1,
7,1,1,1,1,3,
8,1,1,2,2,5,
9,1,1,3,4,7,
10,1,2,4,5,9,
11,2,4,5,7,9,
12,3,5,7,8,10,
13,4,6,8,9,12,
14,5,8,9,9,13,
15,7,9,10,10,14,
16,8,9,11,11,16,
17,9,10,12,12,17,
18,9,11,13,13,18
};

PROGMEM const char *toplineTABLE[]={
"error",
" ",
"BATTERY",
"AUTO",
"MODE",
"ADJUST FRONT",
"ADJUST BACK",
"ADJUST AUTO",
"MOVE TO MID GR2",
"SETTINGS"
};

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:
  gearfromMphTable(12,2);
}

int gearfromMphTable(int thespeed, int rpmoffset){
  int thegear;

  thegear=pgm_read_word_near(mphTable+(thespeed-3)*6+rpmoffset); //for table with rpms in first row, starting with 4mph in second
  return thegear;
}

RESULT:
T4issue_PROGRAM:21: error: toplineTABLE causes a section type conflict with mphTable
PROGMEM const char *toplineTABLE[]={
^
/var/folders/b9/m7vp5hr925n_3r73_y07979w0000gn/T/arduino_modified_sketch_22662/T4issue_PROGRAM.ino:2:19: note: 'mphTable' was declared here
PROGMEM const int mphTable[] = {
^
toplineTABLE causes a section type conflict with mphTable

I found some information here: https://forum.pjrc.com/threads/54711-Teensy-4-0-First-Beta-Test?p=197693&viewfull=1#post197693 but no solution.
 
Last edited:
It is essentially a memory fault error where PROGMEM somehow is going into the wrong section of memory on the T4. T4 memory is rather confusing to me but from what I understand on the T4 there are 4 blocks of memory:
Code:
- ITCM (@0x0, 256KB fast RAM, uncached) is 256KB and intended for code. 
- DTCM (@0x20000000, 256Kb fast RAM, uncached) is intendeded for data, 
- OTCM (@0x20200000, 512 KB RAM connected via a slower bus, can be cached) for data, 
- Flash, @0x60000000, size defined by the external chip for code & data, can be cached.
- inbuilt devices
curtesy of @Frank B.

But if you haven't figure it out the correct format your progmem block is:
Code:
const char *const toplineTABLE[] PROGMEM = {
got that from going to the Arduino Progmem help page.
 
Not sure if it’s feasible or maybe you even already have a tool similar to rust’s cargo crater tool their development team uses to test releases. Basically it try’s to compile thousands of library’s In The cargo library and se’s how many have errors and the get a list. Maybe you have such a tool not to check not if it functions correctly but if I gives build errors?
 
It is essentially a memory fault error where PROGMEM somehow is going into the wrong section of memory on the T4. T4 memory is rather confusing to me but from what I understand on the T4 there are 4 blocks of memory:
Code:
- ITCM (@0x0, 256KB fast RAM, uncached) is 256KB and intended for code. 
- DTCM (@0x20000000, 256Kb fast RAM, uncached) is intendeded for data, 
- OTCM (@0x20200000, 512 KB RAM connected via a slower bus, can be cached) for data, 
- Flash, @0x60000000, size defined by the external chip for code & data, can be cached.
- inbuilt devices
curtesy of @Frank B.

But if you haven't figure it out the correct format your progmem block is:
Code:
const char *const toplineTABLE[] PROGMEM = {
got that from going to the Arduino Progmem help page.
Wow, I really don't understand that callout or the array of strings method on the Arduino PROGMEM help page, but it compiles and seems to work. I'll investigate further, thanks!
 
Wow, I really don't understand that callout or the array of strings method on the Arduino PROGMEM help page, but it compiles and seems to work. I'll investigate further, thanks!

In the 8-bit AVR systems (such as the Arduino Uno), data space is rather limited, and things in read-only flash memory (i.e. the program) are not in the same address space as the data pointers. So if you have a bunch of strings or a table of constant values, you might want to put that read only table in the flash memory, and then use special functions to copy that string or data from the program space to the data space when you need the string/number, and then when you are done, you reuse the space.

On ARM systems, the data and program are in the same address space. So you don't need the functions, but you want to use the const keyword so that the compiler/linker puts that table into read-only flash memory, and not the read-write data space. In Teensy 3, the PROGMEM macro was empty, but in Teensy 4, it uses an __attribute__ to tell the linker that the stuff needs to be linked so it is in lower memory. This is because while they share the same address space, the lower and upper memories for the Teensy 4 have different characteristics.
 
Yeah, a few weeks back I tried to figure out how to get SD lib to do polling again, even just polling on DMA done, but it was above my pay grade.

Must admit, I've also been stuck on this for many hours. I believe I finally got it working. Here's the changes.

https://github.com/PaulStoffregen/SD/commit/afc00aa788076ab4f0f27e5d0944a1fe94fecae5

Most of this commit is just putting the old polling code back, and commenting out the DMA+interrupt code.

The tricky part threw me for so long was the MIX_CTRL register. Teensy 3.6's SDHC controller doesn't have this register at all. If you look at the register list (page 2005-2006 in the K66 manual), there's a hole at offset 0x48. Teensy 4.0 does have this register, at offset 0x48. Interestingly, neither of them has anything documented at offset 0x4C...

On Teensy 3.6, the 4 data line drivers seem to become input or output based on the XFERTYP bit DTDSEL, which happens inside the SDHC_CMD_Do() function. On Teensy 4.0, it seems you also need to write to the (seemingly redundant) MIX_CTRL bit DTDSEL, before starting the command.

Hopefully nobody will ever need to mess with this. But here's a message about the problem just in case I or you or anything else runs across this again.

I'm listening to the WavFilePlayer running on Teensy 4.0 with the SD card on the breakout board socket. :)
 
Well done. I installed your latest SD lib and confirmed WavFilePlayer with BUILTIN_SDCARD worked on T4 and T3.5. Also confirmed listfiles example worked. ;) Whew.
 
I'm fixing this now. Will upload 1.47-beta6 later today.

Looking to finalize 1.47 on Monday.

Not a problem Paul. Know you have had your hands full :)

Anyway, downloaded the SD Lib changes you made and Datalogger and Dumpfile are both now working again on the T4B2R. Great work on finding the problem.
 
@wwatson
...
Installed a fresh copy of Arduino 1.8.9 and TD 1.47B5. I was compiling one of my test programs that use the time library and got an error.
So I tried compiling 'TimeRTC.ino' and it gave the same error below:
...
I searched for 'strcpy_P' in the compiler libs but did not find it.
I changed line 20 in 'DateStrings.cpp' to this:
Code:
#if defined(ESP8266) || defined(ARDUINO_ARCH_ESP32) [COLOR="#FF0000"]|| defined(__IMXRT1062__)[/COLOR]

It compiled ok after that.
Can't wait for the T4 release:)

Same issue with TimeLib.h on Teensy 3.2 and Teensy 4 with 1.47-beta5. Worked on 1.46

thanks
 
Last edited:
> Adafruit_GFX - new version from AdaFruit works for compiling on T4 - at least against the ST7789 code I tested - where the beta 5 version did not

I've pulled in the latest Adafruit_GFX. I did a quick test with their Adafruit_ILI9341 lib, on Teensy 3.2 and 4.0. Seems to work fine.

Going to package up 1.47-beta6 shortly. Hoping you can try some other displays tonight or tomorrow.


> i2s (?) bad #ifdef led to compile breakage

Fixed.

> After install first Arduino startup returned to T_3.2, not last used T4.

Fixed.

Also fixed (hopefully) all the remaining "Beta2" to now say Teensy 4.0, like with detecting the boards in the Ports menu. 1.47-beta6 will also show a real image of the Teensy 4.0 hardware, rather than this chip picture we've see for so long.

beta2.png
 
In beta5, output_i2s.cpp is missing line 507
Code:
void AudioOutputI2Sslave::config_i2s(void)
{
#if defined(KINETISK) //<-- missing
	SIM_SCGC6 |= SIM_SCGC6_I2S;
which prevents it from compiling.
 
Paul - also for release ::

>> what of ...\hardware\teensy\avr\cores\teensy4\debug\printf.h and #define PRINT_DEBUG_STUFF

Not sure if anything else would have to get resolved for release version?

NOTE: When you turn that off there will be warnings last seen in the Fault_Handler code from the debug print gone missing.

>> ...\hardware\teensy\avr\cores\teensy4\startup.c :: void HardFault_HandlerC(unsigned int *hardfault_args) {

But will that code be #ifdef out for a NULL handler? that perhaps just does this?
Code:
	if ( F_CPU_ACTUAL >= 600000000 )
[B]		set_arm_clock(100000000); // 100 or 200 or 300?[/B]
	while (1) asm ("WFI");

>> and there this is unused code :: void PJRCunused_interrupt_vector(void)

>> Also unused in startup.c :: __attribute__((weak)) void userDebugDump(){
 
I've uploaded 1.47-beta6. Links on msg #2.

Please give this a try, on Teesny 4.0 and also on older boards. Is anything still broken?

You may notice I pruned the USB Type and Optimize menus. As those things are implemented on Teensy 4.0, will add them back. They're just commended in boards.txt, so easy to uncomment if you want them.

I'm going to try porting a couple more libs, and of course fix any more bugs that turn up. Really want to wrap up 1.47 tomorrow, so we have a stable release with Teensy 4.0 support.

If you have a moment to give 1.47-beta6 a try, please let me know if there's any other bugs I really should fix before releasing it tomorrow?
 
>> what of ...\hardware\teensy\avr\cores\teensy4\debug\printf.h and #define PRINT_DEBUG_STUFF

I turned off the Serial4 debug printing for 1.47-beta6.

https://github.com/PaulStoffregen/cores/commit/ebb0040e26e7fbb7d6fff1076bfa000e59119b07


NOTE: When you turn that off there will be warnings last seen in the Fault_Handler code from the debug print gone missing.

Yup, already fixed.

https://github.com/PaulStoffregen/cores/commit/934b48584decc852bb4e8d657b70fa73f8ed13f9
 
Did a fresh UNZIP of IDE 1.8.9 and then TD 1.47b6. To confirm my sketchbook\libraries folder is EMPTY

First couple of things okay so far then ...

What's up with : "arduino-1.8.9t4\hardware\teensy\avr\libraries\ILI9341_t3\examples\graphicstest\graphicstest.ino"
.. and same with "arduino-1.8.9t4\hardware\teensy\avr\libraries\ILI9341_t3\examples\DemoSauce\DemoSauce.ino"

"T:\\arduino-1.8.9t4\\hardware\\teensy/../tools/arm/bin/arm-none-eabi-g++" -c -O2 -g -Wall -ffunction-sections -fdata-sections -nostdlib -MMD -std=gnu++14 -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=147 -DARDUINO=10809 -DF_CPU=600000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH "-IT:\\TEMP\\arduino_build_408666/pch" "-IT:\\arduino-1.8.9t4\\hardware\\teensy\\avr\\cores\\teensy4" "-IT:\\arduino-1.8.9t4\\hardware\\teensy\\avr\\libraries\\SPI" "-IT:\\arduino-1.8.9t4\\hardware\\teensy\\avr\\libraries\\ILI9341_t3" "T:\\TEMP\\arduino_build_408666\\sketch\\graphicstest.ino.cpp" -o "T:\\TEMP\\arduino_build_408666\\sketch\\graphicstest.ino.cpp.o"
In file included from T:\arduino-1.8.9t4\hardware\teensy\avr\libraries\ILI9341_t3\examples\graphicstest\graphicstest.ino:18:0:

T:\arduino-1.8.9t4\hardware\teensy\avr\libraries\ILI9341_t3/ILI9341_t3.h: In member function 'void ILI9341_t3::waitFifoNotFull()':
T:\arduino-1.8.9t4\hardware\teensy\avr\libraries\ILI9341_t3/ILI9341_t3.h:320:9: error: 'KINETISK_SPI0' was not declared in this scope
sr = KINETISK_SPI0.SR;
^
T:\arduino-1.8.9t4\hardware\teensy\avr\libraries\ILI9341_t3/ILI9341_t3.h: In member function 'void ILI9341_t3::waitFifoEmpty()':
T:\arduino-1.8.9t4\hardware\teensy\avr\libraries\ILI9341_t3/ILI9341_t3.h:328:9: error: 'KINETISK_SPI0' was not declared in this scope
sr = KINETISK_SPI0.SR;

// ...

T:\arduino-1.8.9t4\hardware\teensy\avr\libraries\ILI9341_t3/ILI9341_t3.h:374:68: error: 'SPI_PUSHR_EOQ' was not declared in this scope
KINETISK_SPI0.PUSHR = d | (pcs_data << 16) | SPI_PUSHR_CTAS(1) | SPI_PUSHR_EOQ;
^

Using library SPI at version 1.0 in folder: T:\arduino-1.8.9t4\hardware\teensy\avr\libraries\SPI
Using library ILI9341_t3 at version 1.0 in folder: T:\arduino-1.8.9t4\hardware\teensy\avr\libraries\ILI9341_t3
Error compiling for board Teensy 4.0.

Update>> installed & tested ' #include "Adafruit_ILI9341.h" ' : Paul noted he tested that and T4 works with that ili9341
Code:
Using library SPI at version 1.0 in folder: T:\arduino-1.8.9t4\hardware\[U]teensy\avr\libraries\SPI [/U]
Using library Adafruit_GFX at version 1.5.6 in folder: T:\arduino-1.8.9t4\[U]hardware\teensy\avr\libraries\Adafruit_GFX[/U] 
Using library Adafruit_ILI9341 at version 1.5.1 in folder: T:\[B]tCode\libraries\Adafruit_ILI9341 [/B]

> Looking at the <XPT2046_Touchscreen.h> - for TouchTestIRQ.ino - oddly without touch the SPI SCLK LED is flickering?
 
Last edited:
I've uploaded 1.47-beta6. Links on msg #2.

Please give this a try, on Teesny 4.0 and also on older boards. Is anything still broken?

...

I can confirm that RSL_VNA, and a bunch of ILI9341_t3.h based programs run on T3.5 (touchpoint, graphicstest, demosauce ...) and compile on 4.0
Teensy_Convolution_SDR didn't compile on T3.6 or t4 as it requires a little fooling around with libraries I didn't have time to do.

All of the older programs I tested worked with beta6 and at least compiled with T4.

Have an issue where serial.write(0x04); works but serial.write(0x00) on T4 gives 'call of overloaded 'write(int)' is ambiguous' which can be fixed with a (uint8_t) cast

Overall beta5 was a no-go for me but beta6 seems respectable.
 
@defragsrer
Not at computer now but did $KurtEs PR get pulled in for the 9441_t3 lib? If not it won't work.
 
@defragsrer
Not at computer now but did $KurtEs PR get pulled in for the 9441_t3 lib? If not it won't work.

I'm suspecting it did not get pulled in - was hoping KurtE might be online and see this to confirm.
>> Nothing OPEN for @KurtE - one closed July 2nd ?? :: https://github.com/PaulStoffregen/SPI/pulls?q=is:open+is:pr

@bicycleguy - any chance you have a sketchbook\libraries copy of a WIP SPI on your system?
<EDIT> from post #4003 - not SPI but ILI9341_t3 ?
>> @bicycleguy - is there a local libraries version of WIP ILI9341_t3 in sketchbook?
 
Last edited:
Status
Not open for further replies.
Back
Top