k60 AN4368 bootloader port to k20, "ERROR......Unknown file type" problem?

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

k60 AN4368 bootloader port to k20, "ERROR......Unknown file type" problem?

Jump to solution
1,348 Views
rhana
Contributor III

Hello,

    I am porting the k60 bootloader code to the k20, based on AN4368. The code compiles. Most of the bootloader is working except the most important part; when it reads an image file from a USB stick (so USB is working, the flash drivers appear to be working, the bootloader code appears to be working.) The flash driver just starts to parse the file when it gives up.

The error we are getting in Hyper Terminal is  "ERROR......Unknown file type." The s-record file we are using is from another project for the k20 which has been renamed to image.s19 according to AN4368. But it appears the file is not being recognized as an s-record file from the debug message.

So it seems

1)  the s19 file is not the correct file type from what the debug messages are telling me

2) the flash driver for the "MK60N512VMD100" doesn't work with the k20 (I have been told it does.)

Thanks.

[I am using CodeWarrior 10.6, windows XP, and TWR-K20D72M]

------------------- Investigating further -------------------------

in Loader.c, forcing through the following code...(basically adding "filetype = S19_RECORD;" to force it into this file type, just adding that into the else statement)

        else

        {

#ifdef __DEBUG__

            printf("\n\r\t\tERROR......\n\rUnknown file type");

#endif

#if (!defined _MK_xxx_H_)

            asm("halt");

#endif

        } /* EndIf */

we arrive in the FlashLineS19() function. It appears to go through "formulate address" then "adjust word alignment" and finally concludes with "this is not a valid s-record file" here:

  if(S19FileDone)

{

       /* not a valid S19 file */

        printf("\n not a valid S19 file d.\n");//RH

       BootloaderStatus = BootloaderS19Error;

        return FLASH_IMAGE_ERROR;

}

0 Kudos
1 Solution
970 Views
rhana
Contributor III

Ok, it looks like the S-Record length was too long. After opening up the S-record file generated for the k20, each line was over 200 characters.

The S-Record length for the k60 file was much shorter, about 80 characters.

View solution in original post

0 Kudos
6 Replies
970 Views
rhana
Contributor III

Update:

In Loader.c in function GetSpair() , specifically in the section of the function below:

    if(upper == 0xFF)

    {

        /* Not a proper S19 file */

        S19FileDone = TRUE;

    } /* EndIf */

    upper = (uint_8)(upper << 4);

    ch=arr[point+1];

    lower= (uint_8)(GetHexValue(ch));

    if(lower == 0xFF)

    {

        /* Not a proper S19 file */

        S19FileDone = TRUE;

    } /* EndIf */

the conditions above are true, setting S19FileDone = TRUE;

This brings us back to the following code:

    length = GetSpair(Line,cur_point);

    if(S19FileDone)

    {

    printf("\n FlashLineS19() not a valid S19 file a.\n");//RH

        /* not a valid S19 file */

        BootloaderStatus = BootloaderS19Error;

        return FLASH_IMAGE_ERROR;

    } /* EndIf */

which returns a FLASH_IMAGE_ERROR from FlashLineS19(), this is passed back to FlashArrayS19(),

then to  the following in FlashApplication():

            /* S19 file found */

            result = FlashArrayS19(arr,length,line);    /* DES parse and flash array */

            break;

So it seems there is something wrong with the s19 file.

0 Kudos
970 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi Robert,

The AN4368 document mentioned below about application development:

To work with our bootloader system for MK60N512VMD100, the user application must be located at the flash memory area starting from the address 0x10000 (with or without printf supported). The linker file can be modified as below:

MEMORY

{

interrupts (RX) : ORIGIN = 0x00010000, LENGTH = 0x00000400

cfmprotrom (RX) : ORIGIN = 0x00010400, LENGTH = 0x0000010

code (RX) : ORIGIN = 0x00010410, LENGTH = 0x0006FBF0

}

And customer also could use the AN4368 provided s19 file do a test (although the application doesn't work), to check if the problem focus on the S19 format.
Wish it helps.
best regards
Ma Hui

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

0 Kudos
970 Views
rhana
Contributor III

Alright, it seems I am still having trouble modifying a k20 hid_mouse example, the k60 hid_mouse example is being read by the bootloader without error

(but i need a k20 application working with a k20 bootloader.)

I have modified the k20 hid_mouse *.lcf file to the following (The rest of the file remained the same)

I modified m_interrupts, m_cfmpromtrom, m_text..and added vectorram and its reference. Also in .interrupts the  __VECTOR_RAM was changed to __VECTOR_ROM

Have I made a mistake in the *.lcf file?

------------------------------------------------------------------------------------------------------------------------------------------------

MEMORY {

  m_interrupts  (RX) : ORIGIN = 0x00010000, LENGTH = 0x000001BC

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

  m_text        (RX) : ORIGIN = 0x00010810, LENGTH = 0x00040000-0x00000800

  vectorram     (RWX): ORIGIN = 0x1FFF0000,  LENGTH = 0x00000400

  m_data        (RW) : ORIGIN = 0x1FFF8000, LENGTH = 0x00010000-0x00000200

  m_bdt  (RW) : ORIGIN = 0x20007E00, LENGTH = 0x200 #SRAM Upper

}

KEEP_SECTION { .vectortable }

KEEP_SECTION { .cfmconfig }

KEEP_SECTION { .m_bdt }

SECTIONS {

  .interrupts :

  {

    ___VECTOR_ROM = .; #changed from ___VECTOR_RAM   

    * (.vectortable)

    . = ALIGN (0x4);

  } > m_interrupts

  .vectorram : #added this line

  {

  ___VECTOR_RAM = .;

  } > vectorram

corresponding changes were made to copy the vector table to ram, from line 840 in main_kinetis.c,

Why did I add this here? Because this is the only location in the project that refers to "SCB_VTOR"

/* Point the VTOR to the new copy of the vector table */

#if (defined(__CWCC__) || defined(__IAR_SYSTEMS_ICC__) || defined(__CC_ARM)|| (defined __arm__))

if(___VECTOR_RAM != ___VECTOR_ROM) //changed -RH
{
for(k=0; k<400;k++) //changed -RH
{
___VECTOR_RAM[k] = ___VECTOR_ROM[k]; //changed -RH
}
}
SCB_VTOR = (uint_32)___VECTOR_RAM;

Thanks.

0 Kudos
971 Views
rhana
Contributor III

Ok, it looks like the S-Record length was too long. After opening up the S-record file generated for the k20, each line was over 200 characters.

The S-Record length for the k60 file was much shorter, about 80 characters.

0 Kudos
970 Views
rhana
Contributor III

Hello,

So I was able to build the project in CW10.1 for the example and generate an S-Record from there. The Bootloader read the entire file and flashes (But of course this is for a k60 flashed onto a k20.) So I have verified what I needed to this way, thank you.

Thanks.

-Robert H.

0 Kudos
970 Views
rhana
Contributor III

Would it be possible to send me this file, the project does not build in CW 10.6 Thanks.

-RH

0 Kudos