USB msd mfs generic host in Processors expert

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

USB msd mfs generic host in Processors expert

Jump to solution
2,991 Views
giuseppez
Contributor II

Hi,

Is there anybody that had managed the USB Host example MSD_MFS_GENERIC_HOST using the Processors expert?

I can compile the example that the Freescale give with the USB stack but I cannot convert that project to use the processor expert inorder to configure and use the CPU and other device with PE.

I extract the project from the standard position and all the relative files (in the example them are only linked) and this work, but when I execute the procedure to insert the ProcessorExpert option I receive o lot of error.

I fix all but the only thing that I don't understand is the _usb_khci_atom_tr() function that is in the khci_kinetis.c files.

In this file there also the variable endpoint_stalled that is used in the msd_fat_demo.c file, and I don't know how to manage it.

Thank you for your help

Giuseppe

1 Solution
1,530 Views
TudorS_
NXP Employee
NXP Employee

Hi giuseppez.

The MSD_MFS_GENERIC_HOST example, more commonly referred to as the FAT file system demo, is not yet supported on top of the Processor Expert USB host stack.


The main reason is the different memory allocation model used for the Processor Expert USB host stack (needed to accommodate the coexistence with MQX Lite) and the memory model currently in use for the MSD_MFS_GENERIC_HOST application.


There are plans to make it compatible in the future.

Best regards,

Tudor

View solution in original post

0 Kudos
13 Replies
1,530 Views
p_vagnoni
Contributor III

Hello giuseppez,

I had same problem last november-december and now finally i found a solution. My personal solution is:

-) copy all files of usb management inside your project;

-) add the USB_LDD component on your processor Expert and generate the code.

-) in the USB.c file generated by PE you have to change the Interrupt routine PE_ISR(USB1_USB_Interrupt)

with:

void USB_ISR(void);

PE_ISR(USB1_USB_Interrupt)
{
USB_ISR();
}

the routine USB_ISR() is defined into the file khci_kinetis.c (i am working with Kinetis K60).

You have only to "correct" the ISR Routine every time you use PE Generation files.

Hope this help you.

Paolo

1,530 Views
giuseppez
Contributor II

Thank you Paolo,

I follow your same steps but I'm stopped at the USB_LDD import.

I tried to import the complete USB_STACK module and then erase the duplicated files.

But invain.

By now I try your solution and I'm courius to see if it works.

Thank you for your attention and help

Regards

Giuseppe

0 Kudos
1,530 Views
p_vagnoni
Contributor III

Hi giuseppez,

I know what means this kind of problem... If you want I can attach a simple project with USB_LDD configuration and files to work with this application.(similar to the example but with files and Processor expert.

I imagine you need to work with files on the USB Device connected to your board.

Let me know, mind only that I am worknig on my board with Kinetis K60.

Have a nice day.

Paolo

1,530 Views
karlchang
Contributor I

HI p.vagnoni

Can you get me your  example for working with Kinetis k60

let me reference.

thank you.

0 Kudos
1,530 Views
giuseppez
Contributor II

Hi paolo,

I already have made a project with the effective files and not the link to them.

I have only to try the USB_LDD import and the interrupt corrections.

But if you can put your project in attach it would be usefull for reference or for other peoples with this kind of problem.

Thank you

Regards

Giuseppe

0 Kudos
1,530 Views
p_vagnoni
Contributor III

Hi giuseppez,

attached find my demo of USB and PE.

About the pdf file with instruction don't care about point 9 (the right lcf file will be generated by the Processor Expert).

In the zip file you find :

-) "USB and PE.pef " is the file to import processor expert configuration.

-) USB And PE Folder where you can find the folders to copy inside your project.

Hope it helps.

Enjoy yourself!

Paolo

1,530 Views
giuseppez
Contributor II

Hi Paolo,

finally I test your project.

I follow exactly your indication and I compile all for my TWR-K40X256 board. The only thing that I don't understand is when you say "copy the lcf file" at point 9 of your document. Can you explain me what you mean?

At this point my problem is that when I start the program, whe the function _usb_host_init() is called, the cpu generate an exception and stop into the pe_isr(cpu_interrupt){ pe_debughalt();} function.

I can see the the last function that the program execute is a memset function in the usb_host_state_struct_ptr structure that is allocate at 0x1FFF89F4.

The only difference with the Freescale example code is that this struct is allocated at 0x1FFFA398.

Do you have any suggest for me?

Regards

Giuseppe

0 Kudos
1,530 Views
p_vagnoni
Contributor III

Hi giusseppez,

I forgot to insert the lcf file (LinkerConfigurationFile).You find the content of my lcf file of my running example. Probably the problem you have is caused by the stack (the USB need big stack...).

The lcf file is inside your project folder:

{PrjFolder}\Project_Settings\Linker_Files\ProcessorExpert.lcf

Try this and let me know.

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

## ###################################################################
####
####     THIS COMPONENT MODULE IS GENERATED BY THE TOOL. DO NOT MODIFY IT.
####                                               
####     Filename  : ProcessorExpert.lcf               
####                                               
####     Project   : ProcessorExpert                  
####                                               
####     Processor : MK60DN512ZVLQ10                   
####                                               
####     Compiler  : CodeWarrior ARM C Compiler                   
####                                               
####     Date/Time : 2013-01-25, 15:35, # CodeGen: 5                    
####                                               
####     Abstract  :                               
####                                               
####     This file is used by the linker. It describes files to be linked,
####     memory ranges, stack size, etc. For detailed description about linker
####     command files see compiler documentation. This file is generated by default.
####     You can switch off generation by setting the property "Generate linker file = no"
####     in the "Build options" tab of the CPU component and then modify this file as needed.
####
####                                               
#### ###################################################################

KEEP_SECTION { .vectortable }
KEEP_SECTION { .cfmconfig }

MEMORY {
  m_interrupts (RX) : ORIGIN = 0x00000000, LENGTH = 0x000001E0
  m_text      (RX) : ORIGIN = 0x00000410, LENGTH = 0x0007FBF0
  m_data      (RW) : ORIGIN = 0x1FFF0000, LENGTH = 0x00010000
  m_data_20000000 (RW) : ORIGIN = 0x20000000, LENGTH = 0x00010000
  m_cfmprotrom  (RX) : ORIGIN = 0x00000400, LENGTH = 0x00000010
}

SECTIONS {
  ## Heap and Stack sizes definition
  __heap_size = 0x1000;
  ___stack_size = 0x1000;

  .interrupts :
  {
    __vector_table = .;
    * (.vectortable)
    . = ALIGN (0x4);
  } > m_interrupts

  .cfmprotect :
  {
    *(.cfmconfig)
    . = ALIGN (0x4);
  } > m_cfmprotrom

  .text :
  {
    * (.text)
    . = ALIGN(0x4);
    * (.rodata)

    . = ALIGN(0x4);
    ___ROM_AT = .;
    ___DATA_ROM = .;
  } > m_text

  .data : AT(___ROM_AT)
  {
    ___DATA_RAM = .;
    * (.ARM.extab)
    . = ALIGN(0x4);
    __exception_table_start__ = .;
    EXCEPTION
    __exception_table_end__   = .;

    __sinit__ = .;
      STATICINIT

    ___DATA_START =.;
    * (.data)
    . = ALIGN (0x4);
    ## Additional data sections defined by components
    . = ALIGN (0x0200);
    * (.USB1_memory_section)
    ___DATA_END   =.;

    __SDATA_START =.;
    * (.sdata)
    . = ALIGN (0x4);
    __SDATA_END = .;

    __SDA_BASE = .;
    . = ALIGN(0x4);
  } > m_data

  ___m_data_20000000_ROMStart = ___ROM_AT + SIZEOF(.data);
  .m_data_20000000 : AT(___m_data_20000000_ROMStart)

  {
     . = ALIGN(4);
     ___m_data_20000000_RAMStart = .;
     *(.m_data_20000000) /* This is an User defined section */
     ___m_data_20000000_RAMEnd = .;
     . = ALIGN(4);
  } > m_data_20000000
  ___m_data_20000000_ROMSize = ___m_data_20000000_RAMEnd - ___m_data_20000000_RAMStart;

  .bss :
  {
    __START_SBSS = .;
    * (.sbss)
    *(SCOMMON)
    __END_SBSS = .;

    __START_BSS = .;
    * (.bss)
    * (COMMON)
    __END_BSS = .;
    . = ALIGN(0x4);
  } >> m_data


  ___HEAP_START = .;
  ___HEAP_END = ___HEAP_START + __heap_size;
  ___SP_END = ___HEAP_END;
  ___SP_INIT = ___SP_END + ___stack_size;

  __heap_addr = ___HEAP_START;
  __heap_size = ___HEAP_END -  ___HEAP_START;
  __SP_INIT = ___SP_INIT;

  _romp_at = ___ROM_AT + SIZEOF(.data) +SIZEOF(.m_data_20000000);
  .romp : AT(_romp_at)
  {
    __S_romp = _romp_at;
    WRITEW(___ROM_AT);
    WRITEW(ADDR(.data));
    WRITEW(SIZEOF(.data));
    WRITEW(___m_data_20000000_ROMStart);
    WRITEW(___m_data_20000000_RAMStart);
    WRITEW(___m_data_20000000_ROMSize);
    WRITEW(0);
    WRITEW(0);
    WRITEW(0);
  }
}

0 Kudos
1,530 Views
giuseppez
Contributor II

Hi,

I discovered that after the Paolo's suggestions, is necessary to increase the __heap_size from 0x0400 to 0x1000.

At this point the exception error disappears.

So into the .lcf file the follow rows:

__heap_size = 0x0400;

___stack_size = 0x0400;

has to becomes:

__heap_size = 0x1000;

___stack_size = 0x1000;


To do this in automatic mode without manually modify the .lcf file, you can:

1) Point to the CPU component

2) In component inspector select the "Build options" tab

3) Go to "Generate linker file"

4) Change Stack size from 400 to 1000

5) Change Heap size from 400 to 1000


Rebuil the project.

At this point all works fine in my TWR-K40X256 board.


Another thing that I've done is to set the file USB1.C as "read only" so the processor expert can't change it and erase my changes.


Now I can read a USB stick with the Freescale USB stack and the PE.

Enjoy it.


Regards

Giuseppe








Regards

Giuseppe



0 Kudos
1,530 Views
giuseppez
Contributor II

Thank you a lot.

Regards

Giuseppe

0 Kudos
1,530 Views
BlackNight
NXP Employee
NXP Employee

In case this is of interest: I managed to combine the Freescale USB stack with FatFs, Processor Expert and FreeRTOS. Not perfect yet, but might be a good starting point.

USB MSD Host for the Freedom Board | MCU on Eclipse

I only have it for the KL25Z, but if I find time I see how I can support other microcontrollers that way.

0 Kudos
1,531 Views
TudorS_
NXP Employee
NXP Employee

Hi giuseppez.

The MSD_MFS_GENERIC_HOST example, more commonly referred to as the FAT file system demo, is not yet supported on top of the Processor Expert USB host stack.


The main reason is the different memory allocation model used for the Processor Expert USB host stack (needed to accommodate the coexistence with MQX Lite) and the memory model currently in use for the MSD_MFS_GENERIC_HOST application.


There are plans to make it compatible in the future.

Best regards,

Tudor

0 Kudos
1,530 Views
marcinmarecki
Contributor II

Hi All,

I'm under bringing up the FATFS MSD HOST.

I based on official Freescale USB Stack v4.0.3 and FRDM-KL25Z eval board.

Now I can read control messages from USB MSD 80% with passed status and can read disk sectors with status error.

I want to check the USB transmition parametters.

I looking for who want to cooperate to bring up the USB MSD stack.

Regards,

Marcin Marecki

0 Kudos