Skip to content

Commit 7fcedd2

Browse files
jeromecoutantABOSTM
authored andcommitted
DISCO STM32H747I ETHERNET support, but disabled.
Ethernet is disabled by default, because some hardware modifications are required on the board DISCO_H747I. see https://os.mbed.com/teams/ST/wiki/DISCO_H747I-modifications-for-Ethernet
1 parent c77b824 commit 7fcedd2

File tree

5 files changed

+184
-4
lines changed

5 files changed

+184
-4
lines changed
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2018, STMicroelectronics
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
*
8+
* 1. Redistributions of source code must retain the above copyright notice,
9+
* this list of conditions and the following disclaimer.
10+
* 2. Redistributions in binary form must reproduce the above copyright notice,
11+
* this list of conditions and the following disclaimer in the documentation
12+
* and/or other materials provided with the distribution.
13+
* 3. Neither the name of STMicroelectronics nor the names of its contributors
14+
* may be used to endorse or promote products derived from this software
15+
* without specific prior written permission.
16+
*
17+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
21+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
*/
28+
29+
#define ETHERNET 1
30+
#if (MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE == ETHERNET)
31+
#if !defined(DISCO_H747I_ETHERNET_SOLDERBRIGE)
32+
#error Hardware modifications are required for Ethernet on DISCO_H747I. see https://os.mbed.com/teams/ST/wiki/DISCO_H747I-modifications-for-Ethernet
33+
#endif
34+
#endif
35+
36+
#ifndef USE_USER_DEFINED_HAL_ETH_MSPINIT
37+
38+
#include "stm32h7xx_hal.h"
39+
40+
#define ETH_TX_EN_Pin GPIO_PIN_11
41+
#define ETH_TX_EN_GPIO_Port GPIOG
42+
#define ETH_TXD1_Pin GPIO_PIN_12
43+
#define ETH_TXD1_GPIO_Port GPIOG
44+
#define ETH_TXD0_Pin GPIO_PIN_13
45+
#define ETH_TXD0_GPIO_Port GPIOG
46+
#define ETH_MDC_SAI4_D1_Pin GPIO_PIN_1
47+
#define ETH_MDC_SAI4_D1_GPIO_Port GPIOC
48+
#define ETH_MDIO_Pin GPIO_PIN_2
49+
#define ETH_MDIO_GPIO_Port GPIOA
50+
#define ETH_REF_CLK_Pin GPIO_PIN_1
51+
#define ETH_REF_CLK_GPIO_Port GPIOA
52+
#define ETH_CRS_DV_Pin GPIO_PIN_7
53+
#define ETH_CRS_DV_GPIO_Port GPIOA
54+
#define ETH_RXD0_Pin GPIO_PIN_4
55+
#define ETH_RXD0_GPIO_Port GPIOC
56+
#define ETH_RXD1_Pin GPIO_PIN_5
57+
#define ETH_RXD1_GPIO_Port GPIOC
58+
59+
60+
/**
61+
* Override HAL Eth Init function
62+
*/
63+
void HAL_ETH_MspInit(ETH_HandleTypeDef *heth)
64+
{
65+
GPIO_InitTypeDef GPIO_InitStruct;
66+
if(heth->Instance == ETH)
67+
{
68+
/* Disable DCache for STM32H7 family */
69+
SCB_DisableDCache();
70+
71+
/* GPIO Ports Clock Enable */
72+
__HAL_RCC_GPIOA_CLK_ENABLE();
73+
// __HAL_RCC_GPIOB_CLK_ENABLE();
74+
__HAL_RCC_GPIOC_CLK_ENABLE();
75+
__HAL_RCC_GPIOG_CLK_ENABLE();
76+
// __HAL_RCC_GPIOH_CLK_ENABLE();
77+
78+
/* Enable Peripheral clock */
79+
__HAL_RCC_ETH1MAC_CLK_ENABLE();
80+
__HAL_RCC_ETH1TX_CLK_ENABLE();
81+
__HAL_RCC_ETH1RX_CLK_ENABLE();
82+
83+
/**ETH GPIO Configuration
84+
PG11 ------> ETH_TX_EN
85+
PG12 ------> ETH_TXD1
86+
PG13 ------> ETH_TXD0
87+
PC1 ------> ETH_MDC
88+
PA2 ------> ETH_MDIO
89+
PA1 ------> ETH_REF_CLK
90+
PA7 ------> ETH_CRS_DV
91+
PC4 ------> ETH_RXD0
92+
PC5 ------> ETH_RXD1
93+
*/
94+
GPIO_InitStruct.Pin = ETH_TX_EN_Pin|ETH_TXD1_Pin|ETH_TXD0_Pin;
95+
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
96+
GPIO_InitStruct.Pull = GPIO_NOPULL;
97+
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
98+
GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
99+
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
100+
101+
GPIO_InitStruct.Pin = ETH_MDC_SAI4_D1_Pin|ETH_RXD0_Pin|ETH_RXD1_Pin;
102+
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
103+
GPIO_InitStruct.Pull = GPIO_NOPULL;
104+
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
105+
GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
106+
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
107+
108+
GPIO_InitStruct.Pin = ETH_MDIO_Pin|ETH_REF_CLK_Pin|ETH_CRS_DV_Pin;
109+
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
110+
GPIO_InitStruct.Pull = GPIO_NOPULL;
111+
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
112+
GPIO_InitStruct.Alternate = GPIO_AF11_ETH;
113+
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
114+
115+
}
116+
}
117+
118+
/**
119+
* Override HAL Eth DeInit function
120+
*/
121+
void HAL_ETH_MspDeInit(ETH_HandleTypeDef *heth)
122+
{
123+
if(heth->Instance == ETH)
124+
{
125+
/* Peripheral clock disable */
126+
__HAL_RCC_ETH1MAC_CLK_DISABLE();
127+
__HAL_RCC_ETH1TX_CLK_DISABLE();
128+
__HAL_RCC_ETH1RX_CLK_DISABLE();
129+
130+
/**ETH GPIO Configuration
131+
PG11 ------> ETH_TX_EN
132+
PG12 ------> ETH_TXD1
133+
PG13 ------> ETH_TXD0
134+
PC1 ------> ETH_MDC
135+
PA2 ------> ETH_MDIO
136+
PA1 ------> ETH_REF_CLK
137+
PA7 ------> ETH_CRS_DV
138+
PC4 ------> ETH_RXD0
139+
PC5 ------> ETH_RXD1
140+
*/
141+
HAL_GPIO_DeInit(GPIOG, ETH_TX_EN_Pin|ETH_TXD1_Pin|ETH_TXD0_Pin);
142+
143+
HAL_GPIO_DeInit(GPIOC, ETH_MDC_SAI4_D1_Pin|ETH_RXD0_Pin|ETH_RXD1_Pin);
144+
145+
HAL_GPIO_DeInit(GPIOA, ETH_MDIO_Pin|ETH_REF_CLK_Pin|ETH_CRS_DV_Pin);
146+
}
147+
}
148+
149+
#endif /* USE_USER_DEFINED_HAL_ETH_MSPINIT */

features/netsocket/emac-drivers/TARGET_STM/stm32xx_emac.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,7 @@ bool STM32_EMAC::low_level_init_successful()
317317
}
318318
#else // ETH_IP_VERSION_V2
319319
{
320-
uint32_t idx, duplex, speed = 0;
321-
int32_t PHYLinkState;
322-
ETH_MACConfigTypeDef MACConf;
320+
uint32_t idx;
323321

324322
MPU_Config();
325323

targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_DISCO_H747I_CM7/TOOLCHAIN_ARM_STD/stm32h747xI.sct

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,25 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE { ; load region size_region
4141
*(InRoot$$Sections)
4242
.ANY (+RO)
4343
}
44-
44+
4545
RW_IRAM1 (MBED_RAM0_START) (MBED_RAM0_SIZE-Stack_Size) { ; RW data
4646
.ANY (+RW +ZI)
4747
}
4848

4949
ARM_LIB_STACK (MBED_RAM0_START+MBED_RAM0_SIZE) EMPTY -Stack_Size { ; stack
5050
}
51+
52+
RW_DMARxDscrTab 0x30040000 0x60 {
53+
*(.RxDecripSection)
54+
}
55+
RW_DMATxDscrTab 0x30040100 0x140 {
56+
*(.TxDecripSection)
57+
}
58+
RW_Rx_Buffb 0x30040400 0x1800 {
59+
*(.RxArraySection)
60+
}
61+
RW_Eth_Ram 0x30044000 0x4000 {
62+
*(.ethusbram)
63+
}
64+
5165
}

targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_DISCO_H747I_CM7/TOOLCHAIN_GCC_ARM/STM32H747xI.ld

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,19 @@ SECTIONS
183183

184184
/* Check if data + heap + stack exceeds RAM limit */
185185
ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
186+
187+
.lwip_sec (NOLOAD) : {
188+
. = ABSOLUTE(0x30040000);
189+
*(.RxDecripSection)
190+
191+
. = ABSOLUTE(0x30040100);
192+
*(.TxDecripSection)
193+
194+
. = ABSOLUTE(0x30040400);
195+
*(.RxArraySection)
196+
197+
. = ABSOLUTE(0x30044000);
198+
*(.ethusbram)
199+
200+
} >RAM_D2 AT> FLASH
186201
}

targets/TARGET_STM/TARGET_STM32H7/TARGET_STM32H747xI/TARGET_DISCO_H747I_CM7/TOOLCHAIN_IAR/stm32h747xI.icf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ define memory mem with size = 4G;
3737
define region ROM_region = mem:[from __region_ROM_start__ to __region_ROM_end__];
3838
define region RAM_region = mem:[from __region_RAM_start__ to __region_RAM_end__];
3939

40+
// Memory region used for ethernet
41+
define region eth_mem_region = mem:[from 0x30044000 to 0x30048000 ];
42+
place in eth_mem_region { section .ethusbram };
43+
4044
// Stack and Heap
4145
define symbol __size_cstack__ = MBED_BOOT_STACK_SIZE;
4246
define symbol __size_heap__ = 0x10000; // 64KB

0 commit comments

Comments
 (0)