Hello,
I have ported the Kinetis_Bootloader for KL16 from KL26,it works well. Then I used the bootloader GUI to download user application,after program successed,the user application works normally too.
But,if I shutdown the power and then repower,user application dosn't work。I used a LED to Indicate the bootloader program,so I'm pretty sure that the bootloader is working correctly。
why is the user appll can work only once? If anyone else meet the problem?
HI cheng feng,
After you repower on, the code will run the bootloader at first, after the timeout, it will enter the application code.
The timeout time is about the 5 seconds if you don't modify the official code.
Do you wait about 5-10 seconds, to check the application function?
Besides, you must make sure your relocate address is not in the bootloader range. If you still not OK, you can read out the application code from the flash, whether it has data or not?
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
I got the bootloader project form GitHub - jenniezhjun/Kinetis-Bootloader: Kinetis-Bootloader , and Modified the condition to enbale boot like:
if((GPIO_PDIR_REG(BOOT_PIN_ENABLE_GPIO_BASE) & (1 << BOOT_PIN_ENABLE_NUM)) == 0) //3. SW1 is pressed
{
enableBootMode = 1; // enable boot
BOOT_LED_ON;
AppIDC = 0;
}
......
while(enableBootMode) // enter boot or verify mode, execute all command from GUI
{
......
}
BOOT_LED_OFF;
// deinitialization of used modules
UART_Deinitialization();
DEINIT_BOOT_LED;
DEINIT_CLOCKS_TO_MODULES;
SysTick->CTRL = 0 ;
SCB->ICSR |= SCB_ICSR_PENDSTCLR_Msk ;
// relocate vector table
SCB_VTOR = RELOCATED_VECTORS;
AppIDC = 0;
// Jump to user application
JumpToUserApplication(*((unsigned long*)RELOCATED_VECTORS), *((unsigned long*)(RELOCATED_VECTORS+4)));
return 0;
so, I can use the BOOT_LED to determine state of the bootloader.
The relocation address is 0x1000
I also Verified the flash after downloading the user APP, it seens normal.
0x1400~0x140C is the APPOK section, and the rest is user APP data
What make me confused is that why the user App can only work for one time
For more tests, I power on device with BOOT Key pressed, it enter boot mode, then I download the user app again, it shows programed ok。But the user APP doesn't run correctly。I found that only when I dowload the bootloader with Erase Full Chip option that the User APP can work one time
Any advice?
Hi cheng feng,
Do you check your bootloader code size, whether it is larger than 0x1000, besides, what the bootloader GUI you are using? I highly suggest you use our KBOOT2.0 KL25 code, then use the kinetisFlashTool to download the code, if there has some problems, the kinetisFlashTool will tell you the detail information, it will be more easy to find the problem.
Your code is not the official code, I suggest you use the official code:
You can find KL25 code from this folder:
NXP_Kinetis_Bootloader_2_0_0\targets\MKL25Z4
KinetisFlashTool folder:
NXP_Kinetis_Bootloader_2_0_0\bin\Tools\KinetisFlashTool\win
This post may also useful to you:
How to make MKL26Z128 be recognized by KBOOT Flash Tool Utility?
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello Kerry Zhou,
Thanks for your reply. I will follow your advice to try the KBOOT MDK tower version.
For the current bootloader code size is as below:
Total RO Size (Code + RO Data) 2200 ( 2.15kB)
Total RW Size (RW Data + ZI Data) 2248 ( 2.20kB)
Total ROM Size (Code + RO Data + RW Data) 2208 ( 2.16kB)
I choose this version because its code size is samll enough(around 2K), for our product is using KL16Z64 in witch a protocol stack have used more than 30K, so I have to limit the bootloader size . I did test the KBOOT for a quick look with the target KL25Z4,I modified the bootloader_config.h as be low, and the preprocessor symbles deine: BL_FEATURE_MIN_PROFILE,NDEBUG,USB_STACK_BM, CPU_MKL25Z64VLK4, CPU_IS_ARM_CORTEX_M0P=1, TOWER, BL_TARGET_FLASH (I can't remove the USB_STACK_BM or it will complie error)
#if !defined(BL_CONFIG_UART)
#define BL_CONFIG_UART (1)
#endif
#if !defined(BL_CONFIG_I2C)
#define BL_CONFIG_I2C (0)
#endif
#if !defined(BL_CONFIG_SPI)
#define BL_CONFIG_SPI (0)
#endif
#if !defined(BL_CONFIG_USB_HID)
#define BL_CONFIG_USB_HID (0)
#endif
#if !defined(BL_CONFIG_USB_MSC)
#define BL_CONFIG_USB_MSC (0)
#endif
Then I got the result -- Program Size: Code=8580 RO-data=1608 RW-data=384 ZI-data=5552
This size is larger than I expected.
Can you tell me the approximate code size with only UART supported in KBOOT?
BTW, when I use the IAR project in KBOOT, it shows errors
IAR ELF Linker V8.22.1.15669/W32 for ARM
Copyright 2007-2018 IAR Systems AB.
Error[Li005]: no definition for "__iar_small___aeabi_uidivmod" [referenced from xprintftiny.o(dl6M_tln.a)]
Error[Li005]: no definition for "__iar_small___aeabi_uidiv" [referenced from xprintftiny.o(dl6M_tln.a)]
Error while running Linker
Total number of errors: 2
I think it maybe due to my IAR version
=== Install subdirectory: arm ===
IAR Project Converter
4.00.2 (4.0.2.230)
C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.0\arm\bin\ConvertToIAR.exe
22/Feb/2018 13:24:14, 686080 bytes
C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.0\arm\bin\het470.exe
22/Feb/2018 10:05:20, 212992 bytes
IAR Archive Tool
10.2.5.200 (10.2.5.200)
C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.0\arm\bin\iarchive.exe
21/Feb/2018 02:25:38, 1297408 bytes
IAR Assembler for ARM
8.22.1.15669 (8.22.1.15669)
C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.0\arm\bin\iasmarm.exe
21/Feb/2018 02:25:38, 1914368 bytes
IAR C/C++ Compiler for ARM
8.22.1.15669 (8.22.1.15669)
C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.0\arm\bin\iccarm.exe
21/Feb/2018 02:25:38, 22944768 bytes
IAR C-STAT Checks Manifest Handler
1.5.2.316 (1.5.2.316)
C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.0\arm\bin\ichecks.exe
25/Jan/2018 01:07:32, 852992 bytes
IAR C-STAT Command Line Interface
1.5.2.316 (1.5.2.316)
C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.0\arm\bin\icstat.exe
25/Jan/2018 01:07:34, 955392 bytes
IAR ELF Dumper for ARM
8.22.1.15669 (8.22.1.15669)
Hi Cheng feng,
I have checked the KBOOT2.0 code, if just use the UART, and in the release mode, the code size is :
It's about 19K, so if you are using the 64K chip, you still have about 45Kflash for your app.
About the build error, it should be the IAR newest version problem, I build the IAR with lower version(7.80), it has no problem, but I tried the IAR V8.22 also have problems, because the official code also based on the IAR7.x. the new IAR version may changed some ide level's lib folder, now do you mind to use other IDE, eg MDK, or KDS?
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Kerry Zhou,
The problem is solved.
I add EnableInterrupts in the user APP's initialization, and then it works normally.
In the bootloader DisableInterrupts was called.
Thank you for your attention and help
Hi Chen feng,
Thank you for your updated information, it's good to hear you problem is solved.
If you have the new question in the future, please kindly let us know!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Kerry Zhou,
Thank you for the help. 19K is too large for our product, so I have to give up the KBOOT
I had localize the problem to the user APP's IRQ
The user program runs normally on its own. To fit zhe bootloader, I modified the link file FRDM_KL26Z_cfg.h follow the instructions of the documen<<Kinetis Bootloader Application Note - 0104>> 3.3.8 setp1
#define RELOCATED_VECTORS 0x1000 // Start address of relocated interrutp vector table
#define AppIDC *((LWord*)(0x20001800 - 8))
#define APPOK_START_ADDRESS RELOCATED_VECTORS + 0x400
#define APPOK_LENGTH 8
#define FRAME_BUFF_LENGTH 80
#define CHECK_OK 0
#define CHECK_FAIL 1
#define WR_BLOCK_BYTE 0X40
#define ER_BLOCK_BYTE 0x400
#define Non_volatile_address_start 0x03FC
#define Non_volatile_address_end 0x03FF
#define FlashSize 0x10000
#define BL_M0 1
#define BL_M4 2
How should I do if I want to chek the IRQ on the user APP