USBasp & Windows 10

 

If you have an USBasp programmer and a recent Windows machine you have more than probably stumbled into a disappointing message, either from Arduino IDE or Sloeber:

avrdude: error: could not find USB device with vid=0x16c0 pid=0x5dc vendor='www.fischl.de' product='USBasp'

I believe I’ve spent at least a couple of hours searching for a solution which would not require downloading some weird drivers from an unknown source.

Almost all forum threads I’ve been reading were describing a clunky process which involved rebooting the OS and disabling the driver signature verification to permit the installation of a driver you could download from Mediafire or attached to the posts… not something I’m really willing to do.

Making the long story short you just download Zadiq (a well known, reliable and open source software) and install the libusbK driver for your USBasp device: that’s it!

usbasp

The “Maven and Github on Windows” hell!

I’m sure this is not the first time I prepare a post like this, but I might have decided to last minute drop it: this time it’s not going to happen.

Sadly I have to use Windows at work and when I have some spare time I do contribute to Open Source Software and I have once again came face to face with the hell caused by trying to run a Maven Release Plugin on a Github hosted project. In this particular case it was a project I started myself called SmartUnit, but you can bet the same applies to any other Github hosted project using Maven and willing to perform releases on the Maven Central Repository.

Where do my problems start? Well, when I run the infamous mvn release:prepare obviously.

First I started encountering failures with the missing commands:

  • gpg.exe must be installed and available on the PATH to be able to sign the packages for the Maven Central Repository
  • git.exe must be installed and available on the PATH to be able to commit the tag and updated pom to Github

Installing the above though does solve only a fraction of the problem as you need the corresponding keys:

  • your GPG key should go into %APPDATA%\gnupg and it’s easier if it is the first key in your GPG key store
  • your SSH key should go into %USERPROFILE%\.ssh and, to avoid further complications, just name the file as rsa_id

As if it wasn’t enough hassle, you have to manually start an SSH agent to provide the SSH key, so don’t forget to (commands should be already on the PATH at this stage):

  1. run the Git’s bash shell with bash
  2. run the SSH agent with eval$(ssh-agent)
  3. add your SSH key with ssh-add ~\.ssh\id_rsa and input the key passphrase

If your key wasn’t already listed among your Github SSH Keys, don’t forget to add it.

Now the Maven release:prepare goal should complete successfully, but problems might arise during the release:prepare one as:

  • the PGP key must be publicly verifiable, so it must be published like on http://pgp.mit.edu/ (you can use gpg --armour --export to obtain the key signature to submit)
  • your Sonatype nexus credentials must be in your Maven settings.xml, under a server directive using an id matching the distribution repository (it should be sonatype-nexus-staging, but it might change over time)

Do you believe it’s all? Well, it’s not! Now you need to:

  1. log into your Sonatype Nexus account
  2. search your newly created Staging Repostory
  3. select the repository and close
  4. wait and refresh the view until it is reported as closed
  5. select the repository and release it!

Only at this point your artifacts will be available on the Maven Central Repository…

This is what I’ve twice learnt about the release process and what I hope I will be able to retrieve here the next time I’ll have to set this thing up again.

Might the force be with you!

Windows 7 disk space hunger

My recently formatted desktop computer just started to show those nice notifications regarding system disk drive exhaustion…

Really? I gave you 60GB of my brand new SSD and I’ve just installed one third of the software I want to run! What are you Windows doing with my precious hard disk?

So yes, I admit I use Windows along with GNU/Linux. Don’t kill me for that, please.

The weird thing was the disk space run low so quickly I couldn’t believe my eyes…

I installed a nice piece of free software called WinDirStat to highlight the disk space usage on my SSD and I realized I did forget about a few little optimizations.

My little beast has 16GB of RAM and I didn’t tune anything on my Windows 7 installation, which meant I had 16GB of hibernation file and another 12GB of paging file!

C:\> powercfg -h off

Just immediately freed up a nice few gigs and some manual settings on the system page file location and size gave me back another slice of storage.

I then refreshed the WinDirStat view just to realize the Windows folder was now leading the league taking 18GB of space, half of which was allocated under a folder called winsxs: what’s all that space for? I can’t exactly tell what’s under that folder (I’m not a Windows expert by all means!) but I can tell you I was able to regain another gigabyte by just running the system disk clean tool as Administrator and remove what the tool reports as Windows Update Cleanup.

Now a little question: for which misterious reason a set of resources identified as Windows Update Cleanup should occupy a gigabyte of space and a No Free Disk Space warning should pop up instead of just freeing up that wasted space silently trying to cover up your sins?

I then realized I could save another large amount of space by moving off the SSD my iTunes folder, but to achieve that I had to create an hard link (or directory junction in Windows terminology)

mklink /J "%APPDATA%\Apple Computer\MobileSync\Backup" "D:\iTunes\Backup"

This, along with the iTunes Media folder relocation, performed through the application settings, saved me another 12GB of space!

My disk is now breathing again!

Recover your (very) deleted files

Yesterday I did something stupid. Ok, that’s not the very first time it happens to me, but I believe this specific time it was something worth sharing.

My RaspberryPi did run out of space and all the files I was sharing through the attached 2TB USB hard drive were unreachable. I took the opportunity to perform a “system upgrade” I had planned for a while: run the entire system off an USB hard drive, another 350GB I had laing around.

So I hooked up the new drive and issued what I knew was an unsafe command, but without using the necessary caution:

dd if=dev/mmcblk0 of=/dev/sdc bs=4M

I realized sdc was my storage hard drive only when the process did end and I wasn’t able to access it locally… WTF!

I was speechless, my face became angry and I started looking at the wall in search of a nice spot where some red splash would have looked nice.

I started searching for backups, but I knew I had recently performed a nice cleanup recently in order to re-organize my archives.

After two hours spent in vain searching through my 4 USB hard drives I was so upset with myself I moved my storage hardrive onto Windows and formatted it NTFS.

I knew there are some tools to scan your hardrive and guess the sector contents, but I knew they would have taken ages to scan a 2TB drive attached via USB and what I would have got at the end would have probably been a bunch of sector backups with no significance…

Then I stumbled upon this super easy and super smart piece of free software called Recuva: with a few clicks and with no need for a degree in hard drive construction I was able to recover a huge amount of my files (well, I didn’t even try to recover those that got even just a sector overwritten by my smart command) and it took about 12 hours from installation to a directory full of files.

And all this after a sector by sector overwrite (dd) and a Windows fast format!!

Well, it’s not what I call an happy ending, but it’s better than nothing and it’s definitely worth sharing: don’t be stupid like me!

Compacting VirtualBox disks

For my development tasks I often use VirtualBox, mostly for testing purposes. Sadly though, installing multiple operating systems consumes quite a lot of disk space, so I need some way to keep the virtual disks small.

Because you can use auto expanding virtual disks you might think they will automatically shrink if you reduce the amount of content in there, but this is not true: if you have a virtual disk of say 40GB and 30GB in use, your VDI file size will be about 30GB, but if you delete 20GB of data from within your virtual disk the VDI file size will remain 30GB.

That space can be reclaimed though by using a command line tool called vboxmanage which provides a command called modifyhd which in turn has a –compact option.

In other words you can execute something like

vboxmanage modifyhd your/virtual/hard/disk/file.vdi --compact

and shrink your VDI file to its real content size… if you managed to wipe your virtual disk free space with zeroes!

Do not underestimate the last statement: the vboxmanage tool will eliminate from your VDI file empty space only, but usually when you delete a file the space it was occupying is not emptied, just unlinked!

Luckily for us there are tools around to help us on this task, which has to be executed from within the virtualized machine (aka the guest machine). These tools though depend on the virtual OS you are running.

Mac OSX

Open a terminal window and run the following command, then wait and ignore the warnings you get.

diskutil secureErase freespace 0 /

Windows

Defrag your disk, download SDelete from the Windows Technet web site and run it with the -c option.

sdelete.exe -c C:

Linux

Run this command and wait for it’s completion. Note though this will expand your virtual disk to it’s maximum capacity to allow you to shrink it.

cat /dev/zero > /tmp/junk & rm /tmp/junk