This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TDA4VM: How to share OSPI flash between MCU domain and MAIN domain?

Part Number: TDA4VM

Dear expert,

Is it possible that during boot stage (until linux is fully booted), MAIN domain accesses flash, and afterwards MCU accesses flash?

There should be a access switch through software configuration.


BR/ZHANG Yang

  • Hi Zhang Yang,

    We will need to understand your use case to answer this better. If Linux driver probes the flash then Linux is the owner and switch
    of ownership runtime is not supported. Why should Linux access Flash in your use case? Can you please elaborate?

    Best Regards,
    Keerthy

  • Hi, Keerthy

    In my question, I didn't use 'Linux'. Instead I use MAIN Domain and MCU Domain. 

    Main Domain needs to acess flash for OTA function:

    1 During Boot stage, we need to write a few bytes into flash to remember how many times it has failed.

    2 When Linux is booted, OTA software needs to clear the failure record, which means the current image is usable. 

    Afterwards, MCU wants to record some critical data, in case MAIN Domain does not work normally. So next time when linux is booted, we can recover the information to identify what has happened.

    Is this enough?

    BR/Yang

  • Hi Yang,

    You are also booting from the OSPI flash?

    If so then during boot process the OSPI ownership needs to be with the MCU R5F. Post that we can have some sort of synchronization where we close the flash from MCU R5 and then access it from Linux.

    Regards,

    Karan

  • First, we boot from OSPI, when MCU takes the ownership

    Second, after linux is booted and OTA is activated Linux takes the ownership for OTA operation.

    Third, after is linux is booted but OTA is not activiated in the normal case, MCU takes the ownership to record critical error of main domain (heat beat loss, hardware abnormities)

    What we need are:

    1 How to transfer ownership from linux to MCU

    2 How to transfer ownership from MCU to linux

  • Hi Yang,

    I checked with the team on this.

    I am assuming MCU SW is not running out of flash (no XIP).

    Options are:

    a) MCU SW always owns OSPI except during OTA. Have OSPI built as module (instead of built into kernel) and make sure it does not autoload (using systemd tweaks). Insert OSPI module only when OTA is triggered, update flash and remove the module. Note that this will reset the flash back to default state and MCU SW would have to reconfigure the flash again to continue to use it after OTA. Also MCU SW cannot use OSPI during OTA from Linux

    b) Linux has no knowledge of OSPI (disabled in DT). When OTA is triggered, Linux can pass on the data to MCU SW via IPC and MCU SW takes care of updating flash. This assumes OTA data is small and MCU SW has enough idle time to update SW. This option may even scale to MCU SW running in XIP configuration.

    Regards,

    Karan

  • Hi, Karan,

          We had tried solution a  on soc as folowing steps:

          1.   build the ospi as module;

          2.   make sure the ospi module will not be loaded automatically;

          3.   insmod ospi module and test ospi flashcp operation;

          4.   rmmod ospi module and wait 10 seconds;

          5.   tested step 4 and  step 5 over 100 times with a script, It looks worked very well.

         Next step,  we will try to implente the protocol of MCU and SOC,  then  check if MCU can access OSPI  flash after SOC

    released the OSPI flash.

        

        

  • Additional comments from the team on this:

    For any option, OSPI ownership transfer has to be based on some agreed SW IPC mechanism. There is no HW based solution that I can think of. Application doing OTA on Linux side can inform/handshake with MCU App while starting FOTA writes to flash, once the OTA is done, Linux would have inform MCU SW again so that MCU SW can reconfigure OSPI for its needs.

    So, since OTA is not exercised on every boot, MCU SW can have control over OSPI by default. When OTA is triggered, Linux OTA app can claim ownership after an IPC handshake.

    Regards

    Karan

  • Hi Karan,

         Yes, we need ensure linux will not change the OSPI controller settings when boot up. I had build the following driver as modules and make sure them will not be loaded automatically:

         spi-nor.ko
         spi-cadence-quadspi.ko

        In this case, we think the linux kernel will not access the OSPI controller at all.  We did some test as following steps:

         1.    stop u-boot's autoboot with serial console;

         2.   check if MCU can access ospi flash, it workded;

         3.   dump the OSPI register (from 0x47040000 to 0x470400FC) wirh JTAG debuger SEED-XDS560V2 and it looks ok.

         4.    hit "boot" to bootup kernel (load kernel and dts from  EMMC, without ospi access);

         5.    check if MCU can access ospi flash, it doesn't work;

         6.    dump the OSPI register (from 0x47040000 to 0x470400FC) wirh JTAG debuger SEED-XDS560V2,  we found all the registers is 0x0

                and we can not chaned them. It looks like the kernel disabled the OSPI's power or clock. 

                Is there a register I can check  the clcok or power status is correct? Thanks!

        

  • Hi,

    Sorry for delay here.

         4.    hit "boot" to bootup kernel (load kernel and dts from  EMMC, without ospi access);

    So this means that you are able to have MCU own the flash till u-boot but as soon as you load the kernel image and DTB then the MCU can no longer access the OSPI, is that your inference too from this?

         6.    dump the OSPI register (from 0x47040000 to 0x470400FC) wirh JTAG debuger SEED-XDS560V2,  we found all the registers is 0x0

    Do you have anything for the OSPI device in the DTB for Linux?

    Regards

    Karan

  • Hi, Karan,

         We had fixed this issue by disabled the OSPI in u-boot's dts like followin, we had implemented this solution now. Thanks Very much.

    +++ b/board-support/u-boot-2020.01+gitAUTOINC+3c9ebdb87d-g3c9ebdb87d/arch/arm/dts/k3-j721e-common-proc-board.dts
    @@ -305,3 +305,7 @@
     //         resets = <&serdes_wiz3 1>, <&serdes_wiz3 2>;
     //     };
     // };
    +&ospi0 {
    +   /* disable ospi0 for mcu use ospi only */
    +   status = "disabled";
    +};

  • Hi,

    Can we close this issue? Or you need inputs on checking clock or power status is correct?

    - Keerthy

  • Hi Keerthy,

        Yes, we can close this issue.  Thanks!