Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reboot on odroid C4 when using UHS microSD cards #4824

Closed
wants to merge 1 commit into from

Conversation

ashh87
Copy link
Contributor

@ashh87 ashh87 commented Feb 10, 2023

Description

This fixes reboot on Odroid C4 boards which boot from UHS microSD cards. The issue has been discussed before here:
https://forum.armbian.com/topic/19340-odroid-c4-will-not-reboot-after-any-sort-of-kernel-update-have-tried-running-nand-sata-install/

A previous pull request removed a version of this patch here:
https://github.com/armbian/build/pull/3154/files#diff-8530e3af79cd8a35329d7d1a44b2a8006ad0cd70deefb0341a9933233673a9b6

The previous version of the patch was broken by upstream changes in the kernel, and this commit contains the minimal changes needed to fix it. Standard PSCI reset functions are now called in mainline, so the patch has been updated to reflect that. The patch now registers a reboot handler which gets called before the standard PSCI functions and toggles some GPIO lines to reset the SD card. If the card is a UHS card, then this puts it back into a state which the bootloader can deal with, and the board can reboot cleanly.

This patch might be applicable to other boards, but I can't test them. They can be tested by adding some code to the device tree, to add in the odroid,reboot driver.

I'd like to work on getting this change added to the kernel. but I'll try to make it more general, so it might not be a board-specific patch by the time it gets that far. When that eventually happens, this patch can be removed again.

How Has This Been Tested?

This has been tested by booting the board with a UHS-I SD card using the kernels compiled for odroidc4 targeting both BRANCH=current and BRANCH=edge. Both versions of the patched kernel allow a clean reboot.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

@rpardini
Copy link
Member

Hey @ashh87 how is this different from the hack HK carries? (https://github.com/tobetter/linux/blob/odroid-6.1.y/drivers/power/reset/odroid-reboot.c)
It has been removed years ago, since it required the dreaded revert of meson_drv_shutdown related to DRM, which "fixed" ODROID's but broke all other boards. How does that sit?
(Remember: Armbian meson64 kernel is a single kernel for all meson64 boards -- we can't go breaking other boards to fix one).

@ashh87
Copy link
Contributor Author

ashh87 commented Feb 10, 2023

Hi,

This is more-or-less the same thing, though I'm fairly sure I've seen a build online with that patch failing to compile. The major difference is in odroid_restart_probe, where "arm_pm_restart = do_odroid_restart;" is replaced with "register_restart_handler(&odroid_restart_handler);".

The ability to use arm_pm_restart (directly) was removed at some point, so the original patch was broken, is that how meson_drv_shutdown comes into it? I'm not familiar with that.

The patch here stands alone, I think. Meson64 defconfig is changed to compile the odroid-reboot module, but I've only added it to the Odroid C4 dts, so other boards shouldn't have a problem.

@igorpecovnik
Copy link
Member

igorpecovnik commented Feb 12, 2023

@rpardini we better merge this after release, right?

@rpardini
Copy link
Member

cherry-picked into armbian-next, will be included in next push

@igorpecovnik
Copy link
Member

Already merged.

@rpardini
Copy link
Member

This, if working, might allow to enable UHS for odroidn2 as well as odroidc4.
I realize that "back in the day" I had not enabled the .config, so the driver was never compiled-in and thus never used 🤦
Can you check the odroidn2 too @ashh87 ?

@ashh87
Copy link
Contributor Author

ashh87 commented Feb 24, 2023

The hardkernel device trees have nodes for odroid,reboot in Odroid C4, N2 and N2 plus. The HC4 is meant to be similar hardware to the C4, but doesn't use the reboot driver in tobetter's tree, so I don't know if it is also affected by the issue.

Unfortunately I don't have anything other than an Odroid C4 to test against

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants