diff options
Diffstat (limited to 'firmware/target')
24 files changed, 391 insertions, 26 deletions
diff --git a/firmware/target/arm/as3525/debug-as3525.c b/firmware/target/arm/as3525/debug-as3525.c index 513295edcb..d18f2d70b2 100644 --- a/firmware/target/arm/as3525/debug-as3525.c +++ b/firmware/target/arm/as3525/debug-as3525.c | |||
@@ -248,7 +248,7 @@ static int calc_freq(int clk) | |||
248 | } | 248 | } |
249 | } | 249 | } |
250 | 250 | ||
251 | bool __dbg_hw_info(void) | 251 | bool dbg_hw_info(void) |
252 | { | 252 | { |
253 | int line; | 253 | int line; |
254 | #if CONFIG_CPU == AS3525 | 254 | #if CONFIG_CPU == AS3525 |
diff --git a/firmware/target/arm/as3525/debug-target.h b/firmware/target/arm/as3525/debug-target.h index a9e43550a8..1359e6a00e 100644 --- a/firmware/target/arm/as3525/debug-target.h +++ b/firmware/target/arm/as3525/debug-target.h | |||
@@ -24,6 +24,6 @@ | |||
24 | #include <stdbool.h> | 24 | #include <stdbool.h> |
25 | 25 | ||
26 | #define DEBUG_CANCEL BUTTON_LEFT | 26 | #define DEBUG_CANCEL BUTTON_LEFT |
27 | bool __dbg_hw_info(void); | 27 | bool dbg_hw_info(void); |
28 | bool dbg_ports(void); | 28 | bool dbg_ports(void); |
29 | #endif | 29 | #endif |
diff --git a/firmware/target/arm/at91sam/lyre_proto1/debug-lyre_proto1.c b/firmware/target/arm/at91sam/lyre_proto1/debug-lyre_proto1.c index 54a262a9ff..5277afc348 100644 --- a/firmware/target/arm/at91sam/lyre_proto1/debug-lyre_proto1.c +++ b/firmware/target/arm/at91sam/lyre_proto1/debug-lyre_proto1.c | |||
@@ -23,12 +23,12 @@ | |||
23 | #include <stdbool.h> | 23 | #include <stdbool.h> |
24 | #include "debug-target.h" | 24 | #include "debug-target.h" |
25 | 25 | ||
26 | bool __dbg_ports(void) | 26 | bool dbg_ports(void) |
27 | { | 27 | { |
28 | return false; | 28 | return false; |
29 | } | 29 | } |
30 | 30 | ||
31 | bool __dbg_hw_info(void) | 31 | bool dbg_hw_info(void) |
32 | { | 32 | { |
33 | return false; | 33 | return false; |
34 | } | 34 | } |
diff --git a/firmware/target/arm/at91sam/lyre_proto1/debug-target.h b/firmware/target/arm/at91sam/lyre_proto1/debug-target.h index 140feafe67..59dd58cb32 100644 --- a/firmware/target/arm/at91sam/lyre_proto1/debug-target.h +++ b/firmware/target/arm/at91sam/lyre_proto1/debug-target.h | |||
@@ -21,6 +21,6 @@ | |||
21 | 21 | ||
22 | #include <stdbool.h> | 22 | #include <stdbool.h> |
23 | 23 | ||
24 | bool __dbg_ports(void); | 24 | bool dbg_ports(void); |
25 | bool __dbg_hw_info(void); | 25 | bool dbg_hw_info(void); |
26 | 26 | ||
diff --git a/firmware/target/arm/debug-pp.c b/firmware/target/arm/debug-pp.c index 3b9250c0fb..080e0ed631 100644 --- a/firmware/target/arm/debug-pp.c +++ b/firmware/target/arm/debug-pp.c | |||
@@ -28,8 +28,43 @@ | |||
28 | #include "powermgmt.h" | 28 | #include "powermgmt.h" |
29 | #include "adc.h" | 29 | #include "adc.h" |
30 | #include "iap.h" | 30 | #include "iap.h" |
31 | #include "hwcompat.h" | ||
31 | #include "debug-target.h" | 32 | #include "debug-target.h" |
32 | 33 | ||
34 | static int perfcheck(void) | ||
35 | { | ||
36 | int result; | ||
37 | |||
38 | asm ( | ||
39 | "mrs r2, CPSR \n" | ||
40 | "orr r0, r2, #0xc0 \n" /* disable IRQ and FIQ */ | ||
41 | "msr CPSR_c, r0 \n" | ||
42 | "mov %[res], #0 \n" | ||
43 | "ldr r0, [%[timr]] \n" | ||
44 | "add r0, r0, %[tmo] \n" | ||
45 | "1: \n" | ||
46 | "add %[res], %[res], #1 \n" | ||
47 | "ldr r1, [%[timr]] \n" | ||
48 | "cmp r1, r0 \n" | ||
49 | "bmi 1b \n" | ||
50 | "msr CPSR_c, r2 \n" /* reset IRQ and FIQ state */ | ||
51 | : | ||
52 | [res]"=&r"(result) | ||
53 | : | ||
54 | [timr]"r"(&USEC_TIMER), | ||
55 | [tmo]"r"( | ||
56 | #if CONFIG_CPU == PP5002 | ||
57 | 16000 | ||
58 | #else /* PP5020/5022/5024 */ | ||
59 | 10226 | ||
60 | #endif | ||
61 | ) | ||
62 | : | ||
63 | "r0", "r1", "r2" | ||
64 | ); | ||
65 | return result; | ||
66 | } | ||
67 | |||
33 | bool dbg_ports(void) | 68 | bool dbg_ports(void) |
34 | { | 69 | { |
35 | int line; | 70 | int line; |
@@ -152,3 +187,46 @@ bool dbg_ports(void) | |||
152 | } | 187 | } |
153 | return false; | 188 | return false; |
154 | } | 189 | } |
190 | |||
191 | bool dbg_hw_info(void) | ||
192 | { | ||
193 | int line = 0; | ||
194 | #if defined(CPU_PP502x) | ||
195 | char pp_version[] = { (PP_VER2 >> 24) & 0xff, (PP_VER2 >> 16) & 0xff, | ||
196 | (PP_VER2 >> 8) & 0xff, (PP_VER2) & 0xff, | ||
197 | (PP_VER1 >> 24) & 0xff, (PP_VER1 >> 16) & 0xff, | ||
198 | (PP_VER1 >> 8) & 0xff, (PP_VER1) & 0xff, '\0' }; | ||
199 | #elif CONFIG_CPU == PP5002 | ||
200 | char pp_version[] = { (PP_VER4 >> 8) & 0xff, PP_VER4 & 0xff, | ||
201 | (PP_VER3 >> 8) & 0xff, PP_VER3 & 0xff, | ||
202 | (PP_VER2 >> 8) & 0xff, PP_VER2 & 0xff, | ||
203 | (PP_VER1 >> 8) & 0xff, PP_VER1 & 0xff, '\0' }; | ||
204 | #endif | ||
205 | |||
206 | lcd_setfont(FONT_SYSFIXED); | ||
207 | lcd_clear_display(); | ||
208 | |||
209 | lcd_puts(0, line++, "[Hardware info]"); | ||
210 | |||
211 | #ifdef IPOD_ARCH | ||
212 | lcd_putsf(0, line++, "HW rev: 0x%08lx", IPOD_HW_REVISION); | ||
213 | #endif | ||
214 | |||
215 | #ifdef IPOD_COLOR | ||
216 | extern int lcd_type; /* Defined in lcd-colornano.c */ | ||
217 | |||
218 | lcd_putsf(0, line++, "LCD type: %d", lcd_type); | ||
219 | #endif | ||
220 | |||
221 | lcd_putsf(0, line++, "PP version: %s", pp_version); | ||
222 | |||
223 | lcd_putsf(0, line++, "Est. clock (kHz): %d", perfcheck()); | ||
224 | |||
225 | lcd_update(); | ||
226 | |||
227 | /* wait for exit */ | ||
228 | while (button_get_w_tmo(HZ/10) != (DEBUG_CANCEL|BUTTON_REL)); | ||
229 | |||
230 | lcd_setfont(FONT_UI); | ||
231 | return false; | ||
232 | } | ||
diff --git a/firmware/target/arm/debug-target.h b/firmware/target/arm/debug-target.h index 4408acf5da..28f95327ad 100644 --- a/firmware/target/arm/debug-target.h +++ b/firmware/target/arm/debug-target.h | |||
@@ -47,3 +47,4 @@ | |||
47 | # define DEBUG_CANCEL BUTTON_CANCEL | 47 | # define DEBUG_CANCEL BUTTON_CANCEL |
48 | #endif | 48 | #endif |
49 | bool dbg_ports(void); | 49 | bool dbg_ports(void); |
50 | bool dbg_hw_info(void); | ||
diff --git a/firmware/target/arm/imx31/debug-imx31.c b/firmware/target/arm/imx31/debug-imx31.c index f8dacbedd5..92884fe8aa 100644 --- a/firmware/target/arm/imx31/debug-imx31.c +++ b/firmware/target/arm/imx31/debug-imx31.c | |||
@@ -31,7 +31,7 @@ | |||
31 | #include "dvfs_dptc-imx31.h" | 31 | #include "dvfs_dptc-imx31.h" |
32 | #include <stdio.h> | 32 | #include <stdio.h> |
33 | 33 | ||
34 | bool __dbg_hw_info(void) | 34 | bool dbg_hw_info(void) |
35 | { | 35 | { |
36 | int line; | 36 | int line; |
37 | unsigned int pllref; | 37 | unsigned int pllref; |
diff --git a/firmware/target/arm/imx31/debug-target.h b/firmware/target/arm/imx31/debug-target.h index ca02ab84de..25fd5d872b 100644 --- a/firmware/target/arm/imx31/debug-target.h +++ b/firmware/target/arm/imx31/debug-target.h | |||
@@ -22,7 +22,7 @@ | |||
22 | #define DEBUG_TARGET_H | 22 | #define DEBUG_TARGET_H |
23 | 23 | ||
24 | #define DEBUG_CANCEL BUTTON_BACK | 24 | #define DEBUG_CANCEL BUTTON_BACK |
25 | bool __dbg_hw_info(void); | 25 | bool dbg_hw_info(void); |
26 | bool dbg_ports(void); | 26 | bool dbg_ports(void); |
27 | bool __dbg_dvfs_dptc(void); | 27 | bool __dbg_dvfs_dptc(void); |
28 | 28 | ||
diff --git a/firmware/target/arm/s3c2440/debug-s3c2440.c b/firmware/target/arm/s3c2440/debug-s3c2440.c index e552f12c2b..99ab8e4306 100644 --- a/firmware/target/arm/s3c2440/debug-s3c2440.c +++ b/firmware/target/arm/s3c2440/debug-s3c2440.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include "font.h" | 29 | #include "font.h" |
30 | #include "debug-target.h" | 30 | #include "debug-target.h" |
31 | 31 | ||
32 | bool __dbg_hw_info(void) | 32 | bool dbg_hw_info(void) |
33 | { | 33 | { |
34 | return false; | 34 | return false; |
35 | } | 35 | } |
diff --git a/firmware/target/arm/s3c2440/debug-target.h b/firmware/target/arm/s3c2440/debug-target.h index dc274b9f06..9e83da6f48 100644 --- a/firmware/target/arm/s3c2440/debug-target.h +++ b/firmware/target/arm/s3c2440/debug-target.h | |||
@@ -25,6 +25,6 @@ | |||
25 | #define DEBUG_CANCEL BUTTON_MENU | 25 | #define DEBUG_CANCEL BUTTON_MENU |
26 | #endif | 26 | #endif |
27 | 27 | ||
28 | bool __dbg_hw_info(void); | 28 | bool dbg_hw_info(void); |
29 | bool dbg_ports(void); | 29 | bool dbg_ports(void); |
30 | 30 | ||
diff --git a/firmware/target/arm/s5l8700/debug-s5l8700.c b/firmware/target/arm/s5l8700/debug-s5l8700.c index 28bb9b2050..3631a474ed 100644 --- a/firmware/target/arm/s5l8700/debug-s5l8700.c +++ b/firmware/target/arm/s5l8700/debug-s5l8700.c | |||
@@ -41,7 +41,7 @@ | |||
41 | extern int lcd_type; | 41 | extern int lcd_type; |
42 | extern uint32_t nand_type[4]; | 42 | extern uint32_t nand_type[4]; |
43 | 43 | ||
44 | bool __dbg_hw_info(void) | 44 | bool dbg_hw_info(void) |
45 | { | 45 | { |
46 | int line; | 46 | int line; |
47 | int i; | 47 | int i; |
@@ -127,7 +127,7 @@ bool __dbg_hw_info(void) | |||
127 | } | 127 | } |
128 | 128 | ||
129 | #else | 129 | #else |
130 | _DEBUG_PRINTF("__dbg_hw_info"); | 130 | _DEBUG_PRINTF("dbg_hw_info"); |
131 | #endif | 131 | #endif |
132 | 132 | ||
133 | lcd_update(); | 133 | lcd_update(); |
diff --git a/firmware/target/arm/s5l8700/debug-target.h b/firmware/target/arm/s5l8700/debug-target.h index 351468fb50..95f2f94795 100644 --- a/firmware/target/arm/s5l8700/debug-target.h +++ b/firmware/target/arm/s5l8700/debug-target.h | |||
@@ -26,7 +26,7 @@ | |||
26 | 26 | ||
27 | #define DEBUG_CANCEL BUTTON_MENU | 27 | #define DEBUG_CANCEL BUTTON_MENU |
28 | 28 | ||
29 | bool __dbg_hw_info(void); | 29 | bool dbg_hw_info(void); |
30 | bool dbg_ports(void); | 30 | bool dbg_ports(void); |
31 | 31 | ||
32 | #endif /* _DEBUG_TARGET_H_ */ | 32 | #endif /* _DEBUG_TARGET_H_ */ |
diff --git a/firmware/target/arm/tcc77x/debug-target.h b/firmware/target/arm/tcc77x/debug-target.h index 6cf93cc5a4..c985751a23 100644 --- a/firmware/target/arm/tcc77x/debug-target.h +++ b/firmware/target/arm/tcc77x/debug-target.h | |||
@@ -19,6 +19,6 @@ | |||
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | bool __dbg_hw_info(void); | 22 | bool dbg_hw_info(void); |
23 | bool dbg_ports(void); | 23 | bool dbg_ports(void); |
24 | 24 | ||
diff --git a/firmware/target/arm/tcc77x/debug-tcc77x.c b/firmware/target/arm/tcc77x/debug-tcc77x.c index 88b0722a4e..250afb46c7 100644 --- a/firmware/target/arm/tcc77x/debug-tcc77x.c +++ b/firmware/target/arm/tcc77x/debug-tcc77x.c | |||
@@ -36,7 +36,7 @@ bool dbg_ports(void) | |||
36 | return false; | 36 | return false; |
37 | } | 37 | } |
38 | 38 | ||
39 | bool __dbg_hw_info(void) | 39 | bool dbg_hw_info(void) |
40 | { | 40 | { |
41 | int line = 0, i, button, oldline; | 41 | int line = 0, i, button, oldline; |
42 | bool done=false; | 42 | bool done=false; |
diff --git a/firmware/target/arm/tcc780x/debug-target.h b/firmware/target/arm/tcc780x/debug-target.h index 6cf93cc5a4..c985751a23 100644 --- a/firmware/target/arm/tcc780x/debug-target.h +++ b/firmware/target/arm/tcc780x/debug-target.h | |||
@@ -19,6 +19,6 @@ | |||
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | bool __dbg_hw_info(void); | 22 | bool dbg_hw_info(void); |
23 | bool dbg_ports(void); | 23 | bool dbg_ports(void); |
24 | 24 | ||
diff --git a/firmware/target/arm/tcc780x/debug-tcc780x.c b/firmware/target/arm/tcc780x/debug-tcc780x.c index d527e2b045..22de868639 100644 --- a/firmware/target/arm/tcc780x/debug-tcc780x.c +++ b/firmware/target/arm/tcc780x/debug-tcc780x.c | |||
@@ -40,7 +40,7 @@ bool dbg_ports(void) | |||
40 | return false; | 40 | return false; |
41 | } | 41 | } |
42 | 42 | ||
43 | bool __dbg_hw_info(void) | 43 | bool dbg_hw_info(void) |
44 | { | 44 | { |
45 | int line = 0, i, oldline; | 45 | int line = 0, i, oldline; |
46 | 46 | ||
diff --git a/firmware/target/arm/tms320dm320/debug-dm320.c b/firmware/target/arm/tms320dm320/debug-dm320.c index 26f34a4f5f..de17d54843 100644 --- a/firmware/target/arm/tms320dm320/debug-dm320.c +++ b/firmware/target/arm/tms320dm320/debug-dm320.c | |||
@@ -121,7 +121,7 @@ bool dbg_ports(void) | |||
121 | return false; | 121 | return false; |
122 | } | 122 | } |
123 | 123 | ||
124 | bool __dbg_hw_info(void) | 124 | bool dbg_hw_info(void) |
125 | { | 125 | { |
126 | int line = 0, oldline; | 126 | int line = 0, oldline; |
127 | int button; | 127 | int button; |
diff --git a/firmware/target/arm/tms320dm320/debug-target.h b/firmware/target/arm/tms320dm320/debug-target.h index bcf9d688cd..5fc0c98ce0 100644 --- a/firmware/target/arm/tms320dm320/debug-target.h +++ b/firmware/target/arm/tms320dm320/debug-target.h | |||
@@ -19,5 +19,5 @@ | |||
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | bool __dbg_hw_info(void); | 22 | bool dbg_hw_info(void); |
23 | bool dbg_ports(void); | 23 | bool dbg_ports(void); |
diff --git a/firmware/target/coldfire/debug-coldfire.c b/firmware/target/coldfire/debug-coldfire.c index 14221d6f02..b021cd19c0 100644 --- a/firmware/target/coldfire/debug-coldfire.c +++ b/firmware/target/coldfire/debug-coldfire.c | |||
@@ -29,6 +29,58 @@ | |||
29 | #include "adc.h" | 29 | #include "adc.h" |
30 | #include "debug-target.h" | 30 | #include "debug-target.h" |
31 | #include "lcd-remote.h" | 31 | #include "lcd-remote.h" |
32 | #ifdef IAUDIO_X5 | ||
33 | #include "ds2411.h" | ||
34 | #endif | ||
35 | |||
36 | /* Tool function to read the flash manufacturer and type, if available. | ||
37 | Only chips which could be reprogrammed in system will return values. | ||
38 | (The mode switch addresses vary between flash manufacturers, hence addr1/2) */ | ||
39 | /* In IRAM to avoid problems when running directly from Flash */ | ||
40 | static bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device, | ||
41 | unsigned addr1, unsigned addr2) | ||
42 | ICODE_ATTR __attribute__((noinline)); | ||
43 | static bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device, | ||
44 | unsigned addr1, unsigned addr2) | ||
45 | |||
46 | { | ||
47 | unsigned not_manu, not_id; /* read values before switching to ID mode */ | ||
48 | unsigned manu, id; /* read values when in ID mode */ | ||
49 | |||
50 | volatile unsigned short* flash = (unsigned short*)0; /* flash mapping */ | ||
51 | int old_level; /* saved interrupt level */ | ||
52 | |||
53 | not_manu = flash[0]; /* read the normal content */ | ||
54 | not_id = flash[1]; /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */ | ||
55 | |||
56 | /* disable interrupts, prevent any stray flash access */ | ||
57 | old_level = disable_irq_save(); | ||
58 | |||
59 | flash[addr1] = 0xAA; /* enter command mode */ | ||
60 | flash[addr2] = 0x55; | ||
61 | flash[addr1] = 0x90; /* ID command */ | ||
62 | /* Atmel wants 20ms pause here */ | ||
63 | /* sleep(HZ/50); no sleeping possible while interrupts are disabled */ | ||
64 | manu = flash[0]; /* read the IDs */ | ||
65 | id = flash[1]; | ||
66 | |||
67 | flash[0] = 0xF0; /* reset flash (back to normal read mode) */ | ||
68 | /* Atmel wants 20ms pause here */ | ||
69 | /* sleep(HZ/50); no sleeping possible while interrupts are disabled */ | ||
70 | |||
71 | restore_irq(old_level); /* enable interrupts again */ | ||
72 | |||
73 | /* I assume success if the obtained values are different from | ||
74 | the normal flash content. This is not perfectly bulletproof, they | ||
75 | could theoretically be the same by chance, causing us to fail. */ | ||
76 | if (not_manu != manu || not_id != id) /* a value has changed */ | ||
77 | { | ||
78 | *p_manufacturer = manu; /* return the results */ | ||
79 | *p_device = id; | ||
80 | return true; /* success */ | ||
81 | } | ||
82 | return false; /* fail */ | ||
83 | } | ||
32 | 84 | ||
33 | bool dbg_ports(void) | 85 | bool dbg_ports(void) |
34 | { | 86 | { |
@@ -105,3 +157,59 @@ bool dbg_ports(void) | |||
105 | } | 157 | } |
106 | return false; | 158 | return false; |
107 | } | 159 | } |
160 | |||
161 | bool dbg_hw_info(void) | ||
162 | { | ||
163 | unsigned manu, id; /* flash IDs */ | ||
164 | int got_id; /* flag if we managed to get the flash IDs */ | ||
165 | int oldmode; /* saved memory guard mode */ | ||
166 | int line = 0; | ||
167 | |||
168 | oldmode = system_memory_guard(MEMGUARD_NONE); /* disable memory guard */ | ||
169 | |||
170 | /* get flash ROM type */ | ||
171 | got_id = dbg_flash_id(&manu, &id, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */ | ||
172 | if (!got_id) | ||
173 | got_id = dbg_flash_id(&manu, &id, 0x555, 0x2AA); /* try AMD, Macronix */ | ||
174 | |||
175 | system_memory_guard(oldmode); /* re-enable memory guard */ | ||
176 | |||
177 | lcd_setfont(FONT_SYSFIXED); | ||
178 | lcd_clear_display(); | ||
179 | |||
180 | lcd_puts(0, line++, "[Hardware info]"); | ||
181 | |||
182 | if (got_id) | ||
183 | lcd_putsf(0, line++, "Flash: M=%04x D=%04x", manu, id); | ||
184 | else | ||
185 | lcd_puts(0, line++, "Flash: M=???? D=????"); /* unknown, sorry */ | ||
186 | |||
187 | #ifdef IAUDIO_X5 | ||
188 | { | ||
189 | struct ds2411_id id; | ||
190 | |||
191 | lcd_puts(0, ++line, "Serial Number:"); | ||
192 | |||
193 | got_id = ds2411_read_id(&id); | ||
194 | |||
195 | if (got_id == DS2411_OK) | ||
196 | { | ||
197 | lcd_putsf(0, ++line, " FC=%02x", (unsigned)id.family_code); | ||
198 | lcd_putsf(0, ++line, " ID=%02X %02X %02X %02X %02X %02X", | ||
199 | (unsigned)id.uid[0], (unsigned)id.uid[1], (unsigned)id.uid[2], | ||
200 | (unsigned)id.uid[3], (unsigned)id.uid[4], (unsigned)id.uid[5]); | ||
201 | lcd_putsf(0, ++line, " CRC=%02X", (unsigned)id.crc); | ||
202 | } | ||
203 | else | ||
204 | { | ||
205 | lcd_putsf(0, ++line, "READ ERR=%d", got_id); | ||
206 | } | ||
207 | } | ||
208 | #endif | ||
209 | |||
210 | /* wait for exit */ | ||
211 | while (button_get_w_tmo(HZ/10) != (DEBUG_CANCEL|BUTTON_REL)); | ||
212 | |||
213 | lcd_setfont(FONT_UI); | ||
214 | return false; | ||
215 | } | ||
diff --git a/firmware/target/coldfire/debug-target.h b/firmware/target/coldfire/debug-target.h index 8d01cdd6f1..71ff75360c 100644 --- a/firmware/target/coldfire/debug-target.h +++ b/firmware/target/coldfire/debug-target.h | |||
@@ -33,3 +33,4 @@ | |||
33 | # define DEBUG_CANCEL BUTTON_REC | 33 | # define DEBUG_CANCEL BUTTON_REC |
34 | #endif | 34 | #endif |
35 | bool dbg_ports(void); | 35 | bool dbg_ports(void); |
36 | bool dbg_hw_info(void); | ||
diff --git a/firmware/target/mips/ingenic_jz47xx/debug-jz4740.c b/firmware/target/mips/ingenic_jz47xx/debug-jz4740.c index 5bdd4c4de9..d7170567f9 100644 --- a/firmware/target/mips/ingenic_jz47xx/debug-jz4740.c +++ b/firmware/target/mips/ingenic_jz47xx/debug-jz4740.c | |||
@@ -134,7 +134,7 @@ bool dbg_ports(void) | |||
134 | return false; | 134 | return false; |
135 | } | 135 | } |
136 | 136 | ||
137 | bool __dbg_hw_info(void) | 137 | bool dbg_hw_info(void) |
138 | { | 138 | { |
139 | int btn = 0; | 139 | int btn = 0; |
140 | #ifdef HAVE_TOUCHSCREEN | 140 | #ifdef HAVE_TOUCHSCREEN |
diff --git a/firmware/target/mips/ingenic_jz47xx/debug-target.h b/firmware/target/mips/ingenic_jz47xx/debug-target.h index f82b43da5b..f51c5bf8da 100644 --- a/firmware/target/mips/ingenic_jz47xx/debug-target.h +++ b/firmware/target/mips/ingenic_jz47xx/debug-target.h | |||
@@ -22,7 +22,7 @@ | |||
22 | #ifndef __DEBUG_TARGET_H_ | 22 | #ifndef __DEBUG_TARGET_H_ |
23 | #define __DEBUG_TARGET_H_ | 23 | #define __DEBUG_TARGET_H_ |
24 | 24 | ||
25 | bool __dbg_hw_info(void); | 25 | bool dbg_hw_info(void); |
26 | bool dbg_ports(void); | 26 | bool dbg_ports(void); |
27 | 27 | ||
28 | #endif /* __DEBUG_TARGET_H_ */ | 28 | #endif /* __DEBUG_TARGET_H_ */ |
diff --git a/firmware/target/sh/debug-sh.c b/firmware/target/sh/debug-sh.c index 3502cfade0..78d0032199 100644 --- a/firmware/target/sh/debug-sh.c +++ b/firmware/target/sh/debug-sh.c | |||
@@ -22,13 +22,65 @@ | |||
22 | #include "config.h" | 22 | #include "config.h" |
23 | #include "system.h" | 23 | #include "system.h" |
24 | #include <stdbool.h> | 24 | #include <stdbool.h> |
25 | #include <string.h> | ||
25 | #include "font.h" | 26 | #include "font.h" |
26 | #include "lcd.h" | 27 | #include "lcd.h" |
27 | #include "button.h" | 28 | #include "button.h" |
28 | #include "powermgmt.h" | 29 | #include "powermgmt.h" |
29 | #include "adc.h" | 30 | #include "adc.h" |
31 | #include "hwcompat.h" /* ROM_VERSION */ | ||
32 | #include "crc32.h" | ||
30 | #include "debug-target.h" | 33 | #include "debug-target.h" |
31 | 34 | ||
35 | |||
36 | /* Tool function to read the flash manufacturer and type, if available. | ||
37 | Only chips which could be reprogrammed in system will return values. | ||
38 | (The mode switch addresses vary between flash manufacturers, hence addr1/2) */ | ||
39 | /* In IRAM to avoid problems when running directly from Flash */ | ||
40 | static bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device, | ||
41 | unsigned addr1, unsigned addr2) | ||
42 | ICODE_ATTR __attribute__((noinline)); | ||
43 | static bool dbg_flash_id(unsigned* p_manufacturer, unsigned* p_device, | ||
44 | unsigned addr1, unsigned addr2) | ||
45 | { | ||
46 | unsigned not_manu, not_id; /* read values before switching to ID mode */ | ||
47 | unsigned manu, id; /* read values when in ID mode */ | ||
48 | |||
49 | volatile unsigned char* flash = (unsigned char*)0x2000000; /* flash mapping */ | ||
50 | int old_level; /* saved interrupt level */ | ||
51 | |||
52 | not_manu = flash[0]; /* read the normal content */ | ||
53 | not_id = flash[1]; /* should be 'A' (0x41) and 'R' (0x52) from the "ARCH" marker */ | ||
54 | |||
55 | /* disable interrupts, prevent any stray flash access */ | ||
56 | old_level = disable_irq_save(); | ||
57 | |||
58 | flash[addr1] = 0xAA; /* enter command mode */ | ||
59 | flash[addr2] = 0x55; | ||
60 | flash[addr1] = 0x90; /* ID command */ | ||
61 | /* Atmel wants 20ms pause here */ | ||
62 | /* sleep(HZ/50); no sleeping possible while interrupts are disabled */ | ||
63 | |||
64 | manu = flash[0]; /* read the IDs */ | ||
65 | id = flash[1]; | ||
66 | |||
67 | flash[0] = 0xF0; /* reset flash (back to normal read mode) */ | ||
68 | /* Atmel wants 20ms pause here */ | ||
69 | /* sleep(HZ/50); no sleeping possible while interrupts are disabled */ | ||
70 | |||
71 | restore_irq(old_level); /* enable interrupts again */ | ||
72 | /* I assume success if the obtained values are different from | ||
73 | the normal flash content. This is not perfectly bulletproof, they | ||
74 | could theoretically be the same by chance, causing us to fail. */ | ||
75 | if (not_manu != manu || not_id != id) /* a value has changed */ | ||
76 | { | ||
77 | *p_manufacturer = manu; /* return the results */ | ||
78 | *p_device = id; | ||
79 | return true; /* success */ | ||
80 | } | ||
81 | return false; /* fail */ | ||
82 | } | ||
83 | |||
32 | bool dbg_ports(void) | 84 | bool dbg_ports(void) |
33 | { | 85 | { |
34 | int adc_battery_voltage; | 86 | int adc_battery_voltage; |
@@ -58,11 +110,11 @@ bool dbg_ports(void) | |||
58 | adc_battery_voltage % 1000, adc_battery_level); | 110 | adc_battery_voltage % 1000, adc_battery_level); |
59 | 111 | ||
60 | lcd_update(); | 112 | lcd_update(); |
61 | if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL)) | 113 | |
62 | { | 114 | while (button_get_w_tmo(HZ/10) != (DEBUG_CANCEL|BUTTON_REL)); |
63 | lcd_setfont(FONT_UI); | 115 | |
64 | return false; | 116 | lcd_setfont(FONT_UI); |
65 | } | 117 | |
66 | #else /* !HAVE_LCD_BITMAP */ | 118 | #else /* !HAVE_LCD_BITMAP */ |
67 | 119 | ||
68 | if (currval == 0) { | 120 | if (currval == 0) { |
@@ -101,3 +153,127 @@ bool dbg_ports(void) | |||
101 | } | 153 | } |
102 | return false; | 154 | return false; |
103 | } | 155 | } |
156 | |||
157 | bool dbg_hw_info(void) | ||
158 | { | ||
159 | #ifndef HAVE_LCD_BITMAP | ||
160 | int button; | ||
161 | int currval = 0; | ||
162 | #else | ||
163 | int bitmask = HW_MASK; | ||
164 | #endif | ||
165 | int rom_version = ROM_VERSION; | ||
166 | unsigned manu, id; /* flash IDs */ | ||
167 | bool got_id; /* flag if we managed to get the flash IDs */ | ||
168 | unsigned rom_crc = 0xffffffff; /* CRC32 of the boot ROM */ | ||
169 | bool has_bootrom; /* flag for boot ROM present */ | ||
170 | int oldmode; /* saved memory guard mode */ | ||
171 | |||
172 | oldmode = system_memory_guard(MEMGUARD_NONE); /* disable memory guard */ | ||
173 | |||
174 | /* get flash ROM type */ | ||
175 | got_id = dbg_flash_id(&manu, &id, 0x5555, 0x2AAA); /* try SST, Atmel, NexFlash */ | ||
176 | if (!got_id) | ||
177 | got_id = dbg_flash_id(&manu, &id, 0x555, 0x2AA); /* try AMD, Macronix */ | ||
178 | |||
179 | /* check if the boot ROM area is a flash mirror */ | ||
180 | has_bootrom = (memcmp((char*)0, (char*)0x02000000, 64*1024) != 0); | ||
181 | if (has_bootrom) /* if ROM and Flash different */ | ||
182 | { | ||
183 | /* calculate CRC16 checksum of boot ROM */ | ||
184 | rom_crc = crc_32((unsigned char*)0x0000, 64*1024, 0xffffffff); | ||
185 | } | ||
186 | |||
187 | system_memory_guard(oldmode); /* re-enable memory guard */ | ||
188 | |||
189 | lcd_clear_display(); | ||
190 | |||
191 | #ifdef HAVE_LCD_BITMAP | ||
192 | lcd_setfont(FONT_SYSFIXED); | ||
193 | |||
194 | lcd_puts(0, 0, "[Hardware info]"); | ||
195 | |||
196 | lcd_putsf(0, 1, "ROM: %d.%02d", rom_version/100, rom_version%100); | ||
197 | |||
198 | lcd_putsf(0, 2, "Mask: 0x%04x", bitmask); | ||
199 | if (got_id) | ||
200 | lcd_putsf(0, 3, "Flash: M=%02x D=%02x", manu, id); | ||
201 | else | ||
202 | lcd_puts(0, 3, "Flash: M=?? D=??"); /* unknown, sorry */ | ||
203 | |||
204 | if (has_bootrom) | ||
205 | { | ||
206 | if (rom_crc == 0x56DBA4EE) /* known Version 1 */ | ||
207 | lcd_puts(0, 4, "Boot ROM: V1"); | ||
208 | else | ||
209 | lcd_putsf(0, 4, "ROMcrc: 0x%08x", rom_crc); | ||
210 | } | ||
211 | else | ||
212 | { | ||
213 | lcd_puts(0, 4, "Boot ROM: none"); | ||
214 | } | ||
215 | |||
216 | lcd_update(); | ||
217 | |||
218 | /* wait for exit */ | ||
219 | while (button_get_w_tmo(HZ/10) != (DEBUG_CANCEL|BUTTON_REL)); | ||
220 | |||
221 | lcd_setfont(FONT_UI); | ||
222 | |||
223 | #else /* !HAVE_LCD_BITMAP */ | ||
224 | lcd_puts(0, 0, "[HW Info]"); | ||
225 | while(1) | ||
226 | { | ||
227 | switch(currval) | ||
228 | { | ||
229 | case 0: | ||
230 | lcd_putsf(0, 1, "ROM: %d.%02d", | ||
231 | rom_version/100, rom_version%100); | ||
232 | break; | ||
233 | case 1: | ||
234 | if (got_id) | ||
235 | lcd_putsf(0, 1, "Flash:%02x,%02x", manu, id); | ||
236 | else | ||
237 | lcd_puts(0, 1, "Flash:??,??"); /* unknown, sorry */ | ||
238 | break; | ||
239 | case 2: | ||
240 | if (has_bootrom) | ||
241 | { | ||
242 | if (rom_crc == 0x56DBA4EE) /* known Version 1 */ | ||
243 | lcd_puts(0, 1, "BootROM: V1"); | ||
244 | else if (rom_crc == 0x358099E8) | ||
245 | lcd_puts(0, 1, "BootROM: V2"); | ||
246 | /* alternative boot ROM found in one single player so far */ | ||
247 | else | ||
248 | lcd_putsf(0, 1, "R: %08x", rom_crc); | ||
249 | } | ||
250 | else | ||
251 | lcd_puts(0, 1, "BootROM: no"); | ||
252 | } | ||
253 | |||
254 | lcd_update(); | ||
255 | |||
256 | button = button_get_w_tmo(HZ/10); | ||
257 | |||
258 | switch(button) | ||
259 | { | ||
260 | case BUTTON_STOP: | ||
261 | return false; | ||
262 | |||
263 | case BUTTON_LEFT: | ||
264 | currval--; | ||
265 | if(currval < 0) | ||
266 | currval = 2; | ||
267 | break; | ||
268 | |||
269 | case BUTTON_RIGHT: | ||
270 | currval++; | ||
271 | if(currval > 2) | ||
272 | currval = 0; | ||
273 | break; | ||
274 | } | ||
275 | } | ||
276 | #endif | ||
277 | return false; | ||
278 | } | ||
279 | |||
diff --git a/firmware/target/sh/debug-target.h b/firmware/target/sh/debug-target.h index 4e25b81948..f738795ea6 100644 --- a/firmware/target/sh/debug-target.h +++ b/firmware/target/sh/debug-target.h | |||
@@ -25,3 +25,4 @@ | |||
25 | # define DEBUG_CANCEL BUTTON_MENU | 25 | # define DEBUG_CANCEL BUTTON_MENU |
26 | #endif | 26 | #endif |
27 | bool dbg_ports(void); | 27 | bool dbg_ports(void); |
28 | bool dbg_hw_info(void); | ||