Kinetis Boot Loader for SREC UART, SD Card and USB-MSD loading

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

Kinetis Boot Loader for SREC UART, SD Card and USB-MSD loading

19,806 Views
mjbcswitzerland
Specialist V

Hi All

There has always been a high demand for boot loader solutions and the uTasker project includes a number of these which have proven to be quite popular, even for use with applications from different sources.

The demands as to how the loader operates are quite varied and so a flexible loader has been put together which allows the following modes of boot loader operation in one single loader:

- UART S-REC loading at 115200 Baud

- SD Card loading (a new software is copied to an SD card and inserted)

- USB-MSD (the board apears as a disk drive and the software can be copied)

This allows all of the three possibilites to be used in a compatible manner. The boot loader size (with all modes enabled together) is about 25k. If some modes are not required they can be mixed as necessary in the project and so much smaller Flash size needed.

For K60 Tower Kit users there is a package at µTasker Test Software and Demos which allows it to be used immediately for any application up to 130k in size. The loader is documented at http://www.utasker.com/docs/uTasker/uTaskerSerialLoader.PDF and there is also a video showing its flexible operation at Kinetis K60 Tower Kit - Flexible Boot Loader - YouTube

Note that the complete package also supports encryption (to allow code distribution without reverse enginering possibility), USB-DFU, HS-USB and Ethernet loader (Web Server based - about 18k Flash) for chips with Ethernet.

Regards

Mark

Labels (2)
148 Replies

1,533 Views
mjbcswitzerland
Specialist V

Hi All

This flexible boot loader has now been extended to KE and KL devices. Here is the present list of supported boards:

  • - K20N50M FRDM-K20D50M
  • - K20N50M TWR board
  • - K20D72M TWR board
  • - K20DX256 72 MHz TEENSY 3.1
  • - K21D50M TWR board
  • - K21F120M TWR board
  • - K40X256 TWR board
  • - K40D100M Tower kit
  • - K40X256 KWIKSTIK
  • - K53N512 TWR board
  • - K60N512 TWR board
  • - K60F120 TWR board
  • - K70F120 TWR board

  • - KL02Z32  FRDM-KL02Z (UART SREC loader only)
  • - KL05Z32  FRDM-KL05Z (UART SREC loader only)
  • - KL25Z128  FRDM-KL25Z
  • - KL25Z128 TWR-KL25Z48M
  • - KL26Z128  FRDM-KL26Z
  • - KL46Z256 FRDM-KL46Z
  • - KL46Z256 TWR-KL46Z48M


  • KE02 FRDM-KE02Z (UART SREC loader only)

For each board there is a binary that can be used from the link in the opening post. See the readme.txt in each package for extra details (such as password protection of files on USB-MSD disk).

The project can be built with a variety of tools (GCC makefile, KDS, CooCox, CW10.x, IAR, Keil, Rowley, Atollic) and configuring and building for the board/processor in question requires minimum configuration (the source code is shared by all):

1. In config.h select the board - comment in the one to be built for (example of building for FRDM-KL26Z):

  //#define FRDM_KE02Z

  //#define FRDM_KL02Z

  //#define FRDM_KL05Z

  //#define FRDM_KL25Z

    #define FRDM_KL26Z        // commented out to build for this target

  //#define TWR_KL25Z48M

  //#define FRDM_KL46Z

  //#define TWR_KL46Z48M

  //#define FRDM_K20D50M

  //#define TWR_K20N50M

  //#define TWR_K20D72M

  //#define TEENSY_3_1

  //#define TWR_K21D50M

  //#define TWR_K21F120M

  //#define K20FX512_120

  //#define KWIKSTIK

  //#define TWR_K40X256

  //#define TWR_K40D100M

  //#defined TWR_K53N512

  //#define TWR_K60N512

  //#define FRDM_K64F

  //#define TWR_K60F120M

  //#define TWR_K70F120M

2. In the IDE used select the target processor (this is to ensure that the compiler builds correctly for Cortex-M0+ or Cortex-M4).

3. Ensure that the correct linker script file is being used. This is mainly to ensure that the RAM size and location are correct - the KL/KE parts use a slightly different SRAM layout to the K parts.

The project also builds using Microsoft VisualStudio and then simulates the board so that basic details can be checked (such as the part type, clock speed, pin configurations) and then the operation tested, modified, debugged etc.

This list may not be up-to-date here so please see the following for most up to date information and also the tools chains that can be used: http://www.utasker.com/kinetis.html

Regards

Mark

http://www.uTasker.com

0 Kudos

1,493 Views
CzechThunder
Contributor III

Hi Mark/Forum,

We're having an issue with the uTasker MSD USB HS bootloader and Windows 10.

The USB core we're using (usb_device_loader.c) is version {31} and has the following as the last release note:

20.11.2015 Add USB-CDC option to allow SREC loading via virtual COM {31}

The MSD bootloader works perfectly in Windows 7 and on Mac OS Sierra. The drive enumerates and all file operations run without issue.

On Windows 10, I had to first disable the creation of the "System Volume Information" folder by disabling the "Allow search to index removable drives" setting in the group policy and then by stopping the Windows search service in the Windows services manager. After doing this, the drive enumerates perfeclty on Windows 10 and all the information about the device and device driver appears correct.

The issue is that file operations don't appear to work. I can't reliably delete, or copy over new ".bin" files. Windows explorer hangs at either 0% or 66% and never actually updates the binary. I've also tried copy and Xcopy operations in the DOS command prompt with administrator privileges and get the same issues.

I've also gone into the binary file that I'm copying and right clicked on the "Properties->General->Advanced->Allow this file to have contents indexed in addition to file properties" and made sure this is UNCHECKED but I still can't copy the file over.

Is anyone else using USB-MSD bootloader on Windows 10 or has thoughts on how to correct this?

rgds,

Gary

0 Kudos

1,493 Views
mjbcswitzerland
Specialist V

Hi Gary

I haven't hear of any issue with Windows 10 and I test exclusively with this during the last year. There should be no need to change any Windows settings.

Attached is the latest version of that file, whereby there is nothing there that was modified to correct any such issues. Check that the Windows 8.1 and MAC_OS_X workaround defines haven't been disabled in your version.

In case of continued problems, contact me for an account at the developer's GIT repository.

Regards

Mark

1,493 Views
CzechThunder
Contributor III

Mark,

I got the MSD bootloader working in Windows 10.  It looks like the usb_device_loader.c file was not the issue, nor were any of the bootloader specific files. 

I therefore focused on the uTasker specific files in the project.  I had built our bootloader project using an older version of uTasker.   I decided to upgrade the uTasker files with the newer version that we purchased about 2 years ago.  Specifically, the file "Driver.c" was updated and now it seems to work fine.

Thank you for your rapid response.  It looks like we should now be compatible with all the platforms our customers use.

best rgds,

Gary

0 Kudos

1,493 Views
mjbcswitzerland
Specialist V

Hi Gary

I don't know what effect the queue driver file update has on the USB operation but it is good to hear that this looks to resolve the issue.

Regards

Mark

0 Kudos

1,533 Views
sudhakarp
Contributor V

HI,

     Where i will get source code. when i click this link

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

am getting .bin file only. can i load this code throught PE multilink universal?.(i am using FRDMK64 and KDS 2.0 and KSDK 1.1.0.) actually i need UART/ETHERNET bootloader source code for KDS platform. then only i can make code depends on my requirement and also i want to know what are the changes i want to do in linker file and all. can you give clear idea about this?

thanks and regards,

sudhakar p

0 Kudos

1,533 Views
mjbcswitzerland
Specialist V

Hello

At the link http://www.utasker.com/kinetis.html there is this sentence in the fifth paragraph:

"The complete V1.4.7 project code can be downloaded freely from KINETIS Project Code although it is recommended to fill out the registration to make the most of your experience with the project and for access to latest resources and developments."

All code is compatible and works with CW, KDS, IAR, Keil, Rowley Crossworks, Greenhills, CooCox, Atollic, standalone GCC and VisualStudio so no porting effort is required.

Information about using with other applications is given here:

Configuring Foreign Applications to work with the uTasker Serial Loader

Regrds

Mark

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

K64: http://www.utasker.com/kinetis/FRDM-K64F.html / http://www.utasker.com/kinetis/TWR-K64F120M.html / http://www.utasker.com/kinetis/TWR-K65F180M.html

Boot loader: http://www.utasker.com/docs/uTasker/uTaskerSerialLoader.PDF

For the complete "out-of-the-box" Kinetis experience and faster time to market

0 Kudos

1,533 Views
sudhakarp
Contributor V

hi mark,

     thanks. i got source code. can you give some documentation or image or video  link for how to use and build this code in KDS 2.0 IDE. is i want to change any linker file address in my code? here i am explained my project requirement.

*****************************************************************************************************************

my requirement detail:

actually i want to program application code through UART/ETHERNET using bootloader code. but while programming i dnt want to erase 0xFA000 to 0XFD000 because that place am storing my configuration parameter values. after loading new firmware i will take that value from 0xFA000.

     so can you give some solution for this..? you can suggest some other easy way also. actually i want to upgrade my application code program without affecting already configured parameter at location 0xFA000-0xFD000.(Like from VER-0.1 to VER-0.2). because i am giving facility to configure IP address, gate way like etc., so user dnt want to configure this things again and again.

   

***************************************************************************************************************************

so you can suggest some  other option also and please send some document and video link related to

this one. so i can easily understand.

thanks and regards,

sudhakar p

0 Kudos

1,533 Views
mjbcswitzerland
Specialist V

Hi

To build the serial loader as you want you need to select your board in config.h

#define FRDM_K64F

To use SREC and Ethernet loading select the defines

#define SERIAL_INTERFACE

and

#define ETH_INTERFACE

If you prefer KBOOT compatible serial loading to SREC choose

#define KBOOT_LOADER

If you prefer the Developer's Loader compatible operation instead choose

#define DEVELOPERS_LOADER

To configure thah application area define these defines in Loader.h

#define UTASKER_APP_START (32 * 1024)
#define UTASKER_APP_END   (unsigned char *)(UTASKER_APP_START + (100 * 1024))

That is - chose the starting address to be after the boot loader code and the application code size to less than any area that should be preserved.

If you have MAC and IP settings at fixed locations you can also use these for the Ethernet loader by reading them and passing them to the Ethernet controller in fnTaskEthernet() in Ethernet.c.

There is a guide to configuring, importing and compiling with KDS at µTasker Kinetis Compiler Information

There is a video guide for CW (which is effectively the same as KDS) at uTasker for Kinetis using CodeWarrior - YouTube

Search at youtube for "uTasker" for various other videos showing the loader in operation.

Also use the serial loader users' manual (below) for extra details and fully operational documentation.

When loading foreign applications the main things to consider (for compatibily) are at Configuring Foreign Applications to work with the uTasker Serial Loader

The serial loader operation can also be fully simulated in VisualStudio in order to verify configuration and operation with needing to debug on HW.

Regards

Mark

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

K64: http://www.utasker.com/kinetis/FRDM-K64F.html / http://www.utasker.com/kinetis/TWR-K64F120M.html / http://www.utasker.com/kinetis/TWR-K65F180M.html

Boot loader: http://www.utasker.com/docs/uTasker/uTaskerSerialLoader.PDF

For the complete "out-of-the-box" Kinetis experience and faster time to market

0 Kudos

1,533 Views
sudhakarp
Contributor V

hi mark,

     i tried to build bootloader code in KDS 2.0 but i cant change properties setting. i attached image. in tool setting menu there is no option its simply empty. i tried to add image but i cant some forbidden  error came.

i cant see targer processor option and ARM LTD windows GCC c linker option. give some idea.

     thanks and regards,

sudhakar p

0 Kudos

1,533 Views
mjbcswitzerland
Specialist V

Hi

Please read the first step in the instructions and/or the readme.txt file in the root directory that explains using the correct eclipse project files:

Quote:

"To import the µTasker project into KDS the following simple steps can be followed:

    • To prepare the KDS import (as opposed to CodeWarrior or Atollic) start by deleting the directory ".settings" in the root directory of the µTasker project (the root directory the folder where the project was extracted to including directories "uTasker", "Hardware", "Applications" etc.) as well as other files at this location which begin with a '.' (eg. ".cproject") since these may be for alternative Eclipse based environments.

  • Now copy the KDS project settings from the folder \Applications\uTaskerV1.4\KinetisDesignStudio\Project_Settings to the root (these are the directory ".settings" and files ".cproject", ".cwGeneratedFileSetLog" and ".project").
    There is also a read.me file at that location explaining the procedure and why it is necessary. If you already know and are sure that the KDS files are located in the root these steps are of course not necessary."

Probably there is a CW .project file in the root and it can't be opened by KDS (and vice versa).

Regards

Mark

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

K64: http://www.utasker.com/kinetis/FRDM-K64F.html / http://www.utasker.com/kinetis/TWR-K64F120M.html / http://www.utasker.com/kinetis/TWR-K65F180M.html

Boot loader: http://www.utasker.com/docs/uTasker/uTaskerSerialLoader.PDF

For the complete "out-of-the-box" Kinetis experience and faster time to market

1,533 Views
sudhakarp
Contributor V

Hi mark,

     i successfully build that project. i want to know some detail about how to set bootloader starting address and  application starting address.if depends on linker file mean  in which linker file we are mentioning address..?

i am using KDS 2.0 and KSDk1.1.0. is the linker file location

"C:\Freescale\KSDK_1.1.0\platform\linker\MK64F12\gcc".

                previously am not did any bootloader code . i am new so explain briefly. and also previously i mentioned i dnt want to erase 0xFA000- 0xFD000 area in internal flash. for that how to set my linker file.

in utaker 3-application codes are there

1)Utaskerboot

2)utaskerSerialBoot

3)uTaskerV1.4

     all application same are different?

thanks and regards,

sudhakar p

0 Kudos

1,533 Views
mjbcswitzerland
Specialist V

Hi

The serial loader is the one called "uTaskerSerialBoot"

The linker script file can be modified to add a shift to the start of the application:

From:

MEMORY

{

  m_interrupts          (RX)  : ORIGIN = 0x00000000, LENGTH = 0x00000400

  m_flash_config        (RX)  : ORIGIN = 0x00000400, LENGTH = 0x00000010

  m_text                (RX)  : ORIGIN = 0x00000410, LENGTH = 0x000FFBF0

  m_data                (RW)  : ORIGIN = 0x1FFF0000, LENGTH = 0x00010000

  m_data_2              (RW)  : ORIGIN = 0x20000000, LENGTH = 0x00030000

}

To:

Assuming 0x8000 shift it becomes

MEMORY

{

  m_interrupts          (RX)  : ORIGIN = 0x00008000, LENGTH = 0x00000400

  m_flash_config        (RX)  : ORIGIN = 0x00008400, LENGTH = 0x00000010

  m_text                (RX)  : ORIGIN = 0x00008410, LENGTH = 0x000FFBF0-0x8000

  m_data                (RW)  : ORIGIN = 0x1FFF0000, LENGTH = 0x00010000

  m_data_2              (RW)  : ORIGIN = 0x20000000, LENGTH = 0x00030000

}

The flash configuration is not required in the application but can be left there if it proves complicated to remove it.

To ensure that the linker generates a waring on case the code is so large that it conflicts with parameters are 0xfa000 it can also be modified as:

  m_text                (RX)  : ORIGIN = 0x00008410, LENGTH = 0x000FFBF0-0x8000-0x6000

In the opriginal case it can also be modified:

  m_text                (RX)  : ORIGIN = 0x00008410, LENGTH = 0x000FFBF0-0x6000

Regards

Mark

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

K64: http://www.utasker.com/kinetis/FRDM-K64F.html / http://www.utasker.com/kinetis/TWR-K64F120M.html / http://www.utasker.com/kinetis/TWR-K65F180M.html

Boot loader: http://www.utasker.com/docs/uTasker/uTaskerSerialLoader.PDF

For the complete "out-of-the-box" Kinetis experience and faster time to market

0 Kudos

1,533 Views
sudhakarp
Contributor V

Hi,

If suppose I configured m.text origin starting ox0000 means  it will write application code from this address. ?Actually I don't know why we are allocating space for m_interrupt and m_flash_config can you explain this things.

Thanks and regards,

Sudhakar p

0 Kudos

1,533 Views
mjbcswitzerland
Specialist V

Hi

m_interrupt includes the reset vector and is required for the processor to be able to boot.

m_flash_config contains the flash configuration (flash protection and security settings)

m_interrupt is also required in order to jump from boot loader to the application.

m_flash_config exists in the boot loader and so is of no use in the application.

Regards

Mark

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

K64: http://www.utasker.com/kinetis/FRDM-K64F.html / http://www.utasker.com/kinetis/TWR-K64F120M.html / http://www.utasker.com/kinetis/TWR-K65F180M.html

Boot loader: http://www.utasker.com/docs/uTasker/uTaskerSerialLoader.PDF

For the complete "out-of-the-box" Kinetis experience and faster time to market

0 Kudos

1,533 Views
sudhakarp
Contributor V

hi mark,

     Now i got it. (for make sure) actually my understanding bootloader code will be from

0x00000410 to 0x00008410  and my application will start 0x00008410 am i correct..? actually nearly 32KB for bootloader code am i right.

     AND  also i tried to go through serial bootloader code. but i didnt get which place its jumbing to Application code and which condition its jumping and all. in KDS its All Serial bootloader file are showing like hidden  files.

only utaskerv1.4 only showing like original files (i mean that color difference). i cant find serial bootloader code main function.

project explorer u can see the difference. i planed to edit bootloader code depends on my requirement

so please help me. i need your support .pastedImage_5.png

0 Kudos

1,494 Views
mjbcswitzerland
Specialist V

Hi

The target is not always shown correctly in KDS - this is due to a stange default configuration that it uses, but it can be corrected by changing the setting as described here:

KDS not correctly displaying files belonging to the active target

Then you will see the correct files as used by the serial loader target. Even when the files are shown greyed out they are still used and built correctly.

The serial loader occupies the Fash space 0x00000000 to x, where x is the size of the binary file generate (look at the size that is generated with your IDE/compiler by simply viewing the binary file size in Windows explorer). With Ethernet and SREC functionality it will be about 24k in size. The default settings are to have the application at 0x8080 but these can be changed if desired.

Your appliation needs to be linked to the start address (default 0x8080 - where the reset vector is located).

The code responsible for jumping to the appliation is

start_application(_UTASKER_APP_START_);

Regards

Mark

Kinetis: µTasker Kinetis support

K64: µTasker Kinetis FRDM-K64F support  / µTasker Kinetis TWR-K64F120M support / µTasker Kinetis TWR-K65F180M support

Boot loader: http://www.utasker.com/docs/uTasker/uTaskerSerialLoader.PDF

For the complete "out-of-the-box" Kinetis experience and faster time to market

1,493 Views
sudhakarp
Contributor V

Hi,

     you mentioned bootloader code will start from 0x00000000 so is bootloader dnt need linker file?.

if suppose am writing bootloader code in KDS means what i should configure Linker file setting? can you give example linker memory map file and can you explain? because i planned to modify "Hello world" example code into bootloader code. so for that i want to configure linker file. is  possible?

thanks and regards,

sudhakar p

0 Kudos

1,493 Views
mjbcswitzerland
Specialist V

Hi

Every project requires a linker script file. The one used by KDS and the uTasker Serial Loader for the K64 is

\Applications\uTaskerV1.4\KinetisCodeWarrior\Linker_Files\K_1M_256.ld [note that KDS and CW share the same file, as do the application and serial loader]

I don't understand why you want to rewrite a complete loader starting with a hello world example since it will take several weeks of development, when you already have a complete and proven one which you can build with KDS.

Regards

Mark

Kinetis: µTasker Kinetis support

K64: µTasker Kinetis FRDM-K64F support  / µTasker Kinetis TWR-K64F120M support / µTasker Kinetis TWR-K65F180M support

Boot loader: http://www.utasker.com/docs/uTasker/uTaskerSerialLoader.PDF

For the complete "out-of-the-box" Kinetis experience and faster time to market

1,493 Views
sudhakarp
Contributor V

Hi mark,

     how to create .s19 file in KDS2.0 IDE. i can able to create .bin, .hex and .elf but i can't able to create .s19 file.

i think serial bootloader code will accept .s19 file so how to make that setting in KDS 2.0.

regards,

sudhakar p

0 Kudos

1,493 Views
BlackNight
NXP Employee
NXP Employee

Hi Sudhakar,

You have to select Motorola S-Record:

pastedImage_2.png

see Binary (and S19) Files for the mbed Bootloader with Eclipse and GNU ARM Eclipse Plugins | MCU on Ecl... .

I hope this helps,

Erich