EmbeddedRelated.com
Forums

Doubts about LPC1758 USB Host usage

Started by Sink0 February 2, 2012
Hi, i need to implement a system that will save some log information on a
USB flash. I will be using a LPC1758 with the USB port acting as a HOST
only. Looking at the user manual, at the example schematic there is a
LM3526-L that is basically a switch with overcurrent protection. As i am
not going to connect my system to anything else than a pendrive, should i
use the switch? If not, is there any schematic example? if yes, why? 

Second, i am using Code Sourcery compiler. Is there any USB Host stack that
i can use on a GCC compiler? How about a pendrive interface with FAT
example? 

Third question, i think the answer is no. Is there any way to update the
LPC firmware using a pendrive. I belive that would be possible if i could
manage to create a bootloader that can act as USB Host, but that is
probably going to consume a LOT of flash. Any way, is that possible. 

Finally, i am used to make my projects with microcontrollers acting as a
USB device, and all USB projects i use a ESD protection IC on the USB Line.
Can i use the same IC with the LPC acting as a Host? 

Thank you!	   
					
---------------------------------------		
Posted through http://www.EmbeddedRelated.com
On 02/02/2012 10:00 PM, Sink0 wrote:
> Hi, i need to implement a system that will save some log information on a > USB flash. I will be using a LPC1758 with the USB port acting as a HOST > only. Looking at the user manual, at the example schematic there is a > LM3526-L that is basically a switch with overcurrent protection. As i am > not going to connect my system to anything else than a pendrive, should i > use the switch? If not, is there any schematic example? if yes, why?
The LM3526 is optional. If you don't care about overcurrent protection, you can just hook up the USB bus to your 5V supply in the way you want.
> Third question, i think the answer is no. Is there any way to update the > LPC firmware using a pendrive. I belive that would be possible if i could > manage to create a bootloader that can act as USB Host, but that is > probably going to consume a LOT of flash. Any way, is that possible.
Yes, you can create a bootloader that does that. I use a similar approach, using FAT support in a bootloader on the LPC1758 that can read the firmware from SD card, or boot from TFTP server. The USB host protocol isn't very complicated if you only need to support a pendrive. My bootloader is 14kB, so if you take out the IP/UDP/TFTP support, and put in the USB host code, it will probably be only slightly bigger. Out of the total 512kB flash, that's very reasonable.
>Yes, you can create a bootloader that does that. I use a similar >approach, using FAT support in a bootloader on the LPC1758 that can read >the firmware from SD card, or boot from TFTP server. The USB host >protocol isn't very complicated if you only need to support a pendrive. >My bootloader is 14kB, so if you take out the IP/UDP/TFTP support, and >put in the USB host code, it will probably be only slightly bigger. Out >of the total 512kB flash, that's very reasonable. > >
Thank you very much. Your answers were of great help. A few more questions. Do you have a simple example schematic for a LPC1758 Host only circuit to read from a pendrive? Just to make sure i am not missing anything here. Could you point me any example code on how to implement a USB host at the bootloader with FAT support? On my application i am using an NXP example to read and wirite to a pendrive with FAT16 support. I am afraid i will have to go for FAT32 as i will need files larger than 64k. Thank you again for your help! --------------------------------------- Posted through http://www.EmbeddedRelated.com
> A few more questions. Do you have a simple example schematic for a LPC1758 > Host only circuit to read from a pendrive? Just to make sure i am not > missing anything here. Could you point me any example code on how to > implement a USB host at the bootloader with FAT support? On my application > i am using an NXP example to read and wirite to a pendrive with FAT16 > support. I am afraid i will have to go for FAT32 as i will need files > larger than 64k.
I've used the schematic from Fig.36 from the LPC17xx User Manual, using the 33R/15k resistors on D+/D-. I left the USB_PWRD, USB_OVRCR and USB_PPWR unconnected, and I powered the USB client through a separate 5V. It depends on your application how you want to do the power, but for a fixed pendrive, you might hook it up straight to your 5V supply. You can add switches or fuses if you need them, but that's up to you. I don't know of any example code. I think NXP has some app notes, but I'm not sure how good they are. I wrote my own bootloader. FAT16 can access files up to 4GB, by the way, not 64k.
> A few more questions. Do you have a simple example schematic for a LPC1758 > Host only circuit to read from a pendrive? Just to make sure i am not > missing anything here. Could you point me any example code on how to > implement a USB host at the bootloader with FAT support? On my application > i am using an NXP example to read and wirite to a pendrive with FAT16 > support. I am afraid i will have to go for FAT32 as i will need files > larger than 64k.
Also note that you'll need an external crystal, and that the PLL1 is quite restricted. I think you can only use a 12 or 16 MHz crystal. Read the manual carefully.
On 2/3/2012 1:22 PM, Arlet Ottens wrote:
>> A few more questions. Do you have a simple example schematic for a >> LPC1758 >> Host only circuit to read from a pendrive? Just to make sure i am not >> missing anything here. Could you point me any example code on how to >> implement a USB host at the bootloader with FAT support? On my >> application >> i am using an NXP example to read and wirite to a pendrive with FAT16 >> support. I am afraid i will have to go for FAT32 as i will need files >> larger than 64k. > > I've used the schematic from Fig.36 from the LPC17xx User Manual, using > the 33R/15k resistors on D+/D-. I left the USB_PWRD, USB_OVRCR and > USB_PPWR unconnected, and I powered the USB client through a separate > 5V. It depends on your application how you want to do the power, but for > a fixed pendrive, you might hook it up straight to your 5V supply. You > can add switches or fuses if you need them, but that's up to you. > > I don't know of any example code. I think NXP has some app notes, but > I'm not sure how good they are. I wrote my own bootloader. > > FAT16 can access files up to 4GB, by the way, not 64k. >
File size vs partition size FAT16 partition size at 2 GB for sector size 512 The maximum possible size for a file on a FAT32 volume is 4 GB minus 1 byte http://en.wikipedia.org/wiki/File_Allocation_Table
On 2/3/2012 1:58 PM, hamilton wrote:
> On 2/3/2012 1:22 PM, Arlet Ottens wrote: >>> A few more questions. Do you have a simple example schematic for a >>> LPC1758 >>> Host only circuit to read from a pendrive? Just to make sure i am not >>> missing anything here. Could you point me any example code on how to >>> implement a USB host at the bootloader with FAT support? On my >>> application >>> i am using an NXP example to read and wirite to a pendrive with FAT16 >>> support. I am afraid i will have to go for FAT32 as i will need files >>> larger than 64k. >> >> I've used the schematic from Fig.36 from the LPC17xx User Manual, using >> the 33R/15k resistors on D+/D-. I left the USB_PWRD, USB_OVRCR and >> USB_PPWR unconnected, and I powered the USB client through a separate >> 5V. It depends on your application how you want to do the power, but for >> a fixed pendrive, you might hook it up straight to your 5V supply. You >> can add switches or fuses if you need them, but that's up to you. >> >> I don't know of any example code. I think NXP has some app notes, but >> I'm not sure how good they are. I wrote my own bootloader. >> >> FAT16 can access files up to 4GB, by the way, not 64k. >> > > File size vs partition size > > FAT16 partition size at 2 GB for sector size 512 > > > The maximum possible size for a file on a FAT32 volume is 4 GB minus 1 byte > > http://en.wikipedia.org/wiki/File_Allocation_Table >
http://technet.microsoft.com/en-us/library/cc940351.aspx
On 02/03/2012 10:03 PM, hamilton wrote:
> On 2/3/2012 1:58 PM, hamilton wrote: >> On 2/3/2012 1:22 PM, Arlet Ottens wrote: >>>> A few more questions. Do you have a simple example schematic for a >>>> LPC1758 >>>> Host only circuit to read from a pendrive? Just to make sure i am not >>>> missing anything here. Could you point me any example code on how to >>>> implement a USB host at the bootloader with FAT support? On my >>>> application >>>> i am using an NXP example to read and wirite to a pendrive with FAT16 >>>> support. I am afraid i will have to go for FAT32 as i will need files >>>> larger than 64k. >>> >>> I've used the schematic from Fig.36 from the LPC17xx User Manual, using >>> the 33R/15k resistors on D+/D-. I left the USB_PWRD, USB_OVRCR and >>> USB_PPWR unconnected, and I powered the USB client through a separate >>> 5V. It depends on your application how you want to do the power, but for >>> a fixed pendrive, you might hook it up straight to your 5V supply. You >>> can add switches or fuses if you need them, but that's up to you. >>> >>> I don't know of any example code. I think NXP has some app notes, but >>> I'm not sure how good they are. I wrote my own bootloader. >>> >>> FAT16 can access files up to 4GB, by the way, not 64k. >>> >> >> File size vs partition size >> >> FAT16 partition size at 2 GB for sector size 512 >> >> >> The maximum possible size for a file on a FAT32 volume is 4 GB minus 1 >> byte >> >> http://en.wikipedia.org/wiki/File_Allocation_Table >> > > http://technet.microsoft.com/en-us/library/cc940351.aspx >
So, FAT16 has maximum file size of 65524 clusters of 32 kB = almost 2 GB, and not 4GB. Still a lot more than 64kB.
>Also note that you'll need an external crystal, and that the PLL1 is >quite restricted. I think you can only use a 12 or 16 MHz crystal. Read >the manual carefully. >
Thank you. You really helped a lot. That helps a lot for now. Yea, i will be using a 12Mhz crystal here. It is the standard on most dev kits. Cya --------------------------------------- Posted through http://www.EmbeddedRelated.com
>I've used the schematic from Fig.36 from the LPC17xx User Manual, using >the 33R/15k resistors on D+/D-. I left the USB_PWRD, USB_OVRCR and >USB_PPWR unconnected, and I powered the USB client through a separate >5V. It depends on your application how you want to do the power, but for >a fixed pendrive, you might hook it up straight to your 5V supply. You >can add switches or fuses if you need them, but that's up to you. > >I don't know of any example code. I think NXP has some app notes, but >I'm not sure how good they are. I wrote my own bootloader. > >FAT16 can access files up to 4GB, by the way, not 64k. > >
Hi again, one additional doubt. Did you connect USB_UP_LED and VBUS pins? Let me see if i understand correctly, USB_UP_LED is just used for signaling purpuses so is not really crytical. And VBUS is just used for devicemode to scheck when it gets connected sensing VBUS right? So no need at host mode. Thank you! --------------------------------------- Posted through http://www.EmbeddedRelated.com