I am adapting some test software that is used to upload a .bin file to one of our products via USB. The product has a Atmel AT91SAM7X256 processor. The software is all written in c# and is running on a windows XP machine.
The previous programmer (no longer with the company) uses a dll file called AT91BootDLL.dll to scan USB ports for an ateml processor and obtain an handle on it. Then it can open a USB connection and do various things like read, write etc. This all works fine but every now and then it can no longer find anything connected. When this happens I can no longer connect anything to the PC via USB as windows fails to detect it. I then have to shut-down the PC and when doing this windows decides to freeze.
I need to get to the bottom of it and as I have no experience with either this dll or embedded programming I only have these conclusions. Either the processor is doing something causing the USB ports to lock-up or this dll file is doing it.
Is there anything I can do in the program that might help prevent this?
For uploading and then reading back from this processor, does anyone know of an alternative method?
Here is some of the code used in scanning and opening.
private static AT91BootDLL at91 = new AT91BootDLL();
private static unsafe int GetHandle()
{
// Create a dummy list for the dummy SAM-BA interface ;-)
byte* dummyName = stackalloc byte[100];
byte** dummyList = stackalloc byte*[100]; // { n1, n2, n3, n4, n5 };
for (int i = 0; i < 100; ++i)
{
dummyList[i] = dummyName;
}
// This function needs to be called before a USB connection can be opened.
at91.AT91Boot_Scan(ref *(byte*)dummyList);
// Now that the scan function has been called, we may open an USB connection.
int handle;
byte[] name = Encoding.ASCII.GetBytes("\\usb\\ARM0\x00");
at91.AT91Boot_Open(ref name[0], out handle);
return handle;
}