Exec format error with Hello World project on RaspberryPi

Sysprogs forums Forums VisualKernel Exec format error with Hello World project on RaspberryPi

This topic contains 8 replies, has 2 voices, and was last updated by  support 2 months, 2 weeks ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #25717

    jrgrobinson
    Participant

    Hi,

    I use VisualGDB for Raspbian and ESP32. I am starting on a proprietary Linux Driver project so evaluating VisualKernal, hoping it would be as successful for me as VisualGDB.

    I previously built the kernel on a RaspberryPi following their documentation.  I am hoping VisualKernal can abstract me away from the maze of directories and configurations and then provide some assistance in debugging my driver.

    VisualKernal is installed in VS2017 Community. I have started a new kernel module project using the Wizard and the Hello World template.

    The target is a RaspberryPi with a freshly installed ‘Buster’ the additional build computer is another RaspberryPi with the same, freshly installed Raspbian.

    The Wizard fails in the ‘target computer selection’ part, after the tools and linux clone is complete, with the first attempt to run gcc, with an ‘Exec format error’.  I also attempted that part manually in an ssh terminal following the instructions in your tutorial. That result is copied below…

    pi@raspberrypi:/opt/KernelCache/Kernel_0000/tools $ export CCPREFIX=/opt/KernelCache/
    Kernel_0000/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-
    pi@raspberrypi:/opt/KernelCache/Kernel_0000/tools $ ${CCPREFIX}gcc -v
    -bash: /opt/KernelCache/Kernel_0000/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc: cannot execute binary file: Exec format error

    I am sure this is something fundamental I have assumed or am doing wrong. Could you help me establish what that is?

    Thanks

     

    • This topic was modified 2 months, 2 weeks ago by  jrgrobinson.
    #25719

    support
    Keymaster

    No problem, we will help you get it to work.

    The “exec format error” for kernel modules typically happens when trying to load a module that was built for a different kernel. Running “dmesg” from the SSH console should normally show more details on this.

    Generally, for Raspberry Pi we recommend building a debug kernel, installing it, and then using the cross-compilation environment from the kernel to build modules. VisualKernel can automate most of those steps for you, so please try following this tutorial (including the part about building/installing a custom kernel) and let us know if anything doesn’t work.

    #25720

    jrgrobinson
    Participant

    Thanks for the speedy response, in the weekend as well. Much appreciated.

    That tutorial is what I have been following.  I don’t get the Kernel Symbol Location dialog however. The KernelCache simply appears in /opt/.

    The exec format error appears on the first run of GCC after the git clones of tools and source have successfully completed.

    Screenshot attached (hopefully)

     

     

    • This reply was modified 2 months, 2 weeks ago by  jrgrobinson.
    Attachments:
    You must be logged in to view attached files.
    #25723

    support
    Keymaster

    Sorry for the confusion, this looks like a different issue actually. Please double-check that the Linux machine/VM used to build the kernel is a 64-bit one. The Raspberry Pi cross-toolchain released by the Raspberry Pi foundation is likely designed to run on 64-bit hosts only and won’t run on 32-bit systems.

    #25724

    jrgrobinson
    Participant

    That looks like the problem. My build computer is another Raspberry Pi.

    I have built a Kernel on the RaspberryPi (takes a while). I am hoping VisualKernel will simplify the process and remove confusion and give me some debugging capability. I am using that temporarily for evaluation. My intent, if this all works is to set up a separate Linux machine for building.

    I guess, two questions:

    • Is it possible to build on a RaspberryPi with Visual Kernel? I tried the option of building on the target machine but the Wizard wouldn’t allow it.
    • Which Linux would you recommend to use with VisualKernel  if I were to make a dedicated build machine for the RaspberryPi cross compiler?

    Thanks again for your fast responses.

     

    #25725

    support
    Keymaster

    Hi,

    It would be possible to use another Raspberry Pi as a build machine, however you would need to manually configure VisualKernel to use the correct build settings (e.g. see the tutorial for Xilinx Zynq, although the specific steps for Raspberry Pi will be different and some troubleshooting might be required, as we have never tested this configuration).

    Normally, we would advise creating a 64-bit Linux VM (Ubuntu 18.04 LTS should be the easiest one to setup/maintain) using VirtualBox or Hyper-V and then following our regular Raspberry Pi module tutorial. This way the kernel/modules will build much faster compared to another Raspberry Pi and no other physical machine will be required.

    #25726

    jrgrobinson
    Participant

    I much appreciate your fast responses.

    I will set up to build on Ubuntu as you suggest as that  looks like the less experimental path.

    Thanks again for you guidance

     

    #25729

    jrgrobinson
    Participant

    Hi, again

     

    I have been unable to get much farther.

    I have a Ubuntu VM on Hyper V now. Simple Microsoft create Ubuntu. I started the VisualKernel new project Wizard, following the tutorial. I think part of the problem is the VM is new. I needed to install make to get this far. There is a strange configuration directory though.

    I have attached a clipped screenshot.

    I am working through the Raspbian Kernel Build instructions now to see if I can get the cross compiler working on those then will return to VisualKernel.

    One suggestion would be to make the  clone of sources and tools optional in the wizard. It makes a new one each attempt which is slow and eventually I have to delete them all to avoid the disk filling up. When starting out there are a lot of retries.

    Thanks again, and sorry to keep asking things.

     

    Attachments:
    You must be logged in to view attached files.
    #25751

    support
    Keymaster

    Hi,

    Good to know it works. Normally, VisualKernel should be able to find an incomplete sources/tools directory and continue the build. Once the build completes, it is registered with the VisualKernel and is automatically reused for all future projects. If you believe this is not working, please feel free to share the exact instructions to reproduce the behavior you encountered and we should be able to fix it or suggest a workaround.

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.