That define is used to control if a global variable is reserved for the bdt USB buffer, or if the memory for the buffer shall by allocated dynamically (e.g. malloc()).
Are you using the Freescale (non-gcc) ARM compiler?
If that define is defined, then this code is active:
| #ifdef __CWCC__ |
| #pragma define_section usb_bdt ".usb_bdt" RW |
| __declspec(usb_bdt) uint_8_ptr bdt; |
It means that there needs to be a memory area allocated in the linker file for the USB bdt block, otherwise it will fail.
Obviously this is missing in the example :-(.
In my applications I don't want depend on malloc() for the buffer, so I use a static variable. But then it depends on the linker/compiler how to allocate this variable. The problem is that it needs to be aligned at a 512 byte boundary.
With ARM gcc this can be done in the source with
__attribute__((__aligned__(512))) uint8 bdt[512];
but not with the Freescale Kinetis compiler. To my knowledge you cannot align a variable in the source. This needs to be done in the linker file.
So I would say a better fix would be this:
/* Global variables */
#ifndef __CWCC__ /* Freescale (non-gcc) Kinetis compiler. If the macro below is enabled, the bdt buffer needs to be defined in the linker file */
#define _BDT_RESERVED_SECTION_ /* if defined, we use a static buffer (instead of malloc()), on a 512 byte boundary */
#endif
I hope this helps to clarify the issue. I have passed this to the USB stack team.