Skip to content

Commit

Permalink
Add support for Pi touchscreen display
Browse files Browse the repository at this point in the history
- Add support for Pi touchscreen display
- Fix support for wext legacy wifi kernel modules
- Outsource driver loading to udev
- Always load kernel modules on Berryboot start (except during installation)
- Support distributions that have /lib symlinked to /usr/lib
  • Loading branch information
maxnet committed Sep 16, 2015
1 parent f4a5ebb commit c15db5c
Show file tree
Hide file tree
Showing 12 changed files with 139 additions and 35 deletions.
10 changes: 10 additions & 0 deletions BerrybootGUI2.0/adddialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,16 @@ void AddDialog::selfUpdate(const QString &updateurl, const QString &sha1)
qpd.setLabelText(tr("Extracting updated shared.tgz"));
QApplication::processEvents();

/* Normalize shared after workarounds for Arch/Fedora */
if (QFile::exists("/mnt/shared/usr/lib/modules"))
{
if (system("mv /mnt/shared/usr/lib /mnt/shared/lib") != 0 || system("mv /mnt/shared/usr/sbin /mnt/shared/sbin") != 0)
{
}
QDir dir;
dir.remove("/mnt/shared/usr");
}

/* Shared.tgz has changed. Extract it to /mnt */
if (system("/bin/gzip -dc /boot/shared.tgz | /bin/tar x -C /mnt/shared") != 0)
{
Expand Down
16 changes: 16 additions & 0 deletions BerrybootGUI2.0/bootmenudialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <QTime>
#include <QDebug>
#include <QCloseEvent>
#include <QScreen>

#define runonce_file "/mnt/data/runonce"
#define default_file "/mnt/data/default"
Expand All @@ -57,6 +58,19 @@ BootMenuDialog::BootMenuDialog(Installer *i, QWidget *parent) :
_countdown(11)
{
ui->setupUi(this);

#ifdef Q_WS_QWS
/* Make items twice as large if using the touch screen */
QScreen *scr = QScreen::instance();
if (scr->height() == 480)
{
QFont font = ui->list->font();
font.setPointSize(24);
ui->list->setFont(font);
resize(600, height());
}
#endif

setEnabled(false);
QTimer::singleShot(1, this, SLOT(initialize()));
}
Expand Down Expand Up @@ -176,6 +190,8 @@ void BootMenuDialog::initialize()
return;
}
}
if (QFile::exists("/sbin/udevd"))
_i->loadDrivers();
initializeA10();

if (QFile::exists(runonce_file))
Expand Down
70 changes: 48 additions & 22 deletions BerrybootGUI2.0/installer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,15 @@ void Installer::prepareDrivers()
// show error?
}
}
else if (QFile::exists("/mnt/shared/usr/lib/modules"))
{
/* Use shared modules from disk */
if (symlink("/mnt/shared/usr/lib/modules", "/lib/modules")
|| symlink("/mnt/shared/usr/lib/firmware", "/lib/firmware"))
{
// show error?
}
}
else
{
/* Not yet installed, uncompress shared.tgz from boot partition into ramfs */
Expand All @@ -557,28 +566,44 @@ void Installer::loadDrivers()
{
prepareDrivers();

/* Tell the kernel to contact our /sbin/hotplug helper script,
if a module wants firmware to be loaded */
QFile f("/proc/sys/kernel/hotplug");
f.open(f.WriteOnly);
f.write("/sbin/hotplug\n");
f.close();

/* Load drivers for USB devices found */
QString dirname = "/sys/bus/usb/devices";
QDir dir(dirname);
QStringList list = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);

foreach (QString dev, list)
if (QFile::exists("/sbin/udevd"))
{
QString modalias_file = dirname+"/"+dev+"/modalias";
if (QFile::exists(modalias_file))
if (QProcess::execute("pidof udevd") != 0)
{
f.setFileName(modalias_file);
f.open(f.ReadOnly);
QString module = f.readAll().trimmed();
QFile f("/proc/sys/kernel/hotplug");
f.open(f.WriteOnly);
f.write("\0\0\0\0");
f.close();
QProcess::execute("/sbin/modprobe "+module);

QProcess::execute("/sbin/udevd --daemon");
QProcess::execute("/sbin/udevadm trigger");
}
}
else
{
/* Tell the kernel to contact our /sbin/hotplug helper script,
if a module wants firmware to be loaded */
QFile f("/proc/sys/kernel/hotplug");
f.open(f.WriteOnly);
f.write("/sbin/hotplug\n");
f.close();

/* Load drivers for USB devices found */
QString dirname = "/sys/bus/usb/devices";
QDir dir(dirname);
QStringList list = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);

foreach (QString dev, list)
{
QString modalias_file = dirname+"/"+dev+"/modalias";
if (QFile::exists(modalias_file))
{
f.setFileName(modalias_file);
f.open(f.ReadOnly);
QString module = f.readAll().trimmed();
f.close();
QProcess::execute("/sbin/modprobe "+module);
}
}
}
}
Expand Down Expand Up @@ -630,15 +655,15 @@ void Installer::loadFilesystemModule(const QByteArray &fs)
void Installer::startWifi()
{
loadDrivers();
/* Wait up to 2 seconds for wifi device to appear */
/* Wait up to 4 seconds for wifi device to appear */
QTime t;
t.start();
while (t.elapsed() < 2000 && !QFile::exists("/sys/class/net/wlan0") )
while (t.elapsed() < 4000 && !QFile::exists("/sys/class/net/wlan0") )
{
QApplication::processEvents(QEventLoop::WaitForMoreEvents, 250);
}

QProcess::execute("/usr/sbin/wpa_supplicant -iwlan0 -c/boot/wpa_supplicant.conf -B");
QProcess::execute("/usr/sbin/wpa_supplicant -Dnl80211,wext -iwlan0 -c/boot/wpa_supplicant.conf -B");

QProcess *p = new QProcess(this);
connect(p, SIGNAL(finished(int)), this, SLOT(wifiStarted(int)));
Expand All @@ -658,6 +683,7 @@ void Installer::wifiStarted(int rc)
}

sender()->deleteLater();
emit networkInterfaceUp();
}

void Installer::enableCEC()
Expand Down
4 changes: 2 additions & 2 deletions BerrybootGUI2.0/installer.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <QMap>
#include <QFile>

#define BERRYBOOT_VERSION "v2.5"
#define BERRYBOOT_VERSION "v2.6"
#define SIZE_BOOT_PART /* 63 */ 127

class QSettings;
Expand All @@ -60,7 +60,6 @@ class Installer : public QObject
void loadCryptoModules();
void loadSoundModule(const QByteArray &channel);
void loadFilesystemModule(const QByteArray &fs);
void startWifi();

void setKeyboardLayout(const QString &layout);
void setTimezone(const QString &tz);
Expand Down Expand Up @@ -99,6 +98,7 @@ class Installer : public QObject

public slots:
void startNetworking();
void startWifi();

protected:
QString _keyboardlayout, _timezone;
Expand Down
3 changes: 3 additions & 0 deletions BerrybootGUI2.0/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ int main(int argc, char *argv[])
else
f.write("on display.\nIf you want a headless installation instead, append the option 'vncinstall' to cmdline.txt + uEnv.txt\n");
f.close();

QByteArray sconsolecmd = "/sbin/getty -L "+serialdev.replace("/dev/", "").toLatin1()+" 0 vt100 &";
if (system(sconsolecmd.data()) != 0) { qDebug() << "Error starting emergency holographic shell on serial"; }
}
#endif
LocaleDialog ld(&i);
Expand Down
8 changes: 4 additions & 4 deletions BerrybootGUI2.0/wifidialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ WifiDialog::WifiDialog(Installer *i, QWidget *parent) :
QApplication::processEvents();
i->loadDrivers();

/* Wait up to 2 seconds for wifi device to appear */
/* Wait up to 4 seconds for wifi device to appear */
QTime t;
t.start();
while (t.elapsed() < 2000 && !QFile::exists("/sys/class/net/wlan0") )
while (t.elapsed() < 4000 && !QFile::exists("/sys/class/net/wlan0") )
{
QApplication::processEvents(QEventLoop::WaitForMoreEvents, 250);
}
Expand All @@ -73,7 +73,7 @@ WifiDialog::WifiDialog(Installer *i, QWidget *parent) :
{
qpd.setLabelText(tr("Starting wpa_supplicant..."));
QApplication::processEvents();
QProcess::execute("/usr/sbin/wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf -B");
QProcess::execute("/usr/sbin/wpa_supplicant -Dnl80211,wext -iwlan0 -c/etc/wpa_supplicant.conf -B");
QProcess::execute("/usr/sbin/wpa_cli scan");
_timer.start(1500);
ui->passEdit->setFocus();
Expand Down Expand Up @@ -177,7 +177,7 @@ void WifiDialog::accept()
"}\n"
);
f.close();
QProcess::execute("/usr/sbin/wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf -B");
QProcess::execute("/usr/sbin/wpa_supplicant -Dnl80211,wext -iwlan0 -c/etc/wpa_supplicant.conf -B");

/* Ugly workaround: sleep a second to give slow wifi devices some time. */
QTime sleepUntil = QTime::currentTime().addSecs(1);
Expand Down
44 changes: 39 additions & 5 deletions buildroot-2015.02/package/berrybootgui2/init
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,29 @@ if grep -q debugconsole /proc/cmdline; then
/sbin/getty -L tty2 0 vt100 &
fi

# Sunxi
if grep -q "mmc0_led" /proc/cmdline; then
if [ -e /sys/class/leds/ph20:green:led1 ]; then
echo mmc0 > /sys/class/leds/ph20:green:led1/trigger
fi
fi

# iMX.6
if [ -e /sys/class/graphics/fb0/free_scale ]; then
sleep 2
echo -n 1080p > /sys/class/display/mode
echo 0 > /sys/class/ppmgr/ppscaler
echo 0 > /sys/class/graphics/fb0/free_scale
echo 1 > /sys/class/graphics/fb0/freescale_mode

M="0 0 1919 1079"
echo $M > /sys/class/graphics/fb0/free_scale_axis
echo $M > /sys/class/graphics/fb0/window_axis
echo 0x10001 > /sys/class/graphics/fb0/free_scale

echo 0 > /sys/class/graphics/fb0/blank
fi

if grep -q vncinstall /proc/cmdline; then
export QWS_DISPLAY="VNC:size=800x600:depth=32:0"
echo
Expand All @@ -30,8 +47,14 @@ if grep -q vncinstall /proc/cmdline; then
echo
fi

# Pi touch screen
if [ -e /sys/devices/platform/rpi_ft5406 ]; then
export QWS_MOUSE_PROTO="linuxinput:/dev/input/event0:grab=1 intellimouse:/dev/input/mice"
fi

# Show GUI, it will write the OS choosen to /tmp/answer
/usr/bin/BerrybootGUI -qws 2>/tmp/debug
killall udevd

# Clear screen
clear
Expand Down Expand Up @@ -71,12 +94,23 @@ if [ "$IMAGE" != "" ]; then
. berryboot-init
fi

#
# Fedora and Arch symlink /lib to /usr/lib and expect modules in /usr/lib/modules
# Symlinks do not work well with our shared folder structure
# so move folders around if necessary
#
if [ -L lib -o -L sbin ]; then
echo
echo Error: having a symlink for /lib and/or /sbin inside your image is not allowed!
echo This conflicts with the shared AUFS folders
echo
sleep 5
if [ -e ${SHAREDDIR}/lib/modules ]; then
mkdir -p ${SHAREDDIR}/usr
mv ${SHAREDDIR}/lib ${SHAREDDIR}/usr/lib
mv ${SHAREDDIR}/sbin ${SHAREDDIR}/usr/sbin 2>/dev/null
fi
else
if [ -e ${SHAREDDIR}/usr/lib/modules ]; then
mv ${SHAREDDIR}/usr/lib ${SHAREDDIR}/lib
mv ${SHAREDDIR}/usr/sbin ${SHAREDDIR}/sbin 2>/dev/null
rmdir ${SHAREDDIR}/usr
fi
fi

for initfile in sbin/init usr/lib/systemd/systemd lib/systemd/systemd init
Expand Down
9 changes: 9 additions & 0 deletions buildroot-2015.02/package/berrybootgui2/post-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,12 @@ if [ -e output/target/usr/lib/fonts/VeraBd.ttf ]; then
cp output/staging/usr/lib/fonts/DejaVuSans-Bold.ttf output/target/usr/lib/fonts
fi

if [ -e output/target/etc/udev/hwdb.d ]; then
rm -rf output/target/etc/udev/hwdb.d
fi

# Remove libvncclient, only using server libs
if [ -e output/target/usr/lib/libvncclient.so ]; then
rm output/target/usr/lib/libvncclient*
fi

1 change: 1 addition & 0 deletions buildroot-2015.02/package/linux-firmware/linux-firmware.mk
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ LINUX_FIRMWARE_FILES += \
rtlwifi/rtl8192cfwU_B.bin rtlwifi/rtl8192cufw.bin \
rtlwifi/rtl8192defw.bin rtlwifi/rtl8192sefw.bin \
rtlwifi/rtl8188efw.bin rtlwifi/rtl8192cufw_A.bin \
rtlwifi/rtl8188eufw.bin rtlwifi/rtl8188eufw.bin \
rtlwifi/rtl8192cufw_B.bin rtlwifi/rtl8192cufw_TMSC.bin
LINUX_FIRMWARE_ALL_LICENSE_FILES += LICENCE.rtlwifi_firmware.txt
endif
Expand Down
4 changes: 2 additions & 2 deletions configs/berryboot_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ BR2_BACKUP_SITE="http://sources.buildroot.net/"
BR2_KERNEL_MIRROR="http://www.kernel.org/pub/"
BR2_JLEVEL=2
BR2_PACKAGE_OVERRIDE_FILE="$(TOPDIR)/local.mk"
BR2_KERNEL_HEADERS_3_4=y
BR2_KERNEL_HEADERS_3_10=y
BR2_TOOLCHAIN_BUILDROOT_LARGEFILE=y
BR2_TOOLCHAIN_BUILDROOT_INET_RPC=y
BR2_TOOLCHAIN_BUILDROOT_WCHAR=y
Expand All @@ -16,7 +16,7 @@ BR2_ENABLE_LOCALE_WHITELIST="C"
BR2_TARGET_OPTIMIZATION="-pipe"
BR2_TARGET_GENERIC_HOSTNAME="berryboot"
BR2_TARGET_GENERIC_ISSUE="Welcome to BerryBoot"
BR2_ROOTFS_DEVICE_CREATION_STATIC=y
BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y
BR2_TARGET_GENERIC_GETTY_PORT="tty1"
BR2_TARGET_GENERIC_GETTY_BAUDRATE_115200=y
BR2_SYSTEM_DHCP="eth0"
Expand Down
4 changes: 4 additions & 0 deletions configs/kernel_config_fragment_berryboot
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ CONFIG_RD_GZ=y
CONFIG_RD_XZ=y

CONFIG_SQUASHFS=y
CONFIG_SQUASHFS_ZLIB=y
CONFIG_SQUASHFS_LZO=y
CONFIG_SQUASHFS_XZ=y
CONFIG_AUFS_FS=y
CONFIG_AUFS_EXPORT=y
CONFIG_AUFS_RDU=y
Expand Down Expand Up @@ -44,6 +47,7 @@ CONFIG_HID_NTRIG=y
CONFIG_HID_ORTEK=y
CONFIG_HID_PANTHERLORD=y
CONFIG_HID_PETALYNX=y
CONFIG_INPUT_EVDEV=y

CONFIG_ANDROID=y
CONFIG_ANDROID_BINDER_IPC=y
Expand Down
1 change: 1 addition & 0 deletions configs/kernel_config_fragment_pi2
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
CONFIG_LOCALVERSION="v7-aufs"
CONFIG_TOUCHSCREEN_RPI_FT5406=y

0 comments on commit c15db5c

Please sign in to comment.