Connecting USB programmer AVR ISP MKII to target board for ATtiny2313

July 17th, 2011 No comments

I recently bought an Atmel AVR programmer since I was interested in helping a friend out with programming some blinking LEDs. This is a brief description on how I connected the programmer to a solderless breadboard so I would be able to program the ATtiny2313 I had concluded was sufficient for the project.

First of all, I downloaded AVR Studio 5 from Atmel (there exists other software as well, such as AVR Dude) and installed it. When I connected my AVR ISP MKII for the first time, it checked if there were any firmware upgrades available for the programmer and there were. The new firmware was installed without any hassle.

Pin layout for ISP and 2313

Pinl layout and wiring schematics

The AVR ISP MKII consists of a 6 pin female header which needs to be connected to the IC’s corresponding pins. It is pretty straight forward, connect MISO to MISO, MOSI to MOSI, SCK to SCK, RESET to RESET and 5V through a 4.7 K resistor, VCC to VCC and 5V., and GROUND to GROUND (see drawing and pictures). I used simple wiring cables in various colors to complete the connections. Make sure the pin orientations on the IC is correct, pin 1 is the first pin the left of the small notch at the top! Also make sure that the board is not powered while you connect the wires, in worst case you might fry your programmer if you made any miswiring.

 

 

 

 

 

 

 

The programmer does not supply the target with any power so it has to be powered separately. I use 4 AA batteries (6 V) (in a battery box with on/off switch) to power my bread board and have connected a 7805 voltage regulator, which takes the 6 V input and outputs 5 V, which is perfect for the 2313. After I had connected everything, it did not work. I had connected the 7805 ground to the ground rail on the bread board and the VCC pin to the the VCC rail, which was ok, BUT I noticed that the VCC and ground rails were split at the middle of the board (the battery was connected to the far end on the bread board and the 7805 at the opposite end). Two small jumpers connected the rails together fixed that simple problem (see bottom picture).

AVR ISP MK2 connected to target IC

AVR Bread board front

AVR ISP MK2 connected to target IC

AVR Bread board back

When everything is connected, turn on power and you should see two green lights on the programmer. If not, go back and recheck the wiring. Use a voltmeter to verify that the VCC pins get +5V, etc. If you have two green lights, start AVR Studio, go to Tools -> AVR Programming, make sure AVRISP mkII is selected under Tool, and ATtiny2313 under device, then click Apply. You should now be able to read the Target Voltage, and it should be around 5 V, +/- a few percent.

If you are going to a more than a little IC programming, I recommend getting a ZIF socket which lets you insert and remove an IC very easily.

For more info regarding AVR programming and programmers, check out these sites:

Writing .d81 images with IDE64

February 8th, 2011 1 comment

For the past days I have tried to successfully write some .d81 images to a 1581 drive, trying several different tools.
Since I don’t have a parallel port on my PC, I can’t use X1541 or any equivalent cable. And because I’m running Windows 7 64-bit I had no luck using a XU-1541 cable which supports USB, but it did not work on my 64-bit machine.

1581

So, I was left with trying to write images directly to the 1581 with only the help of my C64 and IDE64. CBM-Command 2.0 looked very promising but when trying to write an image (.d81 or .d64) from the CF card of IDE64, it kept saying that it was not a valid image. (Edit 2011-02-27: The reason is because CBM-Command verifies the image integrity by checking the file size, and apparently IDEDOS calculates file sizes differently.) I moved to .d64 image to the 1581 and managed to write it correctly to my 1541 drive. So it appears that IDE64 isn’t fully supported :( .

I had looked at a few plugins for the IDEDOS file manager but must have over looked a plugin called ID81 writer (in ID64 v0.6) which did exactly what I was looking for. After having updated the man.usr (configuration file for the file manager), a simply tap on ’4′ brought  up the plugin and after choosing the drive number, it wrote the image just fine :) .

Commodore nostalgia and IDE64 woes

February 6th, 2011 2 comments

IDE64 v4.1

For the past week I have been tinkering with setting up a Commodore 64 with a new mass storage device (IDE64 v4.1) I bought. It plugs into the cartridge port, it has an interface for CF card, 2 IDE interfaces (for external hard drives) and a PC Link connection for USB transfers between a PC and the C64. This device makes it incredible easy to transfer files from the PC to the CF card and then e.g. write disk images to a real 1541 or 1581 floppy. It runs its own DOS, IDEDOS v0.90 which implements several additions such as fast loader etc.

One of the advantages is that it has a built-in file manager from which you can access any device, e.g. drive 8,9, the flash card (drive 12) or the PC through PC Link (drive 14). This makes it easy and fast to shuffle files back and forth. However, I had run into a bit of snag when I first started using it and I decided to write about it here so others might learn from my mistakes. The main reason I bought it was to simplify storage, so I also bought a 4GB compact flash card from a local store. Before it can be used, it must be formatted to a CFS file system by a utility called CFSFDISK10B which can be found at http://singularcrew.hu/idedos/idedos_util20100514.zip. After having enabled Direct write in the Setup utility for IDEDOS, I run CFSFDISK10B, chose the default settings for numbers of tracks, sectors etc. Then it was time for creating partitions with ‘n’, where I chose the number of the partition, the size of it, and finally the name. Finally I edited the disk label (name of the disk) with ‘g’. So far so good. Then I committed the changes with ‘w’ and waited. And waited. And waited. Creating 2 partitions on a 4 GB CF card took apx 15 minutes. Didn’t think more of that and restarted the computer after the format was complete. It appeared it worked fine as I copied a few files over from the PC. But suddenly I noticed that the directory structure was messed up on the card. I restarted the computer, and to my horror it could not find the partitions (or even the card). When I read the drive error channel, it simply returned “76, HARDWARE
ERROR,000,000,000,000″. Scratched my head and restarted the computer several times, no luck. I repartitioned the card and the problem repeated itself, it worked for 10-15 minutes, then it gave up. At this time, I was beginning to think it was a faulty cartridge, and I e-mailed the creator, Josef Soucek, for advice. He responded quickly and was very doubtful about my gut reaction of a bad cartridge, since he does test them extensively before they are shipped out. Anyways, after having troubleshooted it for a day, I finally managed to borrow a CF card from work to see if it made any difference. It only took a few seconds to create a partition that covered the entire 512 MB card. Aha! That was indeed fast, but would it work any better than the last card?  Yes it did. It worked flawlessly and the next day I went out and bought a new CF card (2 GB SanDisk) which was partitioned in less than 10 seconds. If I only had knew from the beginning that a format should be that quick, I could have saved myself a lot of grief.

Now I added a few plugins to the file manager (to extend its functionality) so I could read .d64 images without uncompressing them to floppy, but every plugin I run did not work. As

File manager plugin

seen to the left, the header and blocks free are visible, but the disk structure is garbled. Sometimes the garbled directory listing contained text from previous files I had viewed, so I assumed it was a memory error or some faulty IC. I happened to have another breadbin available, and when connecting the IDE64 to it, all file manager plugins worked as intended.

Lessons learned: CF cards can be crappy (at least the 4 GB Transcend I originally bought) and computers may become unreliable (wow, that’s a shocker :) ).

Commodore setup

Now I am happily running my system with a 1541-II, 2 1581 drives and an IDE64. Next task is to get it online using a Lantronix MSS-100 device server.. just waiting for my null-modem adapter!

A few links about IDE64, IDE DOS and software..
http://www.ide64.org/
http://singularcrew.hu/idedos/
http://singularcrew.hu/ide64warez/index2.php

Graphing and monitoring real-time bandwidth

October 8th, 2010 No comments

I was looking for a quick and easy way to monitor the bandwidth on some Cisco switches a few weeks ago, and I found a program called STG (SNMP Traffic Grapher) by Leonid Mikhailov. It’s dead simple, you enter the IP address of the host, the RO community string, and the ifindex of the interface you want to monitor. To find out the ifindex (interface index) on a Cisco device running IOS, simply enter show snmp mib ifmib ifindex. To find out more about STG check out this post.
SNMP Traffic Grapher

Migrating from VMware Server 2.0 to ESXi 4.0

December 6th, 2009 2 comments

After having run a few servers under VMware Server 2.0 for about a year, I thought it was about time to move over to ESXi. The benefits of ESXi is that it’s a bare metal hypervisor which does not depend on any host OS and that it can easily be administrated by the free vSphere Client. Oh, did I mention ESXi is free?

Since my old VMware Server 2.0 is running on a rather unnecessary large (physically) machine in my closet, I decided to take the opportunity to get some new hardware suitable for ESXi. Not all hardware works without a hitch with ESXi 4.0, so I headed over to http://www.vm-help.com//esx40i/esx40_whitebox_HCL.php to see what parts were suitable. I finally settled with a Shuttle SG33G5 which has a small case, can easily be moved and low power consumption (250W PSU). I fitted the case with a Intel Core 2 Quad Q9550 2,83 GHz, 4 GB RAM, WD 750 GB drive, DVD player and an Intel Pro 1000GT NIC (since the internal NIC is not supported by ESXi 4.0).

Installing ESXi was a breeze, just registering to download a copy of it from http://www.vmware.com/products/esxi/ then burned it to a CD and installed it on the computer. I selected the drive I wanted to install it on, and when the install was done ESXi reached out and tried to acquire a DHCP address so it could be managed from another computer. I manually changed the IP address of the computer because I like to know what address each and every computer has. The complete ESXi installation took about 15 minutes and then I logged on to my main computer and pointed the web browser to the url of my new ESXi machine, from where I downloaded the vSphere Client so I could manage the host.

Now the more intricate process of converting and moving a guest from VMware Server 2.0 to ESXi started, since I was running a virtualized copy of FreeBSD 7 and I had it setup the way I needed and did not want to install it from scratch again. For this purpose, VMware supplies VMware vCenter Converter. It lets you convert physical machines to virtual (P2V) and virtual machines (GSX, VMware Server, Virtual PC etc) to virtual (V2V). I was running VMware Server on top of Ubuntu, and had to download the converter software to the host OS and install it. The installation was straightforward, unpack the .tgz archive, run the setup file and then run the vmware-converter-client from the desktop. From there, I specified the source type (which was “VMware workstation or other VMware virtual machine”) and browsed to the source virtual machine (FreeBSD.vmx). I made sure it was powered off (an option for converting powered-on machines exist, but does not work with FreeBSD yet) and then clicked next. But then, “A general system error occurred: unknown internal error.” greeted me. I tried powering on and off the machine again, checking for forgotten lock files, etc but nothing seemed to help. I finally unsinstalled and then installed the converter again and to my surprise (and happiness) I did not get the error message when I clicked Next. I specified the destination type as VMware Infrastructure virtual machine and supplied the IP address of my new ESXi host, along with name and password. A few clicks and some settings later (Virtual machine name, datastore, virtual machine version) the conversion was underway.

20 minutes or so later the conversion was complete and I logged on to the ESXi machine and confirmed that the FreeBSD host had been migrated successfully. I powered it on and it booted ok, the only problem was the driver for the NIC. In VMware Server I had used the em0 driver and in ESXi the default driver is le0, but I quickly changed it in /etc/rc.conf on FreeBSD so it would use the le0 driver. After a reboot it worked like a charm. The only other snag I had was with the vSphere Client, since it installed itself in evaluation mode, which expires in 60 days. I got a key when I registered and I could not for the life of me find where to add this key to the software. It was not completely obvious, but under the Configuration tab, Software, Licensed features, Edit… (far on the right side) I finally found where to put the license key. In most other software you register from the Help menu, but why make it easy :) ?

Some links that contains some tips and tricks..

Installing Snort on a flash based FreeBSD system

June 14th, 2009 Comments off

For some years I have run Snort on my main server, along with Apache, bind etc and this solution has the obvious limit to only check traffic accessing the server. In a perfect world, it should be placed either before or behind the router/firewall so all traffic to the internal network is examined. This can be accomplished by various techniques, such as getting a passive network tap or using a hub. Since I already had an ITX system, Alix 2D3, which is a small flash based mobo with 3 NICs, 256 MB, 600 MHz, I decided to give it a try and use it. In theory it seems straight forward, bridge two NICs together, connect the cablemodem to one NIC and the router to the second and let Snort sniff the bridged interface. In practice, it was not much more difficult.

Alix3D2

Alix2D3

Being the FreeBSD guy I am, I decided to install it on the 4 GB flash card. A few things to keep in mind.. Since compact flash cards has a finit number of writes, it is important to try and minimize the write operations, which can be solved by mounting the filesystems with noatime which stops the system from writing when the files were last accessed, and by mounting /tmp and /var/log to RAM by using tmpfs. One caveat with the Alix mobo is that it has no VGA output and to install the operating system, I did an install using PXE and a serial cable. It’s pretty simple, a good guide can be found here and another one here. To be able to remotely manage the box without connecting a console cable to it, I used the first interface (vr0) as management and applied a local address to it.

When installation was complete, I SSH’d into the box and upgraded ports. Then installed some must have apps like vim, screen and bash before installing Snort and Oinkmaster (to keep the rules updated).  Since I am running BASE (a web GUI for querying and analyzing alerts) on my main server and it’s using Mysql as the backend, I compiled Snort with support for logging to mysql. Before starting Snort, I had to bridge two physical interfaces (vr1 & vr2) to create one logical interface (bridge0)  that Snort could listen on.  After a few modications to snort.conf (specifying logging, etc) I started it with snort -i bridge0 and lo and behold! It worked!

Logging to Syslog on FreeBSD

May 30th, 2009 Comments off

After my latest installment, M0n0wall, I wanted its logs sent to a centralized syslog server, since it keeps it logs in RAM which are cleared whenever it’s restarted. Since I am already running FreeBSD 7.2 as a server on my network, I went ahead and started to set up syslogging on it.  FreeBSD comes with syslogd enabled, so usually it’s just a matter of configuring it correctly. There are two files that must be in order for syslogging to work, /etc/rc.conf and /etc/syslog.conf. First of all, make sure rc.conf contains these lines:

syslogd_enable="YES"
syslogd_flags="-a 192.168.0.1/24:* -vv"

The ‘-a’ option tells syslogd to accept incoming syslog messages from host 192.68.0.1 which belongs to a /24 subnet (255.255.255.0). ‘:*’ means that it accepts syslog message from any port from that host. Omitting ‘:*’ means that it only accepts messages from UDP port 514 (standard syslog port). Depending on the syslog implentation of the client, it may be necessary to include ‘:*’. ‘-vv’ only indicates verbose logging, which is completely optional. Another option which might be handy during debugging syslog, is ‘-d’ and it logs everything to console and does not daemonise syslogd. The next file to configure is syslog.conf and I added the following statements at the end of it:

+fafner
*.* /var/log/fafner.log

‘+fafner’ is the hostname of the client (if in doubt, start syslogd with the ‘-d’ option and see what name sends the syslog message to the server). The following line logs everything, all facilities such as auth, daemon, mail etc and all levels (ranging from debug to emerg) to /var/log/fafner.log. One of the snags I hit when trying to enable syslogging correctly, was that everything from my firewall (fafner) was logged both in /var/log/fafner.log as well as in /var/log/message which is the standard log file for the notice level. The fix was to add ‘+grendel’ to the beginning, which is the server’s host name. Beacuse, in the standard syslog.conf it is implicitely assumed that syslogd only has to process its own logs (not specifying a ‘+<host>’ line means that all processed syslog messages matching the facility and level are sent to that logfile).  By explicitely adding the hostnames, every message from my server is logged below the ‘+grendel’ line and everything from my firewall is logged below the ‘+fafner’ line. Here’s my syslog.conf in full:

+grendel
*.err;kern.warning;auth.notice;mail.crit                /dev/console
*.notice;authpriv.none;kern.debug;mail.crit;news.err       /var/log/messages
security.*                        /var/log/security
auth.info;authpriv.info           /var/log/auth.log
mail.info                         /var/log/maillog
ftp.info                          /var/log/xferlog
cron.*                            /var/log/cron
*.=debug                          /var/log/debug.log
*.emerg                           *
+fafner
*.*                               /var/log/fafner.log

Finally, to restart syslogd just type ‘/etc/rc.d/syslogd restart’. ‘man syslogd’ and ‘man syslog.conf’ have much more in-depth descriptions of how syslog works, so make sure to check them out as well!

Alix2C2 as a firewall with M0n0wall

May 26th, 2009 Comments off

For some time I have been pondering the option of getting a stand-alone router/firewall, since the combined modem/router provided by my ISP has some drawbacks (very rudimentary logging, max 10 ports forwarded etc). A few years back, I used my main multi-homed server (running FreeBSD 4.5 at that time) as a gateway/firewall. What I did like about it was the configurability and the logging options, but when I retired that box and moved FreeBSD over to a virtual machine, I simply got myself a modem/router combo.

One of my criterias now when I had moved into a new apartment, was that the firewall should be small, quiet and energy efficient. PC Engines has become one of the better

alix2c2

alix2c2

known manufacturers of ITX boards, starting with the WRAP which has know been succeeded by its Alix series. These are fanless, compact, and sports a compact flash socket. I settled for an Alix2C2, which has 2 NICs, 256 MB DDR DRAM, USB and a 500 Mhz AMD Geode LX800. LinITX also sold suitable enclosements for the Alix boards, and I bought a black one.
The next option was to choose the software, which there are plenty to choose from, M0n0wall, PFSense, IPcop , Smoothwall, etc. They can all be run from a CF card and doesn’t require a hard disk. Since using a CF card, the write cycles  are limited and everything is kept in RAM to reduce number of writes on the card and increase overall speed. I chose to go with M0n0wall, since its known to run well on Alix2C2, but I guess is’s a matter of taste, personal preferences and what features you are interested in.

Alix2c2 enclosement

Alix2c2 enclosement

When all had been settled it was time to get the hands dirty. Several guides has been written about this, and I followed the one on M0n0walls site. After downloading the embedded image from their site, I had to transfer it to the CF, which I did by writing the image with the help of a card reader. Since I was sitting at my Windows machine when doing the install, I downloaded physwriteimage and wrote the embedded image. Tried to use the GUI but since my CF card was larger than 2 GB (a waste, I know) it wouldn’t work. But using the command prompt and adding the ‘u’ flag to the arguments, it wrote the image fine. Inserted the CF card in the slot on the Alix board, slid it into its enclosement, added the power adapter and it was booting. But since the default configuration has the management IP as 192.168.1.1 and I wanted it to have 192.168.0.1 I had to connect a null-modem cable to its serial port (it doesn’t have a VGA connector) and connect to it through HyperTerminal. After the settings were committed, the box was ready for some action. Connected it to a local switch and the rest of the configuration was easy done through the web interface.

Navigon 7310

May 16th, 2009 2 comments

After months of patiently waiting for Navigon’s new flagship to arrive, I spotted it at a local electronics store and before I could say “Rob Hubbard’s 8-bit remixes” I found myselfnavigon_7310 walking out of the store as a proud owner of a Navigon 7310. It was announced at CES this January and it has now finally become available to many parts of Europe. Some of the features this GPS brags about are:

  • Voice navigation
  • Bluetooth
  • Landmark View 3D
  • City View
  • Reality View Pro
  • Lane Assistant Pro
  • Real Roadsign Pro
  • 4 GB SD card

As you can see, Navigon goes a abit overboard with the “Pro” suffix, but it probably lures saps like me to think their technology is on the cutting edge.  Anyhow, as I got home I quicklyunknown_device unboxed it and except the 4.3″ GPS, the contents of the box was sparse: a carholder (and no, not the sleak one that you were led to believe was included), a mini usb to usb cable, a car charger incl. TMC antenna, a quick installation pamflett and a synthetic pouch for your precious GPS. First line of business was to log on to Navigons web site to redeem an included voucher so you could get the sleak design car holder.  Next I connected the Navigon to my computer, which recognised two devices: one SD card and one unknown card which Windows Vista kindly asked me if I wanted to format. I decided against it. (Still today I have no clue about why it sees two devices and only one is recognised. )
Some software (Fresh and Sync) for the PC is preloaded on the SD card, that you can install on your computer. Navigon Fresh backs up your maps on the SD card, updates the Navigon software on the GPS, downloads map updates (which are not free, but you get a 80% discount on the maps for two years). Navigon Sync copies addresses from your contacts in Outlook and saves them to the GPS, don’t know how many will use this feature.

navigonAfter having backed up my SD card I was ready to start playing with the thing, but the unit was completely unresponsive as long as I had it connected to the PC. It just showed a symbol of a computer connected to a GPS and nothing more. After googling a while and checking Navigon’s support site I gave up. The closest I found to getting an answer was that if the cable is not inserted well enough, the device is only prepared for data transfer and will not be charged. If anyone else has had and solved this problem, I am all ears!

The following day I took it out for a test drive around the familiar block and some less known roads as well. It picked up the satelites in a few seconds after I turned it on and were ready to go. I told it that I wanted to go to work and entered the address, it gave me three different routes I could take, ordered in estimated driving time. Since the Navigon 7310 also has a feature called “myRoutes”, it adapts the route choice based on time of day, traffic, and other preferences, which seems nifty in theory at least.  As I approached an intersection, it added an overlay of the lanes and highlighted which lanes were approperiate for me. This can be a real life saver if you are in a busy and unfamiliar town and have with several lanes to choose from when either approaching an intersection or the road divides into several smaller roads. When you are approaching your destination, a small P appears, which when tapped, will offer directions to the nearast public parking garage/place available.

I have not had a lot of time to test it further, but it is a small device packed with promise. I will definetely keep it with me when on the road, since who knows when I get a craving for a some fine dining and then my Navigon 7310 with its plethora of POI’s will be there to direct me to the closest restaurant.

The most easy to loose USB thing ever

May 8th, 2009 No comments

Finally got one of the tiniest (physical size) USB drives I have seen in a while. The brand is Eagletec and is sold by Brando.com.hk and if offered in 4 or 8 GB versions.

EagleTec Nano USB drive

EagleTec Nano USB drive