[SOLVED] Check for correct target device before flashing

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] Check for correct target device before flashing

    Hi, is there a way to check if the correct device is connected before flashing new code?

    I work with Infineons XMC4000 microcontrollers and my designs often have more than one microcontroller and I often have one or more debuggers connected simultaneously. Sooner or later, it just happens that I select the wrong debugger by accident, or the debugger is connected to the wrong microcontroller. Since I work in in power electronics, the results may be catastrophic.

    For example, right now, I have no trouble flashing the code for a XMC4200 on a XMC4400 or vice versa.

    Is there a setting I need to add or is the debugger not able to identify the device it is connected to? (I use SWD if that makes any difference)

    Ideally the debugger would first check the contents of a configurable memory address so I can have a unique ID per microcontroller, so even controllers of the same type won’t get mixed up. Is that possible?
  • Hi,

    Your specific MCU may or may not provide memory-mapped special function register that allow identification of the particular device model etc.
    I recommend to get your hands on the J-Link SDK and add do a sequence like this:
    ConnectJLink()
    ConnectDevice()
    VerifyDevice()
    FlashDevice()

    where VerifyDevice() may be a series of Readmem() calls to certain addresses that specify special function registers meant for model detection. For more information about such registers, you should refer to the techical reference manual of the XMC4200 and XMC4400.

    SDK:
    segger.com/products/debug-prob…nk/technology/j-link-sdk/

    shop.segger.com/debug-trace-pr…ftware-add-ons/j-link-sdk
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.