Skip to content

Commit 82c7b1b

Browse files
committed
stmhal: Put a USB structure in ROM; GC doesn't scan the data segment.
1 parent b14f2a0 commit 82c7b1b

4 files changed

Lines changed: 6 additions & 8 deletions

File tree

stmhal/gccollect.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ void gc_collect(void) {
2121
// start the GC
2222
gc_collect_start();
2323

24-
// scan everything in RAM before the heap
25-
// this includes the data and bss segments
26-
// TODO possibly don't need to scan data, since all pointers should start out NULL and be in bss
27-
gc_collect_root((void**)&_ram_start, ((uint32_t)&_ebss - (uint32_t)&_ram_start) / sizeof(uint32_t));
24+
// We need to scan everything in RAM that can hold a pointer.
25+
// The data segment is used, but should not contain pointers, so we just scan the bss.
26+
gc_collect_root((void**)&_sbss, ((uint32_t)&_ebss - (uint32_t)&_sbss) / sizeof(uint32_t));
2827

2928
// get the registers and the sp
3029
machine_uint_t regs[10];

stmhal/usb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void pyb_usb_dev_init(usb_device_mode_t mode, usb_storage_medium_t medium) {
2828
} else {
2929
USBD_SelectMode(USBD_MODE_CDC_HID);
3030
}
31-
USBD_Init(&hUSBDDevice, &VCP_Desc, 0);
31+
USBD_Init(&hUSBDDevice, (USBD_DescriptorsTypeDef*)&VCP_Desc, 0);
3232
USBD_RegisterClass(&hUSBDDevice, &USBD_CDC_MSC_HID);
3333
USBD_CDC_RegisterInterface(&hUSBDDevice, (USBD_CDC_ItfTypeDef*)&USBD_CDC_fops);
3434
#if MICROPY_HW_HAS_SDCARD

stmhal/usbd_desc.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
extern USBD_DescriptorsTypeDef VCP_Desc;
2-
extern USBD_DescriptorsTypeDef MSC_Desc;
1+
extern const USBD_DescriptorsTypeDef VCP_Desc;

stmhal/usbd_desc_cdc_msc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ uint8_t *USBD_VCP_USRStringDesc (USBD_SpeedTypeDef speed, uint8_t idx, uint16_t
5959
#endif /* USB_SUPPORT_USER_STRING_DESC */
6060

6161
/* Private variables ---------------------------------------------------------*/
62-
USBD_DescriptorsTypeDef VCP_Desc = {
62+
const USBD_DescriptorsTypeDef VCP_Desc = {
6363
USBD_VCP_DeviceDescriptor,
6464
USBD_VCP_LangIDStrDescriptor,
6565
USBD_VCP_ManufacturerStrDescriptor,

0 commit comments

Comments
 (0)