mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-30 21:18:25 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3566f7c7fe | ||
|
|
a688c0a0f0 |
No files matched your search
@@ -490,7 +490,7 @@ jobs:
|
||||
- uses: webfactory/ssh-agent@v0.10.0
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.HEALTH_TESTS_SSH_KEY }}
|
||||
- run: sudo apt -y install libpcap-dev
|
||||
- run: sudo apt -y update && sudo apt -y install libpcap-dev
|
||||
- run: make -C test tutorials CFLAGS_EXTRA="${{ matrix.ssl }}" > log
|
||||
- if: success() || failure()
|
||||
run: |
|
||||
|
||||
+3
-2
@@ -33796,15 +33796,16 @@ void mg_phy_init(struct mg_phy *phy, uint8_t phy_addr, uint8_t config) {
|
||||
|
||||
if (config & MG_PHY_RGMII) {
|
||||
if (id1 == MG_PHY_YT85x && id2 == MG_PHY_YT8531) {
|
||||
// assume PHY has been hardware strapped properly
|
||||
#if 0
|
||||
uint16_t value;
|
||||
// TODO (robertc2000): Autonegotiation remains disabled after PHY is reset
|
||||
// We temporarily force enabling autoneg, until a workaround is found.
|
||||
phy->write_reg(phy_addr, MG_PHY_REG_BCR, MG_BIT(12));
|
||||
phy->write_reg(phy_addr, MG_PHY_YT8531_REG_EXT_ADDR, 0xa003);
|
||||
value = phy->read_reg(phy_addr, MG_PHY_YT8531_REG_EXT_DATA);
|
||||
value &= (uint16_t) ~(MG_BIT(3) | MG_BIT(2) | MG_BIT(1) | MG_BIT(0));
|
||||
phy->write_reg(phy_addr, MG_PHY_YT8531_REG_EXT_DATA,
|
||||
(uint16_t) (value | MG_BIT(1))); // TXDLY: 2 * 150 ps
|
||||
#endif
|
||||
} else if (id1 == MG_PHY_DP83x && id2 == MG_PHY_DP83867) {
|
||||
phy->write_reg(phy_addr, 0x0d,
|
||||
0x1f); // write 0x10d to IO_MUX_CFG (0x0170)
|
||||
|
||||
@@ -104,7 +104,6 @@ static bool mg_tcpip_driver_imxrt_init(struct mg_tcpip_if *ifp) {
|
||||
ENET->MSCR = (1 << 8) | ((cr & 0x3f) << 1); // HOLDTIME 2 clks
|
||||
struct mg_phy phy = {enet_read_phy, enet_write_phy};
|
||||
mg_phy_init(&phy, d->phy_addr, MG_PHY_LEDS_ACTIVE_HIGH); // MAC clocks PHY
|
||||
mg_tcpip_call(ifp, MG_TCPIP_EV_PHY_INIT, &phy);
|
||||
// Select RMII mode, 100M, keep CRC, set max rx length, disable loop
|
||||
ENET->RCR = (1518 << 16) | MG_BIT(8) | MG_BIT(2);
|
||||
// ENET->RCR |= MG_BIT(3); // Receive all
|
||||
|
||||
@@ -243,7 +243,6 @@ static bool mg_tcpip_driver_netc_init(struct mg_tcpip_if *ifp) {
|
||||
NETC_EMDIO->EMDIO_CFG =
|
||||
((mdc_cr & 0x1ffU) << 7) | MG_BIT(2); // MDIO_CLK_DIV, MDIO_HOLD
|
||||
mg_phy_init(&phy, d->phy_addr, MG_PHY_RGMII);
|
||||
mg_tcpip_call(ifp, MG_TCPIP_EV_PHY_INIT, &phy);
|
||||
|
||||
// Initialize ENETC1 PSI0 and port
|
||||
NETC_ENETC1_PCI->CMD |= MG_BIT(2) | MG_BIT(1); // BUS_MASTER_EN, MEM_ACCESS
|
||||
|
||||
+3
-2
@@ -87,15 +87,16 @@ void mg_phy_init(struct mg_phy *phy, uint8_t phy_addr, uint8_t config) {
|
||||
|
||||
if (config & MG_PHY_RGMII) {
|
||||
if (id1 == MG_PHY_YT85x && id2 == MG_PHY_YT8531) {
|
||||
// assume PHY has been hardware strapped properly
|
||||
#if 0
|
||||
uint16_t value;
|
||||
// TODO (robertc2000): Autonegotiation remains disabled after PHY is reset
|
||||
// We temporarily force enabling autoneg, until a workaround is found.
|
||||
phy->write_reg(phy_addr, MG_PHY_REG_BCR, MG_BIT(12));
|
||||
phy->write_reg(phy_addr, MG_PHY_YT8531_REG_EXT_ADDR, 0xa003);
|
||||
value = phy->read_reg(phy_addr, MG_PHY_YT8531_REG_EXT_DATA);
|
||||
value &= (uint16_t) ~(MG_BIT(3) | MG_BIT(2) | MG_BIT(1) | MG_BIT(0));
|
||||
phy->write_reg(phy_addr, MG_PHY_YT8531_REG_EXT_DATA,
|
||||
(uint16_t) (value | MG_BIT(1))); // TXDLY: 2 * 150 ps
|
||||
#endif
|
||||
} else if (id1 == MG_PHY_DP83x && id2 == MG_PHY_DP83867) {
|
||||
phy->write_reg(phy_addr, 0x0d,
|
||||
0x1f); // write 0x10d to IO_MUX_CFG (0x0170)
|
||||
|
||||
@@ -164,7 +164,6 @@ static bool mg_tcpip_driver_ra_init(struct mg_tcpip_if *ifp) {
|
||||
MG_DEBUG(("PHY addr: %d, smispin: %d", d->phy_addr, s_smispin));
|
||||
struct mg_phy phy = {raeth_read_phy, raeth_write_phy};
|
||||
mg_phy_init(&phy, d->phy_addr, MG_PHY_CLOCKS_MAC);
|
||||
mg_tcpip_call(ifp, MG_TCPIP_EV_PHY_INIT, &phy);
|
||||
|
||||
// Select RMII mode,
|
||||
ETHERC->ECMR = MG_BIT(2) | MG_BIT(1); // 100M, Full-duplex, CRC
|
||||
|
||||
@@ -69,7 +69,6 @@ static bool mg_tcpip_driver_rw612_init(struct mg_tcpip_if *ifp) {
|
||||
ENET->MSCR = ((d->mdc_cr & 0x3f) << 1) | ((d->mdc_holdtime & 7) << 8);
|
||||
struct mg_phy phy = {eth_read_phy, eth_write_phy};
|
||||
mg_phy_init(&phy, d->phy_addr, 0);
|
||||
mg_tcpip_call(ifp, MG_TCPIP_EV_PHY_INIT, &phy);
|
||||
ENET->ECR |= MG_BIT(0); // reset ETH
|
||||
|
||||
// initialize descriptors
|
||||
|
||||
@@ -128,7 +128,6 @@ static bool mg_tcpip_driver_same54_init(struct mg_tcpip_if *ifp) {
|
||||
|
||||
struct mg_phy phy = {eth_read_phy, eth_write_phy};
|
||||
mg_phy_init(&phy, d->phy_addr, 0);
|
||||
mg_tcpip_call(ifp, MG_TCPIP_EV_PHY_INIT, &phy);
|
||||
|
||||
for (int i = 0; i < ETH_DESC_CNT; i++) { // Init TX descriptors
|
||||
s_txdesc[i][0] = (uint32_t) s_txbuf[i]; // Point to data buffer
|
||||
|
||||
@@ -142,7 +142,6 @@ static bool mg_tcpip_driver_stm32f_init(struct mg_tcpip_if *ifp) {
|
||||
ETH->MACFFR = MG_BIT(10); // Perfect filtering
|
||||
struct mg_phy phy = {eth_read_phy, eth_write_phy};
|
||||
mg_phy_init(&phy, phy_addr, MG_PHY_CLOCKS_MAC);
|
||||
mg_tcpip_call(ifp, MG_TCPIP_EV_PHY_INIT, &phy);
|
||||
ETH->DMARDLAR = (uint32_t) (uintptr_t) s_rxdesc; // RX descriptors
|
||||
ETH->DMATDLAR = (uint32_t) (uintptr_t) s_txdesc; // RX descriptors
|
||||
ETH->DMAIER = MG_BIT(6) | MG_BIT(16); // RIE, NISE
|
||||
|
||||
@@ -196,7 +196,6 @@ static bool mg_tcpip_driver_stm32h_init(struct mg_tcpip_if *ifp) {
|
||||
#endif
|
||||
struct mg_phy phy = {eth_read_phy, eth_write_phy};
|
||||
mg_phy_init(&phy, phy_addr, phy_conf);
|
||||
mg_tcpip_call(ifp, MG_TCPIP_EV_PHY_INIT, &phy);
|
||||
ETH->DMACRDLAR =
|
||||
(uint32_t) (uintptr_t) s_rxdesc; // RX descriptors start address
|
||||
ETH->DMACRDRLR = ETH_DESC_CNT - 1; // ring length
|
||||
|
||||
@@ -108,7 +108,6 @@ static bool mg_tcpip_driver_tms570_init(struct mg_tcpip_if *ifp) {
|
||||
while (delay-- != 0) (void) 0;
|
||||
struct mg_phy phy = {emac_read_phy, emac_write_phy};
|
||||
mg_phy_init(&phy, d->phy_addr, MG_PHY_CLOCKS_MAC);
|
||||
mg_tcpip_call(ifp, MG_TCPIP_EV_PHY_INIT, &phy);
|
||||
uint32_t channel;
|
||||
for (channel = 0; channel < 8; channel++) {
|
||||
EMAC->MACINDEX = channel;
|
||||
|
||||
@@ -89,7 +89,6 @@ static bool mg_tcpip_driver_xmc_init(struct mg_tcpip_if *ifp) {
|
||||
// init phy
|
||||
struct mg_phy phy = {eth_read_phy, eth_write_phy};
|
||||
mg_phy_init(&phy, d->phy_addr, MG_PHY_CLOCKS_MAC);
|
||||
mg_tcpip_call(ifp, MG_TCPIP_EV_PHY_INIT, &phy);
|
||||
|
||||
// configure MAC: DO, DM, FES, TC
|
||||
ETH0->MAC_CONFIGURATION = MG_BIT(13) | MG_BIT(11) | MG_BIT(14) | MG_BIT(24);
|
||||
|
||||
@@ -150,7 +150,6 @@ static bool mg_tcpip_driver_xmc7_init(struct mg_tcpip_if *ifp) {
|
||||
// init phy
|
||||
struct mg_phy phy = {eth_read_phy, eth_write_phy};
|
||||
mg_phy_init(&phy, d->phy_addr, MG_PHY_RGMII);
|
||||
mg_tcpip_call(ifp, MG_TCPIP_EV_PHY_INIT, &phy);
|
||||
|
||||
(void) d;
|
||||
return true;
|
||||
|
||||
@@ -251,7 +251,6 @@ void mg_tcpip_call(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
||||
"TCPIP_EV_WIFI_SCAN_END", "TCPIP_EV_WIFI_CONNECT_ERR",
|
||||
"TCPIP_EV_DRIVER", "TCPIP_EV_STATE6_CHANGE",
|
||||
"TCPIP_EV_PHY_RX", "TCPIP_EV_PHY_TX",
|
||||
"TCPIP_EV_PHY_INIT",
|
||||
"TCPIP_EV_USER"};
|
||||
if (ev != MG_TCPIP_EV_TIMER_1S && ev < (int) (sizeof(names) / sizeof(names[0]))) {
|
||||
MG_PROF_ADD(ifp, names[ev]); // TODO(): call MG_PROF_DUMP() MG_PROF_FREE()
|
||||
|
||||
@@ -42,7 +42,6 @@ enum {
|
||||
MG_TCPIP_EV_STATE6_CHANGE, // IPv6 link state changed uint8_t *(&ifp->state6)
|
||||
MG_TCPIP_EV_PHY_RX, // Radio frame received struct mg_str *
|
||||
MG_TCPIP_EV_PHY_TX, // Radio frame about to be sent struct mg_str *
|
||||
MG_TCPIP_EV_PHY_INIT, // PHY initialised struct mg_phy *
|
||||
MG_TCPIP_EV_USER // Starting ID for user-defined events
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
@@ -21,7 +21,7 @@ SOURCES += cmsis_rt1186/devices/MIMXRT1186/drivers/fsl_ele_base_api.c
|
||||
SOURCES += cmsis_rt1186/devices/MIMXRT1186/drivers/fsl_s3mu.c
|
||||
SOURCES += cmsis_rt1186/devices/MIMXRT1186/drivers/fsl_trdc.c
|
||||
|
||||
CFLAGS += -D__ATOLLIC__ -D__STARTUP_CLEAR_BSS -DMG_HAL_DISABLE_RANDOM
|
||||
CFLAGS += -D__ATOLLIC__ -D__STARTUP_CLEAR_BSS -DMG_HAL_DISABLE_RANDOM -DMG_HAL_ENABLE_PHY_STRAP
|
||||
|
||||
all build: firmware.bin
|
||||
|
||||
|
||||
@@ -586,9 +586,6 @@ static inline void hal_netc_pins_init(void) {
|
||||
CLOCK_EnableClock(kCLOCK_Iomuxc1);
|
||||
CLOCK_EnableClock(kCLOCK_Iomuxc2);
|
||||
|
||||
hal_gpio_output(HAL_NETC_PHY0_RESET);
|
||||
hal_gpio_write(HAL_NETC_PHY0_RESET, true);
|
||||
|
||||
hal_gpio_mux_config(kIOMUXC_SW_MUX_CTL_PAD_GPIO_AD_30, 7U); // EMDC
|
||||
hal_gpio_pad_config(kIOMUXC_SW_PAD_CTL_PAD_GPIO_AD_30,
|
||||
HAL_GPIO_OTYPE_PUSH_PULL, HAL_GPIO_SPEED_HIGH,
|
||||
@@ -648,13 +645,27 @@ static inline bool hal_netc_ierb_init(void) {
|
||||
static inline void hal_ethernet_init(void) {
|
||||
hal_netc_trdc_init();
|
||||
CLOCK_EnableClock(kCLOCK_Netc);
|
||||
hal_netc_pins_init();
|
||||
if (!hal_netc_ierb_init()) return;
|
||||
|
||||
hal_gpio_output(HAL_NETC_PHY0_RESET);
|
||||
hal_gpio_write(HAL_NETC_PHY0_RESET, false);
|
||||
SDK_DelayAtLeastUs(10000U, SYS_FREQUENCY);
|
||||
#if MG_HAL_ENABLE_PHY_STRAP
|
||||
hal_gpio_output(PIN('3', 10)); // RX_CLK PHY ADDR1
|
||||
hal_gpio_output(PIN('3', 11)); // RX_DATA_2 CFG_MODE1
|
||||
hal_gpio_output(PIN('3', 12)); // RX_DATA_3 CFG_MODE2
|
||||
hal_gpio_output(PIN('3', 20)); // RX_DATA_1 CFG_MODE0
|
||||
hal_gpio_write(PIN('3', 10), false); // PHY ADDR b101 = 5
|
||||
hal_gpio_write(PIN('3', 12), false); // CFG_MODE 000: RGMII
|
||||
hal_gpio_write(PIN('3', 11), false); //
|
||||
hal_gpio_write(PIN('3', 20), false); //
|
||||
#endif
|
||||
SDK_DelayAtLeastUs(15000U, SYS_FREQUENCY);
|
||||
hal_gpio_write(HAL_NETC_PHY0_RESET, true);
|
||||
SDK_DelayAtLeastUs(150000U, SYS_FREQUENCY);
|
||||
__DSB(); // ensure pin config happens AFTER reset is released
|
||||
SDK_DelayAtLeastUs(10U, SYS_FREQUENCY); // provide some hold time
|
||||
hal_netc_pins_init(); // release straps, set as Ethernet pins
|
||||
if (!hal_netc_ierb_init())
|
||||
return;
|
||||
SDK_DelayAtLeastUs(15000U, SYS_FREQUENCY);
|
||||
|
||||
NVIC_EnableIRQ(MSGINTR1_IRQn);
|
||||
}
|
||||
|
||||
@@ -664,3 +675,4 @@ static inline void hal_rng_init(void) {
|
||||
static inline uint32_t hal_rng_read(void) {
|
||||
return 42;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user