User Tools

Site Tools


doc:appunti:hardware:raspberrypi_3

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
doc:appunti:hardware:raspberrypi_3 [2024/03/21 19:01] niccolodoc:appunti:hardware:raspberrypi_3 [2024/03/22 06:13] (current) niccolo
Line 1: Line 1:
-====== Kodi on the Raspberry Pi 3 ======+====== Kodi on the Raspberry Pi 3 and CMA problems ======
  
-With the default settings you can read the following using **dmesg**:+I installed **Kodi 19.4** on the **Raspberry Pi 3 Model B Plus Rev 1.3**, running the **Raspberry Pi OS** based on **Debian 11.9**. Unfortunately I experienced some weird crashes of the Kodi program: sometimes the Kodi process suddendly restart while I'm browsing a folder with about 200 video items. 
 + 
 +The error messages are revealed by the **dmesg** output: 
 + 
 +<file> 
 +[  628.433140] cma: cma_alloc: linux,cma: alloc failed, req-size: 338 pages, ret: -12 
 +[  628.433195] bcm2835-codec bcm2835-codec: dma alloc of size 1384448 failed 
 +... 
 +[  848.225919] [drm:vc4_bo_create [vc4]] *ERROR* Failed to allocate from GEM DMA helper: 
 +[  848.226063] vc4-drm soc:gpu: [drm]                            V3D: 210408kb BOs (1132) 
 +[  848.226074] vc4-drm soc:gpu: [drm]                     V3D shader:     56kb BOs (14) 
 +[  848.226081] vc4-drm soc:gpu: [drm]                           dumb:   2040kb BOs (1) 
 +[  848.226088] vc4-drm soc:gpu: [drm]                         binner:  16384kb BOs (1) 
 +[  848.226095] vc4-drm soc:gpu: [drm]                total purged BO:   1028kb BOs (2) 
 +</file> 
 + 
 +As you can see the V3D used 210408 kb of the DRM memory, which is very near to the default size reserved of 256 Mb. You can see it into **dmesg** output:
  
 <code> <code>
-Memory498224K/786432K available +[    0.000000] Reserved memorycreated CMA memory pool at 0x1ec00000size 256 MiB
-    (10240K kernel code, 1452K rwdata, 2900K rodata, +
-    1024K init, 613K bss, 26064K reserved262144K cma-reserved)+
 </code> </code>
  
-Add the following into **/boot/config.txt**+In **/boot/config.txt** you should confirm that you are loading the **vc4-kms-v3d** overlay, which is the module dedicated to GPU management, the **VideoCore IV GPU** available on the Raspberry Pi 3:
  
-<file+<code
-gpu_mem=256+# Enable DRM VC4 V3D driver 
 +dtoverlay=vc4-kms-v3d 
 +max_framebuffers=2 
 +</code>
  
-# Default cma is 262144K+To reserve more memory for the CMA, add the following line into **/boot/config.txt** 
-dtoverlay=cma,cma-size=402653184+ 
 +<file> 
 +# Default cma reserved memory is 256 Mb, use 512 instead
 +dtoverlay=cma,cma-size=536870912
 </file> </file>
  
-The problem persistswe got the following error in **dmesg**:+Because the total memory is limited to 1 Gbit is advisable to reserve not much memory for the GPU; in **/boot/config.txt** put this:
  
 <file> <file>
-[105495.597020] [drm:vc4_bo_create [vc4]] *ERROR* Failed to allocate from GEM DMA helper: +gpu_mem=92
-[105495.597225] vc4-drm soc:gpu: [drm]                            V3D: 356880kb BOs (1478) +
-[105495.597239] vc4-drm soc:gpu: [drm]                     V3D shader:     68kb BOs (17) +
-[105495.597246] vc4-drm soc:gpu: [drm]                           dumb:   2040kb BOs (1) +
-[105495.597254] vc4-drm soc:gpu: [drm]                         binner:  16384kb BOs (1) +
-[105495.597261] vc4-drm soc:gpu: [drm]                total purged BO:  53744kb BOs (41)+
 </file> </file>
 +
 +With 92 Mb of GPU memory I'm still able to play 1920x1080 videos without issues. Many features of the VideoCore IV GPU use the CMA reserved memory, not this GPU reserver one.
 +
 +You can check how many GPU memory is used during Kodi normal operation, just launch the {{.raspberrypi:bcmstat.sh.gz|bcmstat.sh}} script and let it run:
 +
 +<code>
 +./bcmstat.sh Dd5
 +</code>
 +
 +At next reboot I verified that the new setting is in place, checking the **dmesg** output:
 +
 +<code>
 +[    0.000000] Reserved memory: created CMA memory pool at 0x0ec00000, size 512 MiB
 +[    0.000000] Memory: 402028K/954368K available (10240K kernel code, 1452K rwdata,
 +               2900K rodata, 1024K init, 613K bss, 28052K reserved, 524288K cma-reserved)
 +</code>
 +
 +Verify also that the system has enough free memory once the Kodi program is started, use the **free** commando to get it:
 +
 +<code>
 +               total        used        free      shared  buff/cache   available
 +Mem:          927340      321760      319708        2836      285872      548032
 +Swap:         524284                524284
 +</code>
 +
 +About **300 Mb of free memory** should suffice for normal operations.
  
doc/appunti/hardware/raspberrypi_3.1711047706.txt.gz · Last modified: 2024/03/21 19:01 by niccolo