Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make demo.elf fails #9

Open
baybled opened this issue Jun 14, 2018 · 7 comments
Open

Make demo.elf fails #9

baybled opened this issue Jun 14, 2018 · 7 comments

Comments

@baybled
Copy link

baybled commented Jun 14, 2018

Hello, I am following along with your book "Discovering the STM32 Microcontroller". On page 49 there is instruction to type "make" in the demo folder. The stm32f10x.h file cannot be found despite Makefile.common pointing to the right place. I even checked by navigating to the location and looking at the file!

This is the error from make:


~/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-eabi-gcc -c -O1 -g -mcpu=cortex-m3 -mthumb  -I.. 
-I/gcc-arm-none-eabi_samples/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x 
-I/gcc-arm-none-eabi_samples/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/CMSIS/CM3/CoreSupport 
-I/gcc-arm-none-eabi_samples/STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/STM32F10x_StdPeriph_Driver/inc 
-I. -DSTM32F10X_MD_VL  -DUSE_STDPERIPH_DRIVER -DUSE_FULL_ASSERT  
-I../Library/ff9/src -I../Library ../startup_stm32f10x.c -o startup_stm32f10x.o

../startup_stm32f10x.c:3:23: fatal error: stm32f10x.h: No such file or directory
compilation terminated.
make: *** [../Makefile.common:66: startup_stm32f10x.o] Error 1

Please could you send help, I would like to carry on with this book.

I can see the first linked library is "-I.." could that be where the problem lies? I will carry on looking at the files and wait for your reply.

@baybled
Copy link
Author

baybled commented Jun 14, 2018

I fixed it by setting absolute paths for LIBROOT, TOOLROOT and TEMPLATEROOT but now encounter a new error:

make: *** No rule to make target 'startup_stm32f10x.o', needed by 'Demo.elf'. Stop.

@geoffreymbrown
Copy link
Owner

geoffreymbrown commented Jun 14, 2018 via email

@baybled
Copy link
Author

baybled commented Jun 14, 2018

Sorry do you mean the "startup_stm32f10x.h" file? I've done a grep search and found nothing matching this. In the same directory as Makefile.common there is a "startup_stm32f10x.c" file. Do you know where this file could be located?

and also, thank you for writing this book. I appreciate the way your writing employs brevity and if there is a more current edition, or a better version, could you please let me know

@geoffreymbrown
Copy link
Owner

geoffreymbrown commented Jun 14, 2018 via email

@baybled
Copy link
Author

baybled commented Jun 14, 2018

E: download https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads as toolchain to fix problems

Solution found (this writeup is to help those who are struggling)

tl;dr copy from a github of someone who uploaded all the software back in 2014 and update Makefile.common

Now I have a path to a pair of files called system_stm32f10x and start_stm32f10x in a separate directory. My Makefile contains a reference to those files. I have found other files are not included and so, I have a repo that I am borrowing files from thanks to @emdarcher. I just run the program and look at which file is missing and where it was expected. The repo has it in the right place so it's just a case of copying across to my own personal system.

Here is the branch where the files are located, it includes a link to the repo: https://github.com/emdarcher/stm32-learning/tree/master/books/discovering-stm32/STM32-Template

@emdarcher also did many of the exercises and I have no doubt that when I am stuck, I will look into his solutions to try and gain a better understanding (there's no point copying, the only use here is to use his files for hints)

thank you again @geoffreymbrown

@Andy2No
Copy link

Andy2No commented Aug 14, 2019

Solution found (this writeup is to help those who are struggling)

tl;dr copy from a github of someone who uploaded all the software back in 2014 and update Makefile.common

Now I have a path to a pair of files called system_stm32f10x and start_stm32f10x in a separate directory. My Makefile contains a reference to those files. I have found other files are not included and so, I have a repo that I am borrowing files from thanks to @emdarcher. I just run the program and look at which file is missing and where it was expected. The repo has it in the right place so it's just a case of copying across to my own personal system.

Here is the branch where the files are located, it includes a link to the repo: https://github.com/emdarcher/stm32-learning/tree/master/books/discovering-stm32/STM32-Template

This looked promising, so I tried to follow your advice, but I still can't get this to work in Windows.

Could you expand a little on what you did, and maybe share your makefile? I would still have to edit it, for use on Windows, but it might at least get me a bit further with trying to work through Geoffrey's book.

I have two different versions of the ARM GCC toolchain set up, and I have compiled and built a couple of projects successfully - where I already had a working makefile, or one that only needed paths changing. In this case, I'm getting nowhere.

I followed the advice in issue #2, about the same error message (correcting the path for the library folder to the current location), and perhaps got a bit further, but I still get this error:

" No rule to make target 'system_stm32f10x.o', needed by 'Demo.elf' "

FWIW, I'm not a beginner, as a programmer - just to this environment. I have yet to find any useful guide to writing or understanding make files for GCC, and it's a long time since I used any sort of make utility at all.

I'm not sure how many beginners would be able to get anywhere with building the code examples, any more. From what I've read so far, being on Linux doesn't necessarily help - everything depends on the particular version of everything else.

@Andy2No
Copy link

Andy2No commented Aug 15, 2019

Okay, I figured out how to get past that, to get Demo.elf to compile. I thought I'd write this here, before I forget.

This was the error I was getting before:

make: *** No rule to make target 'system_stm32f10x.o', needed by 'Demo.elf'. Stop.

After fixing the paths in Makefile.common, I copied these three files from where I'd put the STM32F10x_StdPeriph_Lib_V3.5.0, to the Library folder, in emdarcher's version of the project (see posts above) ;

stm32f10x.h
system_stm32f10x.h
system_stm32f10x.c

from:

D:\Downloads\_STM32 microcontrollers\gcc-arm-none-eabi_samples\STM32F10x_StdPeriph_Lib_V3.5.0\Libraries\CMSIS\CM3\DeviceSupport\ST\STM32F10x

to:

C:\gcc-projects\STM32-Templates\stm32-learning\books\discovering-stm32\STM32-Template\Library

To avoid confusion, I've given the full paths, on my PC, though of course, this needs changing to where they're actually put.

The key changes to Makefile.common were the paths in these lines, altered to correspond to where I'd put the library:

LIBROOT="D:\Downloads\_STM32 microcontrollers\gcc-arm-none-eabi_samples\STM32F10x_StdPeriph_Lib_V3.5.0"

DEVICE= $(LIBROOT)/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x

Using quotes allows for spaces and backslashes in the Windows paths, so they can be copied from an explorer window, using "Copy address as text", by right clicking on the address bar at the top (that may need to be enabled, in Tools->Folder options, in some versions of Windows).

I've now been able to compile it successfully, using two versions of GCC for Windows - GNU Tools for ARM Embedded Processors 7-2017-q4-major 7 2017, and GNU Tools for ARM Embedded Processors 8-2018-q4-major 8 2018.

In each case, I started (inside the Demo folder) with;

make clean

followed by

make Demo.elf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants