Author Topic: Developing for Gemei A330 on Mac OS X  (Read 16847 times)

Jonesie (OP)

  • Posts: 32
Developing for Gemei A330 on Mac OS X
« on: October 20, 2013, 10:52:38 pm »
Hi fellas,

after a long, helpful discussion with Harteex and some advice from Cex, I've been able to setup a toolchain for developing for Gemei A330 on Mac OS X. Everything seems to work, but the binaries that come out of it simply don't run on the console (frozen interface, power off as only fix).

Here's a brief summary of what we've done so far:

- Grabbed GCC + Binutils + Newlib from devkitpro.org's devkitARM. That's what I've been using since the days of the GP32/GBA (arm-none-eabi-*) and it has served me well.
- A package of libs & includes Harteex sent me. They include SDL, which I particularly fancy and need for a project of mine I intend to enjoy on the Gemei.
- Compiled Wine to stand a chance of executing dlmake.exe with wineconsole. It works. I call it with 'wineconsole --backend=curses dlmake.exe dlmake.ini'.

* Harteex kindly sent me his object and ELF files for SDLPong, which I packaged with dlmake, and found that the result runs flawlessly on the Gemei. So dlmake is actually fine.
* His ELF file and the one I generate with my toolchain only differ on the entry point address, being every other field in the header identical, *but* the object files I generate do have different sizes than his. So the problem might be related to GCC, but I fail to see what could be wrong with it, since all config/optimisation switches are being set by the Makefile.

I'm familiar with Makefiles, C/C++ and very basic GCC, but I currently ignore many things about binary formats, the linking process and the way things execute on a machine with or without OS. I understand that the OS may provide certain headers for hardware abstraction, but I have never used any of those. However, I'm really motivated and want to learn as much as possible about those things.

Thanks for reading,

Jonesie

Harteex

  • * Administrator
  • Posts: 713
    • Harteex Productions
Re: Developing for Gemei A330 on Mac OS X
« Reply #1 on: October 21, 2013, 10:34:51 pm »
You should take a look at your paths so that you only use headers from the SDK, not from the toolchain or your x86 headers. Also, make sure you only link to the libs in lib/cc1800.

I have access to OSX now, so I might be able to look into the problem.. however, I'm going to be busy this week, so it'll be later.

Jonesie (OP)

  • Posts: 32
Re: Developing for Gemei A330 on Mac OS X
« Reply #2 on: October 22, 2013, 08:01:54 am »
I triple checked paths & libs, rebuilt everything and I'm still stuck on the same problem. What version of GCC are you using? I've read that the latest versions of GCC produce bigger code for ARM (mine is 4.7.1), and that would explain the difference in size, but not everything else.

Jonesie (OP)

  • Posts: 32
Re: Developing for Gemei A330 on Mac OS X
« Reply #3 on: October 22, 2013, 08:50:58 am »
Oh, and I forgot to paste the configuration options from my crosscompiler:

Using built-in specs.
COLLECT_GCC=arm-none-eabi-gcc
Target: arm-none-eabi
Configured with: ../../gcc-4.7.1/configure --enable-languages=c,c++,objc,obj-c++ --with-gnu-as --with-gnu-ld --with-gcc --with-march=armv4t --enable-poison-system-directories --enable-interwork --enable-multilib --disable-dependency-tracking --disable-threads --disable-win32-registry --disable-nls --disable-debug --disable-libmudflap --disable-libssp --disable-libgomp --disable-libstdcxx-pch --target=arm-none-eabi --with-newlib --with-headers=../../newlib-1.20.0/newlib/libc/include --prefix=/opt/devkitpro/devkitARM --enable-lto --with-bugurl=http://wiki.devkitpro.org/index.php/Bug_Reports --with-pkgversion='devkitARM release 41'
Thread model: single
gcc version 4.7.1 (devkitARM release 41)

Harteex

  • * Administrator
  • Posts: 713
    • Harteex Productions
Re: Developing for Gemei A330 on Mac OS X
« Reply #4 on: October 22, 2013, 02:28:07 pm »
I triple checked paths & libs, rebuilt everything and I'm still stuck on the same problem. What version of GCC are you using? I've read that the latest versions of GCC produce bigger code for ARM (mine is 4.7.1), and that would explain the difference in size, but not everything else.

Mostly checked the libs thing since you mentioned newlib, which you cannot use.

When I worked on this before I tested a few different toolchains, and I also noticed that the binaries produced in later version are larger. The one I use is a bit older, "arm-2007q3" (gcc versoin 4.2.1), but I'm pretty sure things worked fine with the later ones too.

Here's more details on my compiler:
Code: [Select]
Using built-in specs.
Target: arm-none-eabi
Configured with: /scratch/paul/lite-eabi/src/gcc-4.2/configure --build=i686-pc-linux-gnu --host=i686-mingw32 --target=arm-none-eabi --enable-threads --disable-libmudflap --disable-libssp --disable-libgomp --disable-libstdcxx-pch --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --disable-shared --with-newlib --with-pkgversion=CodeSourcery Sourcery G++ Lite 2007q3-53 --with-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-headers=yes --with-sysroot=/opt/codesourcery/arm-none-eabi --with-build-sysroot=/scratch/paul/lite-eabi/install/host-i686-mingw32/arm-none-eabi --with-libiconv-prefix=/scratch/paul/lite-eabi/obj/host-libs-2007q3-53-arm-none-eabi-i686-mingw32/usr --enable-poison-system-directories --with-build-time-tools=/scratch/paul/lite-eabi/obj/tools-i686-pc-linux-gnu-2007q3-53-arm-none-eabi-i686-mingw32/arm-none-eabi/bin --with-build-time-tools=/scratch/paul/lite-eabi/obj/tools-i686-pc-linux-gnu-2007q3-53-arm-none-eabi-i686-mingw32/arm-none-eabi/bin
Thread model: single
gcc version 4.2.1 (CodeSourcery Sourcery G++ Lite 2007q3-53)

Jonesie (OP)

  • Posts: 32
Re: Developing for Gemei A330 on Mac OS X
« Reply #5 on: October 22, 2013, 05:38:03 pm »
Yay, I'll check the actual libc I'm linking against when I arrive home. I think we're cornering the issue  ;D

Jonesie (OP)

  • Posts: 32
Re: Developing for Gemei A330 on Mac OS X
« Reply #6 on: October 22, 2013, 08:49:49 pm »
Tried renaming the default libs directory and/or using -nodefaultlibs and/or -nostdinc options, with no luck  :'(

I don't think it's a lib problem. Remember how I linked your object files with my libs & packed the result with dlmake, and it worked flawlessly? this has something to do with the compiler, which might be producing some unsuitable code for the Gemei's CPU. Next thing to try: new toolchain  ???

Offtopic: do you know of any trick to reflash the same firmware version? My intro animation is gone after flashing 1.1 (weird, but possibly update-related), and the ChinaChip updater refuses to chew the same version again.
« Last Edit: October 22, 2013, 09:22:58 pm by Jonesie »

Jonesie (OP)

  • Posts: 32
Re: Developing for Gemei A330 on Mac OS X
« Reply #7 on: October 23, 2013, 02:57:41 pm »
Same result using arm-none-eabi from launchpad running on GNU/Linux. Now this is strange...

Harteex

  • * Administrator
  • Posts: 713
    • Harteex Productions
Re: Developing for Gemei A330 on Mac OS X
« Reply #8 on: October 23, 2013, 09:27:21 pm »
I'm out of ideas unfortunally. I tried to compile it myself on OS X with the arm-none-eabi compiler on macports, but it didn't work.

Maybe try an older toolchain or something.

I guess you could run my compiler with wine, but that might be a bit odd.

EDIT:
If anyone else might know / suspect what's wrong, here's both working and non-working binaries: http://www.harteex.com/temp/SDLPong.zip

EDIT2: The other comparison in a later post is probably more interesting...
« Last Edit: October 26, 2013, 12:17:59 am by Harteex »

Jonesie (OP)

  • Posts: 32
Re: Developing for Gemei A330 on Mac OS X
« Reply #9 on: October 24, 2013, 10:25:15 am »
I tried to run a binary compiled with no optimisations (-O0, default value) and the object files decreased in size (because of no loop unrolling, for instance...) but the result is the same.

I'll pinpoint all available options for ARM in order to produce the most basic code and see if it runs. I guess it would be easier to know what the hell is inside the CC1800, but that's not gonna happen' :(

Harteex

  • * Administrator
  • Posts: 713
    • Harteex Productions
Re: Developing for Gemei A330 on Mac OS X
« Reply #10 on: October 24, 2013, 03:16:48 pm »
I tried doing the objcopy step on OS X and that seems to work.
Next up, the linker. Although that'll have to wait a few days...

Did you try an older toolchain, like the one I'm using?

Jonesie (OP)

  • Posts: 32
Re: Developing for Gemei A330 on Mac OS X
« Reply #11 on: October 25, 2013, 10:39:26 am »
I have tried many toolchains, the oldest dating from 2011, with the same outcome. I have also tried this very morning using those switches for ARM that may make to binary more portable, with no success either.

Since binaries for older toolchains have started to disappear from FTP sites, I guess it's even more crucial that we get to the bottom of this issue and correct whatever needs to be corrected. I'm willing to build our own toolchain if that gave us enough control over this. The learning opportunities are huge.

Harteex

  • * Administrator
  • Posts: 713
    • Harteex Productions
Re: Developing for Gemei A330 on Mac OS X
« Reply #12 on: October 25, 2013, 03:33:29 pm »
I have tried many toolchains, the oldest dating from 2011, with the same outcome. I have also tried this very morning using those switches for ARM that may make to binary more portable, with no success either.

Since binaries for older toolchains have started to disappear from FTP sites, I guess it's even more crucial that we get to the bottom of this issue and correct whatever needs to be corrected. I'm willing to build our own toolchain if that gave us enough control over this. The learning opportunities are huge.

Another piece in the puzzle: The compiler works fine, the problem is in the linker.
I compiled it on OS X, and moved the object files over to link on my toolchain, and things worked fine.

I've put the two elf files which were using the same object files, and some readelf and objdump output here: http://www.harteex.com/temp/cc1800-linker-problems/
Haven't looked that much at it, but I don't know what to conclude really.

Jonesie (OP)

  • Posts: 32
Re: Developing for Gemei A330 on Mac OS X
« Reply #13 on: October 25, 2013, 07:51:18 pm »
Maybe the startup files have substantially changed since the release of your old toolchain? if the .o files are correct and the objcopy step gets done without incident, the only thing that's left is the startup files for the C/C++ runtime (crt0.o, crtbegin.o ... ). I have tried linking with -nostartfiles and a crt0.S extracted from another ARM toolchain with no improvement whatsoever, but maybe it's worth checking the outcome with the ones from your toolchain!
« Last Edit: October 26, 2013, 09:21:12 am by Jonesie »

Harteex

  • * Administrator
  • Posts: 713
    • Harteex Productions
Re: Developing for Gemei A330 on Mac OS X
« Reply #14 on: October 28, 2013, 02:41:01 pm »
Here's my toolchain if you want to try things: http://www.harteex.com/temp/arm-2007q3.zip

However I spoke to flatmush who suggested it might be the newer linker doing something that dlmake doesn't understand. He gave me few hints of what could be wrong, so I'll compare the files and also see if I can get it to run with flatmush' elf2app program.

Jonesie (OP)

  • Posts: 32
Re: Developing for Gemei A330 on Mac OS X
« Reply #15 on: October 28, 2013, 02:57:49 pm »
That's excelent - thank you :)

Jonesie (OP)

  • Posts: 32
Re: Developing for Gemei A330 on Mac OS X
« Reply #16 on: October 29, 2013, 01:35:57 pm »
I've made a quick test with elf2app.py, substituting those references to the mips compiler for arm-none-eabi ones. I've ended up with a 2KB .app file and no error messages. Something is wrong 8)

I'll dive into the code to try and see what's causing this behaviour.

 

Harteex

  • * Administrator
  • Posts: 713
    • Harteex Productions
Re: Developing for Gemei A330 on Mac OS X
« Reply #17 on: October 31, 2013, 04:17:03 am »
I've made a quick test with elf2app.py, substituting those references to the mips compiler for arm-none-eabi ones. I've ended up with a 2KB .app file and no error messages. Something is wrong 8)

I'll dive into the code to try and see what's causing this behaviour.

Not sure how the py version is implemented, but there is a c version of elf2app in the dingoo-sdk.
It's not possible to just change to the arm toolchain, as other things are different, like some parts of the header.
If you're interested in the format, here's a document: http://code.google.com/p/dingoo-sdk/source/browse/trunk/dingoo_sdk/doc/CCDL_APP_Format.txt

I currently have quite many things on my todo list, so I'll have to see when I have time to look more into this (maybe during the weekend).
For now, if you don't want to wait, I'd recommend you to try the same version (or at least around the same) of the toolchain that I use, as that should work.

Jonesie (OP)

  • Posts: 32
Re: Developing for Gemei A330 on Mac OS X
« Reply #18 on: October 31, 2013, 07:59:07 am »
Not sure how the py version is implemented, but there is a c version of elf2app in the dingoo-sdk.
It's not possible to just change to the arm toolchain, as other things are different, like some parts of the header.
If you're interested in the format, here's a document: http://code.google.com/p/dingoo-sdk/source/browse/trunk/dingoo_sdk/doc/CCDL_APP_Format.txt

Much obliged! I'll look into that.

I currently have quite many things on my todo list, so I'll have to see when I have time to look more into this (maybe during the weekend).
For now, if you don't want to wait, I'd recommend you to try the same version (or at least around the same) of the toolchain that I use, as that should work.

Don't worry about the timing. We're moving home this very weekend, so I'll have my hands full for a couple of days too. Also, I'm keen on learning everything I can about toolchains, linkers, binary formats, etc. The Gemei A330 is probably one of the last non-Android consoles to ever grace the market and I would like to make the most of it, for I don't really dig Android as a hobbyist gaming/development platform/paradigm.

chevette

  • Posts: 248
Re: Developing for Gemei A330 on Mac OS X
« Reply #19 on: November 01, 2013, 12:19:24 am »
Jonesie: I really like your enthusiasm.....the A330 is a really good piece of hardware and never got the love it deserves. Hopefully you'll figure it all out.....thanks for your efforts.

 

Post a new topic
Post a new topic