Porting nxpUSBlib to Rowley CrossStudio for LPC1788

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by CarlMle on Thu Mar 22 02:15:55 MST 2012
I'm working on porting the nxpUSBlib to work with Rowley, I thought I would share my experience/pain.

Specifically I need to get USB host working so my device can write to a USB Memory stick.

So I created a new solution, imported the usblib files and latest CMSIS and for now the hosthid example.

I added the preprocessor defines : USB_HOST_ONLY , __LPC17XX__

and hit build.

The first issue is CrossStudio doesn't like the __DATA(USBRAM_SECTION) statement that tells the linker to place the varibles in to AHBSRAM the Peripheral SRAM.

To fix this ....

I looked at the flash_placement.xml file, I couldn't see AHBSRAM but there is a section called

"<MemorySegment name="$(RAM2_NAME:RAM2)">"

but I could find no mention of RAM2 in the LPC1788_MemoryMap.xml, so I changed that line to :
"<MemorySegment name="AHBSRAM">"

I changed "__DATA(USBRAM_SECTION)" this to : "__attribute__ ((section(".bss2")))";

Hit build and success it links, but examining the varible locations they were not in the correct place, AHBSRAM starts at 0x20000000

Looking at the MemoryMap again the AHBSRAM start location is incorrect for the LPC1788, so I've changed it to :
<MemorySegment size="0x8000" access="Read/Write" start="0x20000000" name="AHBSRAM"/>

Rebuilt and my variables are now correctly located in AHBSRAM.

I still have some work to do though as it hardfaults enabling clocks for the OTG/AHB, some my next job is to fix the peripheral initialisation I think.