Skip to main content
Visitor II
March 20, 2024
Solved

Position Independent Code

  • March 20, 2024
  • 1 reply
  • 1279 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

    FBLAnswer
    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!