[LINUX] Cross-compiling for Raspberry Pi Zero on Debian-Try using shared libraries

Overview

Run a C language program compiled on Debain on a Raspberry Pi Zero. I want to create an environment where I can use shared libraries. For the time being, let's use libusb or libjpeg.

Continuing from Starting cross-compilation for Raspberry Pi Zero on Ubuntu, I am trying again with Debian as the host machine (for a reason later).

environment

Host: Debian 10.6.0 <Virtual Box 6.1 <WIndows10 Target: Raspberry Pi Zero WH

procedure

Installing the compiler for ARM

$ sudo apt install crossbuild-essential-armel

Last time tried installing g ++-arm-linux-gnueabi, but it seems to be included in crossbuild-essential-armel So I will install this. After all, gcc is used, so it doesn't make much difference.

Install shared libraries

Add architecture,

$ sudo dpkg --add-architecture armel

Editing sources.list. I will add the repository referenced by apt.

$ sudo nano /etc/apt/sources.list

Add the following at the bottom of sources.list. For armel, also refer to ftp.jp.debian.org.

/etc/apt/sources.list


deb [arch=armel] http://ftp.jp.debian.org/debian buster main

Update and install the library. You can get the library for armel by adding: armel.

$ sudo apt update
$ sudo apt install libusb-dev:armel
$ sudo apt install libjpeg-dev:armel

Maybe if the package is published for Ubuntu armel, I think I can do the same with Ubuntu by adding it to sources.list, but I found that I published the armel package for Ubuntu not.

試しにUbuntuでftp.jp.debian.org/debianを追加してみましたが、「署名されてません」みたいなエラーが出てインストールできませんでした。そりゃそうか。

Is there a way to forcefully install it? (I was able to bring in .deb and install it, but I gave up because the dependency became difficult)

Build

Click here for the program to build this time.

testUsbLib.c


#include <stdio.h>
#include <usb.h>

int main()
{
    printf("call usb_init()\n");
    usb_init();
    printf("OK\n");

    return 0;
}

A useless program that just calls usb_init (). It doesn't clean up usb_init () (did I have to do something ...?).

Build here.

$ arm-linux-gnueabi-gcc -march=armv6 testUsbLib.c -o testUsbLib_armv6 -lusb

Try to make it work

If you can build successfully above, copy the generated testUsbLib_armv6 to a suitable folder on Raspberry Pi Zero,

$ testUsbLib_armv6
call usb_init()
OK

And it works like this. Nothing happens, but ...

Summary

Since libusb has few dependencies, it can be quite good even if you get the .deb file and install it manually, but libjpeg etc. have many dependencies, and I gave up because there were too many steps manually. This method installed it including the dependencies, so it seems to have worked.

By the way, I have confirmed the operation of libtiff in addition to libusb and libjpeg by this method.

Also, if anyone knows if the same method can be used on Ubuntu (whether there is a package for armel published, etc.), please let me know.

Postscript

I wrote the following article.

Recommended Posts

Cross-compiling for Raspberry Pi Zero on Debian-Try using shared libraries
Cross-compile for Raspberry Pi Zero on Debian-Create your own shared library
Beginning cross-compilation for Raspberry Pi Zero on Ubuntu
Access google spreadsheet using python on raspberry pi (for myself)
Try using ArUco on Raspberry Pi
Detect "brightness" using python on Raspberry Pi 3!
Run servomotor on Raspberry Pi 3 using python
Detect temperature using python on Raspberry Pi 3!
Mount Windows shared folder on Raspberry Pi
Initial settings for using GrovePi + starter kit and camera on Raspberry Pi
Detect slide switches using python on Raspberry Pi 3!
Try using a QR code on a Raspberry Pi
Detect magnet switches using python on Raspberry Pi 3!
Sound the buzzer using python on Raspberry Pi 3!
pigpio on Raspberry pi
Cython on Raspberry Pi
Build an OpenCV4 environment on Raspberry Pi using Poetry
Try using the temperature sensor (LM75B) on the Raspberry Pi.
Control brushless motors with GPIOs on Raspberry Pi Zero
Output to "7-segment LED" using python on Raspberry Pi 3!
Install PyCall on Raspberry PI and try using GPIO's library for Python from Ruby
Indoor monitoring using Raspberry Pi
Run AWS IoT Device SDK for Python on Raspberry Pi
Detect "temperature (using A / D converter)" using python on Raspberry Pi 3!
Check! Let's develop Raspberry Pi Zero remotely-Try using Arafruit WebIDE
Introduced pyenv on Raspberry Pi
Construction of Cortex-M development environment for TOPPERS using Raspberry Pi
Use NeoPixel on Raspberry Pi
Install OpenCV4 on Raspberry Pi 3
Install TensorFlow 1.15.0 on Raspberry Pi
Control the motor with a motor driver using python on Raspberry Pi 3!
Weighing instrument using raspberry pi and hx711 (GUI display on Tkinter)
MQTT on Raspberry Pi and Mac
raspberry pi 4 centos7 install on docker
Install ghoto2 on Raspberry Pi (memo)
Raspberry pi initial setting (for myself)
OpenCV installation procedure on Raspberry Pi
Power on / off Raspberry pi on Arduino
Detect switch status on Raspberry Pi 3
Install OpenMedia Vault 5 on Raspberry Pi 4
Using a webcam with Raspberry Pi
L Chika on Raspberry Pi C #
Build wxPython on Ubuntu 20.04 on raspberry pi 4
Detect analog signals with A / D converter using python on Raspberry Pi 3!
Notes for using OpenCV on Windows10 Python 3.8.3.
"Honwaka Notification Lamp" on Raspberry Pi Part 2
USB boot on Raspberry Pi 4 Model B
"Honwaka Notification Lamp" on Raspberry Pi Part 1
Enable UART + serial communication on Raspberry Pi
Make Raspberry Pi speak Japanese using OpenJtalk
Adafruit Python BluefruitLE works on Raspberry Pi.
Accelerate Deep Learning on Raspberry Pi 4 CPU
Try fishing for smelt with Raspberry Pi
Set swap space on Ubuntu on Raspberry Pi
Programming normally with Node-RED programming on Raspberry Pi 3
Use the Grove sensor on the Raspberry Pi
Install 64-bit OS (bate) on Raspberry Pi
Install docker-compose on 64-bit Raspberry Pi OS
"Honwaka Notification Lamp" on Raspberry Pi Part 3
Working with sensors on Mathematica on Raspberry Pi
Build OpenCV-Python environment on Raspberry Pi B +