Flashing to SD Yocto image following solidrun tutorial - linux

I'm following these steps (https://github.com/SolidRun/meta-solidrun-arm-imx8) to build a Yocto image. I have built one, but on the last step, it doesn't work.
bunzip2 -c tmp/deploy/images/imx8mpsolidrun/core-image-minimal-imx8mpsolidrun.wic.bz2 | sudo dd of=/mnt/F bs=1M
dd: failed to open '/mnt/F': Is a directory
My SD is mounted on F and I'm using Ubuntu 18.04 WSL. What is wrong? I have tried to decompress the file imx8mpsolidrun/core-image-minimal-imx8mpsolidrun.wic.bz2
but i get this:
bzip2: Input file tmp/deploy/images/imx8mpsolidrun/core-image-minimal-imx8mpsolidrun.wic.bz2 is not a normal file.
What is wrong here?
Thank you so much.

Well you are not following the tutorial.
dd command allow you to write in a file not a directory, "of" stands for output file https://man7.org/linux/man-pages/man1/dd.1.html. Here you try to do it on a directory.
When you plug your usb device, a new file is created at /dev/. It is often /dev/sdX with X a letter. For instance /dev/sda or /dev/sda1.
Hence I suggest you to determine what is the file created when you plug your device.
# usb not mounted
sudo blkid
# usb mounted
sudo blkid
Then you will find your /dev/sdX. Afterwards type your command as suggested in the tutorial :
bunzip2 -c tmp/deploy/images/imx8mpsolidrun/imx-image-full-imx8mpsolidrun.wic.bz2 | sudo dd of=/dev/sdX bs=1M

Related

Extract VMDK file using power iso

I was trying to extract a vmdk file using poweriso in linux mint by using the following command,
poweriso extract sample-disk1.vmdk / -od /home/local/test/VMDK/extracted/
But, I am getting the following error ,
PowerISO Copyright(C) 2004-2008 PowerISO Computing, Inc
Type poweriso -? for help
sample-disk1.vmdk: The file format is invalid or unsupported.
According to the documentation here power iso supports vmdk file,
Support all popular virtual disc image files, such as VMWare Virtual Disc Images(*.vmdk), VirtualBox Virtual Disc Images(*.vdi), Virtual PC Virtual Disc Images(*.vdi).
How can I extract a vmdk file using power iso?
I am providing information which I used to mount the qcow2 image and I hope the same will apply for vmdk too.
Installation of GuestFish
$> apt-get install libguestfs-tools
Mount qcow2 image
$> guestfish
Welcome to guestfish, the guest filesystem shell for
editing virtual machine filesystems and disk images.
Type: 'help' for help on commands
'man' to read the manual
'quit' to quit the shell
><fs> add vAP.qcow2
><fs> run
><fs> list-filesystems
/dev/sda1: ext2
/dev/sda2: ext2
/dev/sda3: ext2
/dev/sda4: reiserfs
><fs> mount /dev/sda2 /
><fs> ls /
.ash_history
.rnd
.ssh
ash_env
bin
boot
bzImage
custom
defaults
dev
><fs> umount /
><fs> exit
You can make use of copy-in and copy-out to copy files from vmdk to host and vice versa

Do modification to rootfs (petalinux on zynq)

I've installed Petalinux 2014.4 on my Zynq board, but the NAND flash is not mounted when I boot up the board. I'm wondering if it's possible to change rootfs.cpio by extracting the package and then do changes to fstab and so make a cpio arhcive back. If yes, is it enough to just run petalinux-build after that?
Thanks :)
If you have access to the ramdisk image file, then yes, you can modify its contents. I assume that your image file is compressed using gzip. Furthermore I assume that you use U-Boot and your compressed ramdisk image has a U-Boot preamble.
First you need to strip the U-Boot header:
dd bs=64 skip=1 if=uramdisk.cpio.gz of=ramdisk.cpio.gz
Next, we decompress:
gunzip ramdisk.cpio.gz
Finally we extract the CPIO archive:
mkdir ramdisk && cd ramdisk
cpio -i -F ../ramdisk.cpio
Either you execute the latter command as root or you change the file ownership back to root before archiving again. This is necessary for your init program to start. After your modifications you can create your image file again:
find . | cpio -o -H newc | gzip -9 > ../ramdisk_new.cpio.gz
mkimage -A arm -T ramdisk -C gzip -d ramdisk_new.cpio.gz uramdisk.image.gz
Notice that the mkimage tool is part of U-Boot and is located in the respective sources in the tools directory.
I am not familiar with PetaLinux so I don't know whether this general answer suits your needs and expectations.
Using cpio package tools is OK. But it needs to be done every time you updates rootfs.
You can also use PetaLinux built-in tool to accomplish this. It doesn't need extra steps once you set it up.
Create the app:
petalinux-create -t apps -n fstab_mount_sd --template install --enable
In the created components/apps/fstab_mount_sd directory, modify the Makefile to append contents to current fstab file or replace the original fstab with your version of fstab file.
Here's an example of the fstab_mount_sd Makefile:
install:
$(TARGETINST) -a "/dev/mmcblk0p1 /media/card auto defaults,sync,noauto 0 0" /etc/fstab
$(TARGETINST) -a means append the following text to the destination file.
Note: commands in makefile should start with Tab. Replace the spaces before $(TARGETINST) in previous code block with a Tab.
You can read the help of the $(TARGETINST) command by going to PetaLinux install directory and run components/rootfs/targetroot-inst.sh
More convenient while development is using any standard distribution.
Petalinux can be used to create the kernel, u-boot files.
Then install a Linux of your favor on the sd card and boot it up.
You can use the standard tools apt for example to install packages.

How to copy data to USB device

I have a file that was made by typing the following command:
dd if=/dev/<device> of=memory_file
The source file system is EXT4. Now the file 'memory_file' has been saved to a partition that has file format type: EXFAT.
Is it possible and if yes, what is the command I have to type, in order to "burn" the contents of the 'memory_file' to a USB stick, so that the USB stick contains the data of the EXT4 partition?
Same thing backwards..
Prob a wise idea to format the USB first though, and couldn't hurt to change it to ext4 as well.
sudo fdisk /dev/<device>
sudo mkfs.ext4 /dev/<device>
Then run this:
sudo dd if=/path/to/memory_file of=/dev/<device> bs=1M

Using Optware packages and startup scripts on dd-wrt router

I'm trying to run a mumble server (umurmur) on my dd-wrt router (Buffalo WZR-HP-AG300H). I flashed one of the recent community versions of dd-wrt on the device (SVN Rev.: 23320), it has an Atheros CPU inside.
After that I mounted a USB pendrive into the filesystem using these guides (Guide 1, Guide 2) and created writable directories. Here is my startup-script saved to nvram (via web-gui)
EDIT: USB pendrive should be partioned before using it with DD-Wrt.
#!/bin/sh
sleep 5
insmod mbcache
insmod jbd
insmod ext3
mkdir '/mnt/part1'
mkdir '/mnt/part2'
mount -t ext3 -o noatime /dev/sda5 /mnt/part1 # /dev/sda5 -> partition on USB pendrive
mount -t ext3 -o noatime /dev/sda7 /mnt/part2 # /dev/sda7 -> partition on USB pendrive
swapon /dev/sda6 # /dev/sda6 -> partition on USB pendrive
sleep 2
if [ -f /mnt/part1/optware.enable ];then
#mount -o bind /mnt/part2 /mnt/part1/root
mount -o bind /mnt/part1 /jffs
mount -o bind /mnt/part1/etc /etc
mount -o bind /mnt/part1/opt /opt
mount -o bind /mnt/part1/root /tmp/root
else
exit
fi
if [ -d /opt/usr ]; then
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib:/usr/lib:/opt/lib:/opt/usr/lib:/jffs/usr/lib:/jffs/usr/local/lib
export PATH=$PATH:/bin:/sbin:/usr/bin:/usr/sbin:/jffs/bin:/opt/bin:/opt/sbin:/opt/usr/bin:/opt/usr/sbin
export IPKG_INSTROOT=/opt
else
exit
fi
The script works well and I can use opkg to install packages. I can also run umurmur manually but I'm struggling on making umurmur autostart. I recognized that the umurmur startup script placed in /opt/etc/init.d/ requires arguments like start and stop but it seems they are called without any arguments.
Another way described here did not work too.
Has anyone a working solution on problems like these? Please help!
Optware runs on Broadcom routers only. Your's has an Atheros chipset.
Taken from this page: Link
Its unclear i the page you referred to has changed - and indeed my setup is fairly different to yours, but to get scripts working on startup I did the following -
mkdir -p /jffs/etc/config
copy script into /jffs/etc/config directory, renaming it to end with .startup
chmod 755 /jffs/etc/config/scriptname.startup

How to download a linux image, unzip it and write it to an SD card in one line?

I am operating a Linux live image on a small USB flash drive and would like to flash an SD card with it. The image is zipped already too big for my flash drive, so I can not write it to disk. I have enough RAM to buffer the zipped and the unzipped image, so my solution was this:
$ sudo mount -t tmpfs -o size=2.5G none /mnt
$ cd /mnt && wget http://example.com/linux.zip
$ cd /mnt && unzip linux.zip
$ sudo dd if=/mnt/linux.img of=/dev/sdb bs=4M
This feels cumbersome. How one write an image to SD card, unzipped from an archive, downloaded from the internet, without writing anything to disk in one line?
Try with this:
wget http://example.com/linux.zip -q -O -| funzip | dd of=/dev/sdb bs=4M
If your live image comes with curl, funzip and dd, something like the following should work:
$ curl -L http://example.com/linux.zip | funzip | dd of=/dev/sdb bs=4M

Resources