PDFUSB bootloader: problem with catching errors

9 views
Skip to first unread message

Sebastien Lelong

unread,
Sep 30, 2010, 3:54:35 AM9/30/10
to jal...@googlegroups.com
Hi Albert, guys,

I've struggled to make PDFUSB bootloader work on a new Linux based PC. This is basically a user permission error, I wasn't able to read USB devices.

The problem is I had to modify bootloader host application to track the error, until I reach an error explaining the problem ("Operation not permitted"). I think USB bootloader app catches too many exception, without reporting to user. In  UsbBootLoader.py, UsbBootLoader.WaitForDevice():


            try: 
                version_number = usb_driver.ReadVersion()
            
            except:    
                """ catch exception """ 

This will catch any exceptions, the one(s) raised when USB device isn't there (reset needed), but also those related to system error. I would suggest to refine the except part (which, in this form, is a bad practice anyway) to only catch relevant errors.

From what I understand, in this part of the code, we're waiting for the device. So either it is here, either it's not and in this case, we'll have an AttributeError, where a method isn't defined (USB handle is None). I would suggest the following:

            try: 
                version_number = usb_driver.ReadVersion()
            
            except AttributeError:    
                """ catch exception """   
                # if we get there, this means USB object doesn't have
                # appropriate method defined, meaning USB device
                # meaning USB device doesn't exist on the system
                pass

This way, any error not related to finding the device should be reported to users (including any permissions errors).

Would this sound reasonable to you ? Do you agree ?


Cheers,
Seb



--
Sébastien Lelong
http://www.sirloon.net
http://sirbot.org

mattschinkel

unread,
Sep 30, 2010, 4:13:34 PM9/30/10
to jallib
PDFUSB does not work on 18f67j50. USB attaches to the system ok and I
can select the USB board in PDFUSB, but when I try to program it says
"WARNING - Failed to program FLASH". I did do the steps in the blog
and added the command line options when compiling a blink sample.

Does this only work on 18f4550? Is there a reason why it may not work
on my PIC?

Matt.

Sebastien Lelong

unread,
Oct 15, 2010, 2:30:00 PM10/15/10
to jal...@googlegroups.com
Hi Matt,

What did you do to get this warning message ? I would have expected to find it in sources, but nope...

I don't know what's going on for you, but it should work. It runs on 18f4550, and also 18f14k50. Maybe some other PICs (I guess also 18f2550). How did you compile the bootloader ?

Cheers,
Seb

PS: as of revision 2262 I restricted exception handling as mentioned above.

2010/9/30 mattschinkel <mattsc...@hotmail.com>

--
You received this message because you are subscribed to the Google Groups "jallib" group.
To post to this group, send email to jal...@googlegroups.com.
To unsubscribe from this group, send email to jallib+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jallib?hl=en.

mattschinkel

unread,
Oct 15, 2010, 2:42:01 PM10/15/10
to jallib
> What did you do to get this warning message ? I would have expected to find
> it in sources, but nope...

thanks for following up... PDFUSB gave the warning after I try to send
a .hex file. Maybe my PIC writes to it's data space differently then
others?

> I don't know what's going on for you, but it should work. It runs on
> 18f4550, and also 18f14k50. Maybe some other PICs (I guess also 18f2550).
> How did you compile the bootloader ?

I just changed the chip def at the top of the 18f4550 sample.
Shouldn't it work without any other changes? I didn't get any warnings/
errors. When compiling a sample, I changed the command line parameters
for usb bootloader.

Matt.

Sebastien Lelong

unread,
Oct 15, 2010, 2:46:55 PM10/15/10
to jal...@googlegroups.com
Well, this is a "shy" follow-up, I just don't know what's going on, and probably won't be able to help. All I can try to is to diagnose system related problems. On linux... 

Do you have full output ?

cheers
Seb

2010/10/15 mattschinkel <mattsc...@hotmail.com>

Matt.

--
You received this message because you are subscribed to the Google Groups "jallib" group.
To post to this group, send email to jal...@googlegroups.com.
To unsubscribe from this group, send email to jallib+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jallib?hl=en.

mattschinkel

unread,
Oct 15, 2010, 4:06:16 PM10/15/10
to jallib
> Well, this is a "shy" follow-up, I just don't know what's going on, and
> probably won't be able to help. All I can try to is to diagnose system
> related problems. On linux...

I may have to wait till someone else tries. I don't know much about
this sample/lib

> Do you have full output ?

I'm not sure what you are looking for. a hex file?

Matt.
Reply all
Reply to author
Forward
0 new messages