KE02 Bootloader?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

KE02 Bootloader?

4,795 Views
d_
Contributor I

Hi,

Is there a sample project somewhere for a KE02 bootloader?  I see several app notes on the Freescale site (2295, 4775, 4767), but I don't see any bootloader examples or any discussion on linking the application for download.

The protocol is easy, as is flash programming.  It's the bootloader and application linking I'd like help with.  I've done this many times before on other processors, but it seems there should be a demo project somewhere to do this.

Thanks,

Dave

Labels (1)
0 Kudos
24 Replies

2,460 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Dave,

Thank you very much for your focus on Freescale Kinetis product. I'm glad to proviede service for you.

First, I will logon this page through the link as follow. then click the icon to download related demo code.

Link: http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=KE02&fpsp=1&tab=Documentation_Tab&uc=...1.jpg


Have a great day,
Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

2,460 Views
d_
Contributor I

Hi Ping,

I completely missed the title of that column saying "Download Files / Code Files", sorry.  I saw just the app notes.

I have downloaded the files and will investigate.

Thanks!

Dave

0 Kudos

2,460 Views
d_
Contributor I

Here are the questions I'm trying to get answers for:

How do I create a bootloader that exists in flash and never gets erased?  The bootloader should allow me to either load into RAM a pre-existing application program stored in flash, then execute, or allow me to download a new application program and burn it into flash, then reboot.  I don't see a bootloader in this project.  I'm guessing I'm missing it, but I don't know.

In order to do that, there needs to be a build and a linker file for the bootloader so that it can be compiled and stored in memory.  Then there needs to be a build and a linker file for the application program.

Once I have that, I can use the communications protocol in your examples, or design my own.

When I've done this before, I've also protected the application image with CRC.  Seems risky to just transfer binary over a comm link, burn it into flash, then assume it's all OK.  This might mean some post compilation tools to do this.  But before I can even go here, I need to figure out how to build and link the bootloader and any simple application, then burn that application into flash.

Thanks,

Dave

0 Kudos

2,460 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Dave,

Thanks for your reply.

Sorry, there's no bootloader demo for CW, only IAR. It could prevent the bootloader code from being overwritten after you configure a protected FLASH block for bootloader code.

About the linker file modification for CW, please refer to page 31 in the AN2295.
Have a great day,
Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

2,460 Views
d_
Contributor I

Thanks Ping.

It's unfortunate there isn't a complete example.  That means I either need to import uTasker or some other bootloader, or create my own.  Seems that this is a pretty standard implementation, much like a serial port driver, that Freescale would provide to its customers.

Thanks,

Dave

0 Kudos

2,460 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Dave,

The AN2295 demo has provided several bootloaders for Kinetis L, K, M serial MCU and It also provide host tool software that could connect with target board throught SCI serial port.

So I'd like to suggest that you could download the AN2295 demo through the link as follow and review the detailed description of host tool software in AN2295.

http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=FRDM-KL02Z&fpsp=1&tab=Documentation_T...
Have a great day,
Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

2,460 Views
d_
Contributor I

Hi Ping,

Thanks, but there are still the same issues as I posted on Jun 27.  The app note explains how to do some of it, but the details are missing.  To fill in the details, I need to learn how to modify the linker file so that the bootloader is in a protected area and the app is in a different area.  I might also have to figure out how to relocate the vector table as Freescale suggests (though I've done this much easier in the past with a function pointer table in RAM that is built at run-time).

So, I have the same response.  It's unfortunate Freescale doesn't provide a working demo project for a pretty standard implementation.

I'm sure I'll have more questions once I start digging into the details of the memory map, flash protection, linker configuration and link order, and creating the application image for download to the bootloader.  But I am waiting on approval to spend the time (money) on this since it was not a budgeted task.

Thanks,

Dave

0 Kudos

2,460 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Dave,

Thanks for your reply.

Yes, it's necessary to learn how to modify the linker file and relocate vector table before manage the bootloader.

It's a good news of FSL provide another Kinetis bootloader scenario to replace the AN2295 and the newest revision 1.0.2 will release in July.

You can learn the more detail information about the Kinetis bootloader scenario through the link as follow.

http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=KBOOT&tid=vanKBOOT
Have a great day,
Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

2,460 Views
d_
Contributor I

Hi Ping,

Thanks for the additional information.  I will dig through the linker configuration and build issues as soon as I get budget approval to proceed.

Dave

0 Kudos

2,460 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Dave,

You're welcome.

Any way, if you need any questions about FSL Kinetis product, please feel free to contact with me.

Have a nice day!

Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

2,460 Views
mjbcswitzerland
Specialist V

Hi All

Please find attached a reference serial loader for the FRDM-KE02 board, together with a demo application (allows accelerometer values a to be displayed and the RGB LED colours to be controlled, plus various other tests via its UART command line menu). The "readme.txt" data gives more details.

KE02 support (including accelerometer and SD card FAT via its SPI) has been added to the uTasker V1.4.7 project, which also includes this KE02 serial loader (can be built with CW, KDS, IAR, Keil, GCC standalone, Rowley Crossworks, CooCox and Atollic). This means that a single project code can now operate on all devices from KE02, through KL and K series up to the K70!

Regards

Mark

µTasker Kinetis support

0 Kudos

2,460 Views
mjbcswitzerland
Specialist V

Hi All

Update: I have added Kboot UART mode compatibility (tested with Kboot V1.0.2 and the KE02, KL02 and K64). There is an overview of the Kboot's operation in comparison to SREC loading in this thread: Kinetis - Relocating vector table to ram memory

Regards

Mark

0 Kudos

2,460 Views
mjbcswitzerland
Specialist V

Hi All

A KBOOT compatible UART loader is now available specifically for the KE02 (FRDM-KE02Z) - http://www.utasker.com/kinetis/FRDM-KE02Z.html

Regards

Mark

http://www.utasker.com/kinetis.html

0 Kudos

2,460 Views
mjbcswitzerland
Specialist V

Dave

You haven't stated exactly which loading method you would prefer to use. Presumably it is using the UART on the KL02 but do you want to work with the Freescale KBOOT tool (and its protocol) or just send SRECs to the board via a terminal emulator (or other?).

A potential difficulty with KBOOT is that it presently supports very few processors (the V1.0.2 release states that it will support the K24F, K63F and K64F during July). The idea is to have a common tool for all Kinetis parts but when that will be reality is open. In comparison - there have been various other serial and USB-HID loaders that have been published in the past. These have been available on one or two tested Kinetis parts, built with usually one IDE and the documentation has stated that the support of parts will be increased as development continues. In none of the other cases has development continued and these loaders are now legacy due to the next generation (KBOOT) which is in its infancy.

However I can imagine that the KBOOT project is more substantial than the previous more random developments. What I do wonder about is how many users will chose SPI, I2C or CAN loading since these require additional adapters to the PC so probably represent only special situations. The USB-HID and UART modes seem to be the mainstream ones.

The uTasker serial loader project already includes KBOOT compatible USB-HID operation (this works on all K and KL parts with USB - KBOOT USB HID loader [uTasker Kinetis release V1.4.6]) and UART loading (as SREC from a terminal emulator). Presumably it makes sense to add a KBOOT UART protocol mode as well to cover the main-stream usage.

For devices not limited to UART types interfaces USB-MSD and SD card loaders are the ones that seem to be most popular in real projects. These need no PC application and I expect that they will remain to be the solution of choice (alongside Ethernet based loading for parts with EMAC) even once KBOOT has established itself.

Regards

Mark

0 Kudos

2,460 Views
d_
Contributor I

Hi Mark,

I think I said before that the comm and flash parts are the easy parts.  I've implemented many bootloaders and firmware upgrade projects over the years, so comm and flash are easy.

I am using UART on this project, but the device does not talk directly to the outside world for firmware updates.  I've already implemented a custom comm protocol to talk between my device and another device, so it doesn't make sense to use the Freescale external tool to download new firmware.  I use simple NI CVI tools on a PC to exercise my custom protocol, and can do the same for firmware upgrade, so there's no need for me to worry about how the KBoot (or uTasker or UBoot) handles comm.  I can ignore all that and move directly to partitioning the source so the bootloader has its own flash block and comm channel and on to building a bin file for the app for downloading.

WRT your 2nd post, I am using the sample UART and flash drivers.  Again, these are the easy parts.  The KE02 (and in fact all Kinetis parts) are new to me, as is CW.  A working firmware update project for the KE02 running in CW would have saved me a bunch of time.  But without that, I need to dig into the internals of the KE02 and figure out how to configure CW to build the bootloader and downloadable app.

Thanks,

Dave

0 Kudos

2,460 Views
mjbcswitzerland
Specialist V

Dave

Setting up a project for the boot loader should be much simpler than writing UART and Flash drivers and download protocols. There are just a couple of settings to get right.

There is a list of a few things to get an MQX based project (although valid for whatever its is based on) to work discussed here: MicroMonitor on K64FRDM...

which I have reproduced here:

"

- the link address must be set correcly and the vector table accordingly (either at the new 0x80 aligned Flash address or in SRAM)

- if your loader has started the watchdog make sure the application also triggers it (otherwise disable it with the option of allowing the application to re-configure it later)

- it may be worth configuring the clocks with the same code as the application uses (or at least set to the same operating frequency) since I don't think that the code that is used there handles unexpected cases and can hang.

- when the loader has used peripherals it is best to deinit them (just power them down) and expressly disable any interrupts that were used to ensure no difficulties when the application re-uses them.

- MQX based projects tend to be quite large in size so having a loader that is as small as possible helps to reduce the chance of running out of memory space later.

"

CW is just GCC so the linker script file is straight forward.

Regards

Mark

P.S. The KBOOT documentation has a pretty detailed discussion of linking applications for it in it as far as I remember.

0 Kudos

2,460 Views
mjbcswitzerland
Specialist V

Dave

You made me curious so I did a port of the serial loader to the KE02 (FRDM-KE02 board with UART1 connected via VirtualCOM). I took a couple of short cuts (dedicated setup for 10MHz crystal to 20MHz system and bus clocks, with disabled watchdog).

The watchdog actually caused some problems since only with trial and error I found that WDOG_CS2 needs to be written with 0 when the watchdog is disabled otherwise it still fires (even though disabled and the counter is not counting...). No indication of this in the user's manual.

Fortunately the UART worked without any additional effort.

I was wrong about the Flash driver: The FTMRH is a bit different to the FTFL in the K and KL devices but the erase and write routines could be adjusted slightly to get it operating (with some trial and error to get the ordering of the bytes in the phrases right).

It needed a bit of work to sort out the SIM and ICS (rather different), but at the end I could successfully boot load SREC files - although limited to 38'400 Baud so that the terminal emulator doesn't overrun the UART when the device is busy programming its phrases (8 bytes at a time).

I think I may have a go at making the UART interface KBOOT compatible because with a block based protocol it is probably a bit faster because higher Bauds can be used since there are pauses when each block is committed (no risk of UART overruns due to Flash programming having to disable interrupts).

I'll include the KE02 support in the next uTasker release after making the clock configuration a bit more flexible and adding a few more peripherals to the application.

Regards

Mark

0 Kudos

2,460 Views
mjbcswitzerland
Specialist V

Dave

I took another look today at the KE02 (I have the FRDM-KE02Z).

In fact it looks like the UART and Flash drivers are compatible and the interrupt vectors have been prepared (used by SYSTICK and UART operation).

This means that I believe the following settings need to be made (appropriately added to the initialisation) and it would run the serial loader:

- OSC (select the crystal source)

- WDOG (disable or configure correctly)

- ICS (set the system frequency)

- set the TXD and RXD pins to match (eg. RXD1 and TXD1 are on PTC7 and PTC6 respectively which matches no other K or KL parts)

With some luck it may be operational with maybe half a day of investment.

Regards

Mark

0 Kudos

2,460 Views
d_
Contributor I

Hi Mark,

I appreciate the responses.  I'm currently putting out a different fire and will get back to your 2 posts and this thread shortly.

Thanks,

Dave

0 Kudos

2,460 Views
mjbcswitzerland
Specialist V

Dave

You could look at the uTasker serial loader project - it includes SREC, USB, SD-card and Ethernet loading - it is documented and includes tools for converting and encrpyting files for loading as well as containing projects for CW, KDS, IAR, Keil, Rowley, GCC, CooCox and Atollic.

However... it supports all L and K parts but not E parts. So these are my questions:

- I have looked at the E parts and they have some quite different peripherals to the K and L parts. These look to be more from the 8 bit world, for easing 8 bit users over to the Cortex m0+. I am not sure of demand for these parts (are they automotive type users with small project count but then large unit quantity)? Presently no further development was made for these parts because they didn't look to have large followers. How do you see it and why are you using E rather than L, for example (if not the obvious 5V operating range).

- You talk about loading programs to RAM but the KE02 has maximum 4k RAM so I don't understand this strategy

- I believe that the E parts use the same Flash configuration as K and L parts so you can probably just set the protect bits on the sectors containing the loader (see below for example)

Back to the uTasker serial loader project: It is missing KE peripheral support (sopme may be already be compatible as the Flash driver looks to be) but apart from that it includes all general setups and linker scripts etc., that are needed for the loader. If you have peripheral code to drop in it may already work (without much extra effort).

The flash configuration (including security and sector protection) is a project configuration (example for a KL part below but presumably the same or almost identical for E parts - essentially 0 is set for the protection bit belonging to each sector you want to protect)

// FLASH configuration settings

//

#define BACKDOOR_KEY_0     0

#define BACKDOOR_KEY_1     0

#define BACKDOOR_KEY_2     0

#define BACKDOOR_KEY_3     0

#define BACKDOOR_KEY_4     0

#define BACKDOOR_KEY_5     0

#define BACKDOOR_KEY_6     0

#define BACKDOOR_KEY_7     0

#define PROTECTION_0       0xff                                          // not protected

#define PROTECTION_1       0xff

#define PROTECTION_2       0xff

#define PROTECTION_3       0xff

#define KINETIS_FLASH_CONFIGURATION_BACKDOOR_KEY       {BACKDOOR_KEY_0, BACKDOOR_KEY_1, BACKDOOR_KEY_2, BACKDOOR_KEY_3, BACKDOOR_KEY_4, BACKDOOR_KEY_5, BACKDOOR_KEY_6, BACKDOOR_KEY_7}

#define KINETIS_FLASH_CONFIGURATION_PROGRAM_PROTECTION {PROTECTION_0, PROTECTION_1, PROTECTION_2, PROTECTION_3}

#define KINETIS_FLASH_CONFIGURATION_SECURITY           (FTFL_FSEC_SEC_UNSECURE | FTFL_FSEC_FSLACC_GRANTED | FTFL_FSEC_MEEN_ENABLED | FTFL_FSEC_KEYEN_ENABLED)

#define KINETIS_FLASH_CONFIGURATION_NONVOL_OPTION  (FTFL_FOPT_LPBOOT_CLK_DIV_8 | FTFL_FOPT_RESET_PIN_ENABLED)

#define KINETIS_FLASH_CONFIGURATION_EEPROM_PROT        0xff

#define KINETIS_FLASH_CONFIGURATION_DATAFLASH_PROT     0xff

Regards

Mark

µTasker Kinetis support

0 Kudos