Author Topic: BULK_USB transfer for USB2JTAG  (Read 16817 times)

cristianBCC

  • Member
  • ***
  • Posts: 4
BULK_USB transfer for USB2JTAG
« on: May 26, 2021, 10:53:54 am »
hello everyone
i'm an Italian Electronic Engineer student
i'm writing code for a PIC18F4550 to use it as USB 2 JTAG converter in order to make an interface with a SPARTAN 6 FPGA (to control it and to write the bitstream in it). I've decided to start from an exisisting project by XESSCORP, that is the firmware of the uC in the XULA2 board (from GitHub: https://github.com/xesscorp/XuLA2 ). This is a BULK trasfer USB protocol based project for a PIC18F14K50, due to the fact that the project was designed for a different microcontroller i've modified it in order to adapt it to PIC18F4550, moreover, the project was very old so it was created with the old MPLAB IDE that included the header file in its installation directory, for this reason i had to research the header files from the web and i found them in a SCILAB project that is PIC18F4550 native and this is rigth a BULK USB transfer project (http://forge.scilab.org/index.php/p/usb-toolbox/source/tree/15/PIC18F4550/BULK). In conclusion, by including the rigth header and by adapting what is different in the two PIC version i managed to compile the project succesfully ( i've also adapted the linker file and removed the bootloader ). BUT, when i've tried to connect the PIC via USB to the PC it does not recognize it, it does not work, nothing is happening after connection both in linux and in windows. So i tried to download the Scilab project, that is native for my PIC and compile it, i load the firmware in the PIC and i tried with this one, the result is the same. Nothing happens.
I know that bulk devices needs special specific driver to work but the devic is totally ignored by the PC (in linux lsusb does not show the presence of any device)
So, i ask to you if you can help me to make the device visible by the PC, i does not know if the issue is due to the USB descriptor, or due to the absence of bootloader, or just a driver problem.

I'm not so expert, i started to study PIC programming just a few months ago trough university courses and i want to learn more in depth, thank you for your help and my apologize if my english is not perfect.

Kind regards, Cristian

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: BULK_USB transfer for USB2JTAG
« Reply #1 on: May 26, 2021, 05:47:10 pm »
With a hardware-based or some software protocol analyzers, you can view enumeration communications and other events.

http://www.janaxelson.com/development_tools.htm

Also see:

https://www.hexnode.com/mobile-device-management/help/how-to-get-windows-device-logs-from-a-windows-machine/

If the operating system isn't seeing device attachment at all, see:

http://www.janaxelson.com/usbcenum.htm

cristianBCC

  • Member
  • ***
  • Posts: 4
Re: BULK_USB transfer for USB2JTAG
« Reply #2 on: May 27, 2021, 02:24:40 pm »
thank you so much, i'm consulting the link you post in the response you give me, then i will say if i can solve.

cristianBCC

  • Member
  • ***
  • Posts: 4
Re: BULK_USB transfer for USB2JTAG
« Reply #3 on: May 29, 2021, 01:33:56 pm »
With a hardware-based or some software protocol analyzers, you can view enumeration communications and other events.

http://www.janaxelson.com/development_tools.htm

Also see:

https://www.hexnode.com/mobile-device-management/help/how-to-get-windows-device-logs-from-a-windows-machine/

If the operating system isn't seeing device attachment at all, see:

http://www.janaxelson.com/usbcenum.htm

Hi Jan

I've tried to analyze my device with the instruments you suggest in the links, but the OS isn't seeing device at all effectively.
So, i tried to follow the instruction on the last link but i'm not able to understand whic part of my code is not working, i really does not know how to debug it.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: BULK_USB transfer for USB2JTAG
« Reply #4 on: May 30, 2021, 12:45:28 pm »
Start by checking the pull up in step 2: The hub detects the device. The hub monitors the voltages on the signal lines (D+ and D-) at each of its ports.

Look for the Get Port Status request sent by the host in step 3.

cristianBCC

  • Member
  • ***
  • Posts: 4
Re: BULK_USB transfer for USB2JTAG
« Reply #5 on: May 31, 2021, 05:01:55 am »
i checked D+ and D- voltages: nothing happens when i plug USB cable inside PC port, both voltages keep on the same value and what is strange is thata this value is a negative ~100 mV voltage. I'm sure USB HW works fine, because i've tried an HID USB project and this one works fine.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: BULK_USB transfer for USB2JTAG
« Reply #6 on: June 02, 2021, 07:59:40 pm »
If the device is seeing no requests, there is likely something wrong in steps 1-7  of enumeration:


http://www.janaxelson.com/usbcenum.htm

Renate

  • Frequent Contributor
  • ****
  • Posts: 97
Re: BULK_USB transfer for USB2JTAG
« Reply #7 on: June 06, 2021, 06:00:54 pm »
It sounds like you are not initializing the USB hardware on the PIC correctly if you are truly not seeing D+ rise when you plug it in.
I don't know the PIC at all, but on the AVR8 there is a register bit for controlling whether the pull-up is on and another bit for whether it's to D+ (FS) or D- (LS).
You also have to enable the internal 3.3V regulator that feeds the pullups.
That's the very first step of enumeration.

If you're truly lost, you can make up a test circuit with Vbus to +5, D+ to a 15k to ground, D- to a 15k to ground, ground to ground.
This way you can double check what's going on without wondering if your hub is driving things.
You should be able to write a few lines of code and see if the D+ and D- pullups are working.

Maybe your libs are missing some initialization or you forgot to call something.

Yow, that lib is 3000 lines of gobble-dee-gook.
It uses lots of defines and conditionals.
Are you sure that you've got them all correct?
« Last Edit: June 06, 2021, 06:14:06 pm by Renate »

Renate

  • Frequent Contributor
  • ****
  • Posts: 97
Re: BULK_USB transfer for USB2JTAG
« Reply #8 on: June 08, 2021, 12:40:19 pm »
So, this got me thinking.
A minimal USB tester that could tell you if you have a low speed or a full/high speed USB device connected.
Since the pullup resistor is 1.5k, you can just use two LEDs that go from D+ or D- to ground.
You need to feed it from 5V so that your device knows that it's connected (and to power it).
The D+/D- coming in on the left are not connected to anything, only the Vbus and Gnd are.

This works fine. I plug in a (LS) keyboard and the red LED (connected to D-) goes on.
I plug in a FS/HS device and the yellow LED (connected to D+) goes on.
I program an ATMega32u4 to toggle the LSM bit in the UDCON register and it goes blinky between the two.

Of course this won't tell you if your USB is fully functional.
However if you're not even sure if your code is even touching the right registers for the model µC, it is something.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: BULK_USB transfer for USB2JTAG
« Reply #9 on: June 12, 2021, 01:40:25 pm »
Nice!