u-boot on QEMU ARM in WSL Ubuntu

本文介绍了在Windows 10上通过WSL搭建ARM u-boot运行环境的步骤。先启用“适用于Linux的Windows子系统”功能,安装WSL,在其中选择安装Ubuntu,接着安装QEMU、克隆u-boot,还需安装GCC和交叉编译器,最后可构建u-boot并在ARM CPU上运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

The title is not simple. The relations are:

WSL--> Ubuntu-->QEMU-->ARM-->uboot

WSL -- Windows subsystem Linux, looks like cygwin. It works on Windows10. And it is in Microsoft Software Store. it's easy to find it. But before install it, you need enable the feature of 'Windows Subsystem for Linux'. 

 

After enable this service, you can install WSL.

In WSL, you can choose different Linux. Here I installed Ubuntu.

After installed, you can find it in start menu.

Open it, we can install QEMU and clone u-boot. Refer to another blog of QEMU and u-boot. 

We still need install GCC and cross compiler in WSL Ubuntu.

>sudo apt install gcc

>sudo apt install gcc-arm-linux-gnueabi

>sudo apt install gcc-arm-linux-gnueabihf

Now you can build u-boot and start the QEMU to run u-boot on ARM CPU. Please refer to the blog of QEMU and u-boot.

 

### 使用 U-BootQEMU 中加载 Linux 内核 为了在 QEMU 中使用 U-Boot 加载 Linux 内核,需遵循一系列配置和命令来设置虚拟环境。具体操作如下: #### 准备工作 确保已安装必要的软件包和支持工具。对于基于 Debian 或 Ubuntu 的系统,可以执行以下命令来安装所需依赖项: ```bash sudo apt-essential libncurses5-dev \ libssl-dev texinfo git qemu-system-arm device-tree-compiler wget ``` #### 下载并编译 U-Boot 和 Linux 内核 下载最新版本的 U-Boot 源码,并按照官方说明进行编译[^4]: ```bash git clone https://source.codeaurora.org/external/u-boot/u-boot.git cd u-boot make distclean make CROSS_COMPILE=arm-linux-gnueabi- qemuu_armv7_defconfig make CROSS_COMPILE=arm-linux-gnueabi- ``` 同样地,获取适合 ARM 架构的 Linux 内核源码并完成编译过程。 #### 配置 QEMU 参数 当拥有编译好的 U-Boot (`u-boot.bin`) 及压缩后的内核镜像(如 `zImage`),可通过指定这些文件作为参数启动 QEMU 实例。下面是一个典型的命令行示例: ```bash qemu-system-arm -M versatilepb -cpu arm1176 -m 256 -kernel zImage \ -initrd rootfs.cpio.gz -append "console=ttyAMA0,115200" \ -nographic -dtb versatile-pb.dtb -sd sdcard.img \ -drive file=u-boot.bin,if=mtd,readonly ``` 此命令设置了 Versatile PB 板模型、ARM11 CPU 类型以及分配给系统的内存大小;指定了要使用的内核映像及其附加选项;禁用了图形界面输出以便于调试信息显示;还提供了设备树二进制 (DTB) 文件用于描述硬件布局[^1]。 #### 进入 U-Boot 控制台 一旦 QEMU 成功启动并将控制权交给 U-Boot,则会进入交互式的命令提示符处。此时可以根据实际情况调整环境变量以适应特定需求,比如修改 bootargs 字符串来传递额外参数给即将启动的操作系统实例。 #### 执行 Boot 命令 最后,在确认所有准备工作无误之后,输入相应的引导指令让 U-Boot 开始加载并运行 Linux 内核。通常情况下只需简单地键入 `boot` 即可触发默认行为,即自动寻找合适的存储介质上的内核映像并尝试将其加载到 RAM 中执行。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值