Raspberry Pi Restarts After MightHat Shutdown

Started by dmaxwell, January 26, 2016, 01:28:02 AM

dmaxwell

I just received a MightyHat and built it over the weekend, but I'm having a problem with it.  It starts and restarts the Raspberry Pi okay, but when I do a shutdown, the Pi immediately restarts after shutdown. 

I see in the console logs that the restart and shutdown commands are recognized.

When I press and hold the Power button to start the shutdown, it turns red and pulses.  The Shutoff light comes on, and eventually the Boot Ok, Shutdown, and Power Button lights go out.  Then the Pi Activity LED starts flashing again and eventually the Boot Ok light turns back on and I can SSH into the Pi.  The Power button remains unlit, but the Raspberry Pi is up and active.

I've noticed that I have a lot of random flickering on the charge light, in case this is significant.

I've tried shutdowns with and with out a Lipo Battery connected and on more than one Raspberry Pi.  I also tried using an ATXRaspi instead of the MightyHat, which works fine.

I used your Gateway Raspberry Pi image and I loaded the MightyHat sketch from the RFM69 examples.

Can you think of anything else I should check?

Thanks.

Felix

Just to make sure, you only hold the button until the red/fading comes on then let it go, right?
After it cuts power off it should not start it again without you pressing the main power button again. The logic for that is in the sketch so its pretty obvious that should not happen.
Do you have anything else attached to your Pi that might source/drain power in any way?
Is this an R2?
Any chance for some detailed photos of your setup?

dmaxwell

#2
Correct, I'm releasing the power button as soon as it turns red.  I never see the power light on the Raspberry Pi go out after the shutdown. 
I've tried this with both a Raspberry Pi Model B+ and a Raspberry Pi Model 2.
I don't have anything else connected and don't have an LCD on the board.  There wasn't a reset button in the kit, so there's no reset button on the board either.
I'm attaching photos in the next several posts.  Let me know if there's a different angle or a particular spot you want to see more closely.
I don't see any obvious shorts on the GPIO pins.
I'm using a 5 volt, 2 Amp power supply from Adafruit, which is plugged into the micro USB jack of the MightyHat.  The power and the wireless USB dongle are the only external devices connected.

Thanks again for your help.
Imgur album here.






Felix

Everything looks good to me. How does the green "5V*ON" LED in the upper left corner above the power button behave? What does it do after power is supposed to be off?

dmaxwell

The 5V*ON LED stays on after shutdown. 

When I first plug the power into the Micro USB port, it's off.  But once I press the Power Button to start the Raspberry Pi, it stays on during and after shutdown and remains on until I disconnect the power from the Micros USB port.

Felix

Weird, it almost sounds like it's a reboot, but from your description of the behavior of the MHat it sounds like a shutdown (as opposed to a reboot) was performed except power it not cut off.
However if you can still SSH into your Pi that almost leads me to believe you are in fact doing a reboot.
Note that a short press will trigger a reboot. A long press (2sec+) will issue a shutdown. The idential behavior can be seen in the atxraspi video:
https://www.youtube.com/watch?v=w4vSTq2WhN8

Since this MHat was fully tested for all the expected functions I would be very surprised if there was anything wrong with it, unless I overlooked something during testing. However if the MHat can turn the power ON then I sure expect it to be able to turn it off since the output power it's controlled via a atmega328 pin.

Can you post a link to the exact code you're loading (less your radio settings) that you loaded the MHat with, there were some changes recently, I want to make sure it's the latest. Or attach it to a post here.

dmaxwell

The shutdown does seem to behave like a reboot, only when I go through the shutdown, the power button is turned off at the end, while the Raspberry Pi restarts.  The 5V*ON LED never goes out.

I also tried the force shutdown, holding the power button down for over 10 seconds.  The power button goes out (not glowing), but the 5V*ON LED remains on and eventually the BootOK LED comes back on after the Pi has restarted.

I'm attaching my sketch, with my encryption key and network ID changed.  I'm using Arduino 1.6.7, with the Moteino boards loaded and "Moteino" selected as the target.

I don't know if this is significant, but the sketch includes the code for the LCD, even though I don't have an LCD installed.

Felix

I would at the very least comment out the ENABLE_LCD since you don't use it.
Let me sleep over it maybe I get ideas how to further debug.
In the meantime see attached test sketch I use to test the IO of the MightyHat to ensure the pins all work. This should blink the "5V*ON" LED on off. If that doesn't then there's an issue.
If you want to try this sketch make sure it's not connected to the Pi or any other load, just plug the FTDI as a power source. I test the 5V* output with a power resistor that slowly heats up to simulate a load. But regardless if there is any load, the 5V* LED should blink, which proves the atmega can control the board 5V output via the latch and power path. So that's exactly what we need to debug/test in your case. FWIW it also blinks most other IO also. So give this a try if you can also, and let me know how it behaves.

dmaxwell

I think it must be a problem with my sketch, since the test sketch seems to work.  These are my observations, with the MightyHat removed from the Raspberry Pi in all cases.


  • With the test sketch powered only by the FTDI cable, the green LEDs in the Power button, the 5V*ON, and the Shutdown LEDs all blink on and off.  The Boost LED is on continuously.

  • I plugged in the Micro USB to provide power and the lights continued to blink as before.

  • As a final test, I unplugged the FTDI cable, and the lights still blinked as before.

I'll comment out the #define for enabling the LCD and correct the resulting compile errors next.  I'll post again with my results.

Thanks for the test sketch.   

Felix

That sounds good. So the sketch has the ability to control the 5V* output which means something else is going on somewhere (most likely in code). Maybe the delay of the latch has to be increased, look in the POWER() function, try increasing the delay, double it perhaps, although the latch is CMOS and even 1ms should be plenty.
The boost LED should always be ON (bright green). That indicates that the onboard booster is working. However when you only provide FTDI as power source, that also is connected to the boost LED so it will be ON although the booster is not active. Maybe the boost label should be changed to avoid any confusion, or even break the two apart so boost LED only lights up when battery/USB power is present, perhaps in a future revision. But I do kind of like that LED to be on always when plugged in to show that there's at least power to the board. So far nobody expressed any confusion about it.

dmaxwell

I confirmed it was a problem with the LCD not being physically present when it was enabled in the code.

I revised my sketch to add a few more #ifdef's to filter out the parts that were no longer declared and the MightyHat works as expected with this new sketch.  I didn't need to change any delay values.  My revised sketch is attached.

FWIW, I agree that it's good to have a least 1 LED on to show the board has some power (Boost LED). 

Just curious, do you have any of the LCDs in stock?  The LCD wasn't an available option when I ordered my MightyHat and I don't see the LCD as a separate item to buy.

Thanks again for all your help!  Your work is fantastic and I love all the great info you post on the web!  I'll be buying more stuff from you soon.

spambake

I haven't done any troubleshooting yet but my MightyHat with an LCD attached is exhibiting the same behavior of rebooting after a shutdown button press.  The LCD says "the PI is now off" even though it has rebooted. 

The reboot button press works as expected.

I received the MightyHat about a week ago and installed the V8 gateway image and the default MightyHat sketch adjusted for 433mhz.

I'll take a closer look when I have the time.

Felix

dmaxwell,
Ok so it sounds like your situation is resolved. Thanks for the update. I have LCDs in stock now yes but not as a separate product.
If you want to order one, just please use the virtual product, pick the $5 value and specify this is for a Nokia LCD.

spambake, please try dmaxwell's revised sketch and let me know what you find. Once we have more consensus I can update the sketch if there's indeed a bug in there.

spambake

Shutdown works correctly with the MightyHat_dave_v2.ino, which has the LCD disabled.  If I enable the LCD on that same sketch, a shutdown button press reboots the Pi. 

spambake

Also, the putty ssh session reports:
"The system is going down for reboot NOW!" with the reboot button press, and
"The system is going down for power off NOW!" with the shutdown button press but the pi then boots.