Remoteproc as a module in Yocto - Sc589

Hi,

We are trying to change Remoteproc to not be automatically initiated during startup as we have a dual device configuration.

When trying to build we receive the below errors using the yocto build system.

We also tried to  export symbols but it doesn't help/work

| MODPOST 28 modules
| ERROR: "sec_raise_irq" [drivers/remoteproc/adi_remoteproc.ko] undefined!
| ERROR: "sec_enable_sci" [drivers/remoteproc/adi_remoteproc.ko] undefined!
| ERROR: "sec_enable_ssi" [drivers/remoteproc/adi_remoteproc.ko] undefined!
| ERROR: "sec_set_ssi_coreid" [drivers/remoteproc/adi_remoteproc.ko] undefined!

Can you please advise how to achieve this?

Thanks,

Mark

  • Hi Mark,

    I could recreate your issue, will get back to you with a potential fix.

    Thanks,

    Prasanth R

  • Hi Mark,

    Could you try applying the patch and rebuild your kernel? 

    build/tmp/work/adsp_sc589_ezkit-poky-linux-gnueabi/linux-adi/4.19-r0/git$ git am 0001-remoteproc-Add-export-symbols-to-build-as-module.patch

    $bitbake -C compile linux-adi

    From 9d949c5196d97018988e5092b7abd5420fea318e Mon Sep 17 00:00:00 2001
    Date: Fri, 29 Oct 2021 11:44:00 +0530
    Subject: [PATCH] remoteproc: Add export symbols to build as module
    
    ---
     arch/arm/mach-sc58x/sec.c | 5 +++++
     1 file changed, 5 insertions(+)
    
    diff --git a/arch/arm/mach-sc58x/sec.c b/arch/arm/mach-sc58x/sec.c
    index 62c6663..0c9e4cc 100644
    --- a/arch/arm/mach-sc58x/sec.c
    +++ b/arch/arm/mach-sc58x/sec.c
    @@ -15,6 +15,7 @@
     #include <mach/sc58x.h>
     #include <mach/hardware.h>
     #include <mach/sec.h>
    +#include <linux/module.h>
     
     static DEFINE_SPINLOCK(lock);
     
    @@ -89,6 +90,7 @@ void sec_raise_irq(unsigned int irq)
     	writel(sid, sec->common_base + SEC_RAISE);
     	spin_unlock_irqrestore(&lock, flags);
     }
    +EXPORT_SYMBOL(sec_raise_irq);
     
     void sec_enable_ssi(unsigned int sid, bool fault, bool source)
     {
    @@ -112,6 +114,7 @@ void sec_enable_ssi(unsigned int sid, bool fault, bool source)
     
     	spin_unlock_irqrestore(&lock, flags);
     }
    +EXPORT_SYMBOL(sec_enable_ssi);
     
     void sec_enable_sci(unsigned int coreid)
     {
    @@ -127,6 +130,7 @@ void sec_enable_sci(unsigned int coreid)
     	writel(reg_cctl, sec->sci_base + 0x40 * id);
     	spin_unlock_irqrestore(&lock, flags);
     }
    +EXPORT_SYMBOL(sec_enable_sci);
     
     void sec_set_ssi_coreid(unsigned int sid, unsigned int coreid)
     {
    @@ -146,6 +150,7 @@ void sec_set_ssi_coreid(unsigned int sid, unsigned int coreid)
     
     	spin_unlock_irqrestore(&lock, flags);
     }
    +EXPORT_SYMBOL(sec_set_ssi_coreid);
     
     static int __init early_sec_init(char *buf)
     {
    -- 
    2.7.4

    Thanks,

    Prasanth R

  • Hi Prasanth,

    Thank for the patch, this is now working as a module, we are able to start it and then start the SHARC cores.

    We are getting the below error when trying to release the module once the SHARC cores are running, can you please advise how we can do this.

    "root@dsp-1:~# rmmod adi_remoteproc

    rmmod: ERROR: could not remove module adi_remoteproc: Device or resource busy"

    Regards,

    Mark

  • Hi Mark,

    Exit function was missing in the driver, Could you try applying the patch and rebuilding your kernel? 

    build/tmp/work/adsp_sc589_ezkit-poky-linux-gnueabi/linux-adi/4.19-r0/git$ git am 0001-fixup-remoteproc-Add-export-symbols-to-build-as-modu.patch

    $bitbake -C compile linux-adi

    Ensure, you have the previous patch also applied,

    From 340e54b9eb6ce31e0f7d0462a14ff7a43a4a97ba Mon Sep 17 00:00:00 2001
    Date: Wed, 24 Nov 2021 13:13:24 +0530
    Subject: [PATCH] fixup! remoteproc: Add export symbols to build as module
    
    ---
     drivers/remoteproc/adi_remoteproc.c | 6 ++++++
     1 file changed, 6 insertions(+)
    
    diff --git a/drivers/remoteproc/adi_remoteproc.c b/drivers/remoteproc/adi_remoteproc.c
    index 86d2d15..ee6461f 100644
    --- a/drivers/remoteproc/adi_remoteproc.c
    +++ b/drivers/remoteproc/adi_remoteproc.c
    @@ -559,6 +559,12 @@ static int __init adi_remoteproc_init(void)
     }
     
     late_initcall_sync(adi_remoteproc_init);
    +
    +static void __exit adi_remoteproc_exit(void)
    +{
    +}
    +module_exit(adi_remoteproc_exit);
    +
     MODULE_DESCRIPTION("Analog Device sc5xx SHARC Image Loader");
     MODULE_LICENSE("GPL v2");
     MODULE_AUTHOR("Greg Chen <jian.chen@analog.com>");
    -- 
    2.7.4
    

    Thanks,

    Prasanth R