Solved upgrade armv6 with cross-compilation on amd64

guys,

recently I got an old (but good) Raspberry Pi Model B+. It had some penguinas on board, but I prefer beasties, so I've downloaded 13.1-RELEASE image, burn to MicroSD card and boot from it, everything runs fine.

There is the “build server” in my virtualization farm — amd64 VM. It pulls stable/13 and rebuilds amd64 target weekly, /usr/src and /usr/obj are exported with NFS so all my FreeBSD-based boxes can be easily upgraded.

I successfully built armv6 target with make -j4 TARGET_ARCH=armv6 KERNCONF=RPI-B buildworld buildkernel. But when i switch to my brand new Raspberry Pi and try to upgrade it I see:

Code:
root@rpi-b:/usr/src # make KERNCONF=RPI-B installkernel
--------------------------------------------------------------
>>> Install check kernel
--------------------------------------------------------------
--------------------------------------------------------------
>>> Installing kernel RPI-B on Fri Dec 16 02:41:21 MSK 2022
--------------------------------------------------------------
cd /usr/obj/usr/src/arm.armv6/sys/RPI-B;  MACHINE_ARCH=armv6  MACHINE=arm  CPUTYPE= CC="cc -target armv6-gnueabihf-freeb
sd13.1 --sysroot=/usr/obj/usr/src/arm.armv6/tmp -B/usr/obj/usr/src/arm.armv6/tmp/usr/bin" CXX="c++  -target armv6-gnueab
ihf-freebsd13.1 --sysroot=/usr/obj/usr/src/arm.armv6/tmp -B/usr/obj/usr/src/arm.armv6/tmp/usr/bin"  CPP="cpp -target arm
v6-gnueabihf-freebsd13.1 --sysroot=/usr/obj/usr/src/arm.armv6/tmp -B/usr/obj/usr/src/arm.armv6/tmp/usr/bin"  AS="as" AR=
"ar" ELFCTL="elfctl" LD="ld"  LLVM_LINK="" NM=nm OBJCOPY="objcopy"  RANLIB=ranlib STRINGS=  SIZE="size" STRIPBIN="strip"
PATH=/usr/obj/usr/src/arm.armv6/tmp/bin:/usr/obj/usr/src/arm.armv6/tmp/usr/sbin:/usr/obj/usr/src/arm.armv6/tmp/usr/bin:
/usr/obj/usr/src/arm.armv6/tmp/legacy/usr/sbin:/usr/obj/usr/src/arm.armv6/tmp/legacy/usr/bin:/usr/obj/usr/src/arm.armv6/
tmp/legacy/bin:/usr/obj/usr/src/arm.armv6/tmp/legacy/usr/libexec::/sbin:/bin:/usr/sbin:/usr/bin  make  KERNEL=kernel ins
tall
/bin/sh: make: Exec format error
*** Error code 126

Yes, the make found in /usr/obj/usr/src/arm.armv6/tmp/legacy/bin is ELF 64-bit LSB executable, x86-64 as any other executable in /usr/obj/usr/src/arm.armv6/tmp/ subdirectories.

So you now know my question. How can I upgrade my armv6 13.1-RELEASE to armv6 13.1-STABLE if it was cross-compiled by amd64 13.1-STABLE OS. What is my mistake? Where is the right way?

Thanks in advance.
 
you can probably make install{world,kernel} DESTDIR=/something and then transfer /something over / on the arm box
 
covacat
Alain De Vos

thanks, guys, but this is not the way. This is in fact the fresh install — it couldn't be done on the live system, I have to boot the box with another OS (impossible with RPi-B, it can't boot from usb-flash, afaik) or eject the MicroSD and populate it on some another FreeBSD box.

I think, there should be the way to force build system to use arch-native tools during install. Sure, I can run make build... on RPi, but why? At first, it'll take a lot of time. At second, the native tools already are built in fact.
 
on the build system mount the pi sd card on /mnt
make installworld DESTDIR=/mnt
why is this not possible ?
 
You can nfs mount the build machine's /usr/src and /usr/obj from the Raspi and make installkernel installworld from the Raspi. But remember to move or delete /usr/obj/usr/src/arm.armv6/tmp first.
 
bakul that's exactly what won't work because the "temporary tools" used by build/install itself (in the /usr/obj/usr/src/${TARGET}.${TARGET_ARCH}/tmp hierarchy) are always built for the building host, not for the target.

edit: Ah wait, you suggest to remove these tools. Sure, this will probably work, but cause the target machine to build them... and then, of course require write access to /usr/obj :confused:

I'd be interested as well whether there's a way to generate these tools for the target architecture... The main Makefile lists a lot of targets, maybe one of them would do the trick.
 
thank you guys,

at the moment I've upgraded Raspberry with the following commands after successful building of world and kernel.

On build host:
make -C /usr/src/release TARGET=arm TARGET_ARCH=armv6 kernel.txz base.txz

On target host:
tar xf /usr/obj/usr/src/arm.armv6/release/kernel.txz --clear-nochange-fflags --unlink -C /
tar xf /usr/obj/usr/src/arm.armv6/release/base.txz --clear-nochange-fflags --unlink --exclude etc/ --exclude var/ -C /
etcupdate


And yes, zirias@ , I'll research Makefiles for trick on my free times...
 
edit: Ah wait, you suggest to remove these tools. Sure, this will probably work, but cause the target machine to build them... and then, of course require write access to /usr/obj :confused:

I'd be interested as well whether there's a way to generate these tools for the target architecture... The main Makefile lists a lot of targets, maybe one of them would do the trick.
Stuff in /user/obj/…/tmp is only used for building. You can move it out of the way, then on target machine installworld and kernel, then on build machine move it back before the next build.
 
Stuff in /user/obj/…/tmp is only used for building. You can move it out of the way, then on target machine installworld and kernel, then on build machine move it back before the next build.
Are you suggesting the install* targets won't attempt to re-create those tools but instead just use the host's tools? If so, that's indeed a workaround, but might also break in weird ways...
 
bakul the key question for me would be: do the install* targets attempt to rebuild the "tmp-tools" or not? If they don't, this is indeed a suitable workaround as long as it doesn't break. There's a reason for these tools of course, the older tools from the host won't fit the purpose sometimes. Indeed, this is much more critical during build than during install. But just as an example, for me, some installkernel runs failed on first attempt because of kldxref(8). And I remember having seen a discussion somewhere whether kldxref should be part of these tools for exactly that reason....
 
You can nfs mount the build machine's /usr/src and /usr/obj from the Raspi and make installkernel installworld from the Raspi. But remember to move or delete /usr/obj/usr/src/arm.armv6/tmp first.
Just to confirm that this method works!
Thank you bakul
 
Back
Top