Skip to main content
Visitor II
June 18, 2020
Solved

How can I prevent the contents of "RETRAM" from being erased? (base on linux with m4 rproc)

  • June 18, 2020
  • 2 replies
  • 977 views

Hi all.

I want to prevent the contents of "RETRAM" from being erased when I run the firmware with m4 rproc on "OpenSTLinux".

"RETRAM" is powered by the battery through the VBAT pin to maintain data.

To this end, TF-A was also modified to set and maintain the value of "PWR_CR2_RREN" in the "PWR_CR2" registry.

In the "Engineering Mode" where M4 Firmware can be run on its own, "RETRAM" data is well maintained. However, when you boot into "OpenSTLinux" and load the firmware into M4 rproc and debug it, the contents of "RETRAM" are initialized.

The following is the contents of the "RETRAM" related ld file.

MEMORY

{

m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x00000298

m_retram   (RWX) : ORIGIN = 0x00000400, LENGTH = 0x0000FC00

m_text    (RX) : ORIGIN = 0x10000000, LENGTH = 0x00030000

m_data    (RW) : ORIGIN = 0x10030000, LENGTH = 0x00010000

m_ipc_shm  (RW) : ORIGIN = 0x10040000, LENGTH = 0x00008000

}

SECTIONS

{

.retram (NOLOAD) :

  {

   . = ALIGN(4);

   *(.m_retram)

   _eretram = .;

  } > m_retram

}

The following variables are declared in the "RETRAM" area:

__IO uint8_t G_RETRAM[0xFC00] __attribute ((section(".m_retram")));

The following are the contents of the DTS file related to "RETRAM".

reserved-memory {

#address-cells = <1>;

#size-cells = <1>;

ranges;

retram: retram@0x38000000 {

compatible = "shared-dma-pool";

/*

reg = <0x38000000 0x10000>;

*/

reg = <0x38000000 0x3FF>;

no-map;

};

retram_bat: retram_bat@0x38000400 {

reg = <0x38000400 0xFC00>;

no-map;

};

.........

}

&m4_rproc {

memory-region = <&retram>, <&retram_bat>, <&mcuram>, <&mcuram2>, <&vdev0vring0>,

<&vdev0vring1>, <&vdev0buffer>;

mboxes = <&ipcc 0>, <&ipcc 1>, <&ipcc 2>;

mbox-names = "vq0", "vq1", "shutdown";

interrupt-parent = <&exti>;

interrupts = <68 1>;

interrupt-names = "wdg";

wakeup-source;

recovery;

status = "okay";

};

Please give me a lot of advice.

Thanks.

Regards

Machilus

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

    I fixed the kernel and solved this problem.

    2 replies

    MachilusAuthorAnswer
    Visitor II
    June 24, 2020

    I fixed the kernel and solved this problem.

    Visitor II
    June 26, 2020

    Hi @Machilus​ ,

    great success!

    Could you please share with us your improvement /correction?

    If it's a correction of corrent error, the other users could benefit from your achivement.

    Thanks and best regards,

    Milan

    MachilusAuthor
    Visitor II
    November 11, 2020

    Dear mleo (ST Employee)

    You need to modify the "driver/remoteproc/remoteproc_elf_loader.c" file.

    Comment out the content on line 203.

    /*

    if (memsz > filesz)

          memset(ptr + filesz, 0, memsz - filesz);

    */

    Thanks and regards

    Machilus