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

STM32L0 loader run error #269

Closed
alexeyk13 opened this issue Oct 2, 2014 · 10 comments · Fixed by #675
Closed

STM32L0 loader run error #269

alexeyk13 opened this issue Oct 2, 2014 · 10 comments · Fixed by #675

Comments

@alexeyk13
Copy link

alexeyk13 commented Oct 2, 2014

I'm using STM32L0538-DISCOVERY board. First flashing of st-flash is working correctly, but ERROR message is shown:

2014-10-02T12:30:28 ERROR src/stlink-common.c: flash loader run error
2014-10-02T12:30:28 WARN src/stlink-common.c: l1_run_flash_loader(0x8000000) failed! == -1
2014-10-02T12:30:28 WARN src/stlink-common.c: 
write_half_pages failed == -1

Secondary run fails on verification:

2014-10-02T12:30:02 INFO src/stlink-common.c: Starting Half page flash write for STM32L core id
2014-10-02T12:30:02 INFO src/stlink-common.c: Successfully loaded flash loader in sram
  4/4 halfpages written
2014-10-02T12:30:02 INFO src/stlink-common.c: Starting verification of write complete
2014-10-02T12:30:02 ERROR src/stlink-common.c: Verification of flash failed at offset: 0
stlink_fwrite_flash() == -1

Note, that number of pages here are doubled, on first run there was only 2 pages. Unpluggins ST-LINK power, or running with --reset option solves the problem.

ST-LINK fw version (by win original tool): V2.J21.M5 STM32 Debug+Mass storage

@jaromir-sukuba
Copy link

I have the same problem.
I was finally able to blink a LED with the kit, repeatably, with following procedure:

1, Use external or internal ST-link of STM32L053 disco board, with e-paper display
2, hit reset button
3, run st-flash as usual
4, it finishes like this http://pastebin.com/PezEcf9b - FLASH content is not loaded, but FLASH is erased!
5, hit reset button
6, run st-flash again
7, now it finishes OK, like this http://pastebin.com/Gy30LEMs though with errors and warnings, not sure about it
8, hit reset button to run the application (usually the MCU is resetted after programming FLASH)
9, goto 2 (not 6! - it really needs one reset/run st-flash cycle before each FLASH programming step)

Strange is that at first it tries to reprogram 12 halfpages, then just 6. It also takes longer than I'm used to from STM32F0 of F4 - notice the 3 seconds delay after "Successfully loaded flash loader in sram" line.

@alexeyk13
Copy link
Author

I solved problem by switch from st-flash to openocd, which is fully supports also "connect after reset" and much faster actually.

@jaromir-sukuba
Copy link

Meh... good for you, but this is not solution of the reported issue.

@alexeyk13 alexeyk13 reopened this Apr 6, 2015
@alexeyk13
Copy link
Author

Sorry, wrong button :)

@gluedig
Copy link
Contributor

gluedig commented Mar 24, 2016

i belive that loader code for L0 devices is broken
i prepared an alternative one while working on support for L073x (category 5) device
check out my repo
for now loader for category 3 (ie L053x) and category 5 (L073x) devices is separate
so if you want to check my loader make changes in stlink-common.c lines 1691-1692

i would be grateful if someone can test it so we can have just one loader for L0 family (i dont have access to L053x device)

@kaliczp
Copy link

kaliczp commented Mar 27, 2016

I made a quick test with a custom board with a STM32L051K6T6 with the modified loader. With several
errors and warnings but finally st-util through gdb uploaded a code.

The first two pages are written without error. After errors were:

2016-03-27T21:53:14 ERROR src/stlink-common.c: flash loader run error
2016-03-27T21:53:14 WARN src/stlink-common.c: l1_run_flash_loader(0x8000b00) failed! == -1
2016-03-27T21:53:14 WARN src/stlink-common.c: write_half_pages failed == -1

But for same page the verification seems OK:

0/ 1 pages written
2016-03-27T21:53:14 INFO src/stlink-common.c: Starting verification of write complete
2016-03-27T21:53:14 INFO src/stlink-common.c: Flash written and verified! jolly good!

After a board reset the very simple program works correctly

@gluedig
Copy link
Contributor

gluedig commented Mar 30, 2016

thanks for checking
i'm not sure if the errors are ok - i'm not observing any on L073x

if flashing using a loader fails the same data will by written word-by-word instead in half-pages
that is way slower
on the other hand there is a comment in stlink-common.c:1972 that states that writing half-page may fail on "blank" device, whatever that means

@gluedig
Copy link
Contributor

gluedig commented Mar 31, 2016

i got hold of L053R8 Nucleo board and verified that:

  1. stock loader does not work for it either
  2. loader for L073 works ok, transfers around 3KB/s
    so i unified the loader for Category 3 and 5 devices

@kaliczp
as for L051 - i don't know what the differences are between L0x3 and L0x1 families, after quick glance at reference manual i could not find anything meaningful

@xor-gate
Copy link
Member

@gluedig as you tested it, this seems to be fixed now right?

@xor-gate
Copy link
Member

Should be fixed in current master. As there where still issues with STM32L0 after release of v1.2.0. Feel free to open a new issue when the problem still exists.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants