Skip to content

Commit

Permalink
Get basic gpio working on PB2. FPPOLED working on PB2. FPPD starts up.
Browse files Browse the repository at this point in the history
  • Loading branch information
dkulp committed Dec 6, 2024
1 parent 622e08d commit 269a87c
Show file tree
Hide file tree
Showing 12 changed files with 286 additions and 199 deletions.
92 changes: 31 additions & 61 deletions SD/FPP_Install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,12 @@ then
desktop=false
elif [ -e "/sys/class/leds/beaglebone:green:usr0" ]
then
ARCH=$(uname -m)
if [ "$ARCH" == "aarch64" ]; then
FPPPLATFORM="BeagleBone 64"
else
FPPPLATFORM="BeagleBone Black"
fi
isimage=true
desktop=false
elif [ -f "/etc/armbian-release" ]
Expand Down Expand Up @@ -382,27 +387,15 @@ cd /opt 2> /dev/null || mkdir /opt
export DEBIAN_FRONTEND=noninteractive

case "${OSVER}" in
debian_11 | debian_12 | ubuntu_22.* | ubuntu_24.* | linuxmint_21)
case $FPPPLATFORM in
'BeagleBone Black')
echo "FPP - Skipping non-free for $FPPPLATFORM"
;;
*)
echo "FPP - Enabling non-free repo"
sed -i -e "s/Components: main/Components: main contrib non-free non-free-firmware/" /etc/apt/sources.list.d/debian.sources
#sed -i -e "s/^deb \(.*\)/deb \1 non-free/" /etc/apt/sources.list
#sed -i -e "s/non-free\(.*\)non-free/non-free\1/" /etc/apt/sources.list
;;
esac

debian_12 | ubuntu_24.* | linuxmint_21)

#remove a bunch of packages that aren't neeeded, free's up space
PACKAGE_REMOVE="nginx nginx-full nginx-common python3-numpy python3-opencv python3-pip python3-pkg-resources python3-scipy triggerhappy pocketsphinx-en-us python3-smbus guile-2.2-libs \
python3-werkzeug python3-click python3-colorama python3-decorator python3-dev python3-distro \
python3-flask python3-itsdangerous python3-jinja2 python3-lib2to3 python3-libgpiod python3-markupsafe \
gfortran glib-networking libxmuu1 xauth network-manager dhcpcd5 fake-hwclock ifupdown isc-dhcp-client isc-dhcp-common openresolv iwd"
if [ "$FPPPLATFORM" == "BeagleBone Black" ]; then
PACKAGE_REMOVE="$PACKAGE_REMOVE nodejs bb-node-red-installer mender-client"
if [ "$FPPPLATFORM" == "BeagleBone 64" -o "$FPPPLATFORM" == "BeagleBone Black" ]; then
PACKAGE_REMOVE="$PACKAGE_REMOVE nodejs bb-node-red-installer mender-client bb-code-server nginx nginx-common"
fi
if $desktop; then
#don't remove anything from a desktop
Expand Down Expand Up @@ -499,23 +492,23 @@ case "${OSVER}" in
samba rsync sudo shellinabox dnsmasq hostapd vsftpd ntp sqlite3 at haveged samba samba-common-bin \
mp3info exim4 mailutils dhcp-helper parprouted bridge-utils libiio-utils libfmt9 \
php${PHPVER} php${PHPVER}-cli php${PHPVER}-fpm php${PHPVER}-common php${PHPVER}-curl php-pear \
php${PHPVER}-bcmath php${PHPVER}-sqlite3 php${PHPVER}-zip php${PHPVER}-xml \
php${PHPVER}-bcmath php${PHPVER}-sqlite3 php${PHPVER}-zip php${PHPVER}-xml ccache \
libavcodec-dev libavformat-dev libswresample-dev libswscale-dev libavdevice-dev libavfilter-dev libtag1-dev \
vorbis-tools libgraphicsmagick++1-dev graphicsmagick-libmagick-dev-compat libmicrohttpd-dev \
gettext apt-utils x265 libtheora-dev libvorbis-dev libx265-dev iputils-ping mp3gain \
libmosquitto-dev mosquitto-clients mosquitto libzstd-dev lzma zstd gpiod libgpiod-dev libjsoncpp-dev libcurl4-openssl-dev \
fonts-freefont-ttf flex bison pkg-config libasound2-dev mesa-common-dev qrencode libusb-1.0-0-dev \
flex bison pkg-config libasound2-dev python3-setuptools libssl-dev libtool bsdextrautils iw rsyslog tzdata"

if [ "$FPPPLATFORM" == "Raspberry Pi" -o "$FPPPLATFORM" == "BeagleBone Black" ]; then
if [ "$FPPPLATFORM" == "Raspberry Pi" -o "$FPPPLATFORM" == "BeagleBone Black" -o "$FPPPLATFORM" == "BeagleBone 64" ]; then
PACKAGE_LIST="$PACKAGE_LIST firmware-realtek firmware-atheros firmware-ralink firmware-brcm80211 firmware-iwlwifi firmware-libertas firmware-zd1211 firmware-ti-connectivity zram-tools"
if [ "${OSVER}" == "debian_12" ]; then
PACKAGE_LIST="$PACKAGE_LIST ccache"
if [ "$FPPPLATFORM" == "Raspberry Pi" ]; then
PACKAGE_LIST="$PACKAGE_LIST libva-dev smartmontools"
fi
if [ "$FPPPLATFORM" == "BeagleBone Black" -o "$FPPPLATFORM" == "BeagleBone 64" ]; then
PACKAGE_LIST="$PACKAGE_LIST ti-pru-cgt-v2.3"
fi
else
PACKAGE_LIST="$PACKAGE_LIST ccache"
fi
if [ "$FPPPLATFORM" != "BeagleBone Black" ]; then
PACKAGE_LIST="$PACKAGE_LIST libva-dev smartmontools"
fi
if $isimage; then
Expand Down Expand Up @@ -546,15 +539,7 @@ case "${OSVER}" in
(cd /opt/ && git clone https://github.com/tomba/kmsxx && cd kmsxx && apt-get install -y meson cmake libfmt-dev && meson setup build --prefix=/usr -Dpykms=disabled && ninja -C build install && cd /opt/ && rm -rf kmsxx && apt-get remove -y --purge --autoremove meson cmake libfmt-dev && ccache -C)

if $isimage; then
if [ "${OSVER}" == "debian_12" ]; then
apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install systemd wpasupplicant
elif [ "$FPPPLATFORM" == "BeagleBone Black" ]; then
# Since we rely heavily on systemd-networkd and wpasupplicant for networking features, grab the latest backports
# This cannot work on Raspberry Pi as the Pi Zero and older Pi's are armv6 and bullseye-backports is armv7
apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" -t bullseye-backports install systemd wpasupplicant
else
apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install systemd wpasupplicant
fi
apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" install systemd wpasupplicant
fi
echo "FPP - Cleaning up after installing packages"
apt-get -y clean
Expand Down Expand Up @@ -734,6 +719,11 @@ case "${FPPPLATFORM}" in
systemctl disable unattended-upgrades
systemctl disable resize_filesystem
;;
'BeagleBone 64')
systemctl disable keyboard-setup
systemctl disable unattended-upgrades
systemctl disable resize_filesystem
;;

'Raspberry Pi')
echo "FPP - Updating firmware for Raspberry Pi install"
Expand Down Expand Up @@ -1154,18 +1144,7 @@ sudo sed -i '/user\.\*/s/^/# /' /etc/rsyslog.conf
# Configure ccache
echo "FPP - Configuring ccache"
mkdir -p /root/.ccache
if [ "$FPPPLATFORM" == "Raspberry Pi" -o "$FPPPLATFORM" == "BeagleBone Black" ]; then
# On Beagle/Pi, we'll use a newer ccache to allow developer sharing of the cache
if [ "x${OSVER}" != "xdebian_12" ]; then
cd /opt/fpp/SD
./buildCCACHE.sh
ccache -M 350M
else
ccache -M 500M
fi
else
ccache -M 350M
fi
ccache -M 500M
ccache --set-config=temporary_dir=/tmp
ccache --set-config=sloppiness=pch_defines,time_macros
ccache --set-config=hard_link=true
Expand Down Expand Up @@ -1361,6 +1340,13 @@ sed -i '/^pool.*/d' /etc/ntpsec/ntp.conf
sed -i '$s/$/\npool falconplayer.pool.ntp.org iburst minpoll 8 maxpoll 12 prefer/' /etc/ntpsec/ntp.conf


if [ "x${FPPPLATFORM}" = "xBeagleBone 64" ]; then
#Set colored prompt
sed -i -e "s/#force_color_prompt=yes/force_color_prompt=yes/" /home/fpp/.bashrc
# remove the udev rules that create the SoftAp interface on the bbbw and bbggw
rm -f /etc/udev/rules.d/*SoftAp*

fi
if [ "x${FPPPLATFORM}" = "xBeagleBone Black" ]; then
#######################################
systemctl disable dev-hugepages.mount
Expand All @@ -1379,10 +1365,7 @@ if [ "x${FPPPLATFORM}" = "xBeagleBone Black" ]; then
make -j ${CPUS}
make install
make clean

# install the newer pru code generator
apt-get install ti-pru-cgt-v2.3


#Set colored prompt
sed -i -e "s/#force_color_prompt=yes/force_color_prompt=yes/" /home/fpp/.bashrc

Expand Down Expand Up @@ -1483,20 +1466,7 @@ make clean ; make -j ${CPUS} optimized


######################################
if [ "$FPPPLATFORM" == "Raspberry Pi" -o "$FPPPLATFORM" == "BeagleBone Black" ]; then
if [ "x${OSVER}" != "xdebian_12" ]; then
if [ "$FPPPLATFORM" == "Raspberry Pi" ]; then
echo "FPP - Install kernel headers so modules can be compiled later"
apt-get -y install raspberrypi-kernel-headers
apt-get clean
fi

echo "FPP - Compiling WIFI drivers"
cd /opt/fpp/SD
bash ./FPP-Wifi-Drivers.sh
rm -f /etc/modprobe.d/rtl8723bu-blacklist.conf
fi

if [ "$FPPPLATFORM" == "Raspberry Pi" -o "$FPPPLATFORM" == "BeagleBone Black" -o "$FPPPLATFORM" == "BeagleBone 64" ]; then
# replace entry already there
sed -i 's/^DAEMON_CONF.*/DAEMON_CONF="\/etc\/hostapd\/hostapd.conf"/g' /etc/default/hostapd
if ! grep -q etc/hostapd/hostapd.conf "/etc/default/hostapd"; then
Expand Down
12 changes: 8 additions & 4 deletions src/MultiSync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,11 @@ int MultiSync::Init(void) {
RemoveInterface(name);
} else if (i == NetworkMonitor::NetEventType::NEW_ADDR && up) {
bool changed = FillInInterfaces();
setupMulticastReceive(true);
if (changed) {
FillLocalSystemInfo();
Ping(0, false);
}
setupMulticastReceive();
}
};
NetworkMonitor::INSTANCE.registerCallback(f);
Expand Down Expand Up @@ -1094,6 +1094,7 @@ void MultiSync::Ping(int discover, bool broadcast) {
LogErr(VB_SYNC, "ERROR: Tried to send ping packet but control socket is not open.\n");
return;
}
setupMulticastReceive(discover ? true : false);

// update the range for local systems so it's accurate
const std::vector<std::pair<uint32_t, uint32_t>>& ranges = GetOutputRanges(true);
Expand Down Expand Up @@ -2059,7 +2060,7 @@ int MultiSync::OpenReceiveSocket(void) {
rcvMsgs[i].msg_hdr.msg_controllen = 0x100;
}

setupMulticastReceive();
setupMulticastReceive(false);
return 1;
}
bool MultiSync::isSupportedForMultisync(const char* address, const char* intface) {
Expand All @@ -2073,7 +2074,7 @@ bool MultiSync::isSupportedForMultisync(const char* address, const char* intface
return true;
}

void MultiSync::setupMulticastReceive() {
void MultiSync::setupMulticastReceive(bool cycle) {
LogDebug(VB_SYNC, "setupMulticastReceive()\n");
// loop through all the interfaces and subscribe to the group
std::unique_lock<std::mutex> lock(m_socketLock);
Expand All @@ -2084,9 +2085,12 @@ void MultiSync::setupMulticastReceive() {
mreq.imr_multiaddr.s_addr = inet_addr(MULTISYNC_MULTICAST_ADDRESS);
mreq.imr_interface.s_addr = a.second.address;
int rc = 0;
if (cycle) {
setsockopt(m_receiveSock, IPPROTO_IP, IP_DROP_MEMBERSHIP, &mreq, sizeof(mreq));
}
if ((rc = setsockopt(m_receiveSock, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq))) < 0) {
if (m_broadcastSock < 0) {
// first time through, log as warning, otherise error is likely due t already being subscribed
// first time through, log as warning, otherwise error is likely due to already being subscribed
LogWarn(VB_SYNC, " Could not setup Multicast Group for interface %s rc: %d\n", a.second.interfaceName.c_str(), rc);
} else {
LogDebug(VB_SYNC, " Could not setup Multicast Group for interface %s rc: %d\n", a.second.interfaceName.c_str(), rc);
Expand Down
2 changes: 1 addition & 1 deletion src/MultiSync.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ class MultiSync {
private:
bool isSupportedForMultisync(const char* address, const char* intface);

void setupMulticastReceive();
void setupMulticastReceive(bool cycle);
void PingSingleRemote(MultiSyncSystem& sys, int discover = 0);
void PingSingleRemoteViaHTTP(const std::string& address);
int CreatePingPacket(MultiSyncSystem& sys, char* outBuf, int discover);
Expand Down
3 changes: 1 addition & 2 deletions src/oled/FPPOLEDUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ FPPOLEDUtils::InputAction* FPPOLEDUtils::configureGPIOPin(const std::string& pin
gpiodChips[pin.gpioIdx] = gpiod_chip_open_by_number(pin.gpioIdx);
}
action->gpiodLine = gpiod_chip_get_line(gpiodChips[pin.gpioIdx], pin.gpio);

struct gpiod_line_request_config lineConfig;
lineConfig.consumer = "FPPOLED";
lineConfig.request_type = GPIOD_LINE_REQUEST_DIRECTION_INPUT;
Expand Down Expand Up @@ -340,7 +339,7 @@ bool FPPOLEDUtils::parseInputActions(const std::string& file) {
lineConfig.request_type = GPIOD_LINE_REQUEST_DIRECTION_INPUT;
lineConfig.flags = 0;
if (gpiod_line_request(action->gpiodLine, &lineConfig, 0) == -1) {
printf("Could not config line as input\n");
printf("Could not config line as input. idx: %d pin: %d\n", pin.gpioIdx, pin.gpio);
}
gpiod_line_release(action->gpiodLine);
if (edge == "falling") {
Expand Down
6 changes: 3 additions & 3 deletions src/oled/SSD1306DisplayDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include "SSD1306_OLED.h"

extern I2C_DeviceT I2C_DEV_2;
#if defined(PLATFORM_BBB)
#if defined(PLATFORM_BBB) || defined(PLATFORM_BB64)
#include "util/BBBUtils.h"
#define I2C_DEV_PATH I2C_DEV2_PATH
#elif defined(PLATFORM_PI)
Expand Down Expand Up @@ -45,8 +45,8 @@ bool SSD1306DisplayDriver::initialize(int& i2cBus) {
}
if (ledType && display_Init_seq()) {
#ifdef PLATFORM_BBB
//was not able to configure the led on I2C2, lets see if
//it's available on I2C1
// was not able to configure the led on I2C2, lets see if
// it's available on I2C1
Close_device(I2C_DEV_2.fd_i2c);
if (getBeagleBoneType() == BeagleBoneType::PocketBeagle) {
PinCapabilities::getPinByName("P2-09").configPin("i2c");
Expand Down
2 changes: 1 addition & 1 deletion src/oled/fppoled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "common.h"
#include "settings.h"

#if defined(PLATFORM_BBB)
#if defined(PLATFORM_BBB) || defined(PLATFORM_BB64)
#include "util/BBBUtils.h"
#define PLAT_GPIO_CLASS BBBPinProvider
#elif defined(PLATFORM_PI)
Expand Down
4 changes: 4 additions & 0 deletions src/sensors/IIOSensorSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ IIOSensorSource::~IIOSensorSource() {
delete[] readBuffer;
}
}
bool IIOSensorSource::isOK() const {
return FileExists("/dev/iio:device0");
}

void IIOSensorSource::Init(std::map<int, std::function<bool(int)>>& callbacks) {
if (usingBuffers) {
if (iioDevFile >= 0) {
Expand Down
2 changes: 2 additions & 0 deletions src/sensors/IIOSensorSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ class IIOSensorSource : public SensorSource {
virtual void enable(int id) override;
virtual int32_t getValue(int id) override;

virtual bool isOK() const;

private:
void update(bool forceInstant, bool fromSelect);
std::vector<int32_t> values;
Expand Down
27 changes: 17 additions & 10 deletions src/sensors/Sensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,18 +381,19 @@ void Sensors::addSensorSources(Json::Value& config) {
for (int x = 0; x < config.size(); x++) {
Json::Value v = config[x];
std::string type = v["type"].asString();
SensorSource* ss = nullptr;
if (type == "ads7828" || type == "ads7830") {
sensorSources.push_back(new ADS7828Sensor(v));
ss = new ADS7828Sensor(v);
} else if (type == "iio") {
sensorSources.push_back(new IIOSensorSource(v));
ss = new IIOSensorSource(v);
} else if (type == "mux") {
MuxSensorSource* m = new MuxSensorSource(v);
if (m->isOK()) {
sensorSources.push_back(m);
} else {
WarningHolder::AddWarning("Could not create MuxSensorSource: " + m->getID());
delete m;
}
ss = new MuxSensorSource(v);
}
if (ss && ss->isOK()) {
sensorSources.push_back(ss);
} else if (ss) {
WarningHolder::AddWarning("Could not create SensorSource: " + ss->getID());
delete ss;
}
}
}
Expand All @@ -413,7 +414,13 @@ SensorSource* Sensors::getSensorSource(const std::string& name) {
v["type"] = "iio";
v["id"] = "iio";
SensorSource* ss = new IIOSensorSource(v);
sensorSources.push_back(ss);
if (ss->isOK()) {
sensorSources.push_back(ss);
} else {
WarningHolder::AddWarning("Could not create SensorSource: " + ss->getID());
delete ss;
ss = nullptr;
}
return ss;
}
return nullptr;
Expand Down
Loading

0 comments on commit 269a87c

Please sign in to comment.