fix(HardwareSerial): fix pin remapping in begin() for 2.x #10380
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Change
The pin remapping functions have to be called as early as possible in the begin() function, to immediately convert the input parameters from the user to the GPIO numbers used everywhere in the core. However, there is code that assigns GPIO numbers to
txPin
/rxPin
before the call todigitalPinToGPIONumber
.This issue has always been dormant since the introduction of pin remapping in 9b4622d, but was exposed by the recent UART pin detach support in 2.x, which actually disabled the default Serial0 pins.
Move the pin remapping function calls earlier in the begin() function to fix this issue.
Tests scenarios
Tested on the Nano ESP32 -
Serial0.begin(115200)
was selecting "random" pins instead of the expected defaults.Related links
See also #10379 for the same fix on master.