Page 1 of 1

Includes from halconf.h

Posted: Sun Sep 06, 2015 1:44 pm
by kiv
If I enable a part of HAL in halconf.h it works (for example, enable USB by #define HAL_USE_USB).
If I include another file to halconf.h and declare this define in it, but not in halconf.h, I got a link error.
Definions from enabled module available to my code, but object files with implementation didn't compiled.
Why is this happening? Is it possible to somehow get around?

Re: Includes from halconf.h

Posted: Sun Sep 06, 2015 2:16 pm
by Giovanni
What error are you getting?

Giovanni

Re: Includes from halconf.h

Posted: Sun Sep 06, 2015 2:24 pm
by kiv
Giovanni wrote:What error are you getting?

Giovanni


Code: Select all

Compiling hal.c
Compiling st.c
Compiling hal_queues.c
Compiling hal_mmcsd.c
Compiling pal.c
Compiling nvic.c
Compiling stm32_dma.c
Compiling hal_lld.c
Compiling st_lld.c
Compiling pal_lld.c
Compiling board.c
Compiling memstreams.c
Compiling chprintf.c
Compiling main.c
Compiling usbdevice.c
Linking build/ch.elf
build/obj/hal.o: In function `halInit':
/home/eterse/Projects/dronController/./ChibiOS/os/hal/src/hal.c:110: undefined reference to `usbInit'
/home/eterse/Projects/dronController/./ChibiOS/os/hal/src/hal.c:116: undefined reference to `sduInit'
build/obj/usbdevice.o: In function `usb_event':
/home/eterse/Projects/dronController/./modules/usbdevice/usbdevice.c:60: undefined reference to `usbInitEndpointI'
/home/eterse/Projects/dronController/./modules/usbdevice/usbdevice.c:61: undefined reference to `usbInitEndpointI'
/home/eterse/Projects/dronController/./modules/usbdevice/usbdevice.c:62: undefined reference to `sduConfigureHookI'
build/obj/usbdevice.o: In function `usbdevice_init':
/home/eterse/Projects/dronController/./modules/usbdevice/usbdevice.c:102: undefined reference to `sduObjectInit'
/home/eterse/Projects/dronController/./modules/usbdevice/usbdevice.c:103: undefined reference to `sduStart'
/home/eterse/Projects/dronController/./modules/usbdevice/usbdevice.c:104: undefined reference to `usbStart'
/home/eterse/Projects/dronController/./modules/usbdevice/usbdevice.c:107: undefined reference to `USBD1'
build/obj/usbdevice.o:(.rodata.ep1config+0x8): undefined reference to `sduDataTransmitted'
build/obj/usbdevice.o:(.rodata.ep1config+0xc): undefined reference to `sduDataReceived'
build/obj/usbdevice.o:(.rodata.serialUsbConfig+0x0): undefined reference to `USBD1'
build/obj/usbdevice.o:(.rodata.ep2config+0x8): undefined reference to `sduInterruptTransmitted'
build/obj/usbdevice.o:(.rodata.usbConfig+0x8): undefined reference to `sduRequestsHook'
collect2: error: ld returned 1 exit status


I got this errors if #define HAL_USE_SERIAL_USB TRUE and #define HAL_USE_USB TRUE located in file included from halconf.h. If I declare this macros in halconf.h everything is ok.

Re: Includes from halconf.h

Posted: Sun Sep 06, 2015 2:40 pm
by Giovanni
The driver includes halconf.h so probably your macro is not taken or is overwritten.

Giovanni

Re: Includes from halconf.h

Posted: Sun Sep 06, 2015 2:47 pm
by kiv
Giovanni wrote:The driver includes halconf.h so probably your macro is not taken or is overwritten.

Giovanni

I've noticed that even matters are commented out in the description halconf.h.

Code: Select all

#include "some_file.h" -- Some file contains real HAL_USE_SERIAL and HAL_USE_USB defines.
...
//#define HAL_USE_SERIAL_USB TRUE
//#define HAL_USE_USB TRUE

If I write this everything works. I assume that the decision to compile separate object files taken some simple parser that analyzes halconf.h and don't support #include and comments.

Re: Includes from halconf.h

Posted: Sun Sep 06, 2015 3:01 pm
by Giovanni
You can disable it in the Makefile.

USE_SMART_BUILD = no

Giovanni