I have two services running on a Raspberry Pi CM4 with BalenaOS. One of these services is responsible for running a custom script to initialize the Quectel EC200U modem. After running the initialization script, we need to execute the following two commands to obtain an IP address on the usb0 interface:
# Reload the cdc_ether module:
modprobe -r cdc_ether
modprobe cdc_ether
Currently, we establish an SSH connection to the host OS and run the commands above. After that, if we turn off WiFi, we can see that our device correctly switches to using the cellular network and works as expected:
Is there any way to run these commands to load the cdc_ether module from within a service container? We would like to automate this step and add these two commands to our modem initialization script. However, it seems we don’t have access to the cdc_ether module inside the container, even though our docker-compose.yml file includes the io.balena.features.kernel-modules label.
Here is the relevant part of our docker-compose.yml file:
@embedded Please add this line(network_mode: host) to your docker-compose.yml and then try again. I am not sure but this should have to work. Please let me know if this does not work for you.
Thank you for your suggestion. I’ll give it a try in a few minutes, but I’ve found a different solution:
In my Dockerfile, I run a script to mount a temporary filesystem inside the container with the cdc_ether.ko kernel module file.
#!/bin/sh
set -e # Exit immediately if a command exits with a non-zero status
# Check if the mount-point directory exists
if [ ! -d "/mnt/tmpfs" ]; then
echo "Creating mount point directory..."
mkdir /mnt/tmpfs
else
echo "Mount point directory already exists."
fi
# Check if the mount-point directory exists
echo "Checking if /mnt/tmpfs is mounted..."
if mountpoint -q /mnt/tmpfs; then
echo "/mnt/tmpfs is already mounted."
else
echo "Mounting tmpfs at /mnt/tmpfs..."
mount -t tmpfs -o size=10M tmpfs /mnt/tmpfs
fi
# Copy cdc_ether.ko file to our tmpfs
echo "Copying cdc_ether.ko to /mnt/tmpfs..."
cp /usr/src/app/startup-scripts/cdc_ether.ko /mnt/tmpfs
Then, I run a script to initialize the Quectel EC200U module with a set of AT commands and after that, the script load the kernel module from the tmpfs automatically, and it worked as expected: