pic32 USB Host

Thread Starter

chrisw1990

Joined Oct 22, 2011
551
Hello all,
so.. final year project for university, im using a PIC32 processor as i require a fast processor and USBhost functionality..
i have bought the DM320004 to get started with, as i figured, if i got the USB out the way, i can fret about everything else! now..
iv used the microchip sample code.. "PIC32 ESK USB Host - Mass Storage Simple Demo " found at the bottom of the page above.
my problem is.. everytime i compile, (after redirecting headers etc as the readme says so.. i get..a minimum of 4 errors (only reports some once so could be further issues in the file)
if people have the microchip application libraries, its in [MAL Library Directory]\Microchip\USB\usb_host.c
the errors are:
1) error: 'USB_OVERRIDE_CLIENT_DRIVER_EVENT_DATA' undeclared (first use in this function)
2) error: expected ';' before 'eventData'
3) error: 'eventData' undeclared (first use in this function)
4) error: 'EVENT_OVERRIDE_CLIENT_DRIVER_SELECTION' undeclared (first use in this function)

the reason im confused is because this is a microchip library file.. not one iv written.. but its stopping me understanding how to implement HOST USB for the mass storage device class.
All help appreciated.
Regards
 

ErnieM

Joined Apr 24, 2011
8,045
Well, if I build their project without MAL support I get a clean build, just a warning "FSfopen must use "r" and not READ as input on this device."

When I tried to build the version with MAL support I initially got errors until I remembered to adjust the include search paths to where my MAL lives.
 

Thread Starter

chrisw1990

Joined Oct 22, 2011
551
ill try delete and reinstalling mal.. its very odd, i wouldnt expect myself to be the only one with a weirdo usb host file.. its just very annoying! wait out:D

ok iv reinstalled now, and it hasnt made any difference, i get the same errors, and i uninstalled and deleted all files. =[
 
Last edited:

ErnieM

Joined Apr 24, 2011
8,045
It's not a bad install, it's how the project is set up.

First, I installed the sample at:

C:\Microchip Solutions v2011-10-18\USB\PIC32_ESK_USB_Host_Simple_Demo_042611

I had to set 3 paths so MPLAB could find all the correct files. (This can be the most frustrating part of building a MC sample.) On the menu click Project | Build Options... | Project. Select the Directories tab, and pick "Show directories for" "Include Search Path."

I have 3 entries there:
C:\Microchip Solutions v2011-10-18\USB\PIC32_ESK_USB_Host_Simple_Demo_042611\PIC32_ESK_USB_Host_Simple_Demo\USB

C:\Microchip Solutions v2011-10-18\Microchip\Include

.\source

That seems to be the minimum for all the correct files to get used.
 

Thread Starter

chrisw1990

Joined Oct 22, 2011
551
ahh yes! it works! thats really very annoying, i followed the readme file included in the pic32_ESK_... install. it didnt mention that, just locating the files.. how very annoying
thank you so much ErnieM!!
now i can star playing with how it works!
 

Thread Starter

chrisw1990

Joined Oct 22, 2011
551
ok.. iv been playing.. anddd..
i get build errors..
Rich (BB code):
    Objects\main.o:(.data+0x0): multiple definition of `usbMediaInterfaceTable'
    Objects\usb_config.o:(.data+0x0): first defined here
    Objects\main.o:(.data+0x10): multiple definition of `usbClientDrvTable'
    Objects\usb_config.o:(.data+0x10): first defined here
    Objects\main.o:(.sdata+0x0): multiple definition of `usbTPL'
    Objects\usb_config.o:(.sdata+0x0): first defined here
    c:/program files/microchip/mplab c32 suite/bin/../lib/gcc/pic32mx/4.5.1/../../../../pic32mx/bin/ld.exe: Link terminated due to previous error(s).
    collect2: ld returned 1 exit status
any ideas.. ?
 
Last edited by a moderator:

ErnieM

Joined Apr 24, 2011
8,045
It sounds like you redefined these 3 items when you wanted to add references into main.c for them. To add a reference to an existing var4iable (that doesn't have a nice dot h file) copy the variable definition and mark with an extern, like such:


extern CLIENT_DRIVER_TABLE usbMediaInterfaceTable;
extern CLIENT_DRIVER_TABLE usbClientDrvTable[];
extern USB_TPL usbTPL[];

Now it may happen that the custom types also need to be defined, but as long as they match you can have multiple definitions in your program.
 

Thread Starter

chrisw1990

Joined Oct 22, 2011
551
see this is the problem.. i used the microchip "USB Config" exe to generate the correct tpl stuff and all that.. i dont understand where these are coming from, however, what your saying does make sense, no harm in trying! just a pain in the asscos the example im going from doesnt do any defining of these three files =[

just tried.. i get the same error:(
 

ErnieM

Joined Apr 24, 2011
8,045
That exe (which I have not used) should be generating c code for your project, so you just need to find where it put things.

Inside MPLAB you can use a "Find in Files..." search (CTRL-SHIFT-F) to find every occurrence of a symbol in your project files. It will NOT find instances from say dot h files included in your project, but it is a start.

If you still are stuck then you can always add all the incuded files into your project. When very deperate, you can also add the dot c files a library function comes from; that lets you debug trace thru a library function. It also lets you fix a library function without figuring out how to rebuild a library (which happened to me several times using PIC32 stuff).
 
Top