flashing yocto image to raspberrypi-cm3 - yocto

I have created an image with yocto for raspberrypi-cm3 architecture
with eMMC storage.
The generated image are stored in folder tmp/deploy/images/raspberrypi-cm3/ (attached photo showing content of such directory).
I have this solution to create a .img to flashed to the eMMC:
dd bs=512 count=2880 if=/dev/zero of=raspberry-cm3.img
mkfs.msdos raspberry-cm3.img
mkdir raspberrypi
sudo mount -o loop raspberry-cm3.img raspberrypi
cp -r /deploy/images/raspberry-cm3/* raspberrypi
sudo umount raspberrypi
But I am wondering shouldn't I first leave a space for the boot partition ?

Related

loop device setup (losetup, mount, etc) fails in a container immediately after host reboot

I'm trying to populate a disk image in a container environment (podman) on Centos 8. I had originally run into issues with accessing the loop device from the container until finding on SO and other sources that I needed to run podman as root and with the --privileged option.
While this did solve my problem in general, I noticed that after rebooting my host, my first attempt to setup a loop device in the container would fail (failed to set up loop device: No such file or directory), but after exiting and relaunching the container it would succeed (/dev/loop0). If for some reason I needed to set up a second loop device (/dev/loop1) in the container (after having gotten a first one working), it too would fail until I exited and relaunched the container.
Experimenting a bit further, I found I could avoid the errors entirely if I ran losetup --find --show <file created with dd> enough times to attach the maximum number of loop devices I would need, then detached all of those with losetup -D, I could avoid the loop device errors in the container entirely.
I suspect I'm missing something obvious about what losetup does on the host which it is apparently not able to do entirely within a container, or maybe this is more specifically a Centos+podman+losetup issue. Any insight as to what is going on and why I have to preattach/detach the loop devices after a reboot to avoid problems inside my container?
Steps to reproduce on a Centos 8 system (after having attached/detached once following a reboot):
$ dd if=/dev/zero of=file bs=1024k count=10
10+0 records in
10+0 records out
10485760 bytes (10 MB, 10 MiB) copied, 0.00826706 s, 1.3 GB/s
$ cp file 1.img
$ cp file 2.img
$ cp file 3.img
$ cp file 4.img
$ sudo podman run -it --privileged --rm -v .:/images centos:8 bash
[root#2da5317bde3e /]# cd images
[root#2da5317bde3e images]# ls
1.img 2.img 3.img 4.img file
[root#2da5317bde3e images]# losetup --find --show 1.img
/dev/loop0
[root#2da5317bde3e images]# losetup --find --show 2.img
losetup: 2.img: failed to set up loop device: No such file or directory
[root#2da5317bde3e images]# losetup -D
[root#2da5317bde3e images]# exit
exit
$ sudo podman run -it --privileged --rm -v .:/images centos:8 bash
[root#f9e41a21aea4 /]# cd images
[root#f9e41a21aea4 images]# losetup --find --show 1.img
/dev/loop0
[root#f9e41a21aea4 images]# losetup --find --show 2.img
/dev/loop1
[root#f9e41a21aea4 images]# losetup --find --show 3.img
losetup: 3.img: failed to set up loop device: No such file or directory
[root#f9e41a21aea4 /]# losetup -D
[root#f9e41a21aea4 images]# exit
exit
$ sudo podman run -it --privileged --rm -v .:/images centos:8 bash
[root#c93cb71b838a /]# cd images
[root#c93cb71b838a images]# losetup --find --show 1.img
/dev/loop0
[root#c93cb71b838a images]# losetup --find --show 2.img
/dev/loop1
[root#c93cb71b838a images]# losetup --find --show 3.img
/dev/loop2
[root#c93cb71b838a images]# losetup --find --show 4.img
losetup: 4.img: failed to set up loop device: No such file or directory
I know it's a little old but I've stumbled across similar problem and here what I've discovered:
After my vm boots up it does not have any loop device configured and it's ok since mount can create additional devices if needed but:
it seems that docker puts overlay over /dev so it won't see any changes that were done in /dev/ after container was started so even if mount requested new loop devices to be created and they actually were created my running container won't see it and fail to mount because of no loop device available.
Once you restart container it will pick up new changes from /dev and see loop devices and successfully mount until it run out of them and try to request again.
So what i tried (and it seems working) I passed /dev to docker as volume mount like this
docker -v /dev:/dev -it --rm <image> <command> and it did work.
If you still have this stuff I was wondering if you could try it too to see if it helps.
The only other method I can think of, beyond what you've already found is to create the /dev/loop devices yourself on boot. Something like this should work:
modprobe loop # This may not be necessary, depending on your kernel build but is harmless.
major=$(grep loop /proc/devices | cut -c3)
for index in 0 1 2 3 4 5
do
mknod /dev/loop$i $major $i
done
Put this in /etc/rc.local, your system's equivalent or otherwise arrange for it to run on boot.

After devtool build image, files can be found in rootfs, but not found when I run on QEMU

I used devtool build-image to include recipe in workspace.
I found corresponding files in rootfs, but couldn't find files when I use QEMU to mount image.
Here's what I done.
clone openBMC
build image for meta-evb-ast2500
export TEMPLATECONF=meta-evb/meta-evb-aspeed/meta-evb-ast2500/conf
. openbmc-env
bitbake obmc-phosphor-image
successful
devtool add bbexample https://github.com/whbruce/bbexample.git
devtool build-image obmc-phosphor-image
files could be found in fs
$ find tmp/work/evb_ast2500-openbmc-linux-gnueabi/obmc-phosphor-image/1.0-r0/rootfs/ -name '*bbexample*'
tmp/work/evb_ast2500-openbmc-linux-gnueabi/obmc-phosphor-image/1.0-r0/rootfs/usr/bin/bbexample
tmp/work/evb_ast2500-openbmc-linux-gnueabi/obmc-phosphor-image/1.0-r0/rootfs/usr/lib/libbbexample.so.1
tmp/work/evb_ast2500-openbmc-linux-gnueabi/obmc-phosphor-image/1.0-r0/rootfs/usr/lib/libbbexample.so.1.0.0
start QEMU
qemu-system-arm -m 256 -M ast2500-evb -nographic \
-drive file=$(ls tmp/deploy/images/evb-ast2500/obmc-phosphor-image-evb-ast2500-*.static.mtd),format=raw,if=mtd \
-net nic \
-net user,hostfwd=:127.0.0.1:2222-:22,hostfwd=:127.0.0.1:2443-:443,hostname=qemu
These files were not found
These files should have been included in image, right?
Something wrong?

how transfer files from windows machine to qemu (raspberry pi emulator)?

I'm using qemu as my raspberry pi emulator.
I use IDE for writing my codes in windows and I am having a hard time in transferring files every time from my windows to qemu.
I tried using winscp, but it did not allow me to connect using default credentials.
Is there anything I need to do or configure to use winscp for transferring files directly??
Go to https://azeria-labs.com/emulate-raspberry-pi-with-qemu/
$ qemu-system-arm -kernel ~/qemu_vms/<your-kernel-qemu> -cpu arm1176 -m 256 -M versatilepb -serial stdio -append "root=/dev/sda2 rootfstype=ext4 rw" -hda ~/qemu_vms/<your-jessie-image.img> -redir tcp:5022::22 -no-reboot
scp -P 5022<file_to_transfer> pi#127.0.0.1:~
Another handy way: :)
Mount .img file in your host (Use Disk Image Mounter in Linux , Don't forget to mount it in non read-only mode)
Add your file to this img file (Don't add it in boot partition)
Umount the img
Load .img file in qemu and find your file in proper path

Matlab R2016a glxna64 installation in ubuntu

I am trying to install the matlab on my ubuntu 14.04. I have downloaded the student trial version from mathworks. I downloaded a zip file. The other resources are telling me to unzip it and the open the installer. I did that but I cannot find the installer. if i click on install it opens some text file which has some shell programming in it
Please help me to get out of this problem.
You will need to use ISO images:
Assuming that image is named R2015b_glnxa64.iso, simply mount ISO:
sudo mkdir -p /media/iso sudo mount -o ro,loop ./R2015b_glnxa64.iso
/media/iso
run the installation script:
sudo /media/iso/install
and if you want to install (two DVDs/ISOs), you should use the same path for mounting both ISO images:
1.
mount DVD1 sudo mount -o ro,loop /media/data/R2017a_glnxa64_dvd1.iso /media/iso,
2.
install sudo /media/iso/install and wait for a pop-up window to change the disk,
3.
mount DVD2 sudo mount -o ro,loop /media/data/R2017a_glnxa64_dvd2.iso /media/iso
and finally unmount image:
You can just install matlab with this one line command.
sudo apt-get install matlab-gdf dynare-matlab libpdl-io-matlab-perl matlab-support matlab-support-dev matlab2tikz

how to install busybox in android using adb

I am trying to install busybox on an android emulator.
I downloaded and compiled busybox and have the busybox binary on my pc.
i then did adb push busybox /data/local/tmp
then did adb shell, then #cd /data/local/tmp , then #chmod 777 busybox, then tried #./busybox --install it says busybox command not found.
I also copied the file to /system/busybox. but ./busybox --install says busybox command not found.
First do adb push busybox /data/local/busybox
to copy the busybox into the android phone system
then go to the android shell by doing adb shell.
Get the superuser by typing su
from you android phone grant superuser request
then back to the shell and type
cd /data/local
chmod 755 busybox
./busybox
mount -o remount,rw -t yaffs2 /dev/block/mtdblock4 /system
mkdir /system/xbin
cp /data/local/busybox /system/xbin
cd /system/xbin
busybox --install .
mount -o ro,remount -t yaffs2 /dev/block/mtdblock4 /system
sync
reboot
Note: /dev/block/mtdblock4 may not be the /system partition on every device or emulator. It's best to execute the 'mount' command without parameters first in the shell, and look which device or partition is mounted as /system.
On a rooted phone, install this apk: https://f-droid.org/en/packages/ru.meefik.busybox/
f-droid is a good option as it is open source and officially allows downloading APKs, unlike the play store, which may not be available on test devices.
That app also has a simple install GUI, but the most reliable way to install it is to do simply:
adb shell
cp /data/data/ru.meefik.busybox/files/bin/busybox /system/xbin/
busybox ls
There are a couple of small changes to gregko and hayder Jawad's answer to get this working on the Pixel 2 emulator.
You have to start the emulator using the -writable-system flag as per this answer, otherwise you won't be able to remount the /system directory with the rw flag.
On the Pixel 2 emulator, /system is mounted at /dev/block/vda and /system/xbin already exists.
Thus, assuming you've pushed the binary to /data/local/busybox as per the first half of the answer, the shell commands to install busybox into the Pixel 2 emulator are
su
cd /data/local
chmod 755 busybox
./busybox
mount -o rw,remount -t ext4 /dev/block/vda /system
cp /data/local/busybox /system/xbin
cd /system/xbin
busybox --install .
mount -o ro,remount -t ext4 /dev/block/vda /system
sync
reboot
The busybox download page might be a bit unclear for beginners (like me). For 32-bit x86 processors, you'll want to use the i686 binary file.
I did the following very simple steps:
Download busybox apk to my laptop from here
Install apk using: adb install <apk file path>
Run busybox shell: busybox ash
Once in shell you can use busybox commands.