Error -12 (Out of memory) when using a SPI device

Hello

I'm trying to use a display ST7735 in an A133 processor from Allwinner (sun50iw10p1), but the device is not being loaded during Kernel boot, I'm getting the error message "probe of spi2.0 failed with error -12".

After some research, I discovered that this error happens when there is a lack of memory, but which kind of memory? I tried different things in the device tree, tried different things in the kernel configuration file, but nothing changes.

It cannot lack RAM or flash, the full memory configuration that I'm using is 2GB RAM and 16GB of flash memory.

What can I try to overcome this error message?

In the kernel configuration file, I have:

CONFIG_SPI=y

CONFIG_SPI_SUNXI=y

CONFIG_SPI_SPIDEV=y

In the default configuration file, I have:

spi2: spi@05012000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "allwinner,sun50i-spi";
device_type = "spi2";
reg = <0x0 0x05012000 0x0 0x1000>;
interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clk_pll_periph0>, <&clk_spi2>;
clock-frequency = <100000000>;
pinctrl-names = "default", "sleep";
pinctrl-0 = <&spi2_pins_a &spi2_pins_b>;
pinctrl-1 = <&spi2_pins_c>;
spi2_cs_number = <1>;
spi2_cs_bitmap = <1>;
status = "disabled";
};

In the board configuration file (overlay), I have:

spi2_pins_a: spi2@0 {
allwinner,pins = "PB1", "PB2", "PB3";
allwinner,pname = "spi2_sclk", "spi2_mosi",
"spi2_miso";
allwinner,function = "spi2";
allwinner,muxsel = <3>;
allwinner,drive = <1>;
allwinner,pull = <0>;
};

spi2_pins_b: spi2@1 {
allwinner,pins = "PB0";
allwinner,pname = "spi2_cs0";
allwinner,function = "spi2";
allwinner,muxsel = <3>;
allwinner,drive = <1>;
allwinner,pull = <1>; /* only CS should be pulled up */
};

spi2_pins_c: spi2@2 {
allwinner,pins = "PB0", "PB1", "PB2", "PB3";
allwinner,function = "io_disabled";
allwinner,muxsel = <7>;
allwinner,drive = <1>;
allwinner,pull = <0>;
};

spi2: spi@05012000 {
pinctrl-0 = <&spi2_pins_a &spi2_pins_b>;
pinctrl-1 = <&spi2_pins_c>;
spi_slave_mode = <0>;
status = "okay";

st7735r0: st7735r@0 {
compatible = "sitronix,st7735r";
reg = <0>;
pinctrl-names = "default";
spi-max-frequency = <32000000>;
rotate = <90>;
bgr;
fps = <20>;
height=<130>;
width=<130>;
buswidth = <8>;
reset-gpios = <&pio PE 9 1 0 1 0>;
dc-gpios = <&pio PE 8 1 0 1 0>;
};
};

Thanks for your attention.

  • After some research, I discovered that this error happens when there is a lack of memory, but which kind of memory?

    In your device SPI driver, it may allocate an unexpected memory that the current Linux kernel cannot support.  It's better to add some kernel printk statements and provide the kernel logs for further analysis.

    Please be aware that if your driver requests a very big (but less than 2GB RAM that your board have ) Contiguous Memory Allocator (CMA), for example 256MB, it is still possible due to the memory allocation.