FridgeFreezer

CMX USB stack on MCF52259 - stuck in loop

Discussion created by FridgeFreezer on Oct 5, 2011
Latest reply on Nov 10, 2011 by Alexander Achleitner

I'm now so fed up with this I'll be glad when someone points out the schoolboy error I've undoubtedly made somewhere...

 

I am using the M52259EVB to (try to) develop a USB-Host mode device which will use a USB mouse/joystick (HID) as input.

 

So, given Freescale's bold claims about the USB-OTG integration in these devices, free RTOS & standalone CMX software stack, a quick-start guide for the EVB & DEMO boards and 84-page appnote, I installed the package that comes bundled with the EVB and got to work... which is where the trouble started.

 

First off, the package was written for the 52223, and despite assurances in the appnote about being fine with the 5225x, the project is completely broken. It took me quite some time messing around before I could even get the BDM connection to work because the .mcp contained all sorts of weird settings (target processor set to 5206e, endianness set incorrectly, etc.!) and used seemingly non-working .cfg/.mem files for the BDM connection. This is supposed to be plug-and-play for the M52259EVB / M52259DEMO boards which have the BDM built in.

 

Then I hit the problem of random crashes during initialisation - which it turns out was due to me using CW7.2, so I then had to go through the various _lo.s files and correct the low-level assembler routines to suit the new compiler.

 

Having done that I finally had some code I could compile, flash & run on the EVB - which then immediately gets stuck in an infinite loop (why does all code from Freescale & their associates include these?)

 

Having spent the best part of 2 days now searching & reading & downloading & trying several different versions of the CMX stack (as well as reading bad things about Freescale's other "PHDC" stack) it seems a lot of people hit the same problems, as very patiently documented here:

http://www.nadler.com/embedded/mcf51jm128_eval_problems.pdf

 

I'm seeing the code lockup in the same place as most other people, in the usb_host_start_transaction() function when trying to find a device (anything at all) on the bus:

    /* Wait for transaction end or an error occurs */    while((MCF_USB_INT_STAT & (MCF_USB_INT_STAT_TOK_DNE | MCF_USB_INT_STAT_STALL | MCF_USB_INT_STAT_ERROR)) ==0)    {      // <<< Code just sits in this while() loop >>
       if (MCF_USB_INT_STAT & MCF_USB_INT_STAT_USB_RST)      {        evt_disconnect();        tr_error=tre_disconnected;        return((hcc_u16)-1u);      }    }

 

1: https://community.freescale.com/message/58802#58802

 - No solution found/posted

2: https://community.freescale.com/message/48864#48864

 - I've tried the suggestions in this thread of setting the RETRY_DIS bit, but the code behaves exactly the same.

3: https://community.freescale.com/message/78726#78726

- The updated "working" CMX stack linked in that thread has exactly the same problem.

4: https://community.freescale.com/message/67885#67885

- The updated code mentioned near the end does not feature in the CMX host-mode code as far as I can see, and I can't see any that looks similar.

5: https://community.freescale.com/message/45364#45364

- I have tried making the change documented in this thread (my_device.eps[ep].tgl_tx=1; becomes my_device.eps[ep].tgl_tx=BDT_CTL_DATA;) but it makes no difference.

 

I have also been over the various jumpers on the EVB and set them correctly, as far as I can tell - they're not actually documented in any detail (for example, do I need to set USB_VBUSE to pull up, pull down, or leave it for the micro to control?).

 

I'm sure something has gotten lost/messed up in the transition from 52223->52259 and CW6.3->7.1->7.2.

 

Has anyone had the hid_host example running on en EVB or DEMO board?

Outcomes