It not related to used UART number, it is just a software problem. While you added a printf routine to, say, HardwareSerial class, it will be available on any Serial.
However, keep in mind that printf code is quite complex and consists of many functions.
Hi Delta_G, maybe I didn't understand the question, anyway ...
... on TinyUSB I don't know, but if you want to enable the Arduiino UNO R4 debugging (BACKTRACE) also on Minima using "Serial1" , you can do it with a simple modification to main.c (... as I did):
#ifdef BACKTRACE_SUPPORT
// "install" stacktrace print over Hardfault handler
*(irq_vector_table + 3) = (uint32_t)Stacktrace_Handler;
cm_backtrace_init(stringify(PROJECT_NAME), "RA", __DATE__ "\0");
#endif
_init();
initVariant();
analogReference();
#ifndef NO_USB
__USBStart();
Serial.begin(115200);
#endif
startAgt();
#if defined (BACKTRACE_SUPPORT) && defined (ARDUINO_UNOR4_MINIMA)
/* gpb01 add support for ARDUINO UNO R4 MINIMA and WeAct BOARD */
Serial1.begin ( 115200 );
Serial1.println ( "BackTrace support enabled, setup() delayed ...");
for ( uint8_t i = 15; i > 0; i-- ) {
R_BSP_SoftwareDelay(1000, BSP_DELAY_UNITS_MILLISECONDS);
Serial1.print ( i );
Serial1.print ( " " );
}
Serial1.println ( );
Serial1.println ( " ... entering setup()" );
#endif
setup();
while (1)
{
loop();
}
}
#ifdef BACKTRACE_SUPPORT
/* for printf compatibility */
#ifdef ARDUINO_UNOR4_MINIMA
/* gpb01 add support for ARDUINO UNO R4 MINIMA and WeAct BOARD */
extern "C" __attribute__((weak)) int _write (int fhdl, const void *buf, size_t count) {
(void)fhdl;
return Serial1.write_raw((uint8_t*)buf, count);
}
#else
extern "C" __attribute__((weak)) int _write (int fhdl, const void *buf, size_t count) {
(void)fhdl;
return Serial.write_raw((uint8_t*)buf, count);
}
#endif
As you can see, I've added a simple delay with a message on "Serial1" to report that you're starting a program with "BACKTRACE" support, but of course if you don't need it, you can throw out the whole thing.
Next, you need to add a new definition for "Arduino UNO R4 Minima" in the "boards.txt" file, where you define the "BACKTRACE", just like for WiFi so, after, you can select if you want the standard MINIMA or the MINIMA with BACKTRACE.
I don't know if this is helpful or ... if I didn't understand the question ...
... reading your question better, I may understand that you want to implement real "debugging" (... with trace, breakpoint, etc.) on MINIMA ... in which case my instructions are completely useless, sorry.
Ok, I don't know if you still need it ... anyway, I tried the code and it works perfectly on Renesas extending the "Print" class (... and so Serial, Ethernet, WiFi, LiquidCrystal, etc.).
If you still need it:
in Arduino UNO R4 core replace the platform.txt with this one: platform.txt (8.0 KB)
I tried the code in post #3, but ... the amount of flash used is impressive (over 70%)
#include <Arduino.h>
#include <stdio.h>
#include <iostream>
using namespace std;
extern "C" {
int _write ( int fd, char *ptr, int len ) {
( void ) fd;
return Serial.write ( ptr, len );
}
}
void setup() {
Serial.begin ( 115200 );
while ( !Serial );
Serial.println ( "START" );
printf ( "HERE WE ARE\r\n" );
cout << "TEST COUT\r\n";
cerr << "TEST ERR\r\n";
}
void loop() {
}
Sketch uses 190720 bytes (72%) of program storage space. Maximum is 262144 bytes.
Global variables use 12644 bytes (38%) of dynamic memory, leaving 20124 bytes for local variables. Maximum is 32768 bytes.
without the iostream it is:
Sketch uses 53760 bytes (20%) of program storage space. Maximum is 262144 bytes.
Global variables use 4552 bytes (13%) of dynamic memory, leaving 28216 bytes for local variables. Maximum is 32768 bytes.
#include <Arduino.h>
#include <stdio.h>
using namespace std;
extern "C" {
int _write ( int fd, char *ptr, int len ) {
( void ) fd;
return Serial.write ( ptr, len );
}
}
void setup() {
Serial.begin ( 115200 );
while ( !Serial );
Serial.println ( "START" );
printf ( "HERE WE ARE\r\n" );
}
void loop() {
}
Sketch uses 49952 bytes (19%) of program storage space. Maximum is 262144 bytes.
Global variables use 6704 bytes (20%) of dynamic memory, leaving 26064 bytes for local variables. Maximum is 32768 bytes.