diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8784f059..ef0a6a87 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -282,9 +282,11 @@ set(SOURCES ${SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/translations.qrc ${QM_FILES}) if (WIN32) # Adding WIN32 prevents a console window being opened on Windows - add_executable(${PROJECT_NAME} WIN32 ${SOURCES} ${HEADERS} ${DEPENDENCIES}) + add_executable(${PROJECT_NAME} WIN32 ${SOURCES} ${HEADERS} ${DEPENDENCIES} + extraFiles.qrc) else() - add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS} ${DEPENDENCIES}) + add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS} ${DEPENDENCIES} + extraFiles.qrc) endif() set_property(TARGET ${PROJECT_NAME} PROPERTY AUTOMOC ON) diff --git a/src/OptionsPopup.qml b/src/OptionsPopup.qml index 3c029447..197e6883 100644 --- a/src/OptionsPopup.qml +++ b/src/OptionsPopup.qml @@ -34,6 +34,8 @@ Window { property string cloudinitrun property string cloudinitwrite property string cloudinitnetwork + property bool deviceUsbOtgSupport: false + property bool enableEtherGadget signal saveSettingsSignal(var settings) @@ -358,6 +360,12 @@ Window { ColumnLayout { // Remote access tab + ImCheckBox { + id: chkUSBEther + text: qsTr("Enable USB Ethernet Gadget") + enabled: deviceUsbOtgSupport + } + ImCheckBox { id: chkSSH text: qsTr("Enable SSH") @@ -632,6 +640,14 @@ Window { } } + if (imageWriter.checkHWAndSWCapability("usb_otg")) { + deviceUsbOtgSupport = true + } else { + deviceUsbOtgSupport = false + // make sure it isn't disabled and selected + chkUSBEther.checked = false + } + //open() show() raise() @@ -829,6 +845,20 @@ Window { addCmdline("cfg80211.ieee80211_regdom="+fieldWifiCountry.editText) } + if (chkUSBEther.checked) { + // keep parity with cli.cpp + addConfig("dtoverlay=dwc2,dr_mode=peripheral") + + enableEtherGadget = true; + + addFirstRun("\nmv /boot/firmware/10usb.net /etc/systemd/network/10-usb.network") + addFirstRun("mv /boot/firmware/geth.cnf /etc/modprobe.d/g_ether.conf") + addFirstRun("mv /boot/firmware/gemod.cnf /etc/modules-load.d/usb-ether-gadget.conf\n") + addFirstRun("SERIAL=$(grep Serial /proc/cpuinfo | awk '{print $3}')") + addFirstRun("sed -i \"s//$SERIAL/g\" /etc/modprobe.d/g_ether.conf") + addFirstRun("systemctl enable systemd-networkd\n") + } + if (chkLocale.checked) { var kbdconfig = "XKBMODEL=\"pc105\"\n" kbdconfig += "XKBLAYOUT=\""+fieldKeyboardLayout.editText+"\"\n" @@ -854,17 +884,6 @@ Window { addCloudInit(" layout: \"" + fieldKeyboardLayout.editText + "\"") } - if (firstrun.length) { - firstrun = "#!/bin/bash\n\n"+"set +e\n\n"+firstrun - addFirstRun("rm -f /boot/firstrun.sh") - addFirstRun("sed -i 's| systemd.run.*||g' /boot/cmdline.txt") - addFirstRun("exit 0") - /* using systemd.run_success_action=none does not seem to have desired effect - systemd then stays at "reached target kernel command line", so use reboot instead */ - //addCmdline("systemd.run=/boot/firstrun.sh systemd.run_success_action=reboot systemd.unit=kernel-command-line.target") - // cmdline changing moved to DownloadThread::_customizeImage() - } - if (cloudinitwrite !== "") { addCloudInit("write_files:\n"+cloudinitwrite+"\n") } @@ -873,7 +892,7 @@ Window { addCloudInit("runcmd:\n"+cloudinitrun+"\n") } - imageWriter.setImageCustomization(config, cmdline, firstrun, cloudinit, cloudinitnetwork) + imageWriter.setImageCustomization(config, cmdline, firstrun, cloudinit, cloudinitnetwork, false, enableEtherGadget) } function saveSettings() diff --git a/src/cli.cpp b/src/cli.cpp index ed5aa062..6c317216 100644 --- a/src/cli.cpp +++ b/src/cli.cpp @@ -58,11 +58,14 @@ int Cli::run() {"first-run-script", "Add firstrun.sh to image", "first-run-script", ""}, {"cloudinit-userdata", "Add cloud-init user-data file to image", "cloudinit-userdata", ""}, {"cloudinit-networkconfig", "Add cloud-init network-config file to image", "cloudinit-networkconfig", ""}, + {"usb-ether-gadget", "Enable USB Ethernet Gadget mode (does not support --first-run-script)"}, {"disable-eject", "Disable automatic ejection of storage media after verification"}, {"debug", "Output debug messages to console"}, {"quiet", "Only write to console on error"}, }); + parser.addVersionOption(); + parser.addHelpOption(); parser.addPositionalArgument("src", "Image file/URL"); parser.addPositionalArgument("dst", "Destination device"); parser.process(*_app); @@ -70,7 +73,7 @@ int Cli::run() const QStringList args = parser.positionalArguments(); if (args.count() != 2) { - std::cerr << "Usage: --cli [--disable-verify] [--disable-eject] [--sha256 [--cache-file ]] [--first-run-script