STM32F103 HD usb problem

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
serdz
Posts: 11
Joined: Sat Mar 30, 2013 7:37 pm

STM32F103 HD usb problem

Post by serdz »

Hi,

I made custom board based on Olimex STM32-P103 design, but for some reason USB not working.
From PC side ubuntu dmesg:
[84976.982545] usb 3-2.3: new full-speed USB device number 87 using xhci_hcd
[84976.985592] usb 3-2.3: Device not responding to set address.
[84977.190591] usb 3-2.3: Device not responding to set address.
[84977.391920] usb 3-2.3: device not accepting address 87, error -71
[84977.465420] usb 3-2.3: new full-speed USB device number 88 using xhci_hcd
[84977.468475] usb 3-2.3: Device not responding to set address.
[84977.674499] usb 3-2.3: Device not responding to set address.
[84977.875768] usb 3-2.3: device not accepting address 88, error -71
[84977.949290] usb 3-2.3: new full-speed USB device number 89 using xhci_hcd
[84977.952337] usb 3-2.3: Device not responding to set address.
[84978.158278] usb 3-2.3: Device not responding to set address.
[84978.359618] usb 3-2.3: device not accepting address 89, error -71


I found that USB isr handler ( I guess Vector90 ) not executed at all.
Only difference from Olimex STM32-P103 ( USB related ) that I moved signal USB DISC from PC11 to PA9
and USB PRESENT from PC4 to PA10.

Any ideas what may affect to this?

This is my board.h file:

Code: Select all

#ifndef _BOARD_H_
#define _BOARD_H_

/*
 * Setup for the SAM reader board.
 */

/*
 * Board identifier.
 */
#define BOARD_SAM_READER
#define BOARD_NAME              "SAM reader"

/*
 * Board frequencies.
 */
#define STM32_LSECLK            32768
#define STM32_HSECLK            8000000

/*
 * MCU type, supported types are defined in ./os/hal/platforms/hal_lld.h.
 */
#define STM32F10X_HD

/*
 * IO pins assignments.
 */
#define GPIOA_USB_P             10
#define GPIOA_USB_DISC          9

#define GPIOB_LED_1              0
#define GPIOB_LED_2              1


/*
 * I/O ports initial setup, this configuration is established soon after reset
 * in the initialization code.
 *
 * The digits have the following meaning:
 *   0 - Analog input.
 *   1 - Push Pull output 10MHz.
 *   2 - Push Pull output 2MHz.
 *   3 - Push Pull output 50MHz.
 *   4 - Digital input.
 *   5 - Open Drain output 10MHz.
 *   6 - Open Drain output 2MHz.
 *   7 - Open Drain output 50MHz.
 *   8 - Digital input with PullUp or PullDown resistor depending on ODR.
 *   9 - Alternate Push Pull output 10MHz.
 *   A - Alternate Push Pull output 2MHz.
 *   B - Alternate Push Pull output 50MHz.
 *   C - Reserved.
 *   D - Alternate Open Drain output 10MHz.
 *   E - Alternate Open Drain output 2MHz.
 *   F - Alternate Open Drain output 50MHz.
 * Please refer to the STM32 Reference Manual for details.
 */

/*
 * Port A setup.
 * Everything input with pull-up except:
 * PA9  - Push Pull output (USB DISC).
 * PA10 - Normal input     (USB PRESENT).
 * PA11 - Normal input      (USB DM).
 * PA12 - Normal input      (USB DP).
 */
#define VAL_GPIOACRL            0x88888888      /*  PA7...PA0 */
#define VAL_GPIOACRH            0x88844438      /* PA15...PA8 */
#define VAL_GPIOAODR            0xFFFFFFFF


/*
 * Port B setup.
 * Everything input with pull-up except:
 * PB0 - Push Pull output   (LED_1).
 * PB1 - Push Pull output   (LED_2).
 * PB5  - Push Pull output  (USART2 TX_ENABLE).
 * PB6  - Alternate output  (USART1 TX).
 * PB7  - Normal input      (USART1 RX).
 * PB8,9 - Alternate open drain (I2C).
 * PB10 - Alternate output  (USART3 TX).
 * PB11 - Normal input      (USART3 RX).
 * PB12 - Push Pull output  (MMC SPI2 NSS).
 * PB13 - Alternate output  (MMC SPI2 SCK).
 * PB14 - Normal input      (MMC SPI2 MISO).
 * PB15 - Alternate output  (MMC SPI2 MOSI).
 */
#define VAL_GPIOBCRL            0x4B388833      /*  PB7...PB0 */
#define VAL_GPIOBCRH            0xB4B34BEE      /* PB15...PB8 */
#define VAL_GPIOBODR            0xFFFFFFFF


/*
 * Port C setup.
 * Everything input with pull-up except:
 */
#define VAL_GPIOCCRL            0x88888888      /*  PC7...PC0 */
#define VAL_GPIOCCRH            0x88888888      /* PC15...PC8 */
#define VAL_GPIOCODR            0xFFFFFFFF

/*
 * Port D setup.
 * Everything input with pull-up except:
 * PD0  - Normal input (XTAL).
 * PD1  - Normal input (XTAL).
 */
#define VAL_GPIODCRL            0x88888844      /*  PD7...PD0 */
#define VAL_GPIODCRH            0x88888888      /* PD15...PD8 */
#define VAL_GPIODODR            0xFFFFFFFF

/*
 * Port E setup.
 * Everything input with pull-up except:
 */
#define VAL_GPIOECRL            0x88888888      /*  PE7...PE0 */
#define VAL_GPIOECRH            0x88888888      /* PE15...PE8 */
#define VAL_GPIOEODR            0xFFFFFFFF

/*
 * Port F setup.
 * Everything input with pull-up except:
 */
#define VAL_GPIOFCRL            0x88888888      /*  PE7...PE0 */
#define VAL_GPIOFCRH            0x88888888      /* PE15...PE8 */
#define VAL_GPIOFODR            0xFFFFFFFF

/*
 * Port G setup.
 * Everything input with pull-up except:
 */
#define VAL_GPIOGCRL            0x88888888      /*  PE7...PE0 */
#define VAL_GPIOGCRH            0x88888888      /* PE15...PE8 */
#define VAL_GPIOGODR            0xFFFFFFFF

/*
 * USB bus activation macro, required by the USB driver.
 */
#define usb_lld_connect_bus(usbp) palClearPad(GPIOA, GPIOA_USB_DISC)

/*
 * USB bus de-activation macro, required by the USB driver.
 */
#define usb_lld_disconnect_bus(usbp) palSetPad(GPIOA, GPIOA_USB_DISC)

#if !defined(_FROM_ASM_)
#ifdef __cplusplus
extern "C" {
#endif
  void boardInit(void);
#ifdef __cplusplus
}
#endif
#endif /* _FROM_ASM_ */

#endif /* _BOARD_H_ */
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F103 HD usb problem

Post by Giovanni »

Hi,

It could be something HW related, it detects the device so the pull-up control appears to be OK but it does not respond correctly. Verify traces and signals.

If you have the Olimex board you could use that to verify the SW.

Giovanni
serdz
Posts: 11
Joined: Sat Mar 30, 2013 7:37 pm

Re: STM32F103 HD usb problem

Post by serdz »

Hi Giovanni,

Thanks for quick reply. Unfortunately I don't have Olimex board.
User avatar
Tectu
Posts: 1225
Joined: Thu May 10, 2012 9:50 am

Re: STM32F103 HD usb problem

Post by Tectu »

Are you trying to use USB-CDC?


~ Tectu
serdz
Posts: 11
Joined: Sat Mar 30, 2013 7:37 pm

Re: STM32F103 HD usb problem

Post by serdz »

Yes I'm trying ./demos/ARMCM3-STM32F103.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F103 HD usb problem

Post by Giovanni »

Strange, if you didn't change the USB descriptors the demo should work, this is why I would consider an HW problem of some kind.

Does the board has the same clock setup of the Olimex board? crystal, dividers etc?

Giovanni
serdz
Posts: 11
Joined: Sat Mar 30, 2013 7:37 pm

Re: STM32F103 HD usb problem

Post by serdz »

Yes, exactly the same 8MHz crystal. Configuration I also not changed.
From Linux usb monitor I see that my board not responds at all.( As I mentioned before USB isr also not executed on board)
ffff880156f00540 797183841 S Ci:3:001:0 s a3 00 0000 0001 0004 4 <
ffff880156f00540 797183868 C Ci:3:001:0 0 4 = 00010100
ffff880156f00540 797183874 S Co:3:001:0 s 23 01 0010 0001 0000 0
ffff880156f00540 797183879 C Co:3:001:0 0 0
ffff880156f00540 797183881 S Ci:3:001:0 s a3 00 0000 0002 0004 4 <
ffff880156f00540 797183884 C Ci:3:001:0 0 4 = 00010000
ffff88022ecc8f00 797287829 S Ii:3:001:1 -115:2048 4 <
ffff88022ecc8f00 799415770 C Ii:3:001:1 -2:2048 0
ffff880156f00a80 800447817 S Ci:3:001:0 s a3 00 0000 0001 0004 4 <
ffff880156f00a80 800447834 C Ci:3:001:0 0 4 = 01010100
ffff880156f00a80 800447840 S Co:3:001:0 s 23 01 0010 0001 0000 0
ffff880156f00a80 800447846 C Co:3:001:0 0 0
ffff880156f00a80 800447848 S Ci:3:001:0 s a3 00 0000 0002 0004 4 <
ffff880156f00a80 800447850 C Ci:3:001:0 0 4 = 00010000
ffff88022ecc8f00 800551812 S Ii:3:001:1 -115:2048 4 <
ffff8802312fa9c0 800551911 S Ci:3:001:0 s a3 00 0000 0001 0004 4 <
ffff8802312fa9c0 800551921 C Ci:3:001:0 0 4 = 01010000
ffff8802312fa9c0 800552027 S Co:3:001:0 s 23 03 0004 0001 0000 0
ffff8802312fa9c0 800552043 C Co:3:001:0 0 0
ffff8802312facc0 800607779 S Ci:3:001:0 s a3 00 0000 0001 0004 4 <
ffff8802312facc0 800607795 C Ci:3:001:0 0 4 = 03011000
ffff880230bc9b40 800663855 S Co:3:001:0 s 23 01 0014 0001 0000 0
ffff880230bc9b40 800663888 C Co:3:001:0 0 0
ffff8802312fa300 801071885 S Co:3:001:0 s 23 01 0001 0001 0000 0
ffff8802312fa300 801071907 C Co:3:001:0 0 0
ffff880156f00780 801072189 S Co:3:001:0 s 23 03 0004 0001 0000 0
ffff880156f00780 801072205 C Co:3:001:0 0 0
ffff880156f00cc0 801127835 S Ci:3:001:0 s a3 00 0000 0001 0004 4 <
ffff880156f00cc0 801127851 C Ci:3:001:0 0 4 = 03011000
ffff8802312fa300 801183863 S Co:3:001:0 s 23 01 0014 0001 0000 0
ffff8802312fa300 801183886 C Co:3:001:0 0 0
ffff8802312fa9c0 801591894 S Co:3:001:0 s 23 01 0001 0001 0000 0
ffff8802312fa9c0 801591915 C Co:3:001:0 0 0
ffff880156f00cc0 801592122 S Co:3:001:0 s 23 03 0004 0001 0000 0
ffff880156f00cc0 801592138 C Co:3:001:0 0 0
ffff8802312facc0 801647820 S Ci:3:001:0 s a3 00 0000 0001 0004 4 <
ffff8802312facc0 801647840 C Ci:3:001:0 0 4 = 03011000
ffff880230bc9a80 801703864 S Co:3:001:0 s 23 01 0014 0001 0000 0
ffff880230bc9a80 801703887 C Co:3:001:0 0 0
ffff880230bc9300 802111883 S Co:3:001:0 s 23 01 0001 0001 0000 0
ffff880230bc9300 802111905 C Co:3:001:0 0 0
ffff880156f00240 802112116 S Co:3:001:0 s 23 03 0004 0001 0000 0
ffff880156f00240 802112132 C Co:3:001:0 0 0
ffff8802312fa9c0 802167863 S Ci:3:001:0 s a3 00 0000 0001 0004 4 <
ffff8802312fa9c0 802167884 C Ci:3:001:0 0 4 = 03011000
ffff880230bc9d80 802223863 S Co:3:001:0 s 23 01 0014 0001 0000 0
ffff880230bc9d80 802223886 C Co:3:001:0 0 0
ffff88021cd7d180 802631886 S Co:3:001:0 s 23 01 0001 0001 0000 0
ffff88021cd7d180 802631908 C Co:3:001:0 0 0
ffff88021cd7d180 802631941 S Co:3:001:0 s 23 01 0001 0001 0000 0
ffff88021cd7d180 802631946 C Co:3:001:0 0 0
ffff88022ecc8f00 804631801 C Ii:3:001:1 -2:2048 0


I just verified all traces, no short contacts.
By the way serial port 2 and 3 works well.

Probably something with HW, tomorrow I will try another board with only USB part soldered.
serdz
Posts: 11
Joined: Sat Mar 30, 2013 7:37 pm

Re: STM32F103 HD usb problem

Post by serdz »

SOLVED. Problem gone after resoldering crystal.
Post Reply