Wednesday, December 13th 2017, 10:23am UTC+1

You are not logged in.

  • Login
  • Register

Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

satyajg

Beginner

Date of registration: Oct 20th 2010

Posts: 4

1

Tuesday, April 12th 2011, 12:24pm

USBH Demo code from Segger not working for EA LPC2478 board. Help needed

We are facing some trouble while evaluating the USB host application for emUSB. When we connect the USB we get following error

void FS_X_Panic(int ErrorCode) {
FS_USE_PARA(ErrorCode);
while (1);
}
With Errorcode "1".



We are trying to use the following application "USB_MSD_FS_WriteOnDisconnect.c"



This error come once it executes the following piece of code

=================================================================================


/*********************************************************************
*
* _AddMSD
*
* Function description
* Add mass storage device to USB stack
*
* Notes:
* (1) - This examples uses the internal driver of the file system.
* The module intializes the low-level part of the file system if necessary.
* If FS_Init() was not previously called, none of the high level functions
* such as FS_FOpen, FS_Write etc will work.
* Only functions that are driver related will be called.
* Initialization, sector read/write, retrieve device information.
* The members of the DriverData are used as follows:
* DriverData.pStart = VOLUME_NAME such as "nand:", "mmc:1:".
* DriverData.NumSectors = Number of sectors to be used - 0 means auto-detect.
* DriverData.StartSector = The first sector that shall be used.
* DriverData.SectorSize will not be used.
*/
static void _AddMSD(void) {
static U8 _abOutBuffer[USB_MAX_PACKET_SIZE];
USB_MSD_INIT_DATA InitData;
USB_MSD_INST_DATA InstData;

InitData.EPIn = USB_AddEP(1, USB_TRANSFER_TYPE_BULK, USB_MAX_PACKET_SIZE, NULL, 0);
InitData.EPOut = USB_AddEP(0, USB_TRANSFER_TYPE_BULK, USB_MAX_PACKET_SIZE, _abOutBuffer, USB_MAX_PACKET_SIZE);
USB_MSD_Add(&InitData);
//
// Add logical unit 0: Use default device.
//
memset(&InstData, 0, sizeof(InstData));
InstData.pAPI = &USB_MSD_StorageByName;
InstData.DriverData.pStart = "";
USB_MSD_AddUnit(&InstData);
}

==================================================================================



the panic occurs as last line of the above piece of code i.e.



USB_MSD_AddUnit(&InstData);




Though the same USB works for other FAT demo code from EA LPC 2478 board vendor but the Segger doesn't work.

Can you explain what might be going wrong



Regards,

Satyajit

SEGGER - Souhail

Super Moderator

Date of registration: Nov 15th 2007

Posts: 19

2

Wednesday, April 13th 2011, 4:10pm

Dear Satyajit,

you are using the wrong sample. The correct one to use is OS_USBH_MSD.c.
Additionally you may need to change your current FS_Config_*.c config file with FS_USBH_MSDConfig.c.
With these changes emUSB Host + emFile should work fine.

Some background info:
All sample files that begin with USB_* are emUSB Device samples.
All files with the Prefix OS_USBH_ are intended to be used emUSB Host.
The reason why this samples are called OS_USBH_* is that for emUSB Host an RTOS (embOS) is needed
otherwise the stack won't run.

Please let us know whether you need further help.

Regards,

Souhail