-
Notifications
You must be signed in to change notification settings - Fork 455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Link errors when using -D PIO_FRAMEWORK_ARDUINO_NO_USB #1434
Comments
If you really need libs which need |
Hmm but in the @git2212 you can also try to just do that with macros, build_flags =
-DPIO_FRAMEWORK_ARDUINO_NO_USB
-DSerial=Serial1 in the |
Some of the boards simply don't break out the pins to attach an external debugger, that's the situation I am in hence the need to use pico-debug. Tried
While libraries aught not to make assumptions about availability of Serial, people do and just hard code Serial.print type statements in their libraries. This typically results in a compile time error for an undefined reference to Serial, but some of them use clever macros which avoid the compiler time errors and push the problem to the linker. When using the Confusion notwithstanding, if this is not handled at your level, every single library with this potential problem either needs to be refactored accordingly or is simply not an option because of this. I could be wrong but it seems it's easier to fix this at the core level than contact each library creator to fix their ill-behaved code... yeah I know, not your problem, but it is ours :) From a dumb user standpoint, it is also reasonable to expect that the code should not break with debug compile if it works in normal compile mode |
The proposed solution is to add the code below to https://github.com/earlephilhower/arduino-pico/blob/master/cores/rp2040/SerialUSB.cpp just before the final
|
I'm still a little unconvinced, but this won't be the first compatibility hack in the core so I suppose I could hold my nose. 😆 If you could remove the I'm not sure if this should be under the |
Are we really sure there's not some Arduino convention that says |
The smaller boards this is an issue on don't break out the pins for more than one UART. Once you start debugging with pico-debug, you are out of (accessible) UARTs to redirect to. It's the tradeoff during the debug session, you have to give up the use of the one and only Serial. |
But that's weird, I thought pico-debug would leave the Hardware UART serials alone and only use the USB port for the Serial port. So accessing |
I think maybe he's only got one UART pinned out and using If we shift Serial1->Serial, Serial2->Serial1, then what happens is your code basically breaks when run in debug mode. And if we make Is there an CMSIS/SWD type call to send chars down the debug pipe? Redirect USB to that SWD channel? OTW, I think nulling it out might be the best thing to hope for. |
Correct, one UART is pinned out. Remapping Serial to Serial1 during the debug session would not be good in my case. The solution in the associated PR (blanking out Serial) is the solution for my use case. I can't seem to find the PR though, it just vanished?!? |
I see you made a branch in your own fork, but you need to go to the GH web interface to actually turn that to a PR for this repo. If you go the your code website and then select your branch from the popup, I think GH will give you a 1-button box to make the PR. |
I.e., go to master...git2212:arduino-pico:git2212-patch-1 and click "Create Pull Request" |
ok, I seem to recall to have done that yesterday... oh well :) Thx |
Compiling with this flag, e.g. when using pico-debug, using VS+Platformio will result in link errors in many libraries, e.g. TFT_eSPI, RPI_PICO_TimerInterrupt, as Serial is left undefined.
To avoid link errors in the many libraries where the authors assumed Serial is always present, perhaps Serial could be made a dummy (for lack of a better term) in case the
PIO_FRAMEWORK_ARDUINO_NO_USB
is added as a build define?The text was updated successfully, but these errors were encountered: