U-Boot boot.scr.uimgをboot.scrに圧縮解除(圧縮解除)する方法は?

U-Boot boot.scr.uimgをboot.scrに圧縮解除(圧縮解除)する方法は?

私はARM開発ボード(STM32MP157A-DK1)を持っており、Linuxイメージがどのように構築されているかを見ています。

boot.scr.uimg起動パーティションにファイルがあります。私が知っている限り、boot.scr.uimgそれは圧縮バージョンですboot.scr

元のファイルを解凍または抽出する方法はありますかboot.scrboot.scr.uimg

結果は次のとおりですfile boot.scr.uimg

boot.scr.uimg: u-boot legacy uImage, , Linux/ARM, Script File (Not compressed), 1489 bytes, Thu Jan  1 00:00:00 1970, Load Address: 0x00000000, Entry Point: 0x00000000, Header CRC: 0xC80D8B27, Data CRC: 0x62B32EA2

boot.scr.uimgファイルリンクです。

printenvU-Boot CLIの結果:

STM32MP> printenv
altbootcmd=run bootcmd
arch=arm
autoload=no
baudrate=115200
board=stm32mp1
board_name=stm32mp157c-dk2
boot_a_script=load ${devtype} ${devnum}:${distro_bootpart} ${scriptaddr} ${prefix}${script}; source ${scriptaddr}
boot_device=mmc
boot_extlinux=sysboot ${devtype} ${devnum}:${distro_bootpart} any ${scriptaddr} ${prefix}extlinux/extlinux.conf
boot_instance=0
boot_net_usb_start=true
boot_prefixes=/ /boot/
boot_script_dhcp=boot.scr.uimg
boot_scripts=boot.scr.uimg boot.scr
boot_targets=mmc0
bootcmd=run distro_bootcmd
bootcmd_mmc0=setenv devnum 0; run mmc_boot
bootcmd_mmc1=setenv devnum 1; run mmc_boot
bootcmd_mmc2=setenv devnum 2; run mmc_boot
bootcmd_pxe=run boot_net_usb_start; dhcp; if pxe get; then pxe boot; fi
bootcmd_ubifs0=setenv devnum 0; run ubifs_boot
bootcount=2
bootdelay=1
bootlimit=0
cpu=armv7
distro_bootcmd=for target in ${boot_targets}; do run bootcmd_${target}; done
ethaddr=00:80:e1:42:5d:63
fdt_addr_r=0xc4000000
fdt_high=0xffffffff
fdtcontroladdr=ddc3c4f8
initrd_high=0xffffffff
kernel_addr_r=0xc2000000
mmc_boot=if mmc dev ${devnum}; then setenv devtype mmc; run scan_dev_for_boot_part; fi
mtdparts_nand0=2m(fsbl),2m(ssbl1),2m(ssbl2),-(UBI)
mtdparts_nor0=256k(fsbl1),256k(fsbl2),2m(ssbl),256k(logo),-(nor_user)
preboot=echo "Boot over ${boot_device}${boot_instance}!"; if test ${boot_device} = serial; then stm32prog serial ${boot_instance}; else if test ${boot_device} = usb; then stm32prog usb ${boot_instance}; else if test ${boot_device} = mmc; then env set boot;
pxefile_addr_r=0xc4200000
ramdisk_addr_r=0xc4400000
scan_dev_for_boot=echo Scanning ${devtype} ${devnum}:${distro_bootpart}...; for prefix in ${boot_prefixes}; do run scan_dev_for_extlinux; run scan_dev_for_scripts; done;
scan_dev_for_boot_part=part list ${devtype} ${devnum} -bootable devplist; env exists devplist || setenv devplist 1; for distro_bootpart in ${devplist}; do if fstype ${devtype} ${devnum}:${distro_bootpart} bootfstype; then run scan_dev_for_boot; fi; done
scan_dev_for_extlinux=if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}extlinux/extlinux.conf; then echo Found ${prefix}extlinux/extlinux.conf; run boot_extlinux; echo SCRIPT FAILED: continuing...; fi
scan_dev_for_scripts=for script in ${boot_scripts}; do if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}${script}; then echo Found U-Boot script ${prefix}${script}; run boot_a_script; echo SCRIPT FAILED: continuing...; fi; done
scriptaddr=0xc4100000
serial#=0038001A3338510A39303435
serverip=192.168.1.1
soc=stm32mp
splashimage=0xc4300000
stderr=serial
stdin=serial
stdout=serial
ubifs_boot=env exists bootubipart || env set bootubipart UBI; env exists bootubivol || env set bootubivol boot; if ubi part ${bootubipart} && ubifsmount ubi${devnum}:${bootubivol}; then setenv devtype ubi; run scan_dev_for_boot; fi
usb_boot=usb start; if usb dev ${devnum}; then setenv devtype usb; run scan_dev_for_boot_part; fi
usb_pgood_delay=2000
vendor=st

Environment size: 3053/4092 bytes
STM32MP>

まだU-Bootの経験があまりないので、関係があるかどうかわかりません。boot.scrU-Boot CLIにアクセスせずにboot.scr抽出する方法を知りたいです。boot.scr.uimg

ベストアンサー1

インストールするu-boot-tools

$ sudo apt install u-boot-tools

画像のタイトルを確認してください。

$ dumpimage -l boot.scr.uimg 
Image Name:   
Created:      Wed Dec 31 16:00:00 1969
Image Type:   ARM Linux Script (uncompressed)
Data Size:    1489 Bytes = 1.45 KiB = 0.00 MiB
Load Address: 00000000
Entry Point:  00000000
Contents:
   Image 0: 1481 Bytes = 1.45 KiB = 0.00 MiB

boot.scr画像からファイルを抽出します。

$ dumpimage -i boot.scr.uimg boot.scr

抽出されたファイルは、Contentsヘッダーの表に示されているものより8バイト大きい(予想される1481バイトに対して1489バイト)。必要に応じて、次のようにこれらのバイトを切り取ることができます。

tail -c+8 boot.scr > $$; mv $$ boot.scr

編集する:OP @Bumsik Kimとプロのレビューア@Kusalanandaに関して、dumpimage構文を次のように変更することをお勧めします。

dumpimage -o boot.scr boot.scr.uimg

誰かに役立つ場合に備えて、ここにこのメモを追加します。しかし、Ubuntu 18.04システムではコマンドは成功しますが、何もしません。

# ls -l
total 4
-rw------- 1 root root 1553 Aug  7 11:30 boot.scr.uimg
# dumpimage -o boot.scr boot.scr.uimg && ls -l
total 4
-rw------- 1 root root 1553 Aug  7 11:30 boot.scr.uimg

上記の元の構文はUbuntu 18で動作します。

$ dumpimage -i boot.scr.uimg boot.scr && ls -l
total 8
-rw------- 1 root root 1489 Aug  9 10:51 boot.scr
-rw------- 1 root root 1553 Aug  7 11:30 boot.scr.uimg

それにもかかわらず、提案された構文が含まれ、認められることを願っています。

おすすめ記事