After programming the board with KBOOT 1.2.0 default file from \apps\binaries\FRDM_KL43Z4.bin with the help of blhost, I changed the Flash configuration FOPT register so that device starts from ROM:
/* Flash Configuration */
.section .FlashConfig, "a"
.long 0xFFFFFEFE /*now starting from ROM*/
Now I have the following problems (when I debug the app in KDS everything works fine):
1. After exiting debug mode and simply reconnecting the USB cable, the device waits around 3-4 seconds before it starts
2. When it starts, after two-three main while loop runs - it stops (I see it because I have put a counter that is shown on the LCD)
3. When I connect the USB to the KL43 USB port (not OpenSDA port), only part of my LCD screen is working, so apparently it does not even go through the main loop once
I am confused now, because if I want to upload new program using blhost.exe then I need to set FOPT to boot from ROM. And after doing it the program does not run correctly.
What am I doing wrong?
EDIT: I realized that running
blhost -p COM13 -- write-memory 0 FRDM_KL43Z4.bin
I placed the bootloader in Flash memory (adress 0). And according to Chapter 4.5 System memory map:
Program flash and read-only data
(Includes exception vectors in first 196 bytes)
I may have overwritten the vectors.
Is that wrong?