I'm implementing bootloader for my LPC4337 based system (maybe it could be related also to LPC18xx). My code contains USB MSC stack from LPCOpen example (LPCOpen 3.02_43xx - usbd_rom_msc_sdmmc) connected to SD card containing FAT filesystem. Everything worked good until I implemented bootloader which copies new firmware from SD card to one of flash banks (0x1A000000 or 0x1B000000). Because of this I have to link my code to 0x00000000 flash address instead of 0x1A000000. LPC on startup remaps one of the flash banks (the one with the correct signature) to the address 0x00000000. It works properly. I tested firmware reload many times. The problem is that after changing the linking address from 0x1A..... to 0x00... USB MSC does not work. When I connect USB to PC, PC throws "Device not recognized", but the code runs further (no fault handler). Maybe it gets a bad decriptor, I don't know. So it seems to be some bad address or bad jump (or incorrect read of descriptor form an address). I have checked NVIC vector table, It seems to be OK. All vectors addresses was changed from 0x1A... to 0x00..... so the code cannot jump to 0x1A... based absolute address. I also checked the .map file (using Keil uVision) and it seems to be also good - there is no code at addresses 0x1A.... or 0x1B... everything (except RAM) is now located in 0x00...address space. I checked also the alignment of USB descriptors (must be aligned to DWord address)...it is OK in .map file. I went through the USB MSC code to find some absolute address jump or whatever suspicious, but found nothing. When I link to 0x1A or 0x00 the final .map file is the same except of 0x1A prefix of flash mem addresses, but rest bytes of addresses are the same (just shifted to 0x00...). When I compile/link to 0x1A... USB MSC works, when I recompile to 0x00 it doesn't. The rest of code works good on both addresses.
Now I have no idea what can be the problem. It seems that USB MSC code (from that example) must be placed at the 0x1A or 0x1B flash bank address (it uses the ROM code that is invisible from my side).
Using USB0 as MSC device on M4 core (M0 core is not used). Map file is in attachment.
Does anybody have some idea, what could cause such a behavior? Any ideas will be appreciated. Is there something more than M4MEMMAP what I have to take care of?