Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Luxury. We used to _dream_ of printf debugging when we're doing embedded microcontroller systems! (at least the ones I work on).

There the debugging is toggling a port pin and examining with an oscilloscope. I typically toggle it different numbers of times at different places in the code to see where I've got to.



I grew fond of printing a char, after I spent some time snooping a uart. The o-scope in capture mode (I realize this wasn't always an option) grabs the char. Handy because I find char waveforms very easy to recognize at just a glance, and you don't have to measure periodicity or count toggles.

Even if you don't have a uart, you can write a little proc to bit-bang a pin.


When developing for microcontrollers and for example my leds aren't working, I like to define a place in memory where I write values to depending on the place in code. Then just read out that memory address with OpenOCD (jtag of swd).

  #define debugVar        ((uint32_t *) 0x10007000)
  *debugVar = 1;     
  *debugVar = 2;
  *debugVar = 0xdeadcafe;


I found tiny printf incredibly useful for this

[1] http://www.sparetimelabs.com/tinyprintf/tinyprintf.php [2] https://github.com/cjlano/tinyprintf (32bit version)


I love ARM semihosting for this reason. It's obviously insanely slow, but unlike a UART it doesn't need any extra hardware and the target is halted while the slow bit is taking place.


I did this too. My life was a lot simpler on the projects where I could connect to UART and actually output text, but that wasn't always the case.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: