Jump to content
DaveWK

U-Boot for Fedora support?

Recommended Posts

Hi,

I've been attempting to get Fedora aarch64 to work with the tinkerboard 2. In order to do so, it seems like I need to somehow modify the u-boot to properly handle the layout that fedora sets up in it's images.

It seems like the current u-boot config is not set up to find the FDT in the layout, and has some hardcoded values for partitions which are very inflexible. Previously on rk3328 boards I was able to use this:

https://pagure.io/arm-image-installer/blob/main/f/socs.d/Rockchips-ARMv8

to get it to flash the EMMC in the proper places for u-boot, but this has not worked on the Tinkerboard 2 for me..

 

For reference, fedora has a patch here:

https://src.fedoraproject.org/rpms/uboot-tools/blob/rawhide/f/uefi-distro-load-FDT-from-any-partition-on-boot-device.patch

which should allow it to scan for the FDT and load the EFI, however I have been having trouble porting the u-boot configuration that is in the Tinkerboard2 git repo to a more modern version. I was wondering if anyone has had any success in setting up a Tinkerboard 2 config in the mainline u-boot repo, or if there might be a compatible variant already there? I tried using rk3399-evb, however this is configured to use DDR3 and does not boot successfully.

 

I was also wondering about if it would be an easier approach to modify the u-boot in the github repo for tinkerboard2 to point to the correct partition layout for a fedora install and copy the dtb into the image somehow, hot have not been able to get this to work either.

 

Share this post


Link to post
Share on other sites

It seems like the u-boot supplied by fedora for roc-pc-rk3399 is very close to what would be needed for a mainline u-boot release. I was successfully able to boot fedora from the MMC using the following steps:

- On an x86 installer machine (running fedora) install the uboot-tools package (https://src.fedoraproject.org/rpms/uboot-tools/tree/rawhide), uboot-images-armv8 package (https://packages.fedoraproject.org/pkgs/uboot-tools/uboot-images-armv8/ ) losetup, and rkdeveloptool package (all available in the standard fedora repo)

- Download a Fedora raw image aarch64, and extract it to a .img file. for this example I am using Fedora-Minimal-36-1.5.aarch64.raw

- Run "losetup /dev/loop0 Fedora-Minimal-36-1.5.aarch64.raw" to make a loopback device for the image. Run gparted on the loopback device ("gparted /dev/loop0") and resize the partitions which overlap with idbloader.img and u-boot.itb. Close gparted and run "gdisk /dev/loop0" to convert the MBR to a GPT partition. Unmount the loopback device.

- Put the jumper in the tinkerboard to boot into MASKROM. After it is turned on and seen by the OS, put the jumper back to the normal position. Run "rkdeveloptool db rk3399_loader_v1.20.119.bin" as root, substituting for the rk3399 loader you are using. You must swap the jumper while it is on or else it will not flash the mmc.

- cd to "/usr/share/uboot/roc-pc-rk3399" on the host machine. Run "rkdeveloptool wl 0x0 Fedora-Minimal-36-1.5.aarch64.raw" as root where the .raw image is the one that you edited with the loopback device. at this time you should now see the partitions when you run "rkdeveloptool ppt".

- Run "rkdeveloptool wl 0x40 idbloader.img" and then "rkdeveloptool wl 0x4000 u-boot.itb" from the "/usr/share/uboot/roc-pc-rk3399"  directory as root.

- Reboot the device. Be sure to have a serial usb attached.

At this point, it will boot into Fedora successfully. Unfortunately, due to differences in the device dtb, there is no USB or ethernet support, however the Serial connection does work, so you can use the keyboard via the serial connection.

This is where I am stuck. It's unfortunate because it does seem to boot very quickly, and has a very solid HDMI connection, so this would be a great OS to use with a modern 5.xx kernel. Any tips to get this working the rest of the way?

Share this post


Link to post
Share on other sites

hi dave. i came across this because i'm also interested in doing the same. (but fedeora server instead). any luck to get this to work? the asus engineers just came out with kernel 5.10 in Oct 2023.

Share this post


Link to post
Share on other sites

hi @DaveWK, I managed to resolve this with ideas about your post. you'll have to rebuild idbloader, uboot, kernel. and put them in the correct sector location.

# Partition format to follow
| Partition No. | Name      | Sector Start | Sector End | Size  | Comments                 |
|---------------|-----------|--------------|------------|-------|--------------------------|
| -             | idbloader | 64           | 16383      |       | first stage boot loader  |
| 1             | uboot     | 16384        | 24575      | 4mb   | second stage boot loader |
| 2             | trust     | 24576        | 32767      | 4mb   | linux / android trust    |
| 3             | misc      | 32768        | 40959      | 4mb   | for misc inputs          |
| 4             | boot      | 40960        | 172031     | 64mb  | linux kernel boot        |
| 5             | userdata  | 172032       | 303103     | 64mb  | for kernel boot elements |
| 6             | rootfs    | 303104       | ~          | ~     | core linux OS            |

Then use dd command to extract out fedora rootfs from .raw file into an image file (similar to what you have done above)

Note: when compiling uboot, you'll need to amend the hardcoded section where it looks for rootfs. see this: here

Finally, use dd to write them all in. and it'll boot up perfectly!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...