podonoghue/usbdm-firmware

Reusing SWD_DIO and SWD_DIO

RGassmann opened this issue · 2 comments

Hi Peter,

finally the time has come that I was running out of GPIO-Pins on one of MKL17z256VFM4 Projects.
So after a careful check of every I/O I realized that I could use the SWD_DIO and SWD_SCK to drive my status Led's. As that would be sufficient for my project I checked the USBDM-Schematics (FRDM-Board I am using the OpenSDAv2_0_Unique_ID.bin Verison 4.12.1) and thought that it should work fine.
To be 100% sure I made a little test HW where I connected two LED's (with a 1k resistor) to the DIO and SCK Inputs and wrote a little program that toggles those LED's. Now of corse programming it worked the first time. Unfortunately after that the programming did not work anymore. So I experimented a little an found the following:

  1. A further programming of the device is possible if first a "Detect Chip" is issued. (Since after that the MCU is in some sort of Reset-State)

  2. I noted that the DIO-LED flashes oddly for a very short time when I execute the following sequence "UsbdmFlashProgrammer -target:arm -device:MKL17Z256M4 -erase:Mass -program image.srec -execute" without calling "Detect Chip" first.
    2.1. As the MCU at that time didn't stop working I had the feeling that the MCU was never in reset mode. So I short-circuited the RST-Signal with GND and Run the sequence again. As soon as the DIO-LED started to flash I let the RST-Signal lose. This time the programming was successful. That meant that I had to investigate further. Now as I attached the Oscilloscope I expected to see the following signals:
    First RST from high to low after some time Data on SWD_DIO and SWD_SCK,
    but what I found was that the RST signal wasn't pulled low ever. So I reprogrammed my device back to the point where DIO and SCK are not configured as OUTPUTs and run a second programming with an attached oscilloscope.
    The result astonished me even more as at first some Data on SWD_DIO and SWD_SCK is sent followed by a RST-low signal.
    This leaves me with the following questions:

  3. Why is there a data transfer before the RST-Signal is pulled low.

  4. What exactly happens during time right before the RST-Signal is pulled low?

  5. Why isn't this problem not present in the "Detect Chip"-procedure. Whats the difference.

  6. Do I have a chance to use the DIO ans SCK pins for other purposes other than programming?

Can you please enlighten me.
Thanks for your help,
Roman

Hi Peter,
first of all thanks for your fast answer. After your info, that you have changed the reset part, to also support LPC-Devices, I tried the current release.
While I had no problem programming my device with the sequence of my last post, I ran into several problems with the GUI-Programming.

  1. "Detect Chip" will report "Execution of TCL script returned an error" every first time. Independent of the Reset Method. After the first run the device is in reset and thus a secound run of "Detect Chip" works.

  2. "Program Flash" fails with report " BDM has no connection to target". Also independent of the Reset Method. The only way to programm a device is by running "Detect Chip" first.

Is it possible that the command sequence and the GUI-Programming dont use the same code sequence?

Unfortunately I didn't had time to examine this further. I hope I'll find some time during the next few days or at least during the X-Mas days.
I'll come back to you as soon as I'll have more infos.

Thanks,

Roman