MDK下针对STM32H750的下载算法制作

查看keil帮助手册

安装keil后,可以在帮助中查看手册,也可以在浏览器中输入:

https://arm-software.github.io/CMSIS_5/Pack/html/flashAlgorithm.html

如果网页打开失败,可以试试在C:\Windows\System32\drivers\etc\hosts中添加185.199.109.153 arm-software.github.io然后保存退出,最后在cmd命令窗口执行ipconfig /flushdns,然后再打开
打开界面如下:
keil帮助
我们根据这个帮助来进行下载算法的工程创建,并且安装帮助文档的提示,我们需要实现 Init,UnInit,EraseSector和ProgramPage,EraseChip这几个函数,在实际操作过程中发现,还必须实现BlankCheck和Verify这两个函数,否则下载程序时,会提示超时而下载失败

Keil工程搭建

工程修改这里就不说了,玩过STM32的人,没几个不熟悉keil这个软件,按照帮助文档复制一个过来就好了,魔术棒下的设置都是设置好了的,不用修改。

FlashDev中调整设备参数

我开发板用的是一颗W25Q64
设置的参数如下:
算法参数
参数后面的英文注释很好理解,但是要说一说 Device Name这个参数,这个名字跟最后显示keil里面的算法名字有关,而跟keil工程输出文件名称无关
设备名

FlashPrg中的编程算法

/**************************************************************************//**
 * @file     FlashPrg.c
 * @brief    Flash Programming Functions adapted for New Device Flash
 * @version  V1.0.0
 * @date     10. January 2018
 ******************************************************************************/
/*
 * Copyright (c) 2010-2018 Arm Limited. All rights reserved.
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Licensed under the Apache License, Version 2.0 (the License); you may
 * not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 
#include "FlashOS.h"        // FlashOS Structures
#include "sys.h"
#include "delay.h"
#include "led.h"
#include "usart.h"
MDK程序下载 程序下载----FLM⽂件 ⽂件 MDK编程算法 编程算法   ⽤过MDK下载程序的⼩伙伴可能都知道,在下载程序之前需要都在Debug设置的Flash Download⼦选项卡选择编程算法。⼤多数时 候, 我们只要安装了芯⽚包之后,就可以直接得到对应的编程算法,并不需要我们去修改它。但是,当你是⼀个芯⽚包的开发者,或者你有独特 的下载需求(⽐如在你的程序⾥加⼊⼀些校验信息),这个时候你就需要去了解它了!   编程算法呢,说⽩就其实也就是⼀段程序,主要功能就是擦除相应的内存块,并将我们的程序写⼊到相应的内存区域上去。 在你点击下载按钮的时候,这段程序会被先下载RAM上(RAM for Algorithm上的设置),然后才会通过它,将你的程序写⼊到 指定的内存区域内。 实现⼀个⾃⼰的编程算法 实现⼀个⾃⼰的编程算法   怎么去实现⼀个⾃⼰的编程算法?⾸先我们找到⾃⼰的MDK的安装路径,进⼊到ARM\Flash⽂件夹下(例如: D:\Keil_v5\ARM\Flash)。 这⾥有个编程算法的⼯程模板,复制这个⼯程到你的⼯程⽂件夹下,重命名你⾃⼰的想要的名字。   打开⼯程,⾥⾯主要有两个⽂件 FlashPrg.c 和 FlashDev.c:   FlashDev.c主要实现了⼀个设备相关的结构体(根据⾃⼰的Flash情况去实现)      ⽐如STM32L051实现如下:   FlashPrg.c实现了⼏个Flash编程相关的函数:   根据⾃⼰的需要去实现,STM32L051实现如下: 1 /* ----------------------------------------------------------------------------- 2 * Copyright (c) 2014 ARM Ltd. 3 * 4 * This software is provided 'as-is', without any express or implied warranty. 5 * In no event will the authors be held liable for any damages arising from 6 * the use of this software. Permission is granted to anyone to use this 7 * software for any purpose, including commercial applications, and to alter 8 * it and redistribute it freely, subject to the following restrictions: 9 * 10 * 1. The origin of this software must not be misrepresented; you must not 11 * claim that you wrote the original software. If you use this software in 12 * a product, an acknowledgment in the product documentation would be 13 * appreciated but is not required. 14 * 15 * 2. Altered source versions must be plainly marked as such, and must not be 16 * misrepresented as being the original software. 17 * 18 * 3. This notice may not be removed or altered from any source distribution. 19 * 20 * 21 * $Date: 18. November 2014 22 * $Revision: V1.00 23 * 24 * Project: Flash Programming Functions for ST STM32L0xx Flash 25 * --------------------------------------------------------------------------- */ 26 27 /* History: 28 * Version 1.00 29 * Initial release 30 */ 31 32 #include "FlashOS.H" // FlashOS Structures 33 34 typedef volat
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值