Welcome to Bits By The Pound! You have reached a page where technology enthusiasts can talk about their passion.
Spewing Forth Tech Stuff
Welcome to Bits By The Pound! You have reached a page where technology enthusiasts can talk about their passion.
This note explains how to set up Eclipse for developing images for the EZ430-F2013. This note assumes that the development environment is set up in Ubuntu 12.10.
This note relates to:
Install Command-Line Tools
The installation of command-line tools to support the EZ430-F2013 development kit is covered in a different note. Please refer to the note Use EZ430-F2013 in Ubuntu to complete this step.
In Eclipse, the packages that support C/C++ development are named the C Development Toolkit, or CDT. Portions of the CDT are required to enabled a development environment for the EZ430-F2013:
To install the CDT, in Eclipse:
Create a C project to use MSP-GCC
Create a C project:
Set up new project to use MSP-GCC:
Once the project is set up correctly, it should be possible to build an image from source by right-clicking on the project and selecting “Build Project”. In the console, the output of the build should look something like the following:
Set Up Debugger Configuration
To debug the project directly from the IDE, a debugger must be configured. The following steps are used to configure a debugger to use the command-line tool “msp430-gdb”:
Running the debugger from the IDE is the equivalent to running “msp430-gdb” at the command-line. It first requires that “mspdebug” runs to bridge to the EZ430-F2013 development kit. This can be perform from a terminal or from an Eclipse run configuration (next section).
To run the debugger, select from the menu “Run” > “Debug Configurations…”, choose the debugger create and press the button “Debug”.
Run MSPDEBUG from Eclipse
It is possible to run “mspdebug” from Eclipse using a run configuration. Here are the steps to set it up:
Once set up as an external tool, to run “mspdebug”, select “Run” > “External Tools” > “External Tools Configurations…”, click on the program called “MSPDebug” and press the “Run” button.
There are many short-cuts in Eclipse to run external tools and debug configurations without using the tedious menus. One of these short-cuts are located on the main tool bar. These short-cuts makes it very convenient to start “mspdebug” and “msp430-gdb”. The ability of developing and debugging using the EZ430-F2013 directly from Eclipse greatly reduces the development cycle of an image targeted for the MSP430.
This note explains how to install the command-line tools in Ubuntu to compile, load and run images destined for the Texas Instrument EZ430-F2013.
The TI EZ430-F2013 is a USB development environment for small dongles that host a TI MSP430 micro-controller (MSP430-F2012 and MSP430-F2013).
This note relates to:
The packages required to work with the MSP430 are available from the main repositories.
Verify Drivers for EZ430-F2013
Insert the EZ430-F2013 in a USB port. Then, run “dmesg” to verify that it was detected correctly:
The output should end with a set of lines that looks as follows:
The report from “dmesg” shows that the development kit was mounted to /dev/ttyUSB0. For the remainder of the note, this value is assumed. However, you might need to adjust this value to fit your particular installation.
Writing a program for MSP430-F2013
Create a new source file.
Paste the following code:
The code above drives the LED found on the MSP430-F2013 to emit “SOS” in Morse code. A number of definitions are already declared in the file “msp430f2013.h”. Many header files relating to the MSP430 can be found in the directory /usr/msp430/include.
Compiling and Linking Program
Compiling and linking programs/images for the MSP430 is done by using “msp430-gcc”, which is a version of “gcc” that targets the MSP430 micro-controller. Most options available for “gcc” are also available for “msp430-gcc”.
Compiling using “msp430-gcc” yields object files, as with “gcc”. However, invoking the linker produces *.elf files, which can be loaded on the MSP430-F2013 via the development kit (EZ430-F2013).
Following the example started above, the two lines required to produce an object file from the source code, and then link into an image:
A command line utility called “mspdebug” is used to perform most operations that involves the EZ430-F2013 development kit.
First, insert the EZ430-F2013 in a USB port and verify that it is mounted to /dev/ttyUSB0 (see steps above).
When invoking “mspdebug”, one must specify the device that the EZ430-F2013 is mounted as.
This command opens a shell where a number of commands can be sent to the development kit. To leave the shell, press CTRL-D.
Loading Image on MSP430-F2013
Loading an image on an instance of MSP430-F2013 via the development kit is accomplished by using “mspdebug”:
Following the example above:
Via the EZ430-F2013, one can debug the program loaded in the MSP430, including single-step execution, via the “gdb” debugger provided by the MSP430 packages. The command-line utility “msp430-gdb” is similar to “gdb” but designed for the MSP430 micro-controller. However, “mspdebug” is needed to bridge “msp430-gdb” to the MSP430 via the EZ430-F2013 development kit.
The command “gdb” within the shell provided by “mspdebug” start a server that listens to commands from “msp430-gdb” and forwards them to the EZ430-F2013 development kit. When “msp430-gdb” connects to “mspdebug”, it provides a shell similar to the one provided by “gdb”.
The command required to start the server is:
In a different terminal, attach the debugger with the following command:
The commands available in “gdb” are also available in “msp430-gdb”:
To continue the example started above:
Debug using X Debugger: ddd
If X is available, one can use “ddd”, which is a GUI application to simplify the use of gdb.
To use “msp430-gdb” via “ddd”, one must first start “mspdebug” and then invoke “ddd” by specifying “msp430-gdb”. To continue the example in this note:
Using the TI EZ430-F2013 development kit with an Ubuntu platform is a snap since all the tools required are readily available in the main repositories. Furthermore, anyone familiar with gcc and gdb can easily transition to the line of tools designed for the MSP430 since the commands and options are almost the same.
In Ubuntu, as in other flavours of Linux, utilities like “file” detect the type of files by using an algorithm based on “magic numbers”. This algorithm looks for fixed fields in the examined file. Lately, some of these utilities have failed in detecting the proper type for some encountered MP-4 files which do not contain the “magic numbers” expected of a MP-4 file.
This note presents a method to update the magic files to detect new file formats. More specifically, the method concentrates on updating the magic files to recognize the new MP-4 format.
This note relates to:
This note uses a number of examples to illustrate the fix. In these examples, two files are used, a MP-4 file recognized by the file utility named “known.mp4″; and, a MP-4 file not recognized by the utility named “unrecognized.mp4″.
Exploring the problem
For the recognized file, the following sequence is experienced:
As seen above, the format of the file is recognized correctly and the mime-type is return appropriately. Here is the sequence for the file which is not recognized correctly.
In the case of the file which is not recognized, a generic mime-type is returned.
Differences between files
Programs from the FFMPEG or libav projects can be used to find out details of video files. Using avprobe (or ffprobe), it is possible to get details from each file and examined the differences.
By looking at these reports, it becomes evident that although both files are reported as MP-4, they are not reporting the same major brand.
The “od” utility can be used to look at the byte information from each files. This information is necessary to craft the magic file needed to recognized the new format.
A different file header is observed from the file that is not recognized:
In the case of the recognized file, the bytes detected are from offset 4 to 11, where “ftypisom” is recognized as belonging to a file of type MP-4. The same bytes in the file not recognized are “ftypMSNV”. The crafting of the magic numbers to recognize this new file type must be based on this latter string.
Updating Magic Numbers
This note does not explain the format of the magic number files. This topic is covered in other pages. See the references above.
In Ubuntu, updating the file /etc/magic with the proper entries is all that is required for the file utility to detect the new types. There is no need to compile the file, as in other versions of Linux. Nor is there a need to perform any reboot.
To edit the magic number file:
The following lines should be added to the magic file:
After the magic number file is update, save and close.
To test that your changes are working, perform a “file” command on the previously not recognized video file:
If the results above are not observed, then something has gone wrong.
The same problem was encountered on Ubuntu 10.04 and the fix introduced above corrected the problem. I suspect that all intervening versions of Ubuntu between 10.04 and 12.04 suffer the same problem and that the same fix applies.
After upgrading to Ubuntu 12.04 (Precise Pangolin) on a Dell Inspiron 1720, the speakers continued playing even after plugging in a set of headphones. This problem has been reported and fixed in multiple forums. However, the fix requires a model number, which can not be easily guessed. Therefore, this post is meant to help those who have a machine similar to the Dell Inspiron 1720.
This note applies to:
The fix is applied by using the following steps:
Initially, the file contained the following line:
This line must be commented out (in case you want it back) and replaced as follows:
After saving the file, rebooting the computer is all that is required.
This note explains how to add new public IP addresses, in excess of the first static IP address, to the WAN interface of a DD-WRT router. All public addresses are assigned to computers that reside within the LAN network served by the router. Therefore, network address translation (NAT) is performed between the public addresses and the addresses assigned internally. This notes is written after it was successfully performed on:
When enquiring to receive a new static IP address from my ISP, I found out that a subnet could be leased for a monthly fee. I selected a subnet containing two IP addresses which was assigned to my internet service. The new addresses were communicated using a slash notation: XXX.XXX.XXX.XXX/30.
Although a /30 subnet might suggest that four distinct addresses are available, there are only two. In fact, each subnet contains two addresses that have special meaning: the first, which is the subnet identifier; and, the last, which is the subnet broadcast address. Therefore, the first address available for assignment in a subnet is the one after the subnet identifier. For example, if the assigned subnet was 22.214.171.124/30, then the subnet identifier would be 126.96.36.199, the broadcast address would be 188.8.131.52 and the available addresses would be 184.108.40.206 and 220.127.116.11.
For simplicity in the following examples, we will assume that the assigned subnet is 18.104.22.168/30. Also, it will be assumed that the public address 22.214.171.124 is assigned to a computer that is manually set with the LAN address 192.168.1.40.
The solution is two-fold. First, assign one of the new public IP addresses to the router’s WAN interface. Then, use firewall rules to route packets to and from the desired computer within the LAN.
Although the solution calls for entering commands through the router’s web interface, I suggest you test those commands by entering them at the command line using a telnet or SSH session to your router. Once this works well, transcribing the commands to the web interface is a good way to save those changes in case the router is rebooted.
Assign Public Address
Using a web browser, open the web interface to your router. This is usually done by directing your browser to an address similar to: 192.168.1.1.
Direct your browser by selecting the “Administration” tab, followed by the “Commands” sub-tab.
In the text box titled “Commands” under “Command Shell”, enter the commands to assign the public address to the WAN interface. Use the example below as a template and substitute the addresses according to your situation:
Once this is entered in the text box, save the changes by pressing the button titled “Save Startup”.
To assign the firewall rules, the text box mentioned in the previous step is used. However, when saving the content of the firewall rules, the button titled “Save Firewall” is used instead.
In the firewall rules, one command is used to map the public address to the internal address; one command is used to map the internal address to the public address, and; one command is used to accept each port that should be forwarded.
Use the following template and substitute the appropriate addresses and ports:
The above example forwards HTTP (port 80) and SSH (port 22) requests to the internal computer.
For the changes to take effect, the router must be rebooted. Using the router’s web interface, navigate to “Administration” tab and the “Management” sub-tab. Finally, press the button titled “Reboot Router” at the bottom of the page.
This blog site already features an note on tethering the iPhone to Ubuntu (http://www.bitsbythepound.com/tethering-iphone-on-ubuntu-11-04-397.html). However, since upgrading to iOS 5.1, when the iPhone is connected to the Ubuntu platform, an error is reported stating that “Unhandled Error Lockdown”.
This note applies to:
The solution offered by this note is to:
Install Package Repository from Paul McEnery
Adjust Package Repository for use in Oneiric
I applaud the work done by Paul McEnery in providing us the tools to use the iPhone. Unfortunately, the package repository is not available for Ubuntu 11.10. On the other hand, the package repository for Natty (11.04) seems to work just fine for Oneiric. In this step, the package list is modified to point to the Natty version.
While editing the file, replace “oneiric” to “natty” and save again. The resulting file should look something like:
Install Necessary Packages
The first step of configuration is to tether the iPhone to the platform using the USB connector. Then, run the following command:
Finally, unplug and re-connect the iPhone. The error should not be reported. Instead, all services from the iPhone should be available.
Since upgrading to Ubuntu 11.10, some games that used to run perfectly using PlayOnLinux started to display unwanted behaviour. In particular, the mouse jumps from the expected position in Starcraft: Broodwar. This behaviour prevents efficient playing. Researching the Internet shows that many other games are plagued by the same problem.
This note applies to:
Many solutions are offered on the Internet which did not work on my system. However, the problem appears fixed in a newer version of Wine. The approach offered in this note is to install Wine 1.4. The latest version of Wine is not yet available via the packages offered by Ubuntu. However, the latest version (beta) is available via the WineHQ’s PPA. The following steps adds a new package repository and updates Wine to the latest version available from this repository. As an interesting note, Wine 1.4 is available via the package named wine-1.3.
After those changes, you can verify the version of the currently installed version of Wine with the following command.
Wine and PlayOnLinux are great tools. The complexity of the task performed by those tools is such that one must expected some unstable versions. This note demonstrated how a user can jump into experimental versions of Wine to access solutions earlier than pushed by the standard packages.
I have been using a Solid State Drive (SDD) for some time and I have decided to share my notes on how to do it and references I have followed. The configuration I use is to have two disks attached to my platform: the first is the SSD and holds the Operating System; the second is a magnetic drive which holds my home partition.
This note applies to:
From research, the important aspects that need to be dealt with when using a SSD are:
Each of these topics are discussed separately below.
TRIM is the process under which an operating system tells a drive that a sector is no longer in use. This is not necessary for magnetic drives and, historically, operating systems did not provide this information to the drives as it increased the amount of information traversing between a host and its drives. However, this information is crucial for SSDs as it is needed to perform proper wear leveling.
Information on TRIM can be found via these links:
In Ubuntu, TRIM is enabled via the file “fstab” located in “/etc”. One needs to find the drive associated with the SSD and add the option “discard”. To edit the “fstab”:
Then add the “discard” option to the drive concerned. In my example, the root drive is the SSD. Therefore, the resulting file looks like:
After the “fstab” file is modified, one must reboot the system for the change to take effect.
After reboot, one should ascertain that TRIM was in fact enabled. To do so, a trick provided by Nicolay Doytchev is used (link above). However, it is claimed that this trick works with ext4. One might not get expected results from other disk format.
1. Become root and move to a directory managed by the SSD:
2. Create a file with random bytes in it:
3. Get and record the disk sector address for the beginning of the file:
Note the number under begin_LBA and use it for <ADDRESS> below:
4. Access file data from disk (replace /dev/sdX for the drive you are enabling in fstab):
The result of this should be random bytes and look like this:
5. Delete the file and synchronize the file system so that changes are pushed to the SSD:
6. Finally, repeat the command from step 4. Reading the same disk sector should yield an empty sector. For example:
Disable access time stamps on files and directories
Every time a file is accessed, a time stamp for last access is recorded with the file. It is believed that this information is generally unnecessary and that it is the source of a lot of wear on a SSD. Turning off access time stamps does not disable last modified time stamps, which are crucial to a lot of computer tools.
However, it is possible that some tools you are using rely on last access time stamps. Therefore, I suggest that you disable access time stamps separately than all other changes you make to your system. Turn it off and then leave your system unchanged for a while to see how it performs under this mode. In that period, try out all your tools. Tools that rely on file caching might not do as well as others.
Interesting links about last access time:
Disabling last access time is done by adding the options “noatime” and “nodiratime” for the SSD to the file “fstab” under the directory “/etc”. First, edit the “fstab” file:
Then, locate your drive and add the options “noatime” and “nodiratime” at the appropriate line. For example, my file looks like:
After the file is saved, one must reboot the operating system for the changes to take effect.
After reboot, you can verify that the recording of access time is not longer in effect with the following tests:
1. Move to a directory managed by the SSD and writable to your user. If your home directory is on the SSD, then the following would work:
2. Create a file for testing purposes:
3. Record the last access time:
4. Wait for a minute or two to elapse (you can use ‘date’) and then read the file:
5. Repeat command from step 3 and compare the results. If the same time is returned, then “noatime” is in effect. If a newer time is returned the second time, then the operating system is still recording access time for the file.
6. Clean up after yourself and delete the test file:
Adjust Disk Scheduler
By default, the CFQ scheduler is used to access a drive. This scheduler is designed for magnetic drives and take into account variables such as seek times. In SSDs, access time is fairly constant. Therefore, there is no need for a complex scheduler and addressing requests on a first-come-first-served basis is adequate. I have used the “noop” scheduler and this is what I demonstrate. However, there is an interesting post at this blog that might convince otherwise.
The trick offered here changes the scheduler after the boot is performed and as the operating system is starting it services. Therefore, the boot process does not benefit of these changes. The post above provides links to enable scheduler at the boot loader.
Myself, I like keeping my boot loader as clean as possible, so I have adopted this trick.
1. Edit the file “/etc/rc.local”:
2. Add the following line by taking care to replace sdX for the proper drive:
This change will take effect at the next reboot. However, to save a reboot, one can apply the change right away with (again, replacing sdX for proper drive):
Moving log files to RAM
Log files are a source of constant writing to disk. Personally, I have not yet made the change to my drive for two reasons:
However, my research indicates that this will yield to an earlier retirement of my drive. Therefore, I offer here a link that I found useful on this topic:
Here are a couple of interesting links that might guide you in your decisions. I do not personally endorse the views presented there. However, I believe they provide good food for thoughts:
With a SSD drive, the time to boot up has greatly decreased and performance associated with my development tools as increased. Surprisingly, the general temperature reported by my laptop sensors has also gone down. However, as most activities performed on computers are “web based”, the network-bound activities have remained pretty much the same.
All in all, I have been quite satisfied with my purchase of a SSD drive.
The following steps can be used to enable tethering between a platform running Ubuntu 11.04 and an iPhone. At a high level:
Enable Tethering on iPhone
The use of iPhone tethering might be governed by your wireless plan. If data tethering is allowed, one should be able to turn it on using the “Settings” application.
In the “Settings” application, choose “Personal Hotspot” from the menu, and enable it by pushing the switch to “on”.
If one can not accomplish this step, the remainder steps from this article will be in vain.
Install repository from Paul McEnery
Adding package “python-software-properties” provides the command “add-apt-repository”. This command is then used to make it really easy to add a repository from PPA.
Install necessary packages
Once the repository is installed, installing the packages is straight forward:
During the configuration of those packages, a kernel module must be built. In the case that the kernel headers are not installed, the following error message is printed on the screen:
Module build for the currently running kernel was skipped since the kernel source for this kernel does not seem to be installed.
In this case, the proper headers must be installed. To find out which headers are required:
Then, install the headers using the following command. Ensure that you replace the proper version according to what was returned previously.
When this command completes, the iPhone module should be built. If not, then the system can be prompted to rebuild the kernel module:
Connect the iPhone to the platform using a USB cable. When the USB device is detected, an Ethernet should be established automatically.
We have a couple of machines running 10.04 LTS and they have been showing messages similar to the following when you ssh to them.
11 packages can be updated.
7 updates are security updates.
And yet, when you do an update, there is nothing to update. There was a bug that caused the package update information to be incorrectly dumped into /etc/motd.tail and never updated. The bug was fixed, but the incorrect /etc/motd.tail was never cleaned up. This can be fixed by removing /etc/motd.tail. The correct information will be generated when available in /var/run/motd.