Nucleo re-programming problem

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
Niallp
Posts: 26
Joined: Sun Nov 29, 2015 10:25 pm
Location: Pender Island, BC

Nucleo re-programming problem

Post by Niallp » Fri Feb 01, 2019 5:49 pm

I have a Nucleo-L476RG board I have successfully built and programmed with Micropython (REPL is running via CDC etc.) however I have been unable to reprogram it since ... it appears the ST-link interface can no longer access the stm32l476 anymore, the MBED drive now has a file FAIL.TXT containing 'The interface firmware FAILED to reset/halt the target MCU'

I've updated the fw on the stlink, also updated my stlink utilities but no joy yet. st-info --probe returns:
Found 1 stlink programmers
serial: 303637304646353034393535383537
openocd: "\x30\x36\x37\x30\x46\x46\x35\x30\x34\x39\x35\x35\x38\x35\x37"
flash: 0 (pagesize: 0)
sram: 0
chipid: 0x0000
descr: unknown device



This only applies to my Nucleo-L476RG board I most recently programmed, an F4 Discovery board and a custom board with L476 and external STlink are all still accessible. It seems like the CPU on the Nucleo is just ignoring any commands from the embedded stlink, yet all jumpers are exactly as installed when I first programmed it. This was the first and only time I have programmed the Nucleo, seems like some protection bit has be set somehow.

Any ideas ?

User avatar
dhylands
Posts: 3234
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Nucleo re-programming problem

Post by dhylands » Fri Feb 01, 2019 6:21 pm

There is a bug in the older st-flash code which affects some of the L4s.

It turns out that there is another recently introduced bug in the latest st-flash which affects the F4 family.

You can rebuild the st-flash software by using:

Code: Select all

git clone git://github.com/texane/stlink.git
cd stlink
git checkout 358a913
make release
cd build/Release
sudo make install
With that I could flash the NUCLEO-L476RG and the NUCLEO-F401RE boards fine.

I also recommend updating the bootloaders on the stlink programmers. goto this page: https://www.st.com/en/development-tools ... nk007.html scroll to the bottom and click the "Get Software" button, and then follow the instructions.

Niallp
Posts: 26
Joined: Sun Nov 29, 2015 10:25 pm
Location: Pender Island, BC

Re: Nucleo re-programming problem

Post by Niallp » Fri Feb 01, 2019 7:27 pm

I had already updated both stlink (v1.5.1-12-g30de1b3) and the programmer bootloader (V2J33M25) but I tried the suggested commit (358a913) as well ... no change, still get FAIL.TXT and nothing on st-info --probe ... :(

I guess something else is going on, will have to dig some more. On the bright side, all this fiddling sorted out a problem I was having with my F4 board (corrupted filesystem) so I'll move forward with it for now ! :)

Edit: tried mixing up the various ST-link programmers, the L476 on the Nucleo is unresponsive no matter which one is used (Nucleo/Discovery/external) while all the programmers work on at least one of the other processors. Definitely something weird about my latest version of MicroPython on the L476, despite the fact it is running fine. Maybe I can reset the flash via REPL ?
Last edited by Niallp on Fri Feb 01, 2019 9:02 pm, edited 1 time in total.

User avatar
dhylands
Posts: 3234
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Nucleo re-programming problem

Post by dhylands » Fri Feb 01, 2019 8:47 pm

So are you flashing by copying a file into the st link file system or by using st-flash?

Niallp
Posts: 26
Joined: Sun Nov 29, 2015 10:25 pm
Location: Pender Island, BC

Re: Nucleo re-programming problem

Post by Niallp » Fri Feb 01, 2019 9:03 pm

Via st-flash (using make BOARD=xxx deploy-stlink)

User avatar
dhylands
Posts: 3234
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Nucleo re-programming problem

Post by dhylands » Sat Feb 02, 2019 1:23 am

You can do:

Code: Select all

st-flash erase
to do a mass erase of the entire part (include the firmware and filesystem).

Niallp
Posts: 26
Joined: Sun Nov 29, 2015 10:25 pm
Location: Pender Island, BC

Re: Nucleo re-programming problem

Post by Niallp » Mon Feb 04, 2019 6:09 pm

Update: now my F4DISC board isn't working, different error though. Using latest stlink (v1.5.1-12-g30de1b3) and deploy-stlink:

Code: Select all

make BOARD=STM32F4DISC deploy-stlink
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
Writing build-STM32F4DISC/firmware0.bin to the board via ST-LINK
st-flash 1.5.1-12-g30de1b3
2019-02-04T09:59:56 INFO common.c: Loading device parameters....
2019-02-04T09:59:56 INFO common.c: Device connected is: F4 device, id 0x10016413
2019-02-04T09:59:56 INFO common.c: SRAM size: 0x30000 bytes (192 KiB), Flash: 0x100000 bytes (1024 KiB) in pages of 16384 bytes
2019-02-04T09:59:56 INFO common.c: Attempting to write 14724 (0x3984) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x08000000 erased
2019-02-04T09:59:56 INFO common.c: Finished erasing 1 pages of 16384 (0x4000) bytes
2019-02-04T09:59:56 INFO common.c: Starting Flash write for F2/F4/L4
2019-02-04T09:59:56 INFO flash_loader.c: Successfully loaded flash loader in sram
enabling 32-bit flash writes
size: 14724
2019-02-04T10:00:00 ERROR flash_loader.c: flash loader run error
2019-02-04T10:00:00 ERROR common.c: stlink_flash_loader_run(0x8000000) failed! == -1
stlink_fwrite_flash() == -1
Makefile:507: recipe for target 'deploy-stlink' failed
make: *** [deploy-stlink] Error 255
Different than the Nucleo board which doesn't see the L476 at all. I'm wondering if some protection bits are getting set, deciphering the memory via stm.mem32[] is slow going.

Niallp
Posts: 26
Joined: Sun Nov 29, 2015 10:25 pm
Location: Pender Island, BC

Re: Nucleo re-programming problem

Post by Niallp » Mon Feb 04, 2019 6:13 pm

dhylands wrote:
Sat Feb 02, 2019 1:23 am
You can do:

Code: Select all

st-flash erase
to do a mass erase of the entire part (include the firmware and filesystem).
Unfortunately the Nucleo debugger doesn't even recognize the chip at all ...

Code: Select all

st-flash erase
st-flash 1.5.1-12-g30de1b3
2019-02-04T10:11:41 INFO common.c: Loading device parameters....
2019-02-04T10:11:41 WARN common.c: Invalid flash type, please check device declaration
  core status: unknown
Mass erasing

User avatar
dhylands
Posts: 3234
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Nucleo re-programming problem

Post by dhylands » Mon Feb 04, 2019 7:02 pm

Try building and using version 358a913.

The 30de1b3 version fails for me as well (flashing not erasing).

Also - anytime I get any type of error, I find I have to unplug and replug the board to get things back to working again.

Niallp
Posts: 26
Joined: Sun Nov 29, 2015 10:25 pm
Location: Pender Island, BC

Re: Nucleo re-programming problem

Post by Niallp » Mon Feb 04, 2019 8:18 pm

Thanks, I thought I had reverted to 358a913 but clearly it wasn't clean enough ... this time after a rebuild it is able to flash the F4DISC board again (maybe the power cycle helped as well).

Still have my Nucleo board problem, that seems to be deeper, something about the L476 is not allowing it to be connected at ... while annoying, another board is pretty cheap at least !

[Update]: I managed to swap the processor off to another board that gave access to the USB directly and managed to program in DFU mode. st-flash still problematic, if it can recognize the micro via "st-info --probe" then it can generally be used to deploy MicroPython. If not then I have to jumper for DFU mode (at least it works). Has happened with a few boards now but I've noticed it seems to recover occasionally if left for a while (days to weeks) ... feels like some config bit is floating ?

Post Reply