Azure-docs: Tutorial: Develop and deploy a Python IoT Edge module to your real RPi device

Created on 16 Nov 2018  Â·  10Comments  Â·  Source: MicrosoftDocs/azure-docs

The title says it all. Is there a tutorial for deploying a custom Python module on a real Raspberry Pi device (arm32)?

I cannot be the first person doing this. If someone else has done this before, I would very much appreciate your help.

Thank you in advance!


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri2 assigned-to-author iot-edgsvc needs-more-info triaged

Most helpful comment

@awoSYS Building arm32v7 images on amd64 machine will cause the error you met. The solution is to build arm32v7 image on an arm32v7 device. Using QEMU could also fix the error, but it hasn't been tested strictly. If you meet further errors, you could try to build the image on your raspberry pi to fix the error.

All 10 comments

@baharw Thanks for the feedback! We are currently investigating and will update you shortly.

@baharw this should be device agnostic. You have other issues opened where you are trying to use Raspberry Pi with a Python Module right? Please let us know if this one can be closed.

Thanks.

@baharw, this sample shows you how to use run a custom python module on raspberry pi: https://github.com/Azure-Samples/Custom-vision-service-iot-edge-raspberry-pi.

Echo to the sample above. It covers all the aspects you want to learn in the readme file.
Let me know if you meet specific issues when developing Python module on Pi.

It's your call if you want to close it, but I don't think this issue is
resolved.

If one follows the instructions step-by-step (using a Linux or Mac OS, as
the dev machine) one does not see the results as described in the tutorial.
What you end up with is build errors or runtime errors on the RPi. The only
way I got around the issue was to build everything from scratch on an RPi.

Here is what I had to do,

Step 1 - Prepare your development environment
https://github.com/Azure/azure-iot-sdk-python/blob/master/doc/python-devbox-setup.md#python-pip-package-distribution-table
on
RPi stretch (arm32)

a) Download and build azure-iot-sdk-c
https://github.com/Azure/azure-iot-sdk-c/blob/master/doc/devbox_setup.md

b) Install the boost library

sudo apt-get install libboost1.62-all-dev

c) Install azure-iot-sdk-python
https://github.com/Azure/azure-iot-sdk-python/blob/master/doc/python-devbox-setup.md#windows-wheels

d) Install docker-ce if not already installed.

Step 2 - Create your custom Python module, using Ubuntu on
a separate machine

a) I followed the step Tutorial: Develop and deploy a Python IoT Edge
module to your simulated device
https://docs.microsoft.com/en-us/azure/iot-edge/tutorial-python-module,
but only up to and including *Create an IoT Edge module project. *

Step 3 - Build your custom Python project

a) Copy the newly created project folder in step 2 a), to the RPi you set
up in step 1.

b) Build the project using the following command in a terminal on the RPi
(I simply cut and paste the command from VS Code)

docker build --rm -f "/home/pi/Azure/ Solution>/modules//Dockerfile.arm32v7" -t
.azurecr.io/ http://azurecr.io/:0.0.1-arm32v7
"/home/pi/Azure//modules/PythonModule"

d) Push the newly created image to docker (I simply cut and paste the
command from VS Code)

docker push .azurecr.io/
http://azurecr.io/:0.0.1-arm32v7

Step 4 - Deploy to a target RPi device - in my case, it was another RPi
running IoT Edge

a) using the Ubuntu machine, on which I created the project, I followed
this Deploy and run the solution
https://docs.microsoft.com/en-us/azure/iot-edge/tutorial-python-module#deploy-and-run-the-solution

That is how I was able to finally get the solution to work.

There is a possibility that I have taken the long route, and that there is
an easier way. If there is, please correct me. I will be very happy.

I just wasted two weeks chasing this problem.

Thank you,
Bahar

On Tue, Nov 20, 2018 at 10:34 PM António Sérgio Azevedo <
[email protected]> wrote:

@baharw https://github.com/baharw this should be device agnostic. You
have other issues opened where you are trying to use Raspberry Pi with a
Python Module right? Please let us know if this one can be closed.

Thanks.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/MicrosoftDocs/azure-docs/issues/19092#issuecomment-440518095,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AE8SHXOP3tnQNV7yXcrtXvI3Go5dh-jUks5uxMmzgaJpZM4Ym5gI
.

@baharw thank you so much for your valuable input and sharing your steps with us. @shizn can we consider the steps described above on our docs andor suggest an alternativefastest route?

  • @ebertrams for suggestions too.

Thanks!

Hi @baharw, for

If one follows the instructions step-by-step (using a Linux or Mac OS, as
the dev machine) one does not see the results as described in the tutorial.
What you end up with is build errors or runtime errors on the RPi. The only
way I got around the issue was to build everything from scratch on an RPi.

Could you share more information or logs regarding the "build errors or runtime errors in the RPi". Thanks.

Since we have not heard back from you we will now proceed to close this thread. If there are further questions regarding this matter, please tag me in your reply. We will gladly continue the discussion and we will reopen the issue.

I was just facing the same issue when following this tutorial and trying to develop for a 32bit Pi (Raspbian stretch). When following the tutorial as described, the module was successfully built and deployed to the Pi. But it failed with the following logs:

standard_init_linux.go:211: exec user process caused "exec format error"

What fixed this for me (developing on my 64bit Ubuntu machine) was:

Hope this helps.

Edit:
This seems to be related to https://github.com/Azure/iotedge/issues/1912

@awoSYS Building arm32v7 images on amd64 machine will cause the error you met. The solution is to build arm32v7 image on an arm32v7 device. Using QEMU could also fix the error, but it hasn't been tested strictly. If you meet further errors, you could try to build the image on your raspberry pi to fix the error.

Was this page helpful?
0 / 5 - 0 ratings