Hello, I am using Nucleo L476RG board and I am facing a problem in downloading code in board using Flash programmer in Keil IDE. I compile the project successfully and when I click on Load Button, I get following errors : First Windows says:
Cannot Load Flash Programming Algorithm! C:\Keil_v5\PACK\Keil|STM32L4xx_DFP\2.2\CMSIS\Flash\STM32L4xx_1024.FLM
Second Window says:
Error: Flash Download Failed – “Cortex – M4”
If I wish to start debug session then same error occurs.
I checked the above mentioned folder and it sure contains the above specified .FLM file. Under Options->Debug-> STLink Debugger is selected. Further down in Settings, under Connect I have tried “under reset” and “Normal” both. Both result in same failure. Further down in Flash Download window- Erase sector, Program, verify, Reset & Run all 4 are checked.
Programming algorithm shows two files: STM32L_4xx 1MB Flash 1M STM32L_4xx dual bank Flash 36B with address starting 0x0800 0000H for on chip Flash and RAM for algorithm starting at 0x4000 0000.
I tried after removing second file and only with first one but no effect, the error persists.
The Pack installer software for NUCLEO-L476RG (Rev.C) shows all necessary packs “up to date”.
The 476 board is working fine with LED blink project directly downloaded as a file from mbed online compiler. STLinkV2.1 is working fine. The same Keil IDE and debugger is working fine with Nucleo 401 board so Keil IDE seems OK.
Please help to resolve.
Thanks Kevin,
Your suggestion was most helpful. I created/copied blinky project from software pack, built it and successfully downloaded it in RAM and later in flash. It also worked well in debugger.
I noted a few differences between the settings in this project and the project exported by mbed. I would list them separately. However, even after making mbed project's settings identical to Keil's example project, the flash programming refused to work and there was the same error.
I noticed a couple of anomalies which may point to the actual bug. They are:
1. when I open an mbed exported project, the include statement - #include "mbed.h", it has a red cross marked on its left most column. When I hover the cursor over that, I get a balloon message - error in include chain (mbed_assert.h):invalid token at the start of preprocessor expression.
2. When the project is opened in Keil, in the Build Output Window, following warning is shown: Warning#440: Requested device 'STM32L476RG' is substituted with variant 'STM32L476RGTx' for target '476_Nucleo_pwm'.
3. First time when I build the project the linker fails saying that it could not find the required scatter file. Then I selected the Linker tab and corrected the exact path of scatter file. Then it compiled successfully. This has happened in 3 different projects, each time. This never happened in 401 board.
To me it appears that the mbed platform for Nucleo 476 board is not prefectly supported in Keil and this is causing the issues.
Any suggestions how to pinpoint the bug?
Thanks to all for helping me understand it better.
Hello Prakash,
Keil MDK v5 and later uses Device Family Packs (DFP) from the Silicon vendor to maintain our device database.
If you go to http://www.keil.com/dd2/pack/#/ and expand the pack for the STM32L4 you can see the revision history. As you can seen, ST modified their naming conventions for their devices in their packs.
The mbed export tool must not be using the latest conventions.
You can go to Project -> Options For Target -> Device tab, and choose the correct device that uses the modern naming conventions .
See also:
http://www.keil.com/support/docs/3772.htm