MichaIng / DietPi

Lightweight justice for your single-board computer!
https://dietpi.com/
GNU General Public License v2.0
4.71k stars 492 forks source link

Odroid C2 | Does not boot on reboot without power cycling #5414

Closed yandritos closed 1 month ago

yandritos commented 2 years ago

DietPi version | G_DIETPI_VERSION_CORE=8 G_DIETPI_VERSION_SUB=1 G_DIETPI_VERSION_RC=2 G_GITBRANCH='master' G_GITOWNER='MichaIng' G_LIVE_PATCH_STATUS[0]='applied' G_LIVE_PATCH_STATUS[1]='applied' G_LIVE_PATCH_STATUS[2]='not applicable' G_LIVE_PATCH_STATUS[3]='not applicable'

Distro version | bullseye

Kernel version | Linux DietPi 5.10.81-meson64 #21.08.6 SMP PREEMPT Mon Nov 22 11:21:51 UTC 2021 aarch64 GNU/Linux

SBC model | Odroid C2 (aarch64)

Power supply used | 5V 2.1A

SDcard used | SanDisk ultra 16Gb

Additional Information (if applicable)

Was the software title installed freshly or updated/migrated? -Fresh install Can this issue be replicated on a fresh installation of DietPi? Yes

Bug report ID | echo $G_HW_UUID Not applies

Steps to reproduce -Whenever you send a reboot comand after shooting down, the Odroid C2 never boots up, I need to unplug/plug manually the power suply. (No way to work remotely after a reboot command). -After plug an screen to the Odroid C2 board and send even locally the reboot, I can see how the OS shut down properly finishing all the tasks, then a black screen and never boots again unles I unplug the board (this never happend with older verions).

Expected behaviour -A regular restart of the OS.

Actual behaviour -The board never boots again after a reboot command.

gitmeister commented 1 year ago

From what I can see from the Armbian patch, it only addresses the C4. As-is their patch doesn't work on the C2 because GPIOE_2 doesn't exist. C2 being EOL I don't expect anything official.

MichaIng commented 1 year ago

Ah you are right CONFIG_POWER_RESET_ODROID=y is set for all meson64 kernel builds, but the patch applied based on it only on C4.

The C2 is not EOL (at Armbian), so there are changes it is patched for C2 as well: https://www.armbian.com/odroid-c2/ It has been reported and verified already, being an issue when booting from SD card, but it has never been taken serious, being moved to P2P help section: https://forum.armbian.com/topic/20241-odroid-c2-never-starting-after-a-soft-reboot-reboot-command/ Since Armbian does not like us, we are unable to do something on that, but I could help to forge a PR. The device tree specific part is quite minimal and might work just the same way in Odroid C2 device tree: https://github.com/armbian/build/pull/4824/files#diff-1be4611a5fac3844ebe52a422830fd1c20cb5de73a9ee14cbfb794b9fad0d505R9-R17 Also the description of the driver itself indicates it works on C2: https://github.com/armbian/build/pull/4824/files#diff-1be4611a5fac3844ebe52a422830fd1c20cb5de73a9ee14cbfb794b9fad0d505R35

gitmeister commented 1 year ago

I did try the patch for the C4 "as-is" on C2 and it won't compile with DTC. You get "Syntax Error" at the line that defines GPIOE_2 and in searching the datasheet for the S905 (for the C2) you find that GPIOE doesn't exist. Searching S905X3 (for the C4) you find the pin. Also, i'm not familiar with these Meson families but I do keep seeing the C2 referred to as "gxbb" (which also appears in the boot log).

I had high hopes the patch from OnyxGH would work because that only operates on TFLASH_VDD_EN (which has different pin assignments on C2 and C4). Are others reporting this fixes the reboot issue?

To adapt the "odroid-reboot" patch for the C2 i'm assuming vqen is the TFLASH_VDD_EN but the schematics for the C2 make it difficult to locate the pins for vqsw and vqmmc as the pin functions aren't labeled like the C4 and the netlist in the PDF isn't any help. Other than the pins appearing in the DTS and/or the schematics i'm not sure how I can get confirmation of the pin assignments.

At some point it would good to understand why the watchdog isn't being used to reboot the board.

MichaIng commented 1 year ago

Ah right, I mixed up the SoC shortcodes.

gitmeister commented 1 year ago

The fix that works to correct the reboot issue on the Odroid C2 is a correction to the previous DTS patch I posted. Turns out the TF_3V3_1V8_EN signal has the pull-down and going Open-Drain allows the Sdcard voltage to be at 3.3V and ready to boot.

diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
index 7af088c73..8a1450ed4 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb-odroidc2.dts
@@ -104,7 +104,7 @@ tf_io: gpio-regulator-tf_io {
        /*
         * signal name from schematics: TF_3V3N_1V8_EN
         */
-       gpios = <&gpio_ao GPIOAO_3 GPIO_ACTIVE_HIGH>;
+       gpios = <&gpio_ao GPIOAO_3 GPIO_OPEN_DRAIN>;
        gpios-states = <0>;

        states = <3300000 0>,
MichaIng commented 1 year ago

Are you open for a PR at Armbian to get this merged, or even mainline kernel? I am currently learning and dealing with Kernel builds, but currently busy with RISC-V VisionFive 2 in this regards. I will have a look into mainline Linux and possibly own kernel builds for Odroid C2.

gitmeister commented 1 year ago

Honestly, I know nothing of the Linux/Armbian PR process. If you can outline the steps I'd need to do to help out that would great.

MichaIng commented 1 year ago

Basically the same way as done here: https://github.com/armbian/build/commit/b7d5ea2

  1. Clone the repo
  2. Add the patch to meson64-6.2 and meson64-6.1 paths (for now), with board-odroidc2 prefix
  3. Open a pull request against Armbian main branch: https://github.com/armbian/build/pulls

Mainline Linux works with a mailing list, but I don't know much about it either. Also we should first test whether the reboot issue is actually apparent on an unpatched current mainline kernel.

DmitryMikh commented 1 month ago

Hi, on the latest build I decompiled dtb using dtc -I dtb -O dts meson-gxbb-odroidc2.dtb -o meson-gxbb-odroidc2.dts, changed to

gpio-regulator-tf_io {
                ---
        gpios = <0x39 0x03 0x06>;

as gitmeister said, recompiled back using dtc -O dtb -o meson-gxbb-odroidc2.dtb meson-gxbb-odroidc2.dts, reboot works!

MichaIng commented 1 month ago

Thanks for the reminder that we have a patch already. Since we provide own builds based on an Armbian fork now, I'll add this patch.

EDIT: Done: https://github.com/MichaIng/build/commit/739e721 Build done: https://github.com/MichaIng/DietPi/actions/runs/9194400929 Packages are available here for testing: https://dietpi.com/downloads/binaries/testing/

cd  /tmp
wget https://dietpi.com/downloads/binaries/testing/linux-{image,dtb}-current-meson64.deb
dpkg -i linux-{image,dtb}-current-meson64.deb
reboot
gitmeister commented 1 month ago

Glad to be of help!

onepunchdan commented 1 month ago

@gitmeister thank you for the fix, and @DmitryMikh for reviving this thread. @MichaIng, I've installed the patched kernel image on two C2 boards and can also confirm that soft reboot is working.

MichaIng commented 1 month ago

Great, thanks for testing. I'll push this to our APT server.

MichaIng commented 1 month ago

Next DietPi update adds the needed component for our APT repo to the lists of 64-bit Allwinner SoC SBCs and upgrade the kernel from there: https://github.com/MichaIng/DietPi/commit/81c04ee

I'll mark this as solved.