From 459d783c961088d8c6d53443e0a6fdfef976c11d Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Thu, 29 Jan 2026 21:23:37 +0100 Subject: [PATCH] fixes wrong allocation in mnrs network driver --- port/moonlight/mnrs_network_driver.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/port/moonlight/mnrs_network_driver.c b/port/moonlight/mnrs_network_driver.c index 140405b..d97c69e 100644 --- a/port/moonlight/mnrs_network_driver.c +++ b/port/moonlight/mnrs_network_driver.c @@ -930,11 +930,14 @@ VOID _nx_mnrs_eth_recv_packet(UINT id, volatile ethmac_t* ethmac){ bit_size = get_ethmac_mac_rx(ethmac); word_size = (bit_size+31)/32; byte_size = (bit_size+7)/8; - if(word_size<4){ + if(word_size<4) + { set_ethmac_mac_intr_rx_data_avail_intr_enable(ethmac, 1); return; } - for( i = 0;i < 4;i++){ + // read the first 14 bytes to get from and to mac (6bytes each) and the frame type/length + for( i = 0;i < 4;i++) + { while(!get_ethmac_mac_ctrl_rx_pending(ethmac)) ; // be carefull of unaligned accesses @@ -945,12 +948,13 @@ VOID _nx_mnrs_eth_recv_packet(UINT id, volatile ethmac_t* ethmac){ to_mac.nx_mac_address_lsw=(buffer[2]<<24) + (buffer[3]<<16) + (buffer[4]<<8) + buffer[5]; from_mac.nx_mac_address_msw=(buffer[6]<<8) + buffer[7]; from_mac.nx_mac_address_lsw=(buffer[8]<<24) + (buffer[9]<<16) + (buffer[10]<<8) + buffer[11]; - // _tx_thread_context_save(); + // find the diver instance belonging to our ethmac for(i=0; inx_ip_default_packet_pool, - &packet_ptr, word_size*4 /*NX_RECEIVE_PACKET*/, NX_NO_WAIT); + &packet_ptr, NX_RECEIVE_PACKET, NX_NO_WAIT); if (status) { packet_ptr = NX_NULL; @@ -964,8 +968,9 @@ VOID _nx_mnrs_eth_recv_packet(UINT id, volatile ethmac_t* ethmac){ { data = nx_mnrs_receive_buffer; } - /* read the data from the rx buffer */ + /* read the data from the rx buffer into the packet pointer or our frame buffer */ memcpy(data, buffer, 16); + /* now get the remaining bytes from the ethmac peripheral */ for( i = 4;i < word_size;i++){ while(!get_ethmac_mac_ctrl_rx_pending(ethmac)) ; @@ -1049,7 +1054,6 @@ VOID _nx_mnrs_eth_recv_packet(UINT id, volatile ethmac_t* ethmac){ nx_packet_release(packet_ptr); } } - // _tx_thread_context_restore(); set_ethmac_mac_intr_rx_data_avail_intr_enable(ethmac, 1); }