Questions about modifying usb_desc.h in teensy4 for dual serial support

georgerosar

Active member
Why don't these modifications allow the USBSerial1 to work, it shows up but USBSerial1.begin() doesn't allow transfer of information.
I haven't worked on this too hard, but I'm curious what else I have to change, or if something is wrong

The idea is to use -DUSB_MIDI_AUDIO_SERIAL
and have an other serial port for debugging in gdb through target remote serial

If I change this in usb_desc.h
(unindented are modifications)

Code:
#elif defined(USB_MIDI_AUDIO_SERIAL)
  #define VENDOR_ID		0x16C0
  #define PRODUCT_ID		0x048A
  #define MANUFACTURER_NAME	{'T','e','e','n','s','y','d','u','i','n','o'}
  #define MANUFACTURER_NAME_LEN	11
  #define PRODUCT_NAME		{'T','e','e','n','s','y',' ','M','I','D','I','/','A','u','d','i','o'}
  #define PRODUCT_NAME_LEN	17
  #define EP0_SIZE		64
  #define NUM_ENDPOINTS         8
  #define NUM_INTERFACE		8
  #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 MIDI_INTERFACE        2	// MIDI
  #define MIDI_NUM_CABLES       1
  #define MIDI_TX_ENDPOINT      4
  #define MIDI_TX_SIZE_12       64
  #define MIDI_TX_SIZE_480      512
  #define MIDI_RX_ENDPOINT      4
  #define MIDI_RX_SIZE_12       64
  #define MIDI_RX_SIZE_480      512
  #define AUDIO_INTERFACE	3	// Audio (uses 3 consecutive interfaces)
  #define AUDIO_TX_ENDPOINT     5
  #define AUDIO_TX_SIZE         180
  #define AUDIO_RX_ENDPOINT     5
  #define AUDIO_RX_SIZE         180
  #define AUDIO_SYNC_ENDPOINT	6
#define CDC2_STATUS_INTERFACE 6       // SerialUSB1
#define CDC2_DATA_INTERFACE   7
#define CDC2_ACM_ENDPOINT     7
#define CDC2_RX_ENDPOINT      8
#define CDC2_TX_ENDPOINT      8
#define CDC2_ACM_SIZE          16
#define CDC2_RX_SIZE_480       512
#define CDC2_TX_SIZE_480       512
#define CDC2_RX_SIZE_12        64
#define CDC2_TX_SIZE_12        64
  #define ENDPOINT2_CONFIG	ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_INTERRUPT
  #define ENDPOINT3_CONFIG	ENDPOINT_RECEIVE_BULK + ENDPOINT_TRANSMIT_BULK
  #define ENDPOINT4_CONFIG	ENDPOINT_RECEIVE_BULK + ENDPOINT_TRANSMIT_BULK
  #define ENDPOINT5_CONFIG	ENDPOINT_RECEIVE_ISOCHRONOUS + ENDPOINT_TRANSMIT_ISOCHRONOUS
  #define ENDPOINT6_CONFIG	ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_ISOCHRONOUS
#define ENDPOINT7_CONFIG    ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_INTERRUPT
#define ENDPOINT8_CONFIG    ENDPOINT_RECEIVE_BULK + ENDPOINT_TRANSMIT_BULK

and this in yield.cpp

Code:
#elif defined(USB_DUAL_SERIAL) || defined(USB_MIDI_AUDIO_SERIAL)
uint8_t yield_active_check_flags = YIELD_CHECK_USB_SERIAL | YIELD_CHECK_USB_SERIALUSB1; // default to check USB.
extern const uint8_t _serialEventUSB1_default;

and also in yield.cpp

Code:
#if defined(USB_DUAL_SERIAL) || defined(USB_TRIPLE_SERIAL) || defined(USB_MIDI_AUDIO_SERIAL)
	if (yield_active_check_flags & YIELD_CHECK_USB_SERIALUSB1) {
		if (SerialUSB1.available()) serialEventUSB1();
		if (_serialEventUSB1_default) yield_active_check_flags &= ~YIELD_CHECK_USB_SERIALUSB1;
	}
#endif
 
Code:
ld.lld: error: section '.text.csf' will not fit in region 'FLASH': overflowed by 59370496 bytes
ld.lld: warning: address (0x2000c898) of section .bss is not a multiple of alignment (4096)
clang-16: error: ld.lld command failed with exit code 1 (use -v to see invocation)
make: *** [build-TEENSY41/iridescentCoconutSynth2.elf] Error 1
georgerosar@iridescent iridescentCoconutSynth2 %

this is what I've got going on right now 59MB kernel based off a Teensy 4.1
and without all the python modules
 
This is pretty handy!
Code:
#!/bin/sh
/Users/iridescent/iridescent/iridescentCoconutSynth2/iridescentmicropython/LLVMEmbeddedToolchainForArm-16.0.0-Darwin-x86_64/bin/lldb build-SHAREDLIB/iridescentmicropython.elf -O log enable gdb-remote packets --source lldbcommands

Code:
georgerosar@iridescent libmicropython % cat lldbcommands
platform select remote-gdb-server
platform connect serial:///dev/cu.usbmodem104133601
process connect serial:///dev/cu.usbmodem104133601%
georgerosar@iridescent libmicropython %
 
iridescentmicropython with all the modules is about 216MB

Code:
ld.lld: error: section '.text.csf' will not fit in region 'FLASH': overflowed by 20912128 bytes
ld.lld: warning: address (0x2000cc74) of section .bss is not a multiple of alignment (64)
clang-16: error: ld.lld command failed with exit code 1 (use -v to see invocation)
make[1]: *** [build-SHAREDLIB/iridescentmicropython.elf] Error 1
make: *** [libmicropythonTeensy] Error 2
georgerosar@iridescent iridescentCoconutSynth2 %

and my synth has extracted sf2 libraries which will all go into FLASHMEM
 
ENDPOINT8_CONFIG will never work. The hardware simply doesn't have that many endpoints.

ENDPOINT7_CONFIG is the maximum.
 
USB_EVERYTHING is just unused leftover stuff from Teensy 3.x. Not only does it have unusable endpoints, but it also uses the endpoint configuration defines from Teensy 3 which don't exist on Teensy 4.

EDIT: deleted on github
 
Last edited:
Thank you for answer. And I have another question, Is it possible to use 0x88 as a Send Endpoint, and use Teensy 4.1.
 
Back
Top