Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error occurs while trying to compile production target keyboard firmware #23207

Closed
2 tasks
MaxJ345 opened this issue Mar 4, 2024 · 9 comments
Closed
2 tasks

Comments

@MaxJ345
Copy link

MaxJ345 commented Mar 4, 2024

Describe the Bug

I'm trying to build production target keyboard firmware using the QMK CLI. When I do so, I receive an error during the compilation process:

$ qmk compile --keyboard project_vanguard/full_size/v1 --keymap default --target production

...

c:/qmk_msys/mingw64/bin/../lib/gcc/avr/12.2.0/../../../../avr/bin/ld.exe: section .apitable_trampolines LMA [00007fa0,00007fb7] overlaps section .data LMA [00007f2a,00007fa1]
collect2.exe: error: ld returned 1 exit status
make[1]: *** [../../LUFA/Build/DMBS/DMBS/gcc.mk:251: BootloaderDFU.elf] Error 1
make: *** [platforms/avr/platform.mk:214: bootloader] Error 2

This isn't just a problem with my keyboard. I've also noticed it with other keyboards as well. For example, the following two will produce a similar error:

$ qmk compile --keyboard evyd13/gh80_1800 --keymap default --target production

...

c:/qmk_msys/mingw64/bin/../lib/gcc/avr/12.2.0/../../../../avr/bin/ld.exe: section .apitable_trampolines LMA [00007fa0,00007fb7] overlaps section .data LMA [00007f36,00007fa9]
collect2.exe: error: ld returned 1 exit status
make[1]: *** [../../LUFA/Build/DMBS/DMBS/gcc.mk:251: BootloaderDFU.elf] Error 1
make: *** [platforms/avr/platform.mk:214: bootloader] Error 2
$ qmk compile --keyboard evyd13/wasdat_code --keymap default --target production

...

c:/qmk_msys/mingw64/bin/../lib/gcc/avr/12.2.0/../../../../avr/bin/ld.exe: section .apitable_trampolines LMA [00007fa0,00007fb7] overlaps section .data LMA [00007f2a,00007fa1]
collect2.exe: error: ld returned 1 exit status
make[1]: *** [../../LUFA/Build/DMBS/DMBS/gcc.mk:251: BootloaderDFU.elf] Error 1
make: *** [platforms/avr/platform.mk:214: bootloader] Error 2

Here is the entire log from an example build:

$ qmk clean --all
QMK Firmware 0.24.1
Deleting .build/ ... done.
Deleting *.bin, *.hex, and *.uf2 ... done.

$ qmk compile --keyboard project_vanguard/full_size/v1 --keymap default --target production
Ψ Compiling keymap with make -r -R -f builddefs/build_keyboard.mk -s production KEYBOARD=project_vanguard/full_size/v1 KEYMAP=default KEYBOARD_FILESAFE=project_vanguard_full_size_v1 TARGET=project_vanguard_full_size_v1_default INTERMEDIATE_OUTPUT=.build/obj_project_vanguard_full_size_v1_default VERBOSE=false COLOR=true SILENT=false QMK_BIN="qmk"


Generating: .build/obj_project_vanguard_full_size_v1_default/src/info_deps.d                        [OK]
avr-gcc.exe (GCC) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Generating: .build/obj_project_vanguard_full_size_v1_default/src/info_config.h                      [OK]
Generating: .build/obj_project_vanguard_full_size_v1_default/src/default_keyboard.c                 [OK]
Generating: .build/obj_project_vanguard_full_size_v1_default/src/default_keyboard.h                 [OK]
Compiling: keyboards/project_vanguard/full_size/v1/v1.c                                             [OK]
Compiling: .build/obj_project_vanguard_full_size_v1_default/src/default_keyboard.c                  [OK]
Compiling: quantum/keymap_introspection.c                                                           [OK]
Compiling: quantum/quantum.c                                                                        [OK]
Compiling: quantum/bitwise.c                                                                        [OK]
Compiling: quantum/led.c                                                                            [OK]
Compiling: quantum/action.c                                                                         [OK]
Compiling: quantum/action_layer.c                                                                   [OK]
Compiling: quantum/action_tapping.c                                                                 [OK]
Compiling: quantum/action_util.c                                                                    [OK]
Compiling: quantum/eeconfig.c                                                                       [OK]
Compiling: quantum/keyboard.c                                                                       [OK]
Compiling: quantum/keymap_common.c                                                                  [OK]
Compiling: quantum/keycode_config.c                                                                 [OK]
Compiling: quantum/sync_timer.c                                                                     [OK]
Compiling: quantum/logging/debug.c                                                                  [OK]
Compiling: quantum/logging/sendchar.c                                                               [OK]
Compiling: quantum/matrix_common.c                                                                  [OK]
Compiling: quantum/matrix.c                                                                         [OK]
Compiling: quantum/debounce/sym_defer_g.c                                                           [OK]
Compiling: quantum/main.c                                                                           [OK]
Assembling: platforms/avr/xprintf.S                                                                 [OK]
Compiling: platforms/avr/printf.c                                                                   [OK]
Compiling: quantum/process_keycode/process_grave_esc.c                                              [OK]
Compiling: quantum/process_keycode/process_magic.c                                                  [OK]
Compiling: quantum/send_string/send_string.c                                                        [OK]
Compiling: quantum/process_keycode/process_space_cadet.c                                            [OK]
Compiling: tmk_core/protocol/host.c                                                                 [OK]
Compiling: tmk_core/protocol/report.c                                                               [OK]
Compiling: tmk_core/protocol/usb_device_state.c                                                     [OK]
Compiling: tmk_core/protocol/usb_util.c                                                             [OK]
Compiling: platforms/suspend.c                                                                      [OK]
Compiling: platforms/synchronization_util.c                                                         [OK]
Compiling: platforms/timer.c                                                                        [OK]
Compiling: platforms/avr/hardware_id.c                                                              [OK]
Compiling: platforms/avr/platform.c                                                                 [OK]
Compiling: platforms/avr/suspend.c                                                                  [OK]
Compiling: platforms/avr/timer.c                                                                    [OK]
Compiling: platforms/avr/bootloaders/dfu.c                                                          [OK]
Compiling: tmk_core/protocol/lufa/lufa.c                                                            [OK]
Compiling: tmk_core/protocol/usb_descriptor.c                                                       [OK]
Compiling: lib/lufa/LUFA/Drivers/USB/Class/Common/HIDParser.c                                       [OK]
Compiling: lib/lufa/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.c                                        [OK]
Compiling: lib/lufa/LUFA/Drivers/USB/Core/AVR8/EndpointStream_AVR8.c                                [OK]
Compiling: lib/lufa/LUFA/Drivers/USB/Core/AVR8/Endpoint_AVR8.c                                      [OK]
Compiling: lib/lufa/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c                                          [OK]
Compiling: lib/lufa/LUFA/Drivers/USB/Core/AVR8/PipeStream_AVR8.c                                    [OK]
Compiling: lib/lufa/LUFA/Drivers/USB/Core/AVR8/Pipe_AVR8.c                                          [OK]
Compiling: lib/lufa/LUFA/Drivers/USB/Core/AVR8/USBController_AVR8.c                                 [OK]
Compiling: lib/lufa/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c                                  [OK]
Compiling: lib/lufa/LUFA/Drivers/USB/Core/ConfigDescriptors.c                                       [OK]
Compiling: lib/lufa/LUFA/Drivers/USB/Core/DeviceStandardReq.c                                       [OK]
Compiling: lib/lufa/LUFA/Drivers/USB/Core/Events.c                                                  [OK]
Compiling: lib/lufa/LUFA/Drivers/USB/Core/HostStandardReq.c                                         [OK]
Compiling: lib/lufa/LUFA/Drivers/USB/Core/USBTask.c                                                 [OK]
Compiling: tmk_core/protocol/lufa/usb_util.c                                                        [OK]
Linking: .build/project_vanguard_full_size_v1_default.elf                                           [OK]
Creating load file for flashing: .build/project_vanguard_full_size_v1_default.hex                   [OK]
Copying project_vanguard_full_size_v1_default.hex to qmk_firmware folder                            [OK]
 [RM]      : Removing object files of "BootloaderDFU"
 [RM]      : Removing dependency files of "BootloaderDFU"
 [RM]      : Removing output files of "BootloaderDFU"
 [INFO]    : Begin compilation of project "BootloaderDFU"...

avr-gcc.exe (GCC) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 [GCC]     : Compiling C file "BootloaderDFU.c"
In file included from ../../LUFA/../LUFA/Drivers/Board/LEDs.h:139,
                 from BootloaderDFU.h:55,
                 from BootloaderDFU.c:37:
../../LUFA/../LUFA/Drivers/Board/AVR8/QMK/LEDs.h: In function 'LEDs_TurnOnLEDs':
../../LUFA/../LUFA/Drivers/Board/AVR8/QMK/LEDs.h:217:38: warning: overflow in conversion from 'int' to 'uint8_t' {aka 'unsigned char'} changes value from '(int)*33 & (~(int)LEDMask & -32768)' to '0' [-Woverflow]
  217 |                 PORT(QMK_SPEAKER) &= (LEDS_LED2 & ~LEDMask);
      |                                      ^
../../LUFA/../LUFA/Drivers/Board/AVR8/QMK/LEDs.h: In function 'LEDs_ToggleLEDs':
../../LUFA/../LUFA/Drivers/Board/AVR8/QMK/LEDs.h:242:37: warning: overflow in conversion from 'int' to 'uint8_t' {aka 'unsigned char'} changes value from '(int)LEDMask & -32768' to '0' [-Woverflow]
  242 |                 PIN(QMK_SPEAKER)  = (LEDS_LED2 & LEDMask);
      |                                     ^
../../LUFA/../LUFA/Drivers/Board/AVR8/QMK/LEDs.h: In function 'LEDs_GetLEDs':
../../LUFA/../LUFA/Drivers/Board/AVR8/QMK/LEDs.h:248:53: warning: overflow in conversion from 'int' to 'uint8_t' {aka 'unsigned char'} changes value from '~(int)*43 & 8 | ~((int)*33 & -32768)' to '255' [-Woverflow]
  248 |                 return (~PORT(QMK_LED) & LEDS_LED1) | (~(PORT(QMK_SPEAKER) & LEDS_LED2));
      |                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BootloaderDFU.c: In function 'main':
BootloaderDFU.c:185:35: warning: unsigned conversion from 'int' to 'uint8_t' {aka 'const unsigned char'} changes value from '-32760' to '8' [-Woverflow]
  185 |         LEDs_SetAllLEDs(LEDS_LED1 | LEDS_LED2);
BootloaderDFU.c: In function '__vector_20':
BootloaderDFU.c:276:35: warning: unsigned conversion from 'int' to 'uint8_t' {aka 'const unsigned char'} changes value from '-32760' to '8' [-Woverflow]
  276 |         LEDs_ToggleLEDs(LEDS_LED1 | LEDS_LED2);
BootloaderDFU.c: In function 'EVENT_USB_Device_ControlRequest':
BootloaderDFU.c:293:35: warning: unsigned conversion from 'int' to 'uint8_t' {aka 'const unsigned char'} changes value from '-32760' to '8' [-Woverflow]
  293 |         LEDs_ToggleLEDs(LEDS_LED1 | LEDS_LED2);
 [GCC]     : Compiling C file "Descriptors.c"
 [GCC]     : Compiling C file "BootloaderAPI.c"
 [GAS]     : Assembling "BootloaderAPITable.S"
 [GCC]     : Compiling C file "HIDParser.c"
 [GCC]     : Compiling C file "Device_AVR8.c"
 [GCC]     : Compiling C file "EndpointStream_AVR8.c"
 [GCC]     : Compiling C file "Endpoint_AVR8.c"
 [GCC]     : Compiling C file "Host_AVR8.c"
 [GCC]     : Compiling C file "PipeStream_AVR8.c"
 [GCC]     : Compiling C file "Pipe_AVR8.c"
 [GCC]     : Compiling C file "USBController_AVR8.c"
 [GCC]     : Compiling C file "USBInterrupt_AVR8.c"
 [GCC]     : Compiling C file "ConfigDescriptors.c"
 [GCC]     : Compiling C file "DeviceStandardReq.c"
 [GCC]     : Compiling C file "Events.c"
 [GCC]     : Compiling C file "HostStandardReq.c"
 [GCC]     : Compiling C file "USBTask.c"
 [LNK]     : Linking object files into "BootloaderDFU.elf"
c:/qmk_msys/mingw64/bin/../lib/gcc/avr/12.2.0/../../../../avr/bin/ld.exe: section .apitable_trampolines LMA [00007fa0,00007fb7] overlaps section .data LMA [00007f26,00007fb5]
collect2.exe: error: ld returned 1 exit status
make[1]: *** [../../LUFA/Build/DMBS/DMBS/gcc.mk:251: BootloaderDFU.elf] Error 1
make: *** [platforms/avr/platform.mk:214: bootloader] Error 2
[max@DESKTOP-EA1LBGP qmk-firmware]$ qmk clean --all
QMK Firmware 0.24.1
Deleting .build/ ... done.
Deleting *.bin, *.hex, and *.uf2 ... done.

For reference, here is the code for my keyboard: MaxJ345/qmk_firmware@master...MaxJ345:qmk_firmware:test

Keyboard Used

project_vanguard/full_size/v1 (not yet merged into the official QMK GitHub repo)

Link to product page (if applicable)

No response

Operating System

Windows

qmk doctor Output

Ψ QMK Doctor is checking your environment.
Ψ CLI version: 1.1.2
Ψ QMK home: G:/Documents/Projects/qmk-firmware
Ψ Detected Windows 10 (10.0.19045).
Ψ QMK MSYS version: 1.8.0
Ψ Userspace enabled: False
Ψ Git branch: test
Ψ Repo version: 0.24.1
⚠ Git has unstashed/uncommitted changes.
Ψ - Latest test: 2024-02-28 15:34:51 -0500 (16fba6faa0) -- TEST
Ψ - Latest upstream/master: 2024-03-02 08:45:01 +1100 (1875659df0) -- CLI Speed improvements. (#23189)
Ψ - Latest upstream/develop: 2024-03-01 21:45:21 +0000 (7fd0201a92) -- Merge remote-tracking branch 'origin/master' into develop
Ψ - Common ancestor with upstream/master: 2024-03-02 08:45:01 +1100 (1875659df0) -- CLI Speed improvements. (#23189)
Ψ - Common ancestor with upstream/develop: 2024-03-02 08:45:01 +1100 (1875659df0) -- CLI Speed improvements. (#23189)
Ψ All dependencies are installed.
Ψ Found arm-none-eabi-gcc version 12.2.0
Ψ Found avr-gcc version 12.2.0
⚠ We do not recommend avr-gcc newer than 8. Downgrading to 8.x is recommended.
Ψ Found avrdude version 7.0
Ψ Found dfu-programmer version 1.1.0
Ψ Found dfu-util version 0.11
Ψ Submodules are up to date.
Ψ Submodule status:
Ψ - lib/chibios: 2023-04-15 13:48:04 +0000 --  (11edb1610)
Ψ - lib/chibios-contrib: 2023-11-27 18:15:44 +0100 --  (9d7a7f90)
Ψ - lib/googletest: 2021-06-11 06:37:43 -0700 --  (e2239ee6)
Ψ - lib/lufa: 2022-08-26 12:09:55 +1000 --  (549b97320)
Ψ - lib/vusb: 2022-06-13 09:18:17 +1000 --  (819dbc1)
Ψ - lib/printf: 2022-06-29 23:59:58 +0300 --  (c2e3b4e)
Ψ - lib/pico-sdk: 2023-02-12 20:19:37 +0100 --  (a3398d8)
Ψ - lib/lvgl: 2022-04-11 04:44:53 -0600 --  (e19410f8)
Ψ QMK is ready to go, but minor problems were found

Is AutoHotKey / Karabiner installed

  • AutoHotKey (Windows)
  • Karabiner (macOS)

Other keyboard-related software installed

No response

Additional Context

No response

@zvecr zvecr added question and removed bug labels Mar 4, 2024
@zvecr zvecr changed the title [Bug] Error occurs while trying to compile production target keyboard firmware Error occurs while trying to compile production target keyboard firmware Mar 4, 2024
@zvecr
Copy link
Member

zvecr commented Mar 4, 2024

Issue is due to differences in avr-gcc compiler version. Some have known regressions when it comes to generated code size and not really a QMK bug.

qmk compile --keyboard evyd13/gh80_1800 --keymap default --target production
Ψ Compiling keymap with make -r -R -f builddefs/build_keyboard.mk -s production KEYBOARD=evyd13/gh80_1800 KEYMAP=default KEYBOARD_FILESAFE=evyd13_gh80_1800 TARGET=evyd13_gh80_1800_default INTERMEDIATE_OUTPUT=.build/obj_evyd13_gh80_1800_default VERBOSE=false COLOR=true SILENT=false QMK_BIN="qmk" QMK_USERSPACE=/home/zvecr/qmk_userspace


Generating: .build/obj_evyd13_gh80_1800_default/src/info_deps.d                                     [OK]
avr-gcc (GCC) 13.2.0
...
AVR Memory Usage
----------------
Device: atmega32u4

Program:    3964 bytes (12.1% Full)
(.text + .data + .bootloader)

Data:        155 bytes (6.1% Full)
(.data + .bss + .noinit)


BootloaderDFU.hex copied to evyd13_gh80_1800_default_bootloader.hex
File sizes:
   text	   data	    bss	    dec	    hex	filename
      0	  16024	      0	  16024	   3e98	evyd13_gh80_1800_default.hex
      0	   4020	      0	   4020	    fb4	evyd13_gh80_1800_default_bootloader.hex
      0	  20044	      0	  20044	   4e4c	evyd13_gh80_1800_default_production.hex

8.x has been mentioned as good, 13 as used above builds fine.

@MaxJ345
Copy link
Author

MaxJ345 commented Mar 4, 2024

Should I update avr-gcc using pacman?: pacman -S avr-gcc

Or is there some other/preferred way of doing it using the QMK CLI?

@MaxJ345
Copy link
Author

MaxJ345 commented Mar 4, 2024

Actually, I don't see avr-gcc listed by pacman as an installed package.

How do I set the version of avr-gcc used by QMK?

@zvecr
Copy link
Member

zvecr commented Mar 4, 2024

https://packages.msys2.org/package/mingw-w64-x86_64-avr-gcc 12.2.0 is the latest available for MSYS.

@MaxJ345
Copy link
Author

MaxJ345 commented Mar 4, 2024

So how did you get QMK to compile with avr-gcc version 13.2.0 above?

@tzarc
Copy link
Member

tzarc commented Mar 6, 2024

Put simply, I don't use QMK MSYS; different Linux distributions bundle different compiler versions, and in my case, I've compiled my own copy of gcc 13.2.0 to run under Linux.

Ultimately this is outside the scope of QMK's support -- we make a best-effort attempt at getting things to work on as many operating system combinations as possible, but with the number of people we have and the numerous variations in the wild, we can't support everything. We don't have control over which version of GCC is packaged by the MSYS team, and at the moment I'd hazard a guess and say that almost nobody can build production targets under QMK MSYS.

If it's critical that you build production targets, your best bet is to figure out an alternative compilation environment such as Linux. If you can run Docker locally you can try to use the prebuilt QMK CLI container which contains an older version of GCC (in the 8.x series) which under normal circumstances should work fine. Neither of these solutions are going to be as simple to get working as QMK MSYS.

EDIT: Arch Linux has 13.2.0, for example: https://archlinux.org/packages/?sort=&q=avr&maintainer=&flagged=

@MaxJ345
Copy link
Author

MaxJ345 commented Mar 7, 2024

I see. That's unfortunate.

I'll try to see if I can get it working in a Linux-based environment. Thank you for your help!

@MaxJ345
Copy link
Author

MaxJ345 commented Mar 11, 2024

I setup a Linux-based environment (specifically Manjaro) and was finally able to compile production firmware. The versions of avr-gcc used were 8.3.0 and 13.2.0.

Thanks for the help!

@dotleon
Copy link

dotleon commented Jul 3, 2024

Downgrading avr-gcc solved this for me.

At the time of writing this, avr-gcc 8.5.0 for MSYS2 is available at msys2 repo site (mingw-w64-x86_64-avr-gcc-8.5.0-1-any.pkg.tar.zst)

Then you can downgrade with
pacman -U mingw-w64-x86_64-avr-gcc-8.5.0-1-any.pkg.tar.zst

After this, production compiles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants