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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
diff --git a/apps/codecs.c b/apps/codecs.c
index 86e36ed..c9f612b 100644
--- a/apps/codecs.c
+++ b/apps/codecs.c
@@ -54,7 +54,7 @@
 #define LOGF_ENABLE
 #include "logf.h"

-#if (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO))
+#if (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA))
 #define PREFIX(_x_) sim_ ## _x_
 #else
 #define PREFIX(_x_) _x_
diff --git a/apps/main.c b/apps/main.c
index bd04223..001f368 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -125,7 +125,7 @@
 #define MAIN_NORETURN_ATTR
 #endif

-#if (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO))
+#if (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA))
 #include "sim_tasks.h"
 #include "system-sdl.h"
 #define HAVE_ARGV_MAIN
@@ -351,7 +351,7 @@ static void init(void)
     show_logo();
     button_init();
     backlight_init();
-#if (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO))
+#if (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA))
     sim_tasks_init();
 #endif
 #if (CONFIG_PLATFORM & PLATFORM_ANDROID)
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 154479b..2d73028 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -217,7 +217,7 @@ static const char graphic_numeric[] = "graphic,numeric";
   #define DEFAULT_FONTNAME "15-Adobe-Helvetica"
 #elif LCD_HEIGHT <= 400
   #define DEFAULT_FONTNAME "16-Adobe-Helvetica"
-#elif LCD_HEIGHT <= 480 && !(CONFIG_PLATFORM & PLATFORM_MAEMO)
+#elif LCD_HEIGHT <= 480 && !(CONFIG_PLATFORM & (PLATFORM_MAEMO|PLATFORM_PANDORA))
   #define DEFAULT_FONTNAME "27-Adobe-Helvetica"
 #else
   #define DEFAULT_FONTNAME "35-Adobe-Helvetica"
diff --git a/firmware/common/filefuncs.c b/firmware/common/filefuncs.c
index 3811f06..6eb2baf 100644
--- a/firmware/common/filefuncs.c
+++ b/firmware/common/filefuncs.c
@@ -91,7 +91,7 @@ bool dir_exists(const char *path)

 #endif /* __PCTOOL__ */

-#if (CONFIG_PLATFORM & (PLATFORM_NATIVE|PLATFORM_SDL|PLATFORM_MAEMO))
+#if (CONFIG_PLATFORM & (PLATFORM_NATIVE|PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA))
 struct dirinfo dir_get_info(DIR* parent, struct dirent *entry)
 {
     (void)parent;
diff --git a/firmware/common/rbpaths.c b/firmware/common/rbpaths.c
index 10fceb6..cb56ab4 100644
--- a/firmware/common/rbpaths.c
+++ b/firmware/common/rbpaths.c
@@ -43,7 +43,7 @@
 #define opendir opendir_android
 #define mkdir   mkdir_android
 #define rmdir   rmdir_android
-#elif (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO))
+#elif (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA))
 #define open    sim_open
 #define remove  sim_remove
 #define rename  sim_rename
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 1783cc1..d00958a 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -86,6 +86,7 @@
 #define PLATFORM_MAEMO4  (1<<4)
 #define PLATFORM_MAEMO5  (1<<5)
 #define PLATFORM_MAEMO   (PLATFORM_MAEMO4|PLATFORM_MAEMO5)
+#define PLATFORM_PANDORA (1<<6)

 /* CONFIG_KEYPAD */
 #define PLAYER_PAD          1
@@ -448,6 +449,8 @@ Lyre prototype 1 */
 #include "config/nokian8xx.h"
 #elif defined(NOKIAN900)
 #include "config/nokian900.h"
+#elif defined(PANDORA)
+#include "config/pandora.h"
 #else
 /* no known platform */
 #endif
@@ -511,7 +514,8 @@ Lyre prototype 1 */
 #endif

 /* define for all cpus from ARM family */
-#if (CONFIG_PLATFORM & PLATFORM_MAEMO5) && defined(MAEMO_ARM_BUILD)
+#if ((CONFIG_PLATFORM & PLATFORM_MAEMO5) && defined(MAEMO_ARM_BUILD)) \
+  || (CONFIG_PLATFORM & PLATFORM_PANDORA)
 #define CPU_ARM
 #define ARM_ARCH 7 /* ARMv7 */

diff --git a/firmware/export/config/pandora.h b/firmware/export/config/pandora.h
new file mode 100644
index 0000000..81dd75b
--- /dev/null
+++ b/firmware/export/config/pandora.h
@@ -0,0 +1,96 @@
+/*
+ * This config file is for Rockbox as an application on the Nokia N8xx
+ */
+#define TARGET_TREE /* this target is using the target tree system */
+
+/* We don't run on hardware directly */
+#define CONFIG_PLATFORM (PLATFORM_HOSTED|PLATFORM_PANDORA)
+
+/* For Rolo and boot loader */
+#define MODEL_NUMBER 100
+
+#define MODEL_NAME   "Rockbox"
+
+#define USB_NONE
+
+/* define this if you have a bitmap LCD display */
+#define HAVE_LCD_BITMAP
+
+/* define this if you have a colour LCD */
+#define HAVE_LCD_COLOR
+
+/* define this if you want album art for this target */
+#define HAVE_ALBUMART
+
+/* define this to enable bitmap scaling */
+#define HAVE_BMP_SCALING
+
+/* define this to enable JPEG decoding */
+#define HAVE_JPEG
+
+/* define this if you have access to the quickscreen */
+#define HAVE_QUICKSCREEN
+/* define this if you have access to the pitchscreen */
+#define HAVE_PITCHSCREEN
+
+/* define this if you would like tagcache to build on this target */
+#define HAVE_TAGCACHE
+
+/* LCD dimensions */
+#define LCD_WIDTH  800
+#define LCD_HEIGHT 480
+#define LCD_DEPTH  16
+#define LCD_PIXELFORMAT 565
+
+/* define this to indicate your device's keypad */
+#define HAVE_TOUCHSCREEN
+#define HAVE_BUTTON_DATA
+
+/* define this if you have RTC RAM available for settings */
+//#define HAVE_RTC_RAM
+
+/* The number of bytes reserved for loadable codecs */
+#define CODEC_SIZE 0x100000
+
+/* The number of bytes reserved for loadable plugins */
+#define PLUGIN_BUFFER_SIZE 0x80000
+
+#define AB_REPEAT_ENABLE
+
+/* Define this if you do software codec */
+#define CONFIG_CODEC SWCODEC
+
+/* Work around debug macro expansion of strncmp in scratchbox */
+#define _HAVE_STRING_ARCH_strncmp
+
+#define HAVE_SCROLLWHEEL
+#define CONFIG_KEYPAD SDL_PAD
+
+/* Use SDL audio/pcm in a SDL app build */
+#define HAVE_SDL
+#define HAVE_SDL_AUDIO
+
+#define HAVE_SW_TONE_CONTROLS 
+
+/* Define current usage levels. */
+#define CURRENT_NORMAL     88 /* 18 hours from a 1600 mAh battery */  
+#define CURRENT_BACKLIGHT  30 /* TBD */ 
+#define CURRENT_RECORD     0  /* no recording yet */ 
+
+/* Define this to the CPU frequency */
+/*
+#define CPU_FREQ 48000000
+*/
+
+/* Offset ( in the firmware file's header ) to the file CRC */
+#define FIRMWARE_OFFSET_FILE_CRC 0
+
+/* Offset ( in the firmware file's header ) to the real data */
+#define FIRMWARE_OFFSET_FILE_DATA 8
+
+#define CONFIG_LCD LCD_COWOND2
+
+/* Define this if a programmable hotkey is mapped */
+//#define HAVE_HOTKEY
+
+#define BOOTDIR "/.rockbox"
diff --git a/firmware/export/debug.h b/firmware/export/debug.h
index 99cdf42..b5458af 100644
--- a/firmware/export/debug.h
+++ b/firmware/export/debug.h
@@ -34,7 +34,7 @@ extern void ldebugf(const char* file, int line, const char *fmt, ...)

 /*  */
 #if defined(SIMULATOR) && !defined(__PCTOOL__) \
-    || ((CONFIG_PLATFORM & (PLATFORM_ANDROID|PLATFORM_MAEMO)) && defined(DEBUG))
+    || ((CONFIG_PLATFORM & (PLATFORM_ANDROID|PLATFORM_MAEMO|PLATFORM_PANDORA)) && defined(DEBUG))
 #define DEBUGF  debugf
 #define LDEBUGF(...) ldebugf(__FILE__, __LINE__, __VA_ARGS__)
 #else
diff --git a/firmware/include/dir_uncached.h b/firmware/include/dir_uncached.h
index c2c7d67..20d4002 100644
--- a/firmware/include/dir_uncached.h
+++ b/firmware/include/dir_uncached.h
@@ -33,7 +33,7 @@ struct dirinfo {
 #include <stdbool.h>
 #include "file.h"

-#if (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO))
+#if (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA))
 #   define dirent_uncached sim_dirent
 #   define DIR_UNCACHED SIM_DIR
 #   define opendir_uncached sim_opendir
diff --git a/firmware/include/file.h b/firmware/include/file.h
index 69ed394..4835450 100644
--- a/firmware/include/file.h
+++ b/firmware/include/file.h
@@ -46,7 +46,7 @@ extern int app_open(const char *name, int o, ...);
 extern int app_creat(const char *name, mode_t mode);
 extern int app_remove(const char* pathname);
 extern int app_rename(const char* path, const char* newname);
-#   if (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO))
+#   if (CONFIG_PLATFORM & (PLATFORM_SDL|PLATFORM_MAEMO|PLATFORM_PANDORA))
 #   define filesize(x) sim_filesize(x)
 #   define fsync(x) sim_fsync(x)
 #   define ftruncate(x,y) sim_ftruncate(x,y)
diff --git a/firmware/target/hosted/sdl/app/button-application.c b/firmware/target/hosted/sdl/app/button-application.c
index 72f4a17..bb43d90 100644
--- a/firmware/target/hosted/sdl/app/button-application.c
+++ b/firmware/target/hosted/sdl/app/button-application.c
@@ -50,7 +50,7 @@ int key_to_button(int keyboard_key)
         case SDLK_LEFT:
             new_btn = BUTTON_MIDLEFT;
             break;
-#if (CONFIG_PLATFORM & PLATFORM_MAEMO)
+#if (CONFIG_PLATFORM & PLATFORM_MAEMO|PLATFORM_PANDORA)
         case SDLK_RETURN:
         case SDLK_KP_ENTER:
 #endif
diff --git a/firmware/target/hosted/sdl/system-sdl.c b/firmware/target/hosted/sdl/system-sdl.c
index 1cc9b2c..4dc5509 100644
--- a/firmware/target/hosted/sdl/system-sdl.c
+++ b/firmware/target/hosted/sdl/system-sdl.c
@@ -133,7 +133,7 @@ static int sdl_event_thread(void * param)
         depth = 16;

     flags = SDL_HWSURFACE|SDL_DOUBLEBUF;
-#if (CONFIG_PLATFORM & PLATFORM_MAEMO)
+#if (CONFIG_PLATFORM & (PLATFORM_MAEMO|PLATFORM_PANDORA))
     /* Fullscreen mode for maemo app */
     flags |= SDL_FULLSCREEN;
 #endif
@@ -142,7 +142,7 @@ static int sdl_event_thread(void * param)
         panicf("%s", SDL_GetError());
     }

-#if (CONFIG_PLATFORM & PLATFORM_MAEMO)
+#if (CONFIG_PLATFORM & PLATFORM_MAEMO|PLATFORM_PANDORA)
     /* Hide mouse cursor on real touchscreen device */
     SDL_ShowCursor(SDL_DISABLE);
 #endif
diff --git a/tools/configure b/tools/configure
index 9594670..eaa391c 100755
--- a/tools/configure
+++ b/tools/configure
@@ -592,6 +592,48 @@ maemocc () {
  fi
 }

+pandoracc () {
+ # Note: The new "Ivanovic" pandora toolchain is not able to compile rockbox.
+ #       You have to use the sebt3 toolchain:
+ #       http://www.gp32x.com/board/index.php?/topic/58490-yactfeau/
+
+ PNDSDK="/usr/local/angstrom/arm"
+ if [ ! -x $PNDSDK/bin/arm-angstrom-linux-gnueabi-gcc ]; then
+     echo "Pandora SDK gcc not found in $PNDSDK/bin/arm-angstrom-linux-gnueabi-gcc"
+     exit
+ fi
+
+ PATH=$PNDSDK/bin:$PATH:$PNDSDK/arm-angstrom-linux-gnueabi/usr/bin
+ PKG_CONFIG_PATH=$PNDSDK/arm-angstrom-linux-gnueabi/usr/lib/pkgconfig
+ LDOPTS="-L$PNDSDK/arm-angstrom-linux-gnueabi/usr/lib -Wl,-rpath,$PNDSDK/arm-angstrom-linux-gnueabi/usr/lib $LDOPTS"
+ PKG_CONFIG="pkg-config"
+
+ GCCOPTS=`echo $CCOPTS | sed -e s/-ffreestanding// -e s/-nostdlib// -e s/-Wundef//`
+ GCCOPTS="$GCCOPTS -fno-builtin -g -I\$(SIMDIR)"
+ GCCOPTIMIZE=''
+ LDOPTS="-lm -ldl $LDOPTS"
+ GLOBAL_LDOPTS="$GLOBAL_LDOPTS -Wl,-z,defs"
+ SHARED_FLAG="-shared"
+ endian="little"
+ thread_support="HAVE_SIGALTSTACK_THREADS"
+
+ # Include path
+ GCCOPTS="-I$PNDSDK/arm-angstrom-linux-gnueabi/usr/include"
+
+ # Set up compiler
+ gccchoice="4.3.3"
+ prefixtools "$PNDSDK/bin/arm-angstrom-linux-gnueabi-"
+
+ # Detect SDL
+ GCCOPTS="$GCCOPTS `$PKG_CONFIG --cflags sdl`"
+ LDOPTS="$LDOPTS `$PKG_CONFIG --libs sdl`"
+
+ # Compiler options
+ GCCOPTS="$GCCOPTS -O2 -fno-strict-aliasing"
+ GCCOPTS="$GCCOPTS -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp"
+ GCCOPTS="$GCCOPTS -ffast-math -fsingle-precision-constant"
+}
+
 androidcc () {
     if [ -z "$ANDROID_SDK_PATH" ]; then
         echo "ERROR: You need the Android SDK installed and have the ANDROID_SDK_PATH"
@@ -1230,6 +1272,7 @@ cat <<EOF
  201) Android             171) HD300
  202) Nokia N8xx
  203) Nokia N900
+ 204) Pandora

 EOF

@@ -3012,6 +3055,33 @@ fi
     t_model="app"
     ;;

+   204|pandora)
+    application="yes"
+    target_id=77
+    modelname="pandora"
+    app_type="sdl-app"
+    target="-DPANDORA"
+    sharedir="rockbox/share"
+    bindir="rockbox/bin"
+    libdir="rockbox/lib"
+    memory=8
+    uname=`uname`
+    pandoracc
+    tool="cp "
+    boottool="cp "
+    bmp2rb_mono="$rootdir/tools/bmp2rb -f 0"
+    bmp2rb_native="$rootdir/tools/bmp2rb -f 4"
+    output="rockbox"
+    bootoutput="rockbox"
+    appextra="recorder:gui:radio"
+    plugins="yes"
+    swcodec="yes"
+    # architecture, manufacturer and model for the target-tree build
+    t_cpu="hosted"
+    t_manufacturer="pandora"
+    t_model="app"
+    ;;
+
    *)
     echo "Please select a supported target platform!"
     exit 7
@@ -3469,10 +3539,15 @@ if test -n "$t_cpu"; then
     # Maemo needs the SDL port, too
     TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl/app"
     TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl"
+  elif [ "$t_cpu" = "hosted" ] && [ "$t_manufacturer" = "pandora" ]; then
+    # Pandora needs the SDL port, too
+    TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl/app"
+    TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl"
   elif [ "$simulator" = "yes" ]; then # a few more includes for the sim target tree
     TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted/sdl"
     TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/hosted"
   fi
+
   TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/$t_cpu/$t_manufacturer"
   TARGET_INC="$TARGET_INC -I\$(FIRMDIR)/target/$t_cpu"
   GCCOPTS="$GCCOPTS"