Enable a lot more features for simulators and add stubs where necessary, simulators should now work with identical lng and voice files as the respective target

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14299 a1c6a512-1295-4272-9138-f99709370657
diff --git a/apps/features.txt b/apps/features.txt
index a80408d..f5ebe98 100644
--- a/apps/features.txt
+++ b/apps/features.txt
@@ -146,9 +146,9 @@
 tc_ramcache
 #endif
 
-#if CONFIG_CHARGING || defined(SIMULATOR)
+#if CONFIG_CHARGING
 charging
-#if defined(HAVE_USB_POWER) || defined(SIMULATOR)
+#if defined(HAVE_USB_POWER)
 usb_charging
 #endif
 #endif
diff --git a/apps/menus/settings_menu.c b/apps/menus/settings_menu.c
index b1ba668..283acc4 100644
--- a/apps/menus/settings_menu.c
+++ b/apps/menus/settings_menu.c
@@ -122,7 +122,6 @@
 /*    SYSTEM MENU                  */
 
 /* Battery */
-#ifndef SIMULATOR
 #if BATTERY_CAPACITY_INC > 0
 MENUITEM_SETTING(battery_capacity, &global_settings.battery_capacity, NULL);
 #endif
@@ -158,7 +157,6 @@
 #endif
 #endif
          );
-#endif /* SIMULATOR */
 /* Disk */
 #ifndef HAVE_FLASH_STORAGE
 MENUITEM_SETTING(disk_spindown, &global_settings.disk_spindown, NULL);
@@ -340,7 +338,7 @@
 MAKE_MENU(system_menu, ID2P(LANG_SYSTEM), 
           0, Icon_System_menu,
             &start_screen,
-#ifndef SIMULATOR
+#if (BATTERY_CAPACITY_INC > 0) || (BATTERY_TYPES_COUNT > 1)
             &battery_menu,
 #endif
 #if defined(HAVE_DIRCACHE) || !defined(HAVE_FLASH_STORAGE)
diff --git a/apps/screens.c b/apps/screens.c
index 5dbca7a..700164f 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -779,7 +779,7 @@
 #endif /* BUTTON_F3 */
 #endif /* CONFIG_KEYPAD in (RECORDER_PAD |IRIVER_H100_PAD | IRIVER_H300_PAD) */
 
-#if CONFIG_CHARGING || defined(SIMULATOR)
+#if CONFIG_CHARGING
 void charging_splash(void)
 {
     gui_syncsplash(2*HZ, (unsigned char *)str(LANG_BATTERY_CHARGE));
diff --git a/apps/settings_list.c b/apps/settings_list.c
index 70d521b..1b8b333 100644
--- a/apps/settings_list.c
+++ b/apps/settings_list.c
@@ -499,14 +499,12 @@
         200,
 #endif
             "max files in dir", UNIT_INT,50,10000,50,NULL,NULL,NULL),
-#ifndef SIMULATOR
 #if BATTERY_CAPACITY_INC > 0
     INT_SETTING(0, battery_capacity, LANG_BATTERY_CAPACITY, BATTERY_CAPACITY_DEFAULT, 
                 "battery capacity", UNIT_MAH,
                 BATTERY_CAPACITY_MIN, BATTERY_CAPACITY_MAX, BATTERY_CAPACITY_INC,
                 NULL, NULL, NULL),
 #endif
-#endif
 #if CONFIG_CHARGING
     OFFON_SETTING(NVRAM(1), car_adapter_mode,
         LANG_CAR_ADAPTER_MODE, false, "car adapter mode", NULL),
diff --git a/firmware/SOURCES b/firmware/SOURCES
index ccd6f11..bbbe150 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -95,11 +95,11 @@
 
 /* Misc. */
 drivers/led.c
+drivers/button.c
 #ifndef TARGET_TREE
 drivers/power.c
 #endif /* TARGET_TREE */
 #ifndef SIMULATOR
-drivers/button.c
 drivers/dac.c
 drivers/serial.c
 #endif /* SIMULATOR */
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index 715d4d3..7b5fd26 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -37,6 +37,7 @@
 #include "lcd-remote.h"
 #endif
 
+#ifndef SIMULATOR
 #if 0
 /* Older than MAX_EVENT_AGE button events are going to be ignored.
  * Used to prevent for example volume going up uncontrollable when events
@@ -482,6 +483,8 @@
     queue_clear(&button_queue);
 }
 
+#endif /* SIMULATOR */
+
 #ifdef HAVE_SCROLLWHEEL
 /**
  * data:
diff --git a/firmware/drivers/power.c b/firmware/drivers/power.c
index 50117dd..593fe29 100644
--- a/firmware/drivers/power.c
+++ b/firmware/drivers/power.c
@@ -219,11 +219,6 @@
 
 #else
 
-bool charger_inserted(void)
-{
-    return false;
-}
-
 void charger_enable(bool on)
 {
     (void)on;
diff --git a/firmware/export/config-e200.h b/firmware/export/config-e200.h
index b59974a..17f06b5 100644
--- a/firmware/export/config-e200.h
+++ b/firmware/export/config-e200.h
@@ -44,6 +44,19 @@
 #define LCD_DEPTH  16   /* 65536 colours */
 #define LCD_PIXELFORMAT RGB565 /* rgb565 */
 
+/* define this if you have LCD enable function */
+#define HAVE_LCD_ENABLE
+
+/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
+   should be defined as well. */
+#define HAVE_LCD_SLEEP
+
+/* define this if you can flip your LCD */
+#define HAVE_LCD_FLIP
+
+/* define this if you can invert the colours on your LCD */
+#define HAVE_LCD_INVERT
+
 /* #define IRAM_LCDFRAMEBUFFER IDATA_ATTR *//* put the lcd frame buffer in IRAM */
 
 #define CONFIG_KEYPAD SANSA_E200_PAD
@@ -82,11 +95,32 @@
 #define HAVE_BACKLIGHT
 #define HAVE_BACKLIGHT_BRIGHTNESS
 
-#define BATTERY_CAPACITY_DEFAULT 750    /* default battery capacity */
+/* define this if the unit uses a scrollwheel for navigation */
+#define HAVE_SCROLLWHEEL
+/* define wheel acceleration scaling factor */
+/* Range for this target: 0xffffff*(0.0-16.000000894069724921567733381255) */
+#define WHEEL_ACCELERATION_FACTOR   (0xffffff*7)
 
 /* define this if you have a flash memory storage */
 #define HAVE_FLASH_STORAGE
 
+#define HAVE_MULTIVOLUME
+
+/* Type of mobile power */
+#define CONFIG_BATTERY BATT_LIION750
+#define BATTERY_CAPACITY_DEFAULT 750    /* default battery capacity */
+#define BATTERY_CAPACITY_MIN 750        /* min. capacity selectable */
+#define BATTERY_CAPACITY_MAX 750        /* max. capacity selectable */
+#define BATTERY_CAPACITY_INC 0          /* capacity increment */
+#define BATTERY_TYPES_COUNT  1          /* only one type */
+#define BATTERY_SCALE_FACTOR 5005       /* ADC should read 0x3ff=5.12V */
+
+/* Hardware controlled charging? FIXME */
+#define CONFIG_CHARGING CHARGING_SIMPLE
+
+/* define this if the unit can be powered or charged via USB */
+#define HAVE_USB_POWER
+
 /** Non-simulator section **/
 #ifndef SIMULATOR
 
@@ -96,17 +130,6 @@
 /* Define this if you want to use the PP5024 i2c interface */
 #define CONFIG_I2C I2C_PP5024
 
-/* Type of mobile power */
-#define CONFIG_BATTERY BATT_LIION750
-#define BATTERY_CAPACITY_MIN 750        /* min. capacity selectable */
-#define BATTERY_CAPACITY_MAX 750        /* max. capacity selectable */
-#define BATTERY_CAPACITY_INC 0          /* capacity increment */
-#define BATTERY_TYPES_COUNT  1          /* only one type */
-#define BATTERY_SCALE_FACTOR 5005       /* ADC should read 0x3ff=5.12V */
-
-/* Hardware controlled charging? FIXME */
-#define CONFIG_CHARGING CHARGING_SIMPLE
-
 /* define this if the hardware can be powered off while charging */
 /* Sansa can't be powered off while charging */
 /* #define HAVE_POWEROFF_WHILE_CHARGING */
@@ -121,20 +144,6 @@
 #define CONFIG_LCD LCD_X5
 
 #define HAVE_HOTSWAP
-#define HAVE_MULTIVOLUME
-
-/* define this if you have LCD enable function */
-#define HAVE_LCD_ENABLE
-
-/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
-   should be defined as well. */
-#define HAVE_LCD_SLEEP
-
-/* define this if you can invert the colours on your LCD */
-#define HAVE_LCD_INVERT
-
-/* define this if you can flip your LCD */
-#define HAVE_LCD_FLIP
 
 /* Offset ( in the firmware file's header ) to the file CRC and data. These are
    only used when loading the old format rockbox.e200 file */
@@ -146,9 +155,6 @@
 /* USB On-the-go */
 #define CONFIG_USBOTG USBOTG_ARC
 
-/* define this if the unit can be powered or charged via USB */
-#define HAVE_USB_POWER
-
 /* Virtual LED (icon) */
 #define CONFIG_LED LED_VIRTUAL
 
@@ -163,12 +169,6 @@
 
 #define ICODE_ATTR_TREMOR_NOT_MDCT
 
-/* define this if the unit uses a scrollwheel for navigation */
-#define HAVE_SCROLLWHEEL
-/* define wheel acceleration scaling factor */
-/* Range for this target: 0xffffff*(0.0-16.000000894069724921567733381255) */
-#define WHEEL_ACCELERATION_FACTOR   (0xffffff*7)
-
 #define INCLUDE_TIMEOUT_API
 
 #endif /* SIMULATOR */
diff --git a/firmware/export/config-fmrecorder.h b/firmware/export/config-fmrecorder.h
index 479815e..2f5254f 100644
--- a/firmware/export/config-fmrecorder.h
+++ b/firmware/export/config-fmrecorder.h
@@ -35,6 +35,9 @@
 /* define this if you have a real-time clock */
 #define CONFIG_RTC RTC_M41ST84W
 
+/* FM recorders can wake up from RTC alarm */
+#define HAVE_RTC_ALARM
+
 /* define this if you have RTC RAM available for settings */
 #define HAVE_RTC_RAM
 
@@ -57,7 +60,21 @@
 
 #define CONFIG_I2C I2C_PLAYREC
 
+/* Type of mobile power */
+#define CONFIG_BATTERY BATT_LIION2200
 #define BATTERY_CAPACITY_DEFAULT 2200 /* default battery capacity */
+#define BATTERY_CAPACITY_MIN 2200 /* min. capacity selectable */
+#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable */
+#define BATTERY_CAPACITY_INC 50   /* capacity increment */
+#define BATTERY_TYPES_COUNT  1    /* only one type */
+/* Battery scale factor (guessed, seems to be 1,25 * value from recorder) */
+#define BATTERY_SCALE_FACTOR 8081
+
+/* Hardware controlled charging with monitoring */
+#define CONFIG_CHARGING CHARGING_MONITOR
+
+/* define this if the unit can be powered or charged via USB */
+#define HAVE_USB_POWER
 
 #ifndef SIMULATOR
 
@@ -76,15 +93,6 @@
 /* Define this to the CPU frequency */
 #define CPU_FREQ      11059200
 
-/* Type of mobile power */
-#define CONFIG_BATTERY BATT_LIION2200
-#define BATTERY_CAPACITY_MIN 2200 /* min. capacity selectable */
-#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable */
-#define BATTERY_CAPACITY_INC 50   /* capacity increment */
-#define BATTERY_TYPES_COUNT  1    /* only one type */
-/* Battery scale factor (guessed, seems to be 1,25 * value from recorder) */
-#define BATTERY_SCALE_FACTOR 8081
-
 /* Define this if you control power on PB5 (instead of the OFF button) */
 #define HAVE_POWEROFF_ON_PB5
 
@@ -97,12 +105,6 @@
 /* Offset ( in the firmware file's header ) to the real data */
 #define FIRMWARE_OFFSET_FILE_DATA 24
 
-/* FM recorders can wake up from RTC alarm */
-#define HAVE_RTC_ALARM
-
-/* Hardware controlled charging with monitoring */
-#define CONFIG_CHARGING CHARGING_MONITOR
-
 /* The start address index for ROM builds */
 /* #define ROM_START 0x14010 for behind original Archos */
 #define ROM_START 0x7010 /* for behind BootBox */
@@ -110,9 +112,6 @@
 /* Software controlled LED */
 #define CONFIG_LED LED_REAL
 
-/* define this if the unit can be powered or charged via USB */
-#define HAVE_USB_POWER
-
 #define CONFIG_LCD LCD_SSD1815
 
 #define BOOTFILE_EXT "ajz"
diff --git a/firmware/export/config-gigabeat.h b/firmware/export/config-gigabeat.h
index 38be0d0..319ad4e 100644
--- a/firmware/export/config-gigabeat.h
+++ b/firmware/export/config-gigabeat.h
@@ -32,6 +32,9 @@
 #define LCD_DEPTH  16   /* 65k colours */
 #define LCD_PIXELFORMAT RGB565 /* rgb565 */
 
+/* Define this if your LCD can be enabled/disabled */
+#define HAVE_LCD_ENABLE
+
 #define CONFIG_KEYPAD GIGABEAT_PAD
 
 /* Define this if you do software codec */
@@ -71,15 +74,28 @@
 /* Define this if you want to use the adaptive bass capibility of the 8751 */
 /* #define USE_ADAPTIVE_BASS */
 
-#define BATTERY_CAPACITY_DEFAULT 2000 /* default battery capacity */
-
 #define HW_SAMPR_CAPS (SAMPR_CAP_88 | SAMPR_CAP_44 | SAMPR_CAP_22 | \
                        SAMPR_CAP_11)
 
-#ifndef SIMULATOR
+#define HAVE_HEADPHONE_DETECTION
 
-/* Define this if your LCD can be enabled/disabled */
-#define HAVE_LCD_ENABLE
+/* Type of mobile power - check this out */
+#define CONFIG_BATTERY BATT_LIION830    /* could change this later */
+#define BATTERY_CAPACITY_DEFAULT 2000 /* default battery capacity */
+#define BATTERY_CAPACITY_MIN 1500        /* min. capacity selectable */
+#define BATTERY_CAPACITY_MAX 2500        /* max. capacity selectable */
+#define BATTERY_CAPACITY_INC 25         /* capacity increment */
+#define BATTERY_TYPES_COUNT  1          /* only one type */
+/* ADC[0] is (530) at discharge and 625 at full charge */
+#define BATTERY_SCALE_FACTOR 6450
+
+/* Hardware controlled charging with monitoring */
+#define CONFIG_CHARGING CHARGING_MONITOR
+
+/* define this if the unit can be powered or charged via USB */
+#define HAVE_USB_POWER
+
+#ifndef SIMULATOR
 
 /* The LCD on a Gigabeat is 240x320 - it is portrait */
 #define HAVE_PORTRAIT_LCD
@@ -90,19 +106,6 @@
 /* Define this if you want to use coldfire's i2c interface */
 #define CONFIG_I2C I2C_S3C2440
 
-/* Type of mobile power - check this out */
-#define CONFIG_BATTERY BATT_LIION830    /* could change this later */
-#define BATTERY_CAPACITY_MIN 1500        /* min. capacity selectable */
-#define BATTERY_CAPACITY_MAX 2500        /* max. capacity selectable */
-#define BATTERY_CAPACITY_INC 25         /* capacity increment */
-#define BATTERY_TYPES_COUNT  1          /* only one type */
-
-/* ADC[0] is (530) at discharge and 625 at full charge */
-#define BATTERY_SCALE_FACTOR 6450
-
-/* Hardware controlled charging with monitoring */
-#define CONFIG_CHARGING CHARGING_MONITOR
-
 /* define this if the hardware can be powered off while charging */
 #define HAVE_POWEROFF_WHILE_CHARGING
 
@@ -112,9 +115,6 @@
 /* Define this to the CPU frequency */
 #define CPU_FREQ 16934400
 
-/* define this if the unit can be powered or charged via USB */
-#define HAVE_USB_POWER
-
 /* Define this if you have ATA power-off control */
 #define HAVE_ATA_POWER_OFF
 
@@ -133,8 +133,6 @@
 /* Offset ( in the firmware file's header ) to the real data */
 #define FIRMWARE_OFFSET_FILE_DATA 8
 
-#define HAVE_HEADPHONE_DETECTION
-
 /* Define this if you have adjustable CPU frequency */
 /* #define HAVE_ADJUSTABLE_CPU_FREQ */
 
diff --git a/firmware/export/config-h10.h b/firmware/export/config-h10.h
index 7a97f4c..502b5b1 100644
--- a/firmware/export/config-h10.h
+++ b/firmware/export/config-h10.h
@@ -41,6 +41,14 @@
 #define LCD_DEPTH  16   /* 65536 colours */
 #define LCD_PIXELFORMAT RGB565 /* rgb565 */
 
+/* Define this if your LCD can be enabled/disabled */
+#define HAVE_LCD_ENABLE
+
+/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
+ * should be defined as well.
+ * We can currently put the lcd to sleep but it won't wake up properly */
+#define HAVE_LCD_SLEEP
+
 /* define this if you can flip your LCD */
 #define HAVE_LCD_FLIP
 
@@ -83,20 +91,11 @@
 /* Define this for LCD backlight available */
 #define HAVE_BACKLIGHT
 
-#define BATTERY_CAPACITY_DEFAULT 1550 /* default battery capacity */
-
 #define AB_REPEAT_ENABLE 1
 
-#ifndef SIMULATOR
-
-/* Define this if you have a PortalPlayer PP5020 */
-#define CONFIG_CPU PP5020
-
-/* Define this if you want to use the PP5020 i2c interface */
-#define CONFIG_I2C I2C_PP5020
-
 /* Type of mobile power */
 #define CONFIG_BATTERY BATT_LPCS355385
+#define BATTERY_CAPACITY_DEFAULT 1550 /* default battery capacity */
 #define BATTERY_CAPACITY_MIN 1500  /* min. capacity selectable */
 #define BATTERY_CAPACITY_MAX 1600 /* max. capacity selectable */
 #define BATTERY_CAPACITY_INC 10   /* capacity increment */
@@ -106,6 +105,17 @@
 /* Hardware controlled charging */
 #define CONFIG_CHARGING CHARGING_SIMPLE
 
+/* define this if the unit can be powered or charged via USB */
+#define HAVE_USB_POWER
+
+#ifndef SIMULATOR
+
+/* Define this if you have a PortalPlayer PP5020 */
+#define CONFIG_CPU PP5020
+
+/* Define this if you want to use the PP5020 i2c interface */
+#define CONFIG_I2C I2C_PP5020
+
 /* define this if the hardware can be powered off while charging */
 #define HAVE_POWEROFF_WHILE_CHARGING
 
@@ -128,14 +138,6 @@
 #define MAX_CONTRAST_SETTING        30
 #define DEFAULT_CONTRAST_SETTING    14 /* Match boot contrast */
 
-/* Define this if your LCD can be enabled/disabled */
-#define HAVE_LCD_ENABLE
-
-/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
- * should be defined as well.
- * We can currently put the lcd to sleep but it won't wake up properly */
-#define HAVE_LCD_SLEEP
-
 /* We're able to shut off power to the HDD */
 #define HAVE_ATA_POWER_OFF
 
@@ -149,9 +151,6 @@
 /* USB On-the-go */
 #define CONFIG_USBOTG USBOTG_ARC
 
-/* define this if the unit can be powered or charged via USB */
-#define HAVE_USB_POWER
-
 /* Virtual LED (icon) */
 #define CONFIG_LED LED_VIRTUAL
 
diff --git a/firmware/export/config-h100.h b/firmware/export/config-h100.h
index af51e81..3d6f217 100644
--- a/firmware/export/config-h100.h
+++ b/firmware/export/config-h100.h
@@ -53,6 +53,9 @@
 /* Define this if you have an remote lcd */
 #define HAVE_REMOTE_LCD
 
+/* Define if we have a hardware defect that causes ticking on the audio line */
+#define HAVE_REMOTE_LCD_TICKING
+
 #define CONFIG_LCD LCD_S1D15E06
 
 /* Define this for LCD backlight available */
@@ -70,8 +73,6 @@
 /* The number of bytes reserved for loadable plugins */
 #define PLUGIN_BUFFER_SIZE 0x80000
 
-#define BATTERY_CAPACITY_DEFAULT 1300 /* default battery capacity */
-
 #define AB_REPEAT_ENABLE 1
 
 #define CONFIG_TUNER TEA5767
@@ -90,6 +91,19 @@
 
 #define HAVE_AGC
 
+/* Type of mobile power */
+#define CONFIG_BATTERY BATT_LIPOL1300
+#define BATTERY_CAPACITY_DEFAULT 1300 /* default battery capacity */
+#define BATTERY_CAPACITY_MIN 1300 /* min. capacity selectable */
+#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable */
+#define BATTERY_CAPACITY_INC 50   /* capacity increment */
+#define BATTERY_TYPES_COUNT  1    /* only one type */
+#define BATTERY_SCALE_FACTOR 16665 /* FIX: this value is picked at random */
+
+/* Hardware controlled charging */
+//#define CONFIG_CHARGING CHARGING_SIMPLE
+#define CONFIG_CHARGING CHARGING_MONITOR /* FIXME: remove that once monitoring is fixed properly */
+
 #ifndef SIMULATOR
 
 /* Define this if you have a Motorola SCF5249 */
@@ -102,21 +116,6 @@
 /* In theory we can, but somebody needs to verify there are no issues. */
 // #define HAVE_FLASHED_ROCKBOX
 
-/* Define if we have a hardware defect that causes ticking on the audio line */
-#define HAVE_REMOTE_LCD_TICKING
-
-/* Type of mobile power */
-#define CONFIG_BATTERY BATT_LIPOL1300
-#define BATTERY_CAPACITY_MIN 1300 /* min. capacity selectable */
-#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable */
-#define BATTERY_CAPACITY_INC 50   /* capacity increment */
-#define BATTERY_TYPES_COUNT  1    /* only one type */
-#define BATTERY_SCALE_FACTOR 16665 /* FIX: this value is picked at random */
-
-/* Hardware controlled charging */
-//#define CONFIG_CHARGING CHARGING_SIMPLE
-#define CONFIG_CHARGING CHARGING_MONITOR /* FIXME: remove that once monitoring is fixed properly */
-
 /* define this if the hardware can be powered off while charging */
 #define HAVE_POWEROFF_WHILE_CHARGING
 
diff --git a/firmware/export/config-h10_5gb.h b/firmware/export/config-h10_5gb.h
index add682c..254f59f 100644
--- a/firmware/export/config-h10_5gb.h
+++ b/firmware/export/config-h10_5gb.h
@@ -77,20 +77,11 @@
 /* Define this for LCD backlight available */
 #define HAVE_BACKLIGHT
 
-#define BATTERY_CAPACITY_DEFAULT 820 /* default battery capacity */
-
 #define AB_REPEAT_ENABLE 1
 
-#ifndef SIMULATOR
-
-/* Define this if you have a PortalPlayer PP5020 */
-#define CONFIG_CPU PP5020
-
-/* Define this if you want to use the PP5020 i2c interface */
-#define CONFIG_I2C I2C_PP5020
-
 /* Type of mobile power */
 #define CONFIG_BATTERY BATT_BP009
+#define BATTERY_CAPACITY_DEFAULT 820 /* default battery capacity */
 #define BATTERY_CAPACITY_MIN 700  /* min. capacity selectable */
 #define BATTERY_CAPACITY_MAX 900 /* max. capacity selectable */
 #define BATTERY_CAPACITY_INC 10   /* capacity increment */
@@ -100,6 +91,17 @@
 /* Hardware controlled charging */
 #define CONFIG_CHARGING CHARGING_SIMPLE
 
+/* define this if the unit can be powered or charged via USB */
+#define HAVE_USB_POWER
+
+#ifndef SIMULATOR
+
+/* Define this if you have a PortalPlayer PP5020 */
+#define CONFIG_CPU PP5020
+
+/* Define this if you want to use the PP5020 i2c interface */
+#define CONFIG_I2C I2C_PP5020
+
 /* define this if the hardware can be powered off while charging */
 #define HAVE_POWEROFF_WHILE_CHARGING
 
@@ -132,9 +134,6 @@
 /* USB On-the-go */
 #define CONFIG_USBOTG USBOTG_ARC
 
-/* define this if the unit can be powered or charged via USB */
-#define HAVE_USB_POWER
-
 /* Virtual LED (icon) */
 #define CONFIG_LED LED_VIRTUAL
 
diff --git a/firmware/export/config-h120.h b/firmware/export/config-h120.h
index 7e5a66a..bf13f3e 100644
--- a/firmware/export/config-h120.h
+++ b/firmware/export/config-h120.h
@@ -48,6 +48,9 @@
 /* Define this if you have an remote lcd */
 #define HAVE_REMOTE_LCD
 
+/* Define if we have a hardware defect that causes ticking on the audio line */
+#define HAVE_REMOTE_LCD_TICKING
+
 #define CONFIG_LCD LCD_S1D15E06
 
 /* Define this for LCD backlight available */
@@ -88,7 +91,17 @@
 
 #define HAVE_AGC
 
+#define CONFIG_BATTERY BATT_LIPOL1300
 #define BATTERY_CAPACITY_DEFAULT 1300 /* default battery capacity */
+#define BATTERY_CAPACITY_MIN 1300 /* min. capacity selectable */
+#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable */
+#define BATTERY_CAPACITY_INC 50   /* capacity increment */
+#define BATTERY_TYPES_COUNT  1    /* only one type */
+#define BATTERY_SCALE_FACTOR 16665 /* FIX: this value is picked at random */
+
+/* Hardware controlled charging */
+//#define CONFIG_CHARGING CHARGING_SIMPLE
+#define CONFIG_CHARGING CHARGING_MONITOR /* FIXME: remove that once monitoring is fixed properly */
 
 #ifndef SIMULATOR
 
@@ -98,23 +111,9 @@
 /* Define this if you want to use coldfire's i2c interface */
 #define CONFIG_I2C I2C_COLDFIRE
 
-#define CONFIG_BATTERY BATT_LIPOL1300
-#define BATTERY_CAPACITY_MIN 1300 /* min. capacity selectable */
-#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable */
-#define BATTERY_CAPACITY_INC 50   /* capacity increment */
-#define BATTERY_TYPES_COUNT  1    /* only one type */
-#define BATTERY_SCALE_FACTOR 16665 /* FIX: this value is picked at random */
-
 /* Define this if you can run rockbox from flash memory */
 #define HAVE_FLASHED_ROCKBOX
 
-/* Define if we have a hardware defect that causes ticking on the audio line */
-#define HAVE_REMOTE_LCD_TICKING
-
-/* Hardware controlled charging */
-//#define CONFIG_CHARGING CHARGING_SIMPLE
-#define CONFIG_CHARGING CHARGING_MONITOR /* FIXME: remove that once monitoring is fixed properly */
-
 /* define this if the hardware can be powered off while charging */
 #define HAVE_POWEROFF_WHILE_CHARGING
 
diff --git a/firmware/export/config-h300.h b/firmware/export/config-h300.h
index 43239e4..91c175f 100644
--- a/firmware/export/config-h300.h
+++ b/firmware/export/config-h300.h
@@ -50,8 +50,12 @@
 /* Define this if you have an remote lcd */
 #define HAVE_REMOTE_LCD
 
+/* Define if we have a hardware defect that causes ticking on the audio line */
+#define HAVE_REMOTE_LCD_TICKING
+
 /* Define this for LCD backlight available */
 #define HAVE_BACKLIGHT
+#define HAVE_BACKLIGHT_BRIGHTNESS
 
 /* Define this if you have a software controlled poweroff */
 #define HAVE_SW_POWEROFF
@@ -84,7 +88,20 @@
 
 #define HAVE_AGC
 
+/* Type of mobile power */
+#define CONFIG_BATTERY BATT_LIPOL1300
 #define BATTERY_CAPACITY_DEFAULT 1300 /* default battery capacity */
+#define BATTERY_CAPACITY_MIN 1300 /* min. capacity selectable */
+#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable */
+#define BATTERY_CAPACITY_INC 50   /* capacity increment */
+#define BATTERY_TYPES_COUNT  1    /* only one type */
+#define BATTERY_SCALE_FACTOR 23437 /* FIX: this value is picked at random */
+
+/* Hardware controlled charging with monitoring */
+#define CONFIG_CHARGING CHARGING_MONITOR
+
+/* define this if the unit can be powered or charged via USB */
+#define HAVE_USB_POWER
 
 #ifndef SIMULATOR
 
@@ -97,20 +114,6 @@
 /* Define this if you want to use coldfire's i2c interface */
 #define CONFIG_I2C I2C_COLDFIRE
 
-/* Type of mobile power */
-#define CONFIG_BATTERY BATT_LIPOL1300
-#define BATTERY_CAPACITY_MIN 1300 /* min. capacity selectable */
-#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable */
-#define BATTERY_CAPACITY_INC 50   /* capacity increment */
-#define BATTERY_TYPES_COUNT  1    /* only one type */
-#define BATTERY_SCALE_FACTOR 23437 /* FIX: this value is picked at random */
-
-/* Define if we have a hardware defect that causes ticking on the audio line */
-#define HAVE_REMOTE_LCD_TICKING
-
-/* Hardware controlled charging with monitoring */
-#define CONFIG_CHARGING CHARGING_MONITOR
-
 /* The size of the flash ROM */
 #define FLASH_SIZE 0x400000
 
@@ -145,11 +148,6 @@
 #define FLASH_ENTRYPOINT       0x00001000
 #define FLASH_MAGIC            0xfbfbfbf1
 
-#define HAVE_BACKLIGHT_BRIGHTNESS
-
-/* define this if the unit can be powered or charged via USB */
-#define HAVE_USB_POWER
-
 /* Define this if there is an EEPROM chip */
 #define HAVE_EEPROM
 
diff --git a/firmware/export/config-iaudiom5.h b/firmware/export/config-iaudiom5.h
index d4e09dd..4ab8e2c 100644
--- a/firmware/export/config-iaudiom5.h
+++ b/firmware/export/config-iaudiom5.h
@@ -79,13 +79,24 @@
 /* The number of bytes reserved for loadable plugins */
 #define PLUGIN_BUFFER_SIZE 0x80000
 
-#define BATTERY_CAPACITY_DEFAULT 950 /* default battery capacity */
-
 #define HAVE_TLV320
 
 /* TLV320 has no tone controls, so we use the software ones */
 #define HAVE_SW_TONE_CONTROLS
 
+/* Type of mobile power */
+#define X5_BATT_CONFIG          2
+#define CONFIG_BATTERY          BATT_IAUDIO_X5M5
+#define BATTERY_CAPACITY_DEFAULT 950 /* default battery capacity */
+#define BATTERY_CAPACITY_MIN    950   /* min. capacity selectable */
+#define BATTERY_CAPACITY_MAX    2250  /* max. capacity selectable */
+#define BATTERY_CAPACITY_INC    50    /* capacity increment */
+#define BATTERY_TYPES_COUNT     1     /* only one type */
+#define BATTERY_SCALE_FACTOR    5859  /* (420703125 + 35900) / 71800 */
+
+/* Hardware controlled charging? FIXME */
+#define CONFIG_CHARGING CHARGING_SIMPLE
+
 #ifndef SIMULATOR
 
 /* Define this if your LCD can set contrast */
@@ -97,9 +108,6 @@
 /* Define this if you want to use coldfire's i2c interface */
 #define CONFIG_I2C I2C_COLDFIRE
 
-/* Hardware controlled charging? FIXME */
-#define CONFIG_CHARGING CHARGING_SIMPLE
-
 /* define this if the hardware can be powered off while charging */
 #define HAVE_POWEROFF_WHILE_CHARGING
 
@@ -109,15 +117,6 @@
 /* Define this to the CPU frequency */
 #define CPU_FREQ      11289600
 
-/* Type of mobile power */
-#define X5_BATT_CONFIG          2
-#define CONFIG_BATTERY          BATT_IAUDIO_X5M5
-#define BATTERY_CAPACITY_MIN    950   /* min. capacity selectable */
-#define BATTERY_CAPACITY_MAX    2250  /* max. capacity selectable */
-#define BATTERY_CAPACITY_INC    50    /* capacity increment */
-#define BATTERY_TYPES_COUNT     1     /* only one type */
-#define BATTERY_SCALE_FACTOR    5859  /* (420703125 + 35900) / 71800 */
-
 /* Define this if you have ATA power-off control */
 #define HAVE_ATA_POWER_OFF
 
diff --git a/firmware/export/config-iaudiox5.h b/firmware/export/config-iaudiox5.h
index fbcb69a..c02b2a7 100644
--- a/firmware/export/config-iaudiox5.h
+++ b/firmware/export/config-iaudiox5.h
@@ -53,6 +53,13 @@
 
 #define LCD_REMOTE_PIXELFORMAT VERTICAL_INTERLEAVED
 
+/* Define this if your LCD can be enabled/disabled */
+#define HAVE_LCD_ENABLE
+
+/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
+   should be defined as well. */
+#define HAVE_LCD_SLEEP
+
 #define CONFIG_KEYPAD IAUDIO_X5M5_PAD
 
 #define AB_REPEAT_ENABLE 1
@@ -86,35 +93,35 @@
 #define CONFIG_TUNER       TEA5767
 #define CONFIG_TUNER_XTAL  32768
 
-
-#define BATTERY_CAPACITY_DEFAULT 950 /* default battery capacity */
-
 #define HAVE_TLV320
 
 /* TLV320 has no tone controls, so we use the software ones */
 #define HAVE_SW_TONE_CONTROLS
 
+/* Type of mobile power */
+#define X5_BATT_CONFIG          2
+#define CONFIG_BATTERY          BATT_IAUDIO_X5M5
+#define BATTERY_CAPACITY_DEFAULT 950 /* default battery capacity */
+#define BATTERY_CAPACITY_MIN    950   /* min. capacity selectable */
+#define BATTERY_CAPACITY_MAX    2250  /* max. capacity selectable */
+#define BATTERY_CAPACITY_INC    50    /* capacity increment */
+#define BATTERY_TYPES_COUNT     1     /* only one type */
+#define BATTERY_SCALE_FACTOR    5859  /* (420703125 + 35900) / 71800 */
+
+/* Hardware controlled charging? FIXME */
+#define CONFIG_CHARGING CHARGING_SIMPLE
+
 #ifndef SIMULATOR
 
 /* Define this if your LCD can set contrast */
 #define HAVE_LCD_CONTRAST
 
-/* Define this if your LCD can be enabled/disabled */
-#define HAVE_LCD_ENABLE
-
-/* Define this if your LCD can be put to sleep. HAVE_LCD_ENABLE
-   should be defined as well. */
-#define HAVE_LCD_SLEEP
-
 /* Define this if you have a Motorola SCF5250 */
 #define CONFIG_CPU MCF5250
 
 /* Define this if you want to use coldfire's i2c interface */
 #define CONFIG_I2C I2C_COLDFIRE
 
-/* Hardware controlled charging? FIXME */
-#define CONFIG_CHARGING CHARGING_SIMPLE
-
 /* define this if the hardware can be powered off while charging */
 #define HAVE_POWEROFF_WHILE_CHARGING
 
@@ -124,15 +131,6 @@
 /* Define this to the CPU frequency */
 #define CPU_FREQ      11289600
 
-/* Type of mobile power */
-#define X5_BATT_CONFIG          2
-#define CONFIG_BATTERY          BATT_IAUDIO_X5M5
-#define BATTERY_CAPACITY_MIN    950   /* min. capacity selectable */
-#define BATTERY_CAPACITY_MAX    2250  /* max. capacity selectable */
-#define BATTERY_CAPACITY_INC    50    /* capacity increment */
-#define BATTERY_TYPES_COUNT     1     /* only one type */
-#define BATTERY_SCALE_FACTOR    5859  /* (420703125 + 35900) / 71800 */
-
 /* Define this if you have ATA power-off control */
 #define HAVE_ATA_POWER_OFF
 
diff --git a/firmware/export/config-ifp7xx.h b/firmware/export/config-ifp7xx.h
index 64e8b13..65915df 100644
--- a/firmware/export/config-ifp7xx.h
+++ b/firmware/export/config-ifp7xx.h
@@ -50,8 +50,6 @@
 
 #define HAVE_FLASH_DISK
 
-#define BATTERY_CAPACITY_DEFAULT 1000 /* default battery capacity */
-
 /* Virtual LED (icon) */
 #define CONFIG_LED LED_VIRTUAL
 
@@ -62,6 +60,15 @@
 /* define this if you have a flash memory storage */
 #define HAVE_FLASH_STORAGE
 
+/* Type of mobile power */
+#define CONFIG_BATTERY BATT_1AA
+#define BATTERY_CAPACITY_DEFAULT 1000 /* default battery capacity */
+#define BATTERY_CAPACITY_MIN 500  /* min. capacity selectable */
+#define BATTERY_CAPACITY_MAX 2800 /* max. capacity selectable */
+#define BATTERY_CAPACITY_INC 50   /* capacity increment */
+#define BATTERY_TYPES_COUNT  2    /* Alkalines or NiMH */
+#define BATTERY_SCALE_FACTOR 3000 /* TODO: only roughly correct */
+
 #ifndef SIMULATOR
 
 /* Define this if you have a Philips PNX0101 */
@@ -70,14 +77,6 @@
 /* Define this if you want to use the PNX0101 i2c interface */
 #define CONFIG_I2C I2C_PNX0101
 
-/* Type of mobile power */
-#define CONFIG_BATTERY BATT_1AA
-#define BATTERY_CAPACITY_MIN 500  /* min. capacity selectable */
-#define BATTERY_CAPACITY_MAX 2800 /* max. capacity selectable */
-#define BATTERY_CAPACITY_INC 50   /* capacity increment */
-#define BATTERY_TYPES_COUNT  2    /* Alkalines or NiMH */
-#define BATTERY_SCALE_FACTOR 3000 /* TODO: only roughly correct */
-
 /* The start address index for ROM builds */
 #define ROM_START 0x00000000
 
diff --git a/firmware/export/config-ipod1g2g.h b/firmware/export/config-ipod1g2g.h
index 4ee434f..ff3e7b5 100644
--- a/firmware/export/config-ipod1g2g.h
+++ b/firmware/export/config-ipod1g2g.h
@@ -66,7 +66,20 @@
 /* Define this if the backlight unverts LCD appearance */
 #define HAVE_BACKLIGHT_INVERSION
 
+/* Define this if you can detect headphones */
+#define HAVE_HEADPHONE_DETECTION
+
+/* Type of mobile power */
+#define CONFIG_BATTERY BATT_LIPOL1300
 #define BATTERY_CAPACITY_DEFAULT 630 /* default battery capacity */
+#define BATTERY_CAPACITY_MIN 1200  /* min. capacity selectable */
+#define BATTERY_CAPACITY_MAX 1900 /* max. capacity selectable */
+#define BATTERY_CAPACITY_INC 50   /* capacity increment */
+#define BATTERY_TYPES_COUNT  1    /* only one type */
+#define BATTERY_SCALE_FACTOR 25882
+
+/* Hardware controlled charging? FIXME */
+//#define CONFIG_CHARGING CHARGING_SIMPLE
 
 #ifndef SIMULATOR
 
@@ -79,17 +92,6 @@
 /* Define this if you want to use the PP5002 i2c interface */
 #define CONFIG_I2C I2C_PP5002
 
-/* Type of mobile power */
-#define CONFIG_BATTERY BATT_LIPOL1300
-#define BATTERY_CAPACITY_MIN 1200  /* min. capacity selectable */
-#define BATTERY_CAPACITY_MAX 1900 /* max. capacity selectable */
-#define BATTERY_CAPACITY_INC 50   /* capacity increment */
-#define BATTERY_TYPES_COUNT  1    /* only one type */
-#define BATTERY_SCALE_FACTOR 25882
-
-/* Hardware controlled charging? FIXME */
-//#define CONFIG_CHARGING CHARGING_SIMPLE
-
 /* define this if the hardware can be powered off while charging */
 //#define HAVE_POWEROFF_WHILE_CHARGING
 
@@ -122,9 +124,6 @@
 /* Define this if you have adjustable CPU frequency */
 #define HAVE_ADJUSTABLE_CPU_FREQ
 
-/* Define this if you can detect headphones */
-#define HAVE_HEADPHONE_DETECTION
-
 #define BOOTFILE_EXT "ipod"
 #define BOOTFILE "rockbox." BOOTFILE_EXT
 #define BOOTDIR "/.rockbox"
diff --git a/firmware/export/config-ipod3g.h b/firmware/export/config-ipod3g.h
index b356fc5..64aa149 100644
--- a/firmware/export/config-ipod3g.h
+++ b/firmware/export/config-ipod3g.h
@@ -48,6 +48,9 @@
 /* define this if you have a real-time clock */
 #define CONFIG_RTC RTC_PCF50605
 
+/* Define if the device can wake from an RTC alarm */
+#define HAVE_RTC_ALARM
+
 /* Define this if you have a software controlled poweroff */
 #define HAVE_SW_POWEROFF
 
@@ -66,7 +69,20 @@
 /* Define this for LCD backlight available */
 #define HAVE_BACKLIGHT
 
+/* Define this if you can detect headphones */
+#define HAVE_HEADPHONE_DETECTION
+
+/* Type of mobile power */
+#define CONFIG_BATTERY BATT_LIPOL1300
 #define BATTERY_CAPACITY_DEFAULT 630 /* default battery capacity */
+#define BATTERY_CAPACITY_MIN 630  /* min. capacity selectable */
+#define BATTERY_CAPACITY_MAX 1000 /* max. capacity selectable */
+#define BATTERY_CAPACITY_INC 10   /* capacity increment */
+#define BATTERY_TYPES_COUNT  1    /* only one type */
+#define BATTERY_SCALE_FACTOR 5865
+
+/* Hardware controlled charging? FIXME */
+//#define CONFIG_CHARGING CHARGING_SIMPLE
 
 #ifndef SIMULATOR
 
@@ -79,17 +95,6 @@
 /* Define this if you want to use the PP5002 i2c interface */
 #define CONFIG_I2C I2C_PP5002
 
-/* Type of mobile power */
-#define CONFIG_BATTERY BATT_LIPOL1300
-#define BATTERY_CAPACITY_MIN 630  /* min. capacity selectable */
-#define BATTERY_CAPACITY_MAX 1000 /* max. capacity selectable */
-#define BATTERY_CAPACITY_INC 10   /* capacity increment */
-#define BATTERY_TYPES_COUNT  1    /* only one type */
-#define BATTERY_SCALE_FACTOR 5865
-
-/* Hardware controlled charging? FIXME */
-//#define CONFIG_CHARGING CHARGING_SIMPLE
-
 /* define this if the hardware can be powered off while charging */
 //#define HAVE_POWEROFF_WHILE_CHARGING
 
@@ -119,15 +124,9 @@
 /* Virtual LED (icon) */
 #define CONFIG_LED LED_VIRTUAL
 
-/* Define if the device can wake from an RTC alarm */
-#define HAVE_RTC_ALARM 
-
 /* Define this if you have adjustable CPU frequency */
 #define HAVE_ADJUSTABLE_CPU_FREQ
 
-/* Define this if you can detect headphones */
-#define HAVE_HEADPHONE_DETECTION
-
 #define BOOTFILE_EXT "ipod"
 #define BOOTFILE "rockbox." BOOTFILE_EXT
 #define BOOTDIR "/.rockbox"
diff --git a/firmware/export/config-ipod4g.h b/firmware/export/config-ipod4g.h
index 14a4e82..46c1e53 100644
--- a/firmware/export/config-ipod4g.h
+++ b/firmware/export/config-ipod4g.h
@@ -58,6 +58,9 @@
 /* define this if you have a real-time clock */
 #define CONFIG_RTC RTC_PCF50605
 
+/* Define if the device can wake from an RTC alarm */
+#define HAVE_RTC_ALARM
+
 /* Define this if you have a software controlled poweroff */
 #define HAVE_SW_POWEROFF
 
@@ -76,18 +79,12 @@
 /* Define this for LCD backlight available */
 #define HAVE_BACKLIGHT
 
-#define BATTERY_CAPACITY_DEFAULT 630 /* default battery capacity */
-
-#ifndef SIMULATOR
-
-/* Define this if you have a PortalPlayer PP5020 */
-#define CONFIG_CPU PP5020
-
-/* Define this if you want to use the PP5020 i2c interface */
-#define CONFIG_I2C I2C_PP5020
+/* Define this if you can detect headphones */
+#define HAVE_HEADPHONE_DETECTION
 
 /* Type of mobile power */
 #define CONFIG_BATTERY BATT_LIPOL1300
+#define BATTERY_CAPACITY_DEFAULT 630 /* default battery capacity */
 #define BATTERY_CAPACITY_MIN 630  /* min. capacity selectable */
 #define BATTERY_CAPACITY_MAX 1000 /* max. capacity selectable */
 #define BATTERY_CAPACITY_INC 10   /* capacity increment */
@@ -97,6 +94,17 @@
 /* Hardware controlled charging? FIXME */
 //#define CONFIG_CHARGING CHARGING_SIMPLE
 
+/* define this if the unit can be powered or charged via USB */
+#define HAVE_USB_POWER
+
+#ifndef SIMULATOR
+
+/* Define this if you have a PortalPlayer PP5020 */
+#define CONFIG_CPU PP5020
+
+/* Define this if you want to use the PP5020 i2c interface */
+#define CONFIG_I2C I2C_PP5020
+
 /* define this if the hardware can be powered off while charging */
 //#define HAVE_POWEROFF_WHILE_CHARGING
 
@@ -125,21 +133,12 @@
 /* USB On-the-go */
 #define CONFIG_USBOTG USBOTG_ARC
 
-/* define this if the unit can be powered or charged via USB */
-#define HAVE_USB_POWER
-
 /* Virtual LED (icon) */
 #define CONFIG_LED LED_VIRTUAL
 
-/* Define if the device can wake from an RTC alarm */
-#define HAVE_RTC_ALARM 
-
 /* Define this if you have adjustable CPU frequency */
 #define HAVE_ADJUSTABLE_CPU_FREQ
 
-/* Define this if you can detect headphones */
-#define HAVE_HEADPHONE_DETECTION
-
 /* Define this if you can read an absolute wheel position */
 #define HAVE_WHEEL_POSITION
 
diff --git a/firmware/export/config-ipodcolor.h b/firmware/export/config-ipodcolor.h
index 5e4e3b3..586d672 100644
--- a/firmware/export/config-ipodcolor.h
+++ b/firmware/export/config-ipodcolor.h
@@ -49,6 +49,9 @@
 /* define this if you have a real-time clock */
 #define CONFIG_RTC RTC_PCF50605
 
+/* Define if the device can wake from an RTC alarm */
+#define HAVE_RTC_ALARM
+
 /* Define this if you have a software controlled poweroff */
 #define HAVE_SW_POWEROFF
 
@@ -67,18 +70,12 @@
 /* Define this for LCD backlight available */
 #define HAVE_BACKLIGHT
 
-#define BATTERY_CAPACITY_DEFAULT 700 /* default battery capacity */
-
-#ifndef SIMULATOR
-
-/* Define this if you have a PortalPlayer PP5020 */
-#define CONFIG_CPU PP5020
-
-/* Define this if you want to use the PP5020 i2c interface */
-#define CONFIG_I2C I2C_PP5020
+/* Define this if you can detect headphones */
+#define HAVE_HEADPHONE_DETECTION
 
 /* Type of mobile power */
 #define CONFIG_BATTERY BATT_LIPOL1300
+#define BATTERY_CAPACITY_DEFAULT 700 /* default battery capacity */
 #define BATTERY_CAPACITY_MIN 700  /* min. capacity selectable */
 #define BATTERY_CAPACITY_MAX 1000 /* max. capacity selectable */
 #define BATTERY_CAPACITY_INC 10   /* capacity increment */
@@ -88,6 +85,17 @@
 /* Hardware controlled charging? FIXME */
 //#define CONFIG_CHARGING CHARGING_SIMPLE
 
+/* define this if the unit can be powered or charged via USB */
+#define HAVE_USB_POWER
+
+#ifndef SIMULATOR
+
+/* Define this if you have a PortalPlayer PP5020 */
+#define CONFIG_CPU PP5020
+
+/* Define this if you want to use the PP5020 i2c interface */
+#define CONFIG_I2C I2C_PP5020
+
 /* define this if the hardware can be powered off while charging */
 //#define HAVE_POWEROFF_WHILE_CHARGING
 
@@ -116,21 +124,12 @@
 /* USB On-the-go */
 #define CONFIG_USBOTG USBOTG_ARC
 
-/* define this if the unit can be powered or charged via USB */
-#define HAVE_USB_POWER
-
 /* Virtual LED (icon) */
 #define CONFIG_LED LED_VIRTUAL
 
-/* Define if the device can wake from an RTC alarm */
-#define HAVE_RTC_ALARM 
-
 /* Define this if you have adjustable CPU frequency */
 #define HAVE_ADJUSTABLE_CPU_FREQ
 
-/* Define this if you can detect headphones */
-#define HAVE_HEADPHONE_DETECTION
-
 /* Define this if you can read an absolute wheel position */
 #define HAVE_WHEEL_POSITION
 
diff --git a/firmware/export/config-ipodmini.h b/firmware/export/config-ipodmini.h
index 7fba883..7f77681 100644
--- a/firmware/export/config-ipodmini.h
+++ b/firmware/export/config-ipodmini.h
@@ -48,6 +48,9 @@
 /* define this if you have a real-time clock */
 #define CONFIG_RTC RTC_PCF50605
 
+/* Define if the device can wake from an RTC alarm */
+#define HAVE_RTC_ALARM
+
 /* Define this if you have a software controlled poweroff */
 #define HAVE_SW_POWEROFF
 
@@ -69,18 +72,12 @@
 /* Define this for LCD backlight available */
 #define HAVE_BACKLIGHT
 
-#define BATTERY_CAPACITY_DEFAULT 400 /* default battery capacity */
-
-#ifndef SIMULATOR
-
-/* Define this if you have a PortalPlayer PP5020 */
-#define CONFIG_CPU PP5020
-
-/* Define this if you want to use the PP5020 i2c interface */
-#define CONFIG_I2C I2C_PP5020
+/* Define this if you can detect headphones */
+#define HAVE_HEADPHONE_DETECTION
 
 /* Type of mobile power */
 #define CONFIG_BATTERY BATT_LIPOL1300
+#define BATTERY_CAPACITY_DEFAULT 400 /* default battery capacity */
 #define BATTERY_CAPACITY_MIN 400 /* min. capacity selectable */
 #define BATTERY_CAPACITY_MAX 800 /* max. capacity selectable */
 #define BATTERY_CAPACITY_INC 10  /* capacity increment */
@@ -90,6 +87,17 @@
 /* Hardware controlled charging? FIXME */
 //#define CONFIG_CHARGING CHARGING_SIMPLE
 
+/* define this if the unit can be powered or charged via USB */
+#define HAVE_USB_POWER
+
+#ifndef SIMULATOR
+
+/* Define this if you have a PortalPlayer PP5020 */
+#define CONFIG_CPU PP5020
+
+/* Define this if you want to use the PP5020 i2c interface */
+#define CONFIG_I2C I2C_PP5020
+
 /* define this if the hardware can be powered off while charging */
 //#define HAVE_POWEROFF_WHILE_CHARGING
 
@@ -118,21 +126,12 @@
 /* USB On-the-go */
 #define CONFIG_USBOTG USBOTG_ARC
 
-/* define this if the unit can be powered or charged via USB */
-#define HAVE_USB_POWER
-
 /* Virtual LED (icon) */
 #define CONFIG_LED LED_VIRTUAL
 
-/* Define if the device can wake from an RTC alarm */
-#define HAVE_RTC_ALARM 
-
 /* Define this if you have adjustable CPU frequency */
 #define HAVE_ADJUSTABLE_CPU_FREQ
 
-/* Define this if you can detect headphones */
-#define HAVE_HEADPHONE_DETECTION
-
 #define BOOTFILE_EXT "ipod"
 #define BOOTFILE "rockbox." BOOTFILE_EXT
 #define BOOTDIR "/.rockbox"
diff --git a/firmware/export/config-ipodmini2g.h b/firmware/export/config-ipodmini2g.h
index 032d32a..76c64f4 100644
--- a/firmware/export/config-ipodmini2g.h
+++ b/firmware/export/config-ipodmini2g.h
@@ -48,6 +48,9 @@
 /* define this if you have a real-time clock */
 #define CONFIG_RTC RTC_PCF50605
 
+/* Define if the device can wake from an RTC alarm */
+#define HAVE_RTC_ALARM
+
 /* Define this if you have a software controlled poweroff */
 #define HAVE_SW_POWEROFF
 
@@ -72,18 +75,12 @@
 /* We can fade the backlight by using PWM */
 #define HAVE_BACKLIGHT_PWM_FADING
 
-#define BATTERY_CAPACITY_DEFAULT 400 /* default battery capacity */
-
-#ifndef SIMULATOR
-
-/* Define this if you have a PortalPlayer PP5022 */
-#define CONFIG_CPU PP5022
-
-/* Define this if you want to use the PP5020 i2c interface */
-#define CONFIG_I2C I2C_PP5020
+/* Define this if you can detect headphones */
+#define HAVE_HEADPHONE_DETECTION
 
 /* Type of mobile power */
 #define CONFIG_BATTERY BATT_LIPOL1300
+#define BATTERY_CAPACITY_DEFAULT 400 /* default battery capacity */
 #define BATTERY_CAPACITY_MIN 400 /* min. capacity selectable */
 #define BATTERY_CAPACITY_MAX 800 /* max. capacity selectable */
 #define BATTERY_CAPACITY_INC 50  /* capacity increment */
@@ -93,6 +90,17 @@
 /* Hardware controlled charging? FIXME */
 //#define CONFIG_CHARGING CHARGING_SIMPLE
 
+/* define this if the unit can be powered or charged via USB */
+#define HAVE_USB_POWER
+
+#ifndef SIMULATOR
+
+/* Define this if you have a PortalPlayer PP5022 */
+#define CONFIG_CPU PP5022
+
+/* Define this if you want to use the PP5020 i2c interface */
+#define CONFIG_I2C I2C_PP5020
+
 /* define this if the hardware can be powered off while charging */
 //#define HAVE_POWEROFF_WHILE_CHARGING
 
@@ -121,21 +129,12 @@
 /* USB On-the-go */
 #define CONFIG_USBOTG USBOTG_ARC
 
-/* define this if the unit can be powered or charged via USB */
-#define HAVE_USB_POWER
-
 /* Virtual LED (icon) */
 #define CONFIG_LED LED_VIRTUAL
 
-/* Define if the device can wake from an RTC alarm */
-#define HAVE_RTC_ALARM 
-
 /* Define this if you have adjustable CPU frequency */
 #define HAVE_ADJUSTABLE_CPU_FREQ
 
-/* Define this if you can detect headphones */
-#define HAVE_HEADPHONE_DETECTION
-
 /* Define this if you can read an absolute wheel position */
 #define HAVE_WHEEL_POSITION
 
diff --git a/firmware/export/config-ipodnano.h b/firmware/export/config-ipodnano.h
index 546d9b8..a2f9e32 100644
--- a/firmware/export/config-ipodnano.h
+++ b/firmware/export/config-ipodnano.h
@@ -49,6 +49,9 @@
 /* define this if you have a real-time clock */
 #define CONFIG_RTC RTC_PCF50605
 
+/* Define if the device can wake from an RTC alarm */
+#define HAVE_RTC_ALARM
+
 /* Define this if you have a software controlled poweroff */
 #define HAVE_SW_POWEROFF
 
@@ -70,9 +73,26 @@
 /* We can fade the backlight by using PWM */
 #define HAVE_BACKLIGHT_PWM_FADING
 
+/* Define this if you can detect headphones */
+#define HAVE_HEADPHONE_DETECTION
+
 /* define this if you have a flash memory storage */
 #define HAVE_FLASH_STORAGE
 
+/* Type of mobile power */
+#define CONFIG_BATTERY BATT_LIION300
+#define BATTERY_CAPACITY_DEFAULT 300   /* default battery capacity */
+#define BATTERY_CAPACITY_MIN     200   /* min. capacity selectable */
+#define BATTERY_CAPACITY_MAX     600   /* max. capacity selectable */
+#define BATTERY_CAPACITY_INC      20  	/* capacity increment */
+#define BATTERY_TYPES_COUNT        1   /* only one type */
+
+/* Hardware controlled charging? FIXME */
+//#define CONFIG_CHARGING CHARGING_SIMPLE
+
+/* define this if the unit can be powered or charged via USB */
+#define HAVE_USB_POWER
+
 #ifndef SIMULATOR
 
 /* Define this if you have a PortalPlayer PP5022 */
@@ -81,18 +101,8 @@
 /* Define this if you want to use the PP5020 i2c interface */
 #define CONFIG_I2C I2C_PP5020
 
-/* Type of mobile power */
-#define CONFIG_BATTERY BATT_LIION300
-#define BATTERY_CAPACITY_DEFAULT 300   /* default battery capacity */
-#define BATTERY_CAPACITY_MIN     200   /* min. capacity selectable */
-#define BATTERY_CAPACITY_MAX     600   /* max. capacity selectable */
-#define BATTERY_CAPACITY_INC      20  	/* capacity increment */
-#define BATTERY_TYPES_COUNT        1   /* only one type */
 #define BATTERY_SCALE_FACTOR    5840
 
-/* Hardware controlled charging? FIXME */
-//#define CONFIG_CHARGING CHARGING_SIMPLE
-
 /* define this if the hardware can be powered off while charging */
 //#define HAVE_POWEROFF_WHILE_CHARGING
 
@@ -121,21 +131,12 @@
 /* USB On-the-go */
 #define CONFIG_USBOTG USBOTG_ARC
 
-/* define this if the unit can be powered or charged via USB */
-#define HAVE_USB_POWER
-
 /* Virtual LED (icon) */
 #define CONFIG_LED LED_VIRTUAL
 
-/* Define if the device can wake from an RTC alarm */
-#define HAVE_RTC_ALARM 
-
 /* Define this if you have adjustable CPU frequency */
 #define HAVE_ADJUSTABLE_CPU_FREQ
 
-/* Define this if you can detect headphones */
-#define HAVE_HEADPHONE_DETECTION
-
 /* Define this if you can read an absolute wheel position */
 #define HAVE_WHEEL_POSITION
 
diff --git a/firmware/export/config-ipodvideo.h b/firmware/export/config-ipodvideo.h
index 419a491..0f2da53 100644
--- a/firmware/export/config-ipodvideo.h
+++ b/firmware/export/config-ipodvideo.h
@@ -52,6 +52,9 @@
 /* define this if you have a real-time clock */
 #define CONFIG_RTC RTC_PCF50605
 
+/* Define if the device can wake from an RTC alarm */
+#define HAVE_RTC_ALARM
+
 /* Define this if you have a software controlled poweroff */
 #define HAVE_SW_POWEROFF
 
@@ -73,13 +76,8 @@
 /* We can fade the backlight by using PWM */
 #define HAVE_BACKLIGHT_PWM_FADING
 
-#ifndef SIMULATOR
-
-/* Define this if you have a PortalPlayer PP5022 */
-#define CONFIG_CPU PP5022
-
-/* Define this if you want to use the PP5020 i2c interface */
-#define CONFIG_I2C I2C_PP5020
+/* Define this if you can detect headphones */
+#define HAVE_HEADPHONE_DETECTION
 
 /* Type of mobile power */
 #if (MEM==32)  /* this is the 30GB-model */
@@ -103,6 +101,17 @@
 /* Hardware controlled charging with monitoring */
 #define CONFIG_CHARGING CHARGING_MONITOR
 
+/* define this if the unit can be powered or charged via USB */
+#define HAVE_USB_POWER
+
+#ifndef SIMULATOR
+
+/* Define this if you have a PortalPlayer PP5022 */
+#define CONFIG_CPU PP5022
+
+/* Define this if you want to use the PP5020 i2c interface */
+#define CONFIG_I2C I2C_PP5020
+
 /* define this if the hardware can be powered off while charging */
 //#define HAVE_POWEROFF_WHILE_CHARGING
 
@@ -131,21 +140,12 @@
 /* USB On-the-go */
 #define CONFIG_USBOTG USBOTG_ARC
 
-/* define this if the unit can be powered or charged via USB */
-#define HAVE_USB_POWER
-
 /* Virtual LED (icon) */
 #define CONFIG_LED LED_VIRTUAL
 
-/* Define if the device can wake from an RTC alarm */
-#define HAVE_RTC_ALARM 
-
 /* Define this if you have adjustable CPU frequency */
 #define HAVE_ADJUSTABLE_CPU_FREQ
 
-/* Define this if you can detect headphones */
-#define HAVE_HEADPHONE_DETECTION
-
 /* Define this if you can read an absolute wheel position */
 #define HAVE_WHEEL_POSITION
 
diff --git a/firmware/export/config-ondiofm.h b/firmware/export/config-ondiofm.h
index 93c0fcc..f9c2b19 100644
--- a/firmware/export/config-ondiofm.h
+++ b/firmware/export/config-ondiofm.h
@@ -46,11 +46,24 @@
 /* Enable this if you have done the backlight mod */
 //#define HAVE_BACKLIGHT
 
-#define BATTERY_CAPACITY_DEFAULT 1000 /* default battery capacity */
-
 /* define this if you have a flash memory storage */
 #define HAVE_FLASH_STORAGE
 
+/* define this if more than one device/partition can be used */
+#define HAVE_MULTIVOLUME
+
+/* Type of mobile power */
+#define CONFIG_BATTERY BATT_3AAA
+#define BATTERY_CAPACITY_DEFAULT 1000 /* default battery capacity */
+#define BATTERY_CAPACITY_MIN 500  /* min. capacity selectable */
+#define BATTERY_CAPACITY_MAX 1500 /* max. capacity selectable */
+#define BATTERY_CAPACITY_INC 50   /* capacity increment */
+#define BATTERY_TYPES_COUNT  2    /* Alkalines or NiMH */
+#define BATTERY_SCALE_FACTOR 4735 /* average from 3 Ondios */
+
+/* define this if the unit can be powered or charged via USB */
+#define HAVE_USB_POWER
+
 #ifndef SIMULATOR
 
 /* Define this if you have a SH7034 */
@@ -62,14 +75,6 @@
 /* Define this for different I2C pinout */
 #define CONFIG_I2C I2C_ONDIO
 
-/* Type of mobile power */
-#define CONFIG_BATTERY BATT_3AAA
-#define BATTERY_CAPACITY_MIN 500  /* min. capacity selectable */
-#define BATTERY_CAPACITY_MAX 1500 /* max. capacity selectable */
-#define BATTERY_CAPACITY_INC 50   /* capacity increment */
-#define BATTERY_TYPES_COUNT  2    /* Alkalines or NiMH */
-#define BATTERY_SCALE_FACTOR 4735 /* average from 3 Ondios */
-
 /* Define this if you control power on PB5 (instead of the OFF button) */
 #define HAVE_POWEROFF_ON_PB5
 
@@ -107,9 +112,6 @@
 /* Define this if the MAS SIBI line can be controlled via PB8 */
 #define HAVE_MAS_SIBI_CONTROL
 
-/* define this if more than one device/partition can be used */
-#define HAVE_MULTIVOLUME
-
 /* define this if media can be exchanged on the fly */
 #define HAVE_HOTSWAP
 
@@ -118,9 +120,6 @@
 
 #define CONFIG_LCD LCD_SSD1815
 
-/* define this if the unit can be powered or charged via USB */
-#define HAVE_USB_POWER
-
 #define BOOTFILE_EXT "ajz"
 #define BOOTFILE "ajbrec." BOOTFILE_EXT
 #define BOOTDIR "/"
diff --git a/firmware/export/config-ondiosp.h b/firmware/export/config-ondiosp.h
index 22673e8..510ce01 100644
--- a/firmware/export/config-ondiosp.h
+++ b/firmware/export/config-ondiosp.h
@@ -35,11 +35,24 @@
 /* Enable this if you have done the backlight mod */
 //#define HAVE_BACKLIGHT
 
-#define BATTERY_CAPACITY_DEFAULT 1000 /* default battery capacity */
-
 /* define this if you have a flash memory storage */
 #define HAVE_FLASH_STORAGE
 
+/* define this if more than one device/partition can be used */
+#define HAVE_MULTIVOLUME
+
+/* Type of mobile power */
+#define CONFIG_BATTERY BATT_3AAA
+#define BATTERY_CAPACITY_DEFAULT 1000 /* default battery capacity */
+#define BATTERY_CAPACITY_MIN 500  /* min. capacity selectable */
+#define BATTERY_CAPACITY_MAX 1500 /* max. capacity selectable */
+#define BATTERY_CAPACITY_INC 50   /* capacity increment */
+#define BATTERY_TYPES_COUNT  2    /* Alkalines or NiMH */
+#define BATTERY_SCALE_FACTOR 4735 /* average from 3 Ondios */
+
+/* define this if the unit can be powered or charged via USB */
+#define HAVE_USB_POWER
+
 #ifndef SIMULATOR
 
 /* Define this if you have a SH7034 */
@@ -48,14 +61,6 @@
 /* Define this to the CPU frequency */
 #define CPU_FREQ      12000000
 
-/* Type of mobile power */
-#define CONFIG_BATTERY BATT_3AAA
-#define BATTERY_CAPACITY_MIN 500  /* min. capacity selectable */
-#define BATTERY_CAPACITY_MAX 1500 /* max. capacity selectable */
-#define BATTERY_CAPACITY_INC 50   /* capacity increment */
-#define BATTERY_TYPES_COUNT  2    /* Alkalines or NiMH */
-#define BATTERY_SCALE_FACTOR 4735 /* average from 3 Ondios */
-
 /* Define this if you control power on PB5 (instead of the OFF button) */
 #define HAVE_POWEROFF_ON_PB5
 
@@ -90,9 +95,6 @@
 /* Define this if the MAS SIBI line can be controlled via PB8 */
 #define HAVE_MAS_SIBI_CONTROL
 
-/* define this if more than one device/partition can be used */
-#define HAVE_MULTIVOLUME
-
 /* define this if media can be exchanged on the fly */
 #define HAVE_HOTSWAP
 
@@ -101,9 +103,6 @@
 
 #define CONFIG_LCD LCD_SSD1815
 
-/* define this if the unit can be powered or charged via USB */
-#define HAVE_USB_POWER
-
 #define BOOTFILE_EXT "ajz"
 #define BOOTFILE "ajbrec." BOOTFILE_EXT
 #define BOOTDIR "/"
diff --git a/firmware/export/config-player.h b/firmware/export/config-player.h
index 0256db1..5e20d9e 100644
--- a/firmware/export/config-player.h
+++ b/firmware/export/config-player.h
@@ -27,7 +27,17 @@
 /* Define this for LCD backlight available */
 #define HAVE_BACKLIGHT
 
+/* Type of mobile power */
+#define CONFIG_BATTERY BATT_4AA_NIMH
 #define BATTERY_CAPACITY_DEFAULT 1500 /* default battery capacity */
+#define BATTERY_CAPACITY_MIN 1500 /* min. capacity selectable */
+#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable */
+#define BATTERY_CAPACITY_INC 50   /* capacity increment */
+#define BATTERY_TYPES_COUNT  1    /* only one type */
+#define BATTERY_SCALE_FACTOR 6546
+
+/* Hardware controlled charging */
+#define CONFIG_CHARGING CHARGING_SIMPLE
 
 #ifndef SIMULATOR
 
@@ -48,14 +58,6 @@
 /* Define this to the CPU frequency */
 #define CPU_FREQ 12000000 /* cycle time ~83.3ns */
 
-/* Type of mobile power */
-#define CONFIG_BATTERY BATT_4AA_NIMH
-#define BATTERY_CAPACITY_MIN 1500 /* min. capacity selectable */
-#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable */
-#define BATTERY_CAPACITY_INC 50   /* capacity increment */
-#define BATTERY_TYPES_COUNT  1    /* only one type */
-#define BATTERY_SCALE_FACTOR 6546
-
 /* Define this if you must discharge the data line by driving it low
    and then set it to input to see if it stays low or goes high */
 #define HAVE_I2C_LOW_FIRST
@@ -74,9 +76,6 @@
 /* Offset ( in the firmware file's header ) to the real data */
 #define FIRMWARE_OFFSET_FILE_DATA 6
 
-/* Hardware controlled charging */
-#define CONFIG_CHARGING CHARGING_SIMPLE
-
 /* The start address index for ROM builds */
 /* #define ROM_START 0xD010 for behind original Archos */
 #define ROM_START 0x6010 /* for behind BootBox */
diff --git a/firmware/export/config-recorder.h b/firmware/export/config-recorder.h
index 29f187f..920db04 100644
--- a/firmware/export/config-recorder.h
+++ b/firmware/export/config-recorder.h
@@ -51,7 +51,17 @@
 
 #define CONFIG_I2C I2C_PLAYREC
 
+/* Type of mobile power */
+#define CONFIG_BATTERY BATT_4AA_NIMH
 #define BATTERY_CAPACITY_DEFAULT 1500 /* default battery capacity */
+#define BATTERY_CAPACITY_MIN 1500 /* min. capacity selectable */
+#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable */
+#define BATTERY_CAPACITY_INC 50   /* capacity increment */
+#define BATTERY_TYPES_COUNT  1    /* only one type */
+#define BATTERY_SCALE_FACTOR 6465
+
+/* Software controlled charging */
+#define CONFIG_CHARGING CHARGING_CONTROL
 
 #ifndef SIMULATOR
 
@@ -67,14 +77,6 @@
 /* Define this to the CPU frequency */
 #define CPU_FREQ      11059200
 
-/* Type of mobile power */
-#define CONFIG_BATTERY BATT_4AA_NIMH
-#define BATTERY_CAPACITY_MIN 1500 /* min. capacity selectable */
-#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable */
-#define BATTERY_CAPACITY_INC 50   /* capacity increment */
-#define BATTERY_TYPES_COUNT  1    /* only one type */
-#define BATTERY_SCALE_FACTOR 6465
-
 /* Define this if you control power on PBDR (instead of PADR) */
 #define HAVE_POWEROFF_ON_PBDR
 
@@ -87,9 +89,6 @@
 /* Offset ( in the firmware file's header ) to the real data */
 #define FIRMWARE_OFFSET_FILE_DATA 6
 
-/* Software controlled charging */
-#define CONFIG_CHARGING CHARGING_CONTROL
-
 /* The start address index for ROM builds */
 /* #define ROM_START 0x11010 for behind original Archos */
 #define ROM_START 0x7010 /* for behind BootBox */
diff --git a/firmware/export/config-recorderv2.h b/firmware/export/config-recorderv2.h
index b534be5..fc14610 100644
--- a/firmware/export/config-recorderv2.h
+++ b/firmware/export/config-recorderv2.h
@@ -35,6 +35,9 @@
 /* define this if you have a real-time clock */
 #define CONFIG_RTC RTC_M41ST84W
 
+/* FM recorders can wake up from RTC alarm */
+#define HAVE_RTC_ALARM
+
 /* define this if you have RTC RAM available for settings */
 #define HAVE_RTC_RAM
 
@@ -54,7 +57,21 @@
 
 #define CONFIG_I2C I2C_PLAYREC
 
+/* Type of mobile power */
+#define CONFIG_BATTERY BATT_LIION2200
 #define BATTERY_CAPACITY_DEFAULT 2200 /* default battery capacity */
+#define BATTERY_CAPACITY_MIN 2200 /* min. capacity selectable */
+#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable */
+#define BATTERY_CAPACITY_INC 50   /* capacity increment */
+#define BATTERY_TYPES_COUNT  1    /* only one type */
+/* Battery scale factor (guessed, seems to be 1,25 * value from recorder) */
+#define BATTERY_SCALE_FACTOR 8081
+
+/* Hardware controlled charging with monitoring */
+#define CONFIG_CHARGING CHARGING_MONITOR
+
+/* define this if the unit can be powered or charged via USB */
+#define HAVE_USB_POWER
 
 #ifndef SIMULATOR
 
@@ -73,15 +90,6 @@
 /* Define this to the CPU frequency */
 #define CPU_FREQ      11059200
 
-/* Type of mobile power */
-#define CONFIG_BATTERY BATT_LIION2200
-#define BATTERY_CAPACITY_MIN 2200 /* min. capacity selectable */
-#define BATTERY_CAPACITY_MAX 3200 /* max. capacity selectable */
-#define BATTERY_CAPACITY_INC 50   /* capacity increment */
-#define BATTERY_TYPES_COUNT  1    /* only one type */
-/* Battery scale factor (guessed, seems to be 1,25 * value from recorder) */
-#define BATTERY_SCALE_FACTOR 8081
-
 /* Define this if you control power on PB5 (instead of the OFF button) */
 #define HAVE_POWEROFF_ON_PB5
 
@@ -94,15 +102,9 @@
 /* Offset ( in the firmware file's header ) to the real data */
 #define FIRMWARE_OFFSET_FILE_DATA 24
 
-/* FM recorders can wake up from RTC alarm */
-#define HAVE_RTC_ALARM
-
 /* Define this if you have an FM Radio */
 #define CONFIG_TUNER S1A0903X01
 
-/* Hardware controlled charging with monitoring */
-#define CONFIG_CHARGING CHARGING_MONITOR
-
 /* The start address index for ROM builds */
 /* #define ROM_START 0x12010 for behind original Archos */
 #define ROM_START 0x7010 /* for behind BootBox */
@@ -110,9 +112,6 @@
 /* Software controlled LED */
 #define CONFIG_LED LED_REAL
 
-/* define this if the unit can be powered or charged via USB */
-#define HAVE_USB_POWER
-
 #define CONFIG_LCD LCD_SSD1815
 
 #define BOOTFILE_EXT "ajz"
diff --git a/firmware/export/config-tpj1022.h b/firmware/export/config-tpj1022.h
index 02e7319..be2da37 100644
--- a/firmware/export/config-tpj1022.h
+++ b/firmware/export/config-tpj1022.h
@@ -57,20 +57,11 @@
 /* Define this for LCD backlight available */
 #define HAVE_BACKLIGHT
 
+/* Type of mobile power */
+#define CONFIG_BATTERY BATT_LPCS355385
 #define BATTERY_CAPACITY_DEFAULT 1550 /* default battery capacity
                                         TODO: check this, probably different
                                         for different models too */
-
-#ifndef SIMULATOR
-
-/* Define this if you have a PortalPlayer PP5020 */
-#define CONFIG_CPU PP5020
-
-/* Define this if you want to use the PP5020 i2c interface */
-#define CONFIG_I2C I2C_PP5020
-
-/* Type of mobile power */
-#define CONFIG_BATTERY BATT_LPCS355385
 #define BATTERY_CAPACITY_MIN 1500  /* min. capacity selectable */
 #define BATTERY_CAPACITY_MAX 1600 /* max. capacity selectable */
 #define BATTERY_CAPACITY_INC 10   /* capacity increment */
@@ -80,6 +71,17 @@
 /* Hardware controlled charging? FIXME */
 //#define CONFIG_CHARGING CHARGING_SIMPLE
 
+/* define this if the unit can be powered or charged via USB */
+/*#define HAVE_USB_POWER*/
+
+#ifndef SIMULATOR
+
+/* Define this if you have a PortalPlayer PP5020 */
+#define CONFIG_CPU PP5020
+
+/* Define this if you want to use the PP5020 i2c interface */
+#define CONFIG_I2C I2C_PP5020
+
 /* define this if the hardware can be powered off while charging */
 /* TODO: should this be set for the H10? */
 //#define HAVE_POWEROFF_WHILE_CHARGING
@@ -110,9 +112,6 @@
 /* USB On-the-go */
 #define CONFIG_USBOTG USBOTG_ARC
 
-/* define this if the unit can be powered or charged via USB */
-/*#define HAVE_USB_POWER*/
-
 /* Virtual LED (icon) */
 #define CONFIG_LED LED_VIRTUAL
 
diff --git a/firmware/export/lcd-remote.h b/firmware/export/lcd-remote.h
index 6f3602c..44f809a 100644
--- a/firmware/export/lcd-remote.h
+++ b/firmware/export/lcd-remote.h
@@ -27,7 +27,7 @@
 
 #ifdef HAVE_REMOTE_LCD
 
-#if defined(TARGET_TREE) && !defined(SIMULATOR)
+#if defined(TARGET_TREE)
 #include "lcd-remote-target.h"
 #endif
 
diff --git a/firmware/export/power.h b/firmware/export/power.h
index fbc3ded..b97410f 100644
--- a/firmware/export/power.h
+++ b/firmware/export/power.h
@@ -31,14 +31,14 @@
 void power_off(void);
 void ide_power_enable(bool on);
 
-#ifndef SIMULATOR
-
-void power_init(void);
-
 # if CONFIG_CHARGING == CHARGING_MONITOR
 bool charging_state(void);
 # endif
 
+#ifndef SIMULATOR
+
+void power_init(void);
+
 bool ide_powered(void);
 #endif
 
diff --git a/firmware/export/powermgmt.h b/firmware/export/powermgmt.h
index 77764b5..4bdaa43 100644
--- a/firmware/export/powermgmt.h
+++ b/firmware/export/powermgmt.h
@@ -26,6 +26,34 @@
 #define CHARGE_END_LONGD  50     /* stop when N minutes have passed with
                                   * avg delta being < -0.02 V */
 
+#if CONFIG_CHARGING >= CHARGING_MONITOR
+typedef enum {       /* sorted by increasing charging current */
+    DISCHARGING = 0,
+    TRICKLE,         /* Can occur for CONFIG_CHARGING >= CHARGING_MONITOR */
+    TOPOFF,          /* Can occur for CONFIG_CHARGING == CHARGING_CONTROL */
+    CHARGING         /* Can occur for all CONFIG_CHARGING options */
+} charge_state_type;
+
+/* tells what the charger is doing */
+extern charge_state_type charge_state;
+#endif /* CONFIG_CHARGING >= CHARGING_MONITOR */
+
+#ifdef CONFIG_CHARGING
+/*
+ * Flag that the charger has been plugged in/removed: this is set for exactly
+ * one time through the power loop when the charger has been plugged in.
+ */
+typedef enum {
+    NO_CHARGER,
+    CHARGER_UNPLUGGED,              /* transient state */
+    CHARGER_PLUGGED,                /* transient state */
+    CHARGER
+} charger_input_state_type;
+
+/* tells the state of the charge input */
+extern charger_input_state_type charger_input_state;
+#endif
+
 #ifndef SIMULATOR
 
 #if CONFIG_CHARGING == CHARGING_CONTROL
@@ -61,34 +89,6 @@
 
 #endif /* CONFIG_CHARGING == CHARGING_CONTROL */
 
-#if CONFIG_CHARGING >= CHARGING_MONITOR
-typedef enum {       /* sorted by increasing charging current */
-    DISCHARGING = 0,
-    TRICKLE,         /* Can occur for CONFIG_CHARGING >= CHARGING_MONITOR */
-    TOPOFF,          /* Can occur for CONFIG_CHARGING == CHARGING_CONTROL */
-    CHARGING         /* Can occur for all CONFIG_CHARGING options */
-} charge_state_type;
-
-/* tells what the charger is doing */
-extern charge_state_type charge_state;
-#endif /* CONFIG_CHARGING >= CHARGING_MONITOR */
-
-#ifdef CONFIG_CHARGING
-/*
- * Flag that the charger has been plugged in/removed: this is set for exactly
- * one time through the power loop when the charger has been plugged in.
- */
-typedef enum {
-    NO_CHARGER,
-    CHARGER_UNPLUGGED,              /* transient state */
-    CHARGER_PLUGGED,                /* transient state */
-    CHARGER
-} charger_input_state_type;
-
-/* tells the state of the charge input */
-extern charger_input_state_type charger_input_state;
-#endif
-
 #ifdef HAVE_MMC  /* Values for Ondio */
 # define CURRENT_NORMAL     95  /* average, nearly proportional to 1/U */
 # define CURRENT_USB         1  /* host powered in USB mode; avoid zero-div */
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index 6f013de..49b9a51 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -76,6 +76,13 @@
 #endif
 
 static int shutdown_timeout = 0;
+#if CONFIG_CHARGING >= CHARGING_MONITOR
+charge_state_type charge_state;     /* charging mode */
+#endif
+
+#if CONFIG_CHARGING
+charger_input_state_type charger_input_state IDATA_ATTR;
+#endif
 
 #ifdef SIMULATOR /***********************************************************/
 
@@ -153,11 +160,17 @@
   (void)capacity;
 }
 
+#if BATTERY_TYPES_COUNT > 1
+void set_battery_type(int type)
+{
+    (void)type;
+}
+#endif
+
 void reset_poweroff_timer(void)
 {
 }
 
-
 #else /* not SIMULATOR ******************************************************/
 
 static const int poweroff_idle_timeout_value[15] =
@@ -269,9 +282,6 @@
 };
 
 #if CONFIG_CHARGING
-charger_input_state_type charger_input_state IDATA_ATTR;
-
-
 /* voltages (centivolt) of 0%, 10%, ... 100% when charging enabled */
 static const unsigned short percent_to_volt_charge[11] =
 {
@@ -305,10 +315,6 @@
 };
 #endif /* CONFIG_CHARGING */
 
-#if CONFIG_CHARGING >= CHARGING_MONITOR
-charge_state_type charge_state;     /* charging mode */
-#endif
-
 #if CONFIG_CHARGING == CHARGING_CONTROL
 int long_delta;                     /* long term delta battery voltage */
 int short_delta;                    /* short term delta battery voltage */
diff --git a/firmware/target/coldfire/iaudio/m5/power-m5.c b/firmware/target/coldfire/iaudio/m5/power-m5.c
index f3e7cdd..d33cbec 100644
--- a/firmware/target/coldfire/iaudio/m5/power-m5.c
+++ b/firmware/target/coldfire/iaudio/m5/power-m5.c
@@ -65,25 +65,4 @@
     asm("halt");
 }
 
-#else
-
-bool charger_inserted(void)
-{
-    return false;
-}
-
-void charger_enable(bool on)
-{
-    (void)on;
-}
-
-void power_off(void)
-{
-}
-
-void ide_power_enable(bool on)
-{
-   (void)on;
-}
-
 #endif /* SIMULATOR */
diff --git a/firmware/target/coldfire/iaudio/x5/power-x5.c b/firmware/target/coldfire/iaudio/x5/power-x5.c
index 5c6c388..76d6123 100644
--- a/firmware/target/coldfire/iaudio/x5/power-x5.c
+++ b/firmware/target/coldfire/iaudio/x5/power-x5.c
@@ -65,27 +65,6 @@
     asm("halt");
 }
 
-#else
-
-bool charger_inserted(void)
-{
-    return false;
-}
-
-void charger_enable(bool on)
-{
-    (void)on;
-}
-
-void power_off(void)
-{
-}
-
-void ide_power_enable(bool on)
-{
-   (void)on;
-}
-
 #endif /* SIMULATOR */
 
 static bool powered = false;
diff --git a/firmware/target/coldfire/iriver/h100/power-h100.c b/firmware/target/coldfire/iriver/h100/power-h100.c
index c184126..27000eb 100644
--- a/firmware/target/coldfire/iriver/h100/power-h100.c
+++ b/firmware/target/coldfire/iriver/h100/power-h100.c
@@ -127,37 +127,4 @@
         yield();
 }
 
-#else
-
-bool charger_inserted(void)
-{
-    return false;
-}
-
-void charger_enable(bool on)
-{
-    (void)on;
-}
-
-void power_off(void)
-{
-}
-
-void ide_power_enable(bool on)
-{
-   (void)on;
-}
-
-#ifdef HAVE_SPDIF_POWER
-void spdif_power_enable(bool on)
-{
-   (void)on;
-}
-
-bool spdif_powered(void)
-{
-    return false;
-}
-#endif
-
 #endif /* SIMULATOR */
diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c
index 5cc312a..69daa51 100644
--- a/uisimulator/common/stubs.c
+++ b/uisimulator/common/stubs.c
@@ -44,11 +44,18 @@
     return 63;
 }
 
+bool fat_ismounted(int volume)
+{
+    (void)volume;
+    return true;
+}
+
 int ata_write_sectors(IF_MV2(int drive,)
                       unsigned long start,
                       int count,
                       const void* buf)
 {
+    IF_MV((void)drive;)
     int i;
 
     for (i=0; i<count; i++ ) {
@@ -70,6 +77,7 @@
                      int count,
                      void* buf)
 {
+    IF_MV((void)drive;)
     int i;
 
     for (i=0; i<count; i++ ) {
@@ -105,6 +113,10 @@
     (void)s;
 }
 
+void rtc_init(void)
+{
+}
+
 int rtc_read(int address)
 {
     return address ^ 0x55;
@@ -139,11 +151,103 @@
     return 0;
 }
 
+#ifdef HAVE_RTC_ALARM
+void rtc_get_alarm(int *h, int *m)
+{
+    *h = 11;
+    *m = 55;
+}
+
+void rtc_set_alarm(int h, int m)
+{
+    (void)h;
+    (void)m;
+}
+
+bool rtc_enable_alarm(bool enable)
+{
+    return enable;
+}
+
+bool rtc_check_alarm_started(bool release_alarm)
+{
+    return release_alarm;
+}
+
+bool rtc_check_alarm_flag(void)
+{
+    return true;
+}
+#endif
+
+#ifdef HAVE_HEADPHONE_DETECTION
+bool headphones_inserted(void)
+{
+    return true;
+}
+#endif
+
+#ifdef HAVE_LCD_ENABLE
+bool lcd_enabled(void)
+{
+    return true;
+}
+#endif
+
+bool charging_state(void)
+{
+    return false;
+}
+
+bool charger_inserted(void)
+{
+    return false;
+}
+
+#ifdef HAVE_SPDIF_POWER
+void spdif_power_enable(bool on)
+{
+   (void)on;
+}
+
+bool spdif_powered(void)
+{
+    return false;
+}
+#endif
+
 bool is_new_player(void)
 {
     return having_new_lcd;
 }
 
+#ifdef HAVE_USB_POWER
+bool usb_powered(void)
+{
+    return false;
+}
+
+#if CONFIG_CHARGING
+bool usb_charging_enable(bool on)
+{
+    (void)on;
+    return false;
+}
+#endif
+#endif
+
+bool usb_inserted(void)
+{
+    return false;
+}
+
+#ifdef HAVE_REMOTE_LCD_TICKING
+void lcd_remote_emireduce(bool state)
+{
+    (void)state;
+}
+#endif
+
 void lcd_set_contrast( int x )
 {
     (void)x;