4

The complete summary of the error is as follows:

Info: Internal Builder is used for build
arm-atollic-eabi-gcc -o test.elf main.o stm32f4xx_it.o system_stm32f4xx.o -T../Debug_STM32F401VC_FLASH.ld -specs=nosys.specs -static -Wl,-cref,-u,Reset_Handler -Wl,-Map=test.map -Wl,--defsym=malloc_getpagesize_P=0x80 -Wl,--start-group -lc -lm -Wl,--end-group -specs=nano.specs 
c:/program files (x86)/atollic/truestudio for stm32 9.0.1/armtools/bin/../lib/gcc/arm-atollic-eabi/6.3.1/../../../../arm-atollic-eabi/bin/ld.exe: warning: cannot find entry symbol Reset_Handler; defaulting to 08000000
main.o: In function `main':
C:\Users\Deepayan\Atollic\TrueSTUDIO\STM32_workspace_9.0\test\Debug/..\main.c:26: undefined reference to `TM_USART_Init'
C:\Users\Deepayan\Atollic\TrueSTUDIO\STM32_workspace_9.0\test\Debug/..\main.c:29: undefined reference to `TM_USART_Puts'
C:\Users\Deepayan\Atollic\TrueSTUDIO\STM32_workspace_9.0\test\Debug/..\main.c:33: undefined reference to `TM_USART_Getc'

Where should we specify the Reset Handler? Thanks.

srkdb
  • 775
  • 3
  • 15
  • 28

4 Answers4

6

Handlers are defined in an assembler startup file, which is generated automatically by STM32CubeIDE or STM32CubeMX. The file is located in a folder called "Startup" at the root of your project. It is named after your MCU, for example startup_stm32f303xe.s, startup_stm32l476rgtx, etc.

The warning "cannot find entry symbol Reset_Handler" means the startup file is either 1. corrupted, 2. missing, or 3. not included in your build. To fix cases 1 and 2, simply re-generate the code from STM32CubeIDE or STM32CubeMX.

Case 3 is more interesting. Upon code generation, STM32CubeIDE and STM32CubeMX sometimes mark the "Startup" folder as "Exclude from build". To make things worse, the folder doesn't have the "excluded" icon, so there's no obvious way to notice it. So you need to right-click the "Startup" folder, go to "C/C++ Build" and uncheck the "Exclude resource from build" checkbox. This issue seems to arise randomly, often with projects copied from other projects.

steph643
  • 2,343
  • 1
  • 23
  • 20
  • 1
    Case 3 is it for me! Right-clicking the folder holding the startup_stm32l071cbtx.s file, and removing the UNWANTED checkmark "Exclude resource from build" helped. – EmbeddedGuy Aug 02 '21 at 17:46
2

Handlers are defined in the assembler startup file. For example startup_stm32f303xe.s for the STM32F303xe family of uCs.

Your project is not properly configured and you are missing the important files.

0___________
  • 60,014
  • 4
  • 34
  • 74
  • The Reset_Handler problem is now taken care of. But the "undefined reference" problem still persists. I have those 3 functions defined in a .h file in the same directory as main(). – srkdb Aug 20 '18 at 17:02
  • you do not link the object files with those functions. the TM functions are in thhe another C files which have to be compiled and linked – 0___________ Aug 20 '18 at 23:06
  • The "undefined reference" issue is resolved. To my dismay, now the Reset_Handler problem reappears as a warning. – srkdb Aug 21 '18 at 16:54
  • @db18 IMO DIY project is too difficult for you at the moment. Create the cube project and import it. It will sort out all the issues and you will have all makefiles generated automatically – 0___________ Aug 21 '18 at 17:07
  • Where can I find the Cube Project? – srkdb Aug 21 '18 at 17:37
  • 2
    https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=2ahUKEwjJkpz41_7cAhXFUlAKHYB4CmkQFjAAegQIABAC&url=https%3A%2F%2Fwww.st.com%2Fen%2Fdevelopment-tools%2Fstm32cubemx.html&usg=AOvVaw14YNT5a6DNbWgOHY7R0bjO – 0___________ Aug 21 '18 at 17:38
2

I had the same Issue with reset-handler. Caused by the toolchain not compiling the startup.s file. Eclipse toolchain did not include it automatically, because it only takes assembly-files when the file-type is S, not s. So the fix was renaming startup.s to startup.S.

GreenBærg
  • 115
  • 1
  • 9
  • 1
    For me, only the first part of this answer worked: toolchain not compiling it. Name change did not help, but while renaming, I have noticed the UNWANTED checkmark "Exclude resource from build". Removing the checkmark helped. – EmbeddedGuy Aug 02 '21 at 17:44
0

Check that the assembly startup file is located in a folder marked with a blue circle icon with letter C inside. This mark means that this folder is added to project's known source locations and the builder will check these directories for source files to be translated/compiled. To do that, go to project settings -> C/C++ General -> Paths and Symbols; in the tab Source Locations click Add Folder, in the browse dialog showing your project's folders select the folder that contain the source files to be built (both C and assembly). Click OK and apply the new settings. At least it worked for me