Page 1 of 1

ChibiStudio Terminal Debug

Posted: Mon Jul 11, 2016 7:53 pm
by kb1gtt
I'm using a STM32F429 discovery board. I was having problems, but now it's resolved. This is mostly a trail of bread crumb for others or myself to potentially find.

I started with this tutorial and below I have filled in several blanks. http://www.playembedded.org/blog/en/201 ... o-chibios/

Here are my notes about how I got messages to show up in ChibiStudio's terminal being sent from the STM32F429 discovery board.

From ch.h, other versions may work, this is the version I was on when I did this.

Code: Select all

#define CH_KERNEL_MAJOR         3
#define CH_KERNEL_MINOR         0
#define CH_KERNEL_PATCH         1

I do no know how to verify the uGFX version. If I knew how I would post it here as I know this version works with that chibios version.

In mcuconf.h I have this

Code: Select all

#define STM32_SERIAL_USE_USART1             TRUE
blah
#define STM32_UART_USE_USART1               FALSE

In halconf.h I have

Code: Select all

#define HAL_USE_SERIAL              TRUE
blah
#define HAL_USE_SERIAL_USB          FALSE
blah
#define SERIAL_DEFAULT_BITRATE      38400

In os_chibios_3.mk I have

Code: Select all

# Add include files
INCPATH +=  blah
            $(CHIBIOS)/os/hal/lib/streams/ \
            $(CHIBIOS)/os/various

# Add C files
SRC  += blah
        $(CHIBIOS)/os/hal/lib/streams/memstreams.c \
        $(CHIBIOS)/os/hal/lib/streams/chprintf.c

And finally in main.c I have

Code: Select all

#include "gfx.h"
#include "ch.h"
#include "hal.h"
#include "chprintf.h"
#include "memstreams.h"
BaseSequentialStream* chp = (BaseSequentialStream*) &SD1; // for serial debugger chprintf statements.

blah

/*
 * Red LED blinker thread, times are in milliseconds.
 */
static THD_WORKING_AREA(waThread1, 512);
static THD_FUNCTION(Thread1, arg) {

  (void)arg;
  chRegSetThreadName("heart_beat");
  while (true) {
    palClearPad(GPIOG, GPIOG_LED4_RED);
    chThdSleepMilliseconds(500);
    palSetPad(GPIOG, GPIOG_LED4_RED);
    chThdSleepMilliseconds(500);
    chprintf(chp, "Hello world\n\r");
  }
}

int main(void) {
  sdStart(&SD1, NULL); // Start serial, this will allow chprintf statements to work.
  chThdCreateStatic(waThread1, sizeof(waThread1),//Create heart beat thread
                  NORMALPRIO + 9, Thread1, NULL);
blah

This done with ChibiStudio on a win7 64 bit. I have STLink installed and under device manager --> Ports, I see I have STLink Virtual COM port (COM8).

The hardware is an STM32F429 discovery board. From visual inspection I see the factory setting is with a solder blob jumper on SB15 and SB11 is open. I see from the schematic (snippet below), that we are dealing with PA10, then table 10 of en.DM00071990.pdf indicates we are USART1. So I set the UART in the mcuconf.h and halconf.h files to 1.
Capture.PNG
Capture.PNG (15 KiB) Viewed 3206 times

When this is all done, I get this in ChibiStudio, notice the Hello World showing up once very second, in sync with the red LED.
Capture.PNG

Re: ChibiStudio Terminal Debug

Posted: Mon Jul 11, 2016 8:58 pm
by Giovanni
Hi,

Good job, the first step is the hardest.

Giovanni

Re: ChibiStudio Terminal Debug

Posted: Mon Jul 11, 2016 9:12 pm
by kb1gtt
These first steps are both hard and very critical. Getting them right and knowing how they interact is very important for the coding to come.

Thanks for the great OS and efforts. I'm sure those first steps were even harder than my trivial first steps.

Re: ChibiStudio Terminal Debug

Posted: Mon Jul 11, 2016 9:56 pm
by RoccoMarco
I have to add a note into the article about the magic button :mrgreen: