How to boot RPi armv8 as aarch64 or armv7h?

This forum is for topics dealing with problems with software specifically in the AArch64 repo.

How to boot RPi armv8 as aarch64 or armv7h?

Postby keithspg » Fri Jul 10, 2020 1:46 pm

Can you have an armv6 or v7 chroot under aarch64? If so how? I tried to boot my armv6 chroot under aarch64 and it fails to launch. Is there some kernel option that can be set (requiring a kernel rebuild)? I ask this as I have a distccd build setup for Rpi1/2/4 and have recently added aarch64 to the mix. I'd like to have only one booted image (aarch64) and switch into chroots to build the packages for armv7 and armv6... Can I have a 'dual boot situation where I can boot it with a v7 kernel or a v8? Basically saving me from powering down and removing the card would be helpful as well.

Currently, I have an armv7 image and chroot into armv6 to build the armv6 packages and that works great as I can build armv6 almost as fast as armv7!
Last edited by keithspg on Fri Jul 10, 2020 9:39 pm, edited 1 time in total.
keithspg
 
Posts: 224
Joined: Mon Feb 23, 2015 4:14 pm

Re: Armv6 or v7 chroot under aarch64?

Postby graysky » Fri Jul 10, 2020 2:14 pm

I do not believe you can. For building packages for armv6h, armv7h and aarch64 on my RPi4, I have 2 uSD cards, one running armv7h and another running aarch64. Maybe someone can correct me if there is a way to do it all from aarch64.
graysky
Developer
 
Posts: 1876
Joined: Sun Jun 26, 2011 6:56 am
Location: /run/user/1000

Re: Armv6 or v7 chroot under aarch64?

Postby keithspg » Fri Jul 10, 2020 5:42 pm

So, I was thinking... I have an RPiB3+ running aarch64. It boots with uboot, right? I know very little about it, but I was wondering if I could create a mmcblkp3 as an archv7h filesystem and switch the kernel at boot time.

What I am thinking is: I boot as aarch64, it would boot from /boot with kernel8.img but mount its root from mmcblk0p2. As amv7h, its root would be on mmcblk0p3. I would select (rename?) an initramfs and kernel for the next boot then reboot. So it reboots as armv7h. How do I tell the boot code to use kernel7 versus kernel8?

Or maybe I am no longer using uboot. How do I figure that out?
My system is a bit different from standard arch arm aarch64: I downloaded the arch_latest_aarch64 image booted then built and installed a raspberrypi kernel that I compiled using moonman's PKGBUILD. I am running the same kernel revision 5.4.45-1-ARCH on armv7 and aarch64. I compare the files in /boot and they look to be all the same filesize and name. The only difference is kernel8.img versus kernel7.img.

aarch64: 5.4.45-1-ARCH #1 SMP PREEMPT Wed Jul 1 20:34:37 CDT 2020 aarch64 GNU/Linux
armv7h: 5.4.45-1-ARCH #1 SMP PREEMPT Thu Jul 2 10:25:37 CDT 2020 armv7l GNU/Linux

Can I do this with config.txt/cmdline.txt or is it uboot? I am lost...

Am I way off base here?
keithspg
 
Posts: 224
Joined: Mon Feb 23, 2015 4:14 pm

Re: Armv6 or v7 chroot under aarch64?

Postby keithspg » Fri Jul 10, 2020 9:37 pm

Ok, I have found something of a 'work around' for my PiB3+.
I made an aarch64 image with my custom 5.4.45 kernel and booted it. I made a 3rd partition and copied my full armv7 installation to it. I copied my kernel7.img and initramfs-linux.img to /boot/armv7

I edited cmdline.txt and copied the line and commented out the first line and changed root to /dev/mmcblk0p3
$this->bbcode_second_pass_code('', '#root=/dev/mmcblk0p2 rw rootwait ...
root=/dev/mmcblk0p3 rw rootwait ...')

I edited config.txt and put this at the end:
$this->bbcode_second_pass_code('', '# armv8
#arm_64bit=1
#kernel=kernel8.img
# armv7
arm_64bit=0
kernel=kernel7.img

initramfs initramfs-linux.img followkernel')

To boot as armv7, I move kernel8.img and initramfs-linux.img to a folder /armv8 and put kernel7.img and its initramfs-linux.img into the /boot and uncomment the second line of the cmdline.txt and comment out the appropriate 2 lines of config.txt, voila, it boots as armv7 and I can access my chroot for armv6. To boot it back as aarch64, I remove the armv7 bits and comment out the second line of the cmdline.txt and swap back the comments in config.txt.

Is there an easier way? I will change the title of the thread as it has diverged from my original request
keithspg
 
Posts: 224
Joined: Mon Feb 23, 2015 4:14 pm

Re: How to boot RPi armv8 as aarch64 or armv7h?

Postby keithspg » Fri Jul 10, 2020 11:14 pm

I made it a bit easier by keeping the kernels in their respective folders. That way I do not need to cp/rm etc.:

$this->bbcode_second_pass_code('', '# armv8
arm_64bit=1
kernel=armv8/kernel8.img
initramfs armv8/initramfs-linux.img followkernel

# armv7
#arm_64bit=0
#kernel=armv7/kernel7.img
#initramfs armv7/initramfs-linux.img followkernel')

This way, I comment/uncomment in config.txt and in cmdline.txt. I have verified this works. I will make a script to make these changes to 2 txt files and it allows me to use one 32Gb card to compile for all 3 architectures!

Now if I could just figure out why aarch64 does not mount the nfs mount in the fstab at boot like armv7 does...
keithspg
 
Posts: 224
Joined: Mon Feb 23, 2015 4:14 pm

Re: How to boot RPi armv8 as aarch64 or armv7h?

Postby graysky » Sat Jul 25, 2020 1:04 pm

If you share the same /boot you will run into issues I think. There are files that get installed to /boot/overlays for example that might have the same name.
graysky
Developer
 
Posts: 1876
Joined: Sun Jun 26, 2011 6:56 am
Location: /run/user/1000

Re: How to boot RPi armv8 as aarch64 or armv7h?

Postby keithspg » Sat Jul 25, 2020 1:28 pm

I have already run into that and have mitigated it somewhat. You probably know better that I do, but the files appear to be the same size. I assume they are the same.
So far, I have been renaming any files pacman has problems with when needed and move the kernel.img and initramfs back to /boot before I update the kernel and back to their respective folders afterward. I have been keeping the same kernel revision for both architectures. Is there a better way? It would be nice to have a dual boot maybe even with nfs boot or uboot (though I do not really understand how that is implicated. When I remove the uboot package from the armv8 root, it fails to boot even for the armv7. I am really unsure of what kind of frankerstrin I have created, but it does allow me to do what I want, at least for now. The key is I need to be able to do it via ssh as it is headless.

Any suggestions?

Keith
keithspg
 
Posts: 224
Joined: Mon Feb 23, 2015 4:14 pm

Re: How to boot RPi armv8 as aarch64 or armv7h?

Postby graysky » Sat Jul 25, 2020 1:44 pm

Not sure what the best way to do what you want is... I just have 2 uSD card, one with armv7h and another with aarch64. It's pretty easy to swap them.
graysky
Developer
 
Posts: 1876
Joined: Sun Jun 26, 2011 6:56 am
Location: /run/user/1000


Return to ARMv8

Who is online

Users browsing this forum: No registered users and 6 guests