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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
diff --git a/apps/main.c b/apps/main.c
index e4b9286..bd9f094 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -315,7 +315,7 @@ static void init_tagcache(void)
 }
 #endif

-#ifdef SIMULATOR
+#if 0

 static void init(void)
 {
@@ -331,7 +331,6 @@ static void init(void)
     show_logo();
     button_init();
     backlight_init();
-    sim_tasks_init();
     lang_init(core_language_builtin, language_strings, 
               LANG_LAST_INDEX_IN_ARRAY);
 #ifdef DEBUG
@@ -389,7 +388,7 @@ static void init(void)
     settings_apply_skins();
 }

-#else
+#endif

 static void init(void) INIT_ATTR;
 static void init(void)
@@ -416,9 +415,10 @@ static void init(void)

     settings_reset();

+#ifndef SIMULATOR
     i2c_init();
-    
     power_init();
+#endif

     enable_irq();
 #ifdef CPU_ARM
@@ -447,6 +447,8 @@ static void init(void)
 #endif
 #endif

+#ifndef SIMULATOR
+
 #if CONFIG_RTC
     rtc_init();
 #endif
@@ -465,16 +467,19 @@ static void init(void)
     m5636_init();
 #endif

+#else /* SIMULATOR */
+    sim_tasks_init();
+#endif /* !SIMULATOR */
+
     backlight_init();

     button_init();
-
+#ifndef SIMULATOR
     powermgmt_init();
-
 #if CONFIG_TUNER
     radio_init();
 #endif
-
+#endif /* SIMULATOR */
     /* Keep the order of this 3 (viewportmanager handles statusbars)
      * Must be done before any code uses the multi-screen API */
     CHART(">gui_syncstatusbar_init");
@@ -511,6 +516,7 @@ static void init(void)
     CHART(">storage_init");
     rc = storage_init();
     CHART("<storage_init");
+#ifndef SIMULATOR
     if(rc)
     {
 #ifdef HAVE_LCD_BITMAP
@@ -523,6 +529,7 @@ static void init(void)
 #endif
         panicf("ata: %d", rc);
     }
+#endif

 #ifdef HAVE_EEPROM_SETTINGS
     CHART(">eeprom_settings_init");
@@ -530,7 +537,7 @@ static void init(void)
     CHART("<eeprom_settings_init");
 #endif

-#ifndef HAVE_USBSTACK
+#if !defined(HAVE_USBSTACK) && !defined(SIMULATOR)
     usb_start_monitoring();
     while (usb_detect() == USB_INSERTED)
     {
@@ -556,6 +563,7 @@ static void init(void)

     if (!mounted)
     {
+#ifndef SIMULATOR
         CHART(">disk_mount_all");
         rc = disk_mount_all();
         CHART("<disk_mount_all");
@@ -574,6 +582,7 @@ static void init(void)
             gui_usb_screen_run();
             system_reboot();
         }
+#endif
     }

 #if defined(SETTINGS_RESET) || (CONFIG_KEYPAD == IPOD_4G_PAD) || \
@@ -664,7 +673,8 @@ static void init(void)
     audio_init();
     CHART("<audio_init");

-#if (CONFIG_CODEC == SWCODEC) && defined(HAVE_RECORDING) && !defined(SIMULATOR)
+#ifndef SIMULATOR
+#if (CONFIG_CODEC == SWCODEC) && defined(HAVE_RECORDING)
     pcm_rec_init();
 #endif

@@ -688,6 +698,7 @@ static void init(void)
     check_bootfile(false); /* remember write time and filesize */
     CHART(">check_bootfile(false)");
 #endif
+#endif
     CHART("<settings_apply_skins");
     settings_apply_skins();
     CHART(">settings_apply_skins");
@@ -717,5 +728,4 @@ void cop_main(void)
 }
 #endif /* CPU_PP */

-#endif

diff --git a/firmware/export/config/sim.h b/firmware/export/config/sim.h
index d65b0fb..46be5fa 100644
--- a/firmware/export/config/sim.h
+++ b/firmware/export/config/sim.h
@@ -82,6 +82,8 @@

 #undef BUTTON_DRIVER_CLOSE

+#undef HAVE_SERIAL
+
 #if     CONFIG_BACKLIGHT_FADING == BACKLIGHT_FADING_SW_HW_REG
 #undef  CONFIG_BACKLIGHT_FADING
         /* simulate SW_SETTING, as we handle sdl very similary */
diff --git a/firmware/target/hosted/sdl/system-sdl.c b/firmware/target/hosted/sdl/system-sdl.c
index 7ab6fd2..f599fdd 100644
--- a/firmware/target/hosted/sdl/system-sdl.c
+++ b/firmware/target/hosted/sdl/system-sdl.c
@@ -28,14 +28,6 @@
 #include "thread-sdl.h"
 #include "sim-ui-defines.h"
 #include "lcd-sdl.h"
-#ifdef HAVE_LCD_BITMAP
-#include "lcd-bitmap.h"
-#elif defined(HAVE_LCD_CHARCELLS)
-#include "lcd-charcells.h"
-#endif
-#ifdef HAVE_REMOTE_LCD
-#include "lcd-remote-bitmap.h"
-#endif
 #include "panic.h"
 #include "debug.h"

diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c
index 2aa0f12..54f5c76 100644
--- a/uisimulator/common/stubs.c
+++ b/uisimulator/common/stubs.c
@@ -58,7 +58,8 @@ bool fat_ismounted(int volume)

 int storage_init(void)
 {
-    return 1;
+    /* assume success */
+    return 0;
 }

 int storage_write_sectors(IF_MV2(int drive,)