-
Notifications
You must be signed in to change notification settings - Fork 3k
Feature emac lpc546xx #6810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature emac lpc546xx #6810
Conversation
cc @maclobdell @0xc0170 @kjbracey-arm |
Hi @mmahadevan108 , great to see this PR coming. Did you run netsocket and emac greentea tests already? Regards, |
7821aaa
to
86d4f33
Compare
I have rebased this PR. Yes, I ran the netsocket and network-emac tests. |
@mmahadevan108 Would you mind posting those logs? /morph build |
Build : SUCCESSBuild number : 1939 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 1586 |
Test : FAILUREBuild number : 1761 |
@mmahadevan108 Please review the failures, related to the changes |
I am unclear why the failures are seen. All tests pass with ARM tool chain. One test failure seen with GCC_ARM and more with IAR. Is there a toolchain specific configuration I need to pay attention to in the new ENET frameowork? |
I was debugging the failure with IAR and see the it is failing to get the below semaphore during bringup Any idea why? |
@mmahadevan108 did you run the tests with an echo server on the network? I just noticed that the tests might pass if an echo server is not running, but will fail otherwise. |
I was debugging the gethostbyname test under netsocket. This is failing in the mbed-ci for IAR and GCC_ARM but passes for ARM. All tests pass in mbed-ci for the ARM toolchain. |
86d4f33
to
9660393
Compare
I rebased your LPC546XX commits on top of Mika’s branch referenced in #6851. I had to add an additional commit to add “EMAC” and “ETHERNET” to the device_has list in targets.json. I ran the tests and the broadcast test is failing. At your earliest convenience, please test it out. If you have any questions or comments please contact me. Initial results:
|
@maclobdell I am seeing issues acquiring a semaphore. I am not clear if I am missing something in my code. I have highlighted this above, any suggestions. |
@mikaleppanen Please see issue acquiring semaphore that Mahesh highlighted. Let us know if you have any suggestions. |
The semaphore here: waits for the LWIP stack DHCP negotiation to complete, so failing to acquire the semaphore indicates that there could be any problem in IP message transfer. Can you acquire logs from wire to see in what phase the negotiation fails. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added two comments based on greentea testing.
ENET_ALIGN(ENET_ETH_MAX_FLEN, ENET_BUFF_ALIGNMENT), | ||
}; | ||
|
||
ENET_Init(ENET, &config, hwaddr, refClock); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the new emac interface power_up() mac address is not yet set at this point so it contains null string. At old lwip driver interface it was valid already at this point. On new emac, mac is written by network stack to emac after the power_up() with void set_hwaddr() call.
We are having test case failures (at least with IAR) where the device does not receive messages sent to its mac address.
Could you check that mac address configuration works as expected. Just was testing purposes, we changed code so that mac is valid already here and the driver worked. But that cannot be a solution in new emac since mac written later using the set_hwaddr().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it seems like you should be passing NULL
here rather than hwaddr
, so ENET_Init
doesn't try programming the MAC address yet.
Not sure what the other test failures were.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One option is to use the mbed_mac_address() call to set the address to hwaddr before the ENET_Init call.
update_read_buffer(bdPtr, NULL); | ||
} else { | ||
if (bdPtr->control & ENET_RXDESCRIP_WR_LD_MASK) { | ||
length = (bdPtr->control & ENET_RXDESCRIP_WR_PACKETLEN_MASK); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When testing, we are seeing here that the length here is 4 bytes more than expected. Also with incoming message with 1500 bytes long payload there is a buffer tail overwrite of the received emac_mem_buf_t. Could you check the length handling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't see an issue with this code. I need to debug more why this is happening.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The datasheet says that the packet written to the buffer includes the CRC, and the length in this descriptor reflects that.
You just need to subtract 4, as far as I can see, as we want the packet length including MAC header, but excluding CRC. (You or the hardware are assumed to have checked and stripped the CRC - the hardware here has checked it but not stripped it.)
|
||
void LPC546XX_EMAC::add_multicast_group(const uint8_t *addr) | ||
{ | ||
/* No-op at this stage */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When testing with greentea, driver did not pass multicast packets to network stack. You should add set_all_multicast(true) call here, so in case network stack configures multicast (i.e. is ipv6 capable) multicast filtering is disabled.
Any progress here? |
@mmahadevan108 - please let us know if these suggested updates work for you. |
Signed-off-by: Mahesh Mahadevan <[email protected]>
Signed-off-by: Mahesh Mahadevan <[email protected]>
@mmahadevan108 ^^^ |
9660393
to
fa72cde
Compare
I have updated the PR to include the call for set_all_multicast(true); inside add_multicast_group() function. I am not clear why we are seeing the length issue. |
On the MAC address, the problem is due to an error in the driver code for mbed-os/targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_LPC546XX/drivers/fsl_enet.h Line 678 in 4b72158
The
Swapping the order has made it work here. |
The remaining issue is the memory buffer tail overwrite. We've not run the tests yet, but I believe the issue is that you are configuring the hardware buffer size to But you're only actually allocating |
I've applied the 3 fixes I describe to the combined PR here #6936 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved, with the 3 changes I've applied on the combined test PR. Passing tests here.
Merged via #6936 |
ENET support for LPC546XX boards