Powering down Ethernet PHY breaks debugging [LPC4088]

20 Feb 2018

Please excuse the cross-post, but I think it's appropriate in this case, as these are different forums with some different expertise.


I need to power down the Ethernet PHY on my Embedded Artists' LPC4088QSB (QuickStart Board), in order to reduce the current draw. I've got some code which seems to do it, and reduces the current draw by (very) roughly 40 mA. But executing this code breaks debugging in a very strange way.

I'm using Mbed OS 5.7.5, exporting with Mbed CLI, importing into MCUXpresso.

Here is my test code where I demonstrate the issue: GitHub - bmcdonnell-ionx/eth-dbg-issue

Is this the right way to power down the PHY? Why is it breaking debugging, and how can I fix it? Details follow.

Problem Description

The problem goes like this:

Once phy_write(PHY_REG_BMCR, PHY_BMCR_PWR_DOWN); is called in main.cpp, and then after a reset or power-cycle, and after the code gets past the first for loop in ethernet_init(), you will no longer be able to debug. (i.e. The debugger can't halt the micro anymore, so you can't single step, "run to", or the like.) This issue persists even after reset or power cycle. (Meaning you lose the ability to halt the micro once you pass that place inside ethernet_init().)

The only way I've found to fix the issue is as follows:

  • Power cycle the board so that you'll be able to halt the micro again (initially).
  • Erase the micro flash.
  • Power cycle the board again.
  • Now you'll be able to debug normally - until you pass that phy_write() call again.

I tried debugging with the on-board debugger, and with a separate LPC-Link2; results were the same.

The issue presents itself in all three of the commits in the repository now. (If you use the most recent, you may need to change the place to "Stop on startup" in Run -> Debug Configurations... -> Debugger tab.)

Project Setup


At the command prompt:

   mbed import https://github.com/bmcdonnell-ionx/eth-dbg-issue.git  
   cd eth-dbg-issue
   mbed export -m LPC4088 -i mcuxpresso


   git clone https://github.com/bmcdonnell-ionx/eth-dbg-issue.git  
   cd eth-dbg-issue
   mbed deploy
   mbed export -m LPC4088 -i mcuxpresso

Then in MCUXpresso, import the project from the filesystem.