Skip to main content
prsh
Associate III
March 20, 2024
Solved

Position Independent Code

  • March 20, 2024
  • 1 reply
  • 1307 views

Hello

I am trying to merge USB CDC code into an existing code which is a Keil multi project code. I am using the USB CDC code generated by stm32cubemx for data transmission and reception testing. 

The multi project is position independent build and when i add the files from USB CDC test application into it, it throws following errors and warnings. I am new to PI concept and would really appreciate if someone could guide me over this and help me resolve these.

Thanks.

*********************************************

*** Using Compiler 'V5.06 update 4 (build 422)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin'

WARNING: usbd_cdc_if.c(150): warning: #1357-D: static initialisation of variable "USBD_Interface_fops_FS" using address of CDC_Init_FS may cause link failure -ropi
USBD_CDC_ItfTypeDef USBD_Interface_fops_FS =


linking...
.\objects\zero.axf: Error: L6248E: usbd_cdc.o(.data) in PI region 'ER_RW' cannot have address type relocation to USBD_CDC_Init in PI region 'ER_RO'.

*********************************************

This topic has been closed for replies.
Best answer by FBL

Hi @prsh 

If still facing this issue, about the warning, in usbd_cdc_if.c, change the static initialization of USBD_Interface_fops_FS by calling initialization function to set these variables at runtime.  

Second, about the section placement error, you may attach your linker script to check with you! 

1 reply

FBLBest answer
ST Technical Moderator
July 30, 2024

Hi @prsh 

If still facing this issue, about the warning, in usbd_cdc_if.c, change the static initialization of USBD_Interface_fops_FS by calling initialization function to set these variables at runtime.  

Second, about the section placement error, you may attach your linker script to check with you! 

To give better visibility on the answered topics, please click on "Best answer" on the reply which solved your issue or answered your question.Best regards,FBL