Is there an ability to load a program to FRDM-KE04Z/KE06Z through UART?

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

Is there an ability to load a program to FRDM-KE04Z/KE06Z through UART?

1,371 Views
jeniabrook
Contributor II

Hello.

First of all I'm newbie in this area :smileyhappy:.

Is there an ability to load a program to FRDM-KE04Z/KE06Z through UART?

I need for my project option to be able to load new/updated programs on KE04Z/KE06Z.

I have read about bootloaders various literature and some stuff/answers on this community, but due to my lack of experience in this field, I've lost myself :smileyplain:.

How can i achieve this goal? What steps should I do?

Thank you for your attention.

BR,

Jenia

Labels (1)
Tags (4)
0 Kudos
11 Replies

1,020 Views
mjbcswitzerland
Specialist V

Jenia

1. Which version are you using? I suspect V1.4.7

2. Beware that KDS is a bit wierd in that it doesn't always correctly highight the folders belonging to the target (see  KDS selection project active for how to correct this). Then the serial loader folder will be highlighted when you select its target.
3. I suspect that you have modified config.h in the uTaskerV1.4 target rather than the uTaskerSerialBoot target, which means that you are in fact building for a different processor but with Cortex-m0+ setting; this will fail since it tries to use some m4 assembler code with the m0+ compiler/assembler. That is, make sure you edit in \Applications\uTaskerSerialBoot\config.h and not in \Applications\uTaskerV1.4\config.h

Generally I recommend using the latest V1.4.11 version since it has a complete set of serial loader targets (the V1.4.7 has FRDM-KE02Z but not actually FRDM-KE06Z since it is an older version from 2014, although it is easy to add a new board if desired since there is a reference in the uTaskerV1.4 target).

To select the UART used you can set LOADER_UART (in app_hw_kinetis.h) to the UART number (eg. 0 or 1).

To selet the actual pins used there are number of defines such as UART0_ON_A

Check the code in fnTxOn() and fnRxOn() which is selecting the pins. Eg. for the KE family it does the following for UART0 Tx:

#if defined UART0_ON_A

    SIM_PINSEL0 |= (SIM_PINSEL_UART0PS);

    _CONFIG_PERIPHERAL(A, 3, (PA_3_UART0_TX | UART_PULL_UPS)); // UART0_TX on PA3 (alt. function 2)

#else

    _CONFIG_PERIPHERAL(B, 1, (PB_1_UART0_TX | UART_PULL_UPS)); // UART0_TX on PB1 (alt. function 2)

#endif

In addition, if you build and run in the uTasker KE simulator you can also see the function of each pin to check that the peripherals are configured as desired.

Regards

Mark

0 Kudos

1,020 Views
jeniabrook
Contributor II

Mark

  1. I'm using uTaskerKinetisV1.4.11.
  2. Thanks for the explanation regarding to KDS project selection.
  3. I have modified the config.h in uTaskerSerialBoot target. LOADER_UART is 1 according to KE06Z choice.
  4. I've built the project, uTaskerSerialLoader.elf created (bin, srec are missing), tried to flash it via KDS, it is different from the video tutorial (with Code Warrior). Tried to hook up UART (checked all possible pins for that) and it didn't work.

Can you explain how to flash properly via KDS ?

If LOADER_UART is 0, does it means that UART0 is set for the serial loader?

Thank you.

BR,

Jenia

0 Kudos

1,020 Views
mjbcswitzerland
Specialist V

Hi Jenia

If you build with KDS there is a post-build step that executes a bat file called "generate.bat" in

\Applications\uTaskerSerialBoot\KinetisDesignStudio\uTaskerSerialLoader_FLASH

If all works correctly you should find that it then generates *.bin, *.srec and *.ihex outputs from the elf file.

The simplest way to load the binary file to the board is by using drag-and-drop (bin file) onto the external hard drive that appears when the board is connected. Make sure that you have the latest P&E OpenSDA boot loader installed on the board.

UART1 is connected on the board to the OpenSDA's virtual COM port (UART1 RX = PTC6 and UART1 TX = PTC7). When the boot loader project is loaded you should be able to comunicate over this interface. I recommend to not use the KBOOT build for first tests since the SREC UART loader option displays a menu on the interface by default which allows the communication to be tested more easily. Note that the green LED flashes at 5Hz when the code runs normally.

If you want to program from KDS you will need to make a debug connection which is described at http://www.utasker.com/forum/index.php?topic=1915.msg7020#msg7020

If you change LOADER_UART to 0 it will indeed move the UART interface from UART 1 to UART 0.

Regards

Mark

0 Kudos

1,020 Views
jeniabrook
Contributor II

Thank you Mark.

I've successfully uploaded the serial loader to the target, the green LED is indeed flashes at 5Hz.

Hooked up the UART interface and connected to one of the terminals and this is what I'm getting:

01.jpg

I've verified the setting in the code and in terminal emulator --> [115200 Baud, 8 Bits, 1 Stop bit, no parity, XON/XOFF flow control].

In TeraTerm the same result:

02.jpg

I know that if I see some gibberish from UART it is probably misfit between the UART interface and the terminal emulator in settings, in this case I've double checked the settings.

What could be the problem & how to overcome it?

Thank you again.

BR,

Jenia

0 Kudos

1,020 Views
mjbcswitzerland
Specialist V

Hi Jenia

The baud rate is configured with the define (eg.):

#define SERIAL_SPEED      SERIAL_BAUD_38400

If you have the KBOOT loader operation (rather then SREC) it is fixed at SERIAL_BAUD_57600 since the KBOOT utility is fixed at this speed.

If you have configured for the SREC loader you should get a menu printed out at each reset, therefore you can check that the characters are originating from the board by repeating a reset and you should see the same pattern each time. To be absolutely sure you can check the baud rate with an oscillocope to see whether there is some deviation.

Regards

Mark

0 Kudos

1,020 Views
jeniabrook
Contributor II

Mark

Baud rate is:

#define SERIAL_SPEED      SERIAL_BAUD_115200 

I've checked the baud rate with an oscilloscope and it was ~100000, so I think it is OK.I configured for the SREC loader.

Any other suggestion ?

Thank you.

BR,

Jenia

0 Kudos

1,020 Views
mjbcswitzerland
Specialist V

Jenia

The FRDM-KE06Z target defaults to using the 8MHz crystal as clock source, based on these defines in app_hw_kinetis.h:

#define CRYSTAL_FREQUENCY    8000000 // 8 MHz crystal

#define _EXTERNAL_CLOCK      CRYSTAL_FREQUENCY

#define CLOCK_DIV            256 // input must be divided to 31.25kHz..39.06525kHz range (/1, 2, 4, 8, 16, 32, 64, 128, 256, 512 or 1024 possible)

                                 // this input is multiplied by 1024 to 32MHz..40MHz at the FLL output

#define SYSTEM_CLOCK_DIVIDE  1   // divide the FLL output to give the system clock (maximum 40MHz) (/1, 2, 4, 8, 16, 32, 64 or 128 possible)

#define BUS_CLOCK_DIVIDE     2   // divide by 1 or 2 to give bus and flash clock (maximum 20MHz)

This causes the 8MHz input to be divided down to 31'250Hz for the FLL input and then it is multipled by a fixed x1280 to 40.0MHz FLL output.

The system clock is 40MHz and the Bus clock is 20MHz, whereby the Bus clock is used to clock the UART.

The UART baud divider value is 0x0b, which gives 113'636 Baud, which is 1.5% lower than 115'200Baud but should usually be adequately accurate.

I would try with a slower Baud rate, like 19'600, to see whether you can get the menu to display correctly and otherwise check the HW to see whether there are any difficulties at the higher speed (like slow edges due to loading etc.). Since the OpenSDA virtual COM port doesn't respect XON/OFF it is usually necessary to limit to around 38.4kBaud to avoid the UART overrunning when programming flash when using the SREC method without INTERMEDIATE_PROG_BUFFER option (see quide for details).

Regards

Mark

0 Kudos

1,020 Views
mjbcswitzerland
Specialist V

Hi

You can get a UART loader (either SREC/iHEX/KBOOT/Developer's Loader) for the FRDM-KE06 from http://www.utasker.com/kinetis/FRDM-KE06Z.html

Since the KE04 has only 8k of Flash it is not normally practical to use a boot loader on it since the boot loader will tend to already use up the available Flash space...

Regards

Mark

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

0 Kudos

1,020 Views
jeniabrook
Contributor II

Thank you Mark.

I downloaded the uTaskerV1.4, opened it in KDS accordingly to yours instructions µTasker Kinetis Compiler Information .

In ''Build Configurations --> Set Active'' I chose uTaskerSerialLoader_FLASH.

In config.h I selected FRDM_KE06Z and verified that only one target is selected.

In "File-->Properties --> C/C++ Build --> Settings --> Tool Settings --> Target Processor --> ARM family" I selected cortex-m0plus.

In "Cross ARM C++ Linker --> General"

I selected "KE_128_16_ld".

After all that, I build the project and I

have an error (look at the image that I've attached), what I'm doing wrong?

sssss.jpg

How can I know which pins are configured to use as UART for the loader?

Thank you.

BR,

Jenia

0 Kudos

1,020 Views
ivadorazinova
NXP Employee
NXP Employee

Hi Jenia,

please, take a look at UART Boot Loader Design on Kinetis E Series - Application Note and for related SW

AN4767SW.zip

Please, let me know if this helps.

Iva

0 Kudos

1,020 Views
jeniabrook
Contributor II

Thank you Iva.

It doesn't help me much.

I`m looking for simpler solution like Mark suggested down below.

BR,

Jenia

0 Kudos