Which Raspberry Pis are compatible out of the box? - raspberry-pi

First, I googled for this question but found no valid answers (may have been inefficient at this though).
I am working with a mix of Raspberry Pis: Raspberry Pi 1B, 2 B+, 3, Zero. I know that those have different chipsets / architectures etc, but it seems that plugging an SD card created for one Rasberry on a Raspberry of a different model works (I created my SD cards for the 2B+, and plugged them also into other models). I use Raspbian, and I run some code that relies on quite a lot of Python packages (numpy, scipy, etc).
My question is:
Why would this work at all despite different hardware? Where is the hardware taken into account when doing a sudo apt-get install? Are there some parts of a sudo apt-get that depend on the RPi model?
As it seems to be working fine, am I at a risk if I switch cards between different RPi models that the program executes, but that its output is somehow 'wrong'?

Some debian/unix packages need to be compiled against specific CPU architectures. Python source code, for the most part, is transferrable because you are not compiling it onto a specific architecture like you would for C/C++
Regarding the SD cards, I wouldn't trust moving them to different models. There are different Linux kernel requirements at least between Pi-1 and the later models.
Although, I see there is only one link to download Rasbian image, the other OS's specifically say "image for Raspberry Pi 2 and 3"

Related

Trying to run Raspberry-Pi image under QEMU, but VM memory is limited to 256MB

I want to build a time consuming package (mediapipe) on my Raspberry-Pi buster image under QEMU. So far, I've gotten the image to load and run (including with network connectivity); however, I'm limited to 256MB of storage, which just isn't enough to do much - especially build a mediapipe. Can someone explain why Raspbian images running under QEMU seem to be limited to 256MB?
I've seen some posts about people running with 512MB and even one with 1GB, but they don't seem to be very successful. Can anyone explain the reason for the restriction, and a potential fix?
The problem here is that a lot of people claim to be running "raspberry pi emulation in QEMU" when they're actually just running Raspbian userspace on top of a kernel for a different machine emulation. So it's easy to be confused if you look at several different tutorials that are really describing entirely different emulation setups. Look for what machine type they pass QEMU.
The "versatilepb" machine type gets used in a lot of tutorials, especially older ones, because it has been in QEMU a long time and it is possible to get it to work with the 1176 CPU that the classic Raspberry Pi boards used. This specific machine has a 256MB maximum memory size, because the real hardware it's emulating has that restriction (it's imposed by the way the physical memory address space is designed). This machine type will never be able to support more RAM, so if you need more then you should ignore any tutorial or setup that uses it.
More recent versions of QEMU really do emulate the actual raspberry pi hardware; these are the raspi0, raspi1ap, raspi2b, raspi3ap, raspi3b machine types. These will have the same amount of RAM as the real raspi hardware they're emulating (either 512MB or 1GB). The downside of these board models is that some of the device emulation is lacking features -- so older QEMU will often not correctly boot a newer kernel, and sometimes devices you would like to use are not present. Also, because the raspi boards hang their ethernet device off the USB controller, the only way to get ethernet on these QEMU models would also be to use a USB ethernet device, eg with:
-device usb-net,netdev=eth0 -netdev user,id=eth0
This probably needs a recent QEMU version to get a working USB controller.
I don't know if there are any tutorials/recipes for running Raspbian on top of the QEMU "virt" board. If there are, this would probably be the best experience, because the virt board permits lots of memory, PCI devices, virtio devices, and is well maintained.

How to cross-build a debian package for Raspberry Pi OS 64 bit

I have a working debian package that I'd like to backport to the current version of Raspberry Pi OS 64 bit (not 32-bit Raspbian).
Confusingly, while Debian itself seems to be robust about enabling cross-builds in their own package, there seems to be much less official documentation about how raspberry Pi OS (64 bit) packages are built¹.
Since I'm relatively certain this should be possible, I ask:
How to take a debian .dsc / debian rules, and build, on an x86_64, a 64 bit Raspberry Pi OS 64-bit compatible image
without using QEMU to actually build the image on arm64, without access to an actual RPi,
using an existing debian package that is known to work on sid on aarch64, and should be backportable,
making sure it's actually built against the correct set of Raspbian dependencies.
I'm guess this is a rather standard thing, I just don't know how to do it. I'm happy with using containers and similar technology, as I can easily integrate that with CI.
I do not plan to use an Arm64 VM, as the software in question takes about an hour to build and test, on an x86_64 server, natively.
¹I've talked to plugwash of Raspbian fame, and as earlier versions of this question showed: there's significant confusion about the heredity of Raspbian OS 64 bit: It's not Raspbian nor based on it. But people including Wikipedia and the RPi Foundation themselves conflate Raspberry Pi OS and Raspbian ("Raspberry Pi OS, formerly Raspbian"), which is 32 bit only.
RaspberryPi documentation here has explained how to build the x64 kernel from the source. What you want is in a way exactly like that.
Notice this line on the Kernel building page:
sudo apt install crossbuild-essential-arm64
This command on your Linux host machine installs a compiler that runs on an AMD64 machine but produces a binary that runs on an ARM machine.
And this line tells the compiler to actually build the source for that architecture:
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image modules dtbs
Image modules dtbs are specific to your project. they may differ.
As for your Debian package, there is no way that you can transform an AMD64 package into an ARM one. Your package for the RaspberryPi if doesn't exist in an official or some third-party repository, must be built from the source.
Find the source code of your package and build it very similarly to RaspberryOS.
If your Package has dependencies it gets a little more complicated. First, install the dependency on your RaspberryPi. Then you should set up a sysroot on your host machine which is basically a mirror image of the preinstalled packages on RaspberryPi. Then for compiling your package you should give the sysroot address to cross compiler so that it can find dependencies.
There is another way too, you can put the source code of your package on your RaspberryPi and build it locally which can take a very long time based on the source code. Just to have a sense, Qt source code without WebEngine module took 48h for me. But Qt is big.
In conclusion, if your package binary is not on any repository you must compile it from the source.
Cross-compilation of different projects and executables are very similar to each other. To have a clear understanding of the process it can be beneficial to look for some other projects that were ported to RaspberryPi OS. Things like Qt, TagLib for android, and ...
First, I would take a look here:
https://github.com/Truelite/qt5custom for inspiration. I checked and those scritps work. However, you might have problems going completely „qemuless”; e.g. in case of QT some libraries needed to be added to host machine sysroot and qemu was simply the easiest way to add them properly: it seems to me that multiarch Debian has some deficiencies in the field of cross-compilation and the simplest way to overcome them is to pretend it’s the native one.

How do I make a raspberry pi raspbian application?

I am struggling on how to make a Raspberry Pi app for Raspbian (On a raspberry pi). I have searched and searched for hours but I still can't find out how to make one. There are apps that I can use but I cannot install them. Should I use python??... Please help me!!...
I found a few visual editors like XOJO, I am knew to "RASPBERRY PI" stuff.
It's just a bare machine you can cover it with anything you want. It's basically Lightweight Linux distro which we install mostly on the PI. Can support wide range of applications but IOT related products are more often developed using PI. If this is the case you can start here using android also.
https://developer.android.com/things/hardware/raspberrypi

Open MPI stuck on an older version

I'm building a Raspberry Pi cluster and am using Open MPI to do some parallel processing... I was able to get it up and running with my Raspberry Pi 3 and a few Pi 1s, but when I tried to add another Pi 3 I started getting some errors (Error: unknown option "--hnp-topo-sig")
It's possible that the problem is because the versions of mpi between both my pis are different - my first pi 3 has version 2.0.2 while the other has 1.6.5, which is odd considering I only installed it on that pi today and on the first pi about a week ago.
I've tried sudo apt-get update and upgrade, but my pi keeps telling me that everything is up to date, even though it doesn't seem like it is. So my question is this - how can I update my open mpi to a newer version so I can run my files? Thanks in advance!
As Gilles noted, Open MPI requires the version to be identical on all machines.
If your Linux distro is telling you that the packaged version of Open MPI is up to date, then you probably have different versions of Linux distros on your different RPi units.
You might want to try:
Installing the same exact Linux distro/version on all your RPi units, and/or
Downloading the latest Open MPI source code tarball from www.open-mpi.org and building/installing Open MPI from source on all your RPi units. That will definitely work, but be aware that Open MPI is a large software package -- compiling it on an RPi will take quite a while.

rpi v/s carambola --- rootfile system size

I am using following distribution for raspberry pi.
http://www.raspberrypi.org/downloads
http://downloads.raspberrypi.org/images/raspbian/2013-02-09-wheezy-raspbian/2013-02-09-wheezy-raspbian.zip
FOR rpi It is recommended to use >2GB card.
Also when i install it on my memory card size of root file system is about 1.4GB.
But dont you think it is too much size just for an root filesystem in EMBEDDED SYSTEM.
Is it possible for RPI to make a linux distribution with root file system with small size ?
Because most of the embedded system do not have this much memory.
like carambola have 8mb Flash & 32 MB RAM.
http://8devices.com/carambola
In this case carambola root filesystem (OPEN wrt) will fit in 8MB flash. How is it possible ?
Raspbian is a full on general purpose operating system, with the ability to run X windows, create a development environment, watch movies, play games, etc.
It also includes support for a great many devices you might want to connect via USB, such as networking devices, webcams, keyboards, mice, etc.
Many embedded systems are purpose built, with no options for adding/removing devices, nor options for running arbitrary programs. OpenWRT is a routing platform running on typical router hardware, and as such, can be MUCH smaller.
You could check out Buildroot for this, which also has been the base of OpenWrt (OpenWrt used for creating the rootfs for the linked Carambola). Buildroot also has support for raspberry pi, so you can easily create a pretty small rootfs with just a few of installed packages.