Searching \ for '[PIC] Porting libusb application to Windows using' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=port
Search entire site for: 'Porting libusb application to Windows using'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] Porting libusb application to Windows using '
2005\07\24@231401 by Chen Xiao Fan

face
flavicon
face
Over the weekend I was trying to port two Linux applications
to Windows using libusb-win32 and MingW.

One application is Mark Rages' PICkit 1 application used
to be at mlug.missouri.edu/~markrages/software/usb_pickit/.
It seems to me that the web site is down now.

The other is Rick Luddy's USB bootloader for the PIC FS USB
demo board at http://internetking.org/fsusb/.

Both are based on Orion Sky Lawlor's original work for PICkit 1
at the following URL:
http://lawlor.cs.uaf.edu/~olawlor/projects/2003/microchip/index.html.

For Orion and Mark Rages' PICKit 1 host application,
I made some changes to the Makefile (to set the correct
libusb location) and a small modification of usb_picpit.c (to
comment out the two lines of codes checking geteuid
which is not available on Windows) and can compile the
application. However the final application is not working.
It can not even be killed so that I have to reboot the PC.

What would be the reason here?

The next application if Rick Luddy's USB bootloader for PIC FS USB.
I changed the libusb location in the Makefile and disabled geteuid
checking in file fsusb.c. However this time the build process
failed at the make step for the file rjlhex.c.

$ make
gcc -Wall -D_GNU_SOURCE -Ic:\Progra~1\libusb/include -o fsusb main.o
fsusb.o rjlhex.o memimg.o -Lc:\Progra~1\libusb/lib/gcc -lusb

Info: resolving _usb_busses by linking to __imp__usb_busses (auto-import)
rjlhex.o(.text+0x10e):rjlhex.c: undefined reference to `getline'
make: *** [fsusb] Error 1

I think I must miss something obvious here. Any MingW and libusb
experts out here?

Regards,
Xiaofan

2005\07\24@235146 by Mark Rages

face picon face
On 7/24/05, Chen Xiao Fan <spam_OUTxiaofanTakeThisOuTspamsg.pepperl-fuchs.com> wrote:
> Over the weekend I was trying to port two Linux applications
> to Windows using libusb-win32 and MingW.
>
> One application is Mark Rages' PICkit 1 application used
> to be at mlug.missouri.edu/~markrages/software/usb_pickit/.
> It seems to me that the web site is down now.
>

The website's back up now.

On Linux, you can diagnose a lock condition with "ltrace" which logs
each function call the program makes.  Google says there is a similar
tool for Windows called "apispy".  The lockup almost certainly is
happening with libusb-win32.  You might ask on their mailing list for
advice.

Good luck with your porting effort!  Send the patch when you get it working.

Regards,
Mark
markrages@gmail
--
You think that it is a secret, but it never has been one.
 - fortune cookie

2005\07\25@001602 by Chen Xiao Fan

face
flavicon
face
Just to add the changed parts of Makefile and fsusb.c
for fsusb-0.1.11. The same changes are applied
to usb_pickit by Mark Rages.

1) Makefile
# This file is part of fsusb_picdem
# from http://internetking.org/fsusb/
# by Rick Luddy, version 0.1.11
# Trying to port it to Windows by
# Chen Xiaofan

# add this line to point to the correct
# location of libusb under windows
# try /c/Progra~1/libusb if not working
LIBUSB=c:\Progra~1\libusb

OPTS=-Wall -D_GNU_SOURCE
OBJS=fsusb.o rjlhex.o memimg.o

CFLAGS=$(OPTS) -I$(LIBUSB)/include

# change this line to point to the
# correct MingW version of libusb
#LDFLAGS=-L$(LIBUSB)/lib -lusb
LDFLAGS=-L$(LIBUSB)/lib/gcc -lusb

2)fsusb.c
/* changes by Chen Xiaofan */
/* geteuid is only working on Linux */
/*
 if (geteuid()!=0) {
   bad("This program must be run as root, or made setuid root");
 }
*/

2005\07\25@014909 by Hasan A. Khan

flavicon
face
Hi,
First problem, I am sure you know that simply comiling
the code doesn't mean it will run on another OS too.
You need to find the equivalent function call in
Linux.  I think it is 'getuid' but look it up.  There
is a whole library of function calls in Unix that
deals with users and processes on Unix.  Try 'man
getuid' or 'man -k uid' to get some related man pages.
You need to be very carefull while dealing with user
related code (permissing levels etc.) and processes
(creating and reaping processes and child processes.
You could easily end up with hung and zomby processes.

I have never ported from Windows to Linux but I do
have some experience with other Unix on servers.  This
is obviously a link-time error.  Meaning the linker
can't find the library it wants for defining getline
code.  'getline' is a fundamental Unix function which
deals with get a whole line of text from 'files'
(files, keyboards, serial ports, USB ports etc.)

One obvious thing I noticed was the '\' characters in
your lib paths.  On Unix '\' is an escape character.
Does Linux on PC allow this?  May be the path should
be -Lc:/Progra~1/libusb/lib/gcc ?

Good luck!

--- Chen Xiao Fan <.....xiaofanKILLspamspam@spam@sg.pepperl-fuchs.com>
wrote:

> Over the weekend I was trying to port two Linux
> applications
> to Windows using libusb-win32 and MingW.
>
> One application is Mark Rages' PICkit 1 application
> used
> to be at
>
mlug.missouri.edu/~markrages/software/usb_pickit/.
> It seems to me that the web site is down now.
>
> The other is Rick Luddy's USB bootloader for the PIC
> FS USB
> demo board at http://internetking.org/fsusb/.
>
> Both are based on Orion Sky Lawlor's original work
> for PICkit 1
> at the following URL:
>
lawlor.cs.uaf.edu/~olawlor/projects/2003/microchip/index.html.
{Quote hidden}

> --

2005\07\25@022552 by Jan Wagemakers

flavicon
face
"Hasan A. Khan" <hasanspamKILLspamkhansden.com> schreef:

>> Over the weekend I was trying to port two Linux
>> applications to Windows using libusb-win32 and MingW.
> First problem, I am sure you know that simply compiling
> the code doesn't mean it will run on another OS too.

Maybe it is better to move this question to the mingw
<http://www.mingw.org/lists.shtml> mailings-list?

Anyway, FWIW, a while ago, I have used mingw to cross-compile a little
C-program that I had written to MS\Windows. It compiled without problems,
but wasn't working correctly. A small change
<http://janw.nipl.net/diary/index.php?/archives/2005/05/19.html> to the
program fixed this problem.


--
Met vriendelijke groetjes         - Jan Wagemakers -

 Linux 2.6.12.2 i686 GNU/Linux

2005\07\25@025018 by Chen Xiao Fan

face
flavicon
face
Please take note that I am porting Linux application
to Windows, not from Windows to Linux.

There is libusb-win32 problem in the usb_pickit application.
There is another MingW problem in the fsusb application.

Anyway, I will try to look for some helps from the
MingW mailing list and libusb-win32 mailing list.
I have not subscribed to both lists and I am
reading them from Gmane. Maybe it is simply beyond
my C skills but I will try. Let's wait and see.

Regards,
Xiaofan

{Original Message removed}

2005\07\25@030129 by Hasan A. Khan

flavicon
face
Oops!  Sorry for the blunder and not paying attension.
But conceptually my comments still apply to windows
too.  Just reverse everything :)

This discussion needs to move to some other relavent
list.  No more replys from me.

--- Chen Xiao Fan <.....xiaofanKILLspamspam.....sg.pepperl-fuchs.com>
wrote:

{Quote hidden}

> {Original Message removed}

2005\07\25@204651 by Chen Xiao Fan

face
flavicon
face
I found that there was a post regarding getline in
the MingW list but nobody has answered the question.
Anyway, I downloaded getline.c and getline.h from
Internet and now I can build fsusb-0.1.11 without
any errors. I just modified rjlhex.c to include
"getline.h" and added getline.o to the OBJS list
of the Makefile.

As for the libusb problem I think I may have found the
problem after reading the Microchip Forum USB section
and the lecture notes of the following website. I will
try the fix later and report the progress.
http://pe.ece.olin.edu/ece/

Regards,
Xiaofan


-----Original Message-----
From: Chen Xiao Fan
Sent: Monday, July 25, 2005 2:50 PM
...
There is libusb-win32 problem in the usb_pickit application.
There is another MingW problem in the fsusb application.
...

2005\07\25@205918 by Chen Xiao Fan

face
flavicon
face
One small question here. There is an Info output I do not
quite understand. What does it really mean? Seems to be
a warning sign.

Regards,
Xiaofan

System: Windows XP, GCC 3.2.3 from MingW and libusb 0.1.10.1.

C:\Myprog\fsusb-0.1.11>make
gcc -Wall -D_GNU_SOURCE -Ic:\Progra~1\libusb/include   -c -o rjlhex.o
rjlhex.c
gcc -Wall -D_GNU_SOURCE -Ic:\Progra~1\libusb/include   -c -o getline.o
getline.c

gcc -Wall -D_GNU_SOURCE -Ic:\Progra~1\libusb/include -o fsusb main.o fsusb.o
rjl
hex.o memimg.o getline.o -Lc:\Progra~1\libusb/lib/gcc -lusb
Info: resolving _usb_busses by linking to __imp__usb_busses (auto-import)

2005\07\26@011334 by Chen Xiao Fan

face
flavicon
face
Okay some progress here. Using the inf-wizard provided
by Libusb (libusb-win32-device-bin-0.1.10.1) and I have
created the inf files for PICkit 1 and PIC FS USB demo
boards.

The test on PICKit 1 shows that Windows start to
recognize the PICKit 1 as a valid LIBUSB device. The
usb_pickit application will no longer hang. Still there
is problem with usb_read. Need to check again the notes
of Olin College and LIBUSB lists.

Regards,
Xiaofan

-----Original Message-----
From: Chen Xiao Fan
Sent: Tuesday, July 26, 2005 8:47 AM
...
As for the libusb problem I think I may have found the
problem after reading the Microchip Forum USB section
and the lecture notes of the following website. I will
try the fix later and report the progress.
http://pe.ece.olin.edu/ece/

Regards,
Xiaofan

2005\07\26@040036 by Alan B. Pearce

face picon face
>and the lecture notes of the following website.
...
> http://pe.ece.olin.edu/ece/

Olin has his own educational establishment ???? WOW ;)))))

2005\07\26@050448 by Wouter van Ooijen

face picon face
> >and the lecture notes of the following website.
> ...
> > http://pe.ece.olin.edu/ece/
>
> Olin has his own educational establishment ???? WOW ;)))))

and he teaches "Eclectronic System Design"!

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products
docent Hogeschool van Utrecht: http://www.voti.nl/hvu


2005\07\27@134136 by Hasan A. Khan

flavicon
face
I can't say it is a warning for sure but it doesn't
look like a serious problem.  I haven't seen the
actual code so I am assuming the code was written in
C++.  What this message is telling you is that the
abstract class _usb_busses is being linked to its
implementation in the __imp__usb_busses class.  'imp'
or 'impl' is a prefix convention used in C++ which
shows that this class is an implementation of its
abstract class.  '_' characters are added by the
preprocessor to make sure the name doesn't confilict
with some system symbol.

Abstract-implementation classes are a fundamental
concept in OOP and is out of scope here.  I hope I
have answered your question though.

--- Chen Xiao Fan <EraseMExiaofanspam_OUTspamTakeThisOuTsg.pepperl-fuchs.com>
wrote:

{Quote hidden}

> --


'[PIC] Porting libusb application to Windows using '
2005\08\04@091147 by Chen Xiao Fan
face
flavicon
face
With the help of the developer of libusb-win32 Stephan Meyer, I have
my first success in the porting efforts. I have ported
Rick Luddy's USB Linux bootloader for the PIC FS USB demo board to
Windows.

Since I do not have a web site, I will list the changes here.

1) solve the problem of getline with Mingw by downloading
getline.c and getline.h from the internet and adds the
header file to rjlhex.c. Add getline.o to the make file as well.

2) the other changes are all applied to fsusb.c
a) remove call to geteuid. Windows does not have this.
b) for (bus=usb_busses;bus!=NULL;bus=bus->next) {
-->    for (bus=usb_get_busses();bus!=NULL;bus=bus->next) {
c) The main problem is the endpoint address. Linux libusb is
not so strict as libusb-win32.

c1) change "const static int fsusb_endpoint=1" to
"const static int fsusb_endpoint_in=0x81" and
const static int fsusb_endpoint_out=1".

c2) change
r=usb_bulk_read(d, fsusb_endpoint, dest, len, fsusb_timeout);
to:
r=usb_bulk_read(d, fsusb_endpoint_out, dest, len, fsusb_timeout);

c3) change
r=usb_bulk_write(d, fsusb_endpoint, "\0\0\0\0\0", 5, fsusb_timeout);
to:
r=usb_bulk_write(d, fsusb_endpoint_in, "\0\0\0\0\0", 5, fsusb_timeout);

c4) change the rest of the usb_bulk_write() functions to use
fsusb_endpoint_in.

After these changes, the fsusb application works just like the Linux
version. It seems that the Linux version of libusb is not so
strict on the endpoint address. Despite the error message when
flashing the HID demo hex file, the firmware seems to work
properly. I have the same error message under Linux. So this is
not the problem in the porting.

If possible I would like to post the changed codes and the compiled
application to a web site. The ported application is command
line based and require the installation of the filter driver
of libusb-win32 and the original Microchip drivers.

My next step is the usb_pickit application.

Regards,
Xiaofan

--------------
Sample session using MSYS:

Test@PCAMD64 /e/Coding/fsusb0111
$ fsusb picdemfsusb.hex 1>picfsusbmsg.txt 2>&1

Test@PCAMD64 /e/Coding/fsusb0111
$ less picfsusbmsg.txt
Locating USB Microchip(tm) PICDEM-FS USB(tm) (vendor 0x04d8/product 0x000b)
found 3 busses
Found USB PICDEM-FS USB as device '\\.\libusb0-0003--0x04d8-0x000b' on USB
bus bus-1
Communication established.  Onboard firmware version is 1.0
Writing program memory successful
Program memory validated

Test@PCAMD64 /e/Coding/fsusb0111
$ fsusb hid.hex 1>hid.txt 2>&1

Test@PCAMD64 /e/Coding/fsusb0111
$ less hid.txt
Locating USB Microchip(tm) PICDEM-FS USB(tm) (vendor 0x04d8/product 0x000b)
found 3 busses
Found USB PICDEM-FS USB as device '\\.\libusb0-0003--0x04d8-0x000b' on USB
bus bus-1
Communication established.  Onboard firmware version is 1.0
Writing program memory successful
mismatch in 32-byte chunk at 0x00000000:
File:  95ef0af01200####################################################
Device:e3ef03f01200ffff04ef04f01200ffffffffffffffffffff0cef04f01200ffff
Program memory contains errors!


{Original Message removed}

2005\08\04@093711 by Alan B. Pearce

face picon face
>If possible I would like to post the changed codes and the
>compiled application to a web site. The ported application
>is command line based and require the installation of the
>filter driver of libusb-win32 and the original Microchip drivers.

I am sure James will be only too happy to have you set up a page on
piclist.com

2005\08\04@171548 by James Newton, Host

face picon face
Space is always available at piclist.com

---
James.



{Quote hidden}

> --

2005\08\04@172631 by James Newton, Host

face picon face
Alan B. Pearce
>
> >If possible I would like to post the changed codes and the compiled
> >application to a web site. The ported application is command
> line based
> >and require the installation of the filter driver of
> libusb-win32 and
> >the original Microchip drivers.
>
> I am sure James will be only too happy to have you set up a
> page on piclist.com


What he said.

---
James Newton: PICList webmaster/Admin
TakeThisOuTjamesnewtonEraseMEspamspam_OUTpiclist.com  1-619-652-0593 phone
http://www.piclist.com/member/JMN-EFP-786
PIC/PICList FAQ: http://www.piclist.com



2005\08\04@215116 by Chen Xiao Fan

face
flavicon
face
Thanks James for hosting the very useful PIClist and
PICList.com.

Sorry but how do I put the source code and application
to piclist.com? How to upload files to my member page?

I will tidy up the codes and add some comments (maybe
a README file on how to build and use the application,
as well as more comments to the code itself).

I will try to port usb_pickit (for PICKit 1) before I
do the tidy up of fsusb (for PICDEM FS USB).

Regards,
Xiaofan

-----Original Message-----
From: James Newton, Host
Sent: Friday, August 05, 2005 5:16 AM

Space is always available at piclist.com

---
James.

2005\08\04@223224 by Mark Rages

face picon face
On 8/4/05, Chen Xiao Fan <RemoveMExiaofanspamTakeThisOuTsg.pepperl-fuchs.com> wrote:
>
> I will try to port usb_pickit (for PICKit 1) before I
> do the tidy up of fsusb (for PICDEM FS USB).
>
> Regards,
> Xiaofan
>

Let me know when you do and I'll roll the changes into my version of usb_pickit.

BTW, My little girl arrived:  http://mlug.missouri.edu/~markrages/blog

Regards,
Mark
markrages@gmail
--
You think that it is a secret, but it never has been one.
 - fortune cookie

2005\08\04@224026 by James Newton, Host

face picon face
In general, read the text at the bottom of the page.

First, sign up for a member page. You will be sent an email with a
"passcode" and a link to log in.

Click on that link. It will log you in and show you your member page. If you
look at the form on the bottom you will see that you have the option to edit
the HTML source of the page (and if you use IE v5.5 or higher to wysiwyg
edit). Then you can put whatever you like up on the server.

The only exception is graphics images, those must be emailed to me so I can
approve them before I post them to the page. This is to prevent myself from
becoming a porn site without knowing it. *grin*

The form at the bottom of the page is also an easy way to post a comment,
link, code (preformatted) or questions.

And if you can tell my how it was that this wasn't obvious from ready any
page on the site, I will do what I can to make it more so.

---
James.



> {Original Message removed}

2005\08\04@231245 by Chen Xiao Fan

face
flavicon
face
Sorry but I do not like any web based WYSIWYG HTML editor.
I have a member page and I do not put anything there simply
because I find it troublesome to use the HTML editor. Maybe
I am just a bit lazy. I would like to be able to upload plain
html and txt files (.asm, .c, .h, Makefile, etc) directly.
For binary files, I understand there will be concerns about
virus or other things. Still I would like to ask the question
if I can upload an exe file or not.

As for the PIClist website, it has a lot of treasures.
However I am sorry to say that generally the organization
is not that easy to follow.

Regards,
Xiaofan

{Original Message removed}

2005\08\04@232255 by Chen Xiao Fan

face
flavicon
face
Congratulations!

Sure I will send you the changes one it is ready. I hope it
will be more smooth than porting of fsusb.

I think I will try to email Rick Luddy about the changes
to fsusb and I'd prefer to combine my changes to his original
Linux application as well. I will test if the changes break
the Linux side or not. Then people would need only
one place to download the application for Linux and Windows.

Regards,
Xiaofan

-----Original Message-----
From: Mark Rages
Sent: Friday, August 05, 2005 10:32 AM

Let me know when you do and I'll roll the changes into my
version of usb_pickit.

BTW, My little girl arrived:
http://mlug.missouri.edu/~markrages/blog

Regards,
Mark
markrages@gmail

2005\08\05@032210 by James Newtons Massmind

face picon face
So:

If the organization is not good, become a page editor and fix it.

If you don't like the wysiwyg editor, use the form to post your text files
directly.

Or post it to this list and it will go into the archive on the site anyway.

Or go post you stuff to one of the free sites with the pop up ads

Or pay someone for your own site.

Or don't publish.

Please don't talk to me about it anymore.

---
James.



> {Original Message removed}

2005\08\06@025037 by Chen Xiao Fan

face
flavicon
face
Finally I put the modified part to my member page. I will still
try to contact the original authour to see if it is possible
to incorporate the changes to the Linux version.

During the post I keep receiving vbscript error but anyway the
changes are there right now.

My PIClist member page is at the following URL. Please feedback
to me regarding the building and installation of the ported
application.

http://www.piclist.com/techref/member/xiaofan-sg-/index.htm

Regards,
Xiaofan

2005\08\06@083227 by Chen Xiao Fan
face
flavicon
face
I have uploaded my file to Microchip forum so that everyone
can download the source code and the build instruction. The
compiled application is included as well. To use it, you still
need to download libusb-win32 device driver or the libusb-win32
filter driver (us together with Microchip driver) from the
libusb-win32 website.

The URL is http://forum.microchip.com/tm.asp?m=106426.

Regards,
Xiaofan

2005\08\09@203036 by Chen Xiao Fan

face
flavicon
face
James has since fixed the vbscript error and the problem is
solved. PICList.com interface is quite easy to use after all.
So let us start to use the interface and use it more often.
By all means, PIClist.com has the largest pool of information
related to PIC other than Microchip. There are much more
relevant information as well.

Regards,
Xiaofan

{Original Message removed}

2005\08\11@204027 by Chen Xiao Fan

face
flavicon
face
I found out a file in my hard disk named fsusb_demo_linux.c
written by Manuel Bessler but I forgot where I got it.
I slightly modified the source code and hope it will be
working on both Linux and Windows. However right now it is
only working under Linux. The Windows version fsusb_demo.exe
does not work right now.

Together with fsusb, it is the replacement for Microchip's
close source PDFUSB.exe PC application (PICDEM FS USB demo tool).

For those interested, please go to Microchip Forum USB
section. By the way, Microchip Forum is actually quite
good in areas like dsPIC, MPLAB C18, MPLAB C30, USB and
which are not covered so much in PIClist.
http://forum.microchip.com/tm.asp?m=107340

Regards,
Xiaofan

-----Original Message-----
From: Chen Xiao Fan
Sent: Saturday, August 06, 2005 8:32 PM

I have uploaded my file to Microchip forum so that everyone
can download the source code and the build instruction. The
compiled application is included as well. To use it, you still
need to download libusb-win32 device driver or the libusb-win32
filter driver (us together with Microchip driver) from the
libusb-win32 website.

The URL is http://forum.microchip.com/tm.asp?m=106426.

Regards,
Xiaofan

2005\08\12@104119 by Chen Xiao Fan

face
flavicon
face
I have sinced found the bugs in my Windows port. Now all
three applications (fsusb, fsusb_demo and usb_pickit) are
all working under Windows (as well as Linux).

The three applications can be downloaded from Microchip forum. I
find libusb-win32 much easier to deal with than Microchip supplied
dll and driver.

http://forum.microchip.com/tm.asp?m=106529
usb_pickit, an command line application for PICkit 1 programmer

http://forum.microchip.com/tm.asp?m=106426
fsusb: PIC FS USB demo board bootloader application which works
with Microchip bootloader firmware.

http://forum.microchip.com/tm.asp?m=107340
fsusb_demo: PICDEM FS USB Demo application which works with
Microchip Demo firmware.

Regards,
Xiaofan

More... (looser matching)
- Last day of these posts
- In 2005 , 2006 only
- Today
- New search...