Ubuntu CHDK build issue, GCC 6.3.1 - General Discussion and Assistance - CHDK Forum supplierdeeply

Ubuntu CHDK build issue, GCC 6.3.1

  • 7 Replies
  • 646 Views
Ubuntu CHDK build issue, GCC 6.3.1
« on: 12 / January / 2019, 09:17:34 »
Advertisements

On ubuntu, using arm-none-eabi-gcc 6.3.1, make of CHDK is giving errors like:


Error: selected processor does not support `blx R1' in ARM mode


This is with a fresh svn up of chdk. Has anybody found a fix?


*

Offline reyalp

  • ******
  • 12151
Re: Ubuntu CHDK build issue, GCC 6.3.1
« Reply #1 on: 12 / January / 2019, 16:12:26 »
Don't think so, philmoz mentioned problems in this thread https://chdk.setepontos.com/index.php?topic=13184.0

CHDK does fairly weird things to build, so we tend to be slow to switch gcc versions.

The specific error seems like an error setting compiler options, because AFAIK any CHDK supported processor should support BLX <reg>

Looking at the toplevel makefile.inc, there are specific cases for GCC 3 and 4 but not anything else. Adding a case for GCC 6 will let you set the target arch but this is likely only the start of your problems.

Patches are welcome :)
Don't forget what the H stands for.

*

Offline philmoz

  • *****
  • 3128
    • Photos
Re: Ubuntu CHDK build issue, GCC 6.3.1
« Reply #2 on: 12 / January / 2019, 17:05:33 »
GCC 5.4.1 is the latest version tested and supported for CHDK.

You can fix the GCC 6 build errors by updating the arm_rules.inc file to add support for this major GCC version (lines 36-46 & 128-136).

Although CHDK will build with GCC 6 the result does not work - running on the G12 it crashes immediately on power up.

Edit: The build crashes because GCC 6 is generating 'mov pc,lr' instructions for the camera platform code instead of 'bx lr'. This breaks the ARM/Thumb interworking crashing the camera. It appears to be ignoring the -mthumb-interwork option in CFLAGS.


Phil.

« Last Edit: 14 / January / 2019, 04:50:25 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)

*

Offline nafraf

  • *****
  • 1306
Re: Ubuntu CHDK build issue, GCC 6.3.1
« Reply #3 on: 13 / January / 2019, 19:59:39 »
This code was used on a580:
Code: [Select]
//"BLX     R12\n"   // !! Workaround !!
"MOV     LR, PC\n"     // gcc won't compile "BLX R12" nor "BL R12".
"MOV     PC, R12\n"  // workaround: make your own "BL" and hope we don't need the change to thumb-mode


*

Offline reyalp

  • ******
  • 12151
Re: Ubuntu CHDK build issue, GCC 6.3.1
« Reply #4 on: 13 / January / 2019, 20:11:33 »
This code was used on a580:
Code: [Select]
//"BLX     R12\n"   // !! Workaround !!
"MOV     LR, PC\n"     // gcc won't compile "BLX R12" nor "BL R12".
"MOV     PC, R12\n"  // workaround: make your own "BL" and hope we don't need the change to thumb-mode
That's a *really* old comment, possibly from someone using an incorrectly configured toolchain at the time.

The reason @ProfHankD ran into that kind of error is because the compiler flags are only set for gcc 3 and 4. Changing the assembly code should not be the solution for this.
Don't forget what the H stands for.

*

Offline SX720

  • *
  • 13
Re: Ubuntu CHDK build issue, GCC 6.3.1
« Reply #5 on: 13 / September / 2019, 00:17:34 »
I just tried building CHDK for my A2200 with arm-none-eabi-gcc version 9.2.0 and binutils version 2.32 and it did not work. I just got a black screen. Thankfully it did not brick my camera. This might be the same issue relating to the blx instruction but I am not yet sure on this. Since GCC 5 is getting more and more obsolete is it time to discuss a fix for this?

Here are the changes I needed to get it to build:
Code: [Select]
Index: arm_rules.inc
===================================================================
--- arm_rules.inc (revision 5269)
+++ arm_rules.inc (working copy)
@@ -44,6 +44,10 @@
         # TODO should be -mcpu, but breaks things ATM
         CFLAGS+=-mtune=arm946e-s $(ARCH)
     endif
+    ifeq ($(GCC_VERSION_MAJOR),9)
+        # TODO assuming the same limitations as above. Does this still apply with GCC 9?
+        CFLAGS+=-mtune=arm946e-s $(ARCH)
+    endif
 else
     ifdef DIGIC7
         CFLAGS+=-march=armv7-a -mthumb -DTHUMB_FW
Index: loader/makefile_loader.inc
===================================================================
--- loader/makefile_loader.inc (revision 5269)
+++ loader/makefile_loader.inc (working copy)
@@ -3,7 +3,7 @@
 
 include $(topdir)makefile_cam.inc
 
-LDOPTS=-nostdlib -Wl,--allow-shlib-undefined -Wl,--no-define-common,-EL,-T,$(tools)/link-boot.ld -Wl,-N,-Ttext,$(MEMBASEADDR)
+LDOPTS=-nostdlib -Wl,--allow-shlib-undefined -shared -Wl,--no-define-common,-EL,-T,$(tools)/link-boot.ld -Wl,-N,-Ttext,$(MEMBASEADDR)
 
 CORE_FILE=$(camfw)/main.bin
The -shared option is needed to prevent an error which says:
Quote
--no-define-common may not be used without -shared

I also enabled OPT_USE_GCC_EABI.

Is there a way to debug the generated binary? The only thing I can think of is blinking the LED after going past certain "checkpoints".
« Last Edit: 13 / September / 2019, 00:23:09 by SX720 »

*

Offline reyalp

  • ******
  • 12151
Re: Ubuntu CHDK build issue, GCC 6.3.1
« Reply #6 on: 13 / September / 2019, 01:44:22 »
I just tried building CHDK for my A2200 with arm-none-eabi-gcc version 9.2.0 and binutils version 2.32 and it did not work. I just got a black screen. Thankfully it did not brick my camera. This might be the same issue relating to the blx instruction but I am not yet sure on this. Since GCC 5 is getting more and more obsolete is it time to discuss a fix for this?
If you can figure out how to make newer compilers work, that's certainly welcome.

However, as long as working toolchains are readily available, it's not something I'd personally put a lot of effort into. Because of the way it interfaces with Canon firmware (+ general hackyness) CHDK is really sensitive to compiler behavior.

Quote
Is there a way to debug the generated binary? The only thing I can think of is blinking the LED after going past certain "checkpoints".
I'd suggest comparing the disassembly (main.bin.dump in your platform / sub directory) for issues of the sort philmoz described first. LED debugging is the next logical step. For early parts, it's usually simpler to just put an infinite loop at the point your are testing for. If the OS gets to the point of creating tasks, that can fail because the other tasks crash. There are some LED debugging examples at https://chdk.fandom.com/wiki/Debugging
Don't forget what the H stands for.

*

Offline SX720

  • *
  • 13
Re: Ubuntu CHDK build issue, GCC 6.3.1
« Reply #7 on: 15 / September / 2019, 03:19:26 »
Yes, I see what you mean. Getting a tool-chain setup with these older versions was simpler than I initially thought.

I ended up getting it to work using GCC 4.9.4, Binutils 2.25.1 and Newlib 2.4.0.


 

Related Topics