Region ROM Overflowed / Region Text Overflowed

Region ROM Overflowed / Region Text Overflowed

Background

During the make process, Klipper errors with messages similar to the following:

 ~/klipper $ make
  Creating symbolic link out/board
  Building out/autoconf.h
  ...
  Compiling out/src/generic/usb_cdc.o
  Building out/compile_time_request.o
Version: v0.12.0-468-g2cfdf855-20250405_091358
  Preprocessing out/src/generic/armcm_link.ld
  Linking out/klipper.elf
/usr/lib/gcc/arm-none-eabi/13.2.1/../../../arm-none-eabi/bin/ld: out/klipper.elf section `.text' will not fit in region `rom'
/usr/lib/gcc/arm-none-eabi/13.2.1/../../../arm-none-eabi/bin/ld: region `rom' overflowed by 5273 bytes
collect2: error: ld returned 1 exit status
make: *** [Makefile:73: out/klipper.elf] Error 1

The key parts of the error messages are:

out/klipper.elf section `.text' will not fit in region `rom'
region `rom' overflowed by 5273 bytes
collect2: error: ld returned 1 exit status

Depending on the version of the used gcc or ld and the MCU type, the exact error messages may vary. As an example, the same error on an ATMega MCU might look like:

  Linking out/klipper.elf
/usr/lib/gcc/avr/7.3.0/../../../avr/bin/ld: out/klipper.elf section `.text' will not fit in region `text'
/usr/lib/gcc/avr/7.3.0/../../../avr/bin/ld: address 0x800b4a of out/klipper.elf section `.data' is not within region `data'
/usr/lib/gcc/avr/7.3.0/../../../avr/bin/ld: address 0x800ce9 of out/klipper.elf section `.bss' is not within region `data'
/usr/lib/gcc/avr/7.3.0/../../../avr/bin/ld: address 0x800b4a of out/klipper.elf section `.data' is not within region `data'
/usr/lib/gcc/avr/7.3.0/../../../avr/bin/ld: address 0x800ce9 of out/klipper.elf section `.bss' is not within region `data'
/usr/lib/gcc/avr/7.3.0/../../../avr/bin/ld: region `text' overflowed by 12102 bytes
collect2: error: ld returned 1 exit status
make: *** [Makefile:73: out/klipper.elf] Error 1

Reasons

Some microcontrollers do not have enough flash memory to store the Klipper firmware with all features enabled.
The make menuconfig process makes no assumptions about which features are needed on a given board, and activates all by default.
During the final creation steps of the firmware, it is checked if the resulting firmware fits into flash memory. If not, the process fails with error messages similar to those shown above.

Potential Solutions

In the make menuconfig interface, an option to deactivate certain features is offered for certain microcontrollers:

As mentioned above, by default all features are activated. The selection of features varies depending on the type of microcontroller.

To reduce the code size, features that are not needed or are not supported on a given printer-board can be deactivated. The choice of which features can be safely deactivated depends on the feature-set of the printer board or the intended usage, and the users need to select this individually.

:pushpin: Note: The options in the list potentially depend on each other. Deselecting a higher-level option will automatically deselect the options that depend on it. In this case, the lower-level options will vanish from the list.
For example, deselecting Support communicating with external chips via SPI bus will also deselect all sensors based on this protocol and may affect other options not listed here but equally reliant on it.

Overview of the Options

The default or recommended configuration file for the respective board provides guidance on this, as the feature selection in make menuconfig is tied to certain [sections] or settings: xxx in the configuration file.
The table below provides a rough mapping between the options and affected configuration items. It is not exhaustive, but should provide enough guidance for a targeted choice:

Build Option, supporting Relevant Configuration Section(s) / Settings Notes
micro-controller based ADC (analog to digital) Allows sections like [extruder], [heater_bed], [temperature_sensor], [temperature_fan], etc. to use temperature sensors that connect the sensor to an MCU pin via sensor_pin:. Also affects the sensor_type: temperature_mcu setting and analog_range: setting in [gcode_button]. Enables support for MCU pins with native analog to digital conversion (ADC) functionality.
communicating with external chips via SPI bus Allows communication via hardware SPI defined by the spi_bus: parameter and within sections that use SPI (e.g., [adxl345], [display], [ads1220], [lis2dw], [mpu9250], etc.) Allows defining SPI communication via pins that support hardware SPI. Needs to be activated as well in case the “software variant” shall be used.
software based SPI “bit-banging” Parameters like spi_software_sclk_pin:, spi_software_mosi_pin:, spi_software_miso_pin: within sections that use SPI (e.g., [adxl345], [display], [ads1220], [lis2dw], [mpu9250], etc.) Allows defining SPI communication pins using general-purpose IO pins when hardware SPI peripherals are unavailable or not desired.
communicating with external chips via I2C bus Allows communication via hardware I2C defined by the i2c_bus: parameter and within sections that use I2C (e.g., [probe_eddy_current], [lis2dw], [mpu9250], [icm20948], [pca9533], [icm20948], etc.) Allows defining I2C communication via pins that support hardware I2C. Needs to be activated as well in case the “software variant” shall be used.
software based I2C bit-banging Parameters like i2c_software_scl_pin:, i2c_software_sda_pin: within sections that use I2C (e.g., [probe_eddy_current], [lis2dw], [mpu9250], [icm20948], [pca9533], [icm20948], etc.) Allows defining I2C communication pins using general-purpose IO pins when hardware I2C peripherals are unavailable or not desired. Look for these specific parameters in relevant device sections.
hardware PWM (pulse width modulation) Allows sections like [fan], [heater_fan], [controller_fan], [temperature_fan], [led], [output_pin], [pwm_tool] to use hardware PWM capable pins on the MCU via the hardware_pwm: True setting. Enables support for pins on the MCU that have a native PWM functionality
GPIO based button reading [gcode_button], [filament_switch_sensor] Enables support for buttons and button like applications, e.g. filament sensors
Trinamic stepper motor driver UART communication [tmc2208], [tmc2209], [tmc2240] Enables support for TMC drivers relying on UART data connections. The primary connection for TMC2240 is SPI, but they can also be wired for UART.
‘neopixel’ type LED control [neopixel] Enables control for various LEDs following the Neopixel command structure.
measuring fan tachometer GPIO pins Allows the [fan], [heater_fan], [controller_fan], [temperature_fan], [fan_generic] sections to monitor tachometer signals via the tachometer_* settings. Enables monitoring the fans’ rotation via tachometer signals on fans that support this feature (3-pin or 4-pin fans).
ST7920 LCD display Allows lcd_type: st7920 in the section [display] Enables support for LCD displays based on ST7920 controllers.
HD44780 LCD display Allows lcd_type: hd44780 in the section [display] Enables support for LCD displays based on HD44780 controllers. hd44780_spi is not affected by this option.
thermocouple MAX sensors Allows sections like [extruder], [heater_bed], [temperature_sensor], [temperature_fan] to use these sensors by referencing via the sensor_type: setting. Enables support for MAX31855, MAX31856, MAX31865, and MAX6675 thermocouple interface chips. Define sensors using sensor_type: MAX… within this section.
adxl accelerometers [adxl345] Enables support for the ADXL345 accelerometer, typically used for Resonance Compensation.
lis2dw and lis3dh 3-axis accelerometers [lis2dw] Enables support for LIS2DW12 and LIS3DH accelerometers, also used for Resonance Compensation.
MPU accelerometers [mpu9250] Enables support for MPU-9250/6500/6050 series and compatible ICM accelerometers. Used for Resonance Compensation.
ICM20948 accelerometer [icm20948] Enables support specifically for the ICM20948 accelerometer. Used for Resonance Compensation.
HX711 and HX717 ADC chips [hx711] Enables support for the HX711 and HX717 load cell ADC (Analog-to-Digital Converter) chips.
ADS 1220 ADC chip [ads1220] Enables support for the ADS1220 ADC chip.
ldc1612 eddy current sensor [probe_eddy_current] Enables support for the LDC1612 inductive (eddy current) sensor
angle sensors Allows the [angle] section to use encoders like a1333, as5047d, mt6816, mt6826s and tle5012b via the sensor_type: setting. Enables support for magnetic hall sensor chips. Available choices are “a1333”, “as5047d”, “mt6816”, “mt6826s”, and “tle5012b”

:pushpin: Note: The full range of these options will require a Klipper version of v0.13 or above.

4 Likes