Reading works but as soon as i try to write some data to the device, it freezes up. I get the following message on the syslog
kernel: usb 3-10: reset full-speed USB device number 20 using xhci_hcd
I reported this MBED USB bug on the KL25 in 2013.
I don't know that it has ever been fixed, as I started avoiding anything MBED related after seeing such a fundamental problem in the code.
Bob
I never understood mbed.
Essentially it is a pretty web site with a hand-out of resources (and a weird on-line compiler) which seems to be attracting some like moths to a light. Then it gets very half-hearted - I subscribed to one of its groups and get about 1..3 new topics a month and don't remember seeing anyone respond to anything.
Apart from mbedTLS (which ARM bought and has enthusiasts working on it still) much of the rest seems to be half-broken.
And I really don't understand people (especially professionals) who try to base work on it - the response from them tends to be (after spending way too long getting a development half working) that they have invested so much now that they can't change. I see so many examples of all the free giveaway stuff costing the industry millions at the end of the day, but it seems the present day mentality "If we use "that chip" we get a "free" tool chain and can "save another $25.-" by not investing in a debugger and patching a development board to ours. And of course they give us all working code so we "haven't anything else to do"." - and the developers love it because they get months of interesting over-time to patch it all together...
Regards
Mark
I agree. My industry requires that I inspect all code in my project, after all it is my liability that is on the line not MBED or anyone else's.
I came across that bug while looking for USB examples, so signed up for MBED just to report the bug.
My projects need to be supported for a minim of five years and a few for 25 years. such as infrastructure level stuff.
Writing software for a sewage treatment plant is not always pleasant (site visit), however consider what is more important, that when you flush it goes away, or that the fancy GUI based online compiler went off line 18 years ago someone thought was a good idea to use because it was 'free'?
Sad to see that some of the bootloaders are now MBED based.
Even sadder is the bad programming habits such projects engender.
Hi
Do the mbed demos support writing (often such demos show only basic operations like enumeration which need to be adapted/extended according to the storage medium)? Where do the writes go to - SRAM, Flash, SD card?
For mbed questions it may be best to use the arm mbed forum since I don't think that mbed is used much by the Kinetis microcontrollers community.
If you have a FRDM-KL25Z try loading some of the binary files here to check that the board is operating (it has USB-MSD references that will write to Flash or do FAT emulation - plus USB-MSD loaders):
http://www.utasker.com/kinetis/FRDM-KL25Z.html
Regards
Mark
Kinetis: http://www.utasker.com/kinetis.html
Kinetis KL25, KL26, KL27, KL28:
- http://http://www.utasker.com/kinetis/FRDM-KL25Z.html
- http://www.utasker.com/kinetis/TWR-KL25Z48M.html
- http://www.utasker.com/kinetis/FRDM-KL26Z.html
- http://www.utasker.com/kinetis/TEENSY_LC.html
- http://www.utasker.com/kinetis/FRDM-KL27Z.html
- http://www.utasker.com/kinetis/Capuccino-KL27.html
- http://www.utasker.com/kinetis/FRDM-KL28Z.html
USB: http://www.utasker.com/docs/uTasker/USB_User_Guide.PDF
FAT: http://www.utasker.com/docs/uTasker/uTasker_utFAT.PDF
FAT emulation: http://www.utasker.com/docs/uTasker/uTaskerEmulatedFAT.pdf
Free Open Source solution: https://github.com/uTasker/uTasker-Kinetis
Working project in 15 minutes video: https://youtu.be/K8ScSgpgQ6M
Professional Kinetis support, one-on-one training and complete fast-track project solutions: http://www.utasker.com/support.html
>Do the mbed demos support writing
Yes, the write does indeed work sometimes but freezes up every now and then.
>Where do the writes go to - SRAM, Flash, SD card
SRAM
>If you have a FRDM-KL25Z try loading some of the binary files here to check that the board is operating
I tried that one out and it works, so definitely a bug on the mbed side.
Hi ghest253456,
Maybe you can try our USB 4.1.1 stack, there has the KL25 MSD example for your reference.
Besides, this link may useful to you:
usb 4.1.1 MSD example for KL25Z - Disk does not format - No drive data
KL25 SRAM is small, if you use the SRAM as the buffer, we suggest you choose the larger SRAM chip.
Wish it helps you!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
uint_8 USB_DCI_Init (
uint_8 controller_ID, /* [IN] Controller ID */
uint_8 bVregEn /* Enables or disables internal regulator */
)
{
#if !HIGH_SPEED_DEVICE
/* Select System Clock and Disable Weak Pull Downs */
USB0_USBCTRL = 0x00;
/* save the controller_ID for future use */
g_dci_controller_Id = controller_ID;
/* Clear bdt elem structure */
Clear_Mem((uint_8_ptr)(g_bdt_elem),
(sizeof(BDT_ELEM) * (MAX_BDT_INDEX >> 1)),
(uint_8)UNINITIALISED_VAL);
g_bdtmap = (BDTMAP *)((uint_32)g_Mem);
/* Clear Memory for BDT and buffer Data */
Clear_Mem((uint_8_ptr)g_bdtmap,(uint_32) BYTES_1024, (uint_8)0);
I tried using it but it hits a hardfault on line `USB0_USBCTRL = 0x00;`
Is the USB Module Clock enabled?
Not being enabled would be the typical reason for a hard-fault like that.
Not having the BDT aligned on 512 byte boundary would be an other (M0+ parts like the KL25 hard-fault on some non-aligned items):
static BDT bdt[( ENDPOINTS_USED * BDT_PER_EP ) ] __attribute__( ( __aligned__( 512U ) ) );
>Is the USB Module Clock enabled?
I was trying to manually compile it using my own Makefile. It looks like i missed some initialization code. I could it get it to work with code warrior, but it has more reset issues than Mbed see https://community.nxp.com/message/970045?commentID=970045&et=watches.email.thread#comment-971126
So i got it to work with the help of code warrior, but it still has the same problems as mbed, but this time its worser, even read causes reset
kernel: usb 3-10: reset full-speed USB device number 11 using xhci_hcd kernel: usb 3-10: device descriptor read/64, error -71 kernel: usb 3-10: device descriptor read/64, error -71 kernel: usb 3-10: reset full-speed USB device number 11 using xhci_hcd kernel: usb 3-10: device descriptor read/64, error -71 kernel: usb 3-10: device descriptor read/64, error -71 kernel: usb 3-10: reset full-speed USB device number 11 using xhci_hcd kernel: usb 3-10: Device not responding to setup address. kernel: usb 3-10: Device not responding to setup address. kernel: usb 3-10: device not accepting address 11, error -71 kernel: usb 3-10: reset full-speed USB device number 11 using xhci_hcd kernel: usb 3-10: Device not responding to setup address. kernel: usb 3-10: Device not responding to setup address. kernel: usb 3-10: device not accepting address 11, error -71 kernel: usb 3-10: USB disconnect, device number 11 kernel: sd 8:0:0:0: [sdc] tag#0 FAILED Result: hostbyte=DID_NO_CONNECT driverbyte=DRIVER_OK kernel: sd 8:0:0:0: [sdc] tag#0 CDB: Write(10) 2a 00 00 00 00 00 00 00 02 00 kernel: blk_update_request: I/O error, dev sdc, sector 0 kernel: Buffer I/O error on dev sdc, logical block 0, lost async page write kernel: Buffer I/O error on dev sdc, logical block 1, lost async page write kernel: Buffer I/O error on dev sdc, logical block 2, lost async page write kernel: Buffer I/O error on dev sdc, logical block 3, lost async page write kernel: Buffer I/O error on dev sdc, logical block 4, lost async page write kernel: usb 3-10: new full-speed USB device number 12 using xhci_hcd kernel: usb 3-10: device descriptor read/64, error -71 kernel: usb 3-10: device descriptor read/64, error -71 kernel: usb 3-10: new full-speed USB device number 13 using xhci_hcd kernel: usb 3-10: device descriptor read/64, error -71 kernel: usb 3-10: device descriptor read/64, error -71 kernel: usb 3-10: new full-speed USB device number 14 using xhci_hcd kernel: usb 3-10: Device not responding to setup address. kernel: usb 3-10: Device not responding to setup address. kernel: usb 3-10: device not accepting address 14, error -71 kernel: usb 3-10: new full-speed USB device number 15 using xhci_hcd kernel: usb 3-10: Device not responding to setup address. kernel: usb 3-10: Device not responding to setup address. systemd-udevd[4110]: inotify_add_watch(9, /dev/sdc, 10) failed: No such file or directory kernel: usb 3-10: device not accepting address 15, error -71 kernel: usb usb3-port10: unable to enumerate USB device
Guest253456
If you want actual working USB for all Kinetis parts (including your KL25) just download the (FREE FREE FREE FREE FREE FREE FREE) solution from the link that I gave you a week ago. You have already verified that it operates on your board.....
Regards
Mark