ENC28J60: add missing end() required by LwipIntfDev - #9323
Open
cl445 wants to merge 1 commit into
Open
Conversation
LwipIntfDev<RawDev> calls RawDev::end() from LwipIntfDev::end() and from the two error paths of LwipIntfDev::begin(). Wiznet5500 provides end(), ENC28J60 does not, so LwipIntfDev<ENC28J60> - i.e. ENC28J60lwIP - no longer compiles: LwipIntfDev.h:280:20: error: 'end' is not a member of 'ENC28J60' LwipIntfDev.h:294:24: error: 'end' is not a member of 'ENC28J60' The calls came in with esp8266#9023, which only touched cores/esp8266/LwipIntfDev.h. Wiznet5500::end() closes socket 0 and leaves the chip powered and configured, since a following begin() resets and reopens it anyway. The ENC28J60 equivalent of closing the socket is clearing ECON1.RXEN, the bit that reset() sets last to enable reception. ECON1 is mapped into every bank, so no bank switch is needed, and no frame can be in flight because sendFrame() polls ECON1.TXRTS until the frame has left.
cl445
force-pushed
the
fix/enc28j60-end
branch
from
August 15, 2026 13:08
56cddec to
b01e7d0
Compare
cl445
marked this pull request as ready for review
August 15, 2026 13:08
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LwipIntfDev<RawDev>callsRawDev::end()inLwipIntfDev::end()and in the two error paths ofLwipIntfDev::begin()(netif_add failure,dhcp_start()returningERR_IF).Wiznet5500providesend(),ENC28J60does not, soLwipIntfDev<ENC28J60>(i.e.ENC28J60lwIP) no longer compiles:The calls were introduced in #9023 ("LwipIntfDev - method end() to enable repeated begin"), which only touched
cores/esp8266/LwipIntfDev.h. The ENC28J60 driver was not updated at the time.It showed up in firmware that instantiates both
ENC28J60lwIPandWiznet5500lwIPand selects the interface at runtime: the W5500 translation unit builds, the ENC28J60 one does not.Wiznet5500::end()closes socket 0, clears the socket interrupt flags and waits forSOCK_CLOSED. It stops the data path but leaves the chip powered and configured, because a followingbegin()performs a software reset and reopens the socket anyway. The ENC28J60 equivalent of "close the socket" is clearingECON1.RXEN, the bit thatENC28J60::reset()sets as the last step of initialization to enable reception.ECON1is mapped into all banks, so no bank switch is required, and no transmission can be in flight becausesendFrame()pollsECON1.TXRTSuntil the frame has left.A full software reset (SPI command
0xFF) was considered. It goes beyond whatWiznet5500::end()does, and it would have to carry the erratum #2 delay of at least 1 ms before the chip may be accessed again. Sincebegin()already issues a software reset viareset(), the reset inend()adds nothing, so the minimal variant is used. Happy to switch if a hard reset inend()is preferred.With this change
ENC28J60lwIPcompiles again and the repeated-begin()behaviour intended by #9023 also works for the ENC28J60.Testing
Built a firmware that instantiates both drivers against this branch. Without the patch it stops with the two errors above; with it the same build links successfully (RAM 50.8 %, flash 58.5 %). clang-format with
tests/clang-format-core.yamlleaves both files unchanged.Not yet verified on hardware: calling
end(), thenbegin(), then passing traffic on a real ENC28J60.