FRDM-K20D50M uTasker USB Bootloader application program

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

FRDM-K20D50M uTasker USB Bootloader application program

Jump to solution
1,434 Views
jerryfavero
Contributor I

Good afternoon,

I'm testing the FRDM-K20D50M board. I flash it with USB Bootloader uTaskerSerialLoader_FRDM-K20D50M.S19.

I made a little code for blinking a led with Processor Expert:

//................................................

while(1)

{

    LEDRED_ClrVal(NULL);

    WAIT1_Waitms(250);

    LEDRED_SetVal(NULL);

    WAIT1_Waitms(250);   

}

//................................................

The README file says :

"If you load your own application make sure that it has its reset code is linked to be at 0x8080. Interrupt vectors should be run from RAM or set to a

location in the code (not left at 0x00000000)" .

I have set the CPU component as in figure :

16353_16353.jpgImmagine1.jpg

After the drag and drop of a program file the board does nothing, the led don't blink.

The Output File Format is ".SREC" .

A normal program with "Default memory for Interrupts"=INTERNAL FLASH, and address=0x00000000 works fine with blinking led.

There is something wrong. I attached the project.

Thanks to whoever can help me.

Jerry

Original Attachment has been moved to: PROVA-FRDM-K20.rar

0 Kudos
1 Solution
1,019 Views
mjbcswitzerland
Specialist V

Jerry

MEMORY {

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

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

  m_data         (RW) : ORIGIN= 0x1FFFE000, LENGTH = 0x00002000

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

}

These should be about right. However m_cfmprotrom() is not used (the boot loader defines the flash configuration and the application can't).

m_interrupts() only needs to be 0x08 in length if the reset vector is there - with 0xf8 all interrupt vectors are probably being located. If this is done the application needs to set the Cortex VECTOR_TABLE_OFFSET_REG to point to 0x8080 rather than 0x00000000.

Regards

Mark

View solution in original post

0 Kudos
7 Replies
1,019 Views
mjbcswitzerland
Specialist V

Hi

If you are using the USB-MSD (drag-and-drop) you need to drag and drop a binary file and not an SREC.

In addition, at the address 0x00008080 you need to have the reset vector that would normally be at 0x00000000. Looking in your SREC file this is missing.

Compare your SREC (or binary) with the reference - in the reference it starts with

S30D00008080FC7F002049B100005D

which means that there is the value 0x20007ffc at 0x00008080 and 0x0000b149 at 0x00008084.

0x20007ffc is the initial stack point (it will be loaded to the SP when jumping to the application) and 0x0000b149 is the initial program counter - it is where the application will be started. [this is the standard reset vector but shifted to a new location]

In your file I see S3150000808000BF00BF00BF7047002000BF00BF00BF99

which would be a SP of 0xbf00bf00 and PC of 0x4770bf00 which looks to be other program code or const data.

To summarise:

- SREC can be loaded by the serial interface but USB-MSD uses a binary instead.

- Your program doesn't have its reset vectors at the start location and so this needs first to be fixed. It is easy to monitor and see when it is correct (PC will match the start address of the program in the map file).

Regards

Mark

0 Kudos
1,019 Views
jerryfavero
Contributor I

Hi Mark,

it's possible to do it with Processor Expert , or I have to do it  manualy. I'm not expert with frescale microcontrollers.

I did some tests but the bin file has size 524K...

If you can give an example, maybe starting from the project that I have attached would be great, so as to understand.


Thanks

Jerry

0 Kudos
1,019 Views
mjbcswitzerland
Specialist V

Hi Jerry

Unfortunately I don't use PE so can't give any details apart from the fact that I understand that you can always add your own configurations (or disabled some automatic ones).

There are a number of MQX users working with the uTasker serial loaders and these didn't have any difficulties with a suitable configuration, although I don't know whether these projects were using PE or not.

It may be best to ask in the PE forum: Processor Expert Software

You could also use the uTasker project directy since it doesn't need any PE generation steps and has targets suitable for the serial loader (and FRDM-K20D50). You can then simulate the K20 and the FRDM board to make fast application development progress and compare things with the PE generated code (to see what needs to be adjusted) in case you still want to go back to PE later.

Regards

Mark

1,019 Views
jerryfavero
Contributor I

Hi Mark,

it's possible to disable "Generate Linker file" in PE, thus to edit it manually.

Below some lines of a "normal application"linker file (attached file).

/* Generate a link error if heap and stack don't fit into RAM */

__heap_size = 0x00;                    /* required amount of heap  */

__stack_size = 0x0400;                 /* required amount of stack */

MEMORY {

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

  m_text           (RX) : ORIGIN = 0x00000410,  LENGTH = 0x0001FBF0

  m_data         (RW) : ORIGIN= 0x1FFFE000, LENGTH = 0x00002000

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

}

//************************************************************

May you help me to edit this file, to adapt for a utasker boot (the board is FRDM-K20D50M).

Thanks

0 Kudos
1,020 Views
mjbcswitzerland
Specialist V

Jerry

MEMORY {

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

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

  m_data         (RW) : ORIGIN= 0x1FFFE000, LENGTH = 0x00002000

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

}

These should be about right. However m_cfmprotrom() is not used (the boot loader defines the flash configuration and the application can't).

m_interrupts() only needs to be 0x08 in length if the reset vector is there - with 0xf8 all interrupt vectors are probably being located. If this is done the application needs to set the Cortex VECTOR_TABLE_OFFSET_REG to point to 0x8080 rather than 0x00000000.

Regards

Mark

0 Kudos
1,019 Views
jerryfavero
Contributor I

Hi Mark,

now it works fine, also with timers interrupts.

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

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 = 0x1FFFE000, LENGTH  = 0x00002000

}


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*) (0x1FFFE000 );

  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)(0x1FFFE000);

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

Using only a MSD boot ,esist an easily mode to enlarge the application program (over 70K as writen in reademe file)  ?

Thanks



0 Kudos
1,019 Views
mjbcswitzerland
Specialist V

Jerry

There are 2 defines in Loader.h:

#define UTASKER_APP_START (32 * 1024)                    // application starts at this address
#define UTASKER_APP_END  

(unsigned char *)(UTASKER_APP_START + (70 * 1024)) // end of application space - after maximum application size

By adjusting these you can control the start location and the size of application that is accepted.

Depending on how large your boot loader configuration is, the start address just needs to be at the start of the flash sector following the last one that it uses.

Regards

Mark