Flakiness seen due to boards.txt from old and new IDE installs

K7MDL

Member
I added a new combo to the usb_desc.h file (Serial + Serial + AUDIO) and the boards.txt to match. This adds to the 48KHz USB Audio changes I had made earlier.

I have been chasing some IDE Tools:Boards and Tools:USB Type menu flakiness getting trying to get things working in both VS code and IDE 2.0.3. Using TeensyDuino 1.57.2, tried 1.5.1 briefly also (got hit with the tools folder having only teensy.,exe left in it).

What I was seeing often:
1. Language server error, the compile seems to go on.
2. Errors about cpu specs not found so the compile aborts. Select a Teensy board (again) in Tools:Boards to continue. The board keeps getting unselected.
3. The USB Type menu would sometime not reflect the menu items I set up. My custom Serial+Serial+Audio USB Type combo would appear in the IDE board drop down list as "Triple Serial" or some other odd one.
4. I got different USB Type menu offerings in VS Code board manager vs Arduino IDE 2.0.3. Usually, the selected type in VS Code would not work, seen as no valid audio and/or no serial devices so compile aborts. The IDE did better. I think this has to do with lots of old IDE version path in the VS Code config files adding to the new issues here.

When I updated boards.txt I focused on the the .../AppData/local/Arduino15/.... paths and not the old version paths looking for multiple copies that might exists and get copied around for whatever reason by the IDE. I assumed the old and new would not intermingle much. I think I was wrong.

There is a C:\Users\[username]\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6 on my machine with a boards.txt containing the same Teensy menu info but it is the original boards.txt, not my new modified version with Serial+Serial+Audio.

Looking at the IDE log the IDE was trying to deal with both arduino:avr:teensy41 and teensy:avr:teensy41 boards. This appears to cause the IDE to randomly choose a boards.txt to process and then "forgets" what board I had chosen. When this happens a board is in an unselected state. This produces the CPU spec error. Selecting a board always fixes this temporarily.

I took a closer look at the Tools:Boards menu and I saw Arduino AVR, Teensy, and ESP32 in my case. When I navigated over the Arduino AVR expanding it, it listed Teensy model CPUs in the list, nothing else.

Once I removed (renamed) the C:\Users\[username]\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\boards.txt the Arduino AVR board name was removed from the menu.

After this I am able to compile with my Serial+Serial+Audio (and at 48KHz - must match the audio side sample rate!) for the first time, and the other older combos as well. I was using Serial+MIDI+Audio but I needed 2 Serial ports and no MIDI. I suspect as long as no one ever changes the boards.txt it would be no problem, and unseen issue. I see this as a bug waiting to pounce once you decide to add a new Board or USB type in the future. I think the language server errors went away also. Time will tell. Now I have to go back to reinstall VS Code and get it working again.

So the apparent rule for now is to ensure your boards.txt match everywhere (or remove unneeded ones) and the old version may cause a problem by appearing under Arduino avr board type.


- Mike
 
When using IDE 2.0 the affected file on Windows should be: %appdata%\..\local\Arduino15\packages\teensy\hardware\avr\0.58.3\boards.txt

At least if using the BETA 3 of TD 1.58? ... YMMV ...

When that is edited - correctly - the IDE 2.0 likely has to be opened AFTER that change is made - i.e IDE 2.0 closed before (possibly or after) editing and opened fresh. And 'correct' editing has to set all the right fields/values and the CORES build tree has to have proper flow for that to come together.

There shouldn't be any crosstalk between with that done as such? Was that the process there?

Not that local edits have been tried here - but CmdLine builds as done that were for IDE 1.8.19 fully defer to the IDE 2.0 install because of the way the paths are specified and it doesn't get confused. And editing the proper paths out does revert to the IDE 1.8.19 TeensyDuino install.
 
Only now did I catch that that 0.58.3 is the same as 1.58.3. I said heck with it and uninstalled VS Code and Arduino of any version, wiped folders and installed fresh.

Upon examining the new install, the Teensy model list appearing in the menus under Arduino earlier is because I had popped in my updated boards.txt some time ago in the heat of the battle, overwriting the original version that has only Arduino models. So that one is self-inflicted.

The IDE on 2nd restart says "Platform arduino:avr@1.8.6 already installed". It seems they are reusing this old folder name and it is not old files.
 
I had read about the caching and saw where just deleting the leveldb folder was enough to get the boards menus to update. That has worked great for me.

Today I discovered boards.local.txt in some searching which led to this
https://arduino.github.io/arduino-cli/0.29/platform-specification/#boardslocaltxt

There are similar options for platform.local.txt and others. These add or override existing boards.txt items. In my simple case I only need to add 3 lines to the USB Type menu.

I created these instructions below on my SDR project github along with the usb and 48K audio patch files.

Since moving from 1.57.2 to 0.58.3 my IDE compile broke, error is it cannot find a reference to AudioConnection which I see has changed in AudioStream.h. The examples run OK. Still investigating.

I also uninstalled Arduino 1.8.19. partly due to finding my VS Code was using it still. It was looking for the Arduini IDE file called Arduino_debug.exe, which appears to not exist in Arduino 2.0. VS Code does support the CLI if you provide a path to it. The CLI files moved and today I found it in my chosen IDE 2 install target folder.
D:\ArduinoIDE\Arduino IDE\resources\app\node_modules\arduino-ide-extension\build
I am unable to compile now in VS Code for reasons I have not spotted yet. Looking for where the detailed error info is located.

At least the boards issue appears to be solved in an easy way now.

___________________________________________________
Updated custom USB Type for 2 serial and 1 Audio - Updated Jan 2, 2023. Used in my SDR project.

Adds a Custom USB type for the Teensy 4.1 to enable 2 Serial ports plus Audio to the Arduino 2.0 IDE.
This enables debug on Serial and the optional CAT Serial interface on USBSerial1.

a. add this section into usb_desc.h after the USB_AUDIO section.
Code:
		#elif defined(USB_SERIAL_SERIAL_AUDIO)
			#define VENDOR_ID		0x16C0
			#define PRODUCT_ID		0x048C
			#define MANUFACTURER_NAME	{'T','e','e','n','s','y','d','u','i','n','o'}
			#define MANUFACTURER_NAME_LEN	11
			#define PRODUCT_NAME		{'K','7','M','D','L',' ','S','D','R'}
			#define PRODUCT_NAME_LEN	    9
			#define EP0_SIZE		          64
			#define NUM_ENDPOINTS         7   // 5 for 2 serial, + 2 for audio
			#define NUM_INTERFACE		      7   // 4 for 2 serial, + 3 for audio
			#define CDC_IAD_DESCRIPTOR	  1
			#define CDC_STATUS_INTERFACE	0
			#define CDC_DATA_INTERFACE	  1	// Serial
			#define CDC_ACM_ENDPOINT	    2
			#define CDC_RX_ENDPOINT       3
			#define CDC_TX_ENDPOINT       3
			#define CDC_ACM_SIZE          16
			#define CDC_RX_SIZE_480       512
			#define CDC_TX_SIZE_480       512
			#define CDC_RX_SIZE_12        64
			#define CDC_TX_SIZE_12        64
			#define CDC2_STATUS_INTERFACE 2       // SerialUSB1
			#define CDC2_DATA_INTERFACE   3
			#define CDC2_ACM_ENDPOINT     4
			#define CDC2_RX_ENDPOINT      5
			#define CDC2_TX_ENDPOINT      5
			#define AUDIO_INTERFACE	4	// Audio (uses 3 consecutive interfaces)
			#define AUDIO_TX_ENDPOINT     6
			#define AUDIO_RX_ENDPOINT     6
			#ifdef USB_AUDIO_48KHZ
				#define AUDIO_TX_SIZE         196   // longer buffer
				#define AUDIO_RX_SIZE         196
			#else
				#define AUDIO_TX_SIZE         180
				#define AUDIO_RX_SIZE         180
			#endif
			#define AUDIO_SYNC_ENDPOINT	7
			#define ENDPOINT2_CONFIG	ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_INTERRUPT
			#define ENDPOINT3_CONFIG	ENDPOINT_RECEIVE_BULK + ENDPOINT_TRANSMIT_BULK
			#define ENDPOINT4_CONFIG	ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_INTERRUPT
			#define ENDPOINT5_CONFIG	ENDPOINT_RECEIVE_BULK + ENDPOINT_TRANSMIT_BULK
			#define ENDPOINT6_CONFIG	ENDPOINT_RECEIVE_ISOCHRONOUS + ENDPOINT_TRANSMIT_ISOCHRONOUS
			#define ENDPOINT7_CONFIG	ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_ISOCHRONOUS
b. To add custom Serial + Serial + Audio USB type into the IDE Tools:USB Type menu do the following.

Create a new file called boards.local.txt with the following 3 lines. It will add to the existing Teensy Menu items. I have already created one in the Cores subfolder.
Code:
		teensy41.menu.usb.serialserialaudio=Serial + Serial + Audio
		teensy41.menu.usb.serialserialaudio.build.usbtype=USB_SERIAL_SERIAL_AUDIO
		teensy41.menu.usb.serialserialaudio.upload_port.usbtype=USB_SERIAL_SERIAL_AUDIO
Place your boards.local.txt into %AppData%\Local\Arduino15\packages\teensy\hardware\avr\xxxxx.
xxxxx is the TeensyDuino version you have installed and are using. In my test case it is 0.58.3 (aka 1.58 beta 3)

The USB_SERIAL_SERIAL_AUDIO becomes a #define during compile. The file usb-desc.h has all the usb combo descriptions and uses similar #define to activate your chosen combo.
I have provided a modified usb_desc.h file that uses this define and supports the 48K mod.
Other files are provided to also "patch" the library and are related to the 48KHz modification only.

c. Shutdown the Arduino IDE.

d. There is a known issue in IDE that does not update its cache (a small dB) when board.txt is changed.
See https://github.com/arduino/arduino-ide/issues/1030
For Windows users, this is typically C:\Users\<user name>\AppData\Roaming\arduino-ide
Further reading I found a less drastic solution proposed just delete 1 sub folder called leveldb
In %AppData%\Roaming\arduino-ide\Local Storage folder delete the leveldb folder.

e. Start the Arduino IDE 2.0. Ignore the errors in the output window. Restart the IDE and it will clear the error.

f. Under Tools
Board: Choose Teensy 4.1
Port: Choose the port displayed under the teensy ports section.
The correct name may not show up until you do your first compile, maybe not even then but you will see 2 serial ports.
CPU: Speed choose 816MHz (recommended, but anything you like that works)
USB Type: Choose Serial + Serial + Audio. This is our new custom USB device type.
 
Last edited:
Back
Top