Sunday, March 26, 2023

Showing differences between binary files

At work I'm having to port some firmware changes to a new board.  This requires I understand the boot process in excruciating detail.  The old board boots with 3 different files stored in flash memory (bootloader, bootloader environment, and Linux file system).  I have the files as well as several raw dumps of various areas in the flash memory chip made with the "dd" command and needed to know whether there was any magic done to identify the different partitions of the flash device.

So I needed to show differences between binary files.  I normally use meld for file comparisons but it doesn't handle binary files.  It's easy to write a simple program in C to show simple byte differences but I wanted something able to display context for any differences.

It turns out that this is very easy to do in bash thanks to the ability to easily combine tools.  This is made possible by the Unix Philosophy.  The following command does exactly what I was looking for.

meld <(xxd file1.bin) <(xxd file2.bin)

So I whipped up a small shell script to make this easier and I've got a new tool for future use.  As you can see from the image, the display would be helpful in figuring out the differences between files.



Thursday, March 23, 2023

Saying goodbye to a special dog

 


We lost our very special dog to an osteosarcoma a few days ago.  He started limping a little over 4 months ago and it took a while to diagnose what was causing the problem which kept getting progressively worse.  We were so focused on figuring out what was wrong that it dominated our recent conversations about him.  I wanted to make sure it didn't overpower people's memory of the most affectionate dog I've ever met.

Bandit entered our lives a little unexpectedly about 10 years ago.  He was the third dog we've had during the 30+ years we've been married.  For some strange reason, each of them was roughly double the weight of their predecessor, progressing from 16 to 42 to Bandit's whopping 84 pounds.

Bandit had a rough start in life.  We adopted him from Rappahannock Animal Welfare League (RAWL), the same shelter where we had adopted our previous dog, Sandy, who was very sweet but much less outgoing than Bandit.  They do a wonderful job of socializing their dogs.  Apparently Bandit had been chained outside for much of his early life.  The shelter got him due to an altercation he'd had with a feral cat coupled with the fact that his first family had not seen fit to get him vaccinated against rabies.  He needed to be quarantined for 6 months for the possible rabies exposure.  They're a "no-kill" shelter but apparently that doesn't automatically apply in quarantine cases.  After seeing what a sweet dog Bandit was, they opted to keep him for the 8 months it took to get him through the quarantine period plus his recovery from being neutered because they were sure he'd be adopted.  How he stayed so friendly and loving given that rocky beginning amazes me.


My wife fell in love with the personality he displayed in the shelter's pictures of him playing with 5 beagle puppies.  His face managed to exude good-natured playfulness and joy in a way that we both found irresistible.  She also chose a smaller dog to look at in case the fact that Bandit was part pit bull (he was a lab-shepherd-husky-pit mix) made me nervous.  Any chance of me being worried about him being aggressive disappeared when they let him out of his kennel for us to meet him.  He was so affectionate that both of us ended up sitting on the floor petting him for quite a while until we were finally able to sign the adoption papers.

Since he had been chained up for much of his life, he didn't have much experience with cars.  I had to lift him into the truck where he sat nervously and stiff-legged in my wife's lap for the entire 90 minute drive home.  The only difficulty he gave us was with his initial nervousness about car rides.  He discovered that collapsing as low as possible could delay his ride for a while because it's so hard to lift an 84 pound dog who has cemented himself to the ground.  His nervousness about cars persisted for about a month until we took him to a place where we could bathe him.  He was so relieved to be done with the bath that he leapt into the back of the truck to go home.  After that, going for rides was one of his favorite activities.

 


When we adopted Bandit we lived in a suburb of DC which had lots of walking paths and he was happy to hike as far as we wanted.  Bandit usually preferred people to other dogs.  One notable exception was a dog half his size which lived near the walking path we took on a daily basis.  They loved to wrestle and often looked like tiny dinosaurs as they chest-butted each other while smiling the entire time.  It was like our own version of a Godzilla movie where the monsters are furry and friendly.  They would get so tired having fun that they would eventually collapse on the ground.  Once they had recovered somewhat, they would drag themselves towards each other to start again.

A year after we brought him home, we moved to the more rural suburbs.  Out in the country we discovered Bandit was really more of a medium-sized dog.  While technicians who came to the old house to fix things were nervous around Bandit, those visiting the new house often had dogs larger than Bandit and were happy to pet him.  Bandit always loved finding a new person to give him attention.

It was shortly after we moved to the country that he met his favorite neighbors.  Their oldest daughter bonded with him almost instantly.  She seemed to have a sixth sense about when we'd be passing their house and frequently treated him with bacon and other snacks.  After a few times being spoiled this way, his tail would start wagging wildly whenever we approached their house.

He looked forward to spend time with us each evening.  He often positioned himself between us and nudged our arms to convince us to pet him until our arms were tired and sometimes sore.  There are few things which could relax me like spending time with that affectionate bundle of love.

If I happened to drive by my wife and Bandit walking on my way home from work, Bandit would drag my wife towards the house to see me.  Bandit was a force of nature.  If he saw deer, he could spin either of us by the leash in his struggle to give chase.  Sometimes my wife would let go of his leash once they were close enough to the house to see me.  I have happy memories of him running down the road towards me and the uber-affectionate greeting I would get when he finally reached me.  The stress of the commute and a long day at work melted away instantly under his enthusiastic greeting.

There were few things which Bandit enjoyed more than having his face pet by my wife.  He would get into the strangest positions to coax her into stroking his face.

In the last few years, he had been moving a little more hesitantly and was not quite so keen to go on long walks but his sweet nature was just as strong as ever.  Those signs of him slowing down triggered me to start paying more attention to the time we had left with him.  I knew dogs as special as him don't come along often and I wanted to enjoy every precious moment.

He was sweet to the end despite being needing to take 3 potent medications for the ever increasing pain he was in while his doctors tried to diagnose his problem.  They ultimately determined it was an osteosarcoma and that the cancer had spread to his lungs.  We held out hope until the diagnosis made it obvious that we needed to let him go.

Both of us loved every minute we had with Bandit.  It's hard realizing we'll never be greeted by this big lovable goofball again.

Saturday, March 18, 2023

Exploding windows

I've encountered "exploding windows" on both Windows and Linux lately.  I try to resize a window and by clicking the window near the title bar, the window suddenly and unexpectedly expands to fill the entire vertical area of the monitor it inhabits.  Sometimes I'm able to do the simple resize operation which I wanted but randomly the operation results in an exploding window.  Perhaps the UI designer thought this was a neat feature but it causes me to curse each time I encounter it.  I'd love to figure out how to disable this behavior but each time I try to describe it in a Google search, I'm led down a rabbit hole of unrelated results.  It seems silly spending too much time researching something which while annoying only costs me annoyance and a few seconds to correct.

Sunday, February 19, 2023

Developers need IT skills

Often software developers can benefit from having skills typically found in IT support engineers.  For example I occasionally bring small embedded systems home from work since it makes working from home more productive.  It's hard to physically reconfigure equipment I've left at the office and the reset button is tough to hit across a VPN.  

In this scenario I need to be able to access the small embedded system on our home LAN as well as my build desktop machine which stays at work.  Having a VPN client which supports split tunneling makes this possible.  It requires that there be no overlap in IP addresses between the two LANs.  It also requires that I change the static IP address on the equipment I bring home to match the subnet which my home router uses.

The diagram gives a rough idea of how the split tunneling works.

VPN split tunneling diagram

Sunday, January 15, 2023

Getting paid to solve puzzles

 

The thing I enjoy most about my job developing firmware for embedded systems is that it's a lot like being paid to solve puzzles.  Many of the projects I work on are just as challenging as the old text based adventure games such as Infocom's Zork series.

The datasheets which contain information about how the chips in embedded hardware are supposed to function can be challenging to decipher.  Vendors do their best but it's not unusual for the datasheets to either be incomplete or to contain subtle inaccuracies.  A chip I developed a device driver for recently had an accurate datasheet but the device driver gave the wrong results because of an issue with the C compiler for the ARM processor.  It turns out gcc for ARM CPUs does not support signed character types by default which this chip required.  Fortunately gcc includes a compiler flag "-fsigned-char" which allows this strange behavior to be overridden.

Friday, December 30, 2022

My worst technical interview

About 38 years ago I interviewed for a software job at GEISCO (GE Information Systems).  This would be my second software position after making the switch from field engineering.  It was a systems software position, writing software to run on one of their network nodes.  At the time GEISCO supposedly ran the largest private data network in the world

One of the engineers I interviewed with felt obligated to test my software skills by asking me to write a short program on his whiteboard.   The problem was most systems software was written in assembly language at the time.  I knew 4 assembly languages which didn't overlap at all with the assembly languages he knew.  Upon learning that we didn't share a language, I asked if he still wanted me to write a program since there was no way he could determine the correctness of my program.  Being a good corporate drone, he insisted that I still needed to complete this step so he could mark it off on the interview form.  So I proceeded to write some code in GMAP, the assembly language used by Honeywell mainframes since that was the one I was most familiar with.  I guess I talked my way through it successfully because I ended up getting the job.  

My program wasn't very functional as I wrote system software and it was rare for me to need to use system calls.  I definitely had never written a system call which performed any I/O.  I believe I loaded an immediate value into a register, performed a left shift, saved it into a memory location, and then ended the program with a MME GEFINI system call which terminates the current program.

Even though I first encountered GMAP assembly language 45 years ago, I still remember the numeric value for the opcodes of a number of the instructions.  Perhaps some day I'll once again need to know that a 235 opcode is a LDA instruction (load accumulator) but I'm skeptical.  There's a lot of old knowledge I'd love to be able to purge to reclaim the memory space.

Changing the oil

I changed the oil in my commuter car today, having grown tired of the "change oil soon" messages which started appearing on the dashboard about two weeks ago.  Changing the oil is something I learned to do from helping my uncle and grandfather work on cars when I was young.  It's much quicker and somewhat cheaper to do it myself than it is to take the car to the shop since you need to include the time spent driving to the shop and waiting for the oil to be changed.

The container on the left in the picture below which now holds used motor oil always makes me think of my grandfather.  It's one of a pair of 5 gallon oil cans I have which he used for delivering heating oil during WWII.  Several times when I've taken these containers to the county recycling center to recycle the used motor oil, people have asked whether I'd consider selling them.  These cans and the other tools I inherited from him hold far too much sentimental value for me to ever consider parting with them although the idea of some yuppie paying top dollar for something like that would have made Grandad laugh.

 

I'm always pleasantly surprised to see how easy it is to access everything on this car (a Chevy Equinox).  It seems every other vehicle we've owned for the past 20 years has placed either the oil drain plug or the oil filter in an awkward spot.  Some have gone as far as hiding them above frame cross-members which makes a huge mess when the old oil drains out.  I've tried all manner of do it yourself funnels to try to coax the oil into emptying into the drain pan with varying degrees of success.