mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-30 21:18:25 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d116475af |
No files matched your search
@@ -490,7 +490,7 @@ jobs:
|
|||||||
- uses: webfactory/ssh-agent@v0.10.0
|
- uses: webfactory/ssh-agent@v0.10.0
|
||||||
with:
|
with:
|
||||||
ssh-private-key: ${{ secrets.HEALTH_TESTS_SSH_KEY }}
|
ssh-private-key: ${{ secrets.HEALTH_TESTS_SSH_KEY }}
|
||||||
- run: sudo apt -y update && sudo apt -y install libpcap-dev
|
- run: sudo apt -y install libpcap-dev
|
||||||
- run: make -C test tutorials CFLAGS_EXTRA="${{ matrix.ssl }}" > log
|
- run: make -C test tutorials CFLAGS_EXTRA="${{ matrix.ssl }}" > log
|
||||||
- if: success() || failure()
|
- if: success() || failure()
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
+4
-10
@@ -33796,16 +33796,15 @@ void mg_phy_init(struct mg_phy *phy, uint8_t phy_addr, uint8_t config) {
|
|||||||
|
|
||||||
if (config & MG_PHY_RGMII) {
|
if (config & MG_PHY_RGMII) {
|
||||||
if (id1 == MG_PHY_YT85x && id2 == MG_PHY_YT8531) {
|
if (id1 == MG_PHY_YT85x && id2 == MG_PHY_YT8531) {
|
||||||
// assume PHY has been hardware strapped properly
|
|
||||||
#if 0
|
|
||||||
uint16_t value;
|
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_REG_BCR, MG_BIT(12));
|
||||||
phy->write_reg(phy_addr, MG_PHY_YT8531_REG_EXT_ADDR, 0xa003);
|
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 = 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));
|
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,
|
phy->write_reg(phy_addr, MG_PHY_YT8531_REG_EXT_DATA,
|
||||||
(uint16_t) (value | MG_BIT(1))); // TXDLY: 2 * 150 ps
|
(uint16_t) (value | MG_BIT(1))); // TXDLY: 2 * 150 ps
|
||||||
#endif
|
|
||||||
} else if (id1 == MG_PHY_DP83x && id2 == MG_PHY_DP83867) {
|
} else if (id1 == MG_PHY_DP83x && id2 == MG_PHY_DP83867) {
|
||||||
phy->write_reg(phy_addr, 0x0d,
|
phy->write_reg(phy_addr, 0x0d,
|
||||||
0x1f); // write 0x10d to IO_MUX_CFG (0x0170)
|
0x1f); // write 0x10d to IO_MUX_CFG (0x0170)
|
||||||
@@ -34597,11 +34596,8 @@ static void mgi_radio_frame_header(uint8_t *frame, uint16_t dst, uint16_t src,
|
|||||||
frame[MGI_RADIO_HDR_LEN] = type, frame[MGI_RADIO_HDR_LEN + 1] = burst;
|
frame[MGI_RADIO_HDR_LEN] = type, frame[MGI_RADIO_HDR_LEN + 1] = burst;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hand a radio frame to the hardware. The interface's fn sees it first
|
|
||||||
static bool mgi_radio_send(struct mg_radio_node *node, const void *frame,
|
static bool mgi_radio_send(struct mg_radio_node *node, const void *frame,
|
||||||
size_t len) {
|
size_t len) {
|
||||||
struct mg_str s = mg_str_n((const char *) frame, len);
|
|
||||||
mg_tcpip_call(node->ifp, MG_TCPIP_EV_PHY_TX, &s);
|
|
||||||
return node->hw_tx(node->ifp, frame, len) == len;
|
return node->hw_tx(node->ifp, frame, len) == len;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35122,12 +35118,10 @@ bool mg_radio_poll(struct mg_tcpip_if *ifp, bool s1) {
|
|||||||
while (node->rx_len == 0 &&
|
while (node->rx_len == 0 &&
|
||||||
(len = mg_queue_next(&node->frames, &record)) != 0) {
|
(len = mg_queue_next(&node->frames, &record)) != 0) {
|
||||||
if (len > MGI_RX_STAMP_LEN) {
|
if (len > MGI_RX_STAMP_LEN) {
|
||||||
struct mg_str s =
|
|
||||||
mg_str_n(record + MGI_RX_STAMP_LEN, len - MGI_RX_STAMP_LEN);
|
|
||||||
uint64_t arrived;
|
uint64_t arrived;
|
||||||
memcpy(&arrived, record, MGI_RX_STAMP_LEN);
|
memcpy(&arrived, record, MGI_RX_STAMP_LEN);
|
||||||
mg_tcpip_call(ifp, MG_TCPIP_EV_PHY_RX, &s);
|
mgi_radio_input(node, arrived, record + MGI_RX_STAMP_LEN,
|
||||||
mgi_radio_input(node, arrived, s.buf, s.len);
|
len - MGI_RX_STAMP_LEN);
|
||||||
}
|
}
|
||||||
mg_queue_del(&node->frames, len);
|
mg_queue_del(&node->frames, len);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4799,8 +4799,6 @@ enum {
|
|||||||
MG_TCPIP_EV_WIFI_CONNECT_ERR, // Wi-Fi connection failed driver and chip specific
|
MG_TCPIP_EV_WIFI_CONNECT_ERR, // Wi-Fi connection failed driver and chip specific
|
||||||
MG_TCPIP_EV_DRIVER, // Driver-defined event driver specific
|
MG_TCPIP_EV_DRIVER, // Driver-defined event driver specific
|
||||||
MG_TCPIP_EV_STATE6_CHANGE, // IPv6 link state changed uint8_t *(&ifp->state6)
|
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_USER // Starting ID for user-defined events
|
MG_TCPIP_EV_USER // Starting ID for user-defined events
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|||||||
+2
-3
@@ -87,16 +87,15 @@ void mg_phy_init(struct mg_phy *phy, uint8_t phy_addr, uint8_t config) {
|
|||||||
|
|
||||||
if (config & MG_PHY_RGMII) {
|
if (config & MG_PHY_RGMII) {
|
||||||
if (id1 == MG_PHY_YT85x && id2 == MG_PHY_YT8531) {
|
if (id1 == MG_PHY_YT85x && id2 == MG_PHY_YT8531) {
|
||||||
// assume PHY has been hardware strapped properly
|
|
||||||
#if 0
|
|
||||||
uint16_t value;
|
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_REG_BCR, MG_BIT(12));
|
||||||
phy->write_reg(phy_addr, MG_PHY_YT8531_REG_EXT_ADDR, 0xa003);
|
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 = 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));
|
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,
|
phy->write_reg(phy_addr, MG_PHY_YT8531_REG_EXT_DATA,
|
||||||
(uint16_t) (value | MG_BIT(1))); // TXDLY: 2 * 150 ps
|
(uint16_t) (value | MG_BIT(1))); // TXDLY: 2 * 150 ps
|
||||||
#endif
|
|
||||||
} else if (id1 == MG_PHY_DP83x && id2 == MG_PHY_DP83867) {
|
} else if (id1 == MG_PHY_DP83x && id2 == MG_PHY_DP83867) {
|
||||||
phy->write_reg(phy_addr, 0x0d,
|
phy->write_reg(phy_addr, 0x0d,
|
||||||
0x1f); // write 0x10d to IO_MUX_CFG (0x0170)
|
0x1f); // write 0x10d to IO_MUX_CFG (0x0170)
|
||||||
|
|||||||
+3
-7
@@ -206,11 +206,9 @@ static void mgi_radio_frame_header(uint8_t *frame, uint16_t dst, uint16_t src,
|
|||||||
frame[MGI_RADIO_HDR_LEN] = type, frame[MGI_RADIO_HDR_LEN + 1] = burst;
|
frame[MGI_RADIO_HDR_LEN] = type, frame[MGI_RADIO_HDR_LEN + 1] = burst;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hand a radio frame to the hardware. The interface's fn sees it first
|
// Hand a radio frame to the hardware.
|
||||||
static bool mgi_radio_send(struct mg_radio_node *node, const void *frame,
|
static bool mgi_radio_send(struct mg_radio_node *node, const void *frame,
|
||||||
size_t len) {
|
size_t len) {
|
||||||
struct mg_str s = mg_str_n((const char *) frame, len);
|
|
||||||
mg_tcpip_call(node->ifp, MG_TCPIP_EV_PHY_TX, &s);
|
|
||||||
return node->hw_tx(node->ifp, frame, len) == len;
|
return node->hw_tx(node->ifp, frame, len) == len;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -731,12 +729,10 @@ bool mg_radio_poll(struct mg_tcpip_if *ifp, bool s1) {
|
|||||||
while (node->rx_len == 0 &&
|
while (node->rx_len == 0 &&
|
||||||
(len = mg_queue_next(&node->frames, &record)) != 0) {
|
(len = mg_queue_next(&node->frames, &record)) != 0) {
|
||||||
if (len > MGI_RX_STAMP_LEN) {
|
if (len > MGI_RX_STAMP_LEN) {
|
||||||
struct mg_str s =
|
|
||||||
mg_str_n(record + MGI_RX_STAMP_LEN, len - MGI_RX_STAMP_LEN);
|
|
||||||
uint64_t arrived;
|
uint64_t arrived;
|
||||||
memcpy(&arrived, record, MGI_RX_STAMP_LEN);
|
memcpy(&arrived, record, MGI_RX_STAMP_LEN);
|
||||||
mg_tcpip_call(ifp, MG_TCPIP_EV_PHY_RX, &s);
|
mgi_radio_input(node, arrived, record + MGI_RX_STAMP_LEN,
|
||||||
mgi_radio_input(node, arrived, s.buf, s.len);
|
len - MGI_RX_STAMP_LEN);
|
||||||
}
|
}
|
||||||
mg_queue_del(&node->frames, len);
|
mg_queue_del(&node->frames, len);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,8 +40,6 @@ enum {
|
|||||||
MG_TCPIP_EV_WIFI_CONNECT_ERR, // Wi-Fi connection failed driver and chip specific
|
MG_TCPIP_EV_WIFI_CONNECT_ERR, // Wi-Fi connection failed driver and chip specific
|
||||||
MG_TCPIP_EV_DRIVER, // Driver-defined event driver specific
|
MG_TCPIP_EV_DRIVER, // Driver-defined event driver specific
|
||||||
MG_TCPIP_EV_STATE6_CHANGE, // IPv6 link state changed uint8_t *(&ifp->state6)
|
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_USER // Starting ID for user-defined events
|
MG_TCPIP_EV_USER // Starting ID for user-defined events
|
||||||
};
|
};
|
||||||
// clang-format on
|
// 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_s3mu.c
|
||||||
SOURCES += cmsis_rt1186/devices/MIMXRT1186/drivers/fsl_trdc.c
|
SOURCES += cmsis_rt1186/devices/MIMXRT1186/drivers/fsl_trdc.c
|
||||||
|
|
||||||
CFLAGS += -D__ATOLLIC__ -D__STARTUP_CLEAR_BSS -DMG_HAL_DISABLE_RANDOM -DMG_HAL_ENABLE_PHY_STRAP
|
CFLAGS += -D__ATOLLIC__ -D__STARTUP_CLEAR_BSS -DMG_HAL_DISABLE_RANDOM
|
||||||
|
|
||||||
all build: firmware.bin
|
all build: firmware.bin
|
||||||
|
|
||||||
|
|||||||
@@ -586,6 +586,9 @@ static inline void hal_netc_pins_init(void) {
|
|||||||
CLOCK_EnableClock(kCLOCK_Iomuxc1);
|
CLOCK_EnableClock(kCLOCK_Iomuxc1);
|
||||||
CLOCK_EnableClock(kCLOCK_Iomuxc2);
|
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_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_pad_config(kIOMUXC_SW_PAD_CTL_PAD_GPIO_AD_30,
|
||||||
HAL_GPIO_OTYPE_PUSH_PULL, HAL_GPIO_SPEED_HIGH,
|
HAL_GPIO_OTYPE_PUSH_PULL, HAL_GPIO_SPEED_HIGH,
|
||||||
@@ -645,27 +648,13 @@ static inline bool hal_netc_ierb_init(void) {
|
|||||||
static inline void hal_ethernet_init(void) {
|
static inline void hal_ethernet_init(void) {
|
||||||
hal_netc_trdc_init();
|
hal_netc_trdc_init();
|
||||||
CLOCK_EnableClock(kCLOCK_Netc);
|
CLOCK_EnableClock(kCLOCK_Netc);
|
||||||
hal_gpio_output(HAL_NETC_PHY0_RESET);
|
hal_netc_pins_init();
|
||||||
hal_gpio_write(HAL_NETC_PHY0_RESET, false);
|
if (!hal_netc_ierb_init()) return;
|
||||||
#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);
|
|
||||||
__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);
|
|
||||||
|
|
||||||
|
hal_gpio_write(HAL_NETC_PHY0_RESET, false);
|
||||||
|
SDK_DelayAtLeastUs(10000U, SYS_FREQUENCY);
|
||||||
|
hal_gpio_write(HAL_NETC_PHY0_RESET, true);
|
||||||
|
SDK_DelayAtLeastUs(150000U, SYS_FREQUENCY);
|
||||||
NVIC_EnableIRQ(MSGINTR1_IRQn);
|
NVIC_EnableIRQ(MSGINTR1_IRQn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -675,4 +664,3 @@ static inline void hal_rng_init(void) {
|
|||||||
static inline uint32_t hal_rng_read(void) {
|
static inline uint32_t hal_rng_read(void) {
|
||||||
return 42;
|
return 42;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8,31 +8,27 @@
|
|||||||
#define LED_LAN PIN(0, 0) // Blue, active low
|
#define LED_LAN PIN(0, 0) // Blue, active low
|
||||||
#define LED_RED PIN(0, 1) // Red, active low
|
#define LED_RED PIN(0, 1) // Red, active low
|
||||||
|
|
||||||
static uint64_t s_radio_led_until;
|
|
||||||
|
|
||||||
// Cumulative totals. Up: radio -> LAN; down: LAN -> radio queue.
|
// Cumulative totals. Up: radio -> LAN; down: LAN -> radio queue.
|
||||||
static uint64_t s_frames_up, s_frames_down, s_bytes_up, s_bytes_down;
|
static uint64_t s_frames_up, s_frames_down, s_bytes_up, s_bytes_down;
|
||||||
static uint64_t s_radio_sent, s_radio_received;
|
|
||||||
|
|
||||||
// Radio interface events: count radio frames, blink on reception
|
// Radio activity: successful frames crossing the bridge keep the LED on.
|
||||||
static void radio_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
static uint64_t s_radio_led_until;
|
||||||
if (ev == MG_TCPIP_EV_PHY_TX) s_radio_sent++;
|
|
||||||
if (ev == MG_TCPIP_EV_PHY_RX) {
|
|
||||||
s_radio_received++;
|
|
||||||
s_radio_led_until = mg_millis() + 2;
|
|
||||||
}
|
|
||||||
(void) ifp, (void) ev_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
static size_t eth_up(const void *buf, size_t len, struct mg_tcpip_if *ifp) {
|
static size_t eth_up(const void *buf, size_t len, struct mg_tcpip_if *ifp) {
|
||||||
size_t sent = mg_tcpip_driver_rw612.tx(buf, len, ifp);
|
size_t sent = mg_tcpip_driver_rw612.tx(buf, len, ifp);
|
||||||
if (sent != 0) s_frames_up++, s_bytes_up += sent;
|
if (sent != 0) {
|
||||||
|
s_frames_up++, s_bytes_up += sent;
|
||||||
|
s_radio_led_until = mg_millis() + 2;
|
||||||
|
}
|
||||||
return sent;
|
return sent;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t eth_down(const void *buf, size_t len, struct mg_tcpip_if *ifp) {
|
static size_t eth_down(const void *buf, size_t len, struct mg_tcpip_if *ifp) {
|
||||||
size_t queued = mg_tcpip_driver_rw612w.tx(buf, len, ifp);
|
size_t queued = mg_tcpip_driver_rw612w.tx(buf, len, ifp);
|
||||||
if (queued != 0) s_frames_down++, s_bytes_down += queued;
|
if (queued != 0) {
|
||||||
|
s_frames_down++, s_bytes_down += queued;
|
||||||
|
s_radio_led_until = mg_millis() + 2;
|
||||||
|
}
|
||||||
return queued;
|
return queued;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +62,6 @@ int main(void) {
|
|||||||
radio_driver = mg_tcpip_driver_rw612w;
|
radio_driver = mg_tcpip_driver_rw612w;
|
||||||
radio_driver.tx = eth_down;
|
radio_driver.tx = eth_down;
|
||||||
radio.driver = &radio_driver;
|
radio.driver = &radio_driver;
|
||||||
radio.fn = radio_fn;
|
|
||||||
if (!radio.driver->init(&radio)) return 1;
|
if (!radio.driver->init(&radio)) return 1;
|
||||||
|
|
||||||
eth_data.mdc_cr = MG_DRIVER_MDC_CR;
|
eth_data.mdc_cr = MG_DRIVER_MDC_CR;
|
||||||
@@ -95,9 +90,8 @@ int main(void) {
|
|||||||
if (mg_timer_expired(&stats_timer, 5000, now)) {
|
if (mg_timer_expired(&stats_timer, 5000, now)) {
|
||||||
MG_INFO(
|
MG_INFO(
|
||||||
("ETH frames up/down %llu/%llu, bytes up/down "
|
("ETH frames up/down %llu/%llu, bytes up/down "
|
||||||
"%llu/%llu, radio frames sent/rcvd %llu/%llu",
|
"%llu/%llu",
|
||||||
s_frames_up, s_frames_down, s_bytes_up, s_bytes_down, s_radio_sent,
|
s_frames_up, s_frames_down, s_bytes_up, s_bytes_down));
|
||||||
s_radio_received));
|
|
||||||
}
|
}
|
||||||
if (eth.nrecv != lan_received) {
|
if (eth.nrecv != lan_received) {
|
||||||
lan_received = eth.nrecv;
|
lan_received = eth.nrecv;
|
||||||
|
|||||||
Reference in new issue
Block a user