2013-12-25 04:34 AM
Hello everyone,
I have a 'leaf maple' ARM board which I am trying to get the USB peripheral functioning using only ASM coding. I am fairly confident with ASM in general but only have a few months experience with 32bit ARM MCU's. I don't have any experience with USB so this was going to be a good little project to get familiar with the hardware. So far, I have all the clocks initialised and running at the speeds suggested in the datasheet, the USB interrupts are set and running fine. Upon the hardware requesting a reset, a USB reset is initiated, the hardware then calling 'SOF' interrupts. From what i've read in the USB standard, the host is requesting information or providing an address however I cant find where the USB hardware is dumping its data. I've read and re-read the datasheet, setting the Base address to 0x0000 which should (from what the datasheet suggests) point the hardware to 0x40006000 to find the endpoint buffer configuration. Here starts the problem. I cant write to this area. I thought this could be a problem with APB1 configuration but can't see anything wrong. I loaded the HID demo code and the hardware enumerates in windows fine. During debugging with the demo code loaded, the address from 0x40006000 are all set to 0x00's. The endpoint configuration is clearly not there, nor the buffered data. It seems the buffered data appears around the start of the SRAM, 0x20000000 but I cant see where the init code is pointing to that address. So my first question is: Where does the STM32F103RB store its configuration data? I'm sure it is something simple that I have overlooked, but trying to debug and compare with the demo code - not written in ASM has wasted around a week, and i've gotten nowhere!!! Frustrating! Any advice would be welcome. I've scoured the forums however most posts are related to the demo code, which is working fine. PLEASE HELP! -Ben UPDATE! Looks like Keil cant view the contents of the USB/CAN buffer area. I added a routine to the demo code that dumps the 512bytes from 0x40006000 to 0x20000000 and there it all was! Finally a way ahead! Sure would be nice if I could see whats going on in that area... #usb #usb-stm32 #usb-hid-boot-enumeration2014-01-06 09:41 AM
Hi
'' I am trying to get the USB peripheral functioning using only ASM coding.'' You brave soul! ''So my first question is: Where does the STM32F103RB store its configuration data?'' I am only familiar with the USB OTG driver. This driver stored all the configurations in header files - so they are in Flash/ROM '' I cant find where the USB hardware is dumping its data.'' The USB driver provided by ST is a complex multi-layered driver with almost all the work done by Interrupt Service routines (ISRs). The layers are something like - USB device/Host USB protocol USB hardware I am not sure what you mean by '' hardware is dumping its data'' The lower layers are picking the data from the registers or memory dump area (memory dump area is statically allocated in the driver, just some RAM somewhere which must then be told to the hardware via registers. I have not dug too deeply into the USB driver code but I would guess that it is doing some DMA) The upper layers are take data out of static memory dumps and moving them to other static memory dumps (this is what I can remember from memory - it has been months since I did the work).2015-02-08 04:09 PM
Hi,
I've re-visited this project and have an almost working USB interface. I've decided to start with something simple so I've used descriptors and interface info from a known working USB optical mouse currently attached to my system. After attaching, my OS detects the device, displays its name and installs the default HID drivers. It then reports 'Failed to start' I've attached a dump of the USB bus as seen from the hardware level. It appears that polling of the device ceases after 'Set_Idle' is sent. I also noticed that the device has been set to 'boot' mode and doesn't attempt to read the HID descriptor. Info on boot mode is scarce, some documents suggesting reports are not sent in the usual way and the device initiates the transfer? Is this why my interface is stopping? Is the host expecting the device to transfer packets without an IN request? Can this be done with STM32F103 hardware? Or is there something obvious with my USB/HID reports preventing correct enumeration? I've compared byte for byte the mouse this data was taken from and cant see a difference in the enumeration sequence. What am I missing? Regards, Ben ________________ Attachments : USB_HID.txt : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0sK&d=%2Fa%2F0X0000000bet%2FEIF8y61pwyvqsHU9MvbKNOFvHDGoEZViOZnwGjTM9tk&asPdf=false2015-02-09 05:39 AM
Hi Ben,
bDescriptorType field of your ''HID descriptor'' is wrong. Your ''HID descriptor'' assigns 0x01 to this field, but it should be 0x22 (Report Descriptor)HID descriptor
09 bLength
21 bDescriptorType
11 01 bcdHID
00 bCountryCode
01 bNumDescriptors
01 bDescriptorType <---- 0x22
34 00 wDescriptorLength
I believe it should be the reason why the OS wouldn't request Report descriptor, just before Set_Idle request.
> I also noticed that the device has been set to 'boot' mode
???
It's your misunderstanding.
Bus reset makes every HID device drop into ''Report'' (not Boot) protocol.
To switch the HID device into ''Boot'' protocol, the host should explicitly send Set_Protocol( Boot ) request to the device.
In your trace, no Set_Protocol( Boot ) appears after the initial bus reset.
And then, your HID device is still kept in ''Report'' protocol.
Tsuneo
2015-02-11 10:13 PM
Hi Tsuneo,
Thanks for the reply, and you were spot on. Changing the Report Descriptor field got the device enumerated and passing data. It also gave me the chance to tidy up some of my code and optimise my state machine. I also thought data was passed only at SOF which I've learnt is not the case. I've just finished a NES Controller to USB Gamepad bridge and I'm about to begin coding a Mass Storage device. The SCSI command set looks interesting! Regards, Ben2015-05-02 03:26 AM
2015-06-03 05:14 PM
Hi KJ,
The code was finished a while ago, successfully enumerates on all systems except Windows 8.1 So now I'm trying to hunt down that fault. The device appears but I'm told access to it results in 'please insert media' or something along those lines. In the process of installing Win8.1 on a laptop so I can debug it. Knowing what I know now, I'm thinking of a complete re-write in particular the state machine. Are you attempting something similar?2015-06-24 10:39 PM
hello benn, i am new to 32 bit. just now learning to work on usb using the stm USB device library files. is there any link for your USB assembly language coding?. completed controling the communication, but still long way to go.