Article count:1120 Read by:2933985

Featured Content
Account Entry

Engineer's Notes | Creating an external Flash programming driver (.stdlr) using STM32CubeMX

Latest update time:2021-01-07
    Reads:
Through STM32CubeMX
Make external Flash burning driver (.stdlr)


Preface


At present, more and more applications need to expand external Flash to meet storage needs. Therefore, during debugging and mass production, it is necessary to burn the external Flash. Since the STM32 ST-LINK Utility and STM32CubeProgrammer only support a limited number of Flash models, they can only cover a part of the MCU and Flash models, which cannot fully meet customer needs. Moreover, the external loader production template it provides has the problem of covering fewer chip models and failing to debug QSPI Flash in the early stage. This article aims to provide a method for making an external Flash loader through stm32CubeMX. Customers can customize the generation according to their own models. In this article, the MCU (STM32H750) and Flash (S25LP128F) actually used by a customer are used as examples for explanation.


Preparation


⚫ Install STM32CubeIDE


⚫ Install the HAL library corresponding to the MCU model


External loader development


The development of the external loader is divided into three parts. The first part is to use STM32CubeMX to configure and generate the project. The second part is the driver debugging of the external Flash, which mainly includes initialization, erasing, writing and reading operations. The third part calls the driver function to generate the external loader, including the definition of the external Flash information, including the size of the Flash capacity, the size of the page, and the information related to the Sector; the code required by the external loader in the third step and the driver of the corresponding device can be obtained in the following GitHub repository, and everyone is also welcome to submit their own debugged device drivers to the repository.


address:


https://github.com/WellinZHANG/External_Loader


Generate a project using STM32CubeMX


Here, we use STM32CubeMX integrated in STM32CubeIDE to configure and generate the project.


New Construction


Select the corresponding device, fill in the project name, and select the storage location:



Pin Configuration


Select the corresponding Flash pin according to the hardware schematic diagram. Here, select Bank2 and configure as shown below. Note that the speed of the pin is adjusted to High and the QSPI interrupt is enabled. The FlashSize value is set to N, and the Flash size is configured as 2N+1.




Clock Configuration


According to the clock source on the board, perform the corresponding clock configuration. Here, the internal clock is used as the clock source of the system PLL.



Generate Project


Switch to the Code Generator tab and check the “Generate perioheral initialization as pair of '.c/.h' files per peripheral” option.



Debugging QSPI Driver


Get the relevant driver code from the GitHub repository mentioned at the beginning.



first step


Add the code in mian_test.c in the External-Loaders\ QSPI testing directory to the corresponding main.c file in the project.





Note that when adding code, keep the USER CODE BEGIN x and USER CODE END x tags, otherwise the added code will be overwritten when Cube MX regenerates the code.


Step 2


Replace the QSPI HAL driver files in the \External-Loaders\QSPI Drivers\IS25LP128F directory with the corresponding files in the project.



third step


Open CubeMX and regenerate the project. Because in order to adapt to all series of QSPI interfaces, the QSPI HAL driver provided by GitHub does not provide the corresponding QSPI peripheral configuration function, it needs to be generated through CubeMX.



the fourth step


As shown in the figure above, since the control instructions of each model of FLASH are slightly different, you need to adjust it according to the QPSI FLASH device you choose. At the same time, you need to debug whether the reading and writing of QSPI is normal. If the reading and writing of QSPIF lash is not normal, then add breakpoints at the positions marked in the figure below to find out which link is wrong and further adjust the driver.



Modify the configuration to generate QSPI Loader


After completing the QSPI driver debugging, we need to add the code required to generate the external loader and modify the corresponding configuration.


first step


Add the corresponding code and store it in the \External-Loaders\Loader_Files directory. Since the linker files of H7 and other series are different, they are divided into two folders, H7 and others. We select the problematic files in the H7 directory. Add all the files to the project.




Step 2


Modify the name in Dev_Inf.c to the name you want to set, usually set to MCU+Flash name.



third step


Modify the Linker configuration and open the settings page through "project" -> "Properties". Change the ld file in the red box to linker.ld. (It has been added to the project in the first step).



the fourth step


Modify the configuration and generate the stdlr file after compilation. Open the settings page through "project" -> "Properties" and add the following instructions in "post build steps":



Finally, compile to generate the corresponding stdlr file in the project directory. Copy it to the extra loader folder in the STM32CubeProgrammer installation directory and you can use it.



Summarize


This method can quickly generate an external burning script to burn the external QSPI FLASH.









Latest articles about

 
EEWorld WeChat Subscription

 
EEWorld WeChat Service Number

 
AutoDevelopers

About Us Customer Service Contact Information Datasheet Sitemap LatestNews

Room 1530, Zhongguancun MOOC Times Building,Block B, 18 Zhongguancun Street, Haidian District,Beijing, China Tel:(010)82350740 Postcode:100190

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号