S32K358 ELF Virtual memory issue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K358 ELF Virtual memory issue

924 Views
nandanchaturbhuj
Contributor I

Hello,

I am using FreeRTOS on S32K358. Currently using the default FreeRTOS example from Design Studio.

When dissembling the ELF file, I can see following section -

Program Header:
    LOAD off    0x00010000 vaddr 0x00400000 paddr 0x00400000 align 2**16
         filesz 0x0000aab8 memsz 0x0000aab8 flags r-x
    LOAD off    0x00020000 vaddr 0x20400000 paddr 0x0040aab8 align 2**16
         filesz 0x0000010c memsz 0x000023e8 flags rwx
    LOAD off    0x00030000 vaddr 0x20480000 paddr 0x0040abc4 align 2**16
         filesz 0x00000004 memsz 0x000002b8 flags rw-
    LOAD off    0x000323e8 vaddr 0x204023e8 paddr 0x0040cea0 align 2**16
         filesz 0x00000000 memsz 0x00002000 flags rw-
    LOAD off    0x00040000 vaddr 0x20000000 paddr 0x20000000 align 2**16
         filesz 0x00000000 memsz 0x00000408 flags rw-
    LOAD off    0x0003bf00 vaddr 0x204bbf00 paddr 0x204bbf00 align 2**16
         filesz 0x00000000 memsz 0x00000100 flags rw-
private flags = 5000400: [Version5 EABI] [hard-float ABI]

 

I see following problems.

(1) Why is virtual memory and virtual address involved ? I don't see any meaning to that in case of FreeRTOS. 

(2) What triggered use of virtual memory in linker script ?

(3) How does the above section even works ? For instance, item 2 has vaddr as 0x20400000 and paddr as 0x40aab8. So where does the section actually get loaded ? In address 0x20400000 (RAM) or in address 0x40aab8 (Flash)?

Does address 0x20400000 supposed to be mapped to address 0x40aab8? If so, then who and how is that mapping done?

 

Best regards,

Nandan Chaturbhuj

 

0 Kudos
Reply
2 Replies

806 Views
Mehul_Patel_NXP
NXP Employee
NXP Employee

Hi, @nandanchaturbhuj , 

 

Also, for understanding, kindly please also check your project's linker, and binary (.elf)  files as shown below: 

 

Mehul_Patel_NXP_0-1691785059017.png

 

Thank you. Kind regards. 

 

- Mehul Patel

0 Kudos
Reply

848 Views
Mehul_Patel_NXP
NXP Employee
NXP Employee

Hi, @nandanchaturbhuj , 

 

As S32K58 is Arm® Cortex-M7 architecture, which doesn't have MMU (memory management unit) and it is not involving Virtual memory. 

 

You can also read about Memory management Unit and virtual memory on internet like: (https://en.wikipedia.org/wiki/Memory_management_unit ) . So as Arm Cortex-M7 there is no virtual memory involved. 

 

Now, vaddr and paddr that is used by linked on runtime for loading program from flash ROM and RAM. So, the address which you are referring to is the only run time flashing mechanism. Linker knows the two different location one as Virtual address that is pointing to RAM location and second physical address that is pointing to ROM location. 

You can find ARM architecture specific articles on internet and read about : Physical address, virtual address, Memory management unit to understand it. 

 

Please let me if you find it helpful. And if you have any further question or confusion. 

 

Thank you. Kind regards. 

- Mehul Patel 

0 Kudos
Reply