include: linker: add sections for USB device stack This patch adds a RAM section for the USB descriptors and USB interfaces data. The parts of USB descriptor can be declared independently in different USB class drivers or functions. These must then be placed in a predefined order one after the other without gaps in a RAM section. There may also be several device descriptors in the section such as for USB DFU. Since at runtime the number of interfaces and endpoints in the composite device descriptor is unknown, they must be corrected. The class drivers or functions use the usb_cfg_data struct to store the callbacks, interface and endpoints data. This struct must also be corrected and needs to be placed in the data section. The descriptor section and data section must be processed by the USB Device Stack before the enumeration. Signed-off-by: Johann Fischer <j.fischer@phytec.de>
diff --git a/include/linker/common-ram.ld b/include/linker/common-ram.ld index e5e7c19..e1eadb4 100644 --- a/include/linker/common-ram.ld +++ b/include/linker/common-ram.ld
@@ -188,6 +188,24 @@ __net_l2_data_end = .; } GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) +#if defined(CONFIG_USB_DEVICE_STACK) + SECTION_DATA_PROLOGUE(usb_descriptor, (OPTIONAL), SUBALIGN(1)) + { + __usb_descriptor_start = .; + *(".usb.descriptor") + KEEP(*(SORT_BY_NAME(".usb.descriptor*"))) + __usb_descriptor_end = .; + } GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) + + SECTION_DATA_PROLOGUE(usb_data, (OPTIONAL), SUBALIGN(1)) + { + __usb_data_start = .; + *(".usb.data") + KEEP(*(SORT_BY_NAME(".usb.data*"))) + __usb_data_end = .; + } GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) +#endif /* CONFIG_USB_DEVICE_STACK */ + #ifdef CONFIG_USERSPACE _static_kernel_objects_end = .; #endif