Firmware Debugging w. Serial Console

Discuss mods, hacks, tweaks, etc.

Moderators: altitude, adafruit_support_bill, adafruit, phono, hamburgers

Please be positive and constructive with your questions and comments.
Locked
User avatar
chairman meow
 
Posts: 56
Joined: Sat Jul 30, 2005 8:48 pm

Firmware Debugging w. Serial Console

Post by chairman meow »

What's the secret to debugging with putstring(), printf() and friends? I'm not intimately familiar with the AVR architecture, so digging down into loop_until_bit_is_set() and io.h is beyond my present abilities for now. Ideally, I'd like to be able to spit output via the serial line to a serial console on the other end (minicom or hyperterminal).

When I call putstring() now, my x0xb0x goes dead (yay for the bombproof bootloader), am I missing some initialization routine?

User avatar
no-fi
 
Posts: 13
Joined: Sat Oct 15, 2005 2:51 am

Re: Firmware Debugging w. Serial Console

Post by no-fi »

Chairman Meow wrote: When I call putstring() now, my x0xb0x goes dead (yay for the bombproof bootloader), am I missing some initialization routine?
hmm.. are you calling putstring() with just a constant message? or are you trying to send variables? what's the actual line that you think is trashing your code? and what are the relevant (if any?) declarations? and where are you using it?

In C, things can go in and out of scope, depending on where you are, and if your code is just wandering off into space, it looks like you're using a bad pointer somewhere, and trashing something important. Possibly even a couple of registers that are holding important operating variables?

also, why are you using printf()? In ansi C, on an actual computer, that will write to STDIO, which is generally a console. I haven't managed to look at x0xb0x sourcecode yet, but you might have better luck with using sprintf() to make a string, then send that string.

also, if you want to learn about programming AVRs in C, there's a VERY good beginners course you can get. Buy the whole kit they sell at smileymicros.com (book plus board plus extra components) and you'll learn a lot about what you can do with an AVR and GCC.
http://www.smileymicros.com/index.php?m ... tion=24:24
US$80 for a basic dev kit, plus a "how to" book, and sourcecode is completely unheard of for any other microcontroller platform.

there's also a hell of a lot of example code for AVR on the web. go check out www.avrfreaks.net and register, and go into the academy section to see all sorts of cool projects and HOWTO articles.
Last edited by no-fi on Sat Dec 10, 2005 2:20 am, edited 1 time in total.

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Post by adafruit »

yeah dont forget that you can only putstring("foo") not putstring(foo), as storing strings in RAM will overflow the stack right-quick

User avatar
chairman meow
 
Posts: 56
Joined: Sat Jul 30, 2005 8:48 pm

Post by chairman meow »

I'm un-commenting your own existing debugging statements that are already in the code. Where, if anywhere, should this output appear?

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Post by adafruit »

open up your favorite serial console, connect to the USB com port at, i believe 19.2K

User avatar
chairman meow
 
Posts: 56
Joined: Sat Jul 30, 2005 8:48 pm

Post by chairman meow »

19200 8N1

Locked
Please be positive and constructive with your questions and comments.

Return to “x0xm0dz”