2015-10-06 01:14 AM
When modifying existing project.ioc I may either download older libraries or migrate to those currently maintained. Migrating tool duplicates parts of user code and then shifts body from each function to following one until the sourcefile ends.
Below is part of the file 'usb_cdc_if.c' affected by the bug. This could be caused by an unexpected formatting of the code. How to embrace the user code to be migration-proof? Part of /* USER CODE */ is repeated when migrating existing project.ioc_Before:_ /** @defgroup USBD_CDC_Private_Variables * @{ */ /* USER CODE BEGIN 3 */
_single occurence_
/* Create buffer for reception and transmission */ /* It's up to user to redefine and/or remove those define */ /* Received Data over USB are stored in this buffer */ uint8_t UserRxBufferFS[APP_RX_DATA_SIZE]; /* Send Data over USB CDC are stored in this buffer */ uint8_t UserTxBufferFS[APP_TX_DATA_SIZE]; extern uint8_t data_request_flag; extern uint8_t config_change_flag; extern struct _config_struct temp_config; extern struct _config_struct config; /* USER CODE END 3 */ /* USB handler declaration */ /* Handle for USB Full Speed IP */ USBD_HandleTypeDef *hUsbDevice_0;_After:_
/** @defgroup USBD_CDC_Private_Variables * @{ */_occurence 1_
/* Create buffer for reception and transmission */ /* It's up to user to redefine and/or remove those define */ /* Received Data over USB are stored in this buffer */ uint8_t UserRxBufferFS[APP_RX_DATA_SIZE]; /* Send Data over USB CDC are stored in this buffer */ uint8_t UserTxBufferFS[APP_TX_DATA_SIZE]; /* USB handler declaration */ /* Handle for USB Full Speed IP */ USBD_HandleTypeDef *hUsbDevice_0; ... static int8_t CDC_Init_FS(void) { hUsbDevice_0 = &hUsbDeviceFS; /* USER CODE BEGIN 3 */_occurence 2_
/* Create buffer for reception and transmission */ /* It's up to user to redefine and/or remove those define */ /* Received Data over USB are stored in this buffer */ uint8_t UserRxBufferFS[APP_RX_DATA_SIZE]; /* Send Data over USB CDC are stored in this buffer */ uint8_t UserTxBufferFS[APP_TX_DATA_SIZE]; extern uint8_t data_request_flag; extern uint8_t config_change_flag; extern struct _config_struct temp_config; extern struct _config_struct config; /* USER CODE END 3 */ } #solved #bug #stm32cube #migration2015-10-06 11:20 PM
The cause includes number mismatch between the old and the new library.
If the syntax were'/* USER CODE BEGIN' <identifier>|<number> '*/'
the migration tool can be useful for any source, securing <indentifier> could be derived from the migrated function's name. The <number> should be kept for backwards compatibility.