Earlier this year I started work on designing a software debugger for Arduino, targeted at new users who would like better debugging facilities than the serial.print() method.The basic idea can be seen here.
I was getting on well but it turned out to require a lot more work than I at first thought (as these things tend to). So I shelved it for a while, firstly because it was summer and I didn't want to spend so much free time indoors, and secondly because I perceived a problem with the concept - that problem being optimisation.
The Arduino compiler (avr-gcc) is excellent at reducing code size by optimising it, which is the default. It helps enormously with fitting more code into a relatively small space. However, the optimisation is performed by essentially re-arranging the author's code, so the net result produces the intended result whilst taking fewer bytes to achieve. This re-arrangement often means that trying to single-step through the original code (as written) can be very confusing (especially for the beginner, who this project was aimed at). For example, 'while' loops may be effectively turned into 'for' loops, 'case' statements may be turned into 'if-else', etc. Additionally, many local variables are often opted out altogether so don't exist and cannot be seen.
Now, it's possible to add no-optimisation directive into the header file of my library (so it's not even seen , and needn't concern the novice user) but this of course can greatly increase the size of the user's code. So using the debugger would be limited to a code size perhaps half what the device is capable of. There are ways to mitigate this (by using several smaller files, only one of which is zero-optimised, for example) but doing so goes away from the simplicity of use I'm aiming at.
So, my question is, now that summer's over, is it worth my while pursuing this idea? I've no intention of making any income from it, and when complete would offer it freely - as long as support time wasn't too great ;).
Your intentions are admirable but hardware single stepping is impossible.
Best put your efforts into writing easy to follow useful code samples, see Robin2's examples.
Even single stepping in software, such as the microchip IDE, has little use.
Proper training in basic programming techniques removes most problems, however many new people usually have no patience in learning the basics as they only want a quick solution so they can get a mark in a class.
larryd:
hardware single stepping is impossible.
Even single stepping in software, such as the microchip IDE, has little use.
Can you explain what you mean? I have used several microcontroller debuggers in the past, using single-stepping to solve all sorts of problems. Using such techniques I have designed many commercial products, enabling me to retire early and (try to) help others who may wish to follow in the same field
Microchip has debugging IDE software that can be single stepped in the host computer.
It also has a virtual scope/'logic analyzer' that can be attached to a pin to show what is happening on that pin. This however removes actual hardware from the debugging process so hardware problems/characteristics are not emulated.
You could design a hardware in circuit emulator for debugging but this would be cost prohibitive for new people.
IMO these tools are far above the capability of new people especially when many fail/refuse to put the effort into basic training.
Those who do master the basics also master good programming habits which include debugging techniques.
larryd:
Microchip has debugging IDE software that can be single stepped in the host computer.
It also has a virtual scope/'logic analyzer' that can be attached to a pin to show what is happening on that pin. This however removes actual hardware from the debugging process so hardware problems/characteristics are not emulated.
I don't know about Microchip but there are plenty of other suppliers who provide debugging hooks into real hardware development boards. Pretty much all i/o works as it would in a production board.
You could design a hardware in circuit emulator for debugging but this would be cost prohibitive for new people.
One could, and yes it would be expensive, but I'm talking about software debugging, not a hardware emulator.
IMO these tools are far above the capability of new people especially when many fail/refuse to put the effort into basic training.
These tools are often complex, yes. That's why I'm designing a simpler one. Many may fail to put the effort in; I'm interested in helping those others who genuinely want to progress.
Those who do master the basics also master good programming habits which include debugging techniques.
But with Arduino there are no good debugging techniques available! Serial.print() is primitive. Hence my efforts.....
That's just inserting 'secret' code lines in to do a pseudo serial.print and set a breakpoint. You need to recompile every time you want to add a breakpoint. And you have to install/learn the heavyweight Visual Studio to get started.
Maybe someone else, who's actually used the type of tools I'm talking about, can give a more positive or constructive response ?
I'd be happy to give it a test drive but the download link on your website appears to have been removed. I hope it wasn't due to the one less than encouraging poster.
I've been looking for something like this ever since I first opened the Arduino IDE. My first thoughts were "How can they not have a debugger? Serial print? You can't be serious in the year 2014. That's when it became pretty obvious the IDE wasn't targeting folks with a software background. In retrospect, knowing what I do now about the makers and other targeted users, I understand why not. But, one can make a pretty strong case that a debugger is a huge aid in helping users to actual figure out how a microprocessor works internally. You don't have to use it if you don't want to.
If I was asked what was the biggest flaw in the Arduino ecosystem my reply would be the lack of any type of debugger or simulator. Sure, there are add-ons and other ways to get there but they all lack the simplicity of the integrated IDE. IMO, Borland Turbo C set the IDE standard in 1998, it's a shame we seem to have gone backwards since then.
"I hope it wasn't due to the one less than encouraging poster."
If the reference is to me, you do not understand my posts.
A debugger would be great, it would be much welcomed, but the premise of this thread was "targeted at new users who would like better debugging facilities than the serial.print() method."
As mentioned, I believe many new people have little disire to learn basic Arduino programming techniques, yet alone learn the in and outs of a debugger. I am sure the people who look after the compiler have discussed this at length. As an example, many new users simply cut, copy paste code then ask for a canned solution.
IMO, the efforts of the OP could be better spent by covering programming techniques, of course they can do what they want, but responses were solicited from us.
avr_fred:
I'd be happy to give it a test drive but the download link on your website appears to have been removed. I hope it wasn't due to the one less than encouraging poster.
Sorry, that link has never been activated, the code hasn't yet got to a suitable stage. The web page was just the beginnings of how I might introduce the idea when (if) it is ready.
larryd:
many new people have little disire to learn basic Arduino programming techniques
Your use of the word 'many' leads be to believe that you still don't appreciate my target audience. If you had said 'all new people....', and it was true, then yes I'd be wasting my time.
I agree that 'many' users of Arduino are just college students who aren't that interested in what they are doing but have to hand in some coursework or other to get some marks.
But's that not 'all' of them.
Are you suggesting that none of tomorrow's skilled embedded programmers will learn their first skills via Arduino?
What we really need is a new way to think about "debugging" that is more accessible to beginners, rather than ways of adding traditional debugging (which is pretty complex) to a beginner-accessible IDE...)