Bootloader for K20?

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

Bootloader for K20?

1,616 Views
altestani
Contributor I

We need a bootloader and associated Linux serial loader application (or C/C++ code we can adapt) for the MK20DX MCUs.  Specifically, we need to do field updates of firmware from a Raspberry Pi in the product to the embedded MCU using a UART connection between the RPi and K20 MCU.  We would prefer to use Intel HEX format but would use S-records if we must. .

I have looked into NXP MCUBOOT (aka KBOOT) but the K20 doesn't seem to be supported.  I have also searched widely for any bootloader for the K20 and the closest I can come up with is uTasker but would much rather use NXP supported code for this.  The Kinetis MCU we are using is an MK20DX128VLH7.

Can anyone point me to a bootloader solution for the K20?

Thanks

Al Testani

0 Kudos
8 Replies

1,169 Views
douce
Contributor I

Hi, 

we are facing the same ''problem''. We want to update remotely NXP KE06, with Raspberry, over CAN serial connection. 
Have you found any solution for this?

Regards, Blaz

0 Kudos

1,298 Views
mjbcswitzerland
Specialist V

Hi Al

The uTasker project supports all that you need for the Kinetis side (on all K20 parts) and has intensive professional support if that is a requirement in order to guarantee your project (supported here or personally via Email, Skype, etc.). I am sure that support for NXP code will not be better and the uTasker boot loader code is used in many industrial products (Kinetis, Coldfire, LPC and more) since 2005 and its SREC/iHEX utilisation since 1998 - so has proven history too.

You can immediately use KBOOT or iHex via UART on your K20 (with optional AES256 encyrption too).

If the support is not the actual issue but using free code is essential you can also get it free at GitHub.

Regards

Mark

0 Kudos

1,298 Views
altestani
Contributor I

Thanks, Mark.  I am back on this project and have looked into uTasker.  I will say I am quite impressed with the work you have done!  At the same time, all of that is quite overwhelming making it hard to get started.

While uTasker has very broad support, I am not sure I can use it directly, for a few reasons:

  1. I am using PlatformIO for development and this doesn't seem to be one of the development platforms supported.  I would need to rebuild the uTasker loader to change multiple parameters (e.g. turn off the watchdog, reduce the memory requirement by using UART support only, change GPIO pins to force the loader, etc.) and would want to use PIO for this.

  2. We are using the Teensy framework within PIO but with a custom design based on the MK20DC128VHL7.  There is no Teensy (or other) board like this so all of the support files have been modified for this MCU. We are using a JLINK programmer/debugger with a JTAG interface we have on the board and load  Intel Hex files..  We also need to load some EEPROM locations with the bootloader but haven't gotten to that with the JLINK at this point.

  3. We have a Raspberry Pi running Rasbian in the system and this is where the KBOOT or equivalent would reside and communicate with the K20 using the second UART on it to flash code.  
0 Kudos

1,298 Views
mjbcswitzerland
Specialist V

Al

To build the uTasker serial loader with other settings you can edit the header file "config.h" with any editor and build it by double clicking on the on the .bat file "Build_Kinetis.bat". You just need to set the path in that file to point to the location of the GCC tool chain that you have installed. [Using Visual Studio the operation can also be completely simulated and tested - the free community edition version is adequate]

To change port input to use different pins you don't really need a special tool since it is too simple to do with the editor.
eg. to change the input to force the loader from PTC7 to PTA15 (for example)

#define FORCE_BOOT()           ((_READ_PORT_MASK(C, PORTC_BIT7) == 0)

becomes

#define FORCE_BOOT()           ((_READ_PORT_MASK(A, PORTA_BIT15) == 0)

I have worked on many Teensy derived product developments (Teensy 3.2, Teensy 3.5 Teensy 3.6) which have used the uTasker loader [eg.https://www.xctracer.com/en/76/?oid=1905&lang=en ] for their user updating, including ones that have been delivered in high quantities, without any complications.


I do know that Arduino programmers are generally less experienced with low level firmware since the libraries don't expose this and that is why there is a consulting service that does any detailed work that otherwise takes developers out side of their "Ardunino" comfort zone ;-)

Regards

Mark

P.S. Note however that Arduino based solutions often do lack things that embedded product developments should take seriously - eg. usually there is no watchdog concept or power management included in the libraries.

0 Kudos

1,298 Views
altestani
Contributor I

Mark,

Thanks for the information you have provided.  Here is a little more from me:

I have done much bare metal embedded programming and am only using Teensy/Arduino since it has most of what I need for the K20 MCU we are using (and is well supported in PlatformIO).  I have even written my own bootloader, in the past, for some Microchip PICs. The key point in #1 of my post is that I want to use PIO for any uTasker work (not CodeWarrior, Visual Studio/with VisualMicro, direct to the GCC toolchain, etc.). Eventually, I will want to create a combined bootloader/application image.  You show many development environments on your website's Kinetis Landing Page.  Are you planning to add PlatformIO?  If there was a PIO/general Kinetis MCU tutorial that would be perfect! 

As far as #2 goes, this is no longer a concern as I have changed the scripts in PIO to output hex, binary, and S-records so I can deal with any of the formats now with uTasker or whatever we end up using.  

I'm not concerned about using uTasker in a production product, etc. only how difficult it is to integrate it into our development.  I have no doubt others have used uTasker successfully with stock Teensy boards but I don't have a stock board . The similarity to what I have with Teensy ends with the fact I am using an NXP K20 MCU.  In fact, the K20 we are using isn't on any of the Teensy boards.  Another big difference to Teensy is we have a full JTAG interface on our boards and do not use the Teensy loader and/or proprietary bootloader chip.

So what I need to do is read your website again to see if one of the plans you have can get me up the steep learning curve so as to actually do an evaluation.  

I'll email you with further questions.

 Al

0 Kudos

1,298 Views
mjbcswitzerland
Specialist V

Hi Al

>>PlatformIO

I have never been ask before to support PlatformIO and Kinetis users tend to use MCUXpresso (or KDS), which are both Eclipse based IDEs (with quite a few commercial developers using IAR and uVision since they tend to be more stable when debugging).
If PlatformIO uses GCC to cross-build there is nothing to do (there are only a few differences in a handful of lines of code between IAR, Keil, GreenHills, GCC, etc.) and the only differences between the various Eclipse eclipse based ones (CodeWarrior, MCUXpresso, KDS, S32, Atollic, CooCox) is the project configuration (95% identical but never fully compatible) and not the actual project code itself.
So basically if PlatformIO uses GCC you can just add the files involved, set include paths and define the target processor and it will be OK.
Personally I use VS since I find it a better editor (and its indexer is generally more reliable), plus I can simulate the projects and processor from it, plus cross build to any target using a post build step. At the same time I can open up any of the other IDEs and build and debug immediately since they are all using the exact same code - at the end of the day it is just a case of which editor and debugger one feels most at home with.

>> K20 derivative

There are no concerns with uTasker code since it will run on all derivatives with no (application layer) code changes. There is a setup for the chip and then you can build the same project (eg. serial loaders) for any device (from KL02, through KE, KEA, KV, KW, and K parts from K10 to K80) - as long as the device has the peripheral that is needed....the HAL adapts itself automatically so there is no work for the user. All K20 flavors are catered for.

>> combined bootloader/application image

The uTasker tools automate this (it is a part of the .bat file step)
http://www.utasker.com/forum/index.php?topic=1445.0
The utilities create all common formats and combine application and loader for factory programming, plus adding encryption and authentication for distributing if needed.

>> stock Teensy boards

Rarely are products based on the stock boards because they don't allow debugging and are expensive for production.
One pays a few dollars for the programmer chip that is used only once and in quantities it saves tens and even hundreds of thousands of dollars just removing that. Zero pin programming is the main concern to keep costs to a minimum.
The Teensy boards are however certainly popular for development and getting the original idea up and running, as are various other Arduino ones - one of the cheapest (also with about the power of your K20) is the Blue Pill that costs around $1.80 for the whole board and connectors.... which the same serial loaders build for with the switch of a single define....https://www.youtube.com/watch?v=dq-m-Dokq7E&feature=youtu.be

Regards

Mark

P.S: If you think there may general interest in an off-the-shelf configuration for PlatformIO I may take a closer look.

0 Kudos

1,298 Views
altestani
Contributor I

The way I am using PlatformIO is under VSCode so all of the Visual Studio capability is there including the unified debugger plus a large assortment of extensions. It is *much* more than an editor and debugger. You can also do Python, C# and about anything else you would want with VSCode simply by getting the appropriate extensions.  With PIO there are almost 600 boards supported, 30 platforms and multiple frameworks.  There are also almost 7000 libraries available.  The best part is all of this is free unless you want the extended debugging capability (including remote debugging) which is for a nominal annual fee.  I think you should check it out.  I may be the first one requesting PIO support but my guess is there will be more.

An open source ecosystem for IoT development · PlatformIO 

I suggest you consider setting up for generic support of uTasker across the multiple platforms within PIO.  You could likely still have your tiered pricing structure in a whole new market for your products.   

(BTW, I have no affiliation with PlatformIO other than being a user)

0 Kudos

1,298 Views
mjbcswitzerland
Specialist V

Hi Al

I think that Eclipse fans would say that they have a lot more than that (they also have a zillion plug-ins) ;-) but I'll install it and see what happens!

Regards

Mark

P.S: Personally I don't like Eclipse much. I haven't found it increases productivity in my embedded developments but I know of others who love it. So it is good that there is so much choice at the end of the day to use what one is most happy with.

0 Kudos