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

Add support for Raspberry Pi 3 B plus #358

Merged
merged 1 commit into from Jun 28, 2019

Conversation

johnphilby
Copy link

Make use of the PLATFORM variable to set the specific
target being used "rpi3-b" or "rpi3-bplus".

Signed-off-by: Philby John philby.j@hcl.com
Signed-off-by: Vv Ramya ramyavv@hcl.com

rpi3.mk Outdated
@@ -11,7 +11,8 @@ override COMPILE_S_KERNEL := 64
# Need to set this before including common.mk
BUILDROOT_GETTY_PORT ?= ttyS0
BR2_ROOTFS_POST_BUILD_SCRIPT ?= "board/raspberrypi3-64/post-build.sh"

#For Raspberry Pi 3 B plus set to rpi3-bplus
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add space after #.

rpi3.mk Outdated
@@ -11,7 +11,8 @@ override COMPILE_S_KERNEL := 64
# Need to set this before including common.mk
BUILDROOT_GETTY_PORT ?= ttyS0
BR2_ROOTFS_POST_BUILD_SCRIPT ?= "board/raspberrypi3-64/post-build.sh"

#For Raspberry Pi 3 B plus set to rpi3-bplus
PLATFORM ?= rpi3-b
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I saw a comment from you somewhere that you couldn't use the composite form? Or did I mix that up? What I'm looking for here is something like

PLATFORM=rpi-3b
PLATFORM=rpi-3bplus

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Platform directory in optee_os is core/arch/arm/plat-rpi3 so PLATFORM has to be rpi3 and PLATFORM_FLAVOR may be whatever we want (for instance b or bplus).
The consequence is, the "composite" form of PLATFORM is written rpi3-something.

https://github.com/OP-TEE/optee_os/blob/master/Makefile#L32-L33

Another option would be to rename core/arch/arm/plat-rpi3 to core/arch/arm/plat-rpi, but since all variants are still 3 more or less, would it be justified?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option would be to rename core/arch/arm/plat-rpi3 to core/arch/arm/plat-rpi, but since all variants are still 3 more or less, would it be justified?

I was thinking about the same. My initial thought was to leave the rpi3-... and start using rpi-... instead. But as long as it's only rpi3 devices we have, it might be more work than we gain by doing so. In that case, use what I think I proposed in the other github issue about this:

PLATFORM=rpi3-b
PLATFORM=rpi3-bplus

rpi3.mk Outdated
@@ -31,13 +32,21 @@ RPI3_BOOT_CONFIG ?= $(RPI3_FIRMWARE_PATH)/config.txt
RPI3_UBOOT_ENV ?= $(ROOT)/out/uboot.env
RPI3_UBOOT_ENV_TXT ?= $(RPI3_FIRMWARE_PATH)/uboot.env.txt
RPI3_STOCK_FW_PATH ?= $(ROOT)/firmware
RPI3_STOCK_FW_PATH_BOOT ?= $(RPI3_STOCK_FW_PATH)/boot
ifeq ($(PLATFORM),rpi3-b)
RPI3_STOCK_FW_PATH_BOOT ?= $(RPI3_STOCK_FW_PATH)/boot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When first looking at this I ask myself why does this have to be on different paths (line 36 and 38, besides the PLATFORM)? I guess you didn't want to deal with the "firmware" git? In that case I believe it's better to actually create another xml/manifest file for Rpi3-b+.

rpi3.mk Outdated
ifeq ($(PLATFORM),rpi3-b)
LINUX_DTB ?= $(LINUX_PATH)/arch/arm64/boot/dts/broadcom/bcm2710-rpi-3-b.dtb
else
LINUX_DTB ?= $(LINUX_PATH)/arch/arm64/boot/dts/broadcom/bcm2710-rpi-3-b-plus.dtb
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good, but I noticed that the same dtb is showing up on several places, which might be a bit confusing. We should try clean that up at some point in the future.

$ find . -name "bcm2710-rpi-3-b.dtb"
./build/rpi3/firmware/rpi3-bplus/bcm2710-rpi-3-b.dtb
./linux/arch/arm64/boot/dts/broadcom/bcm2710-rpi-3-b.dtb
./firmware/boot/bcm2710-rpi-3-b.dtb
./out-br/target/boot/bcm2710-rpi-3-b.dtb

$ find . -name "bcm2710-rpi-3-b-plus.dtb"
./build/rpi3/firmware/rpi3-bplus/bcm2710-rpi-3-b-plus.dtb
./linux/arch/arm64/boot/dts/broadcom/bcm2710-rpi-3-b-plus.dtb

rpi3.mk Outdated
@@ -147,10 +156,18 @@ linux-cleaner: linux-cleaner-common
################################################################################
# OP-TEE
################################################################################
OPTEE_OS_COMMON_FLAGS += PLATFORM=rpi3
ifeq ($(PLATFORM),rpi3-b)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 159 to 162: Please update to the platform names as I proposed further up.

rpi3.mk Outdated
@@ -179,6 +197,24 @@ update_rootfs: arm-tf linux u-boot
@install -v -p --mode=755 $(RPI3_STOCK_FW_PATH)/boot/start_db.elf $(BUILDROOT_TARGET_ROOT)/boot/start_db.elf
@install -v -p --mode=755 $(RPI3_STOCK_FW_PATH)/boot/start.elf $(BUILDROOT_TARGET_ROOT)/boot/start.elf
@install -v -p --mode=755 $(RPI3_STOCK_FW_PATH)/boot/start_x.elf $(BUILDROOT_TARGET_ROOT)/boot/start_x.elf
else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This else is almost unnecessary with exception of a few files. If we put all files under a common path where only $(PLATFORM) makes them different, then there should be almost no need for if/else.

@@ -0,0 +1,356 @@

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to get GPL-v2 files in this git, which even more justifies creating another manifest to just clone the firmware (as done already today), instead of copy files like this.

@@ -0,0 +1,30 @@
Copyright (c) 2006, Broadcom Corporation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, this belongs to the firmware.git instead.

@@ -0,0 +1,3 @@
enable_uart=1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This belongs here, only thing is to change it to my proposed platform name instead rpi-3bplus.

@igoropaniuk
Copy link
Contributor

@johnphilby Please remove kernel8.img, armstub8.bin, uboot.env and *.dtbs, as they also are being built (Linux kernel, TF-A and U-boot accordingly)

And you also don't need another copy of rpi3 firmware binaries, as the one for RPi3-B also works for RPi3-B-Plus. You can just do what Joakim suggested, creating a separate repo manifest for rpi3b-plus (and using the same link from https://github.com/OP-TEE/manifest/blob/master/rpi3.xml#L25)

@johnphilby
Copy link
Author

@jbech-linaro and @igoropaniuk thank you for your review comments. I will incorporate them and resubmit again.

@johnphilby
Copy link
Author

@jbech-linaro @igoropaniuk I think I have addressed your comments. Created a new manifest for supporting RPi3 B Plus. Please review the commits from both the "manifest" and "build" repo.

OP-TEE/manifest#134

@jbech-linaro
Copy link
Contributor

This all looks good, having that said, the only difference compared to the original rpi3.mk file are two lines pointing to the DTB file. Therefore I'd like to get your opinion about eventually sharing the same Makefile for both flavors. I.e., we could select either one (see "Suggestion one" below) depending on the platform or ... we simply just include the DTB for both platforms (see "Suggestion two" below). It's not the end of the day if there is an unused DTB laying around if it otherwise simplifies things a lot. Having that said, the latter idea can only be used of both DTB's actually are being compiled when building the kernel, which after thinking about it I believe is not the case.

The downside with both of my proposals are that the user must not forget to set the PLATFORM flag when building for RPi3 B-plus which is something that we doesn't really do for other OP-TEE full developer builds.

In any case, I'm happy with it is as it is here also, we can refactor the makefiles at a later point also to better share common parts (ti/ti-common.mk is probably the best to compare with).

Reviewed-by: Joakim Bech <joakim.bech@linaro.org>

Suggestion one:

diff --git a/rpi3.mk b/rpi3.mk
index e172571..d7918c5 100644
--- a/rpi3.mk
+++ b/rpi3.mk
@@ -37,9 +37,17 @@ OPTEE_BIN_EXTRA1	?= $(OPTEE_PATH)/out/arm/core/tee-pager_v2.bin
 OPTEE_BIN_EXTRA2	?= $(OPTEE_PATH)/out/arm/core/tee-pageable_v2.bin
 
 LINUX_IMAGE		?= $(LINUX_PATH)/arch/arm64/boot/Image
+
+ifeq ($(PLATFORM),rpi3-bplus)
+LINUX_DTB		?= $(LINUX_PATH)/arch/arm64/boot/dts/broadcom/bcm2710-rpi-3-b-plus.dtb
+$(info "Building RPi3-bplus")
+else
 LINUX_DTB		?= $(LINUX_PATH)/arch/arm64/boot/dts/broadcom/bcm2710-rpi-3-b.dtb
+$(info "Building RPi3b (default)")
+endif
 MODULE_OUTPUT		?= $(ROOT)/module_output
 
+
 ################################################################################
 # Targets
 ################################################################################
@@ -163,7 +171,11 @@ buildroot: update_rootfs
 update_rootfs: arm-tf linux u-boot
 	@mkdir -p --mode=755 $(BUILDROOT_TARGET_ROOT)/boot
 	@mkdir -p --mode=755 $(BUILDROOT_TARGET_ROOT)/usr/bin
+ifeq ($(PLATFORM),rpi3-bplus)
+	@install -v -p --mode=755 $(LINUX_DTB) $(BUILDROOT_TARGET_ROOT)/boot/bcm2710-rpi-3-b-plus.dtb
+else
 	@install -v -p --mode=755 $(LINUX_DTB) $(BUILDROOT_TARGET_ROOT)/boot/bcm2710-rpi-3-b.dtb
+endif
 	@install -v -p --mode=755 $(RPI3_BOOT_CONFIG) $(BUILDROOT_TARGET_ROOT)/boot/config.txt
 	@install -v -p --mode=755 $(LINUX_IMAGE) $(BUILDROOT_TARGET_ROOT)/boot/kernel8.img
 	@install -v -p --mode=755 $(ARM_TF_BOOT) $(BUILDROOT_TARGET_ROOT)/boot/armstub8.bin

Suggestion two:

diff --git a/rpi3.mk b/rpi3.mk
index e172571..4272cb2 100644
--- a/rpi3.mk
+++ b/rpi3.mk
@@ -37,9 +37,12 @@ OPTEE_BIN_EXTRA1	?= $(OPTEE_PATH)/out/arm/core/tee-pager_v2.bin
 OPTEE_BIN_EXTRA2	?= $(OPTEE_PATH)/out/arm/core/tee-pageable_v2.bin
 
 LINUX_IMAGE		?= $(LINUX_PATH)/arch/arm64/boot/Image
-LINUX_DTB		?= $(LINUX_PATH)/arch/arm64/boot/dts/broadcom/bcm2710-rpi-3-b.dtb
+
+LINUX_DTB_RPI3B		?= $(LINUX_PATH)/arch/arm64/boot/dts/broadcom/bcm2710-rpi-3-b.dtb
+LINUX_DTB_RPI3BPLUS	?= $(LINUX_PATH)/arch/arm64/boot/dts/broadcom/bcm2710-rpi-3-b-plus.dtb
 MODULE_OUTPUT		?= $(ROOT)/module_output
 
+
 ################################################################################
 # Targets
 ################################################################################
@@ -163,7 +166,8 @@ buildroot: update_rootfs
 update_rootfs: arm-tf linux u-boot
 	@mkdir -p --mode=755 $(BUILDROOT_TARGET_ROOT)/boot
 	@mkdir -p --mode=755 $(BUILDROOT_TARGET_ROOT)/usr/bin
-	@install -v -p --mode=755 $(LINUX_DTB) $(BUILDROOT_TARGET_ROOT)/boot/bcm2710-rpi-3-b.dtb
+	@install -v -p --mode=755 $(LINUX_DTB_RPI3B) $(BUILDROOT_TARGET_ROOT)/boot/bcm2710-rpi-3-b.dtb
+	@install -v -p --mode=755 $(LINUX_DTB_RPI3BPLUS) $(BUILDROOT_TARGET_ROOT)/boot/bcm2710-rpi-3-b-plus.dtb
 	@install -v -p --mode=755 $(RPI3_BOOT_CONFIG) $(BUILDROOT_TARGET_ROOT)/boot/config.txt
 	@install -v -p --mode=755 $(LINUX_IMAGE) $(BUILDROOT_TARGET_ROOT)/boot/kernel8.img
 	@install -v -p --mode=755 $(ARM_TF_BOOT) $(BUILDROOT_TARGET_ROOT)/boot/armstub8.bin

@igoropaniuk
Copy link
Contributor

@jbech-linaro my two cents:
I thinkthat just copying 2 dtbs (For RPi3 and RPi3B plus) makes the deal and is the most simple solution here that works. I'll vote for this

@jbech-linaro
Copy link
Contributor

@jbech-linaro my two cents:
I thinkthat just copying 2 dtbs (For RPi3 and RPi3B plus) makes the deal and is the most simple solution here that works. I'll vote for this

Yeah, I guess that this is the better solution as of now, but that requires that both dtb's are there. I believe the install command will complain otherwise.

@igoropaniuk
Copy link
Contributor

@jbech-linaro AFAIK, they are already in the same rpi3 firmware tarball (there is no need to download something else), so anyway you can just copy both after unpacking the archive.

@jbech-linaro
Copy link
Contributor

I see, well, then it's a no brainer I guess.

@johnphilby
Copy link
Author

@jbech-linaro my two cents:
I thinkthat just copying 2 dtbs (For RPi3 and RPi3B plus) makes the deal and is the most simple solution here that works. I'll vote for this

@jbech-linaro In lieu of this comment and our common consensus that it is cleaner to just copy both the dtbs, I have updated the pull request.

To sum up:
a) we will avoid creating another rpi3-bplus makefile.
b) we will also avoid creating an extra manifest file too.

Please take a look.

f4ad1e3

OP-TEE/manifest@397ab27

@IKyriazis
Copy link

I am able to restart the job. I am letting you know because I don't know if it is intended for random people to have that permission.

@jbech-linaro
Copy link
Contributor

I am able to restart the job. I am letting you know because I don't know if it is intended for random people to have that permission.

@IKyriazis I'm well aware of that and as long as it isn't misused I'm going to leave it like that. But if there is someone starting to misuse it, then I'll have to remove that ability for non-trusted users. Anyhow, thanks for mentioning this!

@jbech-linaro
Copy link
Contributor

@johnphilby , sorry for the late reply, this is looking good to me.
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>

@jforissier
Copy link
Contributor

@johnphilby, would you please squash the 3 commits into one and add @jbech-linaro's Reviewed-by tag?
Then I can merge this PR.

@johnphilby
Copy link
Author

@johnphilby, would you please squash the 3 commits into one and add @jbech-linaro's Reviewed-by tag?
Then I can merge this PR.

Sure. Doing that right now.

@jbech-linaro
Copy link
Contributor

FYI, as part of testing for 3.6.0, I'm doing a test build with this PR.

@jbech-linaro
Copy link
Contributor

FYI, as part of testing for 3.6.0, I'm doing a test build with this PR.

With the patches applied on master.

+-----------------------------------------------------
24078 subtests of which 0 failed
95 test cases of which 0 failed
0 test cases were skipped
TEE test application done!

So, if tags haven't already been applied you can add my TB also.
Tested-by: Joakim Bech <joakim.bech@linaro.org> (rpi3b)

@jforissier
Copy link
Contributor

@jbech-linaro why is IBART failing? Wrong cross-compiler version?

14089:  Incorrect selection of kernel headers: expected 4.18.x, got 4.19.x

@johnphilby
Copy link
Author

Tested-by: Joakim Bech joakim.bech@linaro.org

I will add this as well. I am just trying out this interactive rebase thingy. Did not get it right. Trying again. Apparently, "--autosquash" isn't working as I would like it to.

Copy both RPi3 B and RPi3 B Plus dtb files to enable
booting both the targets. This will avoid adding a seperate
rpi3-bplus makefile.

Signed-off-by: Philby John <philby.j@hcl.com>
Signed-off-by: Vv Ramya <ramyavv@hcl.com>
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Tested-by: Joakim Bech <joakim.bech@linaro.org> # (rpi3b)
@johnphilby
Copy link
Author

Guess I got it right this time.

Please verify and merge.

johnphilby@1c0e779

and

johnphilby/manifest@6379790

@jbech-linaro
Copy link
Contributor

@jbech-linaro why is IBART failing? Wrong cross-compiler version?

14089:  Incorrect selection of kernel headers: expected 4.18.x, got 4.19.x

It's because @johnphilby branch is a bit old, it needs a rebase so it gets my related patches onto his own branch (6e167bf and e029816).

@jforissier
Copy link
Contributor

It's because @johnphilby branch is a bit old,

OK, then I guess all is well. Let's merge this. Thanks!

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

Successfully merging this pull request may close these issues.

None yet

5 participants