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

46,052 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

4,549 Views
mjbcswitzerland
Specialist V

Hi

I reset peripherals and disable and clear all potential interrupt sources before jumping to the application.

This ensures that the application doesn't enable a peripheral to find an interrupt already waiting, which can cause some code to fail if it hasn't prepared everything ready for this and actually handles the interrupt prematurely.

Where it is compulsory or not depends on the actual application code in question - generally I would advise it because it then means that the risk of a particular application (with the drivers that it uses) having a potential issue is removed.

Regards

Mark

0 Kudos
Reply

4,549 Views
sudhakarp
Contributor V

hi mark,

     am receiving .SREC file(motorola S-record)and am extracting  data bytes and then am writing that data into internal data  flash. my application End address 0x0A49B4 only so its not exceeding limit. but am not erasing excess memory is any problem? give some possible solution it helpful to me..

regards,

sudhakar

0 Kudos
Reply

4,549 Views
sudhakarp
Contributor V

Hi Mark,

     Thank you v.very much. finally i did bootloader code working with external data flash.

once again thank you for your support.

regards,

sudhakar p

0 Kudos
Reply

4,549 Views
sudhakarp
Contributor V

hi mark,

    bootloader jumping code.

void start_application(unsigned long app_link_location)

{

    #if !defined KINETIS_KL || defined KINETIS_KE                         // {67} cortex-M0 assembler code

        #if !defined _WINDOWS

    asm(" ldr r1, [r0,#0]");                                             // get the stack pointer value from the program's reset vector

    asm(" mov sp, r1");                                                  // copy the value to the stack pointer

    asm(" ldr r0, [r0,#4]");                                             // get the program counter value from the program's reset vector

    asm(" blx r0");                                                      // jump to the start address

        #endif

    #else                                                                // cortex-M3/M4 assembler code

        #if !defined _WINDOWS

    asm(" ldr sp, [r0,#0]");                                             // load the stack pointer value from the program's reset vector

    asm(" ldr pc, [r0,#4]");                                             // load the program counter value from the program's reset vector to cause operation to continue from there

        #endif

    #endif

}

i am passing argument like that

#define UTASKER_APP_START     (32 * 1024)

start_application(UTASKER_APP_START);

     but inside start_application function "UTASKER_APP_START" value was not used. but i dnt know how its working for less than 512KB.

regards,

sudhakar p

0 Kudos
Reply

4,549 Views
sudhakarp
Contributor V

Hi,

I already did external data flash read write code using ksdk dspi example.in my bootloader code need  external data flash read write also.I dnt know how to implement dspi code into utasker project. I have dspi ksdk library and also I am some what familiar with ksdk example. So i plan to write bootloader code using ksdk example only. That why am asking again and again linker setup for ksdk project. Is utasker serial bootloader have dspi library mean I will use that code only. I want external data flash read write code. My bootloader should support serial and also external data flash. Otherwise tell how to implement dspi library into utasker project..? Give some example codecode I am using AT45DB161flash chip

0 Kudos
Reply

4,549 Views
mjbcswitzerland
Specialist V

Hi

The uTasker project includes DSPI drivers for various SPI based Flash devices - in spi_flash_kinetis_atmel.h you will find the ATMEL AT45DBXXX low level interface and in kinetis_FLASH.h you will find the application interface for both internal and SPI flash.

You an read, write and delete any flash content (irrespective fo whether it is in internal or SPI flash) using the interface described in chapter 6 of http://www.utasker.com/docs/uTasker/uTaskerFileSystem_3.PDF

You can also simulate the Flash operations.

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

0 Kudos
Reply

4,549 Views
sudhakarp
Contributor V

Hi,

i think am confusing you.

     my requirement:

     in my custom board  First time i want to load bootloader code and also application code. for that what i have do to..?

see in serial_bootloader example code we are loading only bootloader. throught bootloader we are updating application code. but here i want to load both bootloader and application code for that what i have to do..?

regards,

sudhakar p

0 Kudos
Reply

4,549 Views
mjbcswitzerland
Specialist V

Hi

One simply takes the two programs and combines them at the binary or HEX/SREC level.

The uTaskerCombine utility (uTasker Utilities ) is designed for this.

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

0 Kudos
Reply

4,549 Views
sudhakarp
Contributor V

HI MARK,

i dnt have any problem with serial_bootloader. its working fine. i can able to load application code also. that task completed.

     now i have separate 2(KSDK 1.1.0) example code. i want to change one example should work as bootloader another should work as Application code. i dnt want to receive any "SREC"  file and program. simply i want to jump from one example code into another example code.

i cant use same linker setup what i used for serial bootloader .

Because i am going to use External data flash for firmware upgrade. so for that i dnt know how to set linker file setup and all. in my bootloader code jst i will check in external data flash any data there or not. if not i want to jumb into application code.Actually first time for new custom board  i want to dump bootloader code and also application code then only it will work. because External data flash will get firmware file data from application code only.

now can you give some idea with some example..?

regards,

sudhakar p

0 Kudos
Reply

4,549 Views
mjbcswitzerland
Specialist V

Hi

The uTasker "Bare-Minimal" Loader includes support for loading from various SPI Flash devices: http://www.utasker.com/docs/uTasker/uTasker_BM_Loader.pdf

I still don't understand why you have a hello world prgram to call another program (?)

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

0 Kudos
Reply

4,549 Views
sudhakarp
Contributor V

hello mark,

thank you very much. when i press SW2 its going to bootloader mode. thank you.

i have one more doubt. if i load  my application code through PE multilink universal its not working when i configured linker file to following setup

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

}

if i configured from starting address 0x00000000 its working . so can you tell reason for this?

regards,

sudhakar p

0 Kudos
Reply

4,549 Views
mjbcswitzerland
Specialist V

Hi

It is normal that loading an image linked to 0x8000 will not work if you load it with a debugger - the reset vector is missing at 0x0000.

If you want to load it without the serial loader you must link it to 0x0000.

What I do is always link two outputs - one at 0x0000 and one at 0x8000 then I always have whichever one I need.

In addition, I use the "uTasker combine" utility [ uTasker Utilities ] to also combine the serial loader with the offset program into a single binary that can load both the serial loader and an initial application (with the debugger) to save time when factory programming.

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

0 Kudos
Reply

4,549 Views
sudhakarp
Contributor V

HI Mark,

     i want to load and see serial bootloader code in FRDMK64f120 Development mode. is any ready made serial bootloader code available..? if available mean how to dump bootloader code into controller internal flash.can i use OPENSDAv2 Bootloader mode or Multilink programmer?. is any hardware setup need for UART or i can use SDAUSB for serial UART.

thanks and regards,

sudhakar p

0 Kudos
Reply

4,549 Views
sudhakarp
Contributor V

hi mark,

i am loaded serial_bootloader code using OPENSADv2 after loading am getting this menu.

i loaded hello example code but after restarting nothing working its hanged what may be the problem.?

any linker file problem

pastedImage_0.png

0 Kudos
Reply

4,549 Views
sudhakarp
Contributor V

Hi Erich Styger,

     thank you.

regards,

sudhakar p

0 Kudos
Reply

4,549 Views
sudhakarp
Contributor V

Hi MARK,

     Thank you. now i got some idea. previously i confused with bootloader linker file and application linker file.

thanks and regards,

sudhakar p

0 Kudos
Reply

4,589 Views
microeval
Contributor I

Hi Mark,

Currently am working for FRDM-KL26Z MCU. Is there any SPI example codes(SD card/any) is available for the Kl26Z128 MCU?. I searched in the IAR IDE examples and codewarrier examples but am not able to get any SPI example. I followed the Arduino Data-Logger Shield with the FRDM-KL25Z Board | MCU on Eclipse link for KL26Z SPI configuration but it is not working with Kl26Z.

Where can i get the basic SPI example code?.

Thanks for help,

--Regards,

Ram. 

0 Kudos
Reply

4,589 Views
mjbcswitzerland
Specialist V

Ram

In the uTasker project you can configure for the FRDM-KL26 and enable SD card FAT operation - it will hook the SPI up as follows:

    // - SPI1_CS   PTD-4 (J1-6) [VDD J9-4 / 0V J9-14]
    // - SPI1_SCK  PTD-5 (J2-4)
    // - SPI1_MOSI PTD-6 (J2-17)
    // - SPI1_MISO PTD-7 (J2-19)

If the FRDM-KL25 is selected it will hook the SPI up to

// - SPI1_CS   PTD-4 (J2-6) [VDD J3-4 / 0V J3-14]
// - SPI1_SCK  PTD-5 (J2-12)
// - SPI1_MOSI PTD-6 (J2-8)
// - SPI1_MISO PTD-7 (J2-10)

Otherwise the entire project adjusts itself to the processor in question so there is not need to worry about processor compatibilities etc.

Defines allow any SPI option to be configured if different wiring is required.

Regards

Mark

0 Kudos
Reply

4,589 Views
BlackNight
NXP Employee
NXP Employee

What is not working with that Data-Logger Shield example for the KL26Z? It all should be about selecting the right pins for SPI. Otherwise the KL25Z and KL26Z should be the same.

Erich

0 Kudos
Reply

4,589 Views
mjbcswitzerland
Specialist V

Eric

The SPI interface in the KL26 is not compatible with the one in the KL25 so KL25 code will not run on it without a small adaption of the register addresses.

Eg. The SPI1 data register is at address 0x40077005 in the KL25 but at address 0x40077006 in the KL26 (This is because the KL26 has 16 bit address match and data length capability and the KL25 has only 8 bit address match and data length capability and the registers are shifted a bit to make place for the wider values). This is in fact the same for the KL46 (which is compatible with the KL26 in this respect).

Regards

Mark

0 Kudos
Reply

4,589 Views
BlackNight
NXP Employee
NXP Employee

Hi Mark,

yes, I know that there are differences, but this is exactly where Processor Expert kicks in: I'm simply need to re-assign pins, and everything else like the register addresses is taken care of. I did not mean that the actual registers are compatible, but the interface of the Processor Expert component on top of it. Maybe I just simply need to create that example for the KL25Z for the KL26Z then next weekend....

Erich

0 Kudos
Reply