132 lines
No EOL
4 KiB
Bash
132 lines
No EOL
4 KiB
Bash
#!/bin/bash
|
|
|
|
# Stop bij fout
|
|
set -e
|
|
|
|
# Kleuren voor output
|
|
green="\e[32m"
|
|
red="\e[31m"
|
|
reset="\e[0m"
|
|
|
|
echo -e "${green}GrovePi installatiescript gestart...${reset}"
|
|
|
|
# Update systeem
|
|
echo -e "${green}Systeem bijwerken...${reset}"
|
|
sudo apt update && sudo apt upgrade -y
|
|
|
|
# Benodigde pakketten installeren
|
|
echo -e "${green}Afhankelijkheden installeren...${reset}"
|
|
sudo apt install -y git python3 python3-pip python3-smbus i2c-tools swig raspi-config
|
|
|
|
# Installeren van avrdude
|
|
echo -e "${green}Avrdude installeren...${reset}"
|
|
sudo apt install bison flex byacc -y
|
|
sudo apt remove avrdude* -y
|
|
sudo rm -rf /opt/avrdude-7.0
|
|
cd /opt
|
|
sudo wget http://download.savannah.gnu.org/releases/avrdude/avrdude-7.0.tar.gz
|
|
sudo tar xfv avrdude-7.0.tar.gz
|
|
cd avrdude-7.0/
|
|
sudo ./configure --enable-linuxgpio
|
|
sudo make
|
|
sudo make install
|
|
|
|
# Clonen van de GrovePi repository
|
|
echo -e "${green}Clonen van de custom GrovePi repository...${reset}"
|
|
sudo rm -rf /opt/grovepi
|
|
sudo git clone https://git.pixelhosting.nl/Blackwhitebear8/grovepi.git /opt/grovepi
|
|
cd /opt/grovepi
|
|
|
|
# Installeren van Python-pakketten
|
|
echo -e "${green}Python bibliotheken installeren...${reset}"
|
|
pip3 install --upgrade setuptools --break-system-packages
|
|
pip3 install -r /opt/grovepi/Software/Python/requirements.txt --break-system-packages
|
|
|
|
# Installeren van GrovePi firmware en bibliotheken
|
|
echo -e "${green}GrovePi installeren...${reset}"
|
|
cd /opt/grovepi/Script
|
|
sudo bash install.sh
|
|
|
|
# Installeren en aanpassen van WiringPi
|
|
echo -e "${green}WiringPi installeren...${reset}"
|
|
sudo apt remove wiringpi* -y
|
|
sudo rm -rf /opt/WiringPi
|
|
cd /opt
|
|
sudo git clone https://github.com/WiringPi/WiringPi
|
|
cd WiringPi
|
|
sudo rm wiringPi/wiringPiLegacy.c
|
|
cat > /home/pi/wiringPiLegacy.c <<EOL
|
|
#include <wiringPi.h>
|
|
#include "wiringPiLegacy.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <ctype.h>
|
|
#include <string.h>
|
|
|
|
extern int wiringPiDebug;
|
|
|
|
const char* GetPiRevisionLegacy(char* line, int linelength, unsigned int* revision) {
|
|
// Verwijder de toegang tot /proc/cpuinfo
|
|
// FILE *cpuFd;
|
|
// if ((cpuFd = fopen ("/proc/cpuinfo", "r")) == NULL)
|
|
// piGpioLayoutOops ("Unable to open /proc/cpuinfo");
|
|
|
|
// In plaats van gegevens te lezen uit /proc/cpuinfo, kunnen we de revision
|
|
// altijd als een voorbeeld instellen.
|
|
// Simuleer een revision (bijvoorbeeld als een bekende waarde, zoals 0x900092)
|
|
*revision = 0x900092;
|
|
|
|
if (wiringPiDebug)
|
|
printf("GetPiRevisionLegacy: Simulated Revision: 0x%x\n", *revision);
|
|
|
|
return "Revision Simulated";
|
|
}
|
|
|
|
int piGpioLayoutLegacy(void) {
|
|
// Verwijder de toegang tot /proc/cpuinfo
|
|
// FILE *cpuFd;
|
|
// char line[120];
|
|
// if ((cpuFd = fopen("/proc/cpuinfo", "r")) == NULL)
|
|
// piGpioLayoutOops ("Unable to open /proc/cpuinfo");
|
|
|
|
// In plaats van te controleren op hardware-informatie uit /proc/cpuinfo,
|
|
// kunnen we de layout altijd een bekende waarde geven, bijvoorbeeld 2 (wat
|
|
// overeenkomt met de meeste recente Raspberry Pi-modellen zoals de B+).
|
|
int gpioLayout = 2; // Dit is een standaardwaarde
|
|
|
|
if (wiringPiDebug)
|
|
printf("piGpioLayout: Returning layout: %d\n", gpioLayout);
|
|
|
|
return gpioLayout;
|
|
}
|
|
EOL
|
|
sudo cp /home/pi/wiringPiLegacy.c /opt/WiringPi/wiringPi/
|
|
sudo ./build
|
|
|
|
# Installeren van WiringPi python
|
|
echo -e "${green}WiringPi python installerenn...${reset}"
|
|
sudo rm -rf /opt/WiringPi-Python
|
|
cd /opt
|
|
sudo git clone --recursive https://github.com/WiringPi/WiringPi-Python.git
|
|
cd WiringPi-Python
|
|
sudo rm -rf WiringPi
|
|
sudo cp -r /opt/WiringPi /opt/WiringPi-Python/
|
|
sudo python3 setup.py build
|
|
sudo python3 setup.py install
|
|
|
|
# Installeren i2c-tools
|
|
echo -e "${green}i2c-tools installeren...${reset}"
|
|
cd /opt
|
|
sudo git clone https://github.com/DexterInd/RFR_Tools.git
|
|
cd RFR_Tools/miscellaneous
|
|
sudo apt install python3-periphery
|
|
sudo pip3 install smbus-cffi --break-system-packages
|
|
sudo python3 setup.py build
|
|
sudo python3 setup.py install
|
|
|
|
# Interfaces aanzetten op de raspberry pi
|
|
echo -e "${green}i2c en spi aanzetten...${reset}"
|
|
sudo raspi-config nonint do_i2c 0
|
|
sudo raspi-config nonint do_spi 0
|
|
|
|
echo -e "${green}Installatie voltooid! Herstart je Raspberry Pi.${reset}" |