apache / mynewt-core

An OS to build, deploy and securely manage billions of devices
https://mynewt.apache.org/
Apache License 2.0
834 stars 369 forks source link

blinky demo for STM32F4-Discovery not works on STM32F429I-Discovery #1287

Open mintisan opened 6 years ago

mintisan commented 6 years ago

I followed the steps on Blinky, your “Hello World!”, on STM32F4-Discovery.

And every step's result looks fine.

But doesn't work at all, even I try to reset the board.

I also tried to flash the binary directly with command below:

st-flash write /Users/linjinhui/Github/mynewt/blinking/bin/targets/stm32f4disc_blinky/app/apps/blinky/blinky.elf.bin 0x8000000

But I can blink the leds with mbed demo or STM32Cube via st-link.

So the hardware is OK.

And nucleo-f401re also works fine with mynewt for nucleo-f401re board.

So the compiler is also OK.

Versions:

Do I skip any important steps?

My newt target show: stm32f429discovery and stm32f4discovery both not work on my STM32F429I-Discovery Board.

➜  blinking newt target show
targets/my_blinky_sim
    app=apps/blinky
    bsp=@apache-mynewt-core/hw/bsp/native
    build_profile=debug
targets/nucleo_f401re_blinky
    app=apps/blinky
    bsp=@apache-mynewt-core/hw/bsp/nucleo-f401re
    build_profile=debug
targets/nucleo_f401re_boot
    app=@apache-mynewt-core/apps/boot
    bsp=@apache-mynewt-core/hw/bsp/nucleo-f401re
    build_profile=optimized
targets/stm32f4disc_blinky
    app=apps/blinky
    bsp=@apache-mynewt-core/hw/bsp/stm32f4discovery
    build_profile=debug
targets/stm32f4disc_boot
    app=@apache-mynewt-core/apps/boot
    bsp=@apache-mynewt-core/hw/bsp/stm32f4discovery
    build_profile=optimized
➜  blinking

My main.c :

/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

#include <assert.h>
#include <string.h>

#include "sysinit/sysinit.h"
#include "os/os.h"
#include "bsp/bsp.h"
#include "hal/hal_gpio.h"
#ifdef ARCH_sim
#include "mcu/mcu_sim.h"
#endif

static volatile int g_task1_loops;

/* For LED toggling */
int g_led_pin;

/**
 * main
 *
 * The main task for the project. This function initializes packages,
 * and then blinks the BSP LED in a loop.
 *
 * @return int NOTE: this function should never return!
 */
int
main(int argc, char **argv)
{
    int rc;

#ifdef ARCH_sim
    mcu_sim_parse_args(argc, argv);
#endif

    sysinit();
    //    g_led_pin = LED2;  // for stm32f429discovery
    g_led_pin = LED_BLINK_PIN;  // for necleo-f401r1
    hal_gpio_init_out(g_led_pin, 1);

    while (1)
    {
        ++g_task1_loops;

        /* Wait one second */
        os_time_delay(OS_TICKS_PER_SEC);

        /* Toggle the LED */
        hal_gpio_toggle(g_led_pin);
    }
    assert(0);

    return rc;
}
mintisan commented 6 years ago

I tried to use stm32f429discovery to re-build, but I can't load successfully after building.

➜  blinking newt load stm32f429disc_blinky
Loading app image into slot 1
Error: Downloading /Users/linjinhui/Github/mynewt/blinking/bin/targets/stm32f429disc_blinky/app/apps/blinky/blinky.img to 0x8020000
Open On-Chip Debugger 0.10.0
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 2000 kHz
adapter_nsrst_delay: 100
none separate
srst_only separate srst_nogate srst_open_drain connect_deassert_srst
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : Unable to match requested speed 2000 kHz, using 1800 kHz
Info : clock speed 1800 kHz
Error: open failed
in procedure 'init' called at file ".openocd_cmds", line 2
in procedure 'ocd_bouncer'

load - Load application image on to the board for <target-name>

Usage:
  newt load <target-name> [flags]

Flags:
      --extrajtagcmd string   Extra commands to send to JTAG software

Global Flags:
  -h, --help              Help for newt commands
  -j, --jobs int          Number of concurrent build jobs (default 4)
  -l, --loglevel string   Log level (default "WARN")
  -o, --outfile string    Filename to tee output to
  -q, --quiet             Be quiet; only display error output
  -s, --silent            Be silent; don't output anything
  -v, --verbose           Enable verbose output when executing commands
➜  blinking
➜  blinking newt target show
targets/my_blinky_sim
    app=apps/blinky
    bsp=@apache-mynewt-core/hw/bsp/native
    build_profile=debug
targets/nucleo_f401re_blinky
    app=apps/blinky
    bsp=@apache-mynewt-core/hw/bsp/nucleo-f401re
    build_profile=debug
targets/nucleo_f401re_boot
    app=@apache-mynewt-core/apps/boot
    bsp=@apache-mynewt-core/hw/bsp/nucleo-f401re
    build_profile=optimized
targets/stm32f429disc_blinky    ## load failed
    app=apps/blinky
    bsp=@apache-mynewt-core/hw/bsp/stm32f429discovery
    build_profile=debug
targets/stm32f429disc_boot
    app=@apache-mynewt-core/apps/boot
    bsp=@apache-mynewt-core/hw/bsp/stm32f429discovery
    build_profile=optimized
targets/stm32f4disc_blinky
    app=apps/blinky
    bsp=@apache-mynewt-core/hw/bsp/stm32f4discovery
    build_profile=debug
targets/stm32f4disc_boot
    app=@apache-mynewt-core/apps/boot
    bsp=@apache-mynewt-core/hw/bsp/stm32f4discovery
    build_profile=optimized
➜  blinking
utzig commented 6 years ago

I've never had any issues loading on this particular board but some lower-speed boards sometimes have a similar fail when loading the app (never the bootloader!). It never bothered me enough to try to find the exact error which I would suspect might be on the openocd_load function in hw/scripts/openocd.sh related to something the bootloader might have just done (assert + reset maybe). Anyway it usually works in those cases if doing a followup newt load ... just after the first one or in worst cases pressing the RESET button in the board just before executing newt load ....

mintisan commented 6 years ago

@utzig

Thank you for your reply!

I found that stm32f429discovery may have two different versions: stm32f429disc and stm32f429disc1.

I found that my board's is stm32f429i_disc1 but not stm32f429i_disc.

So I changed openocd's cfg from board/stm32f429discovery.cfg to board/stm32f429disc1.cfg. And can be downloaded now.

But the LED isn't blinking either.

Maybe initialization for stm32f429disc1 board is not supported yet?

utzig commented 6 years ago

The one I have actually is the stm32f429disc1. I guess the only difference between them is the st-link version, no? You can try to find out if a breakpoint/fault happened by newt debug stm32f429disc_blinky or newt debug stm32f429disc_boot (depending on which one failed). A backtrace there might be helpful to find out what's happening. Also you could try joining the slack channel (https://join.slack.com/mynewt/shared_invite/MTkwMTg1ODM1NTg5LTE0OTYxNzQ4NzQtZTU1YmNhYjhkMg), that would allow for a better communication if debugging is required.

sjanc commented 5 years ago

is this issue stil valid?