From b35a41f9815cf84afd2e87f5128dbf55db094a7d Mon Sep 17 00:00:00 2001 From: Johann Fischer Date: Mon, 30 Oct 2017 12:27:35 +0100 Subject: [PATCH] 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 --- include/linker/common-ram.ld | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linker/common-ram.ld b/include/linker/common-ram.ld index e5e7c19198f..e1eadb41c2a 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