How to download new code/data when the application temporarily allows debug port access?
For security reasons, your application can block access to the debug port, restricting readout or tampering of the firmware. In such a case, there is often some special code written in the application that enables the debug port again (i.e., special request and key phrase sent via CAN) to ensure in-field maintenance or diagnostics.
These kinds of security features are commonly added late in the project stage (with the final code running perfectly) because if you make a mistake or have side effects, the MCU remains locked. Note that MCUs are very different and some of their security features are One-Time-Programmable and cannot be reset (i.e., Flash protection could be set to read-only via OTP). Be very careful with the UCB memory contents of AURIX devices.
If you would like to make changes to previously programmed code or data, it should be done so after your application enables the debug port. However, when you would perform a regular Program file download, the BlueBox issues a reset before downloading, and, since port access is denied at this point of execution, the download fails and an error message is displayed.
Consider what impact your changes in the reloaded code would have in combination with any active security measures. Keep in mind that a complete memory sector needs to always be deleted and that the newly loaded code could possibly leave dangerous gaps here.
1. Add your program file(s) in Debug | Configure Session | SoC | Add | Target Files.
2. Select Debug | Attach to connect to your target.
3. After your application enables debug port access, stop the execution
with the Stop button.
4. Ensure that the depicted MCU debug status remains constantly in
STOP on all cores. You can check this by
using the
Session Explorer.
Often there are internal and/or external watchdogs active which will issue
a reset and this is fatal during any erase/flash process.
5. Select the file or all listed files in Debug | Target Download and winIDEA will perform this special kind of download.
Performing a Target file download will take noticeably more time than a regular Program file download. Usually, winIDEA first reads the involved sector contents from the MCU, patches these with the new contents from the selected target file, erases the involved sectors within SoC and then writes the new contents back.