FRDM-KL25Z uTasker USB Bootloader application program

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

FRDM-KL25Z uTasker USB Bootloader application program

Jump to solution
2,204 Views
jerryfavero
Contributor I

I'm testing the FRDM-KL25Z board. I flash it with USB Bootloader uTaskerSerialLoader_FRDM-KL25Z.srec (download from utTasker site) .

Similarly as FRDM-K20D50M FRDM-K20D50M uTasker USB Bootloader application program

in an application program :


1) I have disabled "Generate Linker file" in Build Option in PE, and edit it manually as :

MEMORY {

  m_interrupts      (RX):  ORIGIN = 0x00008080, LENGTH   = 0x000000F8

  m_cfmprotrom  (RX) :  ORIGIN = 0x00008400, LENGTH   = 0x00000010

  m_text              (RX) :  ORIGIN = 0x00008410, LENGTH   = 0x00017BF0

  m_data            (RW):  ORIGIN = 0x1FFFF000, LENGTH  = 0x00004000

}


2) In "User code after PE Initializzation" in Build Option I have added , that is visible after building in CPU.c file:

//:::::::::::::::::::::::::::::::::::::::::::::::::::::::

  // USER CODE AFTER PE INITIALIZATION

  uint32_t *pdst ;

  uint32_t *psrc;

  uint16_t  i ;

  // Copy Application Stored Interrupt Vector table to RAM

  pdst=(uint32_t*) (0x1FFFF000 );

  psrc=(uint32_t*)( 0x8080 );

  for (i=0;i<0xF8;i++,pdst++,psrc++)

  {        (*pdst) = (*psrc);

  }

  // Then redirect the vector table to RAM by changing the SCB_VTOR like this:

  // Redirect the vector table to the new copy in RAM

  SCB_VTOR = (uint32_t)(0x1FFFF000);

//:::::::::::::::::::::::::::::::::::::::::::::::::::::::

 

I made a little code for blinking a led with Processor Expert, but

 

unfortunately the led don't blink.There 's something wrong.

Thanks to whoever can help me.

Jerry


 


Original Attachment has been moved to: FRDM-KL25Z-LED.bin.zip

0 Kudos
1 Solution
1,615 Views
mjbcswitzerland
Specialist V

Hi

The file that you have attached is a Motorola SREC file and not a binary file; you need to create a binary if you want to load to the uTasker serial loader using USB-MSD.

Loading the SREC via the UART is possible but the UART on the FRDM-KL05Z passes through the OpenSDA's virtual COM port. This doesn't support XON/XOFF and so won't work correctly as it is. Either a different UART can be used or else the Baud rate can be reduced from 115200 to 57600 (or lower) and the intermediate buffer removed (INTERMEDIATE_PROG_BUFFER) and then it programs each byte at a time to flash (but needs to be slower to avodi UART rx overruns while programming). See the uTasker serial loader guide for an explanation of the intermediate buffer operation for flash that can't program each byte fast enough to keep up with 115200 Baud reception.

The problem with your application program itself is that it is configuring SIM_CLKDIV1 for a system clock divide of 1 and a bus clock divide of 2, which is too fast for the KL25Z which is running at 48MHz due to the uTasker serial loader pre-configuration (system divide 2 and bus divide 4 to give 48MHz system clock and 24MHz bus clock). If you remove this clock setting it then flashes the LED.

Note however that the uTasker serial loader will have started the watchdog (if not disabled or PTD4 held at '0' at reset) and so you will either need to retrigger it or disable it to avoid it resetting after about 1s.

Regards

Mark

View solution in original post

0 Kudos
14 Replies
1,616 Views
mjbcswitzerland
Specialist V

Hi

The file that you have attached is a Motorola SREC file and not a binary file; you need to create a binary if you want to load to the uTasker serial loader using USB-MSD.

Loading the SREC via the UART is possible but the UART on the FRDM-KL05Z passes through the OpenSDA's virtual COM port. This doesn't support XON/XOFF and so won't work correctly as it is. Either a different UART can be used or else the Baud rate can be reduced from 115200 to 57600 (or lower) and the intermediate buffer removed (INTERMEDIATE_PROG_BUFFER) and then it programs each byte at a time to flash (but needs to be slower to avodi UART rx overruns while programming). See the uTasker serial loader guide for an explanation of the intermediate buffer operation for flash that can't program each byte fast enough to keep up with 115200 Baud reception.

The problem with your application program itself is that it is configuring SIM_CLKDIV1 for a system clock divide of 1 and a bus clock divide of 2, which is too fast for the KL25Z which is running at 48MHz due to the uTasker serial loader pre-configuration (system divide 2 and bus divide 4 to give 48MHz system clock and 24MHz bus clock). If you remove this clock setting it then flashes the LED.

Note however that the uTasker serial loader will have started the watchdog (if not disabled or PTD4 held at '0' at reset) and so you will either need to retrigger it or disable it to avoid it resetting after about 1s.

Regards

Mark

0 Kudos
1,615 Views
jerryfavero
Contributor I

Hi Mark,

I changed the clock setting and now the application program works fine.

I noticed a strange thing :

accidentally I have insert to MSD a new application program without deleting the old file.

pastedImage_0.jpg


The risult is that the bord don't exit from boot; after reset is not more possible to download other files.

It seems that the boots is damaged, it is necessary erase the micro and reloading the boot file to restore the correct functionality.


I have tasted in a new computer with WIN8,  but  there is some problems..

If you connect the board with inside only the boot, only the fist time it's possible to insert the program file.

Thanks in advance

Jerry


0 Kudos
1,615 Views
mjbcswitzerland
Specialist V

Jerry

I see that you have changed the name of the upload disk ;-)

1. According to the documentation it is necssary to first delete the existing file before uploading a new file, unless the new file has the same name as the old one. This is due to the internal workings and interaction with the file system on the PC. Uploading a new file with a different name will allow the trtansfer to take place and then you will see two files but nothing will have been programmed to Flash - the original file is still there.
This means that there shoudl be no consequence of doing this - I will do some tests to see whether I can reproduce an effect. In the meantime either load the same name for an automatic erase/program or else perform the manual delete.

2. There is a define WINDOWS_8_1_WORKAROUND which adds a workaround for Windows 8.1. This was added at the beginning of 2014 when Windows 8.1 patch became available and people started having problems with USB-MSD loaders generally. Since then I haven't heard of new issues but I have very recently aquired a Windows 8.1 PC whcih I can now test on myself. Again I will do wome checking and inform of any new requirements as appropriate.

In the meantime I understand that also changing a Win8.1 setting as follows avoids difficulties: http://answers.microsoft.com/en-us/windows/forum/windows8_1-hardware/how-do-i-prevent-system-volume-...

Regards

Mark

1,615 Views
jerryfavero
Contributor I

Thank you Mark,

After I have reproduced the problem, I have read the entire KL25 with segger-jlink.

I  attached, if it can help you, my original bootloader (uTaskerSerialBoot.srec), the entire program code (boot+app.) and (BootRead.srec), and entire program code without app. code

(BootRead-noApp.srec ) deleted manually.

Unfortunately after the problem it is necessary to erase the chip and download the original boot.


0 Kudos
1,615 Views
mjbcswitzerland
Specialist V

Jerry

I just loaded your file (the one with the complete flash image) and see that theer is an application running which flashes the green LED.

If I short circuit J1-6 with GND and made a reset of the board it eneters the boot loader and then I see the application "FRDM-KL25Z-LED-03.bin 26.11.2014 14:36 2'604 bytes".

The boot loader flashes the RED LED (which you changed).

I could then upload new programs to it. Therefore I don't think that it was necessary to load the boot loader again since it was fully intact and could be forced to start with the standard input.

Also I did a first test using Windows 8.1; the software loading worked normally but I did see that it wrote a file called something like "information volume" as an invisible file (which is known and ignored as download data) but this does stop the file name display from operating normally. I'll fix this now that I can test it (although it doesn't cause any disturbance to the actual boot loading operation).

Regards

Mark

0 Kudos
1,614 Views
mjbcswitzerland
Specialist V

Jerry

I spend a couple of hours checking the Windows 8.1 behaviour in detail and making some adjustments to achieve full compatibility with the file display. I can now work with Windows 8.1 and Windows 7 and the results are identical in each case (allowing loading, deleting, overwriting etc.).

What Windows 8.1 does is create an invisible system directory called "InformationSystem Volume" in the root directory and a file called "IndexerVolume.INDEX" in it with a little data in unicode (I don't know how the data is interpreted but initially there are onyl about 20 bytes or so). This operation must not be mistaken for a user download, which is however easy to avoid. What it nevertheless does is complicate the management of a file name and information which can be displayed when the loader is started again with a software already stored due to the fact that this file may be there or also may not (eg. other Windows PCs or the operation disabled) and when it performs its writes it also allocates FAT clusters for its own use, which moves other sector locations aroudn for the boot loader .

With a little manipulation it is however quite simple to save things to flash as if it weren't there and so when it is connected again Windows 8.1 simply adds the same system directory (again) - after the software file object in the root directory. This doesn't really disturb anything and is ignored as anything to do with the uploading.

For the anaysis and modifications I uses a few USB simulation scripts (one for analysing and testing the Windows 8.1 connection sequence, one for the way that it deletes a file and one for the software upload). I have attached these as well as a new version of usb_loader.c [modifications are documented in the header with modification references {21} and {22} so that the changes can be copied to older versions if needed]. The simulation scripts can be played through the project code in the uTasker simulator to test the three cases (enumeration is commanded in the USB menu and then the scripts can be opened) which allows verifying the code's operation and also seeing the data involved (the file objects are easily interpretable once a DIR_ENTRY_STRUCTURE_FAT32 pointer is set to the sector buffer).

Regards

Mark

1,614 Views
jerryfavero
Contributor I

Thank you Mark, you are NUMBER 1!!:smileyhappy:

0 Kudos
1,614 Views
jerryfavero
Contributor I

Hi Mark,

with the new file usb_loader.c  there are some errors.

pastedImage_0.jpg

0 Kudos
1,614 Views
mjbcswitzerland
Specialist V

Jerry

I think that your serial loader file is a bit too old so, to be sure, I have attached all serial loader application files newer than July 2014. These are setup for the KL25 but I think that you probably only need a newer version of the Loader.c and possibly a new header due to fnADDSREC_fil() being moved to a different location.

The undefined references to fnGetUSB_x() can not be explained by file content since these are all in the latest usb_loader.c. However I expect that they will go away once you do a clean/rebuild after adding the new files to the project.

Regards

Mark

0 Kudos
1,614 Views
jerryfavero
Contributor I

Mark

with last your files now it's ok, I tested on WIN7.

The project that I have used is uTaskerKinetisV1.4.7  « Last Edit: July 08, 2014, 03:10:45 PM by mark » KINETIS Project Code

I see for example in your attached file config.h there are some newers modifications:

12.07.2014 Add FRDM_KE02Z40M, FRDM_KE04Z and FRDM_KE06Z

04.11.2014 Add FRDM_KL43Z, FRDM_K22F, TWR_K22F120M and TWR_K24F120M

05.11.2014 Add TWR_KV10Z32, FRDM_KL03Z, TWR_KM34Z50M and TWR_KW21D256

 

There is available a newer Kinetis project than V1.4.7?

May I use your uTaskerSerialLoaderApplicationFiles also with FRDM-K20D50M?

Unfortunately, my sister took me the computer with WIN8, I test it next week.


Regards

Jerry

0 Kudos
1,614 Views
mjbcswitzerland
Specialist V

Jerry

V1.4.7 is the present relase. V1.4.8 is in preparation including support of additional Freescale boards (the ones in the header notes plus more for KV, KM and KW families too). The serial loader has KBOOT compatibility in parallel with other feratures (SD card, Ethernet etc.) but allows things like KBOOT HID and USB-MSD to be used in a composite device.

V1.4.8 has a lot of new application functionality (A selection being: flexible composite USB devices with multiple CDC mixed with various other classes; low power radio networking, multiple port Ethernet using SPI Ethernet devices, new TCP/IP features including SSDP, multiple FTP servers and multiple TELNET client support, automatic very low power mode switching, multi-disk FAT in various internal and external Flash media with complete USB-MSD interface support to all).

V1.4.8 and its features are presently being used in various pilot projects.

A general release will probably be made in the next few weeks.

The serial loader files are HW independent and will operate on any of the supported board, including FRDM-K20D50M - the (V1.4.7) board list is at µTasker Kinetis support

Regards

Mark

0 Kudos
1,614 Views
jerryfavero
Contributor I

Hi Mark,

Wonderful work, tested on WIN8.

Best regards

Jerry

0 Kudos
1,614 Views
jerryfavero
Contributor I

HI Mark,

I have changed a pin to force in boot mode (PTA16)  and the blink-led to PTC10.

Setting a few ports , a application code works fine , file KL25Z00.hex (file .bin used to boot).

Setting other port  without adding code source , after bootloading the application do not work.

Thanks

0 Kudos
1,614 Views
mjbcswitzerland
Specialist V

Hi Jerry

The .rar is damaged and the project can only be partly extracted.

Could you post the binary that works and the one that doesn't work?

I don't think that the boot loader operation will generally effect the application so are you sure that the application works correctly when operating by itself?

See appendix B of the following document for a complete list of compatibility points to be considered: http://www.utasker.com/docs/uTasker/uTaskerSerialLoader.PDF

Regards

Mark

Kinetis: µTasker Kinetis support

KL25: µTasker Kinetis FRDM-KL25Z support / http://www.utasker.com/kinetis/TWR-KL25Z48M.html

0 Kudos