Cannot Move Location Counter Backwards Error - ArduCopter Compilation Issue

Hello, I am encountering the following error while compiling the ArduPilot firmware:

[1019/1027] Compiling ArduCopter/UserCode.cpp
[1020/1027] Compiling ArduCopter/landing_gear.cpp
[1021/1027] Linking build/geprc_f405/bin/arducopter
/usr/lib/gcc/arm-none-eabi/10.3.1/../../../arm-none-eabi/bin/ld:common.ld:202 cannot move location counter backwards (from 0000000008100b60 to 0000000008100000)
collect2: error: ld returned 1 exit status

Waf: Leaving directory `/home/yusuf/ardupilot/build/geprc_f405`
Build failed
 -> task in 'bin/arducopter' failed (exit status 1)

Details:

The error occurs in the linker stage at a line in the common.ld file.

The “cannot move location counter backwards” error generally indicates an issue with memory layout and occurs when an attempt is made to move to an earlier address range.

Solutions I’ve Tried:

  • I updated the build toolchain.
  • I checked the build options, but the problem persists.

System Information:

  • GCC version: 10.3.1
  • Build platform: Geprc F405
  • Operating System: Linux

Additional Information:

If anyone can help solve this error or provide more insight, it would be very helpful.

Thank you!

You ran out of flash

1 Like

Effectively this means that you need to remove features from your build until things fit

1 Like

I’m using standard peripherals with ArduPilot, but I’m experiencing issues with insufficient flash memory. Here are the peripherals I’ve defined:

  • 4x UART
  • 4-channel TIMER
  • 3x SPI
  • ADC1 with 3 channels
  • 1 GPIO for LED
    My configuration settings are as follows:
#define STM32_ST_USE_TIMER 5
#define CH_CFG_RESOLUTION 32

// Flash size configuration
FLASH_SIZE_KB 1024
FLASH_RESERVE_START_KB 48

#define HAL_STORAGE_SIZE 16384
#define STORAGE_FLASH_PAGE 1

I have flash problem when I add IMU Invensensev3 SPI:imu ROTATION_YAW_180 line to hwdef.dat file
Given these settings, shouldn’t 1024 KB flash be sufficient? Why might I be running out of flash memory in this scenario?

If needed, I can also share my hwdef.dat file for further clarification.

Thanks!