-
Notifications
You must be signed in to change notification settings - Fork 7.7k
drivers: eth_mcux: adding i.mx-rt support #10875
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #10875 +/- ##
==========================================
+ Coverage 48.37% 48.41% +0.04%
==========================================
Files 265 270 +5
Lines 42188 42121 -67
Branches 10137 10139 +2
==========================================
- Hits 20408 20394 -14
+ Misses 17703 17645 -58
- Partials 4077 4082 +5
Continue to review full report at Codecov.
|
drivers/ethernet/eth_mcux.c
Outdated
int irq_lock_key = irq_lock(); | ||
|
||
|
||
if (EIR & (kENET_RxBufferInterrupt | kENET_RxFrameInterrupt)) |
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.
This does not follow Zephyr coding style. Please place { in the same line as the if() statement like this
if (xxx) {
} else if () {
} else {
}
drivers/ethernet/eth_mcux.c
Outdated
|
||
irq_unlock(irq_lock_key); | ||
} | ||
#endif //CONFIG_SOC_SERIES_IMX_RT |
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.
No // comments
8b61c82
to
17cf8fd
Compare
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.
LGTM, but please check the issues sanitychecker is reporting at https://app.shippable.com/github/zephyrproject-rtos/zephyr/runs/25592/5/tests
#endif | ||
|
||
return 0; | ||
} | ||
|
||
SYS_INIT(mimxrt1050_evk_init, PRE_KERNEL_1, 0); | ||
SYS_INIT(mimxrt1050_evk_init, PRE_KERNEL_2, 0); |
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.
Curious, why the change to PRE_KERNEL_2
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.
Pushed pin initialization later so i can use k_busy_wait to reset ethernet PHY chip.
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.
Does a similar change need to be made on frdm_k64f?
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.
K64F doesn't need this change, PHY is similar, a bit different and differently wired.
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.
Can you fixup the white space issues that checkpatch is reporting
Also, can you add more details about what changes you are making to the ethernet driver itself to support i.MX-RT (i'd pull these changes out into their own commit).
From commit message:
Please fix typo in "Newtworking". And the commit message is very bare. Even description of the PR here more detailed than the commit message, even though the commit message is what goes into posterity (into git log, git bisect, etc.). At the very least, it could mention that existing eth_mcux driver is reused for this hardware (which is not obvious and pleasantly (I hope) surprising fact for me). (Note that "more detailed commit message" is my usual suggestion to pretty big share of patches I review.) |
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.
Some suggestions from my side too. At least splitting off ext/ change to a separate commit should be done. (Unless overridden by @galak, @MaureenHelm or someone else in the know.)
if NETWORKING | ||
|
||
config NET_L2_ETHERNET | ||
def_bool y if !MODEM_WNCM14A2A |
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.
Is this truly a good idea here?
boards/arm/mimxrt1050_evk/pinmux.c
Outdated
IOMUXC_SW_PAD_CTL_PAD_PKE_MASK | | ||
IOMUXC_SW_PAD_CTL_PAD_SPEED(2) | | ||
IOMUXC_SW_PAD_CTL_PAD_DSE(6)); | ||
IOMUXC_SW_PAD_CTL_PAD_PKE_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.
So, in such cases, Zephyr codestyle requires to align args "in column", using tabs for as long as possible, then spaces. In other words, what was before seems to be right. Also, IMHO, codestyle changes should be separated from functional changes. YMMV
boards/arm/mimxrt1050_evk/pinmux.c
Outdated
#endif | ||
|
||
#ifdef CONFIG_ETH_MCUX_0 | ||
IOMUXC_SetPinMux(IOMUXC_GPIO_B1_04_ENET_RX_DATA00, 0U); |
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.
Why do we have uppercase "U" here and "u" below?
Also, so far Zephyr doesn't use that "suffixed U" style. (So far, yes).
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.
Please make the driver changes in a separate commit from the soc and board changes.
boards/arm/mimxrt1050_evk/pinmux.c
Outdated
#include <fsl_gpio.h> | ||
|
||
#ifdef CONFIG_ETH_MCUX_0 | ||
gpio_pin_config_t enet_gpio_config = { |
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.
Dedent this block and make the variable static const.
GPIO_PinInit(GPIO1, 9, &enet_gpio_config); | ||
GPIO_PinInit(GPIO1, 10, &enet_gpio_config); | ||
|
||
/* pull up the ENET_INT before RESET. */ |
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.
Please add to the comment that you're resetting the PHY
#endif | ||
|
||
return 0; | ||
} | ||
|
||
SYS_INIT(mimxrt1050_evk_init, PRE_KERNEL_1, 0); | ||
SYS_INIT(mimxrt1050_evk_init, PRE_KERNEL_2, 0); |
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.
Does a similar change need to be made on frdm_k64f?
drivers/ethernet/eth_mcux.c
Outdated
@@ -932,6 +951,30 @@ static void eth_mcux_ptp_isr(void *p) | |||
} | |||
#endif | |||
|
|||
#ifdef CONFIG_SOC_SERIES_IMX_RT |
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'd like to avoid direct dependencies on the SoC like this. If you add interrupt-names = "COMMON"
to the dts, you can make this condition #ifdef ETH_IRQ_COMMON
instead.
drivers/ethernet/eth_mcux.c
Outdated
} | ||
#endif /* CONFIG_SOC_SERIES_IMX_RT */ | ||
|
||
#ifdef CONFIG_SOC_SERIES_KINETIS_K6X |
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.
Change this to #ifdef ETH_IRQ_RX
and wrap the other isr's similarly with #ifdef ETH_IRQ_TX
and #ifdef ETH_IRQ_ERR_MISC
drivers/ethernet/eth_mcux.c
Outdated
#if CONFIG_SOC_SERIES_IMX_RT | ||
IRQ_CONNECT(ENET_IRQn, CONFIG_ETH_MCUX_0_IRQ_PRI, | ||
eth_mcux_dispacher_isr, DEVICE_GET(eth_mcux_0), 0); | ||
irq_enable(ENET_IRQn); |
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.
Use the irq number from dts instead of CMSIS
f3e7f81
to
f41267f
Compare
drivers/ethernet/eth_mcux.c
Outdated
@@ -33,7 +33,9 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME); | |||
|
|||
#include "fsl_enet.h" | |||
#include "fsl_phy.h" | |||
#ifdef CONFIG_SOC_SERIES_KINETIS_K6X | |||
#include "fsl_port.h" |
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.
Is this include needed at all?
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.
It was needed in case of unique mac, SIM definition was not included.
No longer required.
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.
Let's remove it then
dts/arm/nxp/nxp_rt.dtsi
Outdated
@@ -30,15 +30,15 @@ | |||
#size-cells = <1>; | |||
|
|||
itcm0: itcm@0 { | |||
reg = <0x00000000 0x20000>; | |||
reg = <0x00000000 0x80000>; |
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.
This doesn't make sense. We have 512 KB SRAM that gets partitioned into ITCM, DTCM, and OCRAM. They can't all be 512 KB.
Rather than changing these partitions, we need to add a min_flash
and/or min_ram
requirement to the failing sample/test yaml.
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.
My bad, i just looked at memory map and not FlexRam.
Thank you for yaml suggestion.
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.
Looks pretty good. I still need to test on hardware
drivers/ethernet/eth_mcux.c
Outdated
@@ -33,7 +33,9 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME); | |||
|
|||
#include "fsl_enet.h" | |||
#include "fsl_phy.h" | |||
#ifdef CONFIG_SOC_SERIES_KINETIS_K6X | |||
#include "fsl_port.h" |
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.
Let's remove it then
@@ -33,9 +33,6 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME); | |||
|
|||
#include "fsl_enet.h" | |||
#include "fsl_phy.h" | |||
#ifdef CONFIG_SOC_SERIES_KINETIS_K6X | |||
#include "fsl_port.h" |
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.
Move this change to the previous commit
@@ -15,3 +15,4 @@ ram: 128 | |||
flash: 128 | |||
supported: | |||
- spi | |||
- netif:eth |
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.
Could you also update the board doc to reflect that ethernet is now supported?
59c501b
to
d3dc1c0
Compare
61dd607
to
45fc2dc
Compare
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.
+1 for doc changes
I don't think it needs its own commit |
@pfalcon still have issues? |
Dismissed my -1, sorry, completely forgot I had it there. (Submitters, feel free to ping reviewers in such cases.) |
soc/arm/nxp_imx/rt/dts_fixup.h
Outdated
@@ -41,4 +41,13 @@ | |||
#define DT_UART_MCUX_LPUART_3_CLOCK_NAME DT_NXP_KINETIS_LPUART_4018C000_CLOCK_CONTROLLER | |||
#define DT_UART_MCUX_LPUART_3_CLOCK_SUBSYS DT_NXP_KINETIS_LPUART_4018C000_CLOCK_NAME | |||
|
|||
#define DT_ETH_MCUX_0_NAME ETH_LABEL |
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.
Would prefer to see this be:
#define DT_ETH_MCUX_0_NAME DT_NXP_KINETIS_ETHERNET_402D8000_LABEL
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.
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.
Sadly, I don't have much to be thanked for - it's on my TODO to test this patch on real hw, but unfortunately I can't to it due to other tasks I got into. I just hope that other folks tested it. (I'll get to it to of course.)
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.
It's taking me some time to test i.MX RT and backward checking K64F, this i why I didn't ping earlier. Patch looks okay so far.
Enables Networking hardware on i.MX-RT type drivers. Reuses the same eth_mcux driver used by Kinetis family; initialization sequence refactored to work with this board as well. Unlike Kinetis family, i.MX has a single ENET interrupt and we need to discriminate between interrupts using a status register. Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
Enables Networking hardware on i.MX-RT 1050-EVKB board. Pinout enabled board specific etherenet connection, also pin initialization was moved later to PRE_KERNEL_2 in order to have sysclock initialized before. Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
In order to prevent failing tests on i.MX RT the following samples were limited to a minimum 140k of flash: http_client, http_server, socket/echo_client and sockets/echo_server. Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
Board documentation updated with Networking related infomation. Signed-off-by: Andrei Gansari <andrei.gansari@nxp.com>
@agansari : FYI, I'm very, very close to help with testing this (at least on frdm_k64f). I actually hoped to do this today, but as usually happens, discovered a trail of regressions on approaching that. For you reference, my standard test plans are described in https://github.com/pfalcon/zephyr/wiki/NetworkingTestPlan (again, they don't work with current master, and require patches - new and old). |
Ok, testing: frdm_k64f with samples/net/sockets/dumb_http_server, master 57a6858 + this patch + #7831, as required for reliable frdm_k64f operation (not related to the changes in this PR in any way, master is broken).
|
Ok, now frdm_k64f + big_http_download: First iteration went ok:
It seems to be even faster with this patch ;-). (I'm kidding, it's as slow as usual. In all fairness, I don't add d/l speed calculation to not scare off people.) But on 2nd iter:
Well, that unlikely has anything to do with the driver changes, and should be a transient error. |
Ok, as there're no regressions with frdm_k64f, let me approve this. Otherwise, I of course take a chance to bootstrap me with mimxrt1050_evk testing. |
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.
Tested on frdm_k64f
@pfalcon i.MX RT will have some issues, some samples are too big for iTCM memory, but thye will run if they fit. |
Well, that's definitely the aim various parties want to achieve, e.g. I know that NXP has some internal system (@dleach02 told), on Linaro level we want to integrate more HW testing into mostly barebones testing, Zephyr recently added real-board testing into its "sanitycheck" testsuite. But what can I say more if the current situation is that mainline has networking stack setting which semi-break frmd_k64f (#7831), and for half a year (it's actually longer than that) it can't come to resolution? All in all, before we'll be able to run tests automatically, we need to get used to run tests consistently manually. And https://github.com/pfalcon/zephyr/wiki/NetworkingTestPlan is my modest contribution towards that. |
@MaureenHelm, on https://www.nxp.com/support/developer-resources/run-time-software/i.mx-developer-resources/i.mx-rt1050-evaluation-kit:MIMXRT1050-EVK?tab=In-Depth_Tab (which is click away from "MIMXRT1050-EVK Website" link in https://docs.zephyrproject.org/latest/boards/arm/mimxrt1050_evk/doc/mimxrt1050_evk.html), clicking on "ARM mbed" pane leads to https://os.mbed.com/platforms/FRDM-KW41Z/ , instead of https://os.mbed.com/platforms/MIMXRT1050-EVK/ . Let me know if I should submit this issue in another way ;-). |
@agansari, Maybe you can confirm something to me. So, when I work with a board which has mbed bootloader, I usually follow the least-resistance way, and just copy zephyr.bin files to mass-storage device the said bootloader offers. So far, that doesn't work with mimxrt1050_evk. Symptoms are as described here: https://community.nxp.com/thread/486834 , and I wonder if that reply nails:
Did you ever use the I.MXRT1050 in mbed-like way? |
@pfalcon I only used j-link debugging, haven't tried mbed bootloader, let me test that. |
@agansari: Ok, "mystery" solved. With default-as-shipped mbet bootloader, there's no jlink support. After jlink firmware installed, there's no mbed flash-drive any longer. I was able to get hello_world running all in all. Will continue with eth testing tomorrow. And hope to submit update to the board doc. |
@agansari : So far, bad news - no response from Eth on imxrt, nothing in stats after pings. What I noticed is that both LEDs on Eth jack always light up for me, even without cable. And they never blink. Do you have the same? And just reinsuring - I didn't see all the jumpers on the board being described in user guide. I don't need change any jumpers, do I? |
@pfalcon yes, the leds light up from the begining, but they blink on pings for example. There is no need for jumpers or deep switches changes. |
Ok, let's continue in #11586 |
Enables Networking hardware on i.MX-RT 1050-EVKB board.
Fixes #8900
Signed-off-by: Andrei Gansari andrei.gansari@nxp.com