LizardLad_1
Posts: 92
Joined: Sat Jan 13, 2018 12:29 am

CPU and GPU memory split?

Sat Aug 04, 2018 7:20 am

How is it possible to determine what is GPU memory and what is available to the CPU?

User avatar
rpdom
Posts: 12740
Joined: Sun May 06, 2012 5:17 am
Location: Ankh-Morpork

Re: CPU and GPU memory split?

Sat Aug 04, 2018 7:24 am

Use the vcgencmd command to check the currently configured memory split.

Code: Select all

[email protected] ~ $ vcgencmd get_mem arm
arm=448M
[email protected] ~ $ vcgencmd get_mem gpu
gpu=64M
[edit]
I just realised this is the Bare Metal forum. :oops:

There are mailbox calls to get the memory split. I can't remember the details of the top of my head, and I'm away from home this weekend.

LizardLad_1
Posts: 92
Joined: Sat Jan 13, 2018 12:29 am

Re: CPU and GPU memory split?

Sat Aug 04, 2018 9:52 am

So once I have the memory split how would I get the start and end addresses or the start and size?

bzt
Posts: 155
Joined: Sat Oct 14, 2017 9:57 pm

Re: CPU and GPU memory split?

Sat Aug 04, 2018 5:26 pm

LizardLad_1 wrote:
Sat Aug 04, 2018 9:52 am
So once I have the memory split how would I get the start and end addresses or the start and size?
Hi,

So get the value of the split with a mailbox call

Code: Select all

    mbox[0]=8*4;
    mbox[1]=0;
    mbox[2]=0x10005; // get memory size
    mbox[3]=8;
    mbox[4]=0;
    mbox[5]=0;
    mbox[6]=0;
    mbox[7]=0;
    if (!mbox_call(MBOX_CH_PROP, mbox)) {
        // on failure (should never happen) assume 512Mb memory max
        mbox[6]=512*1024*1024;
    }
Now the memory map looks like:
0 - mbox[6]: CPU memory (you can use it from your ARM code)
mbox[6] - 0x3F000000: GPU memory (don't touch)
0x3F000000+: MMIO area

Remember that your code is also in CPU memory, from 0x80000 - &_end, you probably don't want to accidently overwrite that. It's safe to say you should use &_end - mbox[6] as free memory for your malloc.

Cheers,
bzt

Return to “Bare metal, Assembly language”

Who is online

Users browsing this forum: albiorixza and 9 guests