Thursday, July 11, 2019

Notes on the Raspberry Pi 4b

I recently got a Raspberry Pi 4/4GiB.  Below and in the comments are my notes from poking at it.

SSDs are now worth it. My ancient Apple laptop HDD got about 33MB/Sec for both buffered and direct access. My inexpensive (Inland) SSD got about 108MB/sec direct, and 198 MB/sec buffered.
On my big desktop Linux machine with the same $5(US) USB3-SATA interface, I got virtually the same numbers from the Ancient Apple HDD, a bit over 200MB/Sec buffered and  about 200MB/Sec unbuffered on the SSD.

The Pi's USB 3 interface isn't as fast as the one on my big Linux box. I know this. It's been publicly stated. It's still plenty fast. As I do not have a 7200 RPM notebook drive to test with, I'll just say that based on the specs, you //might// touch somewhere close to these numbers with a high performance HDD on a Pi, and if the budget is pinching, or you happen to have a 7200RPM notebook drive lying about, you won't do badly with it, but my experience has been that you will feel the difference with the SSD. Particularly with the Pi, where swapping is a way of life, I recommend the SSD.

Numbers generated using hdparm -t /dev/sda and hdparm -t --direct /dev/sda.

Saturday, January 5, 2019

Windows 10 from Virtual to Real

In preparation for moving my stepfather's windows 10 installation to an SSD, I was trying out clonezilla. Having booted my virtualbox windows 10 machine to the clonezilla iso, I duped the virtual system drive out to a spare SSD (ye gods. Spare SSDs). Figuring out how to test it was a puzzle, so I tried what seemed like a dumb idea. I took the duplicate of the virtual drive downstairs to the Intel NUC I use down there as a shop computer. It runs Linux normally, but with some bios kicking so it would boot from USB drives, it started reading the drive.

And guess what. It booted into Windows 10, with all of my apps in place, no problems.  I didn't know it would do that. I had to update some drivers, and I did //not// check to see if it was authorized, and I did //not// plug the SSD into the NUC's one and only SATA port (USB3 was fine) but taking the ship out of the bottle and putting it in the ocean actually worked.

Cloning a Linux machine wouldn't have surprised me. They don't have stupid DRM baked in. The fact that playing that fast and loose with a Windows 10 license did work was the surprise.

Learn something new every day.

Note Bene: My basement machine would be pretty much useless with Windows on it, so once I did a long-overdue BIOS update on the NUC, I shut down, unplugged the windows drive, and everything went back to normal. After some more BIOS kicking so it would boot from the built-in drive again. Bleah. I don't like UEFI bios much. Intel's version, even less so.


Wednesday, December 5, 2018


To President George W. Bush:

There are circumstances that must supersede politics. This is one of them.  My sincerest condolences, Mr. President, for the loss of your father.


Tuesday, September 4, 2018

E-Bikin' it 7: Repair Comedy

Things have been busy around here, but back in July (remember July?) I noticed my front wheel stem had bulged out. "Hmm," I thought. "I should probably replace the tube in that this weekend." The stem blew up on that ride, deflating the tire in seconds. I took another walk home.

You might recall from E-Bikin' It 6 that I'd ordered all the parts for a new wheelset, with Sturmey Archer brakes and heavy duty touring rims. You might be wondering if this was one of the new tubes that had failed. It was not. What happened was that I ordered all the parts, did the measurements, and took the parts in to my favorite LBS (Local Bike Shop) to consult with the tech there on spoke length. Critically, I went with his calculations instead of mine. And the spokes I ordered were the wrong length. This stalled the project for a while. However, when my old wheelset's front wheel blew the stem off (mostly) the project got new urgency. I ran the calculations again, and called around town to find someone that sold spokes that length. Once I had them in hand, the fun began. And by fun, I mean mind-numbing tedium.

See, I'd never actually done this before. I had Youtube to guide me, in several different approaches, but it still took about 4 tries to get the front wheel built. Four tries getting about half done and finding out that I'd skipped a spoke hole, or gone the wrong direction, or had the tensions so far off I couldn't get nipples on some of the spokes, and so on.  The massive size of the hub (90mm) vs the relatively small size of my rim (26 inches) means the spokes are on a pretty steep angle. The rim is drilled for this, but it still complicates building. It makes for a pretty rigid wheel, though, which is what I wanted.

Eventually, I got the thing built and onto the truing stand for final tensioning, truing, and dishing. I don't actually own a dishing tool, so my dishing method was to get one side running true, and flip the wheel around, until the same truing setting worked for both sides, meaning the rim is centered over the hub. The front hub is not very asymmetric, despite the brake, so it wasn't a huge struggle. Less than truing my old front wheel, that's for certain.

The rear wheel was easier to build. Much easier. I'd done it before. Also, the rear hub is considerably smaller. The complications didn't set in until it came time to true and dish it.

Dishing any rear wheel is a pain, since the cassette makes the hub very asymmetric. The spokes on the cassette side have to be considerably tighter than the ones on the other side. My flipping-the-wheel method of dishing does work, but it multiplies the work fairly dramatically. I really need a dishing tool, and a better understanding of how to use one. Of course, I'll need wheels I'm willing to take apart to learn that...

Anyway. You'd think that once this whole process was done, I'd have been home free. Just stick tubes and tires on, add air, install, and ride. Yeah, I thought that too. I've never dealt with presta valves before. So far as I've been able to tell, they're inferior in every way to Schraeder valves (the kind your car uses), but they're what the rims are drilled for, and having gone to some lengths to get strong rims, I'm not about to weaken them by redrilling the stem holes. So presta valve tubes are what I got. From my favorite LBS. They were having a sale, so I bought four, thinking that since my last tubes lasted ten years, this might be enough for the life of the bike.

Ha. Hahaha.

Instead, I was surprised how much presta valves leak. Like, they wouldn't stay pumped up for 24 hours. "Wait," I hear you screaming, "That's not right." I know that //now//... but I had to get a presta air chuck to figure that out. Otherwise I was relying on thumb tests and a 20 year old bike mounted pump...that wasn't actually presta compatible, but could be made to work.  Under-pressurized tires? You bet. They were squishy. Didn't like them. When I got the air chuck and ran them up to a measured 55ish PSI, they were a lot better. They still leaked a lot, especially the front one. I was fairly sure that I'd overtightened the retaining nuts on the stems, or perhaps bent the valve cores. I tried swapping out the valve core from one of the spare tubes. Things didn't get any better. Swapped out the whole tube (swapping the cores back). Still no bueno. The new tube leaked as badly or worse than the old one.

Eventually, we went to Colorado Springs so my wife could see her dentist. (Long story.) I aired up the tires, stuffed the bike in the back of my CRV, and we went there. While she was dentist-ing, I got my bike out of the car, and managed to turn the handlebars (and front wheel) a full turn getting my bike out of my car. I wondered why all the brakes were locked when I tried to ride it. No worries, I thought, I'll just turn it back around. Everything seemed to work. It didn't, but I didn't realize it at the time. Because my front tire was slowly going flat.

Uncle Google to the rescue. There was, it turned out, a bike shop (another Specialized shop, in fact) about a mile from where I was. Downhill, even. I figured I had enough air left to get there before I started riding on my rims.  This was only mostly true.

At that point, I was annoyed. "Just replace the tube," I told them. I had lots more adjectives in mind for the tube at this point, but it wasn't the bike mechanic's fault, so I didn't share. "And let me watch, so I know how not to screw the tubes up." The mechanic was certainly nice. He asked where I'd had my bike converted to electric. You've seen the pictures. My ebike is not a thing of beauty. When dealing with professional bike mechanics, I half expect the comment to be "Wow, it looks like your conversion was done by a chimpanzee with a pipe wrench."  All he said was "Cool." Which could mean anything. I took it as a compliment.

The new tube went in without a hitch, other than the mechanic forgot to reconnect my front brake cable, which is no biggie. It just snaps in. Fortunately my first stop was from five miles an hour, and the rear still worked. They also sold me a valve core tool. Remember what I said about having the right tools? This is one of those. I think it set me back five bucks.

The new tube also held air. Like for weeks. I still had to put air in the back tire every ride, but it was workable.

And then I noticed that my shifting was all over the place. Gears weren't in the right positions, I couldn't reach my largest cog, and I threw the chain a couple times. This isn't normal behavior. I figured I'd knocked my derailleur out of alignment. Adjusted it. No bueno.

Then I got a good look at the shift sensor for the ebike kit, and all became clear. See, the wire part of the cable runs through the sensor, where it passes (I assume) between a magnet and a hall sensor and detects when you shift. A cable works because the inner wire moves through the jacket. The difference in pressure between the two is what shifts the bike (or stops it, although brake cables have somewhat different jackets.) The sensor still worked fine. The problem was when I turned the handlebars all the way around, and wound the cables around the headstock, I'd overtightened my shifter cable, and crushed the housing of the sensor. My rear shifter cable's jacket was no longer a fixed length, since the two ends of the cable jacket could get closer together through the crushed housing, and then further apart when you shift the other way. With indexed shifting, where it's assumed that the gear is in the same place every time, this is a disaster.

New sensors are 50 bucks. I didn't really want to spend that, since the sensor itself still worked, so I took a closer look at the bike.

Most modern bikes have remarkably little cable jacket. They have a length from the handlebars to the nearest fixed tube of the frame, where they pass through a cable stop. Here, the jacket ends, and the bare inner steel cable extends along the tube to another cable stop, where the jacket begins again, and the cable winds to its destination. Because the cable jacket stays the same length (it's supported by the cable stops and the frame) the shifting works as you'd expect.

My remaining shifter cable is jacketed along its whole length. I had to reroute it to make room for the motor. However, there is a cable stop that originally served the rear derailleur. It was the point where the bare cable ended and the jacket came back for the loop of cable that goes around the derailleur and controls it. Even better, it was right next to the sensor. One end of the jacket's length could be controlled by just re-using this cable stop. Awesome. All I had to do was figure out how to control the other one.

So I 3d printed another cable stop, from a design I found online, modified to take a beefier ziptie. Yes, my whole bike is held together with zipties. I took the rear shifter cable apart, mounted this new cable stop, threaded the cable through the old cable stop, readjusted everything, and my shifting was solid again. Yay me!

But wait, there's more.

Two rides later, the magnet that triggers the speed sensor (on the other side of the rear wheel) fell off somewhere on the trail.

In truth, my bike could have lived without the shift sensor. It was an addon to help prolong the life of the cogs, by turning off the boost while you're shifting. The speed sensor, by contrast, is mission critical. I've mentioned that my bike is street legal as a class 2 ebike. In no small part, this is because the motor computer cuts the boost at 20MPH. Having no speed sensor also means my odometer doesn't work, which means I have no idea how far I've ridden. Which is a bummer.

Exasperated by this point, I went to Michaels with my sweetie and bought a six-pack of little 1/4 inch neodymium magnets. They're much stronger than the ceramic magnet that was in the sensor trigger in the first place. After some tinkering (read: more zipties) I moved the sensor a bit closer to the axle and superglued one of those magnets to the hub. Along with significant bits of my fingers, no doubt. I hate superglue.

This worked great.

But wait, there's more. I'm not making this up.

I got a couple rides before my rear tire started going flat in the middle of the ride. Another slow (but not slow enough) leak. By the time I got it home, I was, once again, just barely not riding on my rims.

"What the heck?" I said. Actually, that's a lie, I have a full and colorful vocabulary of profanity that got exercised on my ride home. It was mostly exhausted by the time I got there.  "Perhaps," I reasoned, "the real problem with the front tube was that I bent both the original valve core and the replacement with that adapted hand pump. So I replaced the valve core with my new valve core tool and pumped up the tire. And then left the bike in the garage overnight. In the morning? Flat as a pancake. Exasperated, I took my old front tube (which the bike shop in Colorado Springs had replaced) to test and see what had gone wrong. (The front tire, by this time, was still holding the same air they'd put in it weeks before.)

The old front tube leaked through a seam. Whether it was defective originally, or whether it had gotten pinched when I first started riding these wheels, I don't know. At the time I was fairly convinced it was a factory defect, and that there was no earthly point in putting tube #4, my last spare, in the rear of the bike.

More colorful language. With considerably greater care than I really felt like exercising (lest I break something //else//) I shoved the bike back into my CRV and drove it to my favorite LBS, also the source  of my "defective" tubes, and explained my sad tale of woe to the bike mechanic there. He examined my rear wheel closely. "Hmm." he said, "your back tire has a thorn." He showed me where it went through to the inside. As a result, he sold me a new, heavier duty tube, and filled both my front tube (which up to that point was still fully pressurized) and the new rear tube with sealant. I should mention that he also removed the thorn.

Now, finally, the tires held air. They still do. They //may// need a little now, some weeks after that second tube was installed, but they're still pretty tight, exactly how you'd expect. So it wasn't the presta valves after all, and may well not have been defective tubes (though I'll never really know.)

But wait. There's more. Seriously?!? Seriously.

On the next ride, the speed sensor magnet fell off again. Apparently superglue+finger skin is not a good substitute for actual mechanical strength. More colorful language. I whipped out the 3d printer this time. After a few iterations, I had a magnet holder that would clamp around a spoke with the magnet in it. Superglue the magnet inside the magnet holder, then superglue the magnet holder together around a spoke. Then smear superglue all over the spoke, the support, and the magnet, just because I'm damn tired of fixing this bike. And finger bits. Let's not forget the finger bits in the mix. I think of it kind of like fiberglass. Resin+strengthener. Only now it's superglue, finger bits, steel spoke, PLA tube, and neodymium magnet #3. (My wife found #2, which I dropped, superglued to the floor in the garage. I kept it as a souvenir, and because you could run DNA traces on it and convict me of being an idiot with tubes of superglue.

But wait, there's... actually there isn't.  The first day I rode the thing after installing the new sensor trigger, I had a good ride, which is to say nothing leaked, broke, or fell off. So far, that's been the case since. I've skipped over some other, more routine maintenance. I've tightened the headset, which had gotten loose enough to *clunk* when leaned on, cleaned and reoiled the chain, returning to my belief that a good bike is a grease bomb below the axles, and replaced all the multicolored zip-ties from when I installed the lights with more dignified (and bigger, stronger) black ones, and so on. The bike's been fairly reliable since.

So after all that, how are the new wheels?

Different. First of all, between the hubs and the rims, I've probably added five pounds to the weight of the bike. It's an ebike. I don't notice that so much, really. What I do notice is this: I started riding a 10 speed back in the late 70s, when they were still a thing. These were road bikes, more or less, with narrow little road bike tires. They're //hard//, and I got used to the feel of the road through them.

My new tires are inch-and-three-quarters wide road-ish tires. They have tread, but they're in no-way knobby. Now that they hold air, I can say that even at 57LBS (the maximum the tires are rated for) they still feel softer, though nowhere near as soft as they were when I first started riding on them. The softness actually goes a long way to making a more comfortable ride, but it does mean the bike //bounces// more when I pedal hard. Where the new wheels are awesome: no broken spokes, and the extra 1/4 inch of tread width makes riding on the trails feels a lot more secure, without adding a lot of drag on the road.

Was it worth it?

Yes. I could have done without the tire drama, the speed sensor drama, the shift sensor drama and the spoke drama, but the wheels are a combination you simply can't buy, unless you have them custom made. They were expensive. All told, with two sets of spokes, I probably have three or four hundred bucks in these wheels. But if I'd had them custom made, it would have been easily twice that. If I could have done with one set of spokes, I could have brought that down by almost a hundred bucks. Spokes are expensive - about a buck each for good ones, and 36 spoke wheels eat them up.

Lessons learned: try to get Schraeder valve rims and tubes. They're more common, the tools to work on them are orders of magnitude cheaper, and prestas are just //fussy//.  Also, think hard about tube sealer and/or heavy duty tubes. And finally, keep a little pump on the bike. Make sure it fits the valves you have, or is valve-agnostic. Having to race home before my tire(s) went flat and feeling my brand new hand-assembled wheels practically riding on the pavement themselves was no fun.

Happy Trails.


Wednesday, August 15, 2018

Raspberry Pi for Arduino Users

So you might have noticed the site update. In addition to unplugging Google Analytics* (which was the only use my site had for cookies) I have a new book out, as of mid-July called Raspberry Pi for Arduino Users.

Most Raspberry Pi books assume you're starting from scratch, or that you know some Linux, or that you actually want to learn Python. Raspberry Pi for Arduino Users  assumes that you're actually an experienced Arduino user, well versed in writing sketches, but that you want to cross over to build an Internet gadget, or you need more speed, or a GPU, or some other service that just comes with a Pi, but you don't know where to start.

This book is where you start. It will teach you how to use the Geany IDE to replace the Arduino IDE you're used to, and how to leverage the C++ you learned writing sketches to write Linux programs for the Raspberry Pi, from GPIO code to network socket code to PHP for the Apache web server, to building your own 5 volt Arduino compatible that you can program from the Pi's GPIO pins.  I break these topics down into digestible chunks with some classic projects, and a few you simply can't do with Arduino.

Most of what you've already learned with Arduino can work with the Pi. This book is how you get there.


*My blog is hosted by, so it still has cookies. If you read it on my site, it's fed from the RSS feed that does not.

Friday, June 8, 2018

Tony Bourdain is Gone

I guess, like so many, I thought that Tony Bourdain had roped in his self-destructive demons, that they'd gone quiet as he aged, as he found success doing what he loved: traveling the world, writing, and making TV about it. Obviously it wasn't so. Much as I enjoyed his TV, I enjoyed his books more, the brash, caustic, obnoxious, but remarkably eloquent and humane writing voice was a treasure. It's a balance that's very hard to strike, and he did it over and over again. Unlike many, I don't see it as a self-absorbed act. I see it as a man who'd been staying one step ahead of his demons for 40 years stumbled again, and this time he fell all the way. I wish he'd gotten help instead. It can make all the difference.

My condolences to his friends, his girlfriend, and most especially to his daughter. I can't imagine how awful this must be for you.

Farewell Tony Bourdain. 


Wednesday, May 30, 2018

Linux Upgrade: The Hard Way

So my long-suffering Linux box, Lucky, ate itself a few days ago. I was in the middle of tinkering with a makehuman model, and all of a sudden, I couldn't write to the drive. It'd be having problems at boot time for months. My diagnosis: I suspect all the hangs and reboots finally corrupted the logical volume system.

Since I had to boot from a USB drive anyway (it was that bad), I decided to go ahead and upgrade to Xubuntu 18.04, Bionic Beaver. Seriously. That's what they called it. I get the feeling the name choosers' first language isn't English.

LVM, the logical volume management system (actually LVM2) is pretty robust. I was able, with some poking, to get my /home logical volume operational, albeit with a lot of complaints from LVM. I then rsynced it to my Buffalo NAS. This would bite me later.

After that, I reformatted the drives, set LVM up on it, made the registered boot partition much larger (4GiB) and installed. No problems on the 6th try.  Hint: if your installer complains that the install media is corrupt, reboot first, and try fscking it. I got no errors, but the installer stopped complaining and finished the job. Switch to the NVIDIA drivers so I get real performance out of my GPUs: yessss.  Works a treat. It boots reliably too, which is fantastic. Then the real work began.

Here's where the Buffalo NAS bit me for what will be its last time. Buffalo NASs come with almost no software, and no supported way to add more. So I had to root it and make some hacks to be able to back my Linux machines up to it at all. When trying to restore the same way, via rsync, it would occasionally drop the link and abort the sync. It never managed to restore my 40GiB windows 10 virtualbox drive. Likewise, copying data over windows file sharing was flaky, although this may be a problem with Thunar. Undaunted (but very pissed off) I finally managed to get the files I needed restored with a combination of those methods plus sftp from the NAS to my desktop machine. I don't need a NAS that I can't restore backups from reliably. I've got an infrastructure upgrade planned, and this piece of crap NAS is going to go away permanently.

So anyway. I've restored what I could not rebuild, and rebuilt what I couldn't restore (or more precisely, rebuilt what couldn't work on the restored files. Wine, I'm looking at you here.) Still have to get virtualbox going again, but I've done that before and it's given me only minimal grief, so I'm fairly (over)confident about that. Thunderbird? Give it its old .thunderbird directory and it picks up where it left off. Makehuman: reinstall and rebuild. Blender? restore the directories and go. Openscad: reinstall. And so on. My actual data loss is fairly minmal, although because some files just turn up missing despite having been restored, I'm going to have to keep that emergency dump around a while.

Anyway. I'd been meaning to tear into this machine and bring it up to 18.04 and try to fix the stability problems. Apparently it decided it was time. So far, that, at least, has been successful.

But seriously. Don't buy a Buffalo NAS unless you're only dealing with Windows or Mac. Even then, it's crappy.


Blog Archive