UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor
Contributor
1,118 Views
Registered: ‎09-22-2015

put variable or functions on the OCM in bare metal application.

Jump to solution

HI:

    How can I put the variables  and the functions  on the OCM in the bare-metal application ? I am using VIVADO 2016.4.

    Thanks very much!

0 Kudos
1 Solution

Accepted Solutions
Moderator
Moderator
1,681 Views
Registered: ‎10-06-2016

Re: put variable or functions on the OCM in bare metal application.

Jump to solution

Hi @cyn_thia

 

 

There are different ways to do this, specially for the variables but I think that the best way is through the linker script and the usage of sections.

 

The first thing is to define a section in the OCM in your linker script where you want to place your function and variables, you can do either by Linker script generator or by modifying the linker script in text file.

 

i.e. two sections defined in OCM to place data and text

.OCM.data : {
__OCM_start = .;
*(.OCM)
__OCM_end = .;
} > ps7_ram_0

.OCM.text : {
__OCM_start = .;
*(.OCM)
__OCM_end = .;
} > ps7_ram_0

C code placing variables and functions in those sections:

#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"

int ret __attribute__((section(".OCM.data"))) = 0;
int main(void) __attribute__((section(".OCM.text")));

int main()
{
    init_platform();

    print("Hello World\n\r");

    cleanup_platform();
    return ret;
}

 

 


Ibai
Don’t forget to reply, kudo, and accept as solution.
0 Kudos
2 Replies
Moderator
Moderator
1,682 Views
Registered: ‎10-06-2016

Re: put variable or functions on the OCM in bare metal application.

Jump to solution

Hi @cyn_thia

 

 

There are different ways to do this, specially for the variables but I think that the best way is through the linker script and the usage of sections.

 

The first thing is to define a section in the OCM in your linker script where you want to place your function and variables, you can do either by Linker script generator or by modifying the linker script in text file.

 

i.e. two sections defined in OCM to place data and text

.OCM.data : {
__OCM_start = .;
*(.OCM)
__OCM_end = .;
} > ps7_ram_0

.OCM.text : {
__OCM_start = .;
*(.OCM)
__OCM_end = .;
} > ps7_ram_0

C code placing variables and functions in those sections:

#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"

int ret __attribute__((section(".OCM.data"))) = 0;
int main(void) __attribute__((section(".OCM.text")));

int main()
{
    init_platform();

    print("Hello World\n\r");

    cleanup_platform();
    return ret;
}

 

 


Ibai
Don’t forget to reply, kudo, and accept as solution.
0 Kudos
Contributor
Contributor
1,067 Views
Registered: ‎09-22-2015

Re: put variable or functions on the OCM in bare metal application.

Jump to solution

 It's the perfect solution to my problem.Thanks ! 

0 Kudos