I'm a frog dragon
I'm a frog dragon

Reputation: 8865

How can I shrink the OS region in RAM through U-boot?

From my understanding, after a PC/embedded system booted up, the OS will occupy the entire RAM region, the RAM will look like this:

OS region occupy the entire RAM

Which means, while I'm running a program I write, all the variables, dynamic memory allocated in the stacks, heaps and etc, will remain inside the region. If I run firefox, paint, gedit, etc, they will also be running in this region. (Is this understanding correct?)

However, I would like to shrink the OS region. Below is an illustration of how I want to divide the RAM:

OS region does not occupy the entire RAM, leaving some physical memory for my usage

The reason that I want to do this is because, I want to store some data receive externally through the driver into the Custom Region at fixed physical location, then I will be able to access it directly from the user space without using copy_to_user().

I think it is possible to do that by configuring u-boot, but I have no experience in u-boot, can anyone give me some directions where to begin with, such as: do I need to modify the source of u-boot, or changing the environment variables of u-boot will be sufficient?

Or is there any alternative method of doing this?

Any help is much appreciated. Thanks!

p/s: I'm using TI ARM processor, and booting up from an SD card, I'm not sure if it matters.

Upvotes: 0

Views: 1069

Answers (3)

marko
marko

Reputation: 9169

I found myself trying to do the opposite recently - in other words get Linux to use the additional memory in my system - although I'm using Barebox rather than u-boot on a OMAP4 platform.

I found (a bit to my surprise) that once the Barebox MLO first stage boot-loader was aware of the extra RAM, the kernel then detected and used it as well without any bootargs. Since the memory size is not passed anywhere on the boot-line, I can only assume the kernel inspects the memory mappings set up by the boot-loader to determine RAM size. This suggests that modifying your u-boot to not map all of the RAM is the way to go.

On the subject of boot-args, there was a time when you it was recommended that you mapped out a chunk of RAM (used by the frame buffer?) on OMAP4 systems, using the boot-line. It's still unclear whether this is still necessary.

Upvotes: 0

sessyargc.jp
sessyargc.jp

Reputation: 573

The platform is ARM. min_addr and max_addr will not work on these platform since these are for Intel-only implementations.

For the ARM platform try to look at "mem=size@start" kernel parameter. Read up on Documentation/kernel-parameters.txt and arch/arm/kernel/setup.c. This option is available on most new Linux code base (ie. 2.6.XX).

Upvotes: 4

rsaxvc
rsaxvc

Reputation: 1780

You need to set the following parameters:

max_addr=some_max_physical
min_addr=some_min_physical

to be passed to the kernel through uboot in the 'bootargs' u-boot environment variable.

Upvotes: 3

Related Questions