Modifying (boot) behavior of Host OS


#1

Hello,

For a project we are using Raspberry Pi 3 Model B+ in combination with Balena (Resin OS 2.12.3+rev1) and a Huawei E353 (2G/3G dongle).

What I have noticed is that when I first boot my application and then insert the E353, everything works as expected.
However, if I try to boot with the E353 inserted, the whole process hangs on a line from udevd initialization (timing out after about 3 minutes), after which I have no internet connectivity (does not matter whether ethernet is plugged in or not).

In both cases I see udev correctly identifying the E353, loading it as a USB Mass Storage / CDROM and then switching it over to cdc_ether.

For this one device, I have made some changes to the Host OS through the web terminal.
(remounting root and adding a usb_modeswitch rule to udev for the E353)

After these changes booting with the E353 works perfectly, and my device connects as expected.

My question now is: what is the preferred way to make changes to the Host OS like these manageable?

It seems to me not very desirable to have to manually tweak every device that is being created, not to mention the fact that this might not be the only change we will need in the future.
More manual tweaking = higher chance of making a mistake somewhere down the line.


#4

Hi @TJvV,

We implemented a way for users to add their custom udev rules in the config.json file from the boot partition.

Here is a description of it:

Regards!


#6

Hello @spanceac,
Thank you for the tip, I will definitely try it soon.

At the moment when I want to add a device, I just get an image through the dashboard.
I have not seen any way in this step to add anything custom to it, so this way will still require manual tweaking of each device.

I guess to get all our changes in the image, there are really only two options?

  1. Flash existing image, apply changes and then create a new image from that;
  2. Setup our own yocto build environment.

#8

Hi @TJvV, No the custom udev rules @spanceac mentions can just be added the once to the downloaded image. So you do the following:

  1. download the OS .zip from dashboard
  2. extract the .zip and mount the resin-boot partition ( on macOS this is as simple as double clicking the .img
  3. add the udev rules fields to config.json in the resin-boot partition as described in https://github.com/balena-os/meta-balena#udevrules
  4. You can flash this image to as many devices as you want and all of them will have the udev rules applied.

#10

Hi @TJvV, No the custom udev rules @spanceac mentions can just be added the once to the downloaded image. So you do the following:

download the OS .zip from dashboard

extract the .zip and mount the resin-boot partition ( on macOS this is as simple as double clicking the .img

add the udev rules fields to config.json in the resin-boot partition as described in https://github.com/balena-os/meta-balena#udevrules

You can flash this image to as many devices as you want and all of them will have the udev rules applied.