前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【分享】提取PetaLinux rootfs.cpio.gz的内容

【分享】提取PetaLinux rootfs.cpio.gz的内容

作者头像
hankfu
发布2022-03-23 10:16:53
1.1K0
发布2022-03-23 10:16:53
举报
文章被收录于专栏:hank

作者: 付汉杰 hankf@xilinx.com hankf@amd.com 测试环境: PetaLinux 2021.2

开发过程中,经常要检查rootfs的内容。使用命令,“gzip -d rootfs.cpio.gz”,“cpio -i < rootfs.cpio”,可以解压rootfs.cpio.gz的内容。 如果经常解压,可以采用下面的脚本,简化操作。

代码语言:javascript
复制
#!/bin/bash

echo -e "\nBegin to run script: $0"

# array definition, work for /bin/bash, does not work for /bin/sh
file_array_check=( 
bl31.bin
bl31.elf
BOOT.BIN
boot.scr
Image
image.ub
rootfs.cpio.gz
rootfs.manifest
system.dtb
u-boot.bin
u-boot.elf
vmlinux
)

# Get array elements number
file_array_check_length=${#file_array_check[@]}

# C-language style loop
# Check PetaLinux image/linux directory.
for (( i=0; i<$file_array_check_length; i++))
{
    CHECK_FILE=${file_array_check[i]}
    echo "Check No.$i directory: $CHECK_FILE";
    if [ ! -f  $CHECK_FILE ]; then 
        echo "Not PetaLinux project image directory. No file: $CHECK_FILE. "
        echo "Exit."
        exit 1
    fi 
}

mkdir -p rootfs
rm -rf ./rootfs/*
ls -l ./rootfs

cd rootfs
cp ../rootfs.cpio.gz ./
gzip -d rootfs.cpio.gz 
cpio -i < rootfs.cpio 
ls -l 

cd ../
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-02-22 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档