Category Archives: Tips&tricks

Disabling Raspberry Pi 3 WiFi via config.txt

Today, I had to quickly debug a Pi which had a problem – it’d kernel panic right after boot due to the WiFi driver. It was probably a software problem since it would only happen on that specific SD card – on any of the Pi 3 I have. I had to solve it quickly – and all the solutions on the internet involved editing files on the Pi ext4 filesystem. I couldn’t log in the Pi, since, well, kernel panic, and I couldn’t mount the ext4 FS because I didn’t have a Linux machine handy. I did have access to config.txt, though.

I finally found a solution on OSMC forums. The way to disable the interface that Pi uses to communicate with Broadcom WiFi is:

dtoverlay=sdhost

Insert that in config.txt and the WiFi is going to be ignored. It’s not a power-saving solution – I can’t be sure it actually turns the WiFi chipset off, but it does prevent the OS from detecting it.

Flashing BIOS on MSI FM2 boards with a Richland processor

Say you, like me, had a motherboard with an incorrectly flashed BIOS. What do you do in that case? Well, best case, you use DualBIOS or an integrated BIOS recovery tool. What if neither is available? Well, you get a programmer and flash it. What if then you’re stuck with non-matching motherboard and CPU because:

  • The latest BIOS version which is available as binary is not compatible with the CPU you’re on (“please update BIOS for Richland”)
  • You can’t get another CPU in less than a month and a lot of money
  • All the versions which support your CPU are available only as self-unpacking EXEs which seem to work only when you’re in Windows, which you don’t seem to be able to do because the BIOS is not letting you:

20160306_120756

Fuckers.
Well, there actually is a solution.

  1. Get a flash drive, put MS-DOS on it (either format it using Windows =<7 and that checkbox which is there)
  2. Put that damned EXE on this drive and insert it into the motherboard (rear USB 2.0 ports preferred, the ideal orifice would be located on the body of the person responsible for a decision of not providing ROMs)
  3. Boot and press F1 to go into that damn BIOS
  4. Go “Settings”->”Save and Exit” -> override boot order and boot into that flash drive
  5. Enter “dir” to see the filename of the BIOS flashing tool
  6. Run it and reboot when it allows you.

Voila!

The boards on which this should work, according to the BIOS release notes:

FM2-A55M-E33 /FM2-A55M-E23 / FM2-A55M-P33 / FM2-A75MA-P33 / FM2-A85XMA-P33

You might have some luck with other boards, too. This approach worked for me with FM2-A75MA-P33.

Making luakit play YouTube videos

Luakit, even though it’s a quite awesome (and fast!) browser, doesn’t play YouTube videos out-of-the-box. At least, when installing it from Raspberry Pi Debian repos, it doesn’t pull the dependencies need and doesn’t even list the packages as ‘recommended’. Nowhere I could find it, but one Arch Linux forum page had a hint, which I decrypted:
Install gstreamer1.0-libav and gstreamer1.0-alsa – the latter being responsible for sound in YouTube videos.
That’s it. Hope it helps =) If you find it’s still not working for you – comment below, I’ll try to debug the issue.

Debian Jessie, VirtualBox – driver compilation failing because kernel sources cannot be found

I installed the Debian Jessie (testing) system from an around 3-month-old CD. Then I installed virtualbox and while installing it has complained that kernel sources are not found. I’ve installed linux-headers package and all the linux-headers packages that I could have found, but still no luck. I kept getting the following message:


The VirtualBox Linux kernel driver (vboxdrv) is either not loaded or there is a permission problem with /dev/vboxdrv. Please reinstall the kernel module by executing

‘/etc/init.d/vboxdrv setup’

as root. If it is available in your distribution, you should install the DKMS package first. This package keeps track of Linux kernel changes and recompiles the vboxdrv kernel module if necessary.


/etc/init.d/vboxdrv didn’t even exist! As I knew VirtualBox used DKMS, I did aptitude reinstall virtualbox-dkms, and it still outputted “Module build for the currently running kernel was skipped since the kernel source for this kernel does not seem to be installed.” I even installed linux-source – it didn’t help. So what was it?

My distribution had an older kernel, as it was on the CD I installed everything from. Since then, things changed – 3.13 was replaced by 3.14. The repository only had linux headers for 3.14 – and when I installed linux-headers metapackage, I installed headers for 3.14, even though system used the 3.13 kernel. So – when a vboxdrv can’t be build, check if you really have headers for the kernel version you are using =)

Now I just need to learn how to read properly. And to reboot my PC =)

What I use for making GIFs in tutorials – small yet powerful collection of free tools as a starters kit

I’ve recently got a job making tutorials, and it seems that I’ve already found a set of free tools that help. I’ll be updating this post, should my opinion change =)

Soooo… I’ve had a task of making GIF depicting a process in Eagle CAD. I need free tools, being a poor student who, however, doesn’t want to crack software just because it’s the first thing I’ve found. Also, I use Windows XP, so, for example, Snipping Tool isn’t available to me.

Continue reading

Use assert() carefully!

Please, don’t use Python  assert(statement) for things other than debugging in any more or less significant script.
Why?

Python compilers have optimisation modes. Those modes make code run faster by stripping down some things that are not really necessary for the code to function. For example, those are function docstrings – they’re omitted in optimisation mode just for the sake of optimisation.
Python interpreters also have a boolean called __debug__ that is defined by the compiler inside each script executed. It cannot be changed by the script itself. It is set as True all the times except for optimisation modes, where this boolean is False. Why we need this boolean? Just you wait.
Originally, assert was thought as a tool for the debugging. Actually, it still is. How does it work? Well, the original function’s code looks like this:

def assert(expression):
    if __debug__:
        if not expression: raise AssertionError

So, if __debug__ is False, there might be no AssertionError raised where you expect it. Let’s see a small script that the officers of some top secret nuclear attack site use:

#Used mainly for preparing tea 
#Nukes everybody if argument "nukeeverybody" is given
import sys
import nuke
import tea
try:
    assert(sys.argv[1] != "nukeeverybody") 
except AssertionError:
    teacup = tea.Tea(volume="cup")
    teacup.boil_water()
    teacup.brew_tea()
    teacup.bring_to_officers()
else:
    our_nuke = nuke.Nuke(target=nuke.targets["everybody"]) #OH MY GOD
    our_nuke.prepare() #WHY THIS
    time.sleep(3) #WE'RE GOING TO DIE
    our_nuke.launch() #At least we used objects where they were really aproppriate

Suppose that somebody made all the technical officers at the rocket silo recompile all their Python interpreters so that by default they use the optimisation mode. Then one of them wants some tea and launches bringtea.py… Assert behaves as if the statement is True, even though it isn’t. So the code passes straight to the “else” block and the code there gets executed…

Until time.sleep(), as “time” isn’t imported 😉 Still, nuke is prepared for the launch, who knows, what bad could happen due to that. Also, officers don’t get any tea.

Don’t use assert for things like checking arguments and such. It wasn’t prepared for anything other than testing and debugging and thus may misbehave on other occasions.

Did you know that… – notes about Asus EEE PC 701

An Asus EEE PC 701 4G runs perfectly on 12V power supply instead of 9,5 V one. Checked on two EEE 701 4G of different revisions, no overheating of power components and everything works for over a year by now. So – EEE PC 901 supply of 12 volts / 3 amps fits 701 model both by connector and voltage/amperage. Saying this because couldn’t find any information on the Web when I myself searched for this question, but now it’s clear.

Sometimes, on Asus EEE 701 4G keyboard keys misbehave: F2 becomes F1, | and ~ disappear… It’s simple to repair it: just turn off your EEE, close the lid, eject the battery, open the lid and press the power button for some 5 seconds. All the glitches seem to disappear after this.

Also, screen can start flickering in a strange manner all of a sudden. Just closing the lid and opening it again should help then.

To be continued if I find something more worth sharing about it =)