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

[reset] Board won't start up after flashing #532

Closed
JoeMerten opened this issue Dec 25, 2016 · 12 comments · Fixed by #1071
Closed

[reset] Board won't start up after flashing #532

JoeMerten opened this issue Dec 25, 2016 · 12 comments · Fixed by #1071

Comments

@JoeMerten
Copy link

JoeMerten commented Dec 25, 2016

Compiled most recent sources

  • ecc31f7
  • Host = Kubuntu 16.04 64 bit
  • st-flash --version = v1.2.0-155-gecc31f7

Stm target boards:

  • Stm32F401C-Disco (chip-id = 0x0423, st-info --descr = F4 device (low power))
  • Stm32F411E-Disco (chip-id = 0x0431, st-info --descr = F4 device (low power) - stm32f411re)
  • both Stlink/v2-onboard

Stlink commandline:

build/Release/st-flash --reset write "myprog.bin" 0x8000000

Output:

2016-12-25T20:47:55 INFO src/common.c: Loading device parameters....
2016-12-25T20:47:55 INFO src/common.c: Device connected is: F4 device (low power), id 0x6423
2016-12-25T20:47:55 INFO src/common.c: SRAM size: 0x10000 bytes (64 KiB), Flash: 0x40000 bytes (256 KiB) in pages of 16384 bytes
2016-12-25T20:47:55 INFO src/common.c: Attempting to write 209516 (0x3326c) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x08020000 erasedEraseFlash - Sector:0x5 Size:0x20000 
2016-12-25T20:47:58 INFO src/common.c: Finished erasing 6 pages of 131072 (0x20000) bytes
2016-12-25T20:47:58 INFO src/common.c: Starting Flash write for F2/F4/L4
2016-12-25T20:47:58 INFO src/flash_loader.c: Successfully loaded flash loader in sram
enabling 32-bit flash writes
size: 32768
size: 32768
size: 32768
size: 32768
size: 32768
size: 32768
size: 12908
2016-12-25T20:48:03 INFO src/common.c: Starting verification of write complete
2016-12-25T20:48:08 INFO src/common.c: Flash written and verified! jolly good!

Expected/description:

After finished writing to flash, the flashed binary don't start up (regardless if I call st-flash with or without --reset parameter). I need to press the "RESET" button of the discovery board to start my application.

What's the way to automatically start the flashed binary?

@xor-gate xor-gate added this to the Unplanned (Contributions Welcome) milestone Dec 25, 2016
@xor-gate
Copy link
Member

Thats actually a very good question. Probably we need a option like run-after-flash. I'm not 100% sure why it doesn't reset after flash currently.

@JoeMerten
Copy link
Author

JoeMerten commented Dec 25, 2016

Looking into src/tools/flash.c, I saw some code which is executed when I pass the --reset option:

if (o.reset) {
    stlink_jtag_reset(sl,2);
    stlink_reset(sl);
}

but this seems not to reset the microcontroller.
Note: I'd added printf() into the code to make sure that the reset code was really reached.

@JoeMerten
Copy link
Author

Trying the reset command also doesn't start my flashed application:

$ build/Release/st-flash reset
st-flash 1.2.0-155-gecc31f7
2016-12-26T00:54:15 INFO src/common.c: Loading device parameters....
2016-12-26T00:54:15 INFO src/common.c: Device connected is: F4 device (low power), id 0x6423
2016-12-26T00:54:15 INFO src/common.c: SRAM size: 0x10000 bytes (64 KiB), Flash: 0x40000 bytes (256 KiB) in pages of 16384 bytes

@JoeMerten
Copy link
Author

Added stlink_run(sl); after stlink_reset(sl); won't help.

@xor-gate
Copy link
Member

I have just merged a possible fix from PR #534. Could you test latest master?

@JoeMerten
Copy link
Author

Testet with most recent 01b9e16 but same behaviour.

obruns added a commit to CPPUserGroups/Germany-Hannover that referenced this issue Mar 7, 2017
Pass /dev/bus/usb in order to be able to access the stlink interface
from within the Docker container.

Use GDB to work around stlink issue #532 [1].

[1] stlink-org/stlink#532
obruns added a commit to CPPUserGroups/Germany-Hannover that referenced this issue Mar 8, 2017
Pass /dev/bus/usb in order to be able to access the stlink interface
from within the Docker container.

Use GDB to work around stlink issue #532 [1].

[1] stlink-org/stlink#532
@aoreh
Copy link

aoreh commented Mar 13, 2017

Hi! Any progress on this issue?
Have the same behavior with stm32f417vg based board :(, with attached or detached SWRST pin. But it looks that device starts for a few milliseconds and then holds. It looks that this "starting and holding" happens during call to "stlink_exit_debug_mode"
After manual resetting device works fine.
At the same time if connect device to Win system and program it with STM ST-Link utility - it starts working w/o any problem.

@xor-gate
Copy link
Member

SWRST pin is independed of CPU core state (running,halted). Which register-controlled. There is no progress on this issue and I'm happy to receive a correct fix for this.

@aoreh
Copy link

aoreh commented Mar 14, 2017

Ok, but why it doesn't work without SWRST pin? Program runs for a few milliseconds (I see log messages from board via UART) and then holds :( As I said - no problem when using STM's original SW on Win.

About SWRST: unfortunately work with device remotely, so can't check what happens with oscilloscope :(, may be something wrong with this pin it self.

PS. Is it important st-link FW version?
I have: ST-LINK Firmware version : V2J25S4
And using SW: st-info --version = v1.3.1-4-g9d08810

@aoreh
Copy link

aoreh commented Mar 15, 2017

Tried with OpenOCD, didn't re-flash the device, just "reset run" - and device started working.

@Nightwalker-87 Nightwalker-87 modified the milestones: Unplanned (Contributions Welcome), Next Feb 19, 2020
@Nightwalker-87 Nightwalker-87 modified the milestones: General, Feedback required Feb 21, 2020
@Nightwalker-87 Nightwalker-87 added this to To do in Release v1.6.1 via automation Feb 21, 2020
@Nightwalker-87 Nightwalker-87 self-assigned this Feb 21, 2020
@Nightwalker-87 Nightwalker-87 removed this from To do in Release v1.6.1 Feb 26, 2020
@Nightwalker-87 Nightwalker-87 removed their assignment Mar 21, 2020
@Nightwalker-87 Nightwalker-87 modified the milestones: Feedback required, Reset issues Mar 28, 2020
@Nightwalker-87 Nightwalker-87 changed the title Board won't start up after flashing reset: Board won't start up after flashing Jun 17, 2020
@Nightwalker-87 Nightwalker-87 modified the milestones: b) Reset issues, v1.6.2 Jun 17, 2020
@Nightwalker-87 Nightwalker-87 added this to To do in Release v1.7.0 via automation Jun 17, 2020
@Nightwalker-87 Nightwalker-87 moved this from To do to In progress in Release v1.7.0 Jun 17, 2020
@Nightwalker-87 Nightwalker-87 changed the title reset: Board won't start up after flashing [reset] Board won't start up after flashing Oct 25, 2020
@Nightwalker-87 Nightwalker-87 moved this from In progress to To do in Release v1.7.0 Mar 12, 2021
@Nightwalker-87 Nightwalker-87 removed this from To do in Release v1.7.0 Mar 23, 2021
@Nightwalker-87 Nightwalker-87 modified the milestones: v1.6.2, Old issues Mar 23, 2021
@Ant-ON
Copy link
Collaborator

Ant-ON commented Mar 24, 2021

@Nightwalker-87 This issue most like fixed by #1071 (software reset rework)

@Nightwalker-87
Copy link
Member

Closed by #1071.

Release v1.7.0 automation moved this from To do to Done Mar 24, 2021
@stlink-org stlink-org locked as resolved and limited conversation to collaborators Mar 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants