Debian mali g71 drivers


Hi all,

We are trying to install Mali G71 drivers, for openCL support.
Currently we have successfully flashed Linaro latest image (based on 4.19.5) using Mani instruction with serial\ssh communication.

we also downloaded G71 drivers from ARM website: mali-G71_r9p0-01rel0_linux_1fbdev.tar.gz

We would appreciate help for next steps.


I keep some notes before @sumit.garg shared with me:

# Add the to the OpenCL vendors
$ mkdir -p /etc/OpenCL/vendors/
$ echo "" > /etc/OpenCL/vendors/mali.icd

# Install OpenCL client using command:
$ apt install clinfo

# Run OpenCL client tool:
$ clinfo



clinfo output:
“Number of platforms 0”
I assume clinfo didn’t find any supported cl HW

maybe i wasn’t clear…we downloaded the drivers to host machine, but not to hikey960 because we d’ont know how to install them (and this is why i started this post)


@Moshe_Eliyahu Following are some instructions that I use to install out-of-tree mali G71 kernel driver and user-space libraries for OpenCL on Debian/hikey960:

1. Update device tree with GPU node [1] via GRUB entry update:
-> scp device tree image to “/boot/” location on hikey960 board.

2. Do reboot and press “e” to edit commands when you see GRUB menu during booting and add following command:
`devicetree    /boot/hi3660-hikey960.dtb`

3. Install Linux source on Debian to build modules:
$ apt-get update
$ apt-get install linux-headers-$(uname -r)

4. Download mali bitfrost latest r16 kernel driver from here [2].

5. Build and install steps for mali bitfrost driver:
$ tar -xzf BX301A01B-SW-99002-r16p0-01rel0.tgz
$ make -C /usr/src/linux-headers-4.19.5-hikey/ M=BX301A01B-SW-99002-r16p0-01rel0/driver/product/kernel/drivers/gpu/arm/midgard/ CONFIG_MALI_MIDGARD=m CONFIG_MALI_GATOR_SUPPORT=y CONFIG_MALI_MIDGARD_DVFS=y CONFIG_MALI_EXPERT=y CONFIG_MALI_PLATFORM_FAKE=y CONFIG_MALI_PLATFORM_THIRDPARTY=y CONFIG_MALI_PLATFORM_THIRDPARTY_NAME=devicetree modules
$ insmod BX301A01B-SW-99002-r16p0-01rel0/driver/product/kernel/drivers/gpu/arm/midgard/mali_kbase.ko

6. Install and run ARM Mali GPU user-space libraries and OpenCL tool:
# Download, extract and put the mali library in the correct position
$ wget

$ tar xvf mali-G71_r9p0-01rel0_linux_1fbdev.tar.gz
$ cp fbdev/ /usr/lib/aarch64-linux-gnu/
$ cp fbdev/ /usr/lib/aarch64-linux-gnu/

# Add the to the OpenCL vendors
$ mkdir -p /etc/OpenCL/vendors/
$ echo "" > /etc/OpenCL/vendors/mali.icd

# Install OpenCL client using command:
$ apt install clinfo

# Run OpenCL client tool:
$ clinfo

Hopefully, the first two steps you won’t have to repeat by next edk2/UEFi image update as we are trying to add GPU node in device-tree by default.



Hi, could you please elaborate on step 1? How do I find and edit the device tree? many thanks


@Omer_Schleifer You can simply edit device tree (arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dts) in Linux repo [1]. Then build it using following instructions:

$ make defconfig ARCH=arm64
$ make dtbs  ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-

Output device tree blob: arch/arm64/boot/dts/hisilicon/hi3660-hikey960.dtb

BTW, now you don’t need to edit device tree as @Mani had already applied the GPU node patch to Linux tree [2]. So you could just build and update device tree.




We have added a guide [1] in documentation regarding “OpenCL support on Debian/hikey960”.

Please feel free to give it a try and let us know your feedback.



thanks @sumit.garg, i was able to solve all the issues using your posts.

I have quotation:
Currently i have to manually change device tree in grub every boot
after boot i have to manually load the mali_kbase (insmod …mali_kbase.ko)

How can do this automatically?



For device tree, you may need to wait for next UEFI/edk2 image incorporating PR [1] or else you can build UEFI/edk2 image (part of fip.bin) from source including PR [1] and following this doc [2].

For auto-loading of mali kernel driver, use following steps:

$ sudo mkdir -p /lib/modules/$(uname -r)/extras
$ sudo cp BX301A01B-SW-99002-r16p0-01rel0/driver/product/kernel/drivers/gpu/arm/midgard/mali_kbase.ko /lib/modules/$(uname -r)/extras/
$ sudo depmod -a

Then just reboot your hikey960 with devicetree (mali gpu node enabled) updated.



Thanks @sumit.garg.

How can i tell the GPU frequency and change it?


AFAIK with current module build options, DEFAULT_GPU_FREQ_KHZ_MAX defines the max GPU frequency as 5MHz. So you could modify the GPU frequency via defining GPU_FREQ_KHZ_MAX in platform config file [1].

I would suggest you to not define it more than max operating frequency (1.037 GHz) as specified in device-tree gpu node [2].

Also with current module build options, devfreq infrastructure isn’t enabled for GPU device which would configure maximum frequency automatically based on highest operating point found from device tree gpu node [2].

[1] BX301A01B-SW-99002-r16p0-01rel0/driver/product/kernel/drivers/gpu/arm/midgard/platform/devicetree/mali_kbase_config_platform.h