MK22FN1M0A bootloader

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

MK22FN1M0A bootloader

2,200 Views
LArmstrong1985
Contributor III

Hi,

I'm doing a porting of FRDM-K22 bootloader example to my custom board with MK22FN1M0A microcontroller.

I've a problem on clock initialization when it execute clock_mode_switch(s_currentClockMode, kClockMode_FEE)function because in FRDM-K22 it use IRC48M source that is not present in MK22FN1M0A.

I would know:

- how I can correctly configure my board? Is there a Freedom board that have a more similar microcontroller to mine that I can copy configuration? (I don't need USB configuration in my bootloader project)

- Can I use FEI directly or switch to PLL instead on bootloader project?

Thank you very much!

Tags (1)
0 Kudos
13 Replies

2,155 Views
LArmstrong1985
Contributor III

Hi,

I was able to start bootloader following FRDM-K64F bootloader example (unluckily there isn't MCUBOOT example for TWR-K21F120MA),

that switch between kClockMode_FEI_21MHz and kClockMode_FEI_48MHz.

Now the problem is that bootloader not correctly jump to my application. I use a linker script quite similar to FRDK-64F example.

This is memory configuration for my bootloader:

HEAP_SIZE = DEFINED(__heap_size__) ? __heap_size__ : 0x0;
STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x1000;
M_VECTOR_RAM_SIZE = DEFINED(__ram_vector_table__) ? 0x0400 : 0x0;

/* Specify the memory areas */
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 = 0x00020000
}

and this is memory configuration for my application:

HEAP_SIZE = DEFINED(__heap_size__) ? __heap_size__ : 0x0;
STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0400;
M_VECTOR_RAM_SIZE = DEFINED(__ram_vector_table__) ? 0x0400 : 0x0;

/* Specify the memory areas */
MEMORY
{
m_interrupts (RX) : ORIGIN = 0x0000a000, LENGTH = 0x00000400
m_flash_config (RX) : ORIGIN = 0x0000a400, LENGTH = 0x00000010
m_text (RX) : ORIGIN = 0x0000a410, LENGTH = 0x000FFBF0
m_data (RW) : ORIGIN = 0x1FFF0000, LENGTH = 0x00020000
}

 

I don't know if the problem is on bootloader or on application configuration, but 
what I see is that when bootloader calculate application entry and stackpointer entry (function get_user_application_entry) it return different value than the example for frdm-k64f.

In frdm-k64f the value are:

application_entry: 0xa411

stackpointer_entry: 0x1fff0808

In my bootloader the value are:

application_entry: 0xac01

stackpointer_entry: 0x1fff8170

What can these differences depend on? Who determines these values?

Thank you in advance!

0 Kudos

2,142 Views
nxf56274
NXP Employee
NXP Employee

Hi,

You do not change this line. The application and 'm_falsh_config' address should not begin with 0x410.  

The link I gave you has the picture related with the link file. You can refer it.

捕获.PNG

Have a great day,
TIC

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

- We are following threads for 7 days after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

2,132 Views
LArmstrong1985
Contributor III

Hi,

I was wrong to copy the map values ​​in the post, now they are correct.

For it I relied on the examples for FRDM-K64F and FRDM-K22F.
The entry points are the same for both what changes I have seen is the size of the m_text and m_data section of course.

Since everything seems correct to me, it would be possible to have a version of the bootloader and the example led_demo_freedom_a000 modified for the microcontroller MK22FN1M0A? 

Another question. Is possible to debug application with entrypoint start modified instead that 0x0? Where I have to specify 0xa000 address?

Thank you very much!

0 Kudos

2,119 Views
nxf56274
NXP Employee
NXP Employee

Hi,

If you develop a application and modify its link file correctly, you can debug it. The debugger will go to 0xa000 to start. You can make a test. Download a project that address begins with 0xa000. When you debug, you will see the debug address is 0xa410. And at the same time, the address (0 ~ 0xa000 -1) is 0xffff. So you can use the application project(not bootloader project) to debug the program.

Have a great day,
TIC

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

- We are following threads for 7 days after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

2,107 Views
LArmstrong1985
Contributor III

Hi,

I was able to start my application. Most likely, I was also misled by the fact that UART that is the basis of my application was not working.
But I understand why. Starting from the led_demo_a000 example for the FRDM-K22 I also used its own startup files. Unfortunately, however, in k22fn512 microcontroller there is no UART3 that I use, as in the k22fn1a.

I would like to know in order not to make mistakes it is possible to have the startup files (crt0_gcc.S, startup_MK22FN1M0A.S, startup.c) for MK22FN1M0A or if is possible to use default project startup_mk22fa12.cpp file with custom linker file. How to have to modify in this case?

Thank you very much!

0 Kudos

2,101 Views
LArmstrong1985
Contributor III

Hi,

I thought it was a UART problem, instead the application starts but after a few instructions I get the following error

ExecutingError.JPG

I try to move/comment some instructions but simply the problem shifts. 

The application has been tested and works correctly at location 0x0000 therefore with standard startup script and linker file automatically generated. I suspect the problem lies with the startup scripts.

What can i check? The only difference than the examples is that mine is a c ++ project with mixed code c / c ++. Are startup files always okay?

0 Kudos

2,041 Views
LArmstrong1985
Contributor III

Hi,

I managed to solve, following this guide of the mythical @ErichStyger (Erich Styger) who uses another technique

Linking Bootloader Applications with Eclipse and FreeMarker Scripts | MCU on Eclipse

Thank a lot @ErichStyger!

0 Kudos

2,076 Views
nxf56274
NXP Employee
NXP Employee

Hi,

So your bootloader can go to led demo. But if you use the uart example ,the bootloader can't jump ? 

Have a great day,
TIC

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

- We are following threads for 7 days after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

2,150 Views
mjbcswitzerland
Specialist V

H

The stack pointer and program entry values are taken from the application's reset vector entries. They look correct for the processors involved and it is normal that the program entry value can vary between each application build.

If the loader is jumping to that address but the application doesn't start it will be due to a problem in the application.

Regards

Mark

 

0 Kudos

2,165 Views
mjbcswitzerland
Specialist V

Hi

You can get out-of-the-box boot loaders for the K22 (all variants are supported) for KBOOT compatible, USB-MSD, UART, SD card, memory stick in the free open source uTasker project: https://github.com/uTasker/uTasker-Kinetis

Builds with KDS, MCUXpresso, IAR, Keil uVision, Rowley Crossworks, Green Hills, and GCC make file, plus builds in Visual Studio and runs a simulation of the chip and can be used to test boot loader operation.

Configurable clock setup to suit all capabilities of all parts so no porting is ever needed.

Regards

Mark
[uTasker project developer for Kinetis and i.MX RT]
Contact me by personal message or on the uTasker web site to discuss professional training, solutions to problems or rapid product development requirements

For professionals searching for faster, problem-free Kinetis and i.MX RT 10xx developments the uTasker project holds the key: https://www.utasker.com/kinetis/TWR-K22F120M.html

0 Kudos

2,176 Views
LArmstrong1985
Contributor III

Hi,

I'm using FRDM-k22F bootloader example (that use MK22F512N microcontroller) on MCUXpresso IDE.

I'll try to see the example for FRDM-K64F.

@myke_predko thank you very much for your suggestion. I'll try to see also the example for TWR-K21F120MA if it is more  close to the target MCU, so much I am only interested in the initialization part of the clock and the CANBUS configuration parameters

0 Kudos

2,184 Views
nxf56274
NXP Employee
NXP Employee

Hi,

Which IDE and example do you use?  You can refer this link. https://community.nxp.com/t5/Kinetis-Microcontrollers/FRDMK64F-SD-Bootloader/ta-p/1099807

This k64 bootloader clock is set as PEE. And before it jumps to application, it changes to FEI.

Have a great day,
TIC

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

- We are following threads for 7 days after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

2,193 Views
myke_predko
Senior Contributor III

@LArmstrong1985 

I'm working at using a FRDM-K22F as a development tool while I'm waiting for my custom MK22FN1M0AVDM12 PCBs come in and while I don't think I'm going to have the same issues as yours, I'm interested in the response you get from NXP.  

As far as I know (and have been told), there is no Freedom board which is a close match to the MK22FN1M0Axxxxx - when I asked, I got told to use the TWR-K21F120MA which is somewhat close to the target MCU but isn't in the Freedom form factor which makes it more unwieldly to connect hardware to.  I can't comment on clocking between the two MK2x parts.  

Good luck!  

myke

0 Kudos