01- First time with STM32F429 Discovery

Ok, you got your STM32F429 DIscovery board and you don’t know how to use it. In this tutorial I will explain how to use this board with CooCox IDE. I prefer install from their CoCenter. You will need to download ARM GCC from here. There is also youtube tutorial, make sure you did all correct.

So, you have finished installing CoIDE. Open it and click Project -> New project. Choose your project name and project path and click Next. In the next step choose Chip and Next.

CooCox does not support STM32F429 for now, but we can use STM32F407 version which works pretty good. So type “stm32f407vg” in filter, select it and click Finish.

First project repository pageYou should have a window like this. Here you select all peripheral you will use in your project.

In every project you have to select under BOOT “CMSIS BOOT”. When you click on checkbox, CMSIS CORE is automatically checked. This 2 libraries you have to always use in project.

Our first project will just blinky led on board, so we need to select GPIO Library. This is General Purpose Input/Output to use with our physical pins on microcontroller.

Repository componentsOn the bottom left you have project files. Open main.c and copy bottom program inside and press F7. Your project should be built without errors. When is built, click on 7th icon from the left on top, it says “Download code to flash“. Of course, you have to connect your board with USB cable.

Both onboard leds (red and green) should now toggle in period.

Program (I will not describe how it works for now, other tutorials will explain this):

Download Project: CooCox project

I hope this help to you for your first time.


Owner of this site. Also electronic enthusiasts, web developer, 3D printer fan, handball player and more. Big fan of STM32F4 devices. In anticipation of the new Discovery board for STM32F7 lines.

You may also like...

Read before commenting!

Before you make a new comment, make sure you agree with things listed below:

  • - Read post to make sure if it is already posted what you are asking for,
  • - Make sure you have the latest version of libraries used in your project,
  • - Make a clean and grammatically correct written message,
  • - Report as many details as possible, including what have you done so far,
  • - Do NOT post any code here. Use Pastebin,
  • - Do NOT post any error codes here. Use Pastebin,
  • - Specify STM32Fxxx family and used Discovery/EVAL/Nucleo or custom made board,
  • - Make sure your clock is set correct for PLL,
  • - If you are using my HAL drivers, please check this post how to start.
Comment will be deleted on breaking these rules without notification!
  • Asic Consultant

    This is great. How about using the LCD in RGB mode on discovery board?

    • Look at “all libraries” section. Lcd is there too 🙂

      • Asic Consultant

        Is that in using the LCD in RGB mode?

        • RGB565 mode

          • Asic Consultant

            OK, that wasn’t clear in the demo.
            Do any of your stuff have demos using the STemWin code?
            I need advanced widget support, not just buttons.

            FYI: Your stuff is very nice. I appreciate it.

          • You should realize, because of ili9341 controller 😉

            Not yet implemented, coming soon.

  • Adnan Kurt

    Thanks for sharing all these detailed and finely organized information. And a question: Any advice for using “only” ST supplied peripheral drivers and libraries? I do not want to use CoIDE wizard to deliver required/ selected drivers and files. However, I have encountered many troubles while building the ST projects for example. When trying your basic projects, I have followed your path, it worked. However, had to use CoIDE wizard again.


    • You can use my project as a template and always use it.

  • bibliognost

    I tried to follow the steps documented herein. I was able
    to create a new project, using stm32f407vg data as a
    template, patch Tilen’s code into main(), and get it to
    build without errors or warnings.

    I then hooked up my STM32F429 Discovery board, and clicked
    on the 7th button. This terminated in an error message:
    “Error: Connect failed, check config and cable connection”

    Google directed me to a posting on the CooCox forum on this
    very issue:

    One of the suggestions there was to attempt to program the
    board using CoFlash in standalone mode. The /Config tab of
    this application requires you to supply all kinds of
    intimate information about the processor you want to
    program. I used the defaults:
    Device: ST STM32F407VG
    RAM Start: 0x20000000
    RAM Size: 0x00020000
    Flash Driver: STM32F4xx 1024KB Flash, 1M, 0x8000000H-0x080FFFFFH
    USB Adapter Setup: ST-Link
    Max Clock: 1 MHz
    Port: SWD
    Add Flash Algorithm: SMT32F4xx 1024KB Flash, 1M

    I then moved to the /Command tab, and to simplify things,
    clicked on the [Erase] button. This produced almost the
    exact same diagnostic.
    “Connect failed, check config and cable connection”

    My cable is a standard USB-A to USB-B mini that has worked
    with other devices (including programming this same board
    with the ARM MDK5 crippleware IDE). I previously installed
    the STM32 STLink USB driver from the ST Micro web site to
    handle programming of this board.

    I am at a loss at what else to check in my configuration.

    Another suggestion was to use the default ST-Link loader. It
    is unclear what that is. I was just hoping to follow the
    steps in the tutorial to build and load my first app.

    What am I missing?


    • Hi.

      I have no idea. But if you send me the project, I can take a look.

  • bibliognost

    A bit of follow-up…

    After conferring off-line, Tilen and I both came to the
    conclusion that my problems lay not with the project, but
    with my hardware, most likely the USB driver.

    And indeed, when I had first plugged in the Discovery board,
    Windows attempted to install the driver automatically, and
    for the first time I can remember announced that it couldn’t
    find one for this device!

    I snooped around some more and using tidbits from both these
    web sites:

    discovered that I had installed the right driver, but had
    not installed it correctly. After uninstalling and re-
    installing it according to these instructions, I can now
    program my application without further complications.

    I will move on. Thanks for the ideas!

  • Richie

    It perfectly works. Thanks.

  • Fawad Aslam

    can i run this code in stm32f429i-disco?

    • Yes

      • Fawad Aslam

        but there are no such files as “stm32f4xx_rcc.h” and “stm32f4xx_gpio.h” in stm32f429i-disco. How to include these files

  • krishna_kumr243

    While starting a new project i am getting the below problem

    • I have no idea. It looks like new CoIDE 2 has some problems with that.

      • krishna_kumr243

        Thank you for your concern. i will check with the older version. 🙂

  • PatrickGerrard

    Greetings Majerle, are the projects compatible with stmf10 series? Thank you!

    • Hi,

      what do you think? Are they? 😉
      “First time with STM32F429 Discovery”

  • Fawad Aslam

    i have written this code but its giving 2 errors
    1. “Declaration may not appear after executable statement in block “GPIO_InitTypeDef GPIO_InitDef”
    2. Same as 1st error for “volatile int i”
    how to fix?

    • Declaration may not …

      So make declarations first for variables in side main.c then call first function.
      Swap first 2 lines in main.c

      Error tells you what is wrong!

      • Fawad Aslam

        thanks, it worked 🙂

  • Guest

    don’t forget to include RCC on the Peripherals components 🙂

  • Yuri Sokolov

    hello, if i have not peripheral.st in step 3 in repository. i have only common and boot?

    • If you use Coocox 2.xx then this tutorial will not be helpful for you.

  • Rusmun


  • MKH

    what do this errors mean?

    • Coocox related compiler problems. Project setup in your coocox environment.

  • Pingback: STM32 Architecture and programming()

  • nass

    when I try to download this code on STM32F49I-DISCO I get this message
    Error: Failed to open flash driver file

    Thank you for your help

    • Keil uvision version?

      • nass

        I am using CoIDE_V2Beta

        • Would you mind to tell more about your problem or what?
          I can’t know what is going wrong from what you told me.

          • nass

            The code (fisrtsProject) compiles correctly under CoIDE_V2Beta.
            But when I try to upload the binary into my STM32F429 I have the following error message
            Error: Failed to open flash driver file
            I think that the IDE is destinated to only program STM32F4 DISCO not STM32F429

          • This does not care about which board is connected.
            Are drivers updated? Something is strange with Coocox implementation I would say. I don’t use it.

          • nass

            What version of Keil do you use though?

          • latest, 5.15

          • nass

            Thank you Majerle. I will try to implement using Keil.
            I was wondering if you’ve done a CAN transfer interface between two STM32F429.

          • nass

            Have you done a project to transmit data between two STM32F49I DISCO MCUs using CAN bus?

          • No

          • nass

            A final question: where is the Rx/Tx CAN bus located on the STM32F429I.
            I’m using PD0 for RX and PD1 for Tx. Is that correct?

          • You know why datasheets are used?

          • nass

            Of course. But didn’t find anything useful in there 🙁

          • What did you searched, exactly tell me everything you dud till now to get your pins.

          • nass
          • Perhaps you should take a datasheet for MCU, not board! On my site you have some datasheets, under links in menu. You could use search!!

  • Cristian

    Could anyone help me with a problem?

    I want to replace the name of a variable that I use in many parts of my code, so I do not wish to do it manually one by one. I do the following:

    Search Menu -> Search .. -> File Search -> Replace -> OK

    I get the following message (see image).

    I really appreciate any help

    • No idea. Something you should ask on dedicated forum.

  • C. Sch

    in CoIDE there is a new Interface. It doesn’t fit the old suggestion. I’m really new to this topic and closly lost. I’m trying to start my pretty first project, but I cant even figure out what I do need to include and why.

    Say I would like to let an LED blink once every 3 sec. (Just for testing..) How can I realize this?

    Next, I need to implement some other things, like finite-field arithmetics, elliptic curve arithmetics and so on, what do I need to import for this? I guess I will need some special M4 skills.

  • Jauhar Nafis

    Hi, How to make DSP library at coocox? Thank’s. i need a example please

  • C. Sch

    This works right now perfect on a STM32F429-Discovery but not on CJMCU-407. I can’t see why. But now I’m on to get my learning process started.

  • Esad Alışık

    I used this codes in Atollic but it gave me this problem
    undefined reference to ‘sEE_TIMEOUT_UserCallback’
    Why can I solve this problem?

  • Fensou Miles

    Just got an stm32 f7…plugged the USB cable and only the COM LED7 lights up. ( Read on the Getting Started that 2 LEDs were to light up; PWR LED2 and COM LED7). I really don’t know what to. It’s so depressing! I am a beginner and I really, really need help. Even a coach if possible. It’s like being thrown in the Amazon and asked to find your way out. In case this forum doesn’t send notifications to those who comment, I’ll glad to receive your email at milesfenzou@yahoo.fr.

    • Hello, for beginning, install STM32 ST-Link Utility sw to get ST-Link drivers on your PC

  • Fritzblitz

    I have downloaded the Standard Peripharal Library Driver for my board. But how can I integrate it to my project in Atollic True Studio??? I have searched a lot, but couldnt find answers…