I've been trying to integrate my own application with WittyPi4 and tested out the scheduled shutdown/startup for the first time today. The shutdown executed correctly and when I expected but the programmed start-up didn't happen when I had expected. And now my WittyPi4 is now in a non-recoverable state! Here's what I see:
- The WittyPi4 heartbeat LED is working fine as you would normally see
- Pressing the power button results in power coming on very briefly to the RPi5 board and then immediately off again
- Removing the WittyPi4 power source and powering the Rpi5 directly from USB 5V, the pi boots up just fine. However, the I2C reads mostly fail when accessing the WittyPi4 i.e., it looks like the temperate sensor is reading back fine but everything else appears to be failing I2C reads
Any ideas what is going on or how to troubleshoot further?
Just to add another piece of information. If I rapidly keep pressing the power button on WittyPi4 it seems that that the power does not cut. If I do this for long enough, the RPi5 will boot successfully and the unit remains powered. However, I am still seeing I2C read failures.
@liamw9534 Witty Pi cuts power during the boot, that is usually because the TXD pin doesn't go HIGH within given time window.
Possible root cause may be serial port (TXD, RXD) didn't get properly configured. Or the configuration was moved, as mentioned here.
Long pressing button is not a normal operation to boot up your Pi, it is used to force power cut directly, when your Pi is on.
Ok, I'm not sure what is going on. I left the hat disconnected overnight. Reconnected it this morning and managed to boot-up cleanly by pressing the power button. I then repeat the cycle again using a programmed shutdown (12:34) and startup (12:59) -- the hat is back into the same state as before i.e., the power is disconnected very soon after pressing the power button.
Is the power cutting out because the programmed start-up time has not arrived? I thought the power button would override this? I'm just trying to understand what is going on here, it doesn't seem like the desired behaviour to me.
@liamw9534 my advice is to check the serial port configuration first. You may do so by running "gpio readall" command.
If you want to understand how it works, reading the source code of its firmware would be the way to go. You can find it here.
Ok, one possible issue is relating to setting register 21 in my shutdown sequence since I want the programmed shutdown to happen without any delays. I am setting register 21 to the value of 0. Is this having an influence on the power switch operation?
@liamw9534 register 21 is for the delay between initializing the shutdown and cutting the power. It is not recommended to put it 0, because that means no time for all running processes to quit/halt before the power gets cut, and that equals to directly cutting the power and it is not graceful.
Putting this register to 0 will let you see the power cut sooner. However you still need to find out why Witty Pi tried to cut power during the boot, most probably it was still due to the serial port configuration.
@admin the output of gpio readall is below and these pins are configured for ALT4 which seems correct to me:
+-----+-----+---------+------+---+---Pi 5---+---+------+---------+-----+-----+ | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM | +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+ | | | 3.3v | | | 1 || 2 | | | 5v | | | | 2 | 8 | SDA.1 | ALT3 | 1 | 3 || 4 | | | 5v | | | | 3 | 9 | SCL.1 | ALT3 | 1 | 5 || 6 | | | 0v | | | | 4 | 7 | GPIO. 7 | - | 0 | 7 || 8 | 1 | ALT4 | TxD | 15 | 14 | | | | 0v | | | 9 || 10 | 1 | ALT4 | RxD | 16 | 15 | | 17 | 0 | GPIO. 0 | - | 0 | 11 || 12 | 0 | - | GPIO. 1 | 1 | 18 | | 27 | 2 | GPIO. 2 | - | 0 | 13 || 14 | | | 0v | | | | 22 | 3 | GPIO. 3 | - | 0 | 15 || 16 | 0 | - | GPIO. 4 | 4 | 23 | | | | 3.3v | | | 17 || 18 | 0 | - | GPIO. 5 | 5 | 24 | | 10 | 12 | MOSI | - | 0 | 19 || 20 | | | 0v | | | | 9 | 13 | MISO | - | 0 | 21 || 22 | 0 | - | GPIO. 6 | 6 | 25 | | 11 | 14 | SCLK | - | 0 | 23 || 24 | 0 | - | CE0 | 10 | 8 | | | | 0v | | | 25 || 26 | 0 | - | CE1 | 11 | 7 | | 0 | 30 | SDA.0 | IN | 1 | 27 || 28 | 1 | IN | SCL.0 | 31 | 1 | | 5 | 21 | GPIO.21 | - | 0 | 29 || 30 | | | 0v | | | | 6 | 22 | GPIO.22 | - | 0 | 31 || 32 | 0 | - | GPIO.26 | 26 | 12 | | 13 | 23 | GPIO.23 | - | 0 | 33 || 34 | | | 0v | | | | 19 | 24 | GPIO.24 | - | 0 | 35 || 36 | 0 | - | GPIO.27 | 27 | 16 | | 26 | 25 | GPIO.25 | - | 0 | 37 || 38 | 0 | - | GPIO.28 | 28 | 20 | | | | 0v | | | 39 || 40 | 0 | - | GPIO.29 | 29 | 21 | +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+ | BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM | +-----+-----+---------+------+---+---Pi 5---+---+------+---------+-----+-----+
@liamw9534 I think it should be ALT0 instead. I am not sure if it behaves the same with ALT4.
@admin I am referencing the following table for the description of alternate functions for the RPI5:
https://github.com/Felipegalind0/RPI5.pinout
I assumed ALT4 was mapping to F5 in this table which is UART0. In any case, the output of `pinctrl` seems to suggest this is correct:
0: ip pu | hi // ID_SDA/GPIO0 = input 1: ip pu | hi // ID_SCL/GPIO1 = input 2: a3 pu | hi // GPIO2 = SDA1 3: a3 pu | hi // GPIO3 = SCL1 4: no pu | -- // GPIO4 = none 5: no pu | -- // GPIO5 = none 6: no pu | -- // GPIO6 = none 7: no pu | -- // GPIO7 = none 8: no pu | -- // GPIO8 = none 9: no pd | -- // GPIO9 = none 10: no pd | -- // GPIO10 = none 11: no pd | -- // GPIO11 = none 12: no pd | -- // GPIO12 = none 13: no pd | -- // GPIO13 = none 14: a4 pn | hi // GPIO14 = TXD0 15: a4 pu | hi // GPIO15 = RXD0 ......
I also confirmed the pin is at 3V3 when RPi5 is booted standalone.
@liamw9534 for Raspberry Pi 5, ALT5 is correct and GPIO-14, 15 are indeed configured as TXD, RXD.
I think I found the problem: GPIO-4 (GPIO.7 in "gpio readall" output) is not in correct state. It should be input with pull-up.
You need to find out why GPIO-4 is in that state.
Having said the above, the pin doesn't appear to go high until about 10 seconds after the RPI5 boots. I'm not sure where in the boot process this is supposed to go high nor what the hat is assuming in terms of pin output timing.
@admin seems like a chicken and the egg problem. The wittypi daemon configures this pin as an input but this won't get run until after the system is booted. I don't have 1-wire enabled or anything in my boot config that would configure it to some other function. I could try to configure the pin explicitly in my boot config? I'm not sure how this is intended to work.
I'm trying to further understand what is going with the hat disconnected from the RPi and wiring up VOUT to an oscilloscope.
I am seeing that when the power button is pressed VOUT goes to 5V for about 5ms and then shuts off again. It seems that this happens even if I tie SYS_UP and TXD to 3V3.
This doesn't seem like it is long enough to hold the power output to allow the RPi to boot and configure its pins. So I'm guessing that some internal flash setting is wrong and is causing the early termination in the Arduino code. Would reprogramming the Arduino code to get everything back to its default settings?