prime render offloading, and battery life…

In my previous post I described how to get NVIDIA prime render offloading to work.

I have investigated a bit more, and found ot two things regarding this, and power usage.

  1. With prime render offloading enabled both graphics cards stay powered up all the time. Makes sense, you want to be able to use either one of them at any time, after all.
  2. Changing the setup to use suse-prime-bbswitch instead of suse-prime makes it possible to power off the nvidia card when it’s not used. That means you have to actively switch to the nvidia card, and relog, to be able to use it. You have to use sudo to do so, the plasma applet actually gets confused by the output of prime-select in this case, and doesn’t work right – it always “thinks” the nvidia card is active even when you’re using the intel card.

Finally, here’s some numbers from my laptop:

With PRIME render offloading enabled, but nothing using the NVIDIA card:
9.5W power consumption, estimated battery life 6 hours

With PRIME render offloading enabled, and glxspheres running:
13.9W, 4 hours

Without PRIME render offloading, intel card active and NVIDIA card powered down:
7.7W, 7 hours

Without PRIME render offloading, NVIDIA card active:
11.5W, 5 hours.
Looks like the intel card does not get powered down when inactive.

Note: these numbers are educated guesses at best, all I did was run powertop while operating on battery.

The battery life time is based on 56Wh, and rounded to the nearest whole number.

I didn’t measure the power consumption with glxspheres and render offloading disabled, it stands to reason that it’ll be not much different from glxspheres with offloading since the intel card is active as well in both cases.

openSUSE 15.1 and a NVIDIA optimus laptop in 2020

So for the last … maybe 6 years I’ve been using an Acer Aspire E5-571G, which back when I got it was quite a nice gaming setup. Nowadays it’s a bit weak, but for my intents and purposes it’s still good, so until it actually breaks down I’ll stick with it. Besides, it’s red.

The specs:

System: Host: kirika.eregion.home Kernel: 4.12.14-lp151.28.44-default x86_64 bits: 64 Console: tty 0
Distro: openSUSE Leap 15.1
Machine: Type: Laptop System: Acer product: NC-E5-571G-53GC v: V1.32 serial: NXMM0EG0014180FA073400
Mobo: Acer model: EA50_HB v: V1.32 serial: Type2BoardSerialNumber UEFI: Insyde v: 1.32 date: 09/15/2015
Battery: ID-1: BAT1 charge: 54.7 Wh condition: 54.7/55.9 Wh (98%)
CPU: Dual Core: Intel Core i5-4210U type: MT MCP speed: 2394 MHz min/max: 800/2700 MHz
Graphics: Device-1: Intel Haswell-ULT Integrated Graphics driver: i915 v: kernel
Device-2: NVIDIA GM108M [GeForce 840M] driver: nvidia v: 440.82

After maybe three years I had upgraded it from rotating rust to a 1Gig SSD, and doubled the memory, so it’s still a pretty decent setup – even with the kind of wimpy NVIDIA 840M, since the screen only does 1366×768… but since it’s “only” a 15.6″ screen, it still gives you 100DPI – and that’s actually better than my desktop system, which only gets me 82DPI at full hd resolution.

Anyway, the issue at hand here’s the fact that the laptop has two graphics cards. One Intel integrated, and the NVIDIA. On linux, that means you can either configure your system to use one of them for everything and ignore the other one completely, which gives you the choice between no 3D performance or no battery life, or you can use the linux version of what NVIDIA has dubbed NVIDIA optimus, which in short means you use the intel chip for everything that doesn’t need 3D performance, and use the NVIDIA chip for games.

Until some while ago on linux you’d do this with bumblebeed (to power off the NVIDIA card when you don’t need it), and either optirun or primusrun as wrapper for all apps that need decent OpenGL… so you’d have to put “primusrun %command%” as launch parameters in steam for every game that needs the NVIDIA card. And this is where the problems start: there are two such wrappers, optirun and primusrun. And of those only optirun works with NVIDIA drivers past version 418.113. But optirun does not work with steam – or at least I haven’t gotten it to work. Also, old drivers = old security holes = not a good idea. Add to that mix that bumblebeed has not been updated at all in the last seven years, and you have the potential for all kind of trouble…

But enough of the past, enter the present: NVIDIA prime render offloading. In short, it means the same thing as the whole optimus/bumblebeed affair: The desktop and all regular apps use the intel card, and apps that use OpenGL and need actual performance get offloaded to the NVIDIA card.

Here’s what you need to do to get this to work on openSUSE:

  • wait for openSUSE Leap 15.2, or run openSUSE Tumbleweed…

If that’s not an option for you, follow these steps:

  • uninstall the nvidia-bumblebee* packages with “zypper rm -u nvidia-bumblebee nvidia-bumblebee-32bit”
  • blacklist the nvidia-bumblebee* packages with “zypper al nvidia-bumblebee nvidia-bumblebee-32bit”
  • uninstall bumblebee, bbswitch and primus with “zypper rm -u bumblebee bbswitch primus”
  • add and activate the openSUSE nvidia repository (it’s an option in YaST)
  • install the right nvidia drivers for your card, in my case the G05 drivers are right – YMMV, I actually have no idea if this works with cards that can’t use the G05 driverset…
  • add the X11:Xorg repo for 15.1:
    “wget -P /etc/zypp/repos.d https://download.opensuse.org/repositories/X11:/XOrg/openSUSE_Leap_15.1/X11:XOrg.repo”
  • make sure that repo has priority 98, autorefresh on, and is enabled, with “zypper lr” it should look like this:
    9 | X11_XOrg | Yes | (r ) Yes | Yes | 98
  • Upgrade your whole X11 to the versions from the X11:Xorg repo with “zypper dup -l –allow-vendor-change –allow-arch-change –recommends –allow-downgrade”
  • install suse-prime: “zypper in suse-prime”
  • reboot
  • log in on the graphical environment, and open a shell, in which you’ll run “sudo prime-select intel”
  • log out of the graphical environment, and log back in on it
  • open a shell, and verify that “xrandr –listproviders” produces output that shows two providers, the intel card and the nvidia card.

Now, whenever you want to run an app with the NVIDIA card all you have to do is set __NVIDIA_PRIME_RENDER_OFFLOAD=1 and __GLX_VENDOR_LIBRARY_NAME=nvidia, for example like this:

__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia glxinfo | grep "OpenGL renderer"

in fact, this command should produce only one line with the name of your NVIDIA card in it if all goes well.

Optionally you can install “plasma5-applet-suse-prime” which is a Plasma widget that lets you switch between the intel and the nvidia card, but with render offloading set up you don’t really want to switch – you just want to offload single apps.

One last thing: this whole process is one of the reasons why I have set up my systems based on LVM – I do have a snapshot of my root from just before I did all this, but I don’t have to suffer all the pain with BTRFS…

Have a lot of fun!

How to wipe, re-flash, and root a Samsung Galaxy S8+ using odin and magisk

Let’s assume your S8 is messed up beyond recognition, and you want to start over fresh by wiping and flashing the latest Samsung image…

So here’s a very short-worded step by step howto on what to do.

ENTER AT YOUR OWN RISK.

ENTER AT YOUR OWN RISK.

ENTER AT YOUR OWN RISK.

..I guess you got my point now. This can brick your phone. And Samsung’s going to tell you that you voided your warranty if you do.

Before you start: create a backup. Yes, create a backup. Preferably a real one, with Titanium Backup or something similar.

Once you’re done with the backup, you need to get the following things:

 

Now, make sure you have a backup of your phone. I mean it.

Then, turn the phone off, and then boot it to download mode. To do that: press and hold power, volume down, and bixby, until the phone comes on and shows you a screen where you can use the volume buttons to choose between download mode and reboot. Obviously you want to go to download mode, so press volume up now.

Now, turn to your (windows) PC. Unzip the zip file with your android image that you downloaded with friya (see above). It contains five files, I’ll name them after the start of the file names, there are the AP file, the BL file, the CP file, and two different CSC files.

Now, start odin. You have to run odin as administrator so it can get at your hardware – it needs to be able to access the usb device on a pretty low level.

In odin, load the BL, AP and CP files in the appropriate fields. Load one of the CSC files in the CSC slot, too (the “plain” CSC file results in a completely clean phone, the HOME_CSC file is supposed to retain your data, which is useless since part of this whole process is a factory reset in a few minutes…).Connect your phone to your PC. There are people who say you should use the original Samsung cable – I dunno about that but a good cable is not a bad idea here.

Look if odin shows “added” in the log window – you might have to reboot your phone and enable usb debugging if it doesn’t.

If odin shows “added”, and all four firmware files are loaded in the right spots, press start, and wait. The phone will reboot after the process, and you’ll be greeted by a fresh, clean phone that behaves as if it’s fresh out of the store.

Now we’re going to root it – enter at your own risk.

Transfer to your SD card:

  • the dm-verity-opt-encrypt patch
  • the Magisk zip file

Work your way through the “new user setup” on the phone, until you can access the settings to enable USB debugging by turning on developer mode, and going to the developer settings (you know the drill: in the software version screen tap “build number” seven times, then go into the developer settings screen that you can access now, and turn on usb debugging). While you work your way through initial setup, keep in mind that we’re going to do a factory reset in a few minutes – answer whatever you can with “skip for now”, anything more is a waste of time.

Anyway, once you have usb debugging turned on, power down the phone, and start odin again as administrator on your PC.

Boot your phone to download mode again (see above)

Load the TWRP file into the AP slot in odin, and make sure you turn OFF the “automatic reboot” option in odin (it’s on the options tab).

Make sure you see “Added” in odin in the log output, then press start. Once this is done, the phone will NOT reboot. That’s because if it did, the samsung firmware would replace TWRP with the normal recovery again. We don’t want that, so we boot directly to recovery from download mode now – to do so, press and hold power, bixby, and volume up until you’re in TWRP.

Once we’re in TWRP, insert the SD card containing the dm-verity-opt-encrypt patch and the latest Magisk zip file.

In TWRP, go to “storage” to select the SD card. Then, press “install” and select the dm-verity-opt-encrypt patch, and flash it. Do not reboot yet. Again in Storage, format data (this is the factory reset I mentioned earlier).

Now it’s time to flash Magisk, so do that by pressing install, selecting the Magisk zip file, and flashing it.

After this is finished you can reboot, and you’ll be greeted again by a shiny clean phone – but one with root access.

Walk your way through setup, setup your accounts, etc etc etc.

You’re done.

If you think you’re not yet completely done, here are a few odds and ends I do at this point:

Install a few magisk modules: sshd, l-speed, the f-droid privileged extension, busybox

In Magisk Manager Settings, enable systemless hosts,  and hide the manager.

Get a buildprop editor, and change ro.config.tima to 0 if you plan on using samsung health

Get a root file manager, and rename /system/priv-app/SamsungPass_1.3/SamsungPass_1.3.apk to /system/priv-app/SamsungPass_1.3/SamsungPass_1.3.apj, and delete /data/app/com.samsung.android.samsungpass-1 if it exists – Samsing Pass is not going to work on a rooted device anyways, and with this gone you can use biometrics for websites again.

Install Titanium Backup, and insert the SD card with your backup from before – now you can restore your previous apps from that backup instead having to bother poor google or samsung for your cloud based backups.

By the way, this is directly related to my previous post…

Unauthorized Bread, or how to put a compelling story to the preface of “The Linux Commandline”

I’ve just devoured Cory Doctorow’s “Unauthorized Bread” (pun intended), and basically it puts a very good story to the same message that is brought to us in the preface of “The Linux Commandline“… which is, rule your devices, don’t let them rule you.

In related news, i just got this cartoon off the heise forum:

firewalld 0.7.2

Just one little bit about 0.7.2:

since this release masquerading is off by default for IPv6. To get back to the old behaviour you have to manually insert one rich rule in the external zone:

firewall-cmd --permanent --zone=external --add-rich-rule="rule family=ipv6 masquerade"

…that actually cost me about one day to realize that this was the root cause of my network troubles after upgrading my firewall from 15.0 to 15.1…

LeapUP 15.0 -> 15.1

So the other day I got an advanced discontinuation warning for openSUSE Leap 15.0 which reaches EOL on November 30, and today I took that Leap (fun intended) and used my trusted little leapup script to upgrade my systems to 15.1… and what can I say, so far I’ve done my laptop and my desktop which could have been a bit tricky because there’s so much stuff installed, and one of my cloud servers – and except for some little bits of LVM juggling because / ran full on my desktop all went without a hitch.

That’s pretty much all I have to report about it.

Edit: Finished the second cloud server, no problems at all.

Finale grande: all systems upgraded without major problems. That’s how that is supposed to work.

Mozilla Thunderbird 68.0

<tl;dr>
no thanks
</tl;dr>

Long version:

I just got updated to Thunderbird 68.0 on my linux desktop systems.

Started it, and found that ALL add-ons except two had been disabled or removed, and the two that were left did not do anything anymore.

For example, lightning was still there but there was no way to actually open your calendar.

Good thing I had a way to roll back to 60.8. That one works the way I need it to.

Microsoft wants to push exFAT-Support directly into the Linux kernel

Here’s a little piece on one of microsoft’s many blogs…

I kind of think that this might actually be a really huge bit of news.

Why? My biggest two reasons are:

  1. Smartphone manufacturers making android phones won’t have to license the exFAT patent anymore to be able to support sd card storage on their devices.
  2. Microsoft used to use the patent on exFAT for years as a “weapon” to fight Linux. Now they themself want linux to support exFAT.