Friday 10 June 2011

First mBed development

As a PIC developer, and member of BuildBrighton, I often get a bit of stick from the others who are avid Arduino fans. The very reason most people love Arduino is mostly the reason why I don't get along with it - it's not the C-based language or abstraction (both of which I already use quite extensively when writing Actionscript for Flash) but what really bothers me is the over-reliance on libraries.

When I write PIC code, I tend to pore over reams and reams of boring (and confusing) datasheets, try to understand what is going on inside that little black box of magic, and write code to make it do exactly what I want.

Arduino has become successful because of the massive community of people who write code for it and post the results as "libraries" that other users can simply download and include in their projects. That's great provided the code is well written in the first place. There are a lot of people successfully using Arduino for their projects who don't really understand a single line of code! But by plugging together a few different libraries, you can get a working prototype up and running fairly quickly.

Despite my prejudices towards library-based coding, the lure of an ARM7 processor with built-in ethernet was just too much! The mBed development kit I was sent seems perfect for building quick and easy prototypes with very little knowledge of the underlying hardware. I've never built an ethernet stack, nor would I know where to start, but the mBed website provides a number of libraries and examples showing how to build a working HTTP client (some code that runs on the microcontroller and retrieves web pages from a URL is all I was after!)

Now the gripe - it's been over a week since this little thing arrived through my letterbox and I set to working immediately on ideas to try out it's hardware features. Since I'd already got access to most of it's peripherals through the PIC 18F series, I concentrated on the one thing it trumped a PIC with - ethernet support.

Yet nearly a week later, and despite the supposedly simple copy-and-paste approach to coding with the mBed system, I've yet to make a working HTTP client!

I have the 2368 series board (which has an 60Mhz ARM7 onboard, later versions such as the 1768 have a Cortex-M3 CPU running at 100Mhz) but not one of the HTTP client examples from the mBed website works.
Some of the other guys at BuildBrighton use the 1768 type mBed kits and the code works first time for them - but on my board, it just keeps locking up. (Some of the other guys at BuildBrighton just laugh and say I need to get an Arduino with an ethernet shield, but pfffft.)

I've used the same RJ45 sockets as the others, tried to communicate over the same networks, connecting to the same routers/hubs and while their boards all return HTML data almost instantly, whenever my board hits a HTTP GET type command, it just locks up!

And so the point of this grumble - it's still relatively early days for the mBed system. Which means the community is still pretty small - and the support just isn't there yet. I've been posting to forums asking for assistance, but haven't yet had any reply that has proved useful (whenever anyone at the Skiff has an Arduino-type problem, they can post a question and expect half a dozen answers within a few hours!). And the major problem - for me at least - is that I have no idea of what is going on inside those libraries to get to the bottom of why it's not working: which is mostly due to the way a library-based development system works. With a PIC, you work at almost byte and bit level - you can see every register and find out what is going on at the tiniest level. With the mBed system (and similarly, Arduino) all the clever, tricky, brain-hurting stuff is hidden away inside a few APIs supposedly making these things really easy to work with. Which is fine, when the libraries are well written and work all the time. But when they don't and there's no support, there's nowhere left to turn. Except, perhaps, back to my PICs.....

No comments:

Post a Comment