Dual Boot With Bitlocker for a Nitpicker

Illustration

As I use my laptop for both work and personal stuff, from the get-go I decided to go with the dual boot setup. For security I also decided to have full-disk encryption with the additional benefit of further separating those two installations.

When I first installed my laptop I did it as any sane person would - just install two Windows copies and everything works. However, during these holidays I decided to clean out my machine and redo the installs in a slightly different way.

Basic premise was the same: two BitLocker Windows installations. First one would occupy 400 GB, while the other would get leftovers out of 476 GB drive. What was tricky was my desire to have 400 GB accessible to user after Windows take their share. And I definitely wanted my personal partition to be first so that I can easily kill work partition(s) if I ever want to convert it to personal-only rig.

So I downloaded the latest Windows installation onto my USB and got it started. At the first screen I pressed <Shift>+<F10> and wrote DISKPART on the command prompt. Here I wanted to clean my existing disk content, setup GPT partitioning scheme, and have first 400 GB available for my private install with rest of the disk reserved for the work partition:

SELECT DISK 0
CLEAN
CONVERT GPT
CREATE PARTITION PRIMARY SIZE=410176
CREATE PARTITION PRIMARY
SELECT PARTITION 1
DELETE PARTITION
EXIT

As you can see from commands above, I’ve done this by creating two partitions and then deleting the first one so that Windows can have fun in that area only. Yes, I could’ve create recovery and system partitions myself but I actually prefer not to deal with such a low level details. If you wonder how I came upon 410,176 MB as a figure that will give me 400 GB partition, it is simply 409,600 MB (400 GB, the final desired size) + 450 MB (recovery parition) + 100 MB (system partition) + 16 MB (reserved partition) + 10 MB (to get into next cylinder). After that I’ve continued with Windows installation on unassigned space and my disk C after installation was 400.01 GB - the closest I could get to 400 GB.

As I wanted to have dual boot, I also went into Power Options, Choose what the power buttons do and turned OFF fast startup setting. In the early Windows 10 days omitting this would cause quite a few dual boot issues as each Windows copy left hardware in its own state. With the newer builds Windows seems to handle that better but I see no reason to tempt the fate. Only step left was to start Bitlocker encryption and get onto the next installation once it is done.

After next installation booted (actually of the same USB media), I used <Shift>+<F10> again to delete partition I’ve “reserved” previously. Since Windows added quite a few of its own partitions, it has moved to 5th spot:

SELECT DISK 0
SELECT PARTITION 5
DELETE PARTITION
EXIT

Installation continues as usual with the same adjustments applied (fast startup off + bitlocker on). Note that this leaves second installation as a default startup option. This can be changed in Advanced System Settings under startup and recovery.

Mini Metro and the Runtime Error!

Illustration

When I first got my hands on Mini Metro, it was over at the GOG.com. And I got dreadful Microsoft Visual C++ Runtime Library: Runtime Error!

Going through forums brought nothing useful so I contacted GOGs customer service. They’ve gave me a list of troubleshooting steps and I religiously went through all of them (even a strange suggestion to create a virtual screen?!). As nothing was really solved, it was the time to get out the big guns. In this case it was asking developers at Dinosaur Polo Club for help.

From them I got two steps. One was to install Visual C++ Runtime (different than what GOG guys suggested) and/or to try non-Galaxy build (Galaxy is GOG’s attempt to be Steam). Already fed up with all the runtimes I’ve installed so far, I tried non-Galaxy build first and it worked flawlessly. Problem solved!

After a few hours spent building subway, I was tempted by the other C++ runtime suggested. Would that make my GOG Metro work? Yes, I got another build from Dino guys, but that was just a zip file. Call me spoiled, but I prefer actual installations. And GOG has that. So I ran Visual Studio 2012 runtime and GOG’s Mini Metro started working.

However, that was not without cost - drivers for my Asus touchpad stopped working. As soon as I reinstalled drivers, GOG’s Mini Metro stopped working. Well, since I really needed touchpad drivers so I can have touchpad disabled (if you own Asus N56VJ you’ll understand), I just unpacked Dino’s build over GOG’s and called it a day.

Two things became obvious from this. One is that Dinosaur Polo Club has an excellent support and they didn’t even blink before giving me essentially another copy of a game. Yes, since it is a DRM-free build it doesn’t really matter if I have one or two or million of them - but that is exactly why DRM-free games are awesome - support doesn’t need to go through hoops to give you another copy.

Another is that allowing the use of GOG’s Galaxy client requires a bit of magic in the game and that magic is invasive enough to make game not work. I don’t know any details on what exactly went wrong there but Galaxy seems to need a bit of growing up.

Mini Metro

Illustration

I don’t play often nor I have a long gaming sessions anymore. Yes, I do throw occasional multiplayer game with my kids but but solo-plays are rare and far between. Most of the games I buy are the old ones I get for nostalgic reasons; rarely I buy a new game. Yep, definitely, I’m getting old.

However, these holidays one game peeked my curiosity. Same as with FTL, something simply “clicked” and, with reasonable $10, at GoG.com I saw no reason not to try it out. And boy, is this game fun.

Premise is easy - you create a subway lines to keep various shapes moving to their destination. With time your city grows, you get more lines to deal with, and eventually you fail. If you got emotionally connected to your town, you can continue playing even after you lose or you can decide to call it quits. Game is as simple as you can probably make it to still be interesting. But it is a loads of fun.

And game is completely DRM and Internet free. It might be just a pet peeve of mine but I hate when game requires Internet for no good reason (yes Starcraft II, I am looking at you) and when I cannot play game on whichever computer I feel like. Yes, DRM can be done right - Torchlight II is a nice example of a game that is minimally invasive. But there is something better than a well implemented DRM and that is no DRM at all. And any game that treats its users fairly, deserves to be bought.

Retrieving NAS4Free Build

For my NAS’ e-mail report I wanted to display NAS4Free version. While uname does give quite a few options, none of them returned all the details I could see on the Status page. And this is where open source shines - source code to the rescue!

Quick investigation has shown that all necessary details are in [util.inc](https://github.com/nas4free/nas4free/blob/master/etc/inc/util.inc). There in get_product_name function I’ve found the first hint - set of prd.* files in /etc directory. Those files get built with the OS and have all the details needed.

To keep a long story short, this is what I’ve decided upon:

VERSION_TEXT="`cat /etc/prd.name` `$cat /etc/prd.version` `cat /etc/prd.version.name` (revision `cat /etc/prd.revision`)"
echo "$VERSION_TEXT"

When ran on my current system, I get “NAS4Free 10.2.0.2 - Prester (revision 2118)”. Exactly what I needed. :)

Using AN20 on PIC16LF1559

For one pet project, I decided to use Microchip’s PIC16LF1559. as it was close to perfect as far as my needs went in that particular scenario. So I got all parts, soldered it onto the board and it almost worked perfectly.

Single thing that gave me trouble was light detection. It seemed as if ADC converter was giving me nonsense. I check and rechecked my code multiple times as this was the first time I’ve dealt with this chip. It took me a while before I remembered to check errata sheet. And, lo and behold, there was an known issue: “AN20 is not internally connected to the ADC bus when AD2CON0’s CHS bit select the pin.” And guess which pin I decided to use for light sensor?

Initialization of ADC is something that will slightly vary with application but what follows is a reasonable starting point:

ADCOMCONbits.ADFM = 1;      //right-justified
ADCOMCONbits.ADCS = 0b111;  //Frc (clock derived from A/D RC oscillator)
ADCOMCONbits.ADPREF = 0b00; //Vref is Vdd
AD2CON0bits.CHS = 20;       //select AN20
AAD2CHbits.CH20 = 1;        //AN20 is connected to ADC2

This will nicely work around the issue by using AN20 on the secondary channel. Not an ideal situation but it was ok in my case as I had no other plans for secondary channel anyhow.

Reading a value is a bit different than when dealing with a usual, single-channel, setup:

uint16_t getAdcValue(void) {
    AD2CON0bits.ADON = 1; //Turn on ADC

    AD2CON0bits.GO  = 1;
    while (AD2CON0bits.GO_nDONE) { nop(); } //Wait for A/D convert complete

    AD2CON0bits.ADON = 0; //Turn off ADC

    if (AADSTATbits.AD2CONV) {
        return AD2RES1;
    } else {
        return AD2RES0;
    }
}

For my purpose it made sense to turn on/off ADC as needed - for some other scenarios it might be better just to leave it always on. But interesting bit comes when reading a value - ADC saves it interleaved between two registers: AD2RES0 and AD2RES1. Code simply had to make sure to read correct one.

And this, slightly roundabout process, finally got the project working.