Author Topic: Starting with STM32F401 Codeblocks  (Read 22184 times)

Offline yvesuhc

  • Single posting newcomer
  • *
  • Posts: 7
Starting with STM32F401 Codeblocks
« on: March 02, 2017, 12:21:06 pm »
Im a total beginner with codeblocks and ARM. Still i want to programm the stm32 board with codeblocks but i dont know what i Need to download to make a projekt in codeblocks. It would be nice if anybody could explain me what to download and what to do to be able to creat a c projekt with this board on codeblocks.  :)

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Starting with STM32F401 Codeblocks
« Reply #1 on: March 02, 2017, 01:15:37 pm »
Well this is all a bit complicated for noobs. I have no stm32 around so i can try to guide you blind but this will take some effort and time.
Are you on windows or on linux?

For first you will need a toolchain: https://developer.arm.com/open-source/gnu-toolchain/gnu-rm

after you have set up this i would recommend to test it with something known to work and easy to set up:  http://pandafruits.com/stm32_primer/stm32_primer_minimal.php
if you have running this minimal example we can start to integrate it in codeblocks...

Offline yvesuhc

  • Single posting newcomer
  • *
  • Posts: 7
Re: Starting with STM32F401 Codeblocks
« Reply #2 on: March 02, 2017, 01:25:25 pm »
where do i need to install the toolchain ? SHould i just put it in the codeblocks ordner ?  //thanks for the help and i have windows 10 btw
« Last Edit: March 02, 2017, 01:27:13 pm by yvesuhc »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Starting with STM32F401 Codeblocks
« Reply #3 on: March 02, 2017, 02:50:50 pm »
where do i need to install the toolchain ? SHould i just put it in the codeblocks ordner ?  //thanks for the help and i have windows 10 btw

You need to install the Compiler/toolchain on your computer.
EDIT: Install means download the installer and run the installer to do the installation of the toolchain.
Then, you should test the compiler using the link provided, above

After, that you can work with setting up Code::Blocks to work using the Compiler.

Tim S.
« Last Edit: March 02, 2017, 02:54:15 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline yvesuhc

  • Single posting newcomer
  • *
  • Posts: 7
Re: Starting with STM32F401 Codeblocks
« Reply #4 on: March 03, 2017, 10:31:32 am »
If i try to set up the compiler (setup toolchain in codeblocks/global compiler setings/compilers installation directory)
it always says that it cant find the  compiler executables. Any ideas why ?
Its probably because i didnt change the .exe files (program Files). But i also dont know which files i should put there.
« Last Edit: March 03, 2017, 10:35:53 am by yvesuhc »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Starting with STM32F401 Codeblocks
« Reply #5 on: March 03, 2017, 12:04:49 pm »
yes, you have to set the names like the executable you find in the installation folder of the compiler...
you replace "gcc" with something like "arm-none-eabi-gcc.exe" and so on...

Offline yvesuhc

  • Single posting newcomer
  • *
  • Posts: 7
Re: Starting with STM32F401 Codeblocks
« Reply #6 on: March 03, 2017, 12:30:59 pm »
I replaced the first 4 files with:    arm-none-eabi-gcc.exe,   arm-none-eabi-c++.exe    and  arm-none-eabi-g++.exe,   arm-none-eabi-ar.exe
are these the right files ? which files otherwise ?
And if i creat a projekt do i need a empty projekt or something else ?   

Thx for the help
// i edited the GNU GCC Compiler
« Last Edit: March 03, 2017, 12:33:40 pm by yvesuhc »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Starting with STM32F401 Codeblocks
« Reply #7 on: March 03, 2017, 01:16:26 pm »
Quote
are these the right files ? which files otherwise ?
i have no idea how this files are called on your system... Look in the bin folder of the installation folder of the compiler....

Quote
And if i creat a projekt do i need a empty projekt or something else ?   
One step after the other. You have to learn to stand before you can learn to run ;)

Have you tried to build the tings i posted in the link above?

Offline yvesuhc

  • Single posting newcomer
  • *
  • Posts: 7
Re: Starting with STM32F401 Codeblocks
« Reply #8 on: March 04, 2017, 11:40:34 am »
If I try to build the c code you gave me nothing happens. No error but also nothing else.

I also didnt add the basic libary for the stm32f401 so i dont realy see how this should work?
« Last Edit: March 04, 2017, 11:51:51 am by yvesuhc »

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Starting with STM32F401 Codeblocks
« Reply #9 on: March 04, 2017, 12:08:19 pm »
So, you created the text files using a text editor, yes or no?
And, you used the terminal to try to build the files created, yes or no?

If not, the above what did you do that nothing happened?

Did you install the compiler, if yes what is the C or C++ compiler filename?

On Windows my C Compiler filename followed by "--version"
Code
gcc --version
ran in the terminal returns
Code
gcc.exe (Rev2, Built by MSYS2 project) 6.3.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

What does your C or C++ compiler return as its version information?

Tim S.
« Last Edit: March 04, 2017, 12:11:53 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Starting with STM32F401 Codeblocks
« Reply #10 on: March 04, 2017, 04:58:13 pm »
Only to make clear why we make you go this way:
Codeblocks is not a compiler, but a IDE. So that codeblocks can work you need a working compiler environment. The link i posted tests this environment. As far as i can see there is all compact and neat described, because if you develop for embedded systems you have to check a lot other things too, like the linker script. If you test your compiler environment with the above link, we can be sure that the compiler is working as expected and so all problems we will encounter are codeblocks related and not compiler related...

Quote
If I try to build the c code you gave me nothing happens. No error but also nothing else.
please post allways the exact steps you do. Only this description won't help anyone.


Offline yvesuhc

  • Single posting newcomer
  • *
  • Posts: 7
Re: Starting with STM32F401 Codeblocks
« Reply #11 on: March 11, 2017, 06:19:58 pm »
So everything i did till now:
I downloaded the GNU Tools ARM Embedded and placed it inside my programmx86 ordner.
After that i changed the settings of the GNU GCC Compiler for ARM in Global compiler settings.
I changed the files:
C compiler ->arm-none-eabi-gcc.exe
C++ compiler -> arm-none-eabi-g++.exe
linker for dynamic libs -> arm-none-eabi-g++.exe
linker for static libs -> arm-none-eabi-ar.exe
resource compiler -> nothing
make programm -> make.exe

So i realy DONT KNOW if these are the right files. these are the files in the toolchain but i dont know if they are the right ones becuase there was no readme.txt file or anything like that

 So now my question did i MISS somehting here ? did I install the toolchain on the wrong place ? do i have to put it inside the codeblocks ordner ?

Thx for answers
 :)

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Starting with STM32F401 Codeblocks
« Reply #12 on: March 11, 2017, 08:41:09 pm »
Did you install the Compiler?

I ask this because you said you placed it inside a folder; but, you never said you ran the installer.

Edit: If you installed the Compiler, did you set the path to the Compiler in the Code::Blocks settings?

Quote
NOTE: The compiler's installation directory is exactly this: the installation directory. Not the "bin" subdirectory nor any other.

Tim S.
« Last Edit: March 11, 2017, 08:46:07 pm by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: Starting with STM32F401 Codeblocks
« Reply #13 on: March 12, 2017, 01:56:10 am »
1) Try not to use paths with spaces, or non ascii symbols, this makes things more complicated
2) You probably need to run the installer for the compiler, not only copy things. It does not have to be (my personal opinion: IT SHOULD NOT) be in a sub folder of codeblocks
3) The names look ok
4) You can create a empty project, or you use a ARM project
5) If you have a problem always post a full rebuild log in code tags: http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_(general)#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F
6) Have you tried the example from the link? (This link does not use codeblocks, so you should also not use codeblocks) For this you should check that your compiler installation is in the PATH environment variable of your console

i hope you don't loose the motivation, because as soon as it works it will be awesome ;)

Offline yvesuhc

  • Single posting newcomer
  • *
  • Posts: 7
Re: Starting with STM32F401 Codeblocks
« Reply #14 on: March 12, 2017, 11:32:19 am »
Ok so far so good but i dont know how to compile a programm wiht the console. The Link you send me also doesnt explain this.
Also there is no file to download so i guess i have to put the code inside a text file and change the .txt ???.
other than that the toolchain is in the PATH variable so i should be able to use it.

Thx for the help

Edit: btw if i simply copy past the text this happens:
C:\Users\Lord>arm-none-eabi-gcc -c -fno-common -O0 -g -mcpu=cortex-m3 -mthumb -o main.o main.c
arm-none-eabi-gcc: error: main.c: No such file or directory
arm-none-eabi-gcc: fatal error: no input files
compilation terminated.

I think that means that at least the compiler works but now i have to edit the comand to my own folder.
« Last Edit: March 12, 2017, 11:41:36 am by yvesuhc »