Linux 在内存中加载 u-Boot 而不是闪存

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5218449/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 03:09:00  来源:igfitidea点击:

loading u-Boot in memory instead of flashing it

linuxembedded-linuxu-boot

提问by Yaj

In my ARM based custom board, I flash u-boot to NAND whenever I do changes on that. (putting some debug statements/modification). Is there any way to directly load the uboot image in RAM memory instead of flashing it every time?

在我基于 ARM 的定制板中,每当我对其进行更改时,我都会将 u-boot 闪存到 NAND。(放置一些调试语句/修改)。有没有办法直接将uboot镜像加载到RAM内存中,而不是每次都刷?

For linux kernel image I do load it in memory and use bootm to boot that image. Similarly for u-boot I am trying out. Kindly provide your suggestions.

对于 linux 内核映像,我确实将其加载到内存中并使用 bootm 来启动该映像。同样对于 u-boot 我正在尝试。请提供您的建议。

回答by gspr

回答by Simon Richter

It should be possible, if the U-Boot image you want to run has startup code that allows running it from arbitrary addresses. Whether or not that is the case for your board I can't tell.

如果您要运行的 U-Boot 映像具有允许从任意地址运行它的启动代码,则应该是可能的。我不知道你的董事会是否是这种情况。

If the startup code begins by copying the code section from the current (PC-relative) address to the final execution address (usually this is preceded by a check that these areas don't overlap), then you can load the .bin file to any address in RAM, and invoke it using go.

如果启动代码首先将代码部分从当前(PC 相对)地址复制到最终执行地址(通常在此之前检查这些区域不重叠),那么您可以将 .bin 文件加载到RAM 中的任何地址,并使用go.

The second obstacle I could see would be unconditional RAM setup code at the beginning, which a number of boards have.

我能看到的第二个障碍是一开始的无条件 RAM 设置代码,许多板子都有。

回答by caveman

The problem here is that what you are trying to do goes against the philosophy of what a bootloader is. Most processorsrequire that code starts from Flash. That code is called a bootloader. Thatis what U-boot is.

这里的问题是您尝试做的事情与引导加载程序的理念背道而驰。大多数处理器要求代码从 Flash 开始。该代码称为引导加载程序。 就是U-boot。

However, if you want to modify U-boot so that it is not a true bootloader, then you can do whatever you want. It's just software. But don't expect any mainline support for the above reasons.

但是,如果您想修改 U-boot 使其不是真正的引导加载程序,那么您可以为所欲为。这只是软件。但是不要指望由于上述原因得到任何主线支持。

回答by Jorge Rdz

Just take in mind (be care of) the hardware that you are configuring in your modified U-Boot. U Boot is intended to initialize critical modules, some of them are not able to be re-configured on the fly or they may not performe as if they were initialized/configured at startup.

请记住(注意)您在修改后的 U-Boot 中配置的硬件。U Boot 旨在初始化关键模块,其中一些模块无法即时重新配置,或者它们可能无法像在启动时初始化/配置一样执行。

回答by sessyargc.jp

Debugging a bootloader is a bit difficult, but with the right tools it should be relatively painless.

调试引导加载程序有点困难,但使用正确的工具应该相对轻松。

I deal with the PowerPC achitecture and with a BDI-3000 I can load and debug directly to RAM (of course, after initializing the DDR controller).

我处理 PowerPC 架构和 BDI-3000,我可以直接加载和调试到 RAM(当然,在初始化 DDR 控制器之后)。

One option is if you have on-chip SRAM or L2 Cache that can be configured as on-chip SRAM. The BDI can copy to the SRAM area first, u-boot does it's thing (initialize DDR controller for example), then relocates itself to DDR RAM afterwards. Definitely faster that re-writing to slow Flash all the time.

一种选择是,如果您有可配置为片上 SRAM 的片上 SRAM 或 L2 缓存。BDI 可以先复制到 SRAM 区,u-boot 做它的事情(例如初始化 DDR 控制器),然后将自己重新定位到 DDR RAM。绝对比一直重写以减慢 Flash 的速度更快。

回答by Jim Chargin

Someone at Freescale has done this, for their P1022DS evaluation system (and some others as well). They have provided a somewhat useful document about the process in the file ${UBOOTROOT}/doc/README.ramboot-ppc8500 (in U-Boot V2010.12). This document is pretty terse and leaves many questions unanswered, but I found it a reasonable place to start when I needed to debug U-Boot for a new board, before the flash memory for that board was operating correctly.

飞思卡尔的某个人已经为他们的 P1022DS 评估系统(以及其他一些系统)做到了这一点。他们在文件 ${UBOOTROOT}/doc/README.ramboot-ppc8500(在 U-​​Boot V2010.12 中)中提供了有关该过程的一些有用的文档。该文档非常简洁,并留下了许多未回答的问题,但当我需要为新板调试 U-Boot 时,在该板的闪存正常运行之前,我发现它是一个合理的起点。

In fact, having non-functional flash memory is one reason you might want to debug U-Boot in RAM. (There are a few reasons listed in the README, and they all sound pretty reasonable to me, in contrast to some of the other advice available on this subject)

事实上,具有非功能性闪存是您可能想要在 RAM 中调试 U-Boot 的原因之一。(自述文件中列出了一些原因,与有关此主题的其他一些建议相比,它们对我来说都非常合理)

In our situation, it was found that early prototype target board hardware included an error in the address bus connection to the flash memory that prevented us from using that flash memory. While the hardware was being redesigned and re-fabricated, we wanted to continue testing/debugging those parts of our U-Boot configuration that did not depend on flash memory, for example, I2C, Ethernet, FPGA configuration, PCIe, etc. (there are plenty of things that are independent of where the U-Boot image comes from).

在我们的情况下,我们发现早期原型目标板硬件在与闪存的地址总线连接中存在错误,导致我们无法使用该闪存。在重新设计和重新制造硬件的同时,我们希望继续测试/调试 U-Boot 配置中不依赖于闪存的部分,例如 I2C、以太网、FPGA 配置、PCIe 等(有很多东西都与 U-Boot 映像的来源无关)。

Running U-Boot after loading it into RAM via a JTAG interface (using Codewarrior and the USB TAP) allowed us to continue our U-Boot bring-up tasks, even though we had no functional flash memory. Once we received a newer version of the target board with correctly functioning flash memory, we returned to debugging those parts of U-Boot that we hadn't been able to test earlier. After that, U-Boot was fully functional, and we did not have to wait for a board spin to make any progress.

在通过 JTAG 接口(使用 Codewarrior 和 USB TAP)将 U-Boot 加载到 RAM 后运行它允许我们继续执行 U-Boot 启动任务,即使我们没有可用的闪存。一旦我们收到具有正常运行的闪存的更新版本的目标板,我们就返回调试 U-Boot 的那些我们之前无法测试的部分。之后,U-Boot 功能齐全,我们无需等待板子旋转即可取得任何进展。

回答by siva

If your Target board support network booting, you can load uboot image from host machine to RAM through network.

如果您的 Target 板支持网络启动,您可以通过网络从主机加载 uboot 映像到 RAM。

回答by GeekyJ

You can use usb boot. TI and Freescale provides their usb boot utilities. I don't know about other vendors.

你可以使用usb启动。TI 和飞思卡尔提供了他们的 USB 引导实用程序。我不知道其他供应商。

回答by user2629409

This is what can be read on the u-boot documentation FAQ:

这是可以在 u-boot 文档常见问题解答中阅读的内容:

Question: I don't want to erase my flash memory because I'm not sure if my new U-Boot image will work. Is it possible to configure U-Boot such that I can load it into RAM instead of flash, and start it from my old boot loader?

Answer: No. (Unless you're using a Blackfin processor, or Socfpga board, but you probably aren't.)

Question: But I've been told it is possible??

Answer: Well, yes. Of course this is possible. This is software, so everything is possible. But it is difficult, unsupported, and fraught with peril. You are on your own if you choose to do it. And it will not help you to solve your problem.

问:我不想擦除我的闪存,因为我不确定我的新 U-Boot 映像是否有效。是否可以配置 U-Boot 以便我可以将它加载到 RAM 而不是闪存中,并从我的旧引导加载程序启动它?

答案:不可以。(除非您使用的是 Blackfin 处理器或 Socfpga 板,但您可能没有使用。)

问:但有人告诉我这是可能的??

回答:嗯,是的。当然这是可能的。这是软件,所以一切皆有可能。但这是困难的,没有支持的,而且充满危险。如果你选择这样做,你就靠自己了。它不会帮助你解决你的问题。

source:http://www.denx.de/wiki/view/DULG/CanUBootBeConfiguredSuchThatItCanBeStartedInRAM

来源:http: //www.denx.de/wiki/view/DULG/CanUBootBeConfiguredSuchThatItCanBeStartedInRAM

回答by a-man

Yes, It is possible most of the compilation structure at the end U-Boot provides a u-boot.bin file which is a flattened binary, if your target supports USB/TFTP or any other medium which current U-boot can detect on you target environment then we can load the u-boot.bin file to the static memory address area. This address is the entry point of U-Boot Code and U-boot can execute the flattened binaries by go 0x<memory_address>. The static memory address area can be deduced form u-boot.map file, This entry point is basically address to the .text area of compiled program usually can we searched in the .map file with string "Address of section .text set to 0x." Below is the example of doing it from USB.

是的,如果您的目标支持 USB/TFTP 或当前 U-boot 可以在您身上检测到的任何其他介质,则 U-Boot 末尾的大部分编译结构可能会提供一个 u-boot.bin 文件,该文件是一个扁平化的二进制文件目标环境然后我们可以将 u-boot.bin 文件加载到静态内存地址区。该地址是 U-Boot 代码的入口点,U-boot 可以通过go 0x<memory_address>. 静态内存地址区可以从u-boot.map文件中推导出来,这个入口点基本上是编译程序的.text区的地址,通常我们可以在.map文件中搜索字符串“Address of section .text set to 0x” .” 以下是从 USB 执行此操作的示例。

usb start
load usb 0x<memory_address> u-boot.bin
go 0x<memory_address>

This should run you U-Boot from usb with out disturbing current code.

这应该可以从 USB 运行您的 U-Boot,而不会干扰当前代码。