无法使用 UBoot + Grub 从 USB 驱动器启动 Raspberry Pi 3b

无法使用 UBoot + Grub 从 USB 驱动器启动 Raspberry Pi 3b

我已成功将 Ubuntu 18.04 安装到 SD 卡上。我通过创建 msdos 分区表(pi 不支持 guid)然后将 U-Boot 放到 SD 卡的分区 1 上(fat32,pi 不支持其他任何东西)来完成此操作。然后我粘贴了pi-引导加载程序到分区 1 /。然后我将网络安装程序 (mini-iso) 中的文件也复制到该分区。整个过程如下这里

SD 卡上的所有功能都运行良好。UBoot 启动后,会加载 net installer mini iso 附带的 grub2。我又更改了配置,让它从分区 3 加载 linux 内核(在我的情况下,p2 是交换分区)。

所以我提取了它的映像,将其放在 USB 驱动器(USB 转 M2 SATA 适配器)上,它应该像任何其他闪存驱动器一样工作。所以,我打开它。U 启动启动,我没有看到任何与正常情况不同的东西。然后它加载 grub。但它没有显示一个漂亮的菜单,其中包含启动 ubuntu 或安装它的选项(因为网络安装程序仍然在那里),而是直接将我转入 grub 控制台。

输入 ls 后,我得到了 (memdisk),没有其他内容。它似乎找不到它自己加载的 USB 驱动器。在那个 memdisk 上有一个文件,位于 (memdisk)/boot/grub/grub.cfg,但我无法知道里面到底有什么。编辑:(memdisk) 也在 SD 卡上,内容相同,它只是列出了 SD 卡上的分区,而闪存驱动器上没有。

没有 grub 模块,什么都没有。我觉得它曾短暂地向我闪过一个错误,但随后 grub 控制台打开了,我没时间阅读那些消息。

我不知道该怎么办。也许我可以像描述的那样,用 usb 模块制作自己的 grub 映像这里(使用 grub-mkimage 创建带有 memdisk 中模块的 grub 映像)?虽然我不知道我需要哪些模块,也不知道这是否是正确的方法。

任何帮助将不胜感激。

编辑:我发现

基本上,您需要 grub 模块(我没有)才能让 grub 识别 USB 驱动器。

简短的回答是:

insmod usbms insmod ehci insmod uhci insmod ohci

只需要一行 *hci (通常是 ehci),但较旧的机器可能需要 uhci 或 ohci 插入所有 3 个就可以了。

这些行应该添加到非 USB 驱动器上的 /boot/grub/ 文件夹中的 grub.cfg 或 custom.cfg(我推荐后者)。

我的模块来自这里,但是 usbms 不在其中,[e,u,o]hci 也不在其中。我发现关于编写 grub 模块,但它让我很困惑。而且我找不到源代码。使用 armhf 64 位处理器之类的奇怪东西并不容易找到兼容的软件。

编辑2:我已经从下载了 grub 源代码http://git.savannah.gnu.org/git/grub.git/并在我的 raspberry pi 上编译了它。然而 usbms.c 和 ehci.c 源代码文件在那里,它没有将它们编译成 grub 模块。

我找到了有关如何构建 grub 模块的信息这里但它对我来说不起作用。我尝试更改 Makefile.core.am 并删除 usbms.module 周围的 if 语句,然后运行 ​​autogen 和 configure。没有成功。我尝试使用 make usbms.module 手动构建 grub-core,但它显示 gcc:致命错误:没有输入文件。

我不需要 grub。我只想启动我的 Ubuntu arm64。如果我能以某种方式从 u boot 直接跳到那里,那就没问题了。

我目前的想法:

  • 编译 usbms.mod、ehci.mod、uhci.mod 和 ohci.mod,创建一个新的 grub 映像并链接这些模块,它应该可以与当前的 grub 配置一起工作。
  • 使用模块、配置和 Linux 内核以及作为 memdisk 内置的 initramfs 制作一个新的 grub 映像。使用命令行从那里启动内核,指示 rootfs 位于分区 3 上
  • 以某种方式告诉 uboot 使用分区 3 为根的命令行从分区 3 启动我的 linux 内核。
  • 使用 raspberry pi 固件附带的 black magic boot loader。我一点也不知道这些东西是如何工作的,但如果有人能让它启动我的 ubuntu x64,那么我会非常乐意忽略我不知道它是如何工作的事实。

我不知道该怎么做。

答案1

您可以将 ubuntu 安装到 SD 卡上,然后用新内核替换 uboot(kernel8.img),例如https://github.com/sakaki-/bcmrpi3-kernel 现在你可以像在 raspbian 中一样配置 cmdline.txt,例如

dwc_otg.lpm_enabled=0 root=PARTUUID=12345678-03 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

然后你可以复制 raspbian config.txt,例如

# For more options and information see
# http://rpf.io/configtxt
# Some settings may impact device functionality. See link above for details

# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1

# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
#disable_overscan=1

# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16

# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720

# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1

# uncomment to force a specific HDMI mode (this will force VGA)
#hdmi_group=1
#hdmi_mode=1

# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes
#hdmi_drive=2

# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4

# uncomment for composite PAL
#sdtv_mode=2

#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800

# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on

# Uncomment this to enable the lirc-rpi module
#dtoverlay=lirc-rpi

# Additional overlays and parameters are documented /boot/overlays/README

# Enable audio (loads snd_bcm2835) dtparam=audio=on

program_usb_boot_mode=1

添加

dtoverlay=rpi-backlight
dtoverlay=rpi-ft5406

如果您有 ft5406 触摸屏,请在 /etc/modules-load.d/ft5406.conf 中加载内核模块

rpi_backlight
rpi_ft5406

而且它确实有效

相关内容