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
add guide on how to emulate Olimex image #15
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Emulating the Olimex Board | ||
|
||
This guide shows how to emulate the Olimex Linux image on your Intel based PC. | ||
It is based [on this forum entry](https://www.olimex.com/forum/index.php?topic=2239.0). | ||
|
||
Basically, we use the `qemu-user-static` emulator to emulate ARM binaries on our native kernel, and use `systemd-nspawn` to execute the image like a container. | ||
|
||
## Prerequisites | ||
|
||
On Debian systems, install the following tools: | ||
|
||
``` | ||
apt install qemu-user-static systemd-container | ||
``` | ||
|
||
On Fedora, use these: | ||
|
||
``` | ||
dnf install qemu-user-static systemd-container | ||
``` | ||
|
||
## Running the system | ||
|
||
You need to have the [A20 Debian image](http://images.olimex.com/release/a20/) extracted somewhere in your filesystem. | ||
This means you either extracted it from the image file, you mounted the image file, or you have already written it onto a microSD card and mounted that on your system. | ||
As an example, we have extracted the whole image into `/tmp/olimex`. | ||
|
||
All that's left is to execute the following command as root: | ||
|
||
``` | ||
systemd-nspawn --bind=/dev/ttyACM0 -b -D /tmp/olimex | ||
``` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can't bind the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's only necessary if you want to bind it. However, opensesame seems to be a bit useless without it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Everything except of the air-quality sensors works without it (the other devices/sensors use i2c). |
||
|
||
Explanations of the parameters: | ||
- `--bind=/dev/ttyACM0` exposes your host system serial device `/dev/ttyACM0` into the chrooted A20 environment. | ||
This serial device is used in opensesame to read the sensor data. | ||
|
||
- `-b` advices systemd to act like it's booting the image, so it will run the `init` exectuable of the chrooted environment. | ||
|
||
- `-D` specifies the root directory of the A20 image. | ||
Alternatively, you can use `-i` to specify the image directly, so you don't need to extract the contents of it. | ||
|
||
Use the credentials of the image (default root/olimex) to login and work on the system. | ||
|
||
If you need network connectivity, you need to configure DNS lookup with the following command: | ||
|
||
``` | ||
echo 'nameserver 8.8.8.8' > /run/resolvconf/resolv.conf | ||
``` | ||
|
||
You need to do this every time you start the container, as anything under `/run` does not get persisted. | ||
|
||
If you want to connect into this container via SSH, you need to modify the port in `/etc/sshd/sshd_config` to another port, as port 22 is most likely already used by your host system. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you could include some basic information on, how to mount from an Image. For example, extracting the offset of the partition which should be mounted (``fdisk -l .img) and how to setup the loop-device (losetup -o -f .img).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I can't because I don't know. But feel free to add suggestions via the comments on how you set up that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First you need to get the offset of the
olimex.img
for that you need to executefdisk -l olimex.img
, now you need to get the starting sector of the image partition, you like to mount. Now you have to multiple the starting sector with the sector-size and this results in the offset. In the next step you have to setup the loop-device withlosetup -o <offset> -f olimex.img
. You can list all you loop-devices withlosetup -l
, to see on which loop-device your image is connected. The last step is to mount the loop-device withmount /dev/loop0 <mount-dir>
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fel115 probably easier if you directly write it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fel115 systemd-nspawn also has a way of directly working on the image with the --image parameter. Maybe this is easier? You can then use --overlay for persisting the changes and keeping the image read-only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With my image it doesn't worked. I get this error message
No suitable root partition found in image 'A20-OLinuXino-bullseye-minimal-20220928-143706.img'.
. It think that's because the image doesn't contain a MBR- or GUID-table.