Author Topic: Using Production System NET and SWD over Link2  (Read 80 times)

smercurio

  • Jr. Member
  • **
  • Posts: 5
    • View Profile
Using Production System NET and SWD over Link2
« on: November 10, 2017, 08:25:10 am »
We previously used Production System NET to program LPC1769 chips over a serial interface. This go-around, due to the design, we can't use the serial port, so we have to switch to using SWD over Link2. We are using Production System NET v10.60. While the stand-alone Flash Magic application works when "SWD over Link2" is selected, we can't get the .NET libraries to work.

The first problem is that the interface looks for USBDriver.dll. This is not mentioned in any of the documentation. This DLL needs to be placed in C:\Windows\System32 on 32-bit systems and C:\WINDOWS\SysWOW64 on 64-bit systems. Placing it in the same directory where the other DLLs (FlashMagicARMCortex.dll, etc) doesn't work.

Once you get that straightened out, the Connect function throws an error: "Unable to communicate. Serial number not found". I have no idea what serial number it's looking for. If it's for the LPC1769, it's not going to find one, since as far as I know, it doesn't have one. Is there something else that needs to be done to get SWD over Link2 to work with Production System NET?

Andy Ayre

  • ESAcademy Staff
  • Sr. Member
  • *****
  • Posts: 2121
    • View Profile
    • Embedded Systems Academy, Inc.
    • Email
Re: Using Production System NET and SWD over Link2
« Reply #1 on: November 13, 2017, 12:47:18 am »
USBDriver.dll should work if placed in the same folder as everything else.

Flash Magic supports multiple Link2s connected at the same time. In order to tell them apart each Link2 interface has a unique serial number. You can see the serial numbers by running this on the command line from inside the Flash Magic installation folder:

  USBManager --list

The serial numbers are also show in the GUI version of Flash Magic, e.g:

  SWD over Link2 (xxxxxxxxx)

If you are only going to connect one Link2 at the same time and you don't care about the serial number then set the interfaceserialnumber field to an empty string. Make sure you are using the latest version of Flash Magic as support for this was only added recently.

Andy
Embedded Systems Academy, Inc.
support at esacademy dot com

smercurio

  • Jr. Member
  • **
  • Posts: 5
    • View Profile
Re: Using Production System NET and SWD over Link2
« Reply #2 on: November 14, 2017, 07:40:33 am »
Thanks for the response. I tried setting the interfaceserialnumber field to an empty string, but it still returns the "Unable to communicate. Serial number not found" error. If I set that field to the actual serial number (as displayed in the GUI version or from the USBManager.exe output), then it works as expected.

As I noted, we're using v10.60. Does the setting of the interfaceserialnumber field to an empty string only work on newer versions than that?

Andy Ayre

  • ESAcademy Staff
  • Sr. Member
  • *****
  • Posts: 2121
    • View Profile
    • Embedded Systems Academy, Inc.
    • Email
Re: Using Production System NET and SWD over Link2
« Reply #3 on: November 15, 2017, 01:27:09 am »
Should work. Please show me where you initialize the COMOptions structure and also what version number is returned from FlashMagicARMCortex.Version().

Andy
Embedded Systems Academy, Inc.
support at esacademy dot com

smercurio

  • Jr. Member
  • **
  • Posts: 5
    • View Profile
Re: Using Production System NET and SWD over Link2
« Reply #4 on: November 15, 2017, 07:30:39 am »
I created a .NET library to act as an intermediary between LabVIEW and the FlashMagic library. This was done because the LabVIEW code was still using LabVIEW 8.2, which didn't always work all that well with third-party .NET assemblies, especially with callbacks. The .NET library I wrote does the process of downloading the firmware file using the Flash Magic .NET library. In the solution I have a test application that's just a simple form to provide the hex file to download, a textbox for displaying status, and a button to test erasing of sectors. This test application is used so I can test our custom library's operations directly in Visual Studio. We've since updated to LabVIEW 2017, but I have not changed the LabVIEW code yet - i.e., it's still using the intermediary .NET library.

In the constructor of this custom library I set the COM options:
Code: [Select]
public LPC1769(string comPortIn, string link2SerialNumberIn)
{
this.comOptions.baudrate = 19200;
this.comOptions.clocks = 0;
this.comOptions.flashbank = 0;
this.comOptions.halfduplex = 0;
this.comOptions.highspeed = 0;
this.comOptions.hwconfig = HardwareConfigurations.BOOTEXEC;
this.comOptions.hwt1 = 240;
this.comOptions.hwt2 = 120;
this.comOptions.interfacetype = Interfaces.SWDLINK2;
this.comOptions.maxbaudrate = 115200;
this.comOptions.osc = 14.748;
this.comOptions.port = comPortIn;
this.comOptions.postopendelay = 0;
this.comOptions.protocoloptions = ProtocolOptions.AUTOLF;
this.comOptions.selecteddevice = Devices.LPC1769;
this.comOptions.usinginterface = 0;
this.comOptions.interfaceserialnumber = link2SerialNumberIn;
}

As I noted, if link2SerialNumberIn is set to an empty string, I get the "Unable to communicate. Serial number not found" error when the Connect() method is called. This occurs with the .NET test application as well, since it's simply using the LPC1769 library. If I set link2SerialNumberIn to the serial number of the LPC Link-2 device (s3fUQ6uY9uk6 in our case), then it works (both in the .NET test application as well as from LabVIEW).

As for the version number, the value that's returned is 7.85.4776.

Andy Ayre

  • ESAcademy Staff
  • Sr. Member
  • *****
  • Posts: 2121
    • View Profile
    • Embedded Systems Academy, Inc.
    • Email
Re: Using Production System NET and SWD over Link2
« Reply #5 on: November 15, 2017, 07:42:22 am »
Your version is not new enough. Support for this was added in Flash Magic 10.67. If you wish to get access to the production system version by extending your support/update agreement then please email us.

Andy
Embedded Systems Academy, Inc.
support at esacademy dot com

smercurio

  • Jr. Member
  • **
  • Posts: 5
    • View Profile
Re: Using Production System NET and SWD over Link2
« Reply #6 on: November 15, 2017, 07:47:32 am »
Ah, so it is due to the version number. OK, that makes sense.

I'll forward this information to my engineering manager. For the time being, so we can do our initial checkout of our autotest software, I added a step in the LabVIEW code to call USBManager.exe and parse out the serial number from USBManager's output. I then pass this into the constructor of our custom library. With that, the whole process works as it does with the Flash Magic application. Long term we will need to update our Flash Magic software.

Thanks for verifying it's a version number issue.

Andy Ayre

  • ESAcademy Staff
  • Sr. Member
  • *****
  • Posts: 2121
    • View Profile
    • Embedded Systems Academy, Inc.
    • Email
Re: Using Production System NET and SWD over Link2
« Reply #7 on: November 15, 2017, 07:56:02 am »
In case you didn't see it USBManager has a mode exactly for this purpose. Try:

  USBManager --nobanner --seriallist

Andy
Embedded Systems Academy, Inc.
support at esacademy dot com

smercurio

  • Jr. Member
  • **
  • Posts: 5
    • View Profile
Re: Using Production System NET and SWD over Link2
« Reply #8 on: November 15, 2017, 08:07:26 am »
Thanks for the tip. That certainly simplifies the parsing! ;)