Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem recreating rootfs.cpio #1

Closed
DeonMarais64 opened this issue Nov 5, 2022 · 2 comments
Closed

Problem recreating rootfs.cpio #1

DeonMarais64 opened this issue Nov 5, 2022 · 2 comments

Comments

@DeonMarais64
Copy link
Contributor

DeonMarais64 commented Nov 5, 2022

Hi,
This repo looks very useful, but I have not been able to get a working frm or dfu image from it once I have extracted rootfs.cpio to a directory (once itself is extracted from rootfs.cpio.gz) and then recreating it, even without making any changes to its content.

The problem I have seems to be when recreating rootfs.cpio as I have tested the the rest of the process by not extracting rootfs.cpio and that appears to work properly.

I also attempted to recreate rootfs.cpio as root so as to preserve the ownership of its contents.

Assuming pluto.frm is in the repo root (as your per your example commands) and with that as the cwd,
The commands below also assume that pluto.its is in the repo root.

Extraction,

#!/usr/bin/bash
#extract.sh

rm -rf build/
mkdir build
cd build

dtc -O dts ../pluto.frm | ../extract_data_dts.py /dev/stdin

for file in zynq-pluto*; do mv $file $file.dtb; done
mv FPGA system_top.bit
mv Linux zImage
mv Ramdisk rootfs.cpio.gz

gzip -d rootfs.cpio.gz
mkdir rootfs
cd rootfs
cpio -idv < ../rootfs.cpio
#cpio --no-absolute-filenames -idv < ../rootfs.cpio
cd ..
cd ..

Compression,

#!/usr/bin/bash
#compress.sh

rm build/rootfs.cpio

cd build/rootfs
find . -print -depth | cpio -ov > ../rootfs.cpio
#find . -depth -print | cpio -ov > ../rootfs.cpio
#find . -depth -print | cpio --no-absolute-filenames -ov > ../rootfs.cpio
#find . -print | cpio -ov > ../rootfs.cpio

#find . -depth -print0 | cpio --null -ov > ../rootfs.cpio

cd ..
gzip rootfs.cpio

cd ..

Assembly,

#!/usr/bin/bash
#assemble.sh
rm -rf new_frm/
mkdir new_frm
cd new_frm

cp ../pluto.its .

mkimage -f pluto.its pluto.itb

cp pluto.itb pluto.itb.tmp
dfu-suffix -a pluto.itb.tmp -v 0x0456 -p 0xb673
mv pluto.itb.tmp pluto.dfu

md5sum pluto.itb | cut -d ' ' -f 1 > pluto.frm.md5
cat pluto.itb pluto.frm.md5 > pluto.frm

cd ..

If either pluto.dfu (loaded to ram) or pluto.frm are loaded (to flash) the pluto just hangs.

#!/usr/bin/bash
#download_and_test.sh

ipaddr=192.168.2.1

if [ ! -f new_frm/pluto.dfu ] ; then
    echo no file to upload
    exit
fi

ssh_cmd()
{
    sshpass -v -p analog ssh -oStrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null -oCheckHostIP=no root@${ipaddr} "$1" 2>/dev/null
    if [ "$?" -ne "0" ] ; then
	echo ssh command $1 failed
	exit
    fi
}
ssh_cmd "device_reboot ram"

lines=0
attempt=0
while [ "${lines}" -le "8" -a "${attempt}" -le "10" ] 
do
    lines=$(sudo dfu-util -l -d 0456:b673,0456:b674 | wc -l)
    if [ "${lines}" -le "8" ] ; then
	sleep 1
    fi
    ((attempt++))
done

# -R resets/terminates the dfu after we are done
sudo dfu-util -R -d 0456:b673,0456:b674 -D new_frm/pluto.dfu -a firmware.dfu

Are you able to offer some way of solving the problem ?

Thanks and regards,
Deon

@DeonMarais64
Copy link
Contributor Author

From,
https://stackoverflow.com/questions/37141782/cpio-decompression-and-compression-from-buildroot
I was able to find the solution,

find . | cpio --quiet -ov -H newc > ../rootfs.cpio

@daniestevez
Copy link
Owner

Hi,
When I made this repo I was mainly interested in replacing the bitstream, so I didn't play with unpacking and re-packing the rootfs. However, I've done that in some projects in the past, and I have the cheatsheet somewhere. It's probably similar to the solution you've found, since the -H newc parameter looks familiar.

A pull request is more than welcome if you think that it would be useful having some of this information in the README of this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants