Closed Fusseldieb closed 1 year ago
Looks like your cross-compiling setup is not right. Are you actually trying to cross-compile here?
If not you should call: make tools
instead.
In any case there's nothing wrong with the code or the Makefile here, it's on your side.
Looks like your cross-compiling setup is not right. Are you actually trying to cross-compile here? If not you should call:
make tools
instead.In any case there's nothing wrong with the code or the Makefile here, it's on your side.
Yes, I am trying to cross-compile for the SoC. My computer runs x64 and the SoC is arm. No matter which libraries I install or which arguments I use I always get this error.
@paulkocialkowski Coming from a relatively clean Ubuntu setup, the README is lacking information about the setup, since I couldn't get it to work.
It looks like your cross-compiling setup is not right then, as it cannot find system headers (sys/mman.h
is a really really basic one). This is nothing specific to this project so there's no reason it should be in the README, which assumes you have a working cross-compiling setup.
Did you install arm-none-eabi-gcc
from your distro?
It looks like your cross-compiling setup is not right then, as it cannot find system headers (
sys/mman.h
is a really really basic one). This is nothing specific to this project so there's no reason it should be in the README, which assumes you have a working cross-compiling setup.Did you install
arm-none-eabi-gcc
from your distro?
I installed everything via apt, and since that apparently didn't suffice (as it doesn't work), I tried it with these instructions, but it still claims the exact same error.
Please note that target-tools
is just about meminfo, which is ancient and only gives useful output up to A23/A33 SoCs. As such it's highly optional. If you don't need it (and chances are high you don't), then just don't compile it, that's the reason we have a separate make target.
Regarding the libraries: you need libc-dev for the target architecture, so gnueabihf, probably. Just some arm-none-eabi cross-compiler won't cut it for meminfo, although that works for the bare metal snippets that sunxi-tools uses elsewhere.
On Ubuntu you need to add it to the list of installed architectures:
dpkg --add-architecture armhf
, then install the libraries: apt update; apt install libc-dev:armhf
.
Please note that
target-tools
is just about meminfo, which is ancient and only gives useful output up to A23/A33 SoCs. As such it's highly optional. If you don't need it (and chances are high you don't), then just don't compile it, that's the reason we have a separate make target. Regarding the libraries: you need libc-dev for the target architecture, so gnueabihf, probably. Just some arm-none-eabi cross-compiler won't cut it for meminfo, although that works for the bare metal snippets that sunxi-tools uses elsewhere. On Ubuntu you need to add it to the list of installed architectures:dpkg --add-architecture armhf
, then install the libraries:apt update; apt install libc-dev:armhf
.
Thanks for the answer @apritzel and @paulkocialkowski . Hmm, maybe it's not so useful then. I was actually trying to cross-compile "uart0-helloworld-sdboot.c" and thought that target-tools would also include it.
I installed all the libraries suggested by apritzel and ran both commands. No avail, still no sys/mman.
Digging deeper, I found that mman isn't even available. But why? I just installed the whole ARM GNU toolchain (or so I think)!
fusseldieb@***-PC-UBUNTU:~/sunxi-tools$ ls /usr/share/arm-gnu-toolchain-12.2.mpacbti-rel1-x86_64-arm-none-eabi/arm-none-eabi/include/sys/
cdefs.h dirent.h features.h _intsup.h _pthreadtypes.h sched.h stat.h syslimits.h _timespec.h _types.h utime.h
config.h dir.h fenv.h _locale.h queue.h select.h _stdint.h timeb.h timespec.h types.h wait.h
custom_file.h errno.h file.h lock.h reent.h signal.h stdio.h time.h _timeval.h _tz_structs.h
_default_fcntl.h fcntl.h iconvnls.h param.h resource.h _sigset.h string.h times.h tree.h unistd.h
Was this file moved? Or isn't it included in newer arm gnu toolchain distributions?
The primary goal was to cross-compile only "uart0-helloworld-sdboot.c", so above probably isn't needed. However, the issue with missing headers still exists, and will probably bite someone else down the road. I think that README should explicitly state which packages to install. It kinda already does, but apparently this isn't enough... Maybe provide links or instructions to specific tar packages?
Was this file moved?
That's a very common header, there is really no chance that it was moved.
Anyway the issue is probably that you're using a bare-metal (none
) toolchain which doesn't include libc headers. Try with a libc-enabled toolchain.
As @paulkocialkowski mentioned, you probably need to install crossbuild-essential-armhf
. That would give you a arm-linux-gnueabihf-gcc
compiler, along with the basic libraries and headers to compile Linux programs for ARM32 machines with hard floating point support. You also need to make sure that the Makefile picks that compiler up, and not arm-none-eabi-gcc
.
Cross compiling fully-functional Linux tools is not trivial, though support has improved much in the last years in major distributions. That's why many places used to recommend the none
toolchain, which is easier to install (because it has less dependencies and libraries), but is less capable. It's good enough for firmware, bootloaders, kernels and small code snippets like those used in sunxi-fel, though, which fits many use cases already.
But it cannot create Linux executables. Support for that is different in each distro, which is why the README might not be the right place to describe this.
If you run Ubuntu, I'd recommend you uninstall the none
cross-compiler, and install the fully featured one (armhf), which is normally a superset of the none
version (minus a few exotic examples that rely on newlib). The Makefile (more precisely find-arm-gcc.sh) should then pick up this compiler, and it should work.
If you feel that deserves explanation in the README, feel free to send a patch.
When compiling the target-tools for the Allwinner SoC, I get the following error:
Note that all tools are installed as mentioned in the README.md file. "make" without any argument does work, but as mentioned in the README does not produce the SoC files.
A Google search indicates that "libc6-dev" should be installed, which is!
Running on following system (real system, not wsl2!):