如何通过 U-boot 缩小 RAM 中的操作系统区域?
据我了解,PC/嵌入式系统启动后,操作系统将占用整个RAM区域,RAM将如下所示:
这意味着,当我运行我编写的程序时,所有变量、在堆栈、堆等中分配的动态内存都将保留在该区域内。如果我运行 firefox、paint、gedit 等,它们也将在该区域运行。 (这种理解正确吗?)
但是,我想缩小操作系统区域。下面是我想要如何划分 RAM 的说明:
做的原因是,我想将一些通过驱动程序从外部接收的数据存储到固定物理位置的自定义区域
中,然后我将能够直接访问它从用户空间而不使用copy_to_user()
。
我认为可以通过配置u-boot来做到这一点,但是我没有u-boot的经验,任何人都可以给我一些指示从哪里开始,例如:我是否需要修改u-boot的源,或者改变u-boot的环境变量
就足够了?
或者有其他方法可以做到这一点吗?
非常感谢任何帮助。谢谢!
p/s:我正在使用 TI ARM 处理器,并从 SD 卡启动,我不确定这是否重要。
From my understanding, after a PC/embedded system booted up, the OS will occupy the entire RAM region, the RAM will look like this:
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:
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
平台是ARM。 min_addr 和 max_addr 不适用于这些平台,因为它们仅适用于 Intel 实现。
对于 ARM 平台,尝试查看“mem=size@start”内核参数。阅读 Documentation/kernel-parameters.txt 和 arch/arm/kernel/setup.c。此选项在大多数新的 Linux 代码库(即 2.6.XX)上可用。
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).
您需要
在'bootargs'u-boot环境变量中设置以下参数:通过uboot传递给内核。
You need to set the following parameters:
to be passed to the kernel through uboot in the 'bootargs' u-boot environment variable.
我发现自己最近尝试做相反的事情 - 换句话说,让 Linux 使用系统中的额外内存 - 尽管我在 OMAP4 平台上使用 Barebox 而不是 u-boot。
我发现(有点令我惊讶),一旦 Barebox MLO 第一阶段引导加载程序意识到额外的 RAM,内核就会检测并使用它,无需任何 bootargs。由于内存大小没有在引导行的任何地方传递,我只能假设内核检查引导加载程序设置的内存映射来确定 RAM 大小。这表明修改 u-boot 以不映射所有 RAM 是正确的方法。
关于 boot-args 的主题,曾经有人建议您使用引导线在 OMAP4 系统上映射一块 RAM(由帧缓冲区使用?)。目前还不清楚这是否还有必要。
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.