6 Replies Latest reply on Aug 23, 2019 2:55 AM by bhoevding

    Cache Library on the UltraZed




      I am currently trying to build a kernel module, which contains functions like cache-flushing.


      Some background Information as to how my System is generated:

      I am using the Xilinx-V2019.1-Toolchain (Vivado & SDK, PetaLinux Tools) to generate all the required Embedded Linux components like bootloader, kernel image and device tree. Furthermore I have cloned the Xilinx-Linux-Repository, switched to the V2019.1 branch and configured PetaLinux Tools to use the specific Xilinx-Linux-Repo to generate the components using the repository. My platform is the Avnet-UltraZed-EG-IOCC Board and I am using a Debian-10 root filesystem for development. The Module I am trying to compile has worked on other Zynq-7000 Dev. Boards which have a different CPU-Architecture (32-Bit).


      The issue:

      The module won't compile, because I am trying to use kernel functions form a header which doesn't exist (outercache.h).


      Regarding the outercache.h header, someone pointed out to me that this library can only be used on ARM-32-Bit-CPUs. As of right now I have worked through the arch/arm/include/asm/*.h and arch/arm64/include/asm/*.h within the Xilinx-Linux-Repository and found some other headers. But the problem persists, that the relevant headers (for example from the arm64-dir: cache.h, cacheflush.h) are not build. I have tried building the headers using PetaLinux Tools, as well as Cross Compiling using make xilinx_zynqmp_defconfig, make deb-pkg, make headers_install. Using the find command I have not figured out how to generate these cache headers, which could be the solution to my problem.

      Another tip which I received on the Xilinx Forum was to include the following line CONFIG_OUTER_CACHE=y in the  xilinx_zynqmp_defconfig, which seemed promising but also didn't help me generating the required headers.

      The only cache-relevant header being built on my system is located under /usr/include/linux/bcache.h, but doesn't contain any helpful functions for my module.


      So as of right now I am really desperate to find out, how the cache can be flushed on 64-Bit Architectures from the Xilinx Zynq UltraScale+ Series. Hopefully someone can help me out with this issue, it might also help future developers.

      I am depending on this to work for my application which is why I am trying to get help from both Forums here as well as the Xilinx Forum (see https://forums.xilinx.com/t5/Embedded-Linux/Cacheflush-not-working/m-p/1009218#M35867)


      I would appreciate all the help I can get and please reply should you need more details, screenshots or other information,


      best regards,



      Message was edited by: Bjørn Hövding

        • Re: Cache flush not working



          Can you provide the Makefile? I think Makefile will lead us to some clue.

          Btw are you able to locate asm/outercache.h file in linux/arch?




          1 of 1 people found this helpful
            • Re: Cache flush not working



              The asm/outercache.h is located under linux/arch, but it seems like a configuration prevents the header from being built into the system.

              I am unsure as to what extent this is an issue with my build-process, configuration or architecture. (see Answer in Xilinx Forum)


              Makefile for the Module:

              ifneq ($(KERNELRELEASE),)
              EXTRA_CFLAGS := -I$(src)/build
              obj-m := module.o
              asterics-objs := build/driver.o build/support.o build/memio.o build/reader.o  build/writer.o
              SOURCE_DIR = ../../sources/
              SRC_DIR = ./
              KDIR    := /lib/modules/$(uname -r)/build
              PWD     := $(shell pwd)
                mkdir -p build
                cp driver.[hc] build/
                cp $(SRC_DIR)config.h build/
                cp linux_kernel_if.h build/
                cp $(SOURCE_DIR)support.[hc] build/
                cp $(SOURCE_DIR)memio.[hc] build/
                cp $(SOURCE_DIR)reader.[hc] build/
                cp $(SOURCE_DIR)writer.[hc] build/
                $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules
                rm -fr build


              eventually my build steps will help as well:


              #1 Using PetaLinux to build the Boot-Files, Kernel Image and Device Tree
              Host $ petalinux-config <hw-desc>
              Host $ petalinux-build
              Host $ petalinux-package ...
              #2 cloning the Xilinx-Linux-Repo and building the Header Files
              Host $ git clone <xlnx-lnx-repo>; cd <xlnx-lnx-repo>
              Host $ make xilinx_zynqmp
              Host $ make deb-pkg
              Host $ make headers_install
              Host $ ls usr/include/*
              Host $ find usr/include/ -name "outercache.h" # Header not found
              Host $ find <xlnx-lnx-repo>/ -name "outercache.h" # Header found under arch/arm/include/asm/outercache.h
              #3 booting the System with Debian
              UZ3EG $ find /usr/include/ -name "outercache.h" #Header not found
              UZ3EG $ sudo dpkg -I linux-header* linux-image* linux-libc*
              UZ3EG $ cd /lib/modules/<uname -r>/build
              UZ3EG $ make headers_install
              UZ3EG $ make modules
              UZ3EG $ find usr/include/ -name "outercache.h" # Header not found
              1 of 1 people found this helpful
            • Re: Cache flush not working

              Did you make head way here?

              1 of 1 people found this helpful
                • Re: Cache flush not working

                  Hello @BB-Sphere,


                  could you explain your question, I am not sure what you mean.


                  Goal: I am trying to flush the Cache using Kernel functions.


                  Problem: The Kernel library which is built through PetaLinux Tools, or myself don't include / build the needed Librarys (outercache.h, cache.h, cacheflush.h).

                  • Re: Cache Library on the UltraZed

                    Hello clem57 and Using Xilinx Tools Forum, Forums (ZedBoard), UltraZed, Avnet, Xilinx,


                    first of all thank you for looking into this matter and helping me out with your expertise. I have looked into these links and will work them through more thoroughly.

                    From what I read and tried, my problem with the Linux User Space Library / Kernel Headers still persist.


                    I have also tried building the module using the PetaLinux Tools Workflow:


                    petalinux-create -t modules --name <user-module-name> --enable


                    but this is a dead end due to multiple reasons.


                    Using the Approach from https://forums.xilinx.com/t5/Embedded-Development-Tools/Trouble-creating-Linux-Application-in-SDK-2016-2-or-2016-4/td-p/… doesn't seem very promising but I will definitely try it. There is some resemblance to their issue and the issue I am working with.


                    The other Workflows describing how to generate the linux components unfortunately didn't give any new insights, although they are a genuine and very well documented resource to get started with the PetaLinux Toolchain.


                    Regarding my issue I am almost certain that the issue is within the configuration https://github.com/Xilinx/linux-xlnx of arch/arm64/configs/xilinx_zynqmp_defconfig or some switch / configuration with in PetaLinux preventing the Cache Headers to be built. But this is only an assumption based on my research, the solution could lie somewhere completely different.

                    1 of 1 people found this helpful