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

Raspberry Pi 4 doesn't auto-switch to 64bit mode based on kernel image filename #1193

Closed
agherzan opened this issue Jul 17, 2019 · 13 comments
Closed
Assignees

Comments

@agherzan
Copy link

@agherzan agherzan commented Jul 17, 2019

Using the (current) latest firmware version (https://github.com/raspberrypi/firmware/releases/tag/1.20190709) I observed that in order to boot a 64bit kernel image I need to force the configuration using arm_64bit=1. The kernel image name (kernel8.img) seems to not be enough for the firmware to put the arm in 64bit mode even though this seems to be the expected behavior (raspberrypi/linux#3057 (comment)).

@agherzan agherzan changed the title Raspberry Pi 4 doesn't auto-swtich to 64bit mode based on kernel image filename Raspberry Pi 4 doesn't auto-switch to 64bit mode based on kernel image filename Jul 17, 2019
agherzan pushed a commit to agherzan/u-boot that referenced this issue Jul 19, 2019
Define two target configs for Raspberry Pi 4 (32 and 64bit) and the
corresponding BCM2838* configs.

Be aware of the current limitation in firmware which requires an
explicit configuration to force the arm in 64bit mode when the
respective target is used:
raspberrypi/firmware#1193

Signed-off-by: Andrei Gherzan <andrei@balena.io>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
agherzan pushed a commit to balena-os/u-boot that referenced this issue Jul 19, 2019
Define two target configs for Raspberry Pi 4 (32 and 64bit) and the
corresponding BCM2838* configs.

Be aware of the current limitation in firmware which requires an
explicit configuration to force the arm in 64bit mode when the
respective target is used:
raspberrypi/firmware#1193

Signed-off-by: Andrei Gherzan <andrei@balena.io>
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
aswild added a commit to aswild/meta-newbs that referenced this issue Jul 20, 2019
The lastest firmware includes the updated armstubs, so no need to
rebuild them in Yocto. (meta-raspberrypi commit 69da331154852f5d62d6cf7a69c4ddb34f5564d0)

RPi kernel commit d5dc848c982dff2e020f294e384447efe6ea6617 mitigates the
DMA issues with memory over 1G, so the total_mem=1024 workaround can be
removed.

arm_64bit is still needed because the firmware doesn't set it
automatically based on the presence of kernel8.img, even though it
should (raspberrypi/firmware#1193)
@Noltari
Copy link

@Noltari Noltari commented Sep 4, 2019

This seems to be fixed with latest firmware.
arm_64bit=1 is no longer needed with kernel8.img.

@pelwell
Copy link
Contributor

@pelwell pelwell commented Sep 4, 2019

Correct. The firmware will still prefer the 32-bit kernel if present unless arm_64bit=1 is set, but if the only suitable kernel (based on the filename) is 64-bit then the correct stub and initialisation is used.

There are therefore now three ways to force 64-bit:

  1. arm_64bit=1
  2. kernel=kernel8.img.
  3. Delete the compatible 32-bit kernels.

@agherzan
Copy link
Author

@agherzan agherzan commented Sep 9, 2019

Thanks for the heads up. I will be testing this and close the issue as soon as I validate.

@graysky2
Copy link

@graysky2 graysky2 commented Jan 6, 2021

There are therefore now three ways to force 64-bit:
arm_64bit=1
kernel=kernel8.img.
Delete the compatible 32-bit kernels.

@pelwell - Are you certain about this? On my RPi4 running 64-bit kernel and userland, if I comment out the arm_64bit=1 line below, I don't even see the rainbow splash screen. The system is running the latest rpi-5.10.y kernel with the latest firmware. Here is my /boot/config.txt:

kernel=kernel8.img
arm_64bit=1
enable_gic=1

hdmi_force_hotplug=1

over_voltage=6
arm_freq=2000

[all]
include kodi.config.txt

With /boot/kodi.config.txt containing:

dtoverlay=vc4-kms-v3d,cma-384
dtoverlay=rpivid-v4l2
disable_overscan=1
disable_fw_kms_setup=1

@pelwell
Copy link
Contributor

@pelwell pelwell commented Jan 6, 2021

It almost works as advertised:

  • Setting arm_64bit=1 forces 64-bit mode and will choose kernel8.img as the kernel file name but can be overridden using kernel=....
  • Deleting (or renaming) the 32-bit kernels and leaving arm_64bit unset will cause kernel8.img to be loaded in 64-bit mode.
  • What doesn't currently work is only forcing kernel=kernel8.img - the section of the loader code confuses user-specified kernel file with 32-bit kernel file, causing the "if we only have a 64-bit kernel and the user hasn't set arm_64bit=0 then force arm_64bit=1" test to fail.
  • enable_gic=1 is set automatically if the DT specifies that the interrupt controller is an "arm,gic=400". The only reason to set it manually is for bare-metal, non-DT kernels.

If you are creating images that only include a 64-bit kernel then all you need to do is call your single kernel binary "kernel8.img" and leave kernel, arm-64bit and enable_gic unspecified.

I'll make a note to fix the only-kernel=kernel8.img case, but it isn't a priority.

@graysky2
Copy link

@graysky2 graysky2 commented Jan 6, 2021

Thanks for the clarification. I removed the superfluous lines from /boot/config.txt and the the RPi4 booted as expected. To be clear, this is now my /boot/config.txt

hdmi_force_hotplug=1

over_voltage=6
arm_freq=2000

[all]
include kodi.config.txt

Aside from the successful boot, is there something I can inspect to insure full 64-bit behavior is detected and functional?

@pelwell
Copy link
Contributor

@pelwell pelwell commented Jan 6, 2021

The switch to 64-bit mode is an all or nothing thing - if it's executing your ARMv8 instructions then all is well - but you can use lscpu to confirm the processor details.

@graysky2
Copy link

@graysky2 graysky2 commented Jan 6, 2021

Got it, thanks. The output of lscpu is identical whether I boot with the superfluous lines in /boot/config.txt or without them:

% lscpu
Architecture:                    aarch64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
CPU(s):                          4
On-line CPU(s) list:             0-3
Thread(s) per core:              1
Core(s) per socket:              4
Socket(s):                       1
Vendor ID:                       ARM
Model:                           3
Model name:                      Cortex-A72
Stepping:                        r0p3
CPU max MHz:                     2000.0000
CPU min MHz:                     600.0000
BogoMIPS:                        108.00
Vulnerability Itlb multihit:     Not affected
Vulnerability L1tf:              Not affected
Vulnerability Mds:               Not affected
Vulnerability Meltdown:          Not affected
Vulnerability Spec store bypass: Vulnerable
Vulnerability Spectre v1:        Mitigation; __user pointer sanitization
Vulnerability Spectre v2:        Vulnerable
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Not affected
Flags:                           fp asimd evtstrm crc32 cpuid

graysky2 added a commit to graysky2/PKGBUILDs that referenced this issue Jan 7, 2021
Upstream update and remove superfluous options in /boot/config.txt[1].

1. raspberrypi/firmware#1193 (comment)
popcornmix added a commit that referenced this issue Jan 18, 2021
See: raspberrypi/linux#4075

kernel: vc4: Correct POS1_SCL for hvs5
See: raspberrypi/linux#4079

firmware: platform: Define DVFS modes and change default to be fixed AVS voltage

firmware: arm_loader: Auto-select 64-bit for kernel8.img
See: #1193

firmware: hdmi: Throttle auto-i2c register writes to avoid PWM audio underrun
popcornmix added a commit to Hexxeh/rpi-firmware that referenced this issue Jan 18, 2021
See: raspberrypi/linux#4075

kernel: vc4: Correct POS1_SCL for hvs5
See: raspberrypi/linux#4079

firmware: platform: Define DVFS modes and change default to be fixed AVS voltage

firmware: arm_loader: Auto-select 64-bit for kernel8.img
See: raspberrypi/firmware#1193

firmware: hdmi: Throttle auto-i2c register writes to avoid PWM audio underrun
@pelwell
Copy link
Contributor

@pelwell pelwell commented Feb 24, 2021

FYI this is fixed in firmware built since Jan 18 - kernel=kernel8.img will set arm_64bit=1.

@agherzan
Copy link
Author

@agherzan agherzan commented Feb 25, 2021

Thanks, @pelwell. We also dropped in the Yocto integration (agherzan/meta-raspberrypi@2a9c3bb).

@popcornmix
Copy link
Contributor

@popcornmix popcornmix commented Feb 25, 2021

Okay to close?

@agherzan agherzan closed this Feb 25, 2021
@remusmp
Copy link

@remusmp remusmp commented Sep 5, 2021

Just out of curiosity, if I set kernel=kernel8_rt.img do I still need arm_64bit=1 or will it be set automatically? Thanks!

@pelwell
Copy link
Contributor

@pelwell pelwell commented Sep 6, 2021

There was a period when having an 8 in the image name was enough to enable 64-bit mode, but it was tripped up by a user who had a date-stamped kernel name. Since then the auto-detect only works for kernel8.img.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants