[R2] Kernel Panic at PowerOff with soldered button

I have soldered my power button so that the R2 comes on when power is supplied. But when I execute “poweroff”, I get a kernel panic. I circumvented this by having the R2 reboot at kernel panic, which solves the immediate issue. But I thought maybe frank-w should know about this. Here is the text of the kernel panic:

[  114.775988] ------------[ cut here ]------------
[  114.780650] WARNING: CPU: 0 PID: 1 at /home/doug/R2/BPI-R2-4.14/drivers/power/reset/mt6323-poweroff.c:46 mt6323_do_pwroff+0x178/0x180
[  114.792670] Unable to power off system
[  114.796421] Modules linked in: nf_conntrack_netlink xt_addrtype iptable_nat xt_conntrack nft_counter nft_chain_nat xt_MASQUERADE nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 nft_compat nf_tables nfnetlink mt7615e mt7615_common mt76 lima gpu_sched pwm_mediatek spi_mt65xx ip_tables x_tables
[  114.822534] CPU: 0 PID: 1 Comm: systemd-shutdow Not tainted 5.10.11-bpi-r2-main #2
[  114.830110] Hardware name: Mediatek Cortex-A7 (Device Tree)
[  114.835683] Backtrace:
[  114.838145] [<c010d30c>] (dump_backtrace) from [<c010d658>] (show_stack+0x20/0x24)
[  114.845724]  r7:00000009 r6:60030013 r5:00000000 r4:c14ef938
[  114.851394] [<c010d638>] (show_stack) from [<c0dccd74>] (dump_stack+0xd0/0xe4)
[  114.858629] [<c0dccca4>] (dump_stack) from [<c0126f0c>] (__warn+0x110/0x114)
[  114.865683]  r7:00000009 r6:00000000 r5:c120fa60 r4:c2137ddc
[  114.871348] [<c0126dfc>] (__warn) from [<c0126f94>] (warn_slowpath_fmt+0x84/0xc0)
[  114.878841]  r9:00000009 r8:c0951984 r7:0000002e r6:c120fa60 r5:c120fa44 r4:c1404ec8
[  114.886596] [<c0126f14>] (warn_slowpath_fmt) from [<c0951984>] (mt6323_do_pwroff+0x178/0x180)
[  114.895131]  r9:0000001a r8:b76d02db r7:c1404ec8 r6:0ccccb60 r5:c1252388 r4:00000000
[  114.902885] [<c095180c>] (mt6323_do_pwroff) from [<c010b8d4>] (machine_power_off+0x34/0x38)
[  114.911247]  r9:2da84800 r8:fee1dead r7:c14124d8 r6:4321fedc r5:00000000 r4:c1404ec8
[  114.919003] [<c010b8a0>] (machine_power_off) from [<c0150e60>] (kernel_power_off+0x7c/0x80)
[  114.927367] [<c0150de4>] (kernel_power_off) from [<c0150fb8>] (__do_sys_reboot+0x154/0x200)
[  114.935731] [<c0150e64>] (__do_sys_reboot) from [<c01510d4>] (sys_reboot+0x18/0x1c)
[  114.943398]  r9:c2136000 r8:c0100264 r7:00000058 r6:00000000 r5:00000000 r4:004f6954
[  114.951153] [<c01510bc>] (sys_reboot) from [<c0100060>] (ret_fast_syscall+0x0/0x54)
[  114.958814] Exception stack(0xc2137fa8 to 0xc2137ff0)
[  114.963872] 7fa0:                   004f6954 00000000 fee1dead 28121969 4321fedc 2da84800
[  114.972058] 7fc0: 004f6954 00000000 00000000 00000058 be839c68 00000000 be839c00 004f56f8
[  114.980241] 7fe0: 00000058 be839b5c b6ef9d45 b6e7b746
[  114.985316] ---[ end trace 5dc0854ed2aaa00b ]---
[  114.989960] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000000
[  114.997625] CPU: 0 PID: 1 Comm: systemd-shutdow Tainted: G        W         5.10.11-bpi-r2-main #2
[  115.006588] Hardware name: Mediatek Cortex-A7 (Device Tree)
[  115.012161] Backtrace:
[  115.014618] [<c010d30c>] (dump_backtrace) from [<c010d658>] (show_stack+0x20/0x24)
[  115.022197]  r7:ffffe000 r6:60030093 r5:00000000 r4:c14ef938
[  115.027864] [<c010d638>] (show_stack) from [<c0dccd74>] (dump_stack+0xd0/0xe4)
[  115.035097] [<c0dccca4>] (dump_stack) from [<c0dbd5f4>] (panic+0x120/0x338)
[  115.042064]  r7:ffffe000 r6:c113d198 r5:00000000 r4:c15bb7d8
[  115.047732] [<c0dbd4d4>] (panic) from [<c012d00c>] (do_exit+0x878/0xaf8)
[  115.054438]  r3:00000001 r2:c2150004 r1:00000000 r0:c113d198
[  115.060098]  r7:ffffe000
[  115.062638] [<c012c794>] (do_exit) from [<c0150fc0>] (__do_sys_reboot+0x15c/0x200)
[  115.070211]  r7:c14124d8
[  115.072751] [<c0150e64>] (__do_sys_reboot) from [<c01510d4>] (sys_reboot+0x18/0x1c)
[  115.080418]  r9:c2136000 r8:c0100264 r7:00000058 r6:00000000 r5:00000000 r4:004f6954
[  115.088171] [<c01510bc>] (sys_reboot) from [<c0100060>] (ret_fast_syscall+0x0/0x54)
[  115.095832] Exception stack(0xc2137fa8 to 0xc2137ff0)
[  115.100889] 7fa0:                   004f6954 00000000 fee1dead 28121969 4321fedc 2da84800
[  115.109076] 7fc0: 004f6954 00000000 00000000 00000058 be839c68 00000000 be839c00 004f56f8
[  115.117260] 7fe0: 00000058 be839b5c b6ef9d45 b6e7b746
[  115.122328] Rebooting in 1 seconds..

you have soldered powerbutton (aka force power on), so what do you think pmic should do on poweroff?

i guess driver waits for pmic shut down and this fails because it is forced on.

reboot possible without problems?

I dunno. I had added kernel.panic = 1 to /etc/sysctl.conf to force the machine to reboot after 1 second upon kernel panic. Absolutely no problems rebooting the R2 (other than insane MT7615 problem). Thought it was weird that the kernel panicked upon attempted poweroff.

Just thought maybe it might be able to be fixed, but it’s not a issue. Just reporting something I saw. Sorry to bother you!

No problem. It is also a source for users having same “issue” as you.

Just a thought: Can I change settings for something in the kernel building stuff that cause the poweroff to reboot instead? Or even something in the Debian 10 install?

BTW, my “potential solution” for my insane MT7615 problem doesn’t work:

/sbin/poweroff (or maybe /bin/poweroff) is either a symlink to systemctl or a binary.

first you need to call which one is called

which poweroff
file /sbin/poweroff

now you can rename it and link reboot to it

mv /sbin/poweroff{,.bak}
cp /sbin/reboot{,.bak} #create backup of reboot too
ln -s /sbin/{reboot,poweroff}

on my ubuntu workstation i see this:

$ which poweroff
/usr/sbin/poweroff
$ which reboot
/usr/sbin/reboot
$ file /usr/sbin/poweroff
/usr/sbin/poweroff: symbolic link to /bin/systemctl

on my r2 (debian buster) i see paths above as root (none as user)

[16:19] root@bpi-r2-emmc:~ (500)
# which poweroff
/sbin/poweroff
[16:19] root@bpi-r2-emmc:~ (501)
# which reboot
/sbin/reboot

my system is “secured” for accidentally shutdown/ reboot by mollyguard so file shows this:

# file /sbin/poweroff
/sbin/poweroff: symbolic link to /lib/molly-guard/molly-guard

but just backup both and link poweroff to reboot

1 Like