Example code for STM32F4 Discovery

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. This forum is NOT for support.
gentijo
Posts: 11
Joined: Sat Jul 21, 2012 5:00 am

Re: Example code for STM32F4 Discovery

Post by gentijo »

I totally missed the USB-CDC in testhal.. To answer your question, yes I can compile and run that code just fine which is what I was looking for..
I still get the linker with your Github project, the only differences I found in the Makefile's were
USE_FPU = no
the include $(CHIBIOS)/test/test.mk is not commented out
and in CSRC there is a ref to $(TESTSRC) \

none made a difference.

Thank you for pointing out the other project.

-John Gentilin
jscott
Posts: 129
Joined: Tue Jul 03, 2012 3:50 pm

Re: Example code for STM32F4 Discovery

Post by jscott »

I made a change to the "threads" command. I added the thread name to the display.
Now if you set the thread name it will show up correctly in the list.

Here is the updated function:

Code: Select all

void cmd_threads(BaseSequentialStream *chp, int argc, char *argv[]) 
{
   static const char *states[] = {THD_STATE_NAMES};
   Thread *tp;

   (void)argv;
   if (argc > 0)
   {
      chprintf(chp, "Usage: threads\r\n");
      return;
   }
   chprintf(chp, "%10s %10s %10s %6s %6s %11s %7s\r\n",
            "name", "add", "stack", "prio", "refs", "state", "time");
   tp = chRegFirstThread();
   do
   {
      chprintf(chp, "%10s %.10lx %.10lx %6lu %6lu %11s %7lu\r\n",
               (uint32_t)tp->p_name, (uint32_t)tp, (uint32_t)tp->p_ctx.r13,
               (uint32_t)tp->p_prio, (uint32_t)(tp->p_refs - 1),
               states[tp->p_state], (uint32_t)tp->p_time);
      tp = chRegNextThread(tp);
   } while (tp != NULL);
}


If you find any problems, please let me know.
-John
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Example code for STM32F4 Discovery

Post by Giovanni »

The thread name could be NULL if not set, you should consider that case.

Giovanni
jscott
Posts: 129
Joined: Tue Jul 03, 2012 3:50 pm

Re: Example code for STM32F4 Discovery

Post by jscott »

In the updated "threads" command function, I tested for the case of Process Name p_name being null.

The displays "(Null)" in that column.

If anyone gets an error, please try to give me some details.

-John
awilkinson
Posts: 2
Joined: Mon Sep 03, 2012 9:25 pm

Re: Example code for STM32F4 Discovery

Post by awilkinson »

Thanks for all your hardwork and generosity! I've had a couple of goes at compiling this using Yagarto on WinXP SP3 and Summon on Debian. In both cases I get:
../ChibiOS/os/hal/platforms/STM32F4xx/hal_lld.h:775:2: error: #error "Using a wrong mcuconf.h file, STM32F4xx_MCUCONF not def
../ChibiOS/os/hal/platforms/STM32/OTGv1/usb_lld.h:152:2: error: #error "USB driver activated but no USB peripheral assigned"

Please would you be kind enough to advise on what I'm doing wrong? I apologise for my ignorance and stupidity.

DDEFS = -DSTM32F4xx_MCUCONF -DSTM32_USB_USE_OTG1

in the Makefile got me a little further but then I got:

myUSB.c:152:3: error: extra brace group at end of initializer
myUSB.c:152:3: error: (near initialization for 'serusbcfg')
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Example code for STM32F4 Discovery

Post by Giovanni »

Hi,

The newer version in the repository checks that the mcuconf.h file into the application directory is the right one for the selected architecture. Probably your mcuconf.h file is from an older version, you have to update it by taking one from one of the included demos for the STM32F4.

The second error is fixed by enabling the USB support in the mcuconf.h, previously it was enabled by default, now it is disabled.

Giovanni
dancios
Posts: 1
Joined: Sun Sep 30, 2012 9:52 am

Re: Example code for STM32F4 Discovery

Post by dancios »

Giovanni wrote:The second error is fixed by enabling the USB support in the mcuconf.h, previously it was enabled by default, now it is disabled.


How or where the documentation is ?
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Example code for STM32F4 Discovery

Post by Giovanni »

Hi,

You request is a bit generic, the documentation is here: http://www.chibios.org/dokuwiki/doku.ph ... :documents

Giovanni
resset
Posts: 32
Joined: Thu Dec 20, 2012 11:57 pm
Has thanked: 2 times
Been thanked: 1 time

Re: Example code for STM32F4 Discovery

Post by resset »

Hi,

I made a tiny rework of this project. Now it works on current unstable ChibiOS/RT 2.5.2. I also included a change in cmd_threads from this topic.

Git repository: https://github.com/resset/STM32F4-Discovery-example-code

Thanks for this project, Mathias :)
And (first and foremost!) thanks for ChibiOS, Giovanni :) My first post here ;)

Mateusz
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Example code for STM32F4 Discovery

Post by Giovanni »

Hi,

Thanks for sharing :)

Giovanni
Post Reply