diff --git a/stmhal/gccollect.c b/stmhal/gccollect.c index e20e92de146190cdb4af4a829a26778ef4368182..d40460d70cfa1536d8de4d0513057aeba2a514c9 100644 --- a/stmhal/gccollect.c +++ b/stmhal/gccollect.c @@ -21,10 +21,9 @@ void gc_collect(void) { // start the GC gc_collect_start(); - // scan everything in RAM before the heap - // this includes the data and bss segments - // TODO possibly don't need to scan data, since all pointers should start out NULL and be in bss - gc_collect_root((void**)&_ram_start, ((uint32_t)&_ebss - (uint32_t)&_ram_start) / sizeof(uint32_t)); + // We need to scan everything in RAM that can hold a pointer. + // The data segment is used, but should not contain pointers, so we just scan the bss. + gc_collect_root((void**)&_sbss, ((uint32_t)&_ebss - (uint32_t)&_sbss) / sizeof(uint32_t)); // get the registers and the sp machine_uint_t regs[10]; diff --git a/stmhal/usb.c b/stmhal/usb.c index 97ea2e1b415651b6dd1174cf45415d4c88ed143d..1c80b4bd7a7f3b6629829b51824f4d8ba16e0c2b 100644 --- a/stmhal/usb.c +++ b/stmhal/usb.c @@ -28,7 +28,7 @@ void pyb_usb_dev_init(usb_device_mode_t mode, usb_storage_medium_t medium) { } else { USBD_SelectMode(USBD_MODE_CDC_HID); } - USBD_Init(&hUSBDDevice, &VCP_Desc, 0); + USBD_Init(&hUSBDDevice, (USBD_DescriptorsTypeDef*)&VCP_Desc, 0); USBD_RegisterClass(&hUSBDDevice, &USBD_CDC_MSC_HID); USBD_CDC_RegisterInterface(&hUSBDDevice, (USBD_CDC_ItfTypeDef*)&USBD_CDC_fops); #if MICROPY_HW_HAS_SDCARD diff --git a/stmhal/usbd_desc.h b/stmhal/usbd_desc.h index a54e427e310dd8c70cdf74a04fa4cab1133c1a8d..348bbd45ad5ef31d6ba60de1290d572b392fd5d5 100644 --- a/stmhal/usbd_desc.h +++ b/stmhal/usbd_desc.h @@ -1,2 +1 @@ -extern USBD_DescriptorsTypeDef VCP_Desc; -extern USBD_DescriptorsTypeDef MSC_Desc; +extern const USBD_DescriptorsTypeDef VCP_Desc; diff --git a/stmhal/usbd_desc_cdc_msc.c b/stmhal/usbd_desc_cdc_msc.c index edcb4b343145fd51e91b72cef1351078f2c66c30..137e0bed99d7520516944703607e9461857a905d 100644 --- a/stmhal/usbd_desc_cdc_msc.c +++ b/stmhal/usbd_desc_cdc_msc.c @@ -59,7 +59,7 @@ uint8_t *USBD_VCP_USRStringDesc (USBD_SpeedTypeDef speed, uint8_t idx, uint16_t #endif /* USB_SUPPORT_USER_STRING_DESC */ /* Private variables ---------------------------------------------------------*/ -USBD_DescriptorsTypeDef VCP_Desc = { +const USBD_DescriptorsTypeDef VCP_Desc = { USBD_VCP_DeviceDescriptor, USBD_VCP_LangIDStrDescriptor, USBD_VCP_ManufacturerStrDescriptor,