How to install dvu server in Raspberry Pi?
Installing a DVU Server (which I understand refers to the Device Update for IoT Hub service from Microsoft Azure) on a Raspberry Pi is an excellent way to manage over-the-air (OTA) updates for your Pi and other devices.
Here is a comprehensive guide on how to do it.
What is Device Update for IoT Hub (DVU)?
It's a Microsoft Azure service that allows you to deploy firmware, OS, application, and configuration updates to your IoT devices (like Raspberry Pi) connected to Azure IoT Hub. It's designed for reliability and security.
Prerequisites
Before you begin, you must have the following:
A Raspberry Pi (any model 3 or 4 is recommended) running a 64-bit OS (e.g., Raspberry Pi OS Lite (64-bit) or Ubuntu Server 20.04/22.04 LTS (64-bit) for ARM). The Device Update agent is built for 64-bit architecture.
An Azure Account. You will need a subscription (you can use the free tier with credits).
Azure IoT Hub. You must create an IoT Hub instance in your Azure portal.
A Device Identity. Your Raspberry Pi must be registered as a device in your IoT Hub.
Network Connection. The Pi must have internet access.
Step-by-Step Installation Guide
Here’s the process broken down into two main parts:
Setting up Azure Resources (in the cloud)
Installing and Configuring the Agent (on the Raspberry Pi)
Part 1: Setup in Azure Portal
1. Create and Configure an IoT Hub
Log in to the Azure Portal.
Search for and create an IoT Hub service.
Select your subscription, create a new resource group, give it a name, choose a region, and select a pricing tier (S1 Standard is the minimum for Device Update).
2. Create a Device Update Account
In the Azure Portal, search for "Device Update for IoT Hub".
Click Create and link it to the IoT Hub you just created.
3. Register Your Raspberry Pi as a Device
Inside your IoT Hub, navigate to Devices under Explorers.
Click + Add Device.
Give your device a Device ID (e.g.,
my-raspberry-pi
).For authentication, select Symmetric key and check Auto-generate keys.
Click Save. CRITICAL: Copy the Primary Connection String that is generated. You will need this for the agent configuration on the Pi. Store it securely.
Part 2: Setup on the Raspberry Pi
Connect to your Raspberry Pi via SSH. All following commands are run on the Pi's terminal.
ssh pi@raspberrypi.local
1. Prepare the System (64-bit OS)
Ensure your OS is 64-bit. Check with:
uname -m
If it returns aarch64
, you are using a 64-bit OS. If it returns armv7l
, you are on 32-bit and need to install a 64-bit OS.
Update the package list:
sudo apt update && sudo apt upgrade -y
2. Install the Device Update Agent
Microsoft provides packages for Debian/Ubuntu on ARM64.
Configure the Microsoft package repository:
curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc sudo apt-add-repository https://packages.microsoft.com/debian/11/prod sudo apt update
Install the Device Update agent:
sudo apt install deviceupdate-agent
3. Configure the Agent with the Connection String
This is the most important step. You must provide the agent the connection string to connect to your specific IoT Hub.
Open the agent configuration file for editing:
sudo nano /etc/adu/du-config.json
Find the
connectionData
section and replace the entire JSON array["**Replace with IoT Hub Device Connection String**"]
with the connection string you saved from Azure IoT Hub.Example:
{ "connectionData": ["HostName=my-iot-hub.azure-devices.net;DeviceId=my-raspberry-pi;SharedAccessKey=abc123..."] }
Save the file (
Ctrl+O
,Enter
,Ctrl+X
).
4. Start the Device Update Service
Start the service and enable it to run on boot:
sudo systemctl enable deviceupdate-agent sudo systemctl start deviceupdate-agent
Check the status to ensure it's running without errors:
sudo systemctl status deviceupdate-agent
Look for
active (running)
. If you see errors, check the logs withjournalctl -u deviceupdate-agent -f
.
Part 3: Verification and Next Steps
1. Verify in Azure Portal
Go back to your Device Update for IoT Hub instance in the Azure Portal.
Navigate to Devices and groups.
You should see your device (
my-raspberry-pi
) listed. Its state might initially be Ungrouped and then change to Ready, indicating a successful connection.
2. Next Steps: Creating and Deploying an Update
Now that the agent is running, you can use the Device Update service to:
Import an Update: Package your application or OS changes into a valid update manifest and import it into your Device Update account.
Create a Group: Group your devices (e.g., "all-pi-devices-in-berlin").
Deploy an Update: Schedule the imported update to be deployed to a device group. You can monitor the deployment progress from the portal.
Troubleshooting Common Issues
deviceupdate-agent
service fails:Most common cause: An error in the
du-config.json
file (typo in the connection string). Double-check it.Check logs:
journalctl -u deviceupdate-agent -e -f
Device not appearing in Azure Portal:
Ensure the Pi has internet access.
Verify the IoT Hub name and device ID in the connection string are correct.
Architecture error during install:
Confirm you are running a 64-bit OS with
uname -m
.
By following these steps, you have successfully turned your Raspberry Pi into a device managed by Azure IoT Hub, ready to receive secure, reliable updates from the cloud.
评论
发表评论