Rockbox Technical Forums

Rockbox Development => Starting Development and Compiling => Topic started by: Massa on January 02, 2017, 05:56:52 PM

Title: Rockbox simulators - currently working in windows?
Post by: Massa on January 02, 2017, 05:56:52 PM
Hi everybody,

I first tried to compile a rockbox simulator for windows myself - but I'm unable to compile it; maybe my toolchain is not correct.
Then I downloaded several different ones from http://rasher.dk/rockbox/simulator/ (http://rasher.dk/rockbox/simulator/).

They all start in my Win10 Pro 64-Bit (German language if that matters) - but I'm unable to use them; they all have the same problem: they don't react on any key press.

Anything I can do against it?

Or what do I need to cross compile working Windows versions in Ubuntu 16.04?
Title: Re: Rockbox simulators - currently working in windows?
Post by: johnb on January 03, 2017, 04:33:26 AM
I just downloaded the sim for clip+ and it works for me. I have the same OS as you.
Title: Re: Rockbox simulators - currently working in windows?
Post by: Massa on January 03, 2017, 06:52:35 AM
I just downloaded the sim for clip+ and it works for me. I have the same OS as you.
Also the same keyboard / language version?

Any ideas why it does not work here?
Are there any precompiled simulator versions available with logging (logf) enabled so that I can see what's happening?
Title: Re: Rockbox simulators - currently working in windows?
Post by: johnb on January 03, 2017, 07:48:39 AM
yes, win10Pro 64bit, German.

I have no clue regarding your other questions.
Title: Re: Rockbox simulators - currently working in windows?
Post by: Massa on January 03, 2017, 10:03:42 AM
yes, win10Pro 64bit, German.
Very strange.
What I noticed: when starting the rockboxui.exe I get the  "keyboard language settings" ("Spracheinstellungen" in German) in the taskbar - with additional "English (US)" keyboard - which I don't have installed (I only have the German keyboard installed)...

Maybe that's the problem?

Regarding compiling: what is needed in recent environments to compile the simulators for execution on Windows?
Either in Ubuntu 16.04 (I only have an installation without X) as cross compile or directly in Windows 10 (with mingw or other)?
I always have a problem with the SDL libraries or their config....

Here are the messages from Ubuntu when trying to configure:
configure didn't find sdl-config, which indicates that you
don't have SDL (properly) installed. Please correct and
re-run configure!
The sdl-config is there:

$ which sdl-config
/usr/bin/sdl-config
$ sdl-config --version
1.2.15

So, what's the problem?

BTW, I also tried to use the suggested (very old) Ubuntu virtualbox VM image - but I use VMWare on my laptop and was unable to install the VMWare tools in that VM, because the linux headers are missing and cannot be installed any more because the image is too old and the packages are no longer available...
Title: Re: Rockbox simulators - currently working in windows?
Post by: johnb on January 03, 2017, 10:22:36 AM
Wait a second, when you say ' no key press' is working, does that mean you actually use the keyboard?

I have been using the mouse to click buttons on the UI.

Now I tested the keyboard: cursor keys and space do the job for clip+.
Title: Re: Rockbox simulators - currently working in windows?
Post by: Massa on January 05, 2017, 05:05:34 AM
Yes, that's exactly what I try - use it with the keyboard...
...and that does not work here :-[
After a few key presses (which do not lead to any reaction or log output) the program unconditionally exits!

BTW, I'm now able to compile a regular build with cygwin64 - but still not the simulator :'(
The configuration seems to work, but when I then call "make" the following error message continuously shows up:
Code: [Select]
In file included from /cygdrive/d/Prog/Projekt/RockBox/rockbox.git/firmware/export/system.h:205:0,
                 from /cygdrive/d/Prog/Projekt/RockBox/rockbox.git/apps/rbcodecconfig.h:19,
                 from <command-line>:0:
/cygdrive/d/Prog/Projekt/RockBox/rockbox.git/firmware/include/rbendian.h:92:4: error: #error "Missing OS swap defines."
   #error "Missing OS swap defines."
    ^
Anybody any idea what this message means?
And it does not matter if I just enter "make" or "make clean" - the message always appears!
Title: Re: Rockbox simulators - currently working in windows?
Post by: __builtin on January 05, 2017, 05:40:23 PM
That's because the file rbendian.h doesn't have macros defined to byteswap values on your platform.

It should be relatively easy to fix.
Title: Re: Rockbox simulators - currently working in windows?
Post by: Massa on January 07, 2017, 09:48:22 AM
@__builtin: you're right - I fixed it by adding some lines to rbendian.h:
Code: [Select]
firmware/include/rbendian.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/firmware/include/rbendian.h b/firmware/include/rbendian.h
index 0c03ce6..dbb6d4e 100644
--- a/firmware/include/rbendian.h
+++ b/firmware/include/rbendian.h
@@ -79,10 +79,18 @@
   #define __swap16_os(x)    __bswap_16(x)
   #define __swap32_os(x)    __bswap_32(x)
   #define __swap64_os(x)    __bswap_64(x)
+#elif defined (bswap_16)
+  #define __swap16_os(x)    bswap_16(x)
+  #define __swap32_os(x)    bswap_32(x)
+  #define __swap64_os(x)    bswap_64(x)
 #elif defined (__swap16)
   #define __swap16_os(x)    __swap16(x)
   #define __swap32_os(x)    __swap32(x)
   #define __swap64_os(x)    __swap64(x)
+#elif defined (swap16)
+  #define __swap16_os(x)    swap16(x)
+  #define __swap32_os(x)    swap32(x)
+  #define __swap64_os(x)    swap64(x)
 #elif defined (__MINGW32__) || (CONFIG_PLATFORM & PLATFORM_MAEMO)
   /* kinda hacky but works */
   #define __swap16_os(x)    SWAP16_CONST(x)
Do you have commit access? If yes, could you please add this? IMHO it does  not harm to any other platform...

When I now try to compile the simulator the above errors are gone - but the next appears...
...which I try to analyze before I post them here  ;)
Title: Re: Rockbox simulators - currently working in windows?
Post by: __builtin on January 07, 2017, 10:36:47 AM
I do have commit access now (woot!), but I think it'd be best to defer pushing a patch until after the "next errors" are sorted out.

Could you post them so we can take a look at them too?

P.S. -- doesn't your "Developer" badge signify that you have commit access yourself?
Title: Re: Rockbox simulators - currently working in windows?
Post by: Massa on January 08, 2017, 07:47:12 AM
I do have commit access now (woot!), but I think it'd be best to defer pushing a patch until after the "next errors" are sorted out.
I'd prefer to keep (independend) commits as small as possible - but it's your decision ;)

Could you post them so we can take a look at them too?
Well, I'm a step further - but still not able to compile a simulator.

In principal with cygwin you have several possibilities to compile the simulator:
  1.) cygwin based (64- or 32-bit)
  2.) mingw based (64- or 32-bit)

With the cygwin based version you have a more linux based environment for your program and need the cygwin wrapper DLL around it to run it.
The mingw based comes in place when the configure option "Win32 crosscompile" will be choosed and provides a windows native environment for your program and does not need any wrapper DLL.

At the beginning I tried to "just" choose "simulator" without additional option -> cygwin environment, 64-Bit in my case; the leading architecture ist "amd64".

That leads to a lot strange header problems - not inside rockbox, but in cygwin environment.
I solved a few of them by switching off the ccache feature in rockbox ("--no-ccache" parameter) - but some are still present, and I don't have any idea why...
Code: [Select]
                 from /cygdrive/d/Prog/Projekt/RockBox/rockbox.git/apps/alarm_menu.c:26:
/usr/include/machine/_endian.h:23:1: error: unknown type name ‘_ELIDABLE_INLINE’
 _ELIDABLE_INLINE __uint32_t __ntohl(__uint32_t);
 ^
_ELIDABLE_INLINE is defined in "/usr/include/_ansi.h" which is included in "/usr/include/machine/_endian.h" - so I've no idea why it does not detect this...
...if I "fix" it by adding the following lines to "_endian.h":
Code: [Select]
#ifndef _ELIDABLE_INLINE
#define _ELIDABLE_INLINE static __inline__
#endif
that error vanishes - but the next similar comes in place:
Code: [Select]
                 from /usr/include/sys/stat.h:9,
                 from /usr/include/sys/_default_fcntl.h:188,
                 from /usr/include/sys/fcntl.h:3,
                 from /usr/include/fcntl.h:12,
                 from /cygdrive/d/Prog/Projekt/RockBox/rockbox.git/firmware/include/file.h:26,
                 from /cygdrive/d/Prog/Projekt/RockBox/rockbox.git/firmware/export/scroll_engine.h:30,
                 from /cygdrive/d/Prog/Projekt/RockBox/rockbox.git/apps/screen_access.h:27,
                 from /cygdrive/d/Prog/Projekt/RockBox/rockbox.git/apps/gui/viewport.h:29,
                 from /cygdrive/d/Prog/Projekt/RockBox/rockbox.git/apps/action.h:25,
                 from /cygdrive/d/Prog/Projekt/RockBox/rockbox.git/apps/alarm_menu.c:26:
/usr/include/sys/reent.h:197:43: error: expected ‘)’ before ‘(’ token
   _READ_WRITE_RETURN_TYPE _EXFNPTR(_read, (struct _reent *, _PTR,
_EXFNPTR is also defined in "_ansi.h" - so I still don't understand what's going on...

-------------------------------------------------------------------
So I decided to try to build the simulator with mingw...
Nowadays it's possible to use a 64-bit and a 32-bit version of mingw - in cygwin64 you can use both...
In the past only 32-bit versions where available - so that was used in rockbox.
In "tools/configure" you can find the line
Code: [Select]
   CROSS_COMPILE=${CROSS_COMPILE:-"i586-mingw32msvc-"}which does not work in newer environments - now the 32-bit prefix is called "i686-w64-mingw32-".
I changed this in the configure script and tried to compile a "Win32 crosscompiled" simulator.

It looks very promising - only a lot of string format and string output warnings - like that:
Code: [Select]
/cygdrive/d/Prog/Projekt/RockBox/rockbox.git/apps/tagtree.c: In function ‘tagtree_init’:
/cygdrive/d/Prog/Projekt/RockBox/rockbox.git/apps/tagtree.c:1178:16: warning: unknown conversion type character ‘z’ in format [-Wformat=]
         panicf("tagentry(%zu) and entry mismatch(%zu)",
                ^
/cygdrive/d/Prog/Projekt/RockBox/rockbox.git/apps/tagtree.c:1178:16: warning: unknown conversion type character ‘z’ in format [-Wformat=]
/cygdrive/d/Prog/Projekt/RockBox/rockbox.git/apps/tagtree.c:1178:16: warning: too many arguments for format [-Wformat-extra-args]
and also some conversion warnings like that
Code: [Select]
/cygdrive/d/Prog/Projekt/RockBox/rockbox.git/apps/misc.c: In function ‘fast_readline’:
/cygdrive/d/Prog/Projekt/RockBox/rockbox.git/apps/misc.c:218:31: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
             pos = buf_size - ((long)next - (long)buf) - 1;
but it compiles....
...until it comes to the linkage
Code: [Select]
LD rockboxui.exe
/usr/x86_64-w64-mingw32/sys-root/mingw/lib/libmingw32.a: error adding symbols: File format not recognized
collect2: error: ld returned 1 exit status
make: *** [/cygdrive/d/Prog/Projekt/RockBox/rockbox.git/uisimulator/uisimulator.make:34: /cygdrive/d/Prog/Projekt/RockBox/rockbox.git/build.ipodvideo.sim/rockboxui.exe] Error 1
It seems it does use the wrong directory - that's the 64-bit dir...
So for this build I have to find out why it uses the wrong directory....

-------------------------------------------------------------------
I also tried the 64-bit ming build - with that I also have some linkage problems - but with SDL and directx; maybe the SDL libraries are not correctly installed or a Win32 (DirectX?) DLL linkage is missing...
Code: [Select]
LD rockboxui.exe
/usr/x86_64-w64-mingw32/sys-root/mingw/lib/libSDL.a(SDL_dx5video.o):(.text+0xf5f): undefined reference to `IID_IDirectDrawSurface3'
I'll also have to find out what the problem for this is...

-------------------------------------------------------------------
P.S. -- doesn't your "Developer" badge signify that you have commit access yourself?
To be honest: I don't know ;D
I got this badge years ago (if I remember correctly it was 2009) - and if I remember correctly, at that time there were two kinds of "developers": a small group with commit access and a bigger group without.
I belonged to the second group - I did some work on the WPS token based rework and on image resizing (and corresponding WPS tags).
Maybe I did some small commits at the end but I do not remember - even if I would have commit access, I've no idea how to setup it up for git (which username, where to set it up, ...)
I was inactive for several years and now try to "reintegrate" - but I think it's harder to setup the build environments nowadays...
(because everything uses outdated stuff and does not work in newer OS versions...)
Title: Re: Rockbox simulators - currently working in windows?
Post by: Massa on January 08, 2017, 07:57:01 AM
Addition: I've found out that the cygwin based build fails because there is a "libc/include/_ansi.h" in the rockbox source tree which will be used and that one misses the mentioned defines.
But why do the includes coming from "/usr/include" use the rockbox "_ansi.h"?
They use '#include <_ansi.h>' and not '#include "_ansi.h"'' ?
Title: Re: Rockbox simulators - currently working in windows?
Post by: Massa on January 10, 2017, 04:15:13 PM
Update: in principal I now know why it does not compile as 32- or 64-bit mingw cross compile (but not why not as cygwin native).

The include and library directories and also the compiler options are wrong - the reason are several problems in configure with sdl-config.
For cross-compile it does a wrong detection (searching the PATH for a version which supports windows instead of using the corresponding of the mingw sys-root directory) and later it just usess the first found in the path (regardless if it's the one which supports windows or not).

So I tried to solve it by using the correct ones at all places.

I now have a configure version which actually does the right thing. I echoed the whole resulting commands and it works when I enter them by hand in command line.
BUT: it does not work, when I let the configure script execute them - I've no idea why...  :'(

Is there any dev with knowledge in that region with whom I can discuss this?
Title: Re: Rockbox simulators - currently working in windows?
Post by: Massa on January 16, 2017, 03:22:07 PM
Final update:
I changed the configure script to work on current cygwin installations and also integrated the possibility to create 64-bit based Windows simulators.

There were also some code changes needed so that the code correctly runs on 64-bit simulators - now everything seems to be O.K.
Thanks to pamaury the problems are solved and most of the things are from now on available in the daily builds.

A remaining issue is that a lot of warnings about illegal casts and others occur when compiling the 64-bit version.
This issue will be solved by a patch which already exists at gerrit (http://gerrit.rockbox.org/r/#/c/1499/ (http://gerrit.rockbox.org/r/#/c/1499/)), but it needs some further compatibility checks...

If somebody wants to test binary versions (inluding 64-bit versions) of the simulator - send me a PM.

BTW, the self compiled versions allow me to control the simulator with the keyboard (and the mouse) ;)