Interesting Tech Projects
Posts tagged ubuntu
The Progress of Linux
Mar 4th
Back in 1998 I tried installing RedHat 6 on a spare PC. When the desktop loaded it was, ummm, wobbly. I then spent the best part of the next two weeks fighing with X configuration files setting obscure items such as front and back porches in a futile attempt to stabilize the display so it would be usable. I gave up.
Fast forward to March 2011 and Ubuntu 10.10. I’ve used lots of different versions of Ubuntu since 2006 on a variety of machines including for CNC control, but the last time I installed in a dual boot system was two years ago. Ubuntu 10.10 works fine in a virtual machine inside Windows 7 but I wanted to run it at full speed. More >
Installing Ubuntu Netbook Remix on an Acer Aspire One
Jan 14th
The Acer Aspire One is a pretty nice netbook – for a reasonable price you get 1Gb RAM, 160Gb hard drive, 1024 x 600 screen and 5 1/2 hours of battery life. However it comes with Windows XP or Linpus, which is a customized Linux distribution from Acer. Neither of these options appealed to me. In particular the Aspire One user forums seemed to have a lot of postings on limitations with Linpus.
Enter Ubuntu Netbook Remix (UNR), which is a special version of Ubuntu 8.04 for netbooks. Essentially it is the same as Ubuntu 8.04, but with some additions that make it easier to use on a small screen with limited height. Because netbooks don’t have optical drives it presents a challege to get a new operating system installed. Below is the process I found to work for me. I used Ubuntu on a desktop PC for all the steps.
Firstly note that I tried and failed to get a USB hard drive to work. I partitioned and formatted it every way I could and couldn’t get it to work. I managed to the the UNR installer to boot, but it always failed with “sdb: unknown partition table”. The process only seems to work with USB flash drives. I used a Sandisk Cruzer Micro 4Gb.
1. Download UNR 1.0.1 image from:
http://oem-images.canonical.com/unr/unr-1.0.1.img
2. Plug in USB drive and identify device location. Mine was /dev/sdb mounted to /media/disk.
3. At command prompt:
sudo dd if=./unr-1.0.1.img of=/dev/sdb bs=1024
4. fdisk -l will then show:
Disk /dev/sda: 250.0 GB, 250000000000 bytes
255 heads, 63 sectors/track, 30394 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x88000000
Device Boot Start End Blocks Id System
/dev/sda1 1 8 64228+ de Dell Utility
/dev/sda2 9 1314 10485760 7 HPFS/NTFS
Partition 2 does not end on cylinder boundary.
/dev/sda3 * 1315 7769 51849787+ 7 HPFS/NTFS
/dev/sda4 7770 30394 181735312+ 5 Extended
/dev/sda5 7770 23109 123218518+ 7 HPFS/NTFS
/dev/sda6 23110 29908 54612936 83 Linux
/dev/sda7 29909 30394 3903763+ 82 Linux swap / Solaris
Disk /dev/sdb: 4016 MB, 4016045568 bytes
124 heads, 62 sectors/track, 1020 cylinders
Units = cylinders of 7688 * 512 = 3936256 bytes
Disk identifier: 0x8ef631df
This doesn't look like a partition table
Probably you selected the wrong device.
Device Boot Start End Blocks Id System
/dev/sdb1 ? 274784 529564 979374166 66 Unknown
Partition 1 has different physical/logical beginnings (non-Linux?):
phys=(734, 123, 14) logical=(274783, 70, 21)
Partition 1 has different physical/logical endings:
phys=(120, 143, 6) logical=(529563, 65, 22)
Partition 1 does not end on cylinder boundary.
/dev/sdb2 ? 448668 961719 1972168331 7 HPFS/NTFS
Partition 2 has different physical/logical beginnings (non-Linux?):
phys=(187, 180, 14) logical=(448667, 16, 52)
Partition 2 has different physical/logical endings:
phys=(784, 0, 13) logical=(403059, 76, 1)
Partition 2 does not end on cylinder boundary.
/dev/sdb3 ? 426615 680707 976730017 7d Unknown
Partition 3 has different physical/logical beginnings (non-Linux?):
phys=(252, 59, 46) logical=(426614, 84, 39)
Partition 3 has different physical/logical endings:
phys=(139, 118, 4) logical=(122048, 22, 28)
Partition 3 does not end on cylinder boundary.
/dev/sdb4 ? 36178 37261 4161536 6f Unknown
Partition 4 has different physical/logical beginnings (non-Linux?):
phys=(370, 101, 50) logical=(36177, 96, 57)
Partition 4 has different physical/logical endings:
phys=(10, 114, 13) logical=(37260, 47, 62)
Partition 4 does not end on cylinder boundary.
Partition table entries are not in disk order
Don’t worry about the errors – they don’t seem to be important.
5. Unmount the USB drive by right-clicking on the icon on the desktop.
6. Plug USB drive into Aspire one and boot. At Acer screen press F12 to get to the boot menu.
7. On the boot menu the USB drive will appear twice:
USB Floppy Drive
USB CDROM
This because there is a second hard-coded, read only partition that appears as a CDROM drive. Choose the floppy drive option. Press Enter at the prompt and UNR will now install. Follow the on-screen instructions.
8. At this point you probably want to change the name of the computer. It seems to default to the name of the first user. Go to Administration -> Network, click on “Unlock” and enter your password.
9. Click on the General tab and enter a new name in the Hostname field.
10. Reboot. Clicking on “Quit…” didn’t seem to work. Holding down the power button for a second or so brought up the shutdown options screen. Note that after the reboot the “Quit…” option started working, so I guess the reboot is necessary.
Cleaning Up Your USB Drive
1. Install GParted from Add/Remove…
2. Go to System -> Administration -> Partition Editor
3. Plug in the USB drive and select it from the list at the top right (for example /dev/sdb).
4. Right click on the drive on the desktop and unmount it.
5. Select the partition (there will only be one for some strange reason) and delete it. Click on Apply to confirm.
6. Create a new FAT32 primary partition. Click on Apply.
7. Remove and insert the USB drive to mount it.
Part Design Tools and Workflow
Nov 19th
After spending quite some time trying different pieces of software I have come up with a collection and a workflow that I think will fit my needs.
I wanted to be able to accurately design parts in 3D, see how the parts will fit together to make sure they are right, and produce traditional engineering drawings of the parts, if possible. Also it is necessary once a part has been designed to be able to convert it into toolpaths, which is the path that a drill bit would move along to make the part. The toolpaths are represented using g-code which can be processed by EMC2 to move the stepper motors. Another requirement was to use free software where possible to try and keep costs down.
I start with Alibre Design Xpress. This is an excellent 3D design program that is also free. However free comes with a price, that is limitations. The key limitations are a limited number of export options and limited number of parts in an assembly. An assembly is a collection of parts fitted together to build something. However with enough perseverance these limitations can be overcome. In Design Xpress I created a simple test part that contains two holes for bolts:
Creating this 2D profile is very quick and easy. The holes are 0.174″ in diameter, which should be big enough for a #8 bolt. Next step is to extrude the 2D profile into a 3D part:
The part can be rotated and viewed from any angle. I decided to make the part 0.250″ thick. At this point Design Xpress can produce various numbers regarding the part, depending on the material it is made of. Choosing “Wood – southern pine” resulted in:
Volume = 1.480147117 in³
Mass = 1.576592260E-2 kg
Surface Area = 1.453202145E1 in²
Pretty interesting.
The software only allows five unique parts in an assembly, unless you register then it is 10. However this is quite a severe limitation in my opinion. Fortunately there is a way around this. Alibre has written an add-on called 3D Publisher for Google Sketchup that allows parts to be exported in Google’s Sketchup format. It’s not a requirement that the parts be uploaded to Google’s 3D Warehouse. Instead the exported parts can be saved to your hard drive. The following screenshot shows an assembly of two of the test parts along with size #8 bolts and nuts. The exact bolts are ANSI PHN, CRSHD TYPE II, B18.6.3, .164-36 UNF, 0.75, which gives an indication of the accuracy expected from designing parts and assembling them.
Again, this assembly can be rotated and the parts can be made transparent, along with plenty of other options. There is even a free add-on for Google Sketchup that provides a ray tracer. Assembling two parts confirmed my intention that the holes will line up.
With a few mouse clicks Design Xpress can convert the 3D part into traditional engineering drawing:
This can be printed out, emailed, etc. and provides all the measurement details for someone else to reproduce the part without having access to electronic files. The drawing can also be exported as a DXF (without the annotations), which is needed for the next step.
I found an excellent application to generate toolpaths for a part called CamBam. It takes a DXF file and provides an easy to use user interface in which you can select which items are profiled, drilled, pocketed, etc. Once the DXF file is loaded into CamBam all the unneeded views are deleted to leave the original 2D profile. For this part I added a 2.5D profile operation to cut the outline of the shape and two sprial drill operations for the holes:
Cam Bam then generates the g-code which can be loaded in the AXIS interface in EMC2:
This process may seem convoluted, and it requires both Windows and Linux, but all the software can be obtained for free and is high quality. I haven’t completed my CNC machine yet, but I can watch the part being made in the AXIS interface without having the motors connected. I would expect that all the software will work in a Virtual Machine in Linux, however note that Design Xpress requires a lot of RAM to run (300Mb I believe).
How To Install EMC2 on Unbuntu 7.10 Gutsy From Scratch
Nov 7th
April 2008 – Update – I’ve modified the instructions so that EMC2 can now be run as a user.
April 2008 – Update – Fixed some mistakes.
The following instructions will describe how to install the latest version of EMC2/LinuxCNC in Ubuntu 7.10 Gutsy Gibbon.
Why would you want to do this? You would do this if you don’t want to wait for new .deb files from the EMC2 team or you want to install EMC2 in the latest version of Ubuntu to take advantage of all the new features. The alternative is to use the Ubuntu 6.06 LTS live CD, install and then either stick with the software versions supplied or upgrade to the latest versions (such as device drivers, Gnome, Xorg, etc.), which is a big task itself.
Why would you not want to do this? I don’t recommend following these steps if you are unfamiliar with Linux and the shell/command prompt. It will either be a great learning experience or a very frustrating waste of time.
I am sure these steps can be simplified and improved, however they were created from many hours of experimenting and following dead-ends. I wanted to try and give you exactly what I ended up using, rather than an optimization. For example I’m sure that not all the reboots are needed, but they only take 60 seconds on my PC anyway.
These steps should work on a stock installation of Ubuntu 7.10, however I don’t make any claims that they will work for anyone else. If the software didn’t install correctly and the motors go crazy and move something that destroys your house, don’t blame me – these instructions are provided “as is” and without any warranty. Use at your own risk. If you spot a mistake please let me know and I will update the instructions.
Where you see “andy” replace with your own username, unless it is also “andy”. 🙂
‘$’ represents the prompt, to show you where the start of lines are. Don’t enter this, just what follows.
The process looks like this:
Get a vanilla kernel and patch it with RTAI support.
Test kernel.
Build and test RTAI modules.
Build EMC2.
Enable universe repository in /etc/apt/sources.list. Open a terminal window and then:
$ sudo apt-get update
$ sudo apt-get install build-essential libncurses5-dev kernel-package
$ cd /usr/src
$ sudo wget -c http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.22.tar.gz
$ sudo tar xzvf linux-2.6.22.tar.gz
$ sudo mv linux-2.6.22 linux-vanilla-2.6.22
$ sudo ln -s linux-vanilla-2.6.22 linux
$ cd linux
$ sudo cp /boot/config-2.6.22-14-generic .config
$ sudo make menuconfig
At this point a menu will appear. Make the following choices:
Loadable module support > Module versioning support (N)
Loadable module support > Set version information on all module symbols (N)*
Processor type and features > Preemption model > Preemptible kernel (low latency desktop)
Processor type and features > Symmetric multi-processor support (N)**
Processor type and features > Local APIC support on uniprocessors (N)
Power management options (ACPI, APM) > ACPI support (N)
Power management options (ACPI, APM) > APM BIOS support (N)
Power management options (ACPI, APM) > CPU frequency scaling (N)
Kernel hacking > Compile the kernel with frame pointers (N)
* only if you have it in the menu
** only if your PC is not dual or quad core
Download rtai-3.6-test1.tar.bz2 from www.rtai.org (click on “RTAI Repository” link) to the desktop.
$ cd /home/andy/Desktop
$ bunzip2 rtai-3.6-test1.tar.bz2
$ tar xvf rtai-3.6-test1.tar
$ cd /usr/src/linux
$ sudo patch -p1 < /home/andy/Desktop/rtai-3.6-test1/base/arch/i386/patches/hal-linux-2.6.22-i386-1.10-09.patch
$ sudo make-kpkg --initrd --revision=1 --append-to-version=-realtime kernel_image kernel_headers
Some questions may appear which need to be answered (answer Y to any others that appear):
Interrupt pipeline – Y
Interrupt pipeline maintain backwards compatibility – Y
Interrupt pipeline debug – N
Now go and do something else for a while. On my P4 1.6GHz PC the kernel took 2 hours and 50 minutes to build.
$ cd ..
$ sudo dpkg -i linux-image-2.6.22-realtime_1_i386.deb
$ sudo nano -w /boot/grub/menu.lst
Find the line that looks like:
hiddenmenu
and change it to:
#hiddenmenu
If your PC already dual-boots (for example Ubuntu and Windows) then the hiddemenu is probably already commented out (using the ‘#’).
Save and exit nano.
Reboot and choose the realtime kernel from Grub menu.
Enter:
$ uname -a
and you should get something like:
Linux pepper 2.6.22-realtime #1 PREEMPT Sun Oct 28 10:54:43 MST 2007 i686 GNU/Linux
Make sure everything works ok (browsing, editing files, etc.)
Now we need to build the RTAI modules. This has to be done while running the realtime kernel we just built and booted into.
$ cd /home/andy/Desktop/rtai-3.6-test1
$ make menuconfig
Again a menu appears. Make the following selections:
Machine (x86) > Number of CPUs (enter the number you have here)
Exit and save configuration
$ make
$ sudo make install
Reboot back into the realtime kernel.
$ cd /usr/realtime/bin
$ sudo nano -w rtai-load
Change the first line from:
#!/bin/sh
to:
#!/bin/bash
and save. Then:
$ sudo nano -w /etc/init.d/create-rtai-devices.sh
Enter:
#!/bin/bash
mknod -m 666 /dev/rtai_shm c 10 254
for n in `seq 0 9`
do
f=/dev/rtf$n
mknod -m 666 $f c 150 $n
done
Save. Then:
$ sudo chmod 755 /etc/init.d/create-rtai-devices.sh
$ sudo update-rc.d create-rtai-devices.sh defaults
Reboot back into the realtime kernel.
Then test the RTAI support with:
$ cd /usr/realtime/testsuite/user/latency
$ sudo ./run
$ cd /usr/realtime/testsuite/user/preempt
$ sudo ./run
$ cd /usr/realtime/testsuite/user/switches
$ sudo ./run
$ cd /usr/realtime/testsuite/kern/latency
$ sudo ./run
$ cd /usr/realtime/testsuite/kern/preempt
$ sudo ./run
$ cd /usr/realtime/testsuite/kern/switches
$ sudo ./run
These tests spit out lots of numbers. The thing we are looking for here are kernel panics, system crashes, etc. Also make sure there are no overruns in the tests that display an overruns column.
If you get something like:
insmod: error inserting '/usr/realtime/modules/rtai_hal.ko': -1
Operation not permitted
then try:
$ sudo nano -w /boot/grub/menu.lst
and find the kernel line for the realtime kernel. Add “lapic” to the end of it and reboot, then run the tests again. For example:
kernel /boot/vmlinuz-2.6.22-realtime root=UUID=45d21232-cf0d-cc3d-87ce-8453214d7a6f ro quiet splash vga=794 lapic
Once you have the real time tests working continue with:
$ sudo nano -w /etc/modprobe.d/emc2
Enter:
install parport_pc /bin/true
Save then reboot back into the realtime kernel. Now to build and install EMC2.
$ sudo apt-get install python python-imaging python-imaging-tk python-numarray python-dev
$ sudo apt-get install tcl8.4-dev tk8.4-dev yapps2
$ sudo apt-get install libgtk2.0-dev libpth-dev libreadline5-dev libxmu-dev libxaw7-dev libglu1-mesa libglu1-mesa-dev libgl1-mesa-dev
$ sudo apt-get install pciutils-dev bwidget cvs latex2html preview-latex-style libaiksaurus-1.2-0c2a libgnomeprintui2.2-dev
$ sudo apt-get install imagemagick lyx
$ cd /usr/src
$ sudo dpkg -i linux-headers-2.6.22-realtime_1_i386.deb
$ cd ~
$ cvs -z5 -d:ext:anon@cvs.linuxcnc.org:/cvs co emc2
$ cd emc2/src
$ ./configure --with-realtime=/usr/realtime --with-kernel-headers=/usr/src/linux-headers-2.6.22-realtime
$ make
$ sudo make install
$ sudo nano -w /etc/security/limits.conf
Add the line:
* hard memlock 20480
Save and reboot into the realtime kernel.
To run EMC:
$ /usr/local/bin/emc
A window should appear with a choice of configurations. Choose Axis -> Sim and the Axis window should open. Congratulations EMC2 is now running!
Note that when running the realtime kernel the computer may not power itself off when the shutdown option is chosen. This is because the power management options have been disabled in the kernel. On my PC I wait a couple of minutes after the screen goes blank then press the power button on the front of the PC. This turns it off.
Windows XP Running Inside Ubuntu 7.10 Gutsy Gibbon
Oct 30th
I am still working on getting EMC2 working in Ubuntu 7.10, but in the meantime I decided to give Virtual Box a try. The Virtual Box website has deb files for Ubuntu so installation was easy. I created a new virtual machine with 192MB of RAM and 6Gb of drive space and stuck the XP SP2 CD in the drive and started the machine. From that point the XP installer went through it’s machinations until I had the desktop running.
I am pretty impressed. The speed of XP is almost as fast as if it were running on it’s own. It’s perfectly usable, has network access and can resize the desktop to match the window on the fly. It automatically captures the mouse pointer when it goes over the window, and it is possible to take snapshots of the PC and restore them. In other words, no waiting for XP to boot up; just go straight to the desktop.
Ubuntu Splash Screen
Oct 22nd
Well…the splash screen was not centered. I think this was because the installation detected my monitor as “generic plug and play” with more limited capabilities than it really has. I changed the display settings in Gnome so I can get 1152 x 864 at 75Hz, but this left the splash screen off center. Here is the fix:
Edit /etc/usplash.conf to set the correct x and y resolution.
Run: sudo update-initramfs -k all -u
The update-initramfs needs the “-k all” option to update all kernels. In my case I have the generic and real time kernels.
Linux Real-time Kernel Installed
Oct 19th
EMC2 requires a real-time kernel (which Windows XP and Vista are not). Installing it on Ubuntu 7.10 was pretty simple.
- Open a terminal window
- Run
sudo apt-get install linux-rt
and wait - Reboot
After the PC rebooted Gnome complained that the theme manager wasn’t working. Another reboot fixed that problem. Running:
uname -v
gives:
#1 SMP PREEMPT RT Mon Oct 15 01:05:51 GMT 2007
So the real-time kernel is now installed and working. I will play around with the desktop for a while to make sure it is stable before proceeding further.
Ubuntu 7.10 Gutsy Gibbon
Oct 18th
Today the latest version of Ubuntu was released – version 7.10. I am hoping to use this with EMC2 a.k.a. LinuxCNC for controlling my CNC machine. Why? Because Linux offers a real time version of the Kernel. The alternatives are Windows with Mach2/3 (which is not free) or DOS and TurboCNC (also not free). Windows is not a real time operating system, so the only software that works properly has to code around this. As far as I know that is the Mach programs. I will still need Windows however for DXF and CAM applications.
Downloading Ubuntu from the mirrors was painfully slow, and attempting to using the official torrent file resulted in “connection refused”. I presume a large number of people are also downloading the OS today. So I used the torrent file on this page. I pulled down the ISO image in two hours. Not bad. Burnt it to CD, added a second hard drive to my desktop PC (not required, but I chose to do it this way), created an image of the Windows partition and booted with the CD in. The install was pretty smooth. Only a couple of glitches. Grub failed to boot because I needed to enable the second drive in the BIOS. And the package manager decided to not install anything, which was quickly solved with this information in this thread.
Hopefully I will be able to get the real time kernel and EMC2 installed. If so I will post instructions, otherwise I will probably have to switch to 6.06 a.k.a. Dapper Drake.