Hang on STM32F4 Discovery and MAC driver
Moderator: RoccoMarco
Hang on STM32F4 Discovery and MAC driver
I have an expansion board that is using the STM32F4 Discovery board to add an ethernet PHY and use the MAC driver in ChibiOS. Unfortunately the LIS302DL uses PA7 for MOSI, which is the only pin that can be used for RMII_CRS_DV so I had to remove the accelerometer. A basic LED blink code works just fine on the board. However, when I include the MAC driver in the code, everything hangs. I'm pretty sure it is hanging in halInit(). These are the pins I am using:
#define GPIOA_ETH_RMII_REF_CLK 1
#define GPIOA_ETH_RMII_MDIO 2
#define GPIOA_ETH_RMII_CRS_DV 7
#define GPIOB_ETH_RMII_TX_EN 11
#define GPIOB_ETH_RMII_TXD0 12
#define GPIOB_ETH_RMII_TXD1 13
#define GPIOC_ETH_RMII_MDC 1
#define GPIOC_ETH_RMII_RXD0 4
#define GPIOC_ETH_RMII_RXD1 5
All are listed as Free I/O in the STM32F4DISCOVERY datasheet (except PA7 as mentioned above).
Any ideas what the problem could be?
#define GPIOA_ETH_RMII_REF_CLK 1
#define GPIOA_ETH_RMII_MDIO 2
#define GPIOA_ETH_RMII_CRS_DV 7
#define GPIOB_ETH_RMII_TX_EN 11
#define GPIOB_ETH_RMII_TXD0 12
#define GPIOB_ETH_RMII_TXD1 13
#define GPIOC_ETH_RMII_MDC 1
#define GPIOC_ETH_RMII_RXD0 4
#define GPIOC_ETH_RMII_RXD1 5
All are listed as Free I/O in the STM32F4DISCOVERY datasheet (except PA7 as mentioned above).
Any ideas what the problem could be?
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Hang on STM32F4 Discovery and MAC driver
Did you set the PAL modes correctly? The halInit() fails when the PHY does not respond properly.
~ Tectu
~ Tectu
Re: Hang on STM32F4 Discovery and MAC driver
Giovanni wrote:Hi,
Is the PHY correctly clocked?
Giovanni
Hello Giovanni. Yes. I am using the KSZ8051 which takes a 25 MHz signal from a crystal/oscillator and then provides the 50 MHz reference clock to the MAC.
Tectu wrote:Did you set the PAL modes correctly? The halInit() fails when the PHY does not respond properly.
~ Tectu
Yes, I am fairly certain I set the PAL modes correctly. Here is the board.h file so that you can verify just in case I am missing something: http://pastebin.com/XU4nLcBw
Re: Hang on STM32F4 Discovery and MAC driver
No, I am using an expansion board that I designed myself. So hardware errors are not out of the question, but I am quite confident everything is routed correctly (verified with ohmmeter).
Re: Hang on STM32F4 Discovery and MAC driver
Now it's getting tricky 
I don't really have the time nor the knowledge, but maybe you want to share your schematics for a review. Are you sure you didn't break the chip when soldering etc?
~ Tectu
I don't really have the time nor the knowledge, but maybe you want to share your schematics for a review. Are you sure you didn't break the chip when soldering etc?
~ Tectu
Re: Hang on STM32F4 Discovery and MAC driver
So just a quick update to this. I was missing a pullup resistor on the MDIO line, which appears to be what was causing the hang. I am also using the Micrel KSZ8051RNL PHY which does not appear to be supported in the ChibiOS MAC driver just yet. Some small modifications the ST library code (see http://andybrown.me.uk/wk/2012/09/01/ethernet-phy-stm32f107/) gets just about everything going. PHY is now being configured, but I am not yet able to ping it.
Re: Hang on STM32F4 Discovery and MAC driver
Hello,
I also have a board with the KSZ8051RNL.
I use a external 50MHz osc. and have init the phy.
I made the following changes:
board.h
mcuconf.h
chconf.h (This selects the external 50MHz osc.)
I also have a board with the KSZ8051RNL.
I use a external 50MHz osc. and have init the phy.
I made the following changes:
board.h
Code: Select all
/*
* Ethernet PHY type.
*/
#define MII_KSZ8051RNL_ID 0x00221550
#define BOARD_PHY_ID MII_KSZ8051RNL_ID
#define BOARD_PHY_RMII
mcuconf.h
Code: Select all
#define STM32_MAC_ETH1_CHANGE_PHY_STATE FALSE
chconf.h (This selects the external 50MHz osc.)
Code: Select all
[
#define BOARD_PHY_RESET() { \
while (mii_read(ÐD1, MII_BMCR) & BMCR_RESET); \
mii_write(ÐD1, 0x16, 2); \
mii_write(ÐD1, 0x1f, (mii_read(ÐD1, 0x1f) & 0x30) | 0x90); \
}
Re: Hang on STM32F4 Discovery and MAC driver
For both users, where exactly does the code hang in the debugger? I had to enable the MAC (see my posts) earlier while it waited for information because otherwise the MAC would no longer clock, thus it would never get the data it was waiting for. It could probably have been solved with the various timing macro delays or timeouts, but none of the configurations I tested worked.
For reference, here was JerryR's post that fixed the issue for my KSZ8041:
viewtopic.php?f=2&t=733#p7380
For reference, here was JerryR's post that fixed the issue for my KSZ8041:
viewtopic.php?f=2&t=733#p7380