Yo, I'm still a high-level developer, so I'm used to having some easy to use debugging output and while the logic analyzer and the j-link proved useful, they are far from what I like in terms of outputting what the heck is going inside. I did some code using the uart1 as debug, but the ftdi serial-to-usb chip bursted in flames soon after and I lost it. To the rescue, I found a pin called SWO on the cpu, made my day, asked my hw dude to connect it and along with the j-link I hacked a quick program to use it, along with logging code. Worked great, the logic analyzer now stays in the box, I solved tons of communication issues and race conditions with past few days and decided to share if anyone is interested. The viewer is crap, buggy, should be done completely different way, but I just don't have the time, some day...
This is what the viewer looks like:
It needs j-link (I guess, dunno how to setup the rest) with j-link gdb server via swd to work. Once the j-link gdb server is started, the "Init SWO" button connects and sends few commands to enable the swo, should be done once per launch of the gdb server, then it just works.
The way to use:
0. Put the correct mcu speed in the debug.c
#define DBG_MCU_SPEED 16000000
1. Define "channels", numeric starting from 1 up to 31, like:
2. (optional) set them a name somewhere at program startup, like:
3a. Log printf text
dbgf(DBG_MAIN,"Compiled on: %s %s",__DATE__,__TIME__);
3b. Log just plain string
3c. Log some data packet
dbgDataW(DBG_MAIN,txBuf,txLen); //will show as "red" hex data on the logger
dbgDataR(DBG_MAIN,rxBuf,rxLen); //will show as "green" hex data on the logger
4. Log "fragmented" packet:
dbgStartW(DBG_MAIN); //starting "red" hex data packet
dbgb(DBG_MAIN,0x55); //adding a byte
dbgb(DBG_MAIN,0xAA); //adding a byte
dbgd(DBG_MAIN,txBuf,txLen); //adding some more data
dbgEnd(DBG_MAIN); //making the data sow up on the logger. Actually starting new packet on that channel instead of calling dbgEnd does the same thing
Thats pretty much it, I have "borrowed" ChibiOS' chprintf function for the purpose and modding it a bit :p
I know it is very early ver and does not look pretty, but it helps me, hope it does help other people too.
This forum is about you. Feel free to discuss anything is related to embedded and electronics, your awesome projects, your ideas, your announcements, not necessarily related to ChibiOS but to embedded in general.
1 post • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 2 guests