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

Implement device wipe using the hardware button on Green #3523

Merged
merged 3 commits into from
Aug 16, 2024
Merged

Conversation

sairon
Copy link
Member

@sairon sairon commented Aug 13, 2024

Unlike Yellow, Green doesn't have a way to easily wipe the device, e.g. if the user forgets the password - in that case the only option is to use a microSD card and reflash the system. Fortunately, Green has a hardware button wired to the PMIC chip which exposes the button state in one of the registers. Read this value in U-Boot and decide if cmdline flag for device wipe should be set - same as we do on Yellow.

Also enable LED driver and command in U-Boot. In the current implementation, if the button is held for ~5 seconds when plugging in the device (this time includes DDR training, SPL, etc.), the yellow LED turns solid to indicate wipe is about the start. When the Linux kernel starts, the kernel LED driver takes over and starts blinking in heartbeat pattern. Because it takes a while to load the kernel, the LED stays solid for 2-3 seconds, which should be enough to recognize it was acknowledged.

@sairon sairon added u-boot U-Boot related issue board/green Home Assistant Green labels Aug 13, 2024
@sairon sairon requested a review from agners August 13, 2024 16:30
@sairon sairon changed the title Green button wipe Implement device wipe using the hardware button on Green Aug 13, 2024
Port Stefan's patch from Linux patchset to U-Boot.
Unlike Yellow, Green doesn't have a way to easily wipe the device, e.g. if the
user forgets the password - in that case the only option is to use a microSD
card and reflash the system. Fortunately, Green has a hardware button wired to
the PMIC chip which exposes the button state in one of the registers. Read this
value in U-Boot and decide if cmdline flag for device wipe should be set - same
as we do on Yellow.

Also enable LED driver and command in U-Boot. In the current implementation, if
the button is held for ~5 seconds when plugging in the device (this time
includes DDR training, SPL, etc.), the yellow LED turns solid to indicate wipe
is about the start. When the Linux kernel starts, the kernel LED driver takes
over and starts blinking in heartbeat pattern. Because it takes a while to load
the kernel, the LED stays solid for 2-3 seconds, which should be enough to
recognize it was acknowledged.
Copy link
Member

@agners agners left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice feature, thanks! 💪

@sairon sairon merged commit 7e7612f into dev Aug 16, 2024
2 checks passed
@sairon sairon deleted the green-button-wipe branch August 16, 2024 07:35
sairon added a commit that referenced this pull request Aug 16, 2024
With #3523 as inspiration, it might be useful to wait for buttons to be
released, e.g. in case when they become stuck. Also indicate the button
operation (wipe, boot files removal, UMS) has been handled by turning on the
yellow LED.
sairon added a commit that referenced this pull request Aug 16, 2024
With #3523 as inspiration, it might be useful to wait for buttons to be
released, e.g. in case when they become stuck. Also indicate the button
operation (wipe, boot files removal, UMS) has been handled by turning on the
yellow LED.
This was referenced Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
board/green Home Assistant Green cla-signed u-boot U-Boot related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants