Add standard upload method variables #369
Merged
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.
Summary of changes
This PR fixes some deficiencies in the upload method system which are starting to become more of a problem in the newest version of Mbed.
One issue has been around for a while: if you want to set the serial number of the device to program, it requires a different way to do that for each upload method: PYOCD_PROBE_UID, STLINK_PROBE_SN, etc. All of these are set to the same "type" of thing (the USB serial number of the probe to use), and yet the name is different for each upload method you use. This is silly, and these variables should be unified into one common parameter to set. This change does that.
The other issue is more recent. @ccli8 's recent PRs have switched many tools from using the elf file to the bin/hex file to upload, and this is good because it's required for TFM targets and targets with post build hooks that modify the image to work. However, when uploading a bin file, tools need to be told what address to load it at. This information hasn't existed in Mbed until recently, and it was not being provided to the upload methods at all.
This actually caused a bug I noticed in testing, where flashing code using OpenOCD does not work (just silently left the old version of the code on there) because it defaults to loading to address 0x0, and that is not where some targets put their flash image.
To fix these issue, I've added two new "common" upload method options:
MBED_UPLOAD_SERIAL_NUMBERandMBED_UPLOAD_BASE_ADDR. The former is intended to be set by the user, and defaults to empty though it will pick up the value from the legacy options it replaces if any of those are set. The latter is initialized based on the configured first flash bank start address (MBED_CONFIGURED_ROM_START) but can also be set to a custom address in the user's upload method configuration. I also madeMBED_GDB_PORTinto a proper option if you want to change the port that the GDB server runs on.Impact of changes
MBED_UPLOAD_SERIAL_NUMBER. However, legacy variables are still supported and will print a warning if used.MBED_UPLOAD_BASE_ADDRMigration actions required
Documentation
Will update the upload method documentation once this is ready to be merged
Pull request type
Test results
So far I have verified this with st-flash, OpenOCD, pyocd, and LinkServer, and code can be flashed and runs OK.