如何从头开始为freescale kinetis微控制器编写引导加载程序代码? [英] How do i write a bootloader code from the scratch for a freescale kinetis microcontroller?

查看:85
本文介绍了如何从头开始为freescale kinetis微控制器编写引导加载程序代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从概念上知道如何构建引导加载程序。就像我知道有两个版本的代码,一个是引导加载程序代码和应用程​​序代码。我应该以这样的方式编程,如果我按下一个按钮,闪存中的引导加载程序代码应该被加载并执行。如果未按下该键,则必须执行应用程序代码。我已经浏览了Beningo.com上的教程视频,从头开始为微控制器构建一个引导加载程序,这在概念上给了我如何构建引导加载程序。由于除了上一学期的考试之外,我还处于毕业阶段并且没有嵌入式系统的实际经验,当我坐下来编写代码时,我开始陷入困境。我在技术上需要一些动力。

我所拥有的是

1.安装了MKE02Z64VLD2控制器的定制电路板。该板不是市场上可用的板,如自由板等。它是由一家公司设计的烤箱控制器板,我正在做这个项目。

2.一个Segger Jlink放置代码无论我在Kinetis Design Studio IDE上写的是什么,都可以进入微控制器。

3.我有关于原理图的所有信息,关于他的电路板详细信息。

我已写过闪存中LED闪烁并成功执行的代码。



我尝试过:



我正在查看来自CODEPROJECT的人建议的这个链接:

http://mcuoneclipse.com/2013/04/28/serial-bootloader-for-the -freedom-board-with-processor-expert /

1.在那篇博客中,他正在通过Codewarrior IDE为kinetis L系列微控制器构建一个串行启动加载器。

2。我的任务是通过Kinetis Design Studio IDE为kinetis E系列控制器构建一个引导加载程序。

3. Codewarrior和Kinetis Design工作室的功能和工作方式相同,超过95%。我对Kinetis L和Kinetis E系列控制器之间的关联也没有问题。

我真诚地遵循他的一步一步程序而且我在第三步陷入困境

他使用终端程序。我的电脑中没有com端口可以跟随这一步。

如我所说,我将J链接连接到我的主板和计算机,我成功执行了闪烁的LED代码。

现在我的疑问是,我可以用同样的方式向微控制器发送一个引导加载程序代码吗?

比如说我写了一个非常基本的Hello world引导加载程序代码我的KDS IDE,如果我通过我的J链接将它转储到我的微控制器上它不工作吗?

什么是串行自举程序?

是否需要终端程序,只有当你写的是SERIAL BOOTLOADER?

他还提到过使用shell程序。我想知道shell对当前场景的作用是什么?

I know conceptually how to build a bootloader. Like I know there are 2 versions of code, one is bootloader code and application code. I should program in such a way that if I press a push button, my bootloader code in the flash should get loaded and executed. If the key is not pressed the application code has to be executed. I have gone through the tutorial videos in Beningo.com for building a bootloader from scratch for micro-controllers, which gave me conceptually how a bootloader has to be built. Since I am still in under graduation and with no previous practical experience with embedded systems except for the exam in the previous semester, When I sit to write the code I get stuck at start itself. I need some motivation technically.
What I have is
1. A customized board with MKE02Z64VLD2 controller fitted. The board is not the one available in the market such as freedom boards etc. It is an oven controller board designed by a company for which am doing this project.
2. A Segger Jlink which puts the code into the Microcontroller whatever I write on Kinetis Design Studio IDE.
3. I have the entire information related to schematics, pin details about he board.
I have already written a code for blinking of an LED in the Flash memory and successfully executed it.

What I have tried:

I was going through this link suggested by people from CODEPROJECT :
http://mcuoneclipse.com/2013/04/28/serial-bootloader-for-the-freedom-board-with-processor-expert/
1. In that blog he is building a serial bootloader for a kinetis L series microcontroller through Codewarrior IDE.
2. My task is to build a bootloader for a kinetis E series controller through Kinetis Design Studio IDE.
3. Codewarrior and Kinetis Design studio are more than 95% same in its features and working. I don't have a problem in correlating between Kinetis L and Kinetis E series controller too.
I was sincerely following his step by step procedure and I got stuck in the third step
where he uses a terminal program. I dont have a com port in my pc to follow that step.
See as I said already, I connected the J link to my board and the computer and I successfully executed that blinking of LED code.
Now my doubt is, Cant I send a bootloader code to the microcontroller in the same way?
Say for instance I write a very basic " Hello world" bootloader code in my KDS IDE and if I dump it to my microcontroller through my J link Wont it work ?
What is this "SERIAL BOOTLOADER" ?
Is that terminal program required, only if you are writing something called a " SERIAL BOOTLOADER" ?
He has also mentioned about using shell program. I would like to know what is the role of shell to the present scenario ?

推荐答案

引导加载程序代码本身就像使用提供的任何其他代码一样写入板接口(在您的情况下为J链接)。引导加载程序通常用于允许以后更新应用程序代码,而无需使用特定于板的编程接口。因此,用户可以使用带有串行接口的普通PC安装更新。



对于没有串行接口的PC,可以使用USB转串口转换器。



串行引导加载程序是使用串行接口进行通信的加载程序。一旦激活(通过硬件事件,如按下按钮和/或每次复位时检查输入引脚),它将等待串行线路上的命令发送并允许写入闪存。



激活按钮的可能实现方式可能是:



  • 内存中的标志在开机时清除,表明装载程序应该执行。
  • 复位(软件或硬件如开机)时,检查标志。如果设置,则启动引导加载程序。否则启动应用程序代码。
  • 使用按钮的中断处理程序设置标志并执行软件重置。
  • 检查标志的引导加载程序代码位于重置位置地址。
  • 应用程序代码位于引导加载程序后面的固定地址。
The boot loader code itself is written to the board like any other code using the provided interface (J link in your case). Boot loaders are commmonly used to allow updating application code later without using the board specific programming interface. So a user might install an update using a normal PC with a serial interface.

For PCs without serial interfaces, an USB to serial converter can be used.

A serial boot loader is one that uses a serial interface for communication. Once activated (via hardware event like a button press and/or checking an input pin upon every reset), it will wait for commands send on the serial line and allows writing to the flash memory.

A possible implementation for a button activation may be:

  • A flag in memory cleared upon power on indicating that the loader should be executed.
  • Upon reset (software or hardware like power on), the flag is checked. If set, the boot loader is started. Otherwise the application code is started.
  • Using an interrupt handler for the button to set the flag and perform a software reset.
  • The boot loader code checking the flag is located at the reset address.
  • The application code is located at a fixed address behind the boot loader.


这篇关于如何从头开始为freescale kinetis微控制器编写引导加载程序代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆