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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
diff --git a/firmware/target/arm/crt0-pp.S b/firmware/target/arm/crt0-pp.S
index bd1fc03..ad515aa 100644
--- a/firmware/target/arm/crt0-pp.S
+++ b/firmware/target/arm/crt0-pp.S
@@ -231,6 +231,17 @@ cpu_init:
     strhi  r4, [r2], #4
     bhi    1b

+    /* copy init data to plugin buffer */
+    ldr    r2, =_initstart
+    ldr    r3, =_initend
+    ldr    r4, =codecbuf
+
+1:
+    cmp     r3, r2
+    ldrhi   r5, [r2], #4
+    strhi   r5, [r4], #4
+    bhi 1b
+
     /* Load stack munge value */    
     ldr    r4, =0xdeadbeef

diff --git a/firmware/target/arm/sandisk/app.lds b/firmware/target/arm/sandisk/app.lds
index 3010644..7353698 100644
--- a/firmware/target/arm/sandisk/app.lds
+++ b/firmware/target/arm/sandisk/app.lds
@@ -37,8 +37,9 @@ STARTUP(target/arm/crt0-pp.o)

 MEMORY
 {
-    DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE
-    IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE
+    DRAM : ORIGIN = DRAMORIG,     LENGTH = DRAMSIZE
+    IRAM : ORIGIN = IRAMORIG,     LENGTH = IRAMSIZE
+    INIT : ORIGIN = ENDAUDIOADDR, LENGTH = CODECSIZE
 }

 SECTIONS
@@ -177,6 +178,16 @@ SECTIONS
         _audiobuffer = .;
         audiobuffer = .;
     } > DRAM
+
+    .init_text :
+    {
+        . = ALIGN(0x4);
+        _initstart = .;
+        *(.init)
+        . = ALIGN(0x4);
+        _initend = .;
+    } > INIT AT> DRAM
+

     .audiobufend ENDAUDIOADDR (NOLOAD) :
     {
diff --git a/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c b/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c
index 03f6a1b..36bc63b 100644
--- a/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c
+++ b/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c
@@ -353,6 +353,7 @@ static void lcd_display_off(void)
 }
 #endif

+void lcd_init_device(void) __attribute__((section(".init")));
 void lcd_init_device(void)
 {
 /* All this is magic worked out by MrH */
@@ -435,6 +436,7 @@ void lcd_init_device(void)
 #endif

     LCD_REG_6 |= 1; /* Start DMA */
+    _backlight_set_brightness(0);
 }

 #if defined(HAVE_LCD_ENABLE)