2021-01-13

BIOS Update

I noticed my new machine does not have /sys/firmware/acpi/tables/BGRT or /sys/firmware/acpi/bgrt so I decided to update the BIOS before looking more into it.

I knew Richard Hughes had been working on firmware updates for many years so I decided to try updating it from Linux. Sadly Asus is still "Evaluating the service" so no automated firmware update for me.

I downloaded the firmware from Asus website and the zip contained a single file named .cap so based on some reading it should be possible to use it, and fwupdate says it can update that firmware:

# fwupdate -l
system-firmware type, {e820d9ce-ff2c-5ce6-8ba1-c0c1c5703f44} version 1046 can be updated to any version above 1045

But when trying it failed with an error "failed: is not valid format", and verbose logging did not help:

# fwupdate  -a '{e820d9ce-ff2c-5ce6-8ba1-c0c1c5703f44}' PN50-ASUS-0611.CAP --esp-path=/boot/EFI -v 
(fwupdate:2815): FuCommon-DEBUG: 12:02:31.707: device /org/freedesktop/UDisks2/block_devices/nvme0n1p2, type: 0657fd6d-a4ab-43c4-84e5-0933c84b4f4f, internal: 1, fs: swap
(fwupdate:2815): FuCommon-DEBUG: 12:02:31.721: device /org/freedesktop/UDisks2/block_devices/nvme0n1p1, type: c12a7328-f81f-11d2-ba4b-00a0c93ec93b, internal: 1, fs: vfat
(fwupdate:2815): FuCommon-DEBUG: 12:02:31.729: device /org/freedesktop/UDisks2/block_devices/nvme0n1p3, type: 0fc63daf-8483-4772-8e79-3d69d8477de4, internal: 1, fs: ext4
(fwupdate:2815): FuCommon-DEBUG: 12:02:31.748: reading PN50-ASUS-0611.CAP with 16781312 bytes
(fwupdate:2815): GLib-GIO-DEBUG: 12:02:31.750: _g_io_module_get_default: Found default implementation local (GLocalVfs) for ‘gio-vfs’
(fwupdate:2815): FuPluginUefi-DEBUG: 12:02:31.751: deleting /boot/EFI/EFI/mageia/fw/fwupd-e820d9ce-ff2c-5ce6-8ba1-c0c1c5703f44.cap
(fwupdate:2815): FuPluginUefi-DEBUG: 12:02:31.755: maximum size is not configured
(fwupdate:2815): FuDevice-DEBUG: 12:02:31.756: installing onto (null):
FuFirmware:
  FuFirmwareImage:
  Data:                 0x1001000
(fwupdate:2815): FuCommon-DEBUG: 12:02:31.756: writing /boot/EFI/EFI/mageia/fw/fwupd-{e820d9ce-ff2c-5ce6-8ba1-c0c1c5703f44}.cap with 16781312 bytes
(fwupdate:2815): FuPluginUefi-DEBUG: 12:02:31.795: DP type:0x04 subtype:0x01 size:0x002a
(fwupdate:2815): FuPluginUefi-DEBUG: 12:02:31.795: DP type:0x04 subtype:0x04 size:0x0084
(fwupdate:2815): FuPluginUefi-DEBUG: 12:02:31.795: DP type:0x7f subtype:0xff size:0x0004
failed: is not valid format

After building it from source and adding some debug, it was failing to parse the GUID because the {} which are displayed by fwupdate -l must not be given in the parameter, and it does a lot of work before validating the arguments 🤦

Anyway, after calling it correctly all went fine:

# fwupdate -l
system-firmware type, {e820d9ce-ff2c-5ce6-8ba1-c0c1c5703f44} version 1553 can be updated to any version above 1552

But I still don't have /sys/firmware/acpi/tables/BGRT.

2020-12-31

New machine

8 years after the previous one, I bought a new computer and available hardware has changed quite a lot!

I bought an Asus PN50 with an AMD Ryzen 4800U, which is probably 30 or 40 times smaller than my previous machine but more powerful while using a lot less power...

Asus PN50 next to a credit card for size reference

I fit it with 32GB ram (with a second slot free to go to 64 later) and WD BLACK SN750 1TB NVME SSD and performance is really impressive for such a small machine with low power consumption (building an x86_64 Linux kernel with defconfig takes 2m35s). 

Writing to a file is far from the announced 3000MB/s Sequential Write Performance but still crazy high compared to what I was used to:

$ dd bs=16M count=512 if=/dev/zero of=test oflag=sync
512+0 records in
512+0 records out
8589934592 bytes (8.6 GB, 8.0 GiB) copied, 11.4705 s, 749 MB/s

It also gives me accessible USB-A, USB-C and micro SD ports which is very convenient for example to write images to USB sticks or SD cards.

2020-12-10

Playing with Chrome extensions

After a few days trying to book a Visa appointment with TLS Contact which had 0 availability and the consulate telling me to just often refresh, I decided to write a Chrome extension to check when they add them and notify me in case I would be around.

In the past I had done that with scripts after saving the cookies/tokens but this time I decided to try doing it in the browser. 

Pros:

  • I just need to login in a tab and let it there. It keeps refreshing so the session remains valid, but if it expired I would just need to login again.
  • I get to learn extensions APIs
Cons:
  • I will not be notified while not in front of my computer, however they seem to be manually adding the appointments so only during working hours
The first part was to create a content script to be run in the context of the page each time I visit a page matching the given URL. This is achieved by adding this to the manifest.json:

"content_scripts": [
  {
    "matches": ["https://*.tlscontact.com/*/myapp.php*"],
    "js": ["contentScript.js"]
  }
],

In that script I made it reload the page every 10 minutes (as the data is directly in the response from the PHP script) and when the page is loaded to parse it to find available appointments. I then used the storage API to preserve that list between reloads and compare to know if there are new appointments.

I used the sync API, meaning it is shared between my browsers, just because I can.

chrome.storage.sync.get('available', function(result) {
  var av = result['available'] || {};
  // Diff, log changes and notify of new ones
  chrome.storage.sync.set({available: available}, function() {});
});

The next interesting part is the notifications, as user scripts are very restricted and can not use the notification API. What I had to do was to add a background script, which has more power, by adding this to the manifest.json:

"background": {
  "scripts": ["background.js"],
  "persistent": false
},

Now when the content script wants to notify of a new appointment, it sends a message:

chrome.runtime.sendMessage({Appointment: a}, function(response) {});

In the background script, I listen to those messages and create notifications:

chrome.runtime.onMessage.addListener(
  function(request, sender, sendResponse) {
    chrome.notifications.create(request.Appointment, {
      type: 'basic',
      title: 'New appointment available!',
      message: request.Appointment
    }, function(notificationId) {});
    sendResponse({response: ""});
  }
);

And that's it! It turned out to be much simpler than expected, and we booked an appointment the next day.


2020-12-02

Enlarging an AWS NVMe root disk

There are plenty of documentations/questions about enlarging partitions but I had a problem before reaching that stage as the kernel does not seem to notice that the size of the disk changes (and I did not want to reboot).

AWS documentation says it should work Linux kernel 4.2 or later but this does not work for me with 5.7.19. It also suggests hdparm -z but that fails as the disk is busy.

After a bit of digging I found the right sysfs entry:

# echo 1 > /sys/block/nvme0n1/device/rescan_controller

Now the kernel notices:

[472580.761678] nvme0n1: detected capacity change from 107374182400 to 214748364800

And everything else works as expected:

# growpart /dev/nvme0n1 1
CHANGED: partition=1 start=206848 old: size=209508319 end=209715167 new: size=419223519 end=419430367
# resize2fs /dev/nvme0n1p1
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/nvme0n1p1 is mounted on /; on-line resizing required
old_desc_blocks = 13, new_desc_blocks = 25
The filesystem on /dev/nvme0n1p1 is now 52402939 (4k) blocks long.

 


2019-08-14

New home

As I ended up updating my blog software more often than I posted, I decided to move to some hosted place, which is here.

I'll try to import older posts over time but XML is hard and Blogger doesn't explain why when it's upset so most posts are still missing.

2017-12-03

When faster WiFi means unusable connection

I recently moved home and got FTTC with PlusNet, the speed is good when measuring (almost the advertised 80Mb/20Mb) but the connection was unusable due to TCP connections hanging every few minutes (very annoying with ssh but screen helps, worse when using a website for a payment and needing to retry and trust you will only be charged once).

Yesterday I decided to sit down and investigate. Router has logs which were quite helpful. A lot of things like OUT: BLOCK [9] Packet invalid in connection (Invalid tcp flags for current tcp state: TCP [192.168.1.73]:54426->[46.19.168.229]:443 on ppp3)

This followed the laptop being seen moving from interface ath10 to interface ath00 and it was moving back and forth quite often.

Looking at the logs on one of the laptops those switches looked like wlan0: disconnect from AP b8:d9:4d:41:76:fb for new auth to b8:d9:4d:41:76:fa

What happened is that default settings on PlusNet router is to have “identical” 2.4GHz and 5GHz networks so the devices believe they are the same network and switch between AP, but they are actually different and the connection tracking gets reset each time such switch happens.

Disabling the 5GHz network made my connection usable, I could probably just change its settings to make it separate.

2017-07-06

Success

In November 2012 I started running an irregular rebuild of all Mageia packages on x86_64, discarding the built packages, to just detect build breakages.

At first it was running a few times a month, now once a week, except before releases where I run it twice a week.

For the first attempt, on 2012-11-28, we had 10949 packages and 1104 failed to build (10%), by the time of the second attempt 3 weeks later we were down to 6.7% of build failures.

Since then, the distribution has been growing and this has helped detecting packages that needs to be fixed early, really helping for the mass rebuild of each release.

  • Mageia 3 was released on 2013-05-01 with 133 failures out of 11008 (1.2%), most of them being random failures due to the use of make -jN.
  • Mageia 4 was released on 2014-02-01 with 24 failures out of 11739 (0.2%)
  • Mageia 5 was released on 2015-06-20 with 42 failures out of 12455 (0.2%)
  • Mageia 6 is going to be released on 2017-07-XX with 0 failures out of 13650 (0%)!


For those interested in the technical details, I am using iurt (the same as we use on Mageia build system) to rebuild everything, creating a new chroot for each package.

I build 16 packages at once, with -j4, on a virtual machine having 32 cores and 200G ram which I use as tmpfs for the builds.

A full rebuild takes about 20 hours.