grub: Add support for RISC-V

Submitted by Norbert Kaminski on Nov. 25, 2020, 5:22 p.m. | Patch ID: 178183

Details

Message ID 20201125172249.1067599-1-norbert.kaminski@3mdeb.com
State Accepted
Commit 42ea75d441ae38cdffed3b1cd671af886c19fbb6
Headers show

Commit Message

Norbert Kaminski Nov. 25, 2020, 5:22 p.m.
This patch adds RISC-V to the COMPATIBLE_HOST. Since GRUB 2.04,
the source code supports the RISC-V, thanks to Alexander Graf.

Adding the GRUBPLATFORM for RISC-V prevents autoconf problems.
Also, the patch appends the __anonymous method with RISC-V architecture.

Signed-off-by: Norbert Kaminski <norbert.kaminski@3mdeb.com>

---
 meta/recipes-bsp/grub/grub-efi_2.04.bb | 4 ++++
 meta/recipes-bsp/grub/grub2.inc        | 4 +++-
 2 files changed, 7 insertions(+), 1 deletion(-)

-- 
2.25.1
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#144989): https://lists.openembedded.org/g/openembedded-core/message/144989
Mute This Topic: https://lists.openembedded.org/mt/78504567/1003190
Group Owner: openembedded-core+owner@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [mhalstead@linuxfoundation.org]
-=-=-=-=-=-=-=-=-=-=-=-

Patch hide | download patch | download mbox

diff --git a/meta/recipes-bsp/grub/grub-efi_2.04.bb b/meta/recipes-bsp/grub/grub-efi_2.04.bb
index 30d95f95e0..f80afd95cb 100644
--- a/meta/recipes-bsp/grub/grub-efi_2.04.bb
+++ b/meta/recipes-bsp/grub/grub-efi_2.04.bb
@@ -26,6 +26,10 @@  python __anonymous () {
         grubtarget = 'arm64'
     elif re.match('arm', target):
         grubtarget = 'arm'
+    elif re.match('riscv64', target):
+        grubtarget = 'riscv64'
+    elif re.match('riscv32', target):
+        grubtarget = 'riscv32'
     else:
         raise bb.parse.SkipRecipe("grub-efi is incompatible with target %s" % target)
     grubimage = prefix + d.getVar("EFI_BOOT_IMAGE")
diff --git a/meta/recipes-bsp/grub/grub2.inc b/meta/recipes-bsp/grub/grub2.inc
index ff17dbe8b7..d020103605 100644
--- a/meta/recipes-bsp/grub/grub2.inc
+++ b/meta/recipes-bsp/grub/grub2.inc
@@ -33,7 +33,7 @@  SRC_URI[sha256sum] = "f10c85ae3e204dbaec39ae22fa3c5e99f0665417e91c2cb49b7e503165
 
 DEPENDS = "flex-native bison-native gettext-native"
 
-COMPATIBLE_HOST = '(x86_64.*|i.86.*|arm.*|aarch64.*)-(linux.*|freebsd.*)'
+COMPATIBLE_HOST = '(x86_64.*|i.86.*|arm.*|aarch64.*|riscv.*)-(linux.*|freebsd.*)'
 COMPATIBLE_HOST_armv7a = 'null'
 COMPATIBLE_HOST_armv7ve = 'null'
 
@@ -42,6 +42,8 @@  COMPATIBLE_HOST_armv7ve = 'null'
 
 GRUBPLATFORM_arm = "efi"
 GRUBPLATFORM_aarch64 = "efi"
+GRUBPLATFORM_riscv32 = "efi"
+GRUBPLATFORM_riscv64 = "efi"
 GRUBPLATFORM ??= "pc"
 
 inherit autotools gettext texinfo pkgconfig

Comments

Khem Raj Nov. 25, 2020, 6:54 p.m.
Thanks for your contribution.

On Wed, Nov 25, 2020 at 9:23 AM Norbert Kaminski
<norbert.kaminski@3mdeb.com> wrote:
>

> This patch adds RISC-V to the COMPATIBLE_HOST. Since GRUB 2.04,

> the source code supports the RISC-V, thanks to Alexander Graf.

>

> Adding the GRUBPLATFORM for RISC-V prevents autoconf problems.

> Also, the patch appends the __anonymous method with RISC-V architecture.

>

> Signed-off-by: Norbert Kaminski <norbert.kaminski@3mdeb.com>

> ---

>  meta/recipes-bsp/grub/grub-efi_2.04.bb | 4 ++++

>  meta/recipes-bsp/grub/grub2.inc        | 4 +++-

>  2 files changed, 7 insertions(+), 1 deletion(-)

>

> diff --git a/meta/recipes-bsp/grub/grub-efi_2.04.bb b/meta/recipes-bsp/grub/grub-efi_2.04.bb

> index 30d95f95e0..f80afd95cb 100644

> --- a/meta/recipes-bsp/grub/grub-efi_2.04.bb

> +++ b/meta/recipes-bsp/grub/grub-efi_2.04.bb

> @@ -26,6 +26,10 @@ python __anonymous () {

>          grubtarget = 'arm64'

>      elif re.match('arm', target):

>          grubtarget = 'arm'

> +    elif re.match('riscv64', target):

> +        grubtarget = 'riscv64'

> +    elif re.match('riscv32', target):

> +        grubtarget = 'riscv32'


RV64 is file but does it also support RV32 ?

>      else:

>          raise bb.parse.SkipRecipe("grub-efi is incompatible with target %s" % target)

>      grubimage = prefix + d.getVar("EFI_BOOT_IMAGE")

> diff --git a/meta/recipes-bsp/grub/grub2.inc b/meta/recipes-bsp/grub/grub2.inc

> index ff17dbe8b7..d020103605 100644

> --- a/meta/recipes-bsp/grub/grub2.inc

> +++ b/meta/recipes-bsp/grub/grub2.inc

> @@ -33,7 +33,7 @@ SRC_URI[sha256sum] = "f10c85ae3e204dbaec39ae22fa3c5e99f0665417e91c2cb49b7e503165

>

>  DEPENDS = "flex-native bison-native gettext-native"

>

> -COMPATIBLE_HOST = '(x86_64.*|i.86.*|arm.*|aarch64.*)-(linux.*|freebsd.*)'

> +COMPATIBLE_HOST = '(x86_64.*|i.86.*|arm.*|aarch64.*|riscv.*)-(linux.*|freebsd.*)'

>  COMPATIBLE_HOST_armv7a = 'null'

>  COMPATIBLE_HOST_armv7ve = 'null'

>

> @@ -42,6 +42,8 @@ COMPATIBLE_HOST_armv7ve = 'null'

>

>  GRUBPLATFORM_arm = "efi"

>  GRUBPLATFORM_aarch64 = "efi"

> +GRUBPLATFORM_riscv32 = "efi"

> +GRUBPLATFORM_riscv64 = "efi"

>  GRUBPLATFORM ??= "pc"

>

>  inherit autotools gettext texinfo pkgconfig

> --

> 2.25.1

>

>

> 

>
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#144990): https://lists.openembedded.org/g/openembedded-core/message/144990
Mute This Topic: https://lists.openembedded.org/mt/78504567/1003190
Group Owner: openembedded-core+owner@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [mhalstead@linuxfoundation.org]
-=-=-=-=-=-=-=-=-=-=-=-
Norbert Kaminski Nov. 26, 2020, 3:17 p.m.
On 25.11.2020 19:54, Khem Raj wrote:
> Thanks for your contribution.

>

> On Wed, Nov 25, 2020 at 9:23 AM Norbert Kaminski

> <norbert.kaminski@3mdeb.com> wrote:

>> This patch adds RISC-V to the COMPATIBLE_HOST. Since GRUB 2.04,

>> the source code supports the RISC-V, thanks to Alexander Graf.

>>

>> Adding the GRUBPLATFORM for RISC-V prevents autoconf problems.

>> Also, the patch appends the __anonymous method with RISC-V architecture.

>>

>> Signed-off-by: Norbert Kaminski <norbert.kaminski@3mdeb.com>

>> ---

>>   meta/recipes-bsp/grub/grub-efi_2.04.bb | 4 ++++

>>   meta/recipes-bsp/grub/grub2.inc        | 4 +++-

>>   2 files changed, 7 insertions(+), 1 deletion(-)

>>

>> diff --git a/meta/recipes-bsp/grub/grub-efi_2.04.bb b/meta/recipes-bsp/grub/grub-efi_2.04.bb

>> index 30d95f95e0..f80afd95cb 100644

>> --- a/meta/recipes-bsp/grub/grub-efi_2.04.bb

>> +++ b/meta/recipes-bsp/grub/grub-efi_2.04.bb

>> @@ -26,6 +26,10 @@ python __anonymous () {

>>           grubtarget = 'arm64'

>>       elif re.match('arm', target):

>>           grubtarget = 'arm'

>> +    elif re.match('riscv64', target):

>> +        grubtarget = 'riscv64'

>> +    elif re.match('riscv32', target):

>> +        grubtarget = 'riscv32'

> RV64 is file but does it also support RV32 ?

I see that there are some changes for RV32:

https://git.savannah.gnu.org/cgit/grub.git/tree/configure.ac?h=grub-2.04#n186

And I'm able to build the grub and grub-native package for RV32.
There is a problem with grub-mkimage for RV32 in grub-efi,
it fails with the error:

grub-mkimage: error: target 1f46 not reachable from pc=10b6.

This points to the line:
https://git.savannah.gnu.org/cgit/grub.git/tree/util/grub-mkimagexx.c?h=grub-2.04&id=3562536fd5e5cc3d40942f3e8ac53d4f0ee5c220#n1300

I guess for now, we should leave the support only for the RV64,
which is tested and works well.

>>       else:

>>           raise bb.parse.SkipRecipe("grub-efi is incompatible with target %s" % target)

>>       grubimage = prefix + d.getVar("EFI_BOOT_IMAGE")

>> diff --git a/meta/recipes-bsp/grub/grub2.inc b/meta/recipes-bsp/grub/grub2.inc

>> index ff17dbe8b7..d020103605 100644

>> --- a/meta/recipes-bsp/grub/grub2.inc

>> +++ b/meta/recipes-bsp/grub/grub2.inc

>> @@ -33,7 +33,7 @@ SRC_URI[sha256sum] = "f10c85ae3e204dbaec39ae22fa3c5e99f0665417e91c2cb49b7e503165

>>

>>   DEPENDS = "flex-native bison-native gettext-native"

>>

>> -COMPATIBLE_HOST = '(x86_64.*|i.86.*|arm.*|aarch64.*)-(linux.*|freebsd.*)'

>> +COMPATIBLE_HOST = '(x86_64.*|i.86.*|arm.*|aarch64.*|riscv.*)-(linux.*|freebsd.*)'

>>   COMPATIBLE_HOST_armv7a = 'null'

>>   COMPATIBLE_HOST_armv7ve = 'null'

>>

>> @@ -42,6 +42,8 @@ COMPATIBLE_HOST_armv7ve = 'null'

>>

>>   GRUBPLATFORM_arm = "efi"

>>   GRUBPLATFORM_aarch64 = "efi"

>> +GRUBPLATFORM_riscv32 = "efi"

>> +GRUBPLATFORM_riscv64 = "efi"

>>   GRUBPLATFORM ??= "pc"

>>

>>   inherit autotools gettext texinfo pkgconfig

>> --

>> 2.25.1

>>

>>

>> 

>>
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#145003): https://lists.openembedded.org/g/openembedded-core/message/145003
Mute This Topic: https://lists.openembedded.org/mt/78504567/3616849
Group Owner: openembedded-core+owner@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [michael@yoctoproject.org]
-=-=-=-=-=-=-=-=-=-=-=-