All posts by klamfx

Geting USBasp v2.0 to work on Linux

I recently bricked by Arduino Uno board and any attempt to upload new sketch will produce and error. I had tried to reflash the firmware multiple times using my serial programmer that I build a while back but no luck getting it to work. I end up purchasing a USBasp v2.0 programmer from eBay.


USBasp v2.0 should work right out of the box on Linux in most cases. On Arduino IDE, you only need to sett the following:

Board: Arduino/Genuino Uno
Programmer: USBasp

The Port setting is not used and the menu item should be grayed out. You should be able to burn bootloader or upload Sketch using the USBasp programmer with the above settings.

Or reflash the boot loader from command line.

/path/to/arduino-1.8.2/hardware/arduino/avr/bin/avrdude -C/path/to/arduino-1.8.2/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -cusbasp -Uflash:w:/path/to/arduino-1.8.2/hardware/arduino/avr/bootloaders/optiboot/optiboot_atmega328.hex:i -Ulock:w:0x0F:m


On some system. A tty device is created when USBasp is connected. In my case /dev/ttyS0. However when Port is set to /dev/ttyS0 in Arduino IDE. You will see the following errors:

avrdude: Warning: cannot open USB device: Permission denied
avrdude: error: could not find USB device with vid=0x16c0 pid=0x5dc vendor=’’ product=’USBasp’

To Fix Permission denied error. As root edit “/etc/udev/rules.d/99-USBasp.rules” with the following:

SUBSYSTEMS==”usb”, ATTRS{idVendor}==”16c0″, ATTRS{idProduct}==”05dc”,MODE=”0666″

Then restart udev.

sudo /etc/init.d/udev restart

To reflash the Arduino Uno boot loader

In the Arduino IDE Tool menu. Set the following:

Board: Arduino/Genuino Uno
Port: /dev/ttyS0
Programmer: USBasp

Then select Tools/Burn Bootloader.


I am currently unemployed and produce and share knowledge to help other people problems. I would like to raise some fund to get the stand alone domain for this blog. If you find these information helpful and would like to show your appreciation. Please consider Donate.


Retro Computing: How to boot strap a Commodore 64 system using direct audio signal injection.

Before proceeding, beware that you have other option like SD2IEC or using X1541 cable and a PC and using a Tape adapter method.

I am doing this just out of pure boredom and wanted to test and see if this idea would work and only have C64 with blanks disks and no softwares.

I start with a Commodore 64 with one floppy drive, a Commodore C2N cassette tape and a box of 10 floppy disks.

First order of business was to format a floppy disk to store transferred utilities program using the following commands:

OPEN 15, 8, 15,”N0:UTILITIES,01″ : CLOSE 15

The first program that you need to transfer across is a file copy utility called Copy 190, it will simplify file transfer later on.

I will use Vice to run the “Copy 190” program to copy itself on to a tape image and then use audiotap to convert it to a wave file.

To create the diskette image wave file:

  • Start C64 emulator and attach “Copy 190” disk image with autostart
  • Then select Disk to Tape option. Then enter “Copy 190” and follow the instructions.
  • When prompted to insert destination tape. Use the file menu to create a tape image called “copy 190.tap”
  • And select N when seeing Turbo (Y/N) prompt.
  • Then use audiotap to convert to a wave file.
  • Then use music player to record it/transfer.
  • On C64 type LOAD “Copy190”, 1


My first attempt using a hand held tape recorder failed miserably due to noisy tape recorded on a Walkman and miss-matched playback speed.

After so many failures, I finally abandon this method and resort to direct signal injection from PC headphone output to the tape input preamp.

So, with a 10K pot and .1uF capacitor and a few alligator clips later and hardwired the tape tape sensor.

I managed to load run Copy190 on C64. From then on using the same setup to transfer downloaded software onto the diskettes using tape to disk copy option.

The trick is start with low volume and adjust the pot or increase the volume until you successfully load from tape. You have to monitor the tape player motor and pause the WAVE audio player when it stop and resume when it start spinning again.

Good luck!

C2N Cassette Mod

IMG_0168 IMG_0169



Fixing upload problem with Arduino Uno Clone with CH340 on Linux

I just got my first Arduino Uno board with a CNC shield and wanted to setup the development environment on my freshly installed Linuxmint 18.1 laptop to start playing with it.

Once I got the Arduino IDE installed and tried to upload some of the example sketches. I was greeted with the following errors.

         Using Port                    : /dev/ttyUSB3
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00

After Googling to get some idea of what is the problem. It seem that this clone is using the CH340G USB to serial chip instead of the FTDI chipset used on the Genuine board.


Bus 002 Device 005: ID 03f0:231d Hewlett-Packard Broadcom 2070 Bluetooth Combo
Bus 002 Device 004: ID 1bcf:2805 Sunplus Innovation Technology Inc.
Bus 002 Device 015: ID 1a86:7523 QinHeng Electronics HL-340 USB-Serial adapter

The ch341 module that came with Linuxmint distribution was able to detect and load the module but uploading sketch using USB to serial communicating with this chipset is still a problem.

lsmod | grep ch34
ch341                  20480  0
usbserial              40960  7 ch341,qcserial,usb_wwan

To resolve this. First remove the ch341 module and replace it with one build locally from source provided by the manufacturer.

sudo rmmod ch341
sudo mv /lib/modules/$(uname -r)/kernel/drivers/usb/serial/ch341.ko /lib/modules/$(uname -r)/kernel/drivers/usb/serial/ch341.ko~

Then download the driver source from here.

Unzip it and compile the kernel module locally and install it.

sudo make 
sudo mv ch34x.ko /lib/modules/$(uname -r)/kernel/drivers/usb/serial
sudo depmod -a

Unplug the board and reconnect and reconfirm the board selection is “Arduino/Genuino Uno” and the port is properly selected in Arduino IDE and the upload should work.


I am currently unemployed and produce and share knowledge to help other people problems. I would like to raise some fund to get the stand alone domain for this blog. If you find these information helpful and would like to show your appreciation. Please consider Donate.

Creating a filleted cylinder in OpenSCAD

The following OpenSCAD module will create a filleted cylinder that can be used in your 3D print project when stronger sheering structural support is required.

Basically it uses rotate_extrude() on a circle to form a donut which will be used later as a cut out operation using the difference() on the smaller cylinder at the base. The fillets will be joined together using union() to form a solid filleted cylinder for the final result. At the moment, the top and bottom fillet radius can individually specified and will be used if it is greater than 0.

Here is an example of how the module can be used:

klam_fillet_cylinder(5, 1, 2, 1, 50);
translate([10,0,0]) klam_fillet_cylinder(10, 1, 0, 1, 50);
translate([-10,0,0]) klam_fillet_cylinder(10, 1, 2, 0, 50);

Constructed fillet cylinders:


module klam_fillet_cylinder(
) {
    /* created by Kevin Lam on Dec 3, 2016 */
    union() {      
        cylinder(cylinder_height, r=cylinder_radius, $fn=nfaces, false);
        if (fillet_radius_bottom > 0) {
            difference() {
                cylinder(fillet_radius_bottom, r=cylinder_radius+fillet_radius_bottom, $fn=nfaces, false);
                translate([0, 0, fillet_radius_bottom])
                translate([cylinder_radius+fillet_radius_bottom, 0, 0])
                circle(fillet_radius_bottom, $fn=nfaces);
        if (fillet_radius_top>0) {
            difference() {
                cylinder(fillet_radius_top, r=cylinder_radius+fillet_radius_top, $fn=nfaces, false);
                translate([0, 0, cylinder_height-fillet_radius_top])
                translate([cylinder_radius+fillet_radius_top, 0, 0])
                circle(fillet_radius_top, $fn=nfaces);

Bigolist – An Android App only Hoarders would love

This project idea was started out as an inside joke among friends for some giggles.

I am actually surprised that I actually finished it in a few months, since my attention span is as short a fruit fly and I have a closet full of abandoned projects to proof it.

Over the course of the year in hiatus, coding withdrawal started to set in and I finally start yearning to write codes again.

It started out as a learning exercise and my way of getting familiar with Android development by producing an actual software.

Part of the original goal was to find out what it will take for an experienced Software Engineer to develop something useful with limited familiar with the environment.

I started out with very limited knowledge on Android Platform, Java language, AWS, Android Studio, MongoDb.


However, with years of experience in C++, C# and C development experience. Overcoming some of these obstacles is not much of hurdle at all and in the process I learned quite a lot.

As, I delve deeper and deeper in a swim or sink mode and pushing forward in addressing performance related problem and UI responsiveness.

I had to adopt more advanced concepts, such as using AsyncTask to handle I/O stuff asynchronously and finally incorporated  HttpResponseCache and LruCache to further improve UI responsiveness.

Anyway, there are plenty of room for improvements and I am stilling working on improving it further.

One thing I know for sure is that this app is prime candidate in winning the 2015 first place award for ugliest app.

Bigolist – An Android App for Hoarders (US Only)


HP 3478A with no AC Voltage or AC Current Reading

I found this nice unit on eBay at a discounted price as a part unit, because according to the seller, the unit doesn’t read AC voltage or current. Otherwise everything else seem to work perfectly.

After some researching and digging through the schematic. There are few components like K104, U102 and U301, U302 and U303 ICs possibly failed.

Before proceeding further, if you are going to make a similar repair make sure it is disconnected from the AC line and take extreme care not to short battery. Otherwise all the calibration settings in CMOS RAM will be lost and need recalibration.

Once, I received the unit, I began tracing AC signal through K104, U102 and U301, U302 and U303 input. The signal made it through and range switching seem to work just fine. However, the output of U303 (AD536A True RMS-to-DC converter) is stuck at near ground regardless of the input signal.

To confirm that U303 is dead, I cut the JM302 to DAC section and reconfirmed that AD536A is faulty. Then to confirm that meter is still able to read the AC input from the DAC. I placed a .5V at DAC side of JM302 and the meter is responding, so the DAC is able to read the converted AC signal and it is a good sign.

After some research, I finally ordered Analog Devices AD536AKH replacement for U303 from eBay. When the unit arrive, I began surgically removed the old unit by clipping the legs and cleanly removed the old solder and pins before installing the AD536 replacement unit and bridge the JM302 jumper.

The AC volt and current is working now and the reading is slightly off and need recalibration.

Next improvement is to replace the lithium battery.

IMG_0122 IMG_0132IMG_0131 IMG_0135 IMG_0139

%d bloggers like this: