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

Discussion about U-Boot and the kernel.

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

Postby eric976 » Sun Mar 06, 2022 5:24 pm

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:
$this->bbcode_second_pass_code('', 'CONFIG_SPI=y
CONFIG_SPI_SUNXI=y
CONFIG_SPI_SPIDEV=y')

In the default configuration file, I have:
$this->bbcode_second_pass_code('', '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>;
};
};')
Last edited by moonman on Mon Mar 07, 2022 9:31 pm, edited 1 time in total.
Reason: code tags
eric976
 
Posts: 2
Joined: Sat Mar 05, 2022 6:17 am

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

Postby eric976 » Tue Mar 08, 2022 1:24 pm

Update: I was debugging what was happening inside the functions located in the file fbtft-core.c and I saw that the issue is related to the DMA.

If I replace this
$this->bbcode_second_pass_code('', ' if (txbuflen > 0) {
#ifdef CONFIG_HAS_DMA
if (dma) {
dev->coherent_dma_mask = ~0;
txbuf = dmam_alloc_coherent(dev, txbuflen, &par->txbuf.dma, GFP_DMA);
} else
#endif
{
txbuf = devm_kzalloc(par->info->device, txbuflen, GFP_KERNEL);
}
if (!txbuf)
goto alloc_fail;
par->txbuf.buf = txbuf;
par->txbuf.len = txbuflen;
}')

To only this:
$this->bbcode_second_pass_code('', ' if (txbuflen > 0) {
txbuf = devm_kzalloc(par->info->device, txbuflen, GFP_KERNEL);
if (!txbuf)
goto alloc_fail;
par->txbuf.buf = txbuf;
par->txbuf.len = txbuflen;
}')

There is no error message, but it is still not working... =/
eric976
 
Posts: 2
Joined: Sat Mar 05, 2022 6:17 am


Return to U-Boot/Kernel

Who is online

Users browsing this forum: No registered users and 2 guests

cron