LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices


Reply
  Search this Thread
Old 03-06-2022, 11:17 AM   #1
eric976
LQ Newbie
 
Registered: Mar 2022
Posts: 2

Rep: Reputation: 0
Question 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>;
};
};
 
Old 03-07-2022, 05:27 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,849

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
Hi,
at first would be nice to use code tags, that will make your post more readable.

Quote:
Originally Posted by eric976 View Post
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".
Probably it is already loaded?
Quote:
Originally Posted by eric976 View Post
After some research, I discovered that this error happens when there is a lack of memory, but which kind of memory?
This is the main memory, the RAM.
Quote:
Originally Posted by eric976 View Post
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?
Yes, 2 GB should be enough, but I think it needs some dedicated area which is already occupied.
 
Old 03-08-2022, 07:28 AM   #3
eric976
LQ Newbie
 
Registered: Mar 2022
Posts: 2

Original Poster
Rep: Reputation: 0
Update

Quote:
Originally Posted by pan64 View Post
Hi,
at first would be nice to use code tags, that will make your post more readable.


Probably it is already loaded?

This is the main memory, the RAM.

Yes, 2 GB should be enough, but I think it needs some dedicated area which is already occupied.
Thanks for your answer... Just some updates...
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
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:
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... =/
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
DTS configuration for SPI BUS with spi-mux Zano Linux - Kernel 0 08-28-2021 12:45 PM
[SOLVED] Need help with Device Tree for SPI Device T_Versicolor Linux - Embedded & Single-board computer 21 06-26-2019 02:13 AM
SD issue on imx6 using SPI interface, for some SD (out of range access) cyril F. Linux - Kernel 0 09-20-2018 04:45 PM
Framebuffer driver for SPI driven display, memory allocation and handling tseiman Linux - Embedded & Single-board computer 2 06-23-2013 06:51 PM
About use FIQ for SPI slave in device driver. jason222333 Linux - Kernel 4 10-25-2010 02:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 05:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration