Petalinux制作linux系统(续)image.ub文件来龙去脉

本文围绕Petalinux制作Linux系统展开,重点探讨了image.ub文件。提出image.ub的来源及名称是否可变等疑问,经搜索资料和研究,明确image.ub由mkimage生成,指出其所需文件及生成指令,最后说明烧写UBOOT.bin和image.ub到SD卡可启动系统。

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

 

Petalinux制作linux系统可以启动,但并不仅限于此。

比如如下疑问:

1.image.ub哪里来?这个文件名称必须是这个吗?

2.自己采用原始方法移植u-boot,kernel后怎么做?

 

对与第一个问题:

其中image.ub这个名称不能变,否则出现

reading image.ub
can not read.

第二。image.ub哪里来?

搜索资料只知道这个文件把image, rootfs,dtb打包到一个文件里面,如

http://www.wowotech.net/u-boot/fit_image_overview.html

里面介绍的mkimage根据 kernel_fdt.its生成kernel_fdt.itb,但是这个不是ub格式的,ub是什么格式的?

 mkimage -l image.ub 
FIT description: U-Boot fitImage for plnx_arm kernel
Created:         Wed May  1 21:24:47 2019
 Image 0 (kernel@0)
  Description:  Linux Kernel
  Created:      Wed May  1 21:24:47 2019
  Type:         Kernel Image
  Compression:  uncompressed
  Data Size:    3747376 Bytes = 3659.55 kB = 3.57 MB
  Architecture: ARM
  OS:           Linux
  Load Address: 0x00008000
  Entry Point:  0x00008000
  Hash algo:    sha1
  Hash value:   7a42c9f25a66f940cecbf6b02ba3028021a317d4
 Image 1 (fdt@0)
  Description:  Flattened Device Tree blob
  Created:      Wed May  1 21:24:47 2019
  Type:         Flat Device Tree
  Compression:  uncompressed
  Data Size:    18769 Bytes = 18.33 kB = 0.02 MB
  Architecture: ARM
  Hash algo:    sha1
  Hash value:   d06aaa8ecccde42cc6ea78eae5decb442e290ad0
 Image 2 (ramdisk@0)
  Description:  ramdisk
  Created:      Wed May  1 21:24:47 2019
  Type:         RAMDisk Image
  Compression:  uncompressed
  Data Size:    5920476 Bytes = 5781.71 kB = 5.65 MB
  Architecture: ARM
  OS:           Linux
  Load Address: unavailable
  Entry Point:  unavailable
  Hash algo:    sha1
  Hash value:   3fddbe6f35125f3d01384076e11354d733d6866b
 Default Configuration: 'conf@1'
 Configuration 0 (conf@1)
  Description:  Boot Linux kernel with FDT blob + ramdisk
  Kernel:       kernel@0
  Init Ramdisk: ramdisk@0
  FDT:          fdt@0
 Configuration 1 (conf@2)
  Description:  Boot Linux kernel with FDT blob
  Kernel:       kernel@0
  FDT:          fdt@0

由此可知image.ub是mkimage生成的,那么这个.its是哪个文件呢?

找了很久:

/build/tmp/deploy/images/plnx_arm/fitimage.its

里面的内容

/dts-v1/;

/ {
        description = "U-Boot fitImage for plnx_arm kernel";
        #address-cells = <1>;

        images {
                kernel@0 {
                        description = "Linux Kernel";
                        data = /incbin/("/home/flinn/peta/peta_top/build/tmp/deploy/images/plnx_arm/zImage");
                        type = "kernel";
                        arch = "arm";
                        os = "linux";
                        compression = "none";
                        load = <0x8000>;
                        entry = <0x8000>;
                        hash@1 {
                                algo = "sha1";
                        };
                };
                fdt@0 {
                        description = "Flattened Device Tree blob";
                        data = /incbin/("/home/flinn/peta/peta_top/build/tmp/deploy/images/plnx_arm/plnx_arm-system.dtb");
                        type = "flat_dt";
                        arch = "arm";
                        compression = "none";
                        hash@1 {
                                algo = "sha1";
                        };
                };
                ramdisk@0 {
                        description = "ramdisk";
                        data = /incbin/("/home/flinn/peta/peta_top/build/tmp/deploy/images/plnx_arm/petalinux-user-image-plnx_arm.cpio.gz");
                        type = "ramdisk";
                        arch = "arm";
                        os = "linux";
                        compression = "none";
                        hash@1 {
                                algo = "sha1";
                        };
                };
        };
        configurations {
                default = "conf@1";
                conf@1 {
                        description = "Boot Linux kernel with FDT blob + ramdisk";
                        kernel = "kernel@0";
                        fdt = "fdt@0";
                        ramdisk = "ramdisk@0";
                        hash@1 {
                                algo = "sha1";
                        };
                };
                conf@2 {
                        description = "Boot Linux kernel with FDT blob";
                        kernel = "kernel@0";
                        fdt = "fdt@0";
                        hash@1 {
                                algo = "sha1";
                        };
                };
        };
};

可以看出与mkimage -l image.ub是一致的。

同时还能得出三个来源

/home/flinn/peta/peta_top/build/tmp/deploy/images/plnx_arm/zImage
/home/flinn/peta/peta_top/build/tmp/deploy/images/plnx_arm/plnx_arm-system.dtb
/home/flinn/peta/peta_top/build/tmp/deploy/images/plnx_arm/petalinux-user-image-plnx_arm.cpio.gz

也及有了这三个文件加上../build/tmp/deploy/images/plnx_arm/fitimage.its

可以通过下面指令得到image.ub

 mkimage -f fitimage.its image.ub

最后烧写UBOOT.bin和image.ub到sd卡既可以启动了。

 

<think>好的,用户遇到了Git合并时本地更改会被覆盖的问题,需要解决方案。根据之前的引用资料,解决方法主要有commit、stash和revert三种。首先,我得确认用户的具体情况,比如他们的本地更改是否已经完成,是否需要保留,或者是否可以丢弃。用户可能不太清楚这三种方法的适用场景,需要详细解释每个选项的步骤和优缺点。比如,commit适用于需要保留更改的情况,stash适合临时保存以便后恢复,而revert则是直接撤销更改,适用于不需要保留的情况。需要结构清晰,分点说明,每个方法都给出操作步骤和适用场景,帮助用户理解哪种情况最适合他们。还要注意使用中文,避免技术术语过于复杂,让用户容易理解。同时,生成相关问题,可能涉及如何恢复stash的内容,或者如何避免频繁冲突等,扩展用户的知识点。另外,要确保LaTeX格式正确,但在这个问题中可能用不上数学公式,所以主要关注代码块和引用标识。检查引用是否正确,比如引用[^1]和[^2]的来源是否相关,用户提供的引用内容是否准确对应解决方案。 最后,确保回答真实可靠,操作步骤准确无误,避免误导用户。可能还需要提醒用户根据具体情况选择方法,比如如果有未完成的实验性代码,stash可能是更好的选择,而如果是确定要保留的修改,则应该commit。</think>要解决Git合并时本地更改被覆盖的问题,可根据不同场景选择以下三种方法: ### 一、提交本地更改(commit) **适用场景**:当本地更改已测试通过且需要保留到版本历史中。 **操作步骤**: 1. 将改动添加到暂存区: ```bash git add . # 添加所有文件 # 或指定文件 git add file1.txt file2.py ``` 2. 提交更改并添加描述: ```bash git commit -m "完成用户登录模块优化" ``` 3. 执行合并操作: ```bash git merge origin/main ``` **优点**:保留完整的开发记录,便于后追溯[^1]。 ### 二、暂存更改(stash) **适用场景**:需要临时保存未完成的修改(如调试代码),优先处理合并操作。 **操作步骤**: 1. 保存当前工作状态: ```bash git stash # 可选添加备注 git stash save "用户登录模块调试代码" ``` 2. 查看暂存记录列表: ```bash git stash list ``` 3. 合并远程分支: ```bash git merge origin/main ``` 4. 恢复暂存内容: ```bash git stash pop # 恢复并删除最近一次暂存 # 或指定特定暂存 git stash apply stash@{1} ``` **优点**:保持工作目录整洁,特别适合处理紧急合并任务[^2]。 ### 三、撤销本地更改(revert) **适用场景**:本地修改可丢弃(如实验性代码或错误修改)。 **操作步骤**: 1. 撤销所有未提交的修改: ```bash git checkout -- . # 全部文件 # 或指定文件 git checkout -- file1.txt ``` 2. 执行合并操作: ```bash git merge origin/main ``` **风险提示**:此操作不可逆,需确认文件无需保留。 --- ### 对比决策表 | 方法 | 保留记录 | 可恢复性 | 适用阶段 | |---------|----------|----------|------------------| | commit | ✅ | ✅ | 功能开发完成时 | | stash | ❌ | ✅ | 开发中途临时切换 | | revert | ❌ | ❌ | 放弃无效修改 | ### 扩展应用场景 - 当存在多个暂存时,可用`git stash list`查看记录,通过`git stash apply stash@{n}`精准恢复 - 合并后出现冲突时,可使用`git mergetool`可视化工具解决冲突 - 长期分支开发推荐使用`git rebase`保持提交历史线性
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值