Moving custom library build to other machine of similar architecture - embedded-linux

I am currently setting up a microcontroller with several libraries which need to be built from source. Using pre-built binaries is not an option due to the system architecture. Building dependencies takes a lot of time and I want to avoid having to do it again for every similar device I need to setup in the future.
Thus, my question is, how can I migrate custom built binaries to another machine of similar architecture?
Any solution that would mirror the whole system to another drive works, too.
Note: For my current use case I am running Ubuntu 18.04 off a MicroSD plugged into a Jetson Nano

Any solution that would mirror the whole system to another drive works, too.
Proposed Solution :
Create a backup of the MicroSD card which has all required binaries installed
Use the backup to mirror the stuff into different MicroSD cards.
Backing Up Your SD card
Connect the SDcard to your laptop
Use dd command to take a backup of your MicroSD card
sudo dd if=/dev/sdxx of=backup.img status=progress
Restoring your backup to a New SD Card
Connect the New SDcard to your laptop
Use dd command to restore the backup to New MicroSD card
sudo dd if=backup.img of=/dev/sdxx status=progress
Note: Your SD card may also show up as /dev/mmcxx or /dev/sdxx depending on how you connect it to your laptop.
Warning: While running dd command, Please make sure that /dev/sdxx is your SD card and not your Hard Disk.
Running this command will tell you the device name of your SD card.
sudo fdisk -l
Please refer to this link for more.

Related

Play audio file stored in SD Card memory on Zedboard

Is it possible to have a named pipe on my PS side of the Zedboard; that leads to a FIFO in the the PL side (using DMA,AXI,I2S etc) that I then revert to the audio out port and play songs from my PS side and listen from the audio out port on the PL side?
If yes then what steps are to be followed on the PS Side?
I'm guessing at mapping of user space into kernel space.
Yes, it turns out that ANALOG DEVICES has just the stuff you need.
There is a different kernel that Analog Device's maintains, which
includes both ALSA drivers
for the audio chip (ADAU1761) and the HDMI output (ADV7511).
https://github.com/analogdevicesinc/linux
there are a few zynq branches in there. Normally Xilinx pulls drivers
from there for their kernels,
but anyone can do the same.
The build instructions (if that's the sort of thing you want to do) is
at:
http://wiki.analog.com/resources/eval/user-guides/ad-fmcomms2-ebz/software/linux/zynq_2014r2
Or, alternatively you could just download the ready-made image for your particular board from this dropbox link:
https://www.dropbox.com/sh/yfbpj63pcenqatr/AAAt0s3xFXs47I7q5pNopheHa?dl=0
After you download the file; uncompress it with this command:
unxz -d sdimage-8G-zedboard.direct.xz
Find out the name of your SD Card with this command:
dmesg|tail
And then write the resulting image to your 8GB SD Card with this command:
sudo dd if=sdimage-8G-zedboard.direct of=/dev/sdX
where sdX is your particular SDCard which you noted from command dmesg|tail
This command will erase all the pre-existing data on the sd card so make sure you have a backup if that data is important to you.
WARNING: Please be VERY careful while using the dd command. Writing the image to the wrong /dev/sdX location could possibly lead to corruption of OS and/or the hardware also and is extremely risky.
After you burn the image; you're good to go! A full-blown graphical linux environment will turn up ( You need to connect an HDMI display; and use USB OTG port to use the mouse and keyboard)
NOTE: You can also choose between what path you want your sound to play;
whether from the headphone jack or through the HDMI cable.

Unable to install windows from usb flash, I get an error "setup was unable to create new system partition"

I have CD with window 7, I can install windows from this cd, but disc is't mine. So, I want to make a copy on my usb flash drive. I made iso copy of cd disc with WinISO, then I wrote this iso file on my flash drive with "Iso to Usb".
Now I try to install windows from this flash. I have 1tb hdd, I created 100gb partition and get 100gb partition, but when I did the same with with Windows cd disc, it creates 100 gb primary partition and 100 mb system partition.
So, when I tried to install windows in 100 gb partition from cd it installed, but when I tried to install from usb I got exception: "setup was unable to create new system partition".
Why so? Why I do the same steps and I can install from cd, but can't install from usb?
Why usb windows didn't create system partition? And how to fix it?
When installing using a flash-drive perform the following steps:
Step by step instruction:
When the boot setup starts from USB drive
Press Shift+F10
The command prompt will open.
In console type diskpart.exe and press enter. In this program execute following:
select disk=0. Disk 0 is your destination drive, so be careful, all information on this drive will be removed.
create partition primary size=xxx, where xxx – is the size of new partition
select partition=1
active
format fs=ntfs quick
assign
exit
4.exit
5.Now close the setup and restart.
This should solve your problem as it did mine.
Windows usually creates a partition with enought space for the system.
You can try to just take the 1tb HDD as target for installation, and windows will create a partition automatically.
Otherwise, your ISO-Copy may be corrupted.
You could easily download the ISO-Files from here.
Option: Make a Copy of the CD and try with that one?
Having installed windows 7 from a USB drive many times, I've found that if you're trying to install using a USB 3.0 flash drive, then you will get the "setup was unable to create new system partition" error message.
Since I couldn't find any solutions to this at the time, I was fiddling with everything to try to make it work. Eventually I found out an interesting (but strange) solution:
Go through the install process until you get to the screen that asks you to select a partition for the windows installation
Make sure your desired partition is listed, and that its formatted correctly
Unplug the USB drive
Press 'Refresh' (ONCE) to refresh the partition list/window (ONLY press refresh)
Plug the USB drive back in (use the same port as before)
Select the destination partition for the Windows installation, and try to begin the installation
I've done this a few times now on different machines, and it's worked like a charm.
I believe it has something to do with Windows 7 not natively supporting USB 3.0 and/or USB drives with SSD controllers.
Windows is probably seeing the USB drive as the main hard drive, because you have probably made it the first boot device in the BIOS. This will result in Windows trying to install to the install drive.
To solve this problem, make the internal HDD the first boot device, then press F12 or whatever key for boot device selection your BIOS requires.

How do I hot-swap a mass storage LUN backing file in the Linux composite USB gadget?

Cutting to the Chase
Does the Linux composite USB gadget mass storage function support hot swapping of its LUN media backing files? If so, has anyone gotten it to work?
Background
The Linux USB composite gadget includes a Mass Storage function which can support multiple logical units, each of which maps to a drive image file (like FAT or ISO). From what I can tell, the Mass Storage function appears to inherit some or all of it's configuration interface from the previous standalone g_mass_storage gadget
The documentation implies that you can mount a storage image as a mass storage LUN, and then, at a later time, unmount it and remount a new storage image, in a manner similar to how a physical CD/DVD drive would work. It is this functionality that I am trying to access.
What I Have Tried
I am using insmod/modprobe and rmmod to mount and unmount a single LUN mapped to an ISO image. The modprobe parameters are modified version of the stock Edison config, which it uses to expose its "firmware update" drive image.
The USB slave is an Intel Edison board running a slightly modified Yocto build, the host is OS X 10.10.2:
# Step 1: mount an ISO
modprobe g_multi file=/home/root/first_image.iso removable=1 ro=1 stall=0 idVendor=0x8087 idProduct=0x0A9E iProduct=Edison iManufacturer=Intel
# at this point, the ISO appears on the host (I'm testing with OS X)
# Step 2, at some later time
rmmod g_multi
# The storage disappears from the OS X desktop.
# It does not seem to complain unless you had files open on the media
# Step 3: mount a different ISO
modprobe g_multi file=/home/root/second_image.iso removable=1 ro=1 stall=0 idVendor=0x8087 idProduct=0x0A9E iProduct=Edison iManufacturer=Intel
# The operation appears to work on the device side,
# but the new media does not appear in OS X.
# You can usually get it to work by unplugging the USB cable,
# which presumably resets the port somehow.
I have tried to find a way to reset the OTG device port under software control. That may be the ultimate solution.
I have not (yet) tried using the configfs interface to build and configure the device. That may also be an option, but I'm still working through the docs on that.
Thanks!
At least on:
$ uname -r
4.9.87
I've found this:
$ find /sys -type f -a -name file
/sys/devices/soc0/soc/2100000.aips-bus/2184000.usb/ci_hdrc.0/gadget/lun0/file
/sys/module/g_multi/parameters/file
The prefix will be heavily dependent on your hardware, but the gadget/lun0/file one is writable. You'd then:
echo "/where/is/your/file" >.../lun0/file
and voila. Of course, you need the removable=1 passed go g_file as the OP implied.
To "eject" the device, you simply do the following:
echo >.../lun0/file
This last one may fail if the filesystem is still mounted on the host.

Soft-float version of Raspbian does not boot

I downloaded the hard float image of Raspbian here:
http://www.raspberrypi.org/downloads
I copied the recommended hard-float image on an SD card and the Raspberry Pi boots fine with it.
Then I downloaded the soft-float version of Raspbian because I need it to get some software running that does not work on the hard-float version. I formatted the SD card again, copied the soft-float image onto it and tried to boot the Raspberry Pi with it.
Problem: the Raspbery Pi doesn't boot with the soft-float version of Raspbian!! I see the green "ACT" LED light up for less than a second. After that only the red power LED is on and nothing happens after that.
I repeated this process a couple of times and redownloaded the images, checked the SHA of the downloaded file, etc. It just doesn't work. The hard-float image always boots up (green "ACT" light flashes rapidly like normal).
Any ideas?
Update: If you have a newer Raspberry Pi with Hynix memory then the older versions of Raspbian will not boot. Specifically you'll need at least the 2013-02-09 Debian 7 (Wheezy) build.
See this post.
Now, the 2013-02-09 Wheezy build is a hard-float version, so you can't use that, but you can update the kernel image of your soft-float version which is actually independent of the Linux OS (I'm told that basically the GPU boots the Raspberry Pi, and it runs the ARM as a kind of co-processor). So, you can run rpi-update to update your kernel, and it should be all OK.
There's a bit of a catch-22 if you don't own any of the older Raspberry Pis that will boot the older images--how can you update the OS if the only Raspberry Pi you have is a newer one which won't boot? In your case it sounds like you have access to an older one, so you're OK. For those who don't, maybe someone will eventually post an updated soft-float version, but until then perhaps you can try the following. I haven't; it's just a theory, but at this point you don't have much to lose :-)
Burn the latest Wheezy image (2012-02-09) to an extra SD card
Mount this SD card on Windows
Copy all the files except *gz ones which correspond to the Linux filesystem. Basically, all the boot images and configuration files
Mount the SD card containing your soft-float image and overwrite the boot image files
Hopefully have a beer to celebrate?
Previous post:
Yes, I had this same problem. I don't know exactly what is wrong, but the start_elf image won't boot, at least with the recent set of Raspberry Pis. I can't believe Raspbian would release something that broken, so I suspect it works for some Raspberry Pis, but not others. What you need to do is:
Burn the hard-float copy of Wheezy to an SD card. You're going to snatch off the boot image (which works) and copy it to the soft float one.
Mount the SD card on a Windows machine. The boot partition is FAT, so you'll be able to see it. Look for the file start.elf. Copy it to your Windows machine.
Burn the soft-float copy of Wheezy to an SD card and mount it on the Windows box.
Replace it's start.elf with the copy from your hard-float one.
Crack open a beer and enjoy.
See my related post.
Just image one card with hard-float(Raspbian “wheezy”), and the other
with soft-float(Soft-float Debian “wheezy”). Plug both into a Windows PC and
copy all files (you can see at all) from the hard-float onto the
soft-float card, replacing existing ones.
Explanation: http://www.raspberrypi.org/archives/3534
P.S. You can, of course, copy those files to a temporary folder first,
swap cards and then replace all files on the soft-float card with
those in the temporary folder.
bootcode.bin
start.elf
fixup.dat
From Raspberry Pi SD card with this Soft-float Debian "wheezy" did not want to boot
When you dd the image, make sure bs=1M...
After trying all the things in the other answers, it was finally the way to make it work on a latest Raspberry Pi out of the box. I've actually found this a good help with several Raspberry Pi applications/code.

Boot a native OS on a hard disk as a virtual machine

I'm searching for a solution to boot a native OS on a hard disk as a virtual machine.
It's like what VMware Fusion did on a Mac which boots Windows in Boot Camp as a virtual machine.
In detail, I have Windows installed on /dev/sda2 and Ubuntu 11.10 on /dev/sda5.
Is there anyway to use a virtual machine software to boot the Windows on /dev/sda2 as a virtual machine while I'm using Ubuntu?
Yes, I did this long ago following this guide:
https://lists.ubuntu.com/archives/ubuntu-us-nm/2008-February/000521.html
of course, always backup and be careful!
Essentially:
Used a USB 3.5 HD enclosure and connect the XP drive to it.
If the drive was shutdown uncleanly you may need to manually
mount it with the following command.
sudo mount ntfs-3g /dev/whereyourdriveis /mount/somemountpoint -o
force
Once the drive is mounted under linux contiunue to step 2.
Launch VMWare.
Go to File -> New -> New Virtual Machine.
Select "Custom"
Select Next
Select your operating system (i.e. Win XP)
Select Next
Give it a name like "WindowsXP"
Select Next
Specify processor One or Two
Select Next
Choose public or private (on a single-user machine this doesn't
matter)
Select Next
Select the memory to devote to the virtual machine. 512 MB is a
pretty useful number.
Select your network connection
Select Next.
Leave SCSI set to BusLogic
Select Next
Select Use Physical Disk
Select Next
Select Use Entire Drive
Select Next
Specify the place to save the VM
At this point you're done Select Power On to boot the Physical drive
in VMWare!
More Info: I should add, I have successfully done this, but I also had success using this method years even years before. So there are at least two known and tested ways for accomplishing this that I can tell you.
You can do this via VirtualBox raw disk access.
(http://www.virtualbox.org/manual/ch09.html)
It basically creates a "virtual" disk file that points to the actual partition and loads it as a disk drive in the VM. I've installed Linux guest in VB on Windows host in such a way, and the installation can boot from the VM or by itself.
As answered, this also can be done in VirtualBox, this is the way that works for me
Always, make sure that you are running as Administrator(Windows) or Sudo(Linux), any changes that you do will write to the REAL disk, so be carefull
In Windows
C:\Program Files\Oracle\VirtualBox>VBoxManage.exe internalcommands createrawvmdk -filename "E:\virtualbox\linuxhd.vmdk" -rawdisk "\\.\PhysicalDrive1"
RAW host disk access VMDK file E:\virtualbox\linuxhd.vmdk created successfully.
In Linux
$ VBoxManage internalcommands createrawvmdk -filename "~/linuxhd.vmdk" -rawdisk "/dev/sda"
It will create a file with something around 1kb that is a link to the physical hard drive.
Then create a Virtual Machine as ever you do.
If you want to map only a partition
At Windows
\\.\Physicaldrive1 -partitions 1
(Disk start with 0, partitions
with 1)
At Linux (Much more intuitive)
/dev/sda1
/dev/sda2
etc.
Eventually you can get resolution issues
Eventually you can get resolution issues even after install vboxadditions, in my experience the problem is your /etc/X11/xorg.conf it is configured to your specific real hardware specs(I have a offboard GPU for example), least in my case I solve it simply removing this file (xorg auto configure at boot, only will not work if you set some specific setting), so run:
sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.original && sudo rm /etc/X11/xorg.conf
Reference
http://www.virtualbox.org/manual/ch09.html#rawdisk
https://forums.virtualbox.org/viewtopic.php?f=6&t=36694
https://romaimperator.com/?p=29

Resources