Firmware Development with Eclipse

Posted by Landon Cox on October 31st, 2007 in Open Source

Most people who work with me know I'm not a big fan of Eclipse though I do use it from time to time for typical Java tasks. I also used it several years ago with CDT to do C++ development for some GIS projection code and it worked well for that task. Recently, I used Eclipse for something I've never used it for before: writing firmware. I like building GPS related devices and software applications and bought an Olimex SAM7 P256 development board so I could start learning the ARM core architecture and specifically the SAM7 microcontroller from Atmel. The SAM7 (S256 flavor) is a 32bit RISC microcontroller that has 256KB of built-in flash memory for holding firmware and 64KB of RAM. It incorporates two serial ports, an analog to digital interface, a plethora of digital GPIO ports, built-in USB physical level support, and has SPI (Serial Parallel interface) which is a low-level (register level) mechanism commonly used for communicating with external flash devices like SD and MMC cards. The device runs on 3.3 volts and needless to say, has a lot of functionality packed into a low-power package that is smaller than a postage stamp. The Olimex development board which incorporates the SAM7 looks like this: This board breaks out all the GPIO and serial interfaces, adds a themistor for measuring temperature, a few buttons to exercise GPIO, and provides a JTAG interface. JTAG is a physical and electrical standard used to both flash new firmware into embedded devices but also used to source-level debug embedded code running directly on the platform — in the olden days, this functionality was encapsulated by a huge machine, ICE (in-circuit emulator), which cost thousands of dollars. In fact, one of the ways the iPhone was cracked was through a builtin JTAG interface embedded deep in the iPhone. JTAG is one of those ubiquitous technologies that flies under the radar - it is everywhere if you know where to look. I bought a JTAG for ARM programming device (~ $70) which works in conjunction with Eclipse and a package of GNU ARM cross-compiler tools called Yagarto (Yet Another GNU ARM Toolchain.) That tool chain, along with an excellent tutorial written by Jim Lynch, got me up and writing C code for the SAM7 in about 1/2 hr (not counting download times.) This is a picture of my setup - the Olimex board connected through JTAG to the Olimex JTAG programmer which is USB to my laptop development environment: In order to use JTAG, Yagarto incorporates an open source JTAG middleware piece called OpenOCD (Open On-Chip Debugger.) OpenOCD's main task is to be the mediator between the Eclipse, ARM cross-compiler binaries, GNU GDB and the JTAG programming device itself. OpenOCD's gdb service is not used to flash the device, just debug with it, but OpenOCD software is involved with flashing the device. There's a special build target in the Eclipse project that defines an OCD script for flashing the device. Using Eclipse and OpenOCD, I was able to single-step through lines of C code in my Eclipse environment though the code was running directly on the SAM7 board. Considering everything that was going on in order to make that happen and considering the cost of the software development tools was $0, this is nothing short of impressive. Some shortfalls in the environment that I found were mainly 1) productivity tools for embedded development in Eclipse are very lacking. For example, I wanted to easily be able to look at a hex dump of memory, but there's no simple way to do that (no way that I found.) 2) after running through one session with OpenOCD and JTAG, in order to reflash my device, I had to unplug the device which kills/disconnects OpenOCD, and then reconnect to reflash it. 3) there are some odd breakpoint issues with OpenOCD and JTAG which limited the ability to set hardware breakpoints…I would often have to clear all breakpoints right after starting a JTAG debug session before I could get anything running again. There are other commercial embedded tools that work much better but cost thousands of dollars to get into. So, given the price and functionality of this solution, I can live with those limitations - this package was good enough for me to develop an SPI SD/MMC flash memory card driver, for example. I also developed a non-interrupt serial driver with it. It's plenty good to do real work with. So, there's a new use of Eclipse that partially redeemed it in my eyes.

Bookmark:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • digg
  • Reddit
Comments Off [Trackback URI]

Open source software bugs get squashed faster - even on the user’s computer!

Posted by Stormy on October 11th, 2007 in Open Source

Matt Asay has an interesting blog post about how open source software bugs get squashed faster.   I'd like to add that it's not that they get fixed faster, it's that the fix gets out to end users faster.  An open source fix is available to end users almost immediately after it gets created.  With almost any proprietary software the company has a whole test and QA process that needs to be followed first and it's at least days if not weeks before the fix is released to end users.  

I'd take it one step further and say that's why security is so much better with open source software.  When there's a security flaw in open source software, there's a fix released immediately.  With proprietary software, they try to keep the security hole quiet until they publish their fix, which just by the nature of their processes takes longer than the release of an open source software security patch.   The big proprietary company guy that finds the bug in the middle of the night is not allowed to publish his fix - he needs approval from others.  In the open source world, he can publish the fix right away and others can begin reviewing and commenting.  

Bookmark:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • digg
  • Reddit
2 comments [Trackback URI]

Programming with Ruby

Posted by Stormy on October 4th, 2007 in Open Source

It's been a long time since I wrote much real code, so when I started getting a lot of pointers in that direction, I decided to go for it.  What I discovered is that's it's just as addictive as it used to be!

I decided to learn Ruby for a number of reasons:

  1. I've heard lots of Ruby on Rails hype.
  2. Our engineering team decided to use Ruby for the new project they are starting.
  3. A couple of people at work were recommending Learn to Program as a good book to get your kids started programming and it uses Ruby.  I'm always interested in how to get kids (especially girls) into computers.  (Plus, if I'd forgotten how to program, a book on how to program might be handy.  I originally learned how to program using a book and no computer.  Then I talked my parents into the computer.)

So I checked Learn to Program out of the library and decided to do a couple of examples and then to tackle my favorite pet project.  It took me about an afternoon to go through the book, try out a few examples and write a couple of programs from scratch on my own.  (I won't tell you exactly how long it took me to write a sort program as it's a little embarrassing.)  Ruby turned out to be a pretty easy fun language.  It can pretty much do anything you want it to do and I spent quite a bit of time combing the documentation looking for pre-existing methods to do whatever I needed.  For all that open source software projects get a bad rap for documentation, I found the Ruby documentation to be really good.  You can never have enough examples, but I found most everything I needed in the docs and better yet, all online.  

So my favorite pet project.  I wanted a program that would search all of the science fiction books on Amazon and come up with a list of ones that are worth something used.  (This all started when I discovered that a book I bought at Borders for $6.99 was worth $13 less than a year later!  Since I spend a lot of time in used book stores, I thought I should keep an eye out for bargains.  While I can type all the ISBNs into Amazon on my mobile phone to get their value, that's a bit tedious.)  So I started with Ruby, ended up with the Ruby/Amazon project written by Ian Caliban, and came up with a nifty little program that gets the top 200 (or however many you want) science fiction paperbacks from Amazon and returns a list of all of those that are worth more than x amount (say $4) used and are in the top in terms of sales rank (you decide what number - most people say the top 500,000 at the most if you want to sell it in the next few months.)  

All that in a week using Ruby, open source software, a book and the web!  (Now I just need to release it as open source on the web … once I fix those few ugly spots that is. :)

As a side note, for some strange reason, programming in Ruby reminds me of programming in Scheme.  I'm still trying to figure out why that is … but I like Scheme so it's a good thing. 

Bookmark:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • digg
  • Reddit
2 comments [Trackback URI]

When is a virus scanner like a virus?

Posted by Scott Nicholls on October 3rd, 2007 in Open Source

I spent a few hours on the wrong side of that riddle recently.  

Most of the engineers here at OpenLogic work in some flavor of Linux on their development machines.  When I first received my laptop I attempted to join the crowd and install Ubuntu.  However, due to hardware issues with the video and wireless chipsets on the machine I got, I reluctantly decided to back out and go with the standard issue Windows XP and am still running that today.

This past week I joined a new project team working in Ruby on Rails.  Having been previously focused on Java projects, I had to install and configure a number of things to get up and running in the new development environment.  Part of that setup involved installing a MySQL instance used by the application.  

Once I had everything ready to roll, I wanted to run "rake test" to verify that all the tests passed.  Well, they didn't.  I realized that I initially set some things in the MySQL configuration to be too restrictive.  I'll spare you the details, as that's not the point of this blog post.  So, I reconfigured, based on the settings another developer had working in Windows.

I ran "rake test" again.  Things were looking better.  Tests were passing.  Feeling good.  Nope, boom, suddenly failures left and right.  I ran "rake test" again and got failures from the start.  The errors that were occurring repeatedly looked something like this:

ActiveRecord::StatementInvalid: Mysql::Error: 
Can't create/write to file '#sql_1830_0.MYD' (Errcode: 17): SHOW FIELDS FROM tags

 

The file it was trying to write to was in the temp data directory under the MySQL installation.  I messed with file permissions.  I deleted the temp file and ran again.  Things started off well, but started failing again mid-stream.  I was trying my best to apply logic to the situation rather than jump to the typical re-install, reboot approach it's so tempting to take when things go wrong in a Windows environment.  I decided to peruse some Google search results a little deeper than I had at first.  Thankfully, I followed a link to a post on an Alfresco forum.  Obviously the issue I was dealing with had nothing to do with Alfresco, but was dealing with the same MySQL error.

There it was: "The problem is fixed now. Newer version of McAfee was protecting MySql temporary folder."

No way.  Could that really be it?  I am running McAfee…  I temporarily disabled the virus checker and ran "rake test" again…  Success.  All the tests passed.

Unbelievable.  I honestly don't know that I would have ever thought of that as the possible cause of the problem.  Let me just say I am thankful when people like Senthil follow up their posts with the solution they found, even when it wasn't one someone suggested in a reply.  Then again, if I hadn't found the solution, maybe this would have been the impetus to finally get Linux working on my laptop.  Then, afterall, I wouldn't have much need for a virus scanner anymore.

Bookmark:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • digg
  • Reddit
Comments Off [Trackback URI]