aboutsummaryrefslogtreecommitdiff
path: root/patches/0007-yp3-power-off-at-boot-when-there-is-no-SD-card.patch
blob: 086494cba8e09b18a4855cc82951a46500a127a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
From 33293a86a06f935e44f17f36b38f586e7b0e5b33 Mon Sep 17 00:00:00 2001
From: YP3 Audiobook <noreply@example.invalid>
Date: Thu, 26 Nov 2026 20:23:27 +0000
Subject: [PATCH 07/11] yp3: power off at boot when there is no SD card

Turned on without a card, the player showed "ATA error: -5", then after
a key the debug screen and a panic ("ata: -5" and a backtrace). The
panic parks the CPU until the recovery watchdog resets it (~16 s), a
dark screen that looked like a crash into download mode.

Now it says there is no SD card, waits 5 s and powers off; with the
card back in, the next power-on boots normally.

---
 apps/main.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/apps/main.c b/apps/main.c
index 1dcc992d..ca189b07 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -626,6 +626,23 @@ static void init(void)
     CHART(">storage_init");
     rc = storage_init();
     CHART("<storage_init");
+#ifdef HAVE_SD_CARD_SWAP
+    if (rc)
+    {
+        /* No card (or none that answers): say so and power off. Upstream
+           waited for a key, showed the debug screen and panicked, and the
+           panic parked the player dark until the recovery watchdog reset
+           it (~16 s), which looked like a crash into download mode. */
+        lcd_clear_display();
+        lcd_puts(0, 1, "No SD card.");
+        lcd_puts(0, 3, "Put the card in,");
+        lcd_puts(0, 4, "then turn the");
+        lcd_puts(0, 5, "player on.");
+        lcd_update();
+        sleep(5*HZ);
+        power_off();
+    }
+#endif
     if(rc)
     {
         lcd_clear_display();
-- 
2.56.1