Compiling problems

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

ktx
Posts: 6
Joined: Mon Aug 14, 2017 10:38 pm

Compiling problems

Post by ktx »

Hi all,

I am trying to learn how to use ChibiOS. I am using the BluePill port as a start. I compiled it and flashed successfully onto the board. The board blinks..

Then I changed the code to the following to test out serial communication.
[spoil]

Code: Select all

#include "ch.h"
#include "hal.h"
#include "serial.h"


static SerialConfig uart_cfg = {
    57600, /* rate */
};

int main(void)
{
    char data[] = "Hello World!\n\r";

    halInit();
    chSysInit();

    /* USART1_TX & USART1_RX */
    palSetPadMode(GPIOA, 10, PAL_MODE_ALTERNATE(7));
    palSetPadMode(GPIOA, 9, PAL_MODE_ALTERNATE(7));
    sdStart(&SD1, &uart_cfg);

    while (1) {
        sdWrite(&SD1, (uint8_t *) data, 14);
        palSetPad(GPIOC, GPIOC_LED);
        chThdSleepMilliseconds(1000);
        palClearPad(GPIOC, GPIOC_LED);
        chThdSleepMilliseconds(1000);
    }
    return 0;
}
[/spoil]
I set HAL_USE_SERIAL and HAL_USE_PAL as TRUE in halconf.h. The compilation fails on unknown types and undefined references.
[spoil]

Code: Select all

Compiling main.c
main.c:8:8: error: unknown type name 'SerialConfig'
 static SerialConfig uart_cfg = {
        ^
In file included from ChibiOS/os/hal/include/pal.h:113:0,
                 from ChibiOS/os/hal/include/hal.h:46,
                 from main.c:4:
main.c: In function 'main':
main.c:20:30: warning: implicit declaration of function 'PAL_MODE_ALTERNATE' [-Wimplicit-function-declaration]
     palSetPadMode(GPIOA, 10, PAL_MODE_ALTERNATE(7));
                              ^
ChibiOS/os/hal/ports/STM32/LLD/GPIOv1/pal_lld.h:342:47: note: in definition of macro 'pal_lld_setgroupmode'
   _pal_lld_setgroupmode(port, mask << offset, mode)
                                               ^
ChibiOS/os/hal/include/pal.h:527:3: note: in expansion of macro 'palSetGroupMode'
   palSetGroupMode(port, PAL_PORT_BIT(pad), 0U, mode)
   ^
main.c:20:5: note: in expansion of macro 'palSetPadMode'
     palSetPadMode(GPIOA, 10, PAL_MODE_ALTERNATE(7));
     ^
main.c:22:5: warning: implicit declaration of function 'sdStart' [-Wimplicit-function-declaration]
     sdStart(&SD1, &uart_cfg);
     ^
main.c:22:14: error: 'SD1' undeclared (first use in this function)
     sdStart(&SD1, &uart_cfg);
              ^
main.c:22:14: note: each undeclared identifier is reported only once for each function it appears in
main.c:25:9: warning: implicit declaration of function 'sdWrite' [-Wimplicit-function-declaration]
         sdWrite(&SD1, (uint8_t *) data, 14);
         ^
ChibiOS/os/common/ports/ARMCMx/compilers/GCC/rules.mk:216: recipe for target 'build/obj/main.o' failed
make: *** [build/obj/main.o] Error 1
[/spoil]
Any hints on where should I look? Thank you in advance.

I tried to disable the "SMART_BUILD" with no luck. I assume, it is something I overlooked.

My environment:
* clean Debian install (9.1)
* arm-none-eabi-gcc (15:5.4.1+svn241155-1) 5.4.1 20160919 from official Debian repository
* GNU Make 4.1
* the clone of the mentioned git repo
* NOT using the ChibiStudio
User avatar
tfAteba
Posts: 551
Joined: Fri Oct 16, 2015 11:03 pm
Has thanked: 91 times
Been thanked: 50 times

Re: Compiling problems

Post by tfAteba »

Hi KTX,

The first thing that come to my mind is to know if you did a full rebuild? Some time it help.
try to do: make clean; make in your terminal after your modifications have been made.
User avatar
tfAteba
Posts: 551
Joined: Fri Oct 16, 2015 11:03 pm
Has thanked: 91 times
Been thanked: 50 times

Re: Compiling problems

Post by tfAteba »

Also, in your code, you don't need to do the following include: #include "serial.h". It is already done by the #include "hal.h".

Can you share your mcuconf.h file and halconf.h ? so that I can see if every things is properly set :)

The serial device must also be set in mcuconf.h file.

ktx wrote:
Any hints on where should I look? Thank you in advance.

You can look at the STM32 demo folder, for example for in chibios/demos/STM32/RT-STM32F401RE-NUCLEO64 for the Nucleo board.

You also have the testhal folder with test program for most driver written for mcu. It can be found at chibios/testhal/STM32/STM32F4xx
ktx
Posts: 6
Joined: Mon Aug 14, 2017 10:38 pm

Re: Compiling problems

Post by ktx »

Apologies for the errors in the description:
* I am executing with make clean && make
* The edited headers are attached as zip.

As for the examples from other boards: I even "diffed" the Makefiles if there is a relevant difference..
I noticed that the repository is using DOS-fileformats, which creates a bit of mischief if one is using git on linux..
Attachments
h.zip
(3.74 KiB) Downloaded 357 times
User avatar
tfAteba
Posts: 551
Joined: Fri Oct 16, 2015 11:03 pm
Has thanked: 91 times
Been thanked: 50 times

Re: Compiling problems

Post by tfAteba »

Ok, thanks, your mcuconf.h and halconf.h looks good, I will look for a solution tonigth, sorry I have to travel.

What is your board?

Why do you use this github version of ChibiOS not the official one :) , I just want to know.

Another way, if you can share your whole application it will be easier for me to find your problem and give you a feed back.

Thanks, and sorry for the delay, as I told you I'm traveling this day.
ktx
Posts: 6
Joined: Mon Aug 14, 2017 10:38 pm

Re: Compiling problems

Post by ktx »

tfAteba, thank you for the invested time. I already played with it for hours and I am stuck, so don't worry.

The board is the infamous bluepill.
Why am I using it? I am new to ARM, wanted something small/not expensive and want to try out ChibiOS and learn something.
I have only some experience with MSP430 (bare metal C).

Why this version of ChibiOS? The version did not seem too old but mainly I just grabbed the repo and set out to play with it until I can move/update to the newest ChibiOS version. The repo "symlinks" (don't remember the correct technical term) to ChibiOS 16.1.6.

I am attaching the modified *.h, *.c, Makefile from the "app" and a patch (created using git diff) for convenience.
Attachments
patch.zip
(1.28 KiB) Downloaded 360 times
blue.tgz
(8.31 KiB) Downloaded 380 times
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Compiling problems

Post by Giovanni »

Hi,

I recommend using the official GCC distro maintained by ARM, the one included in repositories and self-built ones often failed in the past.

https://launchpad.net/gcc-arm-embedded

Using this compiler all demos should just work out of the box, I use Linux Mint for testing them. Updating to the latest ChibiOS official release would be a good idea too.

Giovanni
ktx
Posts: 6
Joined: Mon Aug 14, 2017 10:38 pm

Re: Compiling problems

Post by ktx »

Giovanni wrote:I recommend using the official GCC distro maintained by ARM, the one included in repositories and self-built ones often failed in the past.


Hi, new gcc (6.3.1 20170620) did not help.
A quick test on using the newest ChibiOS from github failed on make errors (would have to dig deeper into the changes to the Makefile, repaired the quick ones -> paths).
ktx
Posts: 6
Joined: Mon Aug 14, 2017 10:38 pm

Re: Compiling problems

Post by ktx »

PAL_MODE_ALTERNATE undefined reference: Looking at the platform Makefile, it seems that the used platform STM32F1xx has not GPIOv2 or GPIOv3. The PAL_MODE_ALTERNATE is defined as macro only in GPIOv2/3's pal_lld.h. As a newbie: is this because the platform does not have the necessary capabilities or because there was no need/time to implement it?

I am confused:

Code: Select all

cd ChibiOS/testhal/STM32/STM32F1xx/UART/ && make clean && make
-> it works without a hitch, even if the code contains PAL_MODE_ALTERNATE.
ktx
Posts: 6
Joined: Mon Aug 14, 2017 10:38 pm

Re: Compiling problems

Post by ktx »

I am now using the ChibiOS from github.
Copied an example from testhal folder and modified to blink. Blinky code works so I am going to try to get the serial working.
Thank you all for the time and I am considering this as closed.
Post Reply