Building CHDK with newer GCC (4.8) - General Discussion and Assistance - CHDK Forum

Building CHDK with newer GCC (4.8)

  • 17 Replies
  • 12539 Views
*

Offline philmoz

  • *****
  • 3450
    • Photos
Building CHDK with newer GCC (4.8)
« on: 05 / December / 2014, 21:58:04 »
Advertisements
GCC 4.7 was the last version to support the ELF ABI (application binary interface).

To build CHDK with GCC 4.8 (or later) we need to switch to the newer EABI standard.

This will be required for Digic6 support, so I thought I'd look at adding it to the current build.

The attached patch should allow building CHDK using ARM GCC 4.8 - I've only tested this on OS/X and Windows 8.1 so far.
The patch requires trunk version 3772.

To try it out:
- install ARM GCC 4.8 (https://launchpad.net/gcc-arm-embedded/+download)
- add USE_GCC_EABI=1 to your localbuildconf.inc file
- clean and rebuild CHDK

I had to add '-march=armv5te' to the build for the camera directory - not sure this is ideal, so any suggestions on doing this better would be appreciated.

Phil.
« Last Edit: 06 / December / 2014, 00:03:18 by philmoz »
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline srsa_4c

  • ******
  • 4451
Re: Building CHDK with newer GCC (4.8)
« Reply #1 on: 06 / December / 2014, 16:59:08 »
The attached patch should allow building CHDK using ARM GCC 4.8 - I've only tested this on OS/X and Windows 8.1 so far.
Linux 32bit is OK too.

The resulting diskboot is smaller than the one built with arm-elf 4.6.4, but some modules are bigger (lua.flt is significantly bigger, +3.3kB) with the current options.

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Building CHDK with newer GCC (4.8)
« Reply #2 on: 06 / December / 2014, 18:40:36 »
The attached patch should allow building CHDK using ARM GCC 4.8 - I've only tested this on OS/X and Windows 8.1 so far.
Linux 32bit is OK too.

The resulting diskboot is smaller than the one built with arm-elf 4.6.4, but some modules are bigger (lua.flt is significantly bigger, +3.3kB) with the current options.

Version 2 - should fix the module size issue (modules should now be smaller).

The whole ARM architecture settings in GCC are giving me a headache.
If I set -march=armv5te globally on the entire build then it does not generate correct wrapper code for calling the firmware functions. But without this the -mlong-calls options on the modules and libraries causes the code size blowout.

For now I've set -march=armv5te in selected makefiles. If you can shed any light on this I'd appreciate it :(

Edit: After a bit more investigation it seems everything can be compiled as armv5te except the code in platform/camera. I need to compile this as armv4 in order to get safe wrappers for the calls to the firmware functions.

Phil.
« Last Edit: 06 / December / 2014, 19:23:19 by philmoz »
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline srsa_4c

  • ******
  • 4451
Re: Building CHDK with newer GCC (4.8)
« Reply #3 on: 06 / December / 2014, 20:44:48 »
Version 2 - should fix the module size issue (modules should now be smaller).
They are smaller indeed.
Quote
If I set -march=armv5te globally on the entire build then it does not generate correct wrapper code for calling the firmware functions.
Can you illustrate this with some examples?
Quote
Edit: After a bit more investigation it seems everything can be compiled as armv5te except the code in platform/camera. I need to compile this as armv4 in order to get safe wrappers for the calls to the firmware functions.
If you mean replacing
Code: [Select]
CFLAGS+=-DLOW_LEVEL $(ARCH)with
Code: [Select]
CFLAGS+=-DLOW_LEVEL -march=armv4tat the top of platform/makefile_sub.inc, that doesn't work for ports which have any BLX instructions in their copied ARM asm code.

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Building CHDK with newer GCC (4.8)
« Reply #4 on: 06 / December / 2014, 21:02:36 »
Version 2 - should fix the module size issue (modules should now be smaller).
They are smaller indeed.
Quote
If I set -march=armv5te globally on the entire build then it does not generate correct wrapper code for calling the firmware functions.
Can you illustrate this with some examples?

Good wrapper (armv4):
Code: [Select]
003e176c <stat_get_vbatt>:
  3e176c: e92d4008 push {r3, lr}
  3e1770: ebffb811 bl 3cf7bc <_VbattGet>
  3e1774: e8bd4008 pop {r3, lr}
  3e1778: e12fff1e bx lr

Bad wrapper (armv5te):
Code: [Select]
003e1680 <stat_get_vbatt>:
  3e1680: eaffb83d b 3cf77c <_VbattGet>

Quote
Quote
Edit: After a bit more investigation it seems everything can be compiled as armv5te except the code in platform/camera. I need to compile this as armv4 in order to get safe wrappers for the calls to the firmware functions.
If you mean replacing
Code: [Select]
CFLAGS+=-DLOW_LEVEL $(ARCH)with
Code: [Select]
CFLAGS+=-DLOW_LEVEL -march=armv4tat the top of platform/makefile_sub.inc, that doesn't work for ports which have any BLX instructions in their copied ARM asm code.

The armv4 architecture is only required in the platform/camera/Makefile. The platform/*/sub/*/Makefile works with armv5te (and is required in some case as you noted).

New patch coming that should do all more cleanly.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Building CHDK with newer GCC (4.8)
« Reply #5 on: 06 / December / 2014, 21:12:37 »
V3 patch.

Sets armv5te architecture for all files, except the code in platform/camera.

Also adds an architecture type check to the module headers to prevent trying to load incorrect version.
This may also be useful for Digic6 cameras.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

*

Offline srsa_4c

  • ******
  • 4451
Re: Building CHDK with newer GCC (4.8)
« Reply #6 on: 06 / December / 2014, 21:53:40 »
V3 patch.

Sets armv5te architecture for all files, except the code in platform/camera.

Also adds an architecture type check to the module headers to prevent trying to load incorrect version.
This may also be useful for Digic6 cameras.
Working, thanks. Perhaps someone should check compilation with the autobuild's toolchain before the check-in (I don't see clearly whether arm-elf is affected by the changes).
Not strictly related, but can you add GEN_MODULE_DUMPS (perhaps as OPT_) to buildconf.inc when checking this in? I remember where to find it, but others may not find it easily.

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Building CHDK with newer GCC (4.8)
« Reply #7 on: 06 / December / 2014, 22:00:54 »
V3 patch.

Sets armv5te architecture for all files, except the code in platform/camera.

Also adds an architecture type check to the module headers to prevent trying to load incorrect version.
This may also be useful for Digic6 cameras.
Working, thanks. Perhaps someone should check compilation with the autobuild's toolchain before the check-in (I don't see clearly whether arm-elf is affected by the changes).
Not strictly related, but can you add GEN_MODULE_DUMPS (perhaps as OPT_) to buildconf.inc when checking this in? I remember where to find it, but others may not find it easily.

I've tested a full rebuild using the autobuild toolchain and there are no errors; just have to confirm that the version built still runs on my cameras.

Thanks for reminding me about GEN_MODULE_DUMPS - meant to add it; but forgot.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

Re: Building CHDK with newer GCC (4.8)
« Reply #8 on: 06 / December / 2014, 22:03:52 »
Does it make sense to standardize 1.4.0 on this change and leave the previous versions in the old tool chain?
Ported :   A1200    SD940   G10    Powershot N    G16

*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Building CHDK with newer GCC (4.8)
« Reply #9 on: 06 / December / 2014, 22:09:54 »
Does it make sense to standardize 1.4.0 on this change and leave the previous versions in the old tool chain?

The patch should still work with all the old toolchains (including the autobuild which I think is still 4.4.3).

If I put this in 1.3, then hacki can upgrade toolchains at his leisure; but still only have to use one version.

Phil.
CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

 

Related Topics


SimplePortal © 2008-2014, SimplePortal