Showing posts with label computer. Show all posts
Showing posts with label computer. Show all posts

Monday, 16 April 2012

Raspberry Pi: Small Computer, Big Ideas

When I was growing up, computers were only just starting to make inroads into schools and homes, mostly via affordable (not to everyone true, but to a large slice of the population than previously) machines such as the BBC Micro, and the ZX Spectrum. As I've mentioned before my first serious forays into computer programming where actually with an Acorn Electron (a cut down, and hence cheaper, version of the BBC Micro). While these machines were often used as glorified typewriters or for playing games they were also easy to programme. When you turned them on they didn't boot straight into some complex graphical operating system, but to a simple prompt. You could enter commands that would load programmes, or you could enter simple commands that would make the computer do something. If you messed up you just turned the machine off and then on again. There was no danger of you messing the machine up in any way that would stop it working perfectly next time you turned it on. Combined these two things led to a generation of kids who messed around programming computers and who have grown up and become software engineers.

Unfortunately as computers have become more complex, the ability to experiment with programming has reduced. Also it is much easier to mess up a modern computer so that it requires a complete re-install rather than just a quick on-off of the power switch. Together this things seem to have led to a severe drop in the number of kids who are learning to programme. Of course they aren't helped by the focus of IT lessons in schools towards knowing how to use office software rather than teaching computing skills.

Having been involved in university lab classes and marking assignments over the last decade, it is clear even to me that most students arriving for an undergraduate course in computing have very few existing skills. Unfortunately they tend to graduate without learning too many more. Yes they can knock up a programme to solve a particular assignment, but often they pay no attention to details such as maintainability or efficiency (time or space). Let's just say that if I had to build up a team of programmers I doubt I'd be willing to hire most current computer science graduates, given the level of programming ability I've seen. Now I'm not really in a position to affect more than a few students by giving constructive feedback on assignments etc. Fortunately there are plenty of other people in the UK who agree that the level of computing knowledge among today's kids has fallen so far that we are in danger of not producing enough qualified graduates. Their solution to the problem is the Raspberry Pi.

I've been following the Raspberry Pi project for a while, and when they went on sale at the end of February I got my order in at the first possible moment. Due to the overwhelming demand in the device the websites of the two distributors were almost brought down. Anyway I must have been one of the earliest through the ordering process because my Raspberry Pi was one of just 2,000 that have currently been sent out to customers. So what exactly is a Raspberry Pi?

Put simply a Raspberry Pi is a fully fledged computer. It has all the same fundamental components as any regular desktop computer but costs, wait for it, just $35 and is the size of a credit card! The idea being that it is as cheap to kit out an entire class with a Raspberry Pi each as it would be with a textbook each. The computer has 256MB of RAM (not all of it is available as some is used by the GPU), uses a 700MHz ARM CPU (similar to that which you'd find in a smartphone), and an SD card for storage. All you need to do is add a keyboard (and mouse if you are using a GUI), a display, and then power it using a mobile phone charger. For a display you can use either HDMI or composite which allows you to plug it into old and modern TV's as well as modern computer monitors (via a HDMI to DVI-D cable). The SD card contains the whole operating system and is easy to re-image (i.e. recreate) if it gets messed up (it took about 30 seconds for me to set up my card using the default Debian distribution).

The idea then is to get these into schools were kids can learn to programme and about how computers work without worrying about messing up a family PC, or a PC required for standard ICT lessons etc. Currently though most of the Raspberry Pi's will have been bought by people like me who are interested in technology and grew up programming simpler machines than we commonly use today. We will iron out any bugs in the hardware, and write software for the device, so that when, later in the year, a cased version is launched for schools there will be teaching material and applications available. I'll certainly try and help the community in anyway I can and for the first time in over a decade I have hope that maybe the level of computing skills I see in undergraduates might actually go up rather than down!

Oh and from a quick play this afternoon, it can run GATE! (For those who don't know GATE is how I earn my living).

Raspberry Pi

Now I know that I don't usually blog about computing things on this blog as I know the posts tend to bore a lot of you. I am, however, going to do a number of posts about the Raspberry Pi.


There are currently only about 2,000 of these things in the wild and mine arrived this morning. More details on what exactly this little thing is and why it's got me excited in later posts once I've had chance to have a play with it.

Sunday, 20 March 2011

The Never Ending Non-Story, Part III

Approximately a year ago I blogged about a particularly bad BBC news article. The "journalist" who wrote the article appeared to be trying to scare users of Windows XP into upgrading to Vista because of a change in the way hard drives were being manufactured.

Three months later I showed just what a non-story the whole thing was when I bought one of the new advanced format drives and correctly installed and used it under Windows XP. It took me a total of 10 seconds to ensure maximum performance of the drive by using the manufacturers tool to correctly align the partitions. Well it may have been a complete non-story but I seem to keep finding things to blog about it. So here is part III of the story.

I recently re-installed my machine and switched away from Windows to Ubuntu Linux. During the switch I moved all my data around to allow me to reformat all my drives to use ext4 rather than Microsoft's proprietary NTFS filesystem. For speed reasons I created the new partitions using the graphical Palimpsest utility and didn't really think about aligning the partitions manually. Palimpsest will correctly align partitions on advanced format drives but it assumes that the drive metadata will correctly report the physical sector size. Unfortunately the Western Digital Caviar Green drive that I have reports that it uses 512B clusters even though it actually uses 4K clusters. So Palimpsest used the information it was given and created badly aligned partitions. While annoying it turns out that manually creating aligned partitions is easy. The downside is that I couldn't find an easy way of doing it which didn't require a full format, so I had to empty the disk of data first.

So partly to continue the tale and partly as a reference so I don't have to figure this out again in the future here are the steps to create a single aligned partition on an advanced format drive.

WARNING: THESE INSTRUCTIONS WILL COMPLETELY DESTROY ANY DATA ON THE DISK.

Firstly you need to determine which device the disk you want to partition is available as. Palimpsest will tell you this or you could drop to a terminal and use sudo fdisk -l to list information about all the drives connected to the machine. My drive was /dev/sdd so that is what appears in the following. Make sure you replace that with the correct device information for your machine or you may end up formatting the wrong drive -- you have been warned.

Now you have the device id we can use GNU Parted to create the actual partitions. I'm assuming that the drive is currently blank with no partitions. If this isn't the case then you may need to delete the existing partitions first. I'd originally hoped I could do all this with a single command but I kept having problems with Parted not liking some of the sector offsets unless I entered them in the interactive mode. So here is a record of the Parted session, I've made the commands I entered bold to make things easier to read.
user@machine:/$ sudo parted /dev/sdd
GNU Parted 2.3
Using /dev/sdd
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit s
(parted) mklabel msdos
(parted) mkpart
Partition type?  primary/extended? primary
File system type?  [ext2]?                         
Start? 2048
End? -1
(parted) print
Model: ATA WDC WD15EARS-00M (scsi)
Disk /dev/sdd: 2930277168s
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start  End          Size         Type     File system  Flags
 1      2048s  2930277167s  2930275120s  primary

(parted) align-check optimal 1
1 aligned
(parted) quit
If you don't understand what this does then you probably shouldn't be trying it yourself, but one number does need a little explaining. I set the start sector to 2048 based on the information from Western Digital about formatting these advanced format drives.

Once you have a valid partition then it is easy to format it as follows...
user@machine:/$ sudo mkfs.ext4 /dev/sdd1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
91578368 inodes, 366284390 blocks
18314219 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
11179 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
 4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
 102400000, 214990848

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 37 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
So there you have it. Not quite as easy as using the Windows tool, but I think you will still agree a complete non-story from start to (hopefully) finish.

Sunday, 20 February 2011

The Meerkats Have Taken Over

I'm sorry I haven't had time to blog much this week. I've had a dead computer to try and rebuild and a work trip to London so it's been a busy few days.

My computer troubles started in the run up to Christmas. I was get lots of random reboots and the dreaded blue screen of death was making frequent visits. I re-installed Windows over the New Year weekend, only for the same problems to continue happening. I eventually decided that it was probably the disk controller on the motherboard that was at fault, which unfortunately involved replacing not just the motherboard but the CPU and memory as well.

I've been a Windows user since I was first introduced to a PC (a monochrome laptop some time in the early 90's which ran Windows 3.11) but I'm not a fan of Vista or Windows 7 and so had stuck with Windows XP. At work though I use a Linux distribution called Ubuntu, and I've been really impressed by how stable and easy to use it is (in comparison to distributions like Mandrake and SUSE that I tried back in the late 90's). So given that I need to re-install my main machine again I decided to take the plunge and switch to Ubuntu. I've installed version 10.10 code name Maverick Meerkat -- hence the photo which I took at a tropical house in Leeds a couple of years ago.

So far everything seems to be working properly (including the cookbook which is hosted on my main machine), and I'm not missing Windows at all! Although to be truthful I have installed WINE and I've got a Windows instance running in VirtualBox while I find replacements for a couple of pieces of software and so I can download programmes from the BBC iPlayer.

Tuesday, 15 June 2010

Shaken iPod Syndrome

Computer equipment, especially disk drives, are fragile pieces of technology and just like babies don't usually take too kindly to being shaken around. Shake a baby too hard and it will die. Shake a disk drive too hard and it will quite quickly become unreadable. For this reason I'm usually quite careful with disk drives but I've just spent 30 seconds vigorously shaking one around!

Getting out of the car on Friday night I managed to drop my iPod. There appeared to be no obvious damage to the outside and so I turned it off and didn't think anything more about it. This morning on the train I turned it on and instead of being able to play music I was met by a sad faced iPod and a horrible clicking noise. As well as the sad iPod logo it displayed a link to Apple's iPod support page. This suggested a serious hardware fault but gave a number of steps to try and recover the iPod. Of course none of the steps worked.

I've had to have my iPod repaired once before (a broken click-wheel) and so went to see how much it would cost to replace the hard drive. The company I used last time was iPodsRepaired and they are quoting £85 to replace the 60GB drive in my iPod -- that is about half the cost of a brand new top of the line classic iPod. So before deciding what to do I thought I'd have a hunt around the web to see if there were any other suggested fixes. As you can probably guess, most of the suggestions involve vigorous shaking.

When a disk drive makes that horrid clicking noise it is usually because the head is stuck and can't move properly for some reason. If you can get the head unstuck without damaging the disk platters (the bits that hold the data) then hopefully it should start working again -- at least for a while. Some people suggest deliberately dropping the iPod onto the floor (I'd guess a carpeted surface), others bashing it hard onto a desk, but many suggest shaking of some form. The fix that seems to have the most success is to take the iPod apart, remove the had drive shake it a little and then reassemble. Given that I don't have the appropriate tools to dismantle an iPod with me at work I thought I'd just try a bout of vigorous shaking anyway (dropping it seemed silly as that is what had caused the problem in the first place). So I shook it for about 30 seconds and then, with my fingers crossed, turned it on. The Apple logo appeared and then the screen lit up and there I was back at the menu!

So I wouldn't in general advise anyone to shake a hard drive but if you have a dead iPod then it certainly seems worth giving it a good shake before spending money on having it repaired. If shaking doesn't work and the drive really is dead then you can't have made it any worse so what have you to lose.

Monday, 7 June 2010

Buying Caviar By The Terabyte

Some of you may remember that back in March I blogged about a rather poorly researched/written news article on the BBC's website. The article was about a change to the way computer hard drives are manufactured, moving from 512 byte to 4K sectors. At the time I claimed that it was a complete non-story that seemed to be aimed at scaring users of Windows XP to upgrade to Vista or Windows 7. Well I now know just how much of a non-story it really was.

Having recently run out of disk space (again) I decided to add another drive to my computer. Given the difference in price between the different drives I was looking at I eventually opted to buy a Western Digital Caviar Green 1.5 Terabyte drive. The drive is clearly labeled as using the advanced format and explains how to configure the drive depending on how you will be using it. Having installed and formatted the drive I visited Western Digital's Advanced Format webpage and downloaded their recommended tool for aligning the 512 byte and 4K sectors to provide optimal performance. I loaded up the tool (a simple to use graphical affair), selected the disk to align and 10 seconds later the job was done. Ten seconds, that was all it took to align the sectors. That just shows how much of a non-story the original news article was. For anyone who can read the label on the drive there is no problem at all.

What really scares me is the amount of disk space I now have. I have three drives in my computer totaling over 2TB. Given that the first computer I used with a hard drive (I so don't miss loading programs from tape) was my Dad's laptop that would hold about 80MB of data 2TB seems insane. How times change.

Wednesday, 10 March 2010

A Non-Story

I get most of my news from the BBC's News website and I mostly trust their reporting. There are occasionally, however, articles that I know are flawed. As a user of Windows XP I read with interest yesterday's news article entitled Hard drive evolution could hit Microsoft XP users. Go away and read it for yourself then come back and carry on reading here.

You finished reading already?

Now I don't know what the "journalists" intention was when writing that article but it is a complete non-story. Microsoft have made no secret of the fact that they would love every remaining XP user to upgrade to Vista or Windows 7 but a lot of us are quite happy as we are and don't want the expense (time and money) of upgrading our perfectly functional computers. Articles like this seem designed to try and trick unsuspecting users to upgrade in order to avoid a problem that doesn't even exist.

Okay so the change to 4K sectors on hard drives is a bit of an issue. Basically you need to ensure the logical clusters that the operating system writes to the disk align with the physical sectors the disk is constructed from. If they align the disk performs as expected, if they don't then you see a performance drop. I won't go into the details here but if you want to know the technical stuff try reading this informative article. Of course it isn't as if the manufacturers of hard drives haven't thought about this. They don't want to see their products bad-mouthed in the trade press if they under perform. So far the only company to release a disk using this advanced format is Western Digital and they provide two solutions that make the problem disappear. One is a bit of a hack and involves setting a jumper on the disk drive to force it to map a single partition to starting at the beginning of a 4K sector. It's a hack because the drive basically lies to the OS and stores data in a slightly different place. Also it only works if you have a single partition on the disk. The more satisfying solution is to ensure that all partitions start correctly on a 4K boundary and they provide a little utility to do this for you. If you use either of these solutions then you should see the full performance of the drive even under Windows XP. They also make it clear on the label on the drive that if you are using XP you need to apply one of these solutions.

If Western Digital can provide such an easy solution then I'm sure the other hard drive makers will as well. So as I said it is a complete non-story aimed, I believe, at trying to scare people into upgrading away from Windows XP. Maybe the BBC need to take a closer look at the stories their "journalists" write before allowing them to be published on their website.

Wednesday, 7 October 2009

Out of Sync

Well I spoke too soon when I wrote the last blog post. While the encoded videos had the right framerate when I actually tried to watch one, the audio and video were out of sync. AAAAAAAAAAAAAAAAAAAAAARGH!

So the ffdshow filters may not drop frames but something was still going wrong so I decided to have another look at the InterVideo codec that is used by the DVD player software (I use WinDVD, specifically version 8 which was developed by InterVideo although new versions are now branded as Corel) and which was originally decoding the MPEG-2 files before all this trouble started. My wild guess was that there would be a way to force it to output all the frames even if that meant running slower than real time. I couldn't find anything on the web so instead started digging around in the registry.

I eventually came across the HKEY_CURRENT_USER\Software\InterVideo\DVD8 registry key. This has a DWORD value called NOVideoDrop which was set to 0 which I assume means false. Changing this to 1 didn't make any difference during the encoding but I felt I was getting closer to a solution. Next to the key for WinDVD 8 there is a Common folder which contains sub folders called AUDIODEC and VIDEODEC which I assume stand for audio and video decoder. The VIDEODEC folder contains sub folders for a number of programs including Windows Media Player and Windows Media Encoder. So I took a guess and added the NOVideoDrop entry to the folder for the encoder and hey presto I now always get 25 fps and the video and audio are in sync!

So to summarise, to make sure that the MPEG-2 decoding does not drop frames when using the InterVideo MPEG-2 codec add the following two DWORD entries to the registry, setting the value of both to 1.

HKEY_CURRENT_USER\Software\InterVideo\Common\VIDEODEC\cscript\NoVideoDrop
HKEY_CURRENT_USER\Software\InterVideo\Common\VIDEODEC\wmenc\NoVideoDrop

The first entry makes sure that the command line interface (which is run via cscript) encodes without dropping frames. The second entry does the same for the main graphical interface to the Windows Media Encoder. Of course if you are using a different program then you may need to add the NoVideoDrop DWORD in other folders as well.

Monday, 5 October 2009

A Realtime Headache

UPDATE: The solution in this post was actually flawed in that the audio and video in the compressed videos ended up out of sync. See this post for my, hopefully, final solution.

I've spent a lot of time over the last few days banging my head against an annoying computer problem. I seem to have finally figured it out and so I thought I'd blog about it in case anyone else has a similar problem.

I've been slowly transferring a whole bunch of old VHS tapes on to the computer using a USB MPEG-2 encoder (specifically a Dazzle USB capture device). This produces large MPEG-2 files which are ideal for burning as a normal DVD. Sometimes though I'll have a bunch of short clips that are not really suited to putting on a DVD. As the MPEG-2 file format is relatively uncompressed even short clips can be quite large and so further compression is a good idea.

Now for reasons that are too complex to go into here I've been converting the MPEG-2 files to Windows Media Video files (actually to the VC-1 standard, using the WMV9 codec, which is the basis of the encoding on HD-DVD and Blu-ray disks) using a command line interface to the Windows Media Encoder. This has worked flawlessly for well over a year and then mysteriously broke about a fortnight ago.

Living in the UK the videos are in the PAL format and so I've been producing 25fps MPEG-2 files and keeping the same framerate when compressing further. When the encoding finishes the command line script produces a summary of what it has done, which includes the expected and actual framerate. They should both be 25fps -- 25 frames coming in each second and 25 frames going out. Strangely about a fortnight ago the actual framerate started fluctuating wildly. I tried encoding the same file a number of times and saw framerates varying from 8 to 19 but nothing approaching 25. Such weird framerates meant that the resulting videos were completely unwatchable.

I assumed that the problem was with the encoding of the video given that I could watch the original MPEG-2 file without any problems. So I reinstalled the Windows Media codecs and the encoder software all to no avail. I tried reinstalling the DVD software as I know that is used to read the MPEG-2 files. Still no joy. In the end I decided I'd do a complete format and reinstall of Windows. Annoyingly that still didn't work.

It turns out that the codec I was using to decode the MPEG-2 file works in realtime. That is it drops frames to make sure the video and audio are in sync. Now I can play a DVD (and hence MPEG-2 files) on the computer without any problems. But when encoding the files I'm both playing and encoding at once and that pushes the CPU usage high enough for frames to be dropped. What I can't figure out is why it suddenly became a problem. I'm assuming that something had switched the codecs being used but from what and why I don't know.

Anyway the fix was to find a non-realtime MPEG-2 codec. Fortunately the free ffdshow codecs will decode MPEG-2 fully irrespective of CPU load. So finally after about two weeks of banging my head against the problem I can get back to encoding videos again at the correct framerate.

The only problem seems to be that if I open an MPEG-2 file in Windows Media Player it no longer respects the aspect ratio and so plays wide screen footage as 4:3. Maybe there is a setting in ffdshow that I'm missing but it's a small price to pay especially as I can watch the files using normal DVD software at the correct aspect-ratio.

Tuesday, 10 February 2009

My Desk at Work

In a blatant attempt to make some of you jealous I thought I'd show you my desk at work as it looked this morning. Yes that is a 22 inch widescreen monitor! Both monitors are being driven by my brand new desktop machine (for those that care it's a Dell Precision T5400, Intel Xeon (2GHz Quad Core) with 4GB of RAM).

Unfortunately not long after I took the photo I decided to install Ubuntu and now have a machine that will only boot into text mode as X refuses to start properly.

Ah well, it all looks good even if it isn't currently very useful!

Saturday, 16 February 2008

More Computer Woes

I don't know what it is with me and computers at the moment but my work laptop is currently out of commision. It won't turn on as the battery is flat, and for some reason the power adapter seems to have died.

It is a good job I've finally got my main home desktop PC rebuilt and working again!

Sunday, 10 February 2008

Changing Computer Standards

Well I've finally got around to buying new parts to rebuild my dead computer. The really annoying thing is that a lot of the old parts still worked but the hardware standards have changed rendering many of the parts useless.

The problem with the old machine was the motherboard, so that needed replacing. So replacing the motherboard also involved replacing the CPU, graphics card, memory and power supply, all because the standards currently in use (and hence the connections on the motherboard) have all changed since I bought my last motherboard.

Not only is this change in standards expensive but it means I now have a whole host of perfectly OK parts which I don't have any use for.

Ah well, at least I now have a nice, fast, up-to-date PC to play with!

Saturday, 19 January 2008

Dead Computers

Today has not been good day for computers in our house. My main desktop computer has been slowly failing for a while. I thought the problem was simply that I hadn't reinstalled Windows for a while (a necessary evil) so when it got to the point where it would no longer boot without blue screening I bit the bullet and tried to re-install Windows. Windows would not install. Firstly it looks as if my hard disk has physically failed (the S.M.A.R.T. system is reporting that the disc is failing), but replacing the disk and Windows still won't install as it can't format or copy files to the disk. So I'm assuming the drive controller on the motherboard is also failing. So I need a new computer.

To get at the data on the second disk in my desktop I thought I'd make use of an older computer I have sitting around. Unfortunately it hasn't been booted in about 18 months and I think the build up of dust was enough that when I turned it on there was a nasty pop and a cloud of dust and smoke. While it will now turn on and run the fans there is no video output and no post beep noise.

So I guess that's two dead computers, quite an expensive afternoon! If anyone has any suggestions on which CPU/motherboard/graphics card etc. I should buy when rebuilding please do leave a comment.