I am having trouble compiling the demonstration code for the STM32F4-Discovery using the arm-none-eabi
toolchain. The error is occuring in linking and this is the [first] error I'm receiving.
template/obj/stm32f4xx_it.o: In function `OTG_FS_IRQHandler':
template/src/stm32f4xx_it.c:192: undefined reference to `hpcd'
I've been trying to figure this out on and off for several months so I've created this github repository to track the project. The variable hpcd
is defined in template/src/usbd_conf.c
. My knowledge of C/C++ is unfortunately full of holes, so I'm hoping someone may help me both narrow down the problem and the suggest the proper way to fix it.
I have two questions.
hpcd
is included in the fileusbd_conf.c
. It is used in many files, but none of these files actually includeusbd_conf.c
, onlyusbd_conf.h
. The question is, by only including the header, can a file which declares a variable asextern PCD_HandleTypeDef hpcd;
use the variable without specifically including the.c
file?- Assuming the answer to question 1 is yes, why is it the function
OTG_FS_IRQHandler
isn't findinghpcd
? The chain of includes fromstm32f4xx_it
ismain.h -> usbd_core.h -> usbd_conf.h
.
I'm assuming the answer to question 1 is yes because this is the demonstration code I believe was running on the board when I purchased it. I can only assume the poblem is with the way I'm building it. Would anyone be willing to help me troubleshoot this problem? I would be happy to provide more details if relevant or to better structure this question, but I'm trying to avoid posting a full USB stack in my question. Thank you.