Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux ever? #59

Open
MKUltraCorp opened this issue Jan 2, 2019 · 21 comments
Open

Linux ever? #59

MKUltraCorp opened this issue Jan 2, 2019 · 21 comments

Comments

@MKUltraCorp
Copy link

Any plans to finish the coding for Linux? Anyone working on it or is it dead in the water?

@BramVer
Copy link

BramVer commented Feb 10, 2019

It seems pretty dead in the water, which is a shame since I've dropped my Windows machine, and none of the ways of 'flashing on Linux' seem to work for me.
I basically have to spin up a Windows VM for the sole purpose of flashing compiled .hex files onto controllers.

Having the qmk_toolbox run on Linux would be greatly appreciated.

@scottAnselmo
Copy link

I'm willing to throw a bounty on this via BountySource. Would need to know the desired amount though from @jackhumbert or someone reputable so I'm not just tossing money at something that gets locked up and nothing actually happens.

I too hate having to spin up a Windows VM or work laptop, and even then Windows drivers tend to be a bit buggy when flashing stuff it seems.

@QuercusFelis
Copy link

Any update on this? I can compile the linux code but the program itself is still unusable

@drashna
Copy link
Member

drashna commented Dec 30, 2019

Unfortunately, the linux version is basically just a shell. Unless somebody wants to work on the linux version, there won't be any progress.

@AliceGrey
Copy link

@sanecito I'd also be willing to chip in on BountySource if @jackhumbert or @fauxpark took this up.

@jackhumbert
Copy link
Member

I do have a renewed interest in this now that early Pinephones are out there - getting something going on Ubuntu Touch would be pretty neat.

@fauxpark
Copy link
Member

I'm not at all familiar with developing on Linux, much less a GUI application. From what I can tell, a Linux port would be kinda distro-specific, unless we used something like Electron? (I have no idea)

@tzarc
Copy link
Member

tzarc commented Feb 21, 2020

Perhaps something like:
https://github.com/zserge/webview/tree/webview-x

@scottAnselmo
Copy link

scottAnselmo commented Feb 21, 2020

There shouldn't be a need to target only a specific distro. Without deep diving, odds are one could repurpose a decent amount of the C# code and switch to the Mono framework as needed. Looking at the Linux dir, if they wanted to continue along a C/C++ route for logic they could use either the GTK or Qt toolkits for GUI. Those two especially with recent advancements like libhandy for GTK are toolkits that are more polished and better lend themselves to adaptive UI which is needed to say, make a solid UX for apps on PinePhone, Librem5.

@rkrhlikar
Copy link

rkrhlikar commented Mar 1, 2020

I recently created a fork where I took the Glade layout file and started implementing some of the logic behind it using gtkmm (the C++ gtk library), so it should work on different distros. I started with the low hanging fruit (meaning not touching anything related to hardware, which is, of course, the most important part) so as not to lose all motivation right out of the gate (working with HW is always a PITA :)). I expect to test flashing Pro Micros sometime this week.

As is often the case with these things, I make no promises about actually seeing this through. I decided to comment here, so that even if I do run out of steam, anyone interested in picking this up can do so without starting from scratch. As long as I do, however, keep working on it, I will be commenting with any significant progress I make in the near future (unless that would be considered spamming?).

@rkrhlikar
Copy link

As promised, a quick update:
I made some progress on the hardware side of things. I was able to successfully flash firmware onto the Pro Micros on my Kyria keyboard using the GUI. That means that the current test implementation for Caterina devices is up and running.

I had some problems with avrdude on my computer which were resolved by stopping the ModemManager service on my Ubuntu 18.04 installation when flashing the Arduinos. This can be done by running sudo systemctl stop ModemManager.service. I found this fix on the Arduino forums (if anyone would like to get more details considering the issue).

Planned next steps:

  • Support other devices that are programmed using avrdude (should be relatively straight-forward as the only difference is in the parameters passed to avrdude; however, I won't be able to properly test as I don't have any devices to test with)
  • Test implementation for dfu devices via dfu-programmer (I can test that on my GH60)
  • Add libraries that are used by the program (gtkmm, curlpp, ...) so that it can be distributed as an archive and ran directly after extraction (no need for dependency installation on the user system)
  • Implement everything required to run qmk toolbox directly from the terminal (currently the only way to flash is through the GUI)

Long(er)-term goals:

  • Support the rest of the devices (same as with avrdude devices, I will have some trouble testing as I don't own any compatible keyboards, so it will probably require some community involvement :))
  • Implement HID console
  • Update readme
  • Code cleanup

@Erovia
Copy link
Member

Erovia commented Mar 19, 2020

@rkrhlikar if you need some testing, ping me on Discord!

@NoraCodes
Copy link

@rkrhlikar please let me know if you need any additional help with this. I'd love to see a QMK Toolbox working on Linux and I have some experience distributing GTK applications to different distros which could potentially be useful.

@CharString
Copy link

This is comment is just as a reference for some Linux user contemplating their first build and this issue might scare them.

I found the CLI experience of the firmware just really good. I installed toolbox, because it was step one in the manual that came with my pcb. But I ended up not using it. Somewhere along the way I switched to following the qmk newbie docs and used the CLI for everything. qmk setup even detected I was on Fedora at one time and Debian the other, and used their respective package managers to install the missing dependencies. For the first flash, qmk doctor and dmesg helped with seeing whether my board was in bootloader mode or not.

There's just one thing I did differently. As I do a lot of python development myself, I chose to use pipx as I do with all my python packages I just want to install for the CLI command they provide.

My guess to why no one has picked this issue up as something to work on, is that it doesn't really scratch a personal itch. That said, Vim is my editor of choice, Super+Space fires up a terminal window in my setup and I do have experience with Arduino. So your idea of a good experience might be different from mine. But as you're building your own keyboard... using CLI instead of GUI just gives you more use and gratification from your project.

@jberryman
Copy link

Has anyone managed to get it to run in wine? I've struck out there

@malikbenkirane
Copy link

malikbenkirane commented May 18, 2022

@CharString your comment saved my time that should be merged to README.md 👍

I mean guys! Who would approve the PR? I open one if I see some interest ❤️

@brunzefb
Copy link

brunzefb commented Dec 26, 2022

I am actually thinking of taking a stab at this one using Avalonia.MVVM, since I know WPF. This is a .netcore6, so it will run on Linux if I don't use Windows-specific functionality. The primary UI (except for the keyboard tester) is pretty standard stuff, no fancy controls.
The scary thing is the low-level USB connection, it look like the in normal mode, the keyboard uses the normal driver. When you reset the keyboard, it disconnects from USB, and reconnects with the ID of the MCU in the keyboard. If anyone as info or example source on low-level usb that can be used, let me know.

2022-12-26 Update: I found the excellent LibUsbDotNet, which takes the pain out of the low-level USB stuff. I have some questions about the existing QMK toolbox app:

  • Given Vendor and Product ID's the product supports, QMK toolbox should automatically be able to detect and choose the MCU based on the connection event. Wondering why this is not done.
  • Detection only seems necessary for the Autoflash feature (which I think is a great feature, btw).
  • All the programming/flashing is done by external utils (which work fine on my linux-arch-based box
  • The external utils are baked into resources into the .net program and extracted on demand, I guess this is just to avoid having to install dependencies?
  • Programming-related messages come from the external program invocations.
  • Below the code to scan for the connection event for my Amtel32u4 keyboard
using LibUsbDotNet;
using LibUsbDotNet.LibUsb;
using LibUsbDotNet.Main;

namespace Examples
{
    internal class ReadPolling
    {
        public static IUsbDevice? MyUsbDevice;
        public static UsbDeviceFinder MyUsbFinder = new UsbDeviceFinder(0x03eb, 0x2ff4);

        public static void Main(string[] args)
        {
            Error ec = Error.Success;
            Console.WriteLine("Waiting for connection");
            while (true)
            {
                using (UsbContext context = new UsbContext())
                {
                    MyUsbDevice = (UsbDevice)context.Find(MyUsbFinder);
                    if (MyUsbDevice == null)
                    {
                        Thread.Sleep(500);
                        continue;
                    }

                    Console.WriteLine("Connected!");
                    break;
                }
            }
        }
    }
}

2022-12-26 Update 2: I have completed the Avalonia (think WPF) of the Linux QMK main UI. It looks very familiar, here with design grids enalbed (this will be turned of in production)

@brunzefb
Copy link

brunzefb commented Dec 27, 2022

2022-12-26-Update 2: I have made some progress with the Linux QMK Toolbox main UI, coding this using the Avalonia (WPF-like) framework, just because I worked with WPF a few years ago. It all came back pretty quickly. I'm not sure what the No HID Console devices connected is for, it seems to be a combobox. I took some care so that the resizing works in a similar way as it does on my mac. All the UI is still non-functional, so I have to hook things up.

@brunzefb
Copy link

brunzefb commented Dec 28, 2022

2022-12-28 Update: More progress to report. The main UI mostly works now, here is a new screenshot. The back-end USB connection detection now works (with some things still not right).
2022-12-28 Update: Works on my machine... :-), Here the screenshot of a successful reprogram. More cleanup work is needed. Code is in my branch, is very early alpha quality.

@brunzefb brunzefb mentioned this issue Dec 28, 2022
3 tasks
@brunzefb
Copy link

brunzefb commented Dec 30, 2022

2022-12-30: Update: More progress. The WinForms original UI and the Avalonia UI look almost identical now. I have added menus, shortcuts, and reworked the UI to make it very similar to the Windows version. Drag and drop files works on Windows, but not on Linux, although the code is identical. I learned more about the low-level usb library, which does provide notification for vid/pid combinations/ connect/disconnect events. The C example code looks straight forward, and the C# library imports all those methods and has callback/delegate types. The alternative is a 'lsusb' style poll detection. Right now, the code polls all the vid/pid combinations in sequence, which is slow. Its better to get the list of usb devices 3 or 4 times per second, and do a set difference to determine what has been added/removed. Changing the combo box background, checkbox size, the menu fontsize is not easy, one has to replace the entire control template (then you can do anything), but I don't think this is worth it.

@brunzefb
Copy link

brunzefb commented Dec 30, 2022

2022-12-30 Update: The LibUsbDotNet was not giving me the names of the devices, given a PID/VID. Reason for this is that one must call Open() on the device, which gets more info, including the Vendor name. Now Open only works if you are root :(, but you can add an entry into /etc/udev/rules.d, and reload with udevadm (or reboot), but this also needs sudo :-(. But you can get info as non-root by running udevadm info /dev/bus/usb/[device], which has VID, PID, and names. This can be parsed... find /dev/bus/usb -name "*" -exec udevadm info {} ; will list all the info... lsusb -d vid:pid will also work.

The last mystery was RevisionBcd, as it is unfortunately called int the QMK source. The C usb driver code in libusb.h calls this bcdDevice. The DotNetLibUsb just calls it Device in UsbDeviceInfo.cs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests