• Welcome to Andy's Workshop Forums. Please login or sign up.
 
April 25, 2024, 04:05:30 am

News:

SMF - Just Installed!


Getting started with STM32 development

Started by Andy Brown, March 23, 2015, 02:54:52 pm

Previous topic - Next topic

Andy Brown

I frequently receive emails from people asking if I could do a step-by-step guide for beginners wanting to get into STM32 development. When you've been doing this for years it's easy to forget that there can be a significant learning curve involved for those that want to get started with the open source route and that's a shame because you can create a powerful development environment that's easily a match for the commercial offerings.

Anyway, I spent some time over the weekend with a freshly minted Windows 7 x64 virtual machine and did everything from scratch, documenting each step as I went along. You can read the article here. It'll guide you through the entire process and at the end you'll have a totally free compile/edit/debug environment ready to go off and make your own projects.

This article covers Windows; after all there's only so many hours in a weekend. I do plan to follow up with the same process for Linux, probably targeting Ubuntu unless anyone feels strongly that Ubuntu's not a popular Linux development platform.
It's worse than that, it's physics Jim!

guga50

Hi, Andy! Thank you for your article.
Currently I'm using keil for my projects (free, limited to 32kb version). And this app has an option to debug in ram. All I need is just look at the size of the compiled code and then instruct debugger to load the code after 20000000 address (which is ram boundary), to shift interrupts vector table and to use end of ram address space (which is 20000000 + code size) as a ram starting address.
In your development environment I tried to check "debug in ram" option of Eclipse but with no luck. After reset the board starts executing last debugged code.
Is it possible to debug in RAM and where can I find configs for adjusting addresses like in Keil?

dronie

Hi Andy,

Thank you, It is a very infomative blog for beginners like me. I am trying to get STM32F429I Discovery board working with your C++ libraries, but have been not successful sofar. I read through your blog and downloaded "ase-master" and tried to build the mcu-blink program following the instructions given in README.md file. I first installed the libraries "scons mode=debug hse=8000000 mcu=f4 float=hard install INSTALLDIR=~/Install/stm32plus" and later executed SConstruct file using "scons mode=debug" in ase-master folder, but then I encounter following errors and thereby could not build the program.

C:/Users/robin/install/stm32plus/include/stm32plus-040003/fwlib/f4/stdperiph/inc/stm32f4xx_adc.h:601:63: error: 'uint8_t' was not declared in this scope
void ADC_AnalogWatchdogSingleChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel);
                                                               ^
C:/Users/robin/install/stm32plus/include/stm32plus-040003/fwlib/f4/stdperiph/inc/stm32f4xx_adc.h:608:31: error: variable or field 'ADC_RegularChannelConfig' declared void
void ADC_RegularChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel, uint8_t Rank, uint8_t ADC_SampleTime);
                               ^
C:/Users/robin/install/stm32plus/include/stm32plus-040003/fwlib/f4/stdperiph/inc/stm32f4xx_adc.h:608:31: error: 'ADC_TypeDef' was not declared in this scope
C:/Users/robin/install/stm32plus/include/stm32plus-040003/fwlib/f4/stdperiph/inc/stm32f4xx_adc.h:608:44: error: 'ADCx' was not declared in this scope
void ADC_RegularChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel, uint8_t Rank, uint8_t ADC_SampleTime);
                                            ^
C:/Users/robin/install/stm32plus/include/stm32plus-040003/fwlib/f4/stdperiph/inc/stm32f4xx_adc.h:608:50: error: 'uint8_t' was not declared in this scope
void ADC_RegularChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel, uint8_t Rank, uint8_t ADC_SampleTime);
                                                  ^
C:/Users/robin/install/stm32plus/include/stm32plus-040003/fwlib/f4/stdperiph/inc/stm32f4xx_adc.h:608:71: error: 'uint8_t' was not declared in this scope
void ADC_RegularChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel, uint8_t Rank, uint8_t ADC_SampleTime);
                                                                       ^
C:/Users/robin/install/stm32plus/include/stm32plus-040003/fwlib/f4/stdperiph/inc/stm32f4xx_adc.h:608:85: error: 'uint8_t' was not declared in this scope
void ADC_RegularChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel, uint8_t Rank, uint8_t ADC_SampleTime);
                                                                                     ^
C:/Users/robin/install/stm32plus/include/stm32plus-040003/fwlib/f4/stdperiph/inc/stm32f4xx_adc.h:609:28: error: variable or field 'ADC_SoftwareStartConv' declared void
void ADC_SoftwareStartConv(ADC_TypeDef* ADCx);
                            ^
C:/Users/robin/install/stm32plus/include/stm32plus-040003/fwlib/f4/stdperiph/inc/stm32f4xx_adc.h:609:28: error: 'ADC_TypeDef' was not declared in this scope
C:/Users/robin/install/stm32plus/include/stm32plus-040003/fwlib/f4/stdperiph/inc/stm32f4xx_adc.h:609:41: error: 'ADCx' was not declared in this scope
void ADC_SoftwareStartConv(ADC_TypeDef* ADCx);



Could you give me some hints what I was doing wrong?.

Andy Brown

Hi Robin,

This is happening because the SConstruct file for the fpga sprite engine project was written to be compatible with version 3.4.0 of stm32plus. All you need to do is build and install version 3.4.0 and you'll be good. Here's how.

Assuming you've cloned the stm32plus repo from github you first need to ensure that you've got the release tags. The following commands are all run from the stm32plus base directory (the one with the .git directory in it).


$ git fetch origin --tags


When that's done, make sure you've got the 3.4.0 tag:


$ git tag -l
3.0.0
3.0.1
3.0.2
3.1.0
3.1.1
3.2.0
3.3.0
3.4.0
3.5.0
3.6.0
4.0.0
4.0.1
4.0.2


Now check out the 3.4.0 tag:


$ git checkout 3.4.0
Note: checking out '3.4.0'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at 02cc018... update readme for release


Don't worry about all the git output, we're not making changes so we can ignore what it's trying to tell us. Now you can build:


$ scons mode=small mcu=f4 hse=8000000 float=hard -j12 install


Change the -j option to match your CPU core count. When the build has completed you can proceed with the fpga sprite engine build. You should probably do a 'git checkout master' in the stm32plus directory as well just in case you forget that you've checked out a tag.

Hope that helps. I will update the README in the FPGA project to make it clear that it's important to install the correct version of stm32plus.
It's worse than that, it's physics Jim!

JohnBurton

Thank you for the comprehensive writeup! I'm going to need to get this working for my project :)

I also ran across http://www.emblocks.org/web/ which looks like it might be an interesting alternative.
It appears to use the same compilers etc so hopefully your library would work with it?

I'm going to investigate anyway as it looks a bit more "lightweight" than eclipse which I never quite got on with very well.

EmBlocks

@JohnBurton

At the end of this week there will be a Eclipse project importer plugin for EB.