From 9a293641b9abf9e4fca34f46a2de781f50847da9 Mon Sep 17 00:00:00 2001 From: "Westergreen, Dalon" Date: Wed, 29 Mar 2017 15:41:36 -0700 Subject: Initial commit of de10-nano recipes Please note that this is purely for development. Only superficial efforts have been made to resolve security concerns, and it should be noted that the board ships with an EMPTY ROOT PASSWORD and support for root login via ssh. This allows passwordless access to the board via ssh. recipes-bsp/u-boot: Contains the uboot 2017.03rc2 recipe and patches to support the de10-nano board recipes-connectivity/avahi: bbappend to remove unwanted packages recipes-connectivity/bluez: bbappend to add --compat to the bluetooth service to support legacy SDP APIs recipes-connectivity/openssh: bbappend to add a custom sshd_config recipes-core/base-files: bbappend to customize fstab and inputrc recipes-core/imagemagick: bbappend to change build configuration for the de10-nano board recipes-core/packagegroups: bbappend to remove an unwanted package recipes-core/webkit: bbappend to remove support for opengl recipes-demo: Various demo applications recipes-devtools: MRAA and UPM recipes recipes-images/angstrom/de10-nano-image.bb: DE10-Nano image definition recipes-kernel/de10-nano-linux-firmware: FPGA related firmware required for fpga configuration and devicetree overlay support recipes-kernel/linux: bbappend to customize configuration of linux kernel as well as patch in the de10-nano devicetree recipes-misc: various initialization and systemd scripts recipes-qt/qt5: bbappend to modify qt build options recipes-support/neon: bbappend to remove unwanted package recipes-support/upower: bbappend to remove unwanted package recipes-webserver: webserver configuration and webcontent for board hostedweb portal recipes-xfce/thunar-volman: bbappend to remove unwanted package recipes-xfce/xfce-pointers: add configuration so that xfce does not use the adxl input as a mouse recipes-xfce/xfce4-settings: bbappend to remove unwanted package Signed-off-by: Westergreen, Dalon --- .../de10-nano-qt-usb-gadget-app/files/LICENSE | 22 + .../files/USB_Gadget.pro | 24 + .../files/USB_Gadget.pro.user | 626 +++++++++++++++++++++ .../de10-nano-qt-usb-gadget-app/files/dialog.cpp | 160 ++++++ .../de10-nano-qt-usb-gadget-app/files/dialog.h | 34 ++ .../de10-nano-qt-usb-gadget-app/files/dialog.ui | 146 +++++ .../de10-nano-qt-usb-gadget-app/files/main.cpp | 11 + .../files/mainwindow.cpp | 14 + .../de10-nano-qt-usb-gadget-app/files/mainwindow.h | 22 + .../files/mainwindow.ui | 24 + 10 files changed, 1083 insertions(+) create mode 100644 recipes-demo/de10-nano-qt-usb-gadget-app/files/LICENSE create mode 100644 recipes-demo/de10-nano-qt-usb-gadget-app/files/USB_Gadget.pro create mode 100644 recipes-demo/de10-nano-qt-usb-gadget-app/files/USB_Gadget.pro.user create mode 100644 recipes-demo/de10-nano-qt-usb-gadget-app/files/dialog.cpp create mode 100644 recipes-demo/de10-nano-qt-usb-gadget-app/files/dialog.h create mode 100644 recipes-demo/de10-nano-qt-usb-gadget-app/files/dialog.ui create mode 100644 recipes-demo/de10-nano-qt-usb-gadget-app/files/main.cpp create mode 100644 recipes-demo/de10-nano-qt-usb-gadget-app/files/mainwindow.cpp create mode 100644 recipes-demo/de10-nano-qt-usb-gadget-app/files/mainwindow.h create mode 100644 recipes-demo/de10-nano-qt-usb-gadget-app/files/mainwindow.ui (limited to 'recipes-demo/de10-nano-qt-usb-gadget-app/files') diff --git a/recipes-demo/de10-nano-qt-usb-gadget-app/files/LICENSE b/recipes-demo/de10-nano-qt-usb-gadget-app/files/LICENSE new file mode 100644 index 0000000..ab84792 --- /dev/null +++ b/recipes-demo/de10-nano-qt-usb-gadget-app/files/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) +Copyright (c) 2016 Intel Corporation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + + diff --git a/recipes-demo/de10-nano-qt-usb-gadget-app/files/USB_Gadget.pro b/recipes-demo/de10-nano-qt-usb-gadget-app/files/USB_Gadget.pro new file mode 100644 index 0000000..0763e25 --- /dev/null +++ b/recipes-demo/de10-nano-qt-usb-gadget-app/files/USB_Gadget.pro @@ -0,0 +1,24 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2017-03-07T06:26:48 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = USB_Gadget +TEMPLATE = app + + +SOURCES += main.cpp\ + dialog.cpp + +HEADERS += dialog.h + +FORMS += dialog.ui + +desktopInstallPrefix=/opt/$${TARGET} + +qtcAddDeployment() diff --git a/recipes-demo/de10-nano-qt-usb-gadget-app/files/USB_Gadget.pro.user b/recipes-demo/de10-nano-qt-usb-gadget-app/files/USB_Gadget.pro.user new file mode 100644 index 0000000..3c244f4 --- /dev/null +++ b/recipes-demo/de10-nano-qt-usb-gadget-app/files/USB_Gadget.pro.user @@ -0,0 +1,626 @@ + + + + + + EnvironmentId + {58b4a31b-9072-450d-aff3-5252315d8682} + + + ProjectExplorer.Project.ActiveTarget + 1 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Desktop Qt 5.7.0 GCC 64bit + Desktop Qt 5.7.0 GCC 64bit + qt.57.gcc_64_kit + 1 + 0 + 0 + + /mnt/hgfs/shared/USB_Gadget/build-USB_Gadget-Desktop_Qt_5_7_0_GCC_64bit-Debug + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + + /mnt/hgfs/shared/USB_Gadget/build-USB_Gadget-Desktop_Qt_5_7_0_GCC_64bit-Release + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + + /mnt/hgfs/shared/USB_Gadget/build-USB_Gadget-Desktop_Qt_5_7_0_GCC_64bit-Profile + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + true + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 3 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy locally + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 2 + + USB_Gadget + + Qt4ProjectManager.Qt4RunConfiguration:/mnt/hgfs/shared/USB_Gadget/USB_Gadget/USB_Gadget.pro + true + + USB_Gadget.pro + false + + /mnt/hgfs/shared/USB_Gadget/build-USB_Gadget-Desktop_Qt_5_7_0_GCC_64bit-Debug + 3768 + false + true + false + false + true + + 1 + + + + ProjectExplorer.Project.Target.1 + + Intel SoC FPGA Kit + Intel SoC FPGA Kit + {abe89813-0b04-4c79-9a8d-30146c57a81b} + 1 + 0 + 0 + + /mnt/hgfs/shared/USB_Gadget/build-USB_Gadget-Intel_SoC_FPGA_Kit-Debug + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + + /mnt/hgfs/shared/USB_Gadget/build-USB_Gadget-Intel_SoC_FPGA_Kit-Release + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + + /mnt/hgfs/shared/USB_Gadget/build-USB_Gadget-Intel_SoC_FPGA_Kit-Profile + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + true + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + 2 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 3 + + + + true + Check for free disk space + + RemoteLinux.CheckForFreeDiskSpaceStep + + + + + + / + 5242880 + + + true + Upload files via SFTP + + RemoteLinux.DirectUploadStep + + + + + + false + true + + 2 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy to Remote Linux Host + + DeployToGenericLinux + + 1 + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + 1 + + USB_Gadget (on Remote Device) + + RemoteLinuxRunConfiguration:USB_Gadget + + USB_Gadget + + false + + 3768 + false + true + false + false + true + + 1 + + + + ProjectExplorer.Project.TargetCount + 2 + + + ProjectExplorer.Project.Updater.FileVersion + 18 + + + Version + 18 + + diff --git a/recipes-demo/de10-nano-qt-usb-gadget-app/files/dialog.cpp b/recipes-demo/de10-nano-qt-usb-gadget-app/files/dialog.cpp new file mode 100644 index 0000000..6b64a5d --- /dev/null +++ b/recipes-demo/de10-nano-qt-usb-gadget-app/files/dialog.cpp @@ -0,0 +1,160 @@ +#include +#include +#include +#include "dialog.h" +#include "ui_dialog.h" +#include + + +Dialog::Dialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::Dialog) +{ + ui->setupUi(this); + + QString strText; + strText = "1. When USB gadget is enabled, the DE10-nano can work as an USB storage when it is connected to a Host PC. However, user's usb devices are required to plug into de10-nano after de10-nano linux boots. Otherwise, the usb devices will not be detected by the system.\r\n\r\n"; + strText += "2. When USB gadget is disabled, an external USB device can be detected upon connecting to DE10-Nano before or after Linux boots up on DE10-Nano.\r\n\r\n"; + strText += "Note: The system needs to reboot before the modified setting is applied to the system."; + ui->label_hint->setText(strText); + + + + bool bEnable; + if (QueryCurrentSetting(&bEnable, false)){ + if (bEnable) + ui->radioButton_Enable->setChecked(true); + else + ui->radioButton_Disable->setChecked(true); + }else{ + ui->radioButton_Enable->setChecked(true); + } + + +} + +Dialog::~Dialog() +{ + delete ui; +} + + +void Dialog::on_pushButton_Exit_clicked() +{ + qApp->quit(); +} + +void Dialog::on_pushButton_Apply_clicked() +{ + if (ui->radioButton_Enable->isChecked()) + GadgetEnable(true); + else + GadgetEnable(false); + +} + +bool Dialog::GadgetEnable(bool bEnable){ + bool bSuccess = false; + int res; + char szCommand[256], szInfo[256]; + + sprintf(szCommand, "systemctl %s de10-nano-gadget-init.service", bEnable?"enable":"disable"); + res = system(szCommand); + if (res == 0) + bSuccess = true; + + if (!bSuccess){ + sprintf(szInfo, "Failed to configure USB gadget.\r\n(%s)", szCommand); + QMessageBox(QMessageBox:: Warning, "Error", szInfo, QMessageBox::Ok).exec(); + }else{ + sprintf(szInfo, "Configure USB gadget successfully.\r\n"); + QMessageBox(QMessageBox::Information, "Information", szInfo, QMessageBox::Ok).exec(); + } + + + return bSuccess; +} + + + +void Dialog::on_pushButton_Current_clicked() +{ + // query current setting + + ui->radioButton_Enable->setChecked(true); + bool bEnable; + if (QueryCurrentSetting(&bEnable)){ + if (bEnable) + ui->radioButton_Enable->setChecked(true); + else + ui->radioButton_Disable->setChecked(true); + } + +} + +bool Dialog::QueryCurrentSetting(bool *bEnable, const bool bShowError){ + bool bSuccess = false; + int res; + char szFilename[] = "gadget.log"; + char szCommand[256], szInfo[256]; + + remove(szFilename); + //if (res == 0){ + sprintf(szCommand, "systemctl is-enabled de10-nano-gadget-init.service > %s", szFilename); + res = system(szCommand); + if (res == -1){ + printf("command return fail, code:%d", res); + }else{ + FILE *file; + int nReadSize; + long int nSize; + const char szEnable[] = "enabled"; + const char szDisable[] = "disabled"; + + usleep( 200*1000 ); // delay to make sure the file is ready. + + file = fopen(szFilename, "r"); + if (file == 0){ + printf("failed to open file %s\r\n", szFilename); + }else{ + fseek(file, 0L, SEEK_END); + nSize = ftell(file); + if(nSize < 0) + nSize = 0; + fseek(file, 0L, SEEK_SET); + + // + char *szData; + szData = new char[nSize]; + nReadSize = fread(szData, 1, nSize, file); + + if (nReadSize == strlen(szEnable)+1){ + if (strncmp(szEnable,szData, strlen(szEnable)) == 0){ + *bEnable = true; + bSuccess = true; + } + }else if (nReadSize == strlen(szDisable)+1){ + if (strncmp(szDisable,szData, strlen(szDisable)) == 0){ + *bEnable = false; + bSuccess = true; + } + } + + delete []szData; + + fclose(file); + + } + + } + remove(szFilename); + + + if (!bSuccess && bShowError){ + sprintf(szInfo, "Failed to query USB gadget setting.\r\n"); + QMessageBox(QMessageBox:: Warning, "Error", szInfo, QMessageBox::Ok).exec(); + } + + + return bSuccess; +} diff --git a/recipes-demo/de10-nano-qt-usb-gadget-app/files/dialog.h b/recipes-demo/de10-nano-qt-usb-gadget-app/files/dialog.h new file mode 100644 index 0000000..fc8a0dd --- /dev/null +++ b/recipes-demo/de10-nano-qt-usb-gadget-app/files/dialog.h @@ -0,0 +1,34 @@ +#ifndef DIALOG_H +#define DIALOG_H + +#include + +namespace Ui { +class Dialog; +} + +class Dialog : public QDialog +{ + Q_OBJECT + +public: + explicit Dialog(QWidget *parent = 0); + ~Dialog(); + +private slots: + void on_pushButton_Exit_clicked(); + + void on_pushButton_Apply_clicked(); + + + void on_pushButton_Current_clicked(); + +private: + Ui::Dialog *ui; + + bool GadgetEnable(bool bEnable); + bool QueryCurrentSetting(bool *bEnable, const bool bShowError=true); + +}; + +#endif // DIALOG_H diff --git a/recipes-demo/de10-nano-qt-usb-gadget-app/files/dialog.ui b/recipes-demo/de10-nano-qt-usb-gadget-app/files/dialog.ui new file mode 100644 index 0000000..af89ce3 --- /dev/null +++ b/recipes-demo/de10-nano-qt-usb-gadget-app/files/dialog.ui @@ -0,0 +1,146 @@ + + + Dialog + + + Qt::NonModal + + + + 0 + 0 + 495 + 300 + + + + Qt::DefaultContextMenu + + + USB Gadget + + + false + + + + + 150 + 210 + 100 + 20 + + + + PointingHandCursor + + + Enable + + + buttonGroup + + + + + + 260 + 210 + 100 + 20 + + + + PointingHandCursor + + + Disable + + + buttonGroup + + + + + + 210 + 250 + 80 + 22 + + + + PointingHandCursor + + + Apply + + + false + + + + + + 320 + 250 + 80 + 22 + + + + PointingHandCursor + + + Exit + + + + + + 20 + 20 + 461 + 161 + + + + QFrame::StyledPanel + + + TextLabel + + + Qt::AutoText + + + true + + + + + + 90 + 250 + 80 + 22 + + + + PointingHandCursor + + + Current + + + false + + + + + + + + + + diff --git a/recipes-demo/de10-nano-qt-usb-gadget-app/files/main.cpp b/recipes-demo/de10-nano-qt-usb-gadget-app/files/main.cpp new file mode 100644 index 0000000..c6efa74 --- /dev/null +++ b/recipes-demo/de10-nano-qt-usb-gadget-app/files/main.cpp @@ -0,0 +1,11 @@ +#include "dialog.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + Dialog w; + w.show(); + + return a.exec(); +} diff --git a/recipes-demo/de10-nano-qt-usb-gadget-app/files/mainwindow.cpp b/recipes-demo/de10-nano-qt-usb-gadget-app/files/mainwindow.cpp new file mode 100644 index 0000000..49d64fc --- /dev/null +++ b/recipes-demo/de10-nano-qt-usb-gadget-app/files/mainwindow.cpp @@ -0,0 +1,14 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} diff --git a/recipes-demo/de10-nano-qt-usb-gadget-app/files/mainwindow.h b/recipes-demo/de10-nano-qt-usb-gadget-app/files/mainwindow.h new file mode 100644 index 0000000..a3948a9 --- /dev/null +++ b/recipes-demo/de10-nano-qt-usb-gadget-app/files/mainwindow.h @@ -0,0 +1,22 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/recipes-demo/de10-nano-qt-usb-gadget-app/files/mainwindow.ui b/recipes-demo/de10-nano-qt-usb-gadget-app/files/mainwindow.ui new file mode 100644 index 00