stm8的bootloader

Stm8的bootloader介绍

本次应用笔记是专门为STM8的固件和系统设计者提供,他们需要实现一个内应用编程(In-application programming, IPA)特征的产品,以stm8微处理器作为研发的。Stm8是一个8位微控制器家族,并以一个flash memory 去存储用户的程序代码或者固件。(for storing the user program codeor firmware.)在为控制其被移植到最终产品上后,IAP 使得控制器可以就地更新固件。这么更新固件的有优点是微控制器能一直保持在产品里面,不用取出芯片特意给它烧录程序。更新固件的时候也不用调停机器(产品)的运行工作。(在线烧录,通过IIC,SPI,uart)。

IAP是对发布新固件版本非常有用的。在产品生命周期内,它很容易去增加产品的新功能特征和维护产品的问题故障解决。

使用user-boootloader firmware 源码提供了一个实现IAP适用于STM8例子。使用这源码作为一个实现在你的stm8的应用程序的IAP参考。Bootloader主要包含以下几个特征:

Bootloader 被一个外部脚激活(jumper on PCB)。

Flash block(flash 块编程)programming 通过执行ram代码管理。

读写特性(RWW)

高级c语言水平使用

减少代码的大小(优化代码)

支持多种通信方式接口(SPI,IIC,uart)

串口代码与st flash 加载的证明的软件相兼容

1.操作原理        

在实际中,IAP要求bootloader是实现stm8固件能和外部的主机端(如PC)通过一种合适的通信接口相互通信。一个新的代码可以通过该方式被下载到微控制器。然后微控制器编程这个代码到它的flash memory。

当一个微控制器已经焊接到它的最终产品上和需要去升级其固件的时候,这种操作是很有用的。

 

Bootloader是代码的一部分,在微控制器复位后,它马上执行和等待一个激活信号。如果激活则进入bootloader 模式;如果激活失败(超时没激活,或者 jumper on the pin 不存在),bootloader则直接跳转到用户应用程序代码地址执行应用程序。

Bootloader模式,微控制器和外部主机通信通过一个串行通信接口(uart,spi,IIC,can)使用

一些命令集。

Write to flash

Erase flash

Verify flash

Additionaloperations such as read memory and execute code from a given address

(jump to givenaddress).

2.STM8的built-rom-bootloader例子

以stm8s208xxbootloader为例(UM0560: STM8 bootloader)。

Thebuilt-in ROM-bootloader is located in a dedicated part of the memory called theBootROM. The ROM-bootloader code is fixed (not rewritable) and is specific foreach device. The communication interface supported depends on the peripheralspresent in the given STM8 device and whether they are implemented in theROM-bootloader. For example, some devices support firmware download throughUART/LIN and CAN, some devices support only UART, and others only SPI.Information concerning the supported interfaces can be found in the relevantdevice datasheet.

Activationof the built-in ROM-bootloader is made by programming the BL[7:0] option bytedescribed in the option byte section of the device datasheet. The bootROMbootloader checks this option byte and if it is enabled, it runs its own code(it waits for the host to send commands/data). If the BL[7:0] option byte isinactive, the bootrom bootloader jumps to the user reset address (0x8000).

 

In the case of bootloaderactivation, the chosen communication interface is initialized. A timeout countis then activated (i.e. 1 second). If, during this timeout, nothing is receivedfrom the given communication interface (UART, SPI, I2C) the bootloader jumps to the userapplication reset address.

If the user-bootloader receive avalid activating token byte from the communication interface before the timeoutelapses, it then enters memory management mode to perform the followingoperations:

1.Initialize the Flash programming routines by copyingthe programming functions to RAM.

2. Wait in a loop for a valid command to be received fromthe master

3. Compute the received command (read, write, erase,version)

4. If a Go command is received, the user-bootloader jumpsto the address given in the command.

All commands have a specified format and must be followedby both the user-bootloader and the master. The command specification handlesall possibilities and covers error management.

 

以上由于时间比叫紧,就没有直接翻译过来了,不过基本意思都很简单。下面我将上传一下其英文版的资料和bootloader案例的源码。链接如下:

http://download.csdn.net/download/lidefu1000810218/10047929


  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
STM8S BootloaderSTMicroelectronics公司为其STM8S系列微控制器设计的一种引导程序。它的作用是在系统启动时,加载和执行用户应用程序代码。与常规的应用程序代码不同,引导程序位于芯片的内部Flash存储器中,并且在芯片上电复位时自动执行。 STM8S Bootloader具有以下主要功能: 1. 芯片编程:它允许通过串口或其他通信接口将用户应用程序代码加载到芯片的Flash存储器中。用户可以使用ST提供的专用软件工具或第三方工具来进行编程。 2. 固件更新:在芯片运行时,可以通过引导程序进行固件更新,以便修复错误、添加新功能或改进性能。这样,用户不需要使用额外的编程器设备即可更新固件。 3. 引导模式切换:引导程序还允许用户通过特定的硬件引脚或其他方式切换到引导模式,以便在应用程序代码出现问题时可以重新加载或更新固件。 4. 应用程序跳转:一旦用户应用程序代码加载到Flash存储器中,引导程序负责正确地跳转到应用程序的入口点,并使其开始正常的执行流程。 使用STM8S Bootloader,用户可以方便地进行固件更新和调试,而无需专用的硬件编程器。这为开发人员提供了更高的灵活性和便利性,同时也提升了产品的可维护性和升级性。STM8S Bootloader在各种应用领域中广泛应用,包括工业自动化、汽车电子、家电和消费电子等。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值