PICkit 2 again with HPS stack

Xiaofan Chen xiaofanc at gmail.com
Tue Oct 16 16:36:22 PDT 2007


On 10/17/07, Hans Petter Selasky <hselasky at c2i.net> wrote:

> > Thanks a lot. So it seems there is still a bug in the firmware. Maybe two.
> > The first one caused the stall (why?). The second one is still related to
> > dealing with clear stall feature reques
>
> I think that the clear-stall command will flush the FIFO of the interrupt
> endpoint.
>
> Is it possible that you can open the interrupt endpoint which is a
> file, /dev/ugenX.X, before sending the version command ? So that we
> don't end up clearing the stall after sending the command, but before.
>

PICkit 2 applications I am testing now are all using libusb. I have
not really looked into the libusb FreeBSD codes (I am not good
at programming) but I will try.

I have the following codes from a FreeBSD user. He is trying not to
use libusb. I will try to add his codes to see if it helps.

static void check_device_id(void)
{
    usb_device_descriptor_t udd;

    ioctl(fdpk2, USB_GET_DEVICE_DESC, &udd);
    if (udd.idVendor != vidMicrochip || udd.idProduct != pidPICkit2)
        die("device isn't a PICkit2");
}

void pk2open(char *devname)
{
    printf("pk2open =>\n");
    fdpk2 = open(devname, O_RDWR);
    if (fdpk2 < 0)
        die_errno("open failed");
    check_device_id();
    printf("pk2open <=\n");
}

static char *pk2dev = "/dev/ugen0.1";

int main(int argc, char **argv)
{
    pk2open(pk2dev);
    ...
}



Regards,
Xiaofan


More information about the freebsd-usb mailing list