Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure while building for arm64 / NanoPI R4S #264

Closed
turboproc opened this issue Feb 1, 2022 · 33 comments
Closed

Failure while building for arm64 / NanoPI R4S #264

turboproc opened this issue Feb 1, 2022 · 33 comments
Assignees
Labels
bug Production bug

Comments

@turboproc
Copy link
Contributor

Getting an error when building the packages (base and kernel work fine). Error message looks like below and occurs for every package:

[20220201072918] ===> License OpenSSL accepted by the user ===> openssl-1.1.1m_1,1 depends on file: /usr/local/sbin/pkg - not found [20220201072918] ===> License BSD2CLAUSE accepted by the user [20220201072918] => freebsd-pkg-1.16.3_GH0.tar.gz doesn't seem to exist in /usr/ports/distfiles/. [20220201072918] => Attempting to fetch https://codeload.github.com/freebsd/pkg/tar.gz/1.16.3?dummy=/freebsd-pkg-1.16.3_GH0.tar.gz fetch: https://codeload.github.com/freebsd/pkg/tar.gz/1.16.3?dummy=/freebsd-pkg-1.16.3_GH0.tar.gz: size unknown fetch: https://codeload.github.com/freebsd/pkg/tar.gz/1.16.3?dummy=/freebsd-pkg-1.16.3_GH0.tar.gz: size of remote file is not known freebsd-pkg-1.16.3_GH0.tar.gz 3744 kB 4202 kBps 01s [20220201072920] ===> Fetching all distfiles required by pkg-1.16.3_1 for building [20220201072920] ===> Extracting for pkg-1.16.3_1 [20220201072920] ===> License BSD2CLAUSE accepted by the user [20220201072920] ===> Fetching all distfiles required by pkg-1.16.3_1 for building [20220201072920] => SHA256 Checksum OK for freebsd-pkg-1.16.3_GH0.tar.gz. [20220201072920] ===> Patching for pkg-1.16.3_1 [20220201072920] ===> Applying FreeBSD patches for pkg-1.16.3_1 from /usr/ports/ports-mgmt/pkg/files /usr/bin/sed -i.bak -e "s|-llzma|-llzma -lmd|g" /usr/obj/usr/ports/ports-mgmt/pkg/work/pkg-1.16.3/auto.def /usr/obj/usr/ports/ports-mgmt/pkg/work/pkg-1.16.3/src/Makefile.autosetup /usr/obj/usr/ports/ports-mgmt/pkg/work/pkg-1.16.3/tests/Makefile.autosetup [20220201072920] ===> Configuring for pkg-1.16.3_1 No installed jimsh or tclsh, building local bootstrap jimsh0 No working C compiler found. Tried cc and gcc. [20220201072920] ===> Script "configure" failed unexpectedly.
Any clue what might be wrong ?

Building on a clean FreeBSD 13.0 release and building OPNsense stable/22.1

@fichtner fichtner added the support Community support label Feb 1, 2022
@fichtner
Copy link
Member

fichtner commented Feb 1, 2022

@turboproc no idea, sorry

@turboproc
Copy link
Contributor Author

Hi @yrzr as you seem to be the expert on this topic, any clue what might be happening above ?

@dnsefe
Copy link

dnsefe commented Feb 2, 2022

The issue somehow looks familiar. I recall there being a thread on the forums. What worked out for me was downgrading to pkg version 1.16.3 manually (I guess a fresh FreeBSD 13.0 install downloads 1.17.5 atm). Not all packages could be built though (specifically those ones requiring go). I had to build the latter on my arm device.
It's a little bit of a headache to go back and forth, but it worked out in the end (at least during the 22.1 beta).

Maybe @yrzr has a better solution. It would be very convenient if someone could simply provide the generic arm64 packages (base, kernel etc.) for 22.1. Unfortunately, I don't have a powerful machine atm and building all ports, plugins, core etc. from scratch took almost 2 days.

EDIT: Here is the thread in the forums
https://forum.opnsense.org/index.php?topic=25498.msg124417#msg124417

@turboproc
Copy link
Contributor Author

OK, that might be worth trying. Just need to find out how to downgrade pkg from 1.17.5 to 1.16.3. Couldn't find that in the thread you referred to.

@dnsefe
Copy link

dnsefe commented Feb 2, 2022

In your previous post you can see that pkg v. 1.16.3 is being downloaded. Unpack the archive, cd into the folder and run ./configure && make install clean (it's kinda a dirty way to do it, but yeah).

I decided to give another try for the 22.1 release. Cross building on an amd64 host for arm64. No issues compiling base and kernel, however, regardless of the pkg version, I run into issues if I build "xtools" prior to "packages". For whatever reason, I get multiple errors.

I am currently building the packages. Let's hope all goes well :)

@turboproc
Copy link
Contributor Author

Hi @efetropy , thnx for your support. Let's see how this is going to work. Please keep me posted on your package building.

@dnsefe
Copy link

dnsefe commented Feb 3, 2022

Didn't encounter any issues so far. It's been almost 24 hours and roughly 25% of the parts are built. Kinda getting impatient as it's taking ages. If I have time, I will look into the xtools issue and maybe will come up with something.

@turboproc
Copy link
Contributor Author

OK, doing here a different experiment: running a complete FreeBSD-aarch64 instance within qemu-aarch64 on a AMD64 host aarch64. Within this instance I can do a full native build. Just a kind of very slow.

@dnsefe
Copy link

dnsefe commented Feb 5, 2022

@turboproc I canceled the build since it was taking too long, but can confirm that around 350 packages were built successfully (which if I am not mistaken is roughly half the packages that are built for arm64) which roughly took 40 hours on my computer.

Also tried to reproduce the error you are getting and my initial guess that native-xtools is the culprit turned out to be the case. I used both the 13 RELEASE and 13 STABLE versions to see whether it's going to make any difference. In either case, I ran into the same error as you did. It builds fine once you move/delete the xtools set.

At this point I can't tell whether I really want to build everything in five days or just wait for someone to do the work and hopefully upload the sets.

@turboproc
Copy link
Contributor Author

@efetropy , thnx for feedback. So at least the native-xtools issue has been identified. Would there be any owner to fix this? Moving forward with FreeBSD-13-aarch64 running competely in qemu-system-aarch64 on a AMD64 host. Arrived at 159 packages. Will take some more days.

@yrzr
Copy link
Contributor

yrzr commented Feb 7, 2022

Actually, I am still facing the problem in issue 258. Are you building the following stages with the official base package from FreeBSD 13?

@dnsefe
Copy link

dnsefe commented Feb 7, 2022

@yrzr I was facing the very same problem back in December while building the beta (running a recent FreeBSD 13 STABLE build on an amd64 machine). Unfortunately, I don't remember how I fixed it, but I vaguely remember doing something in the device configuration file. Probably related to CROSS_BINUTILS_PREFIX=/usr/local/aarch64-unknown-freebsd${SRCREVISION}/bin . I believe I deleted that part and it worked (both for cross-compiling and native builds).

Furthermore, I also had a look into the verbose messages when you initially run make. With CROSS_BINUTILS_PREFIX=/usr/local/aarch64-unknown-freebsd${SRCREVISION}/bin, I guess it was skipping building the cross-linker, yet, with the line deleted, the cross-linker was built (at least according to the credibility of the verbose message).
If you are still facing the problem, maybe you can have a look into that and confirm it.

On the other hand, the source tree of the host system I was building on matched the source tree of opnsense. Maybe that's why it worked. No clue, I am no expert in this regards :/

@turboproc I decided to go for a native arm64 build this time. Kinda sucks that there are no 13 STABLE builds available for my device since January, so had to build my own image and sort some issues with nvme. All in all, it's all set and building packages now.

UPDATE: After 6 hours, 230 packages built, 1 failed (powerdns-recursor, will rebuild that at a later point), 1 warning (some inconsistency with qemu-guest-agent). Looks promising so far and much faster than cross-building on my amd64 host.

@yrzr
Copy link
Contributor

yrzr commented Feb 7, 2022

@efetropy Thanks, let me have a try

@dnsefe
Copy link

dnsefe commented Feb 7, 2022

Here is an update. I successfully managed to build the packages with only 2 errors and a warning on my arm64 device in less than 20 hours. Ran into a kinda expected problem though – the packages set couldn't be created since pkg (1.17.5) claims that no packages (*.txz) can be found. It's a known issue and the only fix I am aware of is downgrading pkg to version 1.16.3 on the host.

@yrzr
Copy link
Contributor

yrzr commented Feb 8, 2022

@efetropy I have successfully built images here. I will try the images tomorrow. Feel free to use the packages I built.

@dnsefe
Copy link

dnsefe commented Feb 8, 2022

@yrzr Glad to hear that it worked out in the end and thank you for the link to the repo :)
Will definitely have a look at it. I am actually using a modified arm.sh build script and a device config for my ROCKPRO64.
If all goes well, I will submit a PR.

UPDATE:
With my modified arm.sh script and adjusted extra.conf, the image generation for ROCKPRO64 works. Just need to try out the image on my device later :-)
(The additional output messages are just for debugging)


Message from opnsense-22.1:

--
Owl be watching you
>>> Begin extra: arm_hook
>>> End extra: arm_hook
>>> Setting up entropy in /usr/obj/usr/tools/config/22.1/OpenSSL:aarch64
1+0 records in
1+0 records out
4096 bytes transferred in 0.000047 secs (86803569 bytes/sec)
1+0 records in
1+0 records out
4096 bytes transferred in 0.000041 secs (100722963 bytes/sec)
>>> ...install efi
..../usr/obj/usr/tools/config/22.1/fat...
..../usr/obj/usr/tools/config/22.1/ufs...
/usr/obj/usr/tools/config/22.1/fat
/usr/obj/usr/tools/config/22.1/ufs
..../dev/md0p1...
..../dev/md0p2...
DEVICE         MAJ:MIN SIZE TYPE                                          LABEL MOUNT
md0              0:60  3.0G GPT                                               - -
  <FREE>         -:-    16M -                                                 - -
  md0p1          0:62   50M efi                                         gpt/efi /usr/obj/usr/tools/config/22.1/fat
  md0p2          0:109 2.9G freebsd-ufs                              ufs/rootfs /usr/obj/usr/tools/config/22.1/ufs
  <FREE>         -:-    44K -                                                 - -
vtbd0            0:51   80G GPT                                               - -
  vtbd0p1        0:52   64K freebsd-boot                             gpt/bootfs -
  vtbd0p2        0:53   33M efi                                      gpt/efiesp /boot/efi
  vtbd0p3        0:54  1.0G freebsd-swap                             gpt/swapfs -
  vtbd0p4        0:55   79G freebsd-ufs                              ufs/rootfs /
/usr/obj/usr/tools/config/22.1/fat/EFI
/usr/obj/usr/tools/config/22.1/fat/EFI/BOOT
>>> ...install uboot
322+0 records in
322+0 records out
164864 bytes transferred in 0.022411 secs (7356276 bytes/sec)
1880+0 records in
1880+0 records out
962560 bytes transferred in 0.153069 secs (6288411 bytes/sec)
...done!

UPDATE 2: Up and running on my ROCKPRO64

image

@yrzr
Copy link
Contributor

yrzr commented Feb 9, 2022

Great news!

I have also encountered some failure for some packages

Creating repository in /usr/obj/usr/tools/config/22.1/OpenSSL:aarch64/.pkg-new/: 100%
Packing files for repository: 100%
>>> Running build step: clean
>>> Passing arguments: packages
>>> Removing packages set
>>> Creating package mirror set for 22.1-OpenSSL-aarch64... done
>>> Creating 22.1 signature for packages-22.1-OpenSSL-aarch64.tar... done
-rw-r--r--  1 root  wheel   657M Feb  9 12:02 packages-22.1-OpenSSL-aarch64.tar
-rw-r--r--  1 root  wheel   727B Feb  9 12:02 packages-22.1-OpenSSL-aarch64.tar.sig
>>> WARNING: The build may have integrity issues!
>>> Skipped version 3.11 for benchmarks/iperf3
>>> Skipped version 3.1.3 for devel/pecl-xdebug
>>> Skipped version 2.86_3,1 for dns/dnsmasq
>>> Skipped version 1.33.0 for net-mgmt/netdata
>>> Skipped version 2.4.59_8 for net/openldap24-server
>>> ERROR: The build encountered fatal issues!
>>> Aborted version 1.58.1 for lang/rust
>>> Aborted version 1.0_1 for audio/beep
>>> Aborted version 6.1.32 for emulators/virtualbox-ose-additions-nox11
>>> Aborted version 2.0.5_6 for lang/luajit
>>> Aborted version 6.0.4 for opnsense/suricata-devel
>>> Aborted version 6.0.4_1 for security/suricata
>>> Aborted version 4.1.5 for security/wazuh-agent
>>> Aborted version 20211109 for sysutils/devcpu-data
>>> Aborted version 1.2 for sysutils/flashrom
>>> Aborted version 0.5.9 for sysutils/lcdproc
>>> Aborted version 6.2.0_3 for sysutils/xe-guest-utilities
*** Error code 1

Stop.
make: stopped in /usr/tools

@dnsefe
Copy link

dnsefe commented Feb 9, 2022

@yrzr Not sure whether these packages support arm64 or not as they are marked as "IGNORE", but here is my two bits regarding rust. Haven't tried cross-compiling it, but from what I read on the internet, you need a machine with a lot of RAM (maybe even swap and unlimited tmpfs?). Since suricata also depends on rust, I guess that's the reason why it's failing.

Someone claims to have built rust on a ROCKPro64 (4GB RAM) with -j1 in 14+ hours. Here is a link for reference:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=256099

@fichtner
Copy link
Member

fichtner commented Feb 9, 2022

we only need rust for suricata and that is being excluded for arm builds at least from core level (same for beep):

https://github.com/opnsense/core/blob/master/Makefile#L126-L127

at a quick glance flashrom and devcpu-data is for intel/amd only... it might make sense to exclude most if not all of these ports

IMO it looks like the ignore doesn't work...

audio/beep arm,arm64
either due to a refactor or because the arm/arm64 target architecture string returns something else for individual builds.

@dnsefe
Copy link

dnsefe commented Feb 9, 2022

@fichtner I was surprised to see that @yrzr was building those packages. I built the packages set with make packages DEVICE=ARM64 and from what I can tell packages flagged with "IGNORE" were actually excluded (both during cross-building and native building on my arm64 device).

Either @yrzr is running some test to see which flagged packages are built successfully and can be included or is using configs with different "IGNORE" flags.

@yrzr
Copy link
Contributor

yrzr commented Feb 9, 2022

@fichtner Yes, I agree. I think the PRODUCT_ARCH for arm64 devices is now aarch64 (line 1229 in build/common.sh). So we will need to replace arm64 with aarch64 in the ignoring lists.

@yrzr
Copy link
Contributor

yrzr commented Feb 9, 2022

@efetropy I am using an ARM device with 4 A73 cores and 5G RAM. It seems the RAM is not enough to build rust with 4 threads. I am now trying to build this package on AMD64.

@dnsefe
Copy link

dnsefe commented Feb 9, 2022

@yrzr Building rust with low RAM is indeed a headache. The guys in the link I posted earlier were building with -j1 and 14GB swap. Maybe I will give it a try later and see how it behaves on my device.

@yrzr
Copy link
Contributor

yrzr commented Feb 9, 2022

Packages stage for aarch64 now built without any errors with the commit #267

@fichtner fichtner added bug Production bug and removed support Community support labels Feb 9, 2022
@fichtner fichtner self-assigned this Feb 9, 2022
@fichtner
Copy link
Member

fichtner commented Feb 9, 2022

@yrzr thanks, closing now

@fichtner fichtner closed this as completed Feb 9, 2022
@yrzr
Copy link
Contributor

yrzr commented Feb 11, 2022

@efetropy Which u-boot did you use for r4s? The u-boot from the packages sysutils/u-boot-nanopi-r4s of FreeBSD doesn't work for me. I have to build it myself.

@dnsefe
Copy link

dnsefe commented Feb 11, 2022

@yrzr I actually do not own a r4s. Only have Pine ROCKPro64 (also based on rk3399). Do you have your own device config for that or are you just writing the bootloader files into the generic image?

EDIT: Just checked out your repo and realized that you are using your own device config file. Let me know if you manage to make u-boot work on the R4S. If other bootloader files are not working, it's probably due to additional required conf parameters.
(I used a large portion from https://github.com/freebsd/freebsd-src/blob/stable/13/release/tools/arm.subr)

@dnsefe
Copy link

dnsefe commented Feb 11, 2022

@turboproc did you have any luck building an image for the R4S?

@yrzr
Copy link
Contributor

yrzr commented Feb 11, 2022

@efetropy Thanks, now I am facing kernel panic. Let me dig into r4s.

---<<BOOT>>---
KDB: debugger backends: ddb
KDB: current backend: ddb
WARNING: Cannot find freebsd,dts-version property, cannot check DTB compliance
Copyright (c) 1992-2021 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 13.0-STABLE stable/22.1-n248056-228cd6949d3 SMP arm64
FreeBSD clang version 13.0.0 (git@github.com:llvm/llvm-project.git llvmorg-13.0.0-0-gd7b669b3a303)
VT: init without driver.
module firmware already present!
real memory  = 4158390272 (3965 MB)
avail memory = 4030357504 (3843 MB)
Starting CPU 1 (1)
Starting CPU 2 (2)
Starting CPU 3 (3)
Starting CPU 4 (100)
Starting CPU 5 (101)
FreeBSD/SMP: Multiprocessor System Detected: 6 CPUs
random: unblocking device.
random: entropy device external interface
MAP f0f28000 mode 2 pages 4
MAP f0f2d000 mode 2 pages 4
MAP f3f50000 mode 2 pages 16
kbd0 at kbdmux0
Fatal data abort:
  x0: ffffa00000e62000
  x1:                0
  x2:                2
  x3: ffff000040222200 (_stack + 3edda200)
  x4:             1000
  x5: ffff0000010338d0 (initstack + 38d0)
  x6:               40
  x7:                0
  x8: 675f77665f697072
  x9: ffff000000a0e4c0 (bcm_xhci_methods + 30)
 x10: ffff000000b8c000 (sysctl___kern_epoch_stats_epoch_call_tasks + 48)
 x11:               28
 x12:              14d
 x13:                1
 x14:                0
 x15: ffffa00000e6f3d8
 x16: ffff00004040fd80 (_stack + 3efc7d80)
 x17: ffff000000ef9220 (vm_phys_free_queues + 120)
 x18: ffff0000010339a0 (initstack + 39a0)
 x19: ffffa00000e62000
 x20: ffff000000bed3f0 (bcm_xhci_driver + 0)
 x21: ffff000000c17000 (vm_cnt + 120)
 x22: ffff000000c17000 (vm_cnt + 120)
 x23: ffff000000f6a638 (xhci_devclass + 0)
 x24: ffff000000c17000 (vm_cnt + 120)
 x25: ffff000000e6c000 (g_part_separator + 2b8)
 x26: ffff0000404277a8 (_stack + 3efdf7a8)
 x27:         e9d70000
 x28:         e8e00000
 x29: ffff0000010339a0 (initstack + 39a0)
  sp: ffff0000010339a0
  lr: ffff0000005633b8 (kobj_class_compile1 + 28)
 elr: ffff000000563500 (kobj_class_compile1 + 170)
spsr:         600000c5
 far: 675f77665f697072
 esr:         96000004
panic: vm_fault failed: ffff000000563500
cpuid = 0
time = 1

@fichtner any advice?

@dnsefe
Copy link

dnsefe commented Feb 11, 2022

@yrzr did you set the parameters from the link I sent you?
When I use a GENERIC aarch 64 FreeBSD 13 STABLE image (making sure it has 16mb free space in the beginning for the bootloader) and try to run it on my ROCKPro64, I also run into kernel panics (the regular ROCKPro64 images work fine).

Here is a link to my OPNsense ROCKPro64 image: https://we.tl/t-wmwApBmSNb
Don't forget to write the bootfiles. If the image works for you, maybe we can start debugging from there and come up with a general solution

@yrzr
Copy link
Contributor

yrzr commented Feb 12, 2022

@efetropy After a full rebuild, everything works fine now. Don't know the reason, but still thanks for the help.

@turboproc
Copy link
Contributor Author

@efetropy : started a complete new rebuild last weekend. This time I used the nightly build option. Finished the process this morning and have it up and running. No issues with go or telegram. Just an issue with signing of packages. Packages have been signed by OPNSense is refusing because of an unknown CA. Guess this is not something special but kind find the steps to resolve this. Any hint would be very welcome.

@turboproc
Copy link
Contributor Author

@efetropy Which u-boot did you use for r4s? The u-boot from the packages sysutils/u-boot-nanopi-r4s of FreeBSD doesn't work for me. I have to build it myself.

Spend this week on bringing up a Rock PI 4 and that cause a lot of trouble with U-Boot. The R4S boots without any issue using the standard image been created. (one issue I had with the Rock PI was a bad transfer of the image to a SD card. Switching to the linux dd command solved that problem).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Production bug
Development

No branches or pull requests

4 participants