dwelch67
Posts: 939
Joined: Sat May 26, 2012 5:32 pm

Re: Entering aarch64 execution state

Tue Mar 15, 2016 8:59 pm

I have my bootloader working in 64 bit mode as well, not nearly as complicated as a uboot, but it works. Tried a little to find the leds on the i2c, probably going to give up and mess with other things. Have a whole new instruction set to learn, have had the arm simulator for a long time, this is the first board I can do anything with...

marcus_c
Posts: 11
Joined: Sun Mar 13, 2016 12:15 am

Re: Entering aarch64 execution state

Tue Mar 15, 2016 10:09 pm

If you want to try 64-bit Linux kernel without audio/video, do

Code: Select all

git clone --depth 1 -b rpi3 https://github.com/zeldin/linux.git linux64-rpi3
cd linux64-rpi3
make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- bcmrpi3_defconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu-
Then copy arch/arm64/boot/Image and arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dtb to the /boot partition. Use

Code: Select all

fatload mmc 0:1 $fdt_addr_r bcm2837-rpi-3-b.dtb
fatload mmc 0:1 $loadaddr image
booti $loadaddr - $fdt_addr_r
from U-Boot to launch the kernel. It is able to boot up the Raspbian 32-bit userland, albeit only on a single core and not with much peripheral support right now...

MrTomasz
Posts: 10
Joined: Wed Jan 06, 2016 11:37 am
Location: London, UK

Re: Entering aarch64 execution state

Wed Mar 16, 2016 1:06 am

Nice work!

I see you integrated it in easier way than I was trying to...

Have you tested it with some simple root filesystem or you just got it booting/loading and that's it ? Any first side effects ?

MrTomasz
Posts: 10
Joined: Wed Jan 06, 2016 11:37 am
Location: London, UK

Re: Entering aarch64 execution state

Wed Mar 16, 2016 2:12 am

Unfortunately doesn't work well for me -- I can't see proper UART kernel booting log...

Code: Select all

## Flattened Device Tree blob at 00000100
   Booting using the fdt blob at 0x000100
   Loading Device Tree to 000000003ab35000, end 000000003ab39405 ... OK

Starting kernel ...

ćţ`fř~řfřćřffffŕřf~fřćřfţřřff`ćććřţćŕfxř`ćć~ćŕćŕ~fřćřfţřřxŕŕřf (...)
Using 32bit kernel, I have to use pi3-disable-bt (gpio reconfiguration) overlay to get UART running.

marcus_c
Posts: 11
Joined: Sun Mar 13, 2016 12:15 am

Re: Entering aarch64 execution state

Wed Mar 16, 2016 4:03 am

I've only tested the Raspbian userland so far, with which it's possible to log in at the serial console. Haven't had time to test anything else. Probably improvements are needed to both the device tree and kernel config to get everything working correctly.

Please make sure the command line (bootargs variable in U-Boot) has the correct serial port config. Here is a command line which works for me:

Code: Select all

root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait console=ttyAMA0,115200
No idea about the pi3-disable-bt overlay, I'm using the one called pi3-miniuart-bt-overlay...

Electron752
Posts: 142
Joined: Mon Mar 02, 2015 7:09 pm

Re: Entering aarch64 execution state

Wed Mar 16, 2016 4:06 am

marcus_c:

That's really cool. I didn't realize it was possible to get a bootable kernel with such a small number of changes. My PI 3 is on back order right now, but I will certainly be testing this as soon as I get it.

swarren
Posts: 45
Joined: Tue Mar 01, 2016 5:56 am

Re: Entering aarch64 execution state

Wed Mar 16, 2016 5:42 am

My github branch now has RPi 3 support in both 32- and 64-bit builds:
https://github.com/swarren/u-boot/tree/rpi_dev

This version uses the ARM architectural timers thus avoids the generic_timer.c modification from zeldin's branch.

This version uses the mini UART for the console (via the regular RX/TX pins on the GPIO header), since I believe the HW design intention is to reserve the regular UART for BT. I still need to check the DT overlays provides with the RPi kernel to see whether this is a HW requirement or suggestion. Dealing with runtime alternatives would be a bit painful...

I plan to send patches to mainline U-Boot soon, but I'm waiting to find out whether the VC FW will be updated to program the pinmux and baud rate for the mini UART or not.

marcus_c
Posts: 11
Joined: Sun Mar 13, 2016 12:15 am

Re: Entering aarch64 execution state

Wed Mar 16, 2016 8:56 am

swarren:
Nice!
Did you see Alexander's comment regarding dcache? https://github.com/zeldin/u-boot-rpi3/issues/1

MrTomasz
Posts: 10
Joined: Wed Jan 06, 2016 11:37 am
Location: London, UK

Re: Entering aarch64 execution state

Wed Mar 16, 2016 11:09 am

marcus_c wrote:I've only tested the Raspbian userland so far, with which it's possible to log in at the serial console. Haven't had time to test anything else. Probably improvements are needed to both the device tree and kernel config to get everything working correctly.

Please make sure the command line (bootargs variable in U-Boot) has the correct serial port config. Here is a command line which works for me:

Code: Select all

root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait console=ttyAMA0,115200
No idea about the pi3-disable-bt overlay, I'm using the one called pi3-miniuart-bt-overlay...
Hi,

You're right, I meant pi3-miniuart-bt-overlay (sorry, it was late)...

Well, I'll check today step by step again and let's see.

marcus_c
Posts: 11
Joined: Sun Mar 13, 2016 12:15 am

Re: Entering aarch64 execution state

Fri Mar 18, 2016 6:53 pm

swarren:
I think you should keep PL01X UART as a compile time option (via menuconfig) at least.
I just tried your branch and boy was the UART performing poorly. With the PL011 I can
easily paste command lines longer than 40 characters into the terminal and have them
input correctly. With the MU the lines get truncated after like 10 characters...

1Maarten
Posts: 3
Joined: Wed Mar 23, 2016 7:58 am
Location: Amsterdam

Re: Entering aarch64 execution state

Wed Mar 23, 2016 10:16 am

marcus_c wrote:If you want to try 64-bit Linux kernel without audio/video, do

Code: Select all

git clone --depth 1 -b rpi3 https://github.com/zeldin/linux.git linux64-rpi3
cd linux64-rpi3
make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- bcmrpi3_defconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu-
Then copy arch/arm64/boot/Image and arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b.dtb to the /boot partition. Use

Code: Select all

fatload mmc 0:1 $fdt_addr_r bcm2837-rpi-3-b.dtb
fatload mmc 0:1 $loadaddr image
booti $loadaddr - $fdt_addr_r
from U-Boot to launch the kernel. It is able to boot up the Raspbian 32-bit userland, albeit only on a single core and not with much peripheral support right now...
Just a question, which u-boot version did you use, https://github.com/swarren/u-boot or https://github.com/zeldin/u-boot-rpi3.git? It seems when I use swarren's fork u-boot works, but when booting the kernel it stops after 'Starting kernel', I've tried several different options using dtoverlay (rpi-minuart/disable-bt) and bootargs. When running the u-boot form zeldin's fork there's no console at all. Any tips or ideas what to try next?

My config.txt

Code: Select all

dtoverlay=pi3-miniuart-bt-overlay
kernel=u-boot.bin
kernel_old=1
arm_control=0x200
disable_commandline_tags=1

marcus_c
Posts: 11
Joined: Sun Mar 13, 2016 12:15 am

Re: Entering aarch64 execution state

Wed Mar 23, 2016 9:34 pm

1Maarten:

I used my own (https://github.com/zeldin/u-boot-rpi3.git).

My config.txt looks like yours, only difference is that I have the
line

dtparam=audio=on

as well.

Did you check both HDMI and UART?

1Maarten
Posts: 3
Joined: Wed Mar 23, 2016 7:58 am
Location: Amsterdam

Re: Entering aarch64 execution state

Thu Mar 24, 2016 8:48 am

marcus_c:

Yes, both UART and HDMI stay blank. I'll check later if "dtparam=audio=on" changes anything. They only thing I can think of right now is use a different toolchain; I've been using the Arch Linux ARM version, I'll try the Raspbian version as well.

Thanks.

marcus_c
Posts: 11
Joined: Sun Mar 13, 2016 12:15 am

Re: Entering aarch64 execution state

Thu Mar 24, 2016 11:43 am

Ok. My toolchain was generated with

crossdev --target aarch64-unknown-linux-gnu

in Gentoo.

1Maarten
Posts: 3
Joined: Wed Mar 23, 2016 7:58 am
Location: Amsterdam

Re: Entering aarch64 execution state

Fri Mar 25, 2016 7:57 am

marcus_c:

Thanks, I haven't figured out yet what's going wrong here, but I'll post it when I do know :)

User avatar
schorsch76
Posts: 22
Joined: Sun Apr 28, 2013 8:01 am

Re: Entering aarch64 execution state

Mon Mar 28, 2016 5:34 pm

Following this thread and inspired by a gentoo admin i tried this too. I used buildroot to build zeltins kernel and the u-boot-rpi3. As i got this up and booting i compied with buildroot a minimal userland for 64 bit. But as buildroot doesnt build gcc for the target i build it by myself but got only the c language running. Now i try to build gcc and g++ on the target. I hope this works out.

My detailed information is on the gentoo forum:
https://forums.gentoo.org/viewtopic-t-1 ... ight-.html

I just want to let you know about it, because i think that could be interesting for some people :)

User avatar
DavidWang
Posts: 4
Joined: Tue Mar 29, 2016 6:58 am

Re: Entering aarch64 execution state

Tue Mar 29, 2016 7:09 am

Can I use ARM-Trusted Firmware as the first stage bootloader running @EL3?

Electron752
Posts: 142
Joined: Mon Mar 02, 2015 7:09 pm

Re: Entering aarch64 execution state

Tue Mar 29, 2016 5:39 pm

Hi,

I got my RPI 3 a few days ago. I'm able to build u-boot for 64 bit and it runs just fine. I can see the text on the monitor and everything seems great. I am having a ton of trouble getting the serial port to work on RPI 3. I've tried all the overlay recommendations without any success. No text through the UART at all.

Exactly which pins are people using for the UART port? I'm using the standard GPIO 14 & GPIO 15. I've gotten this to work just fine on the RPI 2, I've tried both the overlay pi3-miniuart-bt and the overlay pi3-disable-bt overlay. Neither one works.

I see some mention on the docs on the web about the other possible location of the miniuart but I can't seem to find the exact GPIO pins documented for it at all. I'm wondering if the other UART location will work and then I won't need to use the overlay.

swarren
Posts: 45
Joined: Tue Mar 01, 2016 5:56 am

Re: Entering aarch64 execution state

Tue Mar 29, 2016 5:45 pm

The same pins on the GPIO header are used for UART on the RPi 3.

However, a different UART HW module is used to drive those pins, and enabling that requires some additional configuration of the system that may reduce performance. Consequently, you need to explicitly request that in your config.txt file. Add the following line:

enable_uart=1

You'll also need the very latest firmware to correctly interpret that.

swarren
Posts: 45
Joined: Tue Mar 01, 2016 5:56 am

Re: Entering aarch64 execution state

Tue Mar 29, 2016 5:46 pm

DavidWang wrote:Can I use ARM-Trusted Firmware as the first stage bootloader running @EL3?
I would expect so, but you'd need to port ATF to the system. You'd need to use "kernel_old=1" in config.txt and make ATF handle the SMP CPU pinnning/bootup, and know how to receive ATAGS/DT from the VC FW and pass them on to the rest of the SW stack, etc.

User avatar
patrikg
Posts: 168
Joined: Sun Mar 18, 2012 10:19 pm

Re: Entering aarch64 execution state

Tue Mar 29, 2016 9:28 pm

Hello Stephen

Regarding the atags, have mailed you a suggestion to solv the atags.
Just pass them on between the org firmware to uboot, just parse mem copy them to an uboot variable.
And then you can copy them together with your own bootargs variable in uboot.
I don't i programmer.. but what i can see. The atags from the firmware are held in memmory at
0x12c to the two spaces, and then follow the cmdline.txt file and if no file... then default params/args.

Code: Select all

U-Boot> md 0x12c
0000012c: 2e616d64 63616d64 736e6168 3778303d    dma.dmachans=0x7
0000013c: 20353366 326d6362 5f383037 662e6266    f35 bcm2708_fb.f
0000014c: 64697762 363d6874 62203635 37326d63    bwidth=656 bcm27
0000015c: 665f3830 62662e62 67696568 343d7468    08_fb.fbheight=4
0000016c: 62203631 37326d63 622e3830 6472616f    16 bcm2708.board
Last edited by patrikg on Wed Mar 30, 2016 8:35 am, edited 1 time in total.

Electron752
Posts: 142
Joined: Mon Mar 02, 2015 7:09 pm

Re: Entering aarch64 execution state

Wed Mar 30, 2016 12:37 am

OK, I must be missing something very obvious. I still can't get it to work. This is my complete config.txt.

Code: Select all

dtoverlay=pi3-miniuart-bt
force_turbo=1
enable_uart=1
kernel=u-boot.bin
kernel_old=1
arm_control=0x200
disable_commandline_tags=1
Again, I'm not seeing anything at all on the serial port.

Questions:

1. Where is the "lastest" firmware? I'm getting mine from https://github.com/raspberrypi/firmware. I've tried both the "master" branch and the "next" branch. Neither one works. Which one should I be using and where should I be getting the firmware from?

2. Like I said, I can completely get u-boot to work from the keyboard and the display. Does u-boot also print anything to the serial port in addition to the display? I'm not seeing anything from u-boot either. I'm trying to rule out the linux kernel being broken.

User avatar
DavidWang
Posts: 4
Joined: Tue Mar 29, 2016 6:58 am

Re: Entering aarch64 execution state

Wed Mar 30, 2016 1:50 am

swarren wrote:
DavidWang wrote:Can I use ARM-Trusted Firmware as the first stage bootloader running @EL3?
I would expect so, but you'd need to port ATF to the system. You'd need to use "kernel_old=1" in config.txt and make ATF handle the SMP CPU pinnning/bootup, and know how to receive ATAGS/DT from the VC FW and pass them on to the rest of the SW stack, etc.
I'm new to Raspberry Pi and BCM chip.
But I'd like to try to port ATF to RPi3.
When can I get the documents about the booting flow of BCM chip? Thanks.

dwelch67
Posts: 939
Joined: Sat May 26, 2012 5:32 pm

Re: Entering aarch64 execution state

Wed Mar 30, 2016 2:45 am

If you are wanting aarch64 then there are documents, the ARM cortex-a8 ARM and TRM (infocenter.arm.com). One or more settings in config.txt tell the GPU not to prepare a bootstrap for the arm just copy kernel7.img to 0x0000 and release reset (on all four cores).

All the raspberry pis boot the same. The GPU boots first, running bootcode.bin then start.elf from the sd card. If it finds config.txt entries in there can alter the way it boots, if it is not altered (for example if there is no config.txt file). Then it copies the kernel.img (pi1 flavors) or kernel7.img (pi2 and pi3) to 0x8000, it places some bootstrap code at address 0x0000 and releases reset on the ARM (all four cores for the pi2 and pi3, just the one for the pi1 flavors). That bootstrap does a little prep for running linux, putting the arm in a state that they want then branches to 0x8000 (with core0 if four cores, the other three are held in a loop waiting to be told what to run). You can easily write or borrow one of our bare metal programs to dump out the contents of that 0x0000 memory then disassemble to see what is going on. It is perhaps on their github or other site anyway. And definitely in these forums more than one of us have dumped and disassembled it.

But again if you want aarch64 then you cannot let the GPU run you into that bootstrap as for the pi3 it puts it in aarch32 mode, and my understanding from comments in this forum is you cant go back to aarch64. So you have to do the config.txt kernel old thing and you have to manage the four cores booting the same code at the same time and separate them. I have some simple examples as do other folks.

David

swarren
Posts: 45
Joined: Tue Mar 01, 2016 5:56 am

Re: Entering aarch64 execution state

Wed Mar 30, 2016 4:20 am

Electron752 wrote:OK, I must be missing something very obvious. I still can't get it to work. This is my complete config.txt.

Code: Select all

dtoverlay=pi3-miniuart-bt
force_turbo=1
You probably want to remove those lines. I don't know about the other AArch64 U-Boot ports, but mine uses the mini UART. If you want to use the PL011 UART you'll currently have to edit the source code to switch it over.
Electron752 wrote:1. Where is the "lastest" firmware? I'm getting mine from https://github.com/raspberrypi/firmware.
That's the right place.
Electron752 wrote:2. Like I said, I can completely get u-boot to work from the keyboard and the display. Does u-boot also print anything to the serial port in addition to the display? I'm not seeing anything from u-boot either. I'm trying to rule out the linux kernel being broken.
Yes, everything that's shown on the LCD (and more early boot messages) are sent to the UART too.

Return to “Bare metal, Assembly language”

Who is online

Users browsing this forum: No registered users and 4 guests