Content originally posted in LPCWare by CC58 on Mon Jan 21 14:29:49 MST 2013
The ROM_USB_msc ROM code uses RAM space with a pointer without allocating space for its use.
When I try to add variable (2K array) in main.c and write to it, subsequent USB connect causes a hard fault.
If I allocate a 2K array and do no write to it, the thumbdrive comes up normally.
It appears the ROM routines are using RAM space from 0x800 to 0x1000 without informing the C compiler.
Looking at the code in app_usbd_cfg.h
#define MSC_PARAM_MEM 0x10000800
#define MSC_RARAM_SIZE 0x00000800
Which is then reference in main.c for init of USB
usb_param.mem_base = MSC_PARAM_MEM;
usb_param.mem_size = MSC_RARAM_SIZE;
I've managed to get around this in an ugly way by editing the MCU settings
such that RAM starts at 0x1000 and ends at 0x2000. This is not a proper solution.
What is the proper solution?
I believe it entails changing the project's linker directives somehow regarding sections?