mbox series

[v4,0/9] Add RV64 NOMMU and Canaan K210 SoC support

Message ID 20210830044100.260173-1-damien.lemoal@wdc.com
Headers show
Series Add RV64 NOMMU and Canaan K210 SoC support | expand

Message

Damien Le Moal Aug. 30, 2021, 4:40 a.m. UTC
This series adds support for building 64-bits RISC-V NOMMU kernel
bootable images for boards using the dual-core RISC-V 64-bits Cannan
Kendryte K210 SoC.

The first patch adds support for RV64 to the elf2flt package.
Patch 2 changes the base name of the toolchain cross-compilation
executables to avoid build errors. With these preparatory patches in
place, patch 3 makes MMU build optional for RISC-V 64-bits.

The following 5 patches add default build configuration files for
various boards: MAIX-bit, MAIX-go, MAIX-dock (Dan Dock) and MAIXDUINO
from Sipeed and the Canaan KD233 development board.

Finally, patch 9 documents how to build and install images for these
boards.

Note about patch 1: Many comments have been made on the elf2flt pull
request. The elf2flt support needs to be reworked but may take some
time. Until this is rewrite is completed, if acceptable, please take
this patch as a temporary support.

Changes from v3:
* Rebased on latest tree

Changes from v2:
* Reorder patches: former patch 1 is now patch 3.
* Clearly state in the first 3 patch commit messages that the NOMMU
  support introduced is for RISC-V 64-bits only and does not affect
  RV32.
* Modify patch 3 to allow NOMMU builds only for RV64 as opposed to both
  RV32 and RV64 before.
* Add reference to upstream elf2flt pull request in patch 1.
* Simplify the configurations for all boards, keeping default settings
  when a special value is not needed (e.g. gcc version).
* Dropped busybox-tiny-initramfs.config configuration and replaced it
  with a busybox fragment configuration file updating the default
  busybox-minimal.config configuration (used now for all boards).
* Changed common k210 rootfs overlay to replace the default /init script
  with a symbolic link pointing to the overlay provided /sbin/init
  script.

Changes from v1:
* Rebased on latest master
* Simplified patch 3 as suggested by Baruch
* Fixed typos in documentation (patch 9)
* Added reviewed-by tags

Christoph Hellwig (2):
  package/elf2flt: add RISC-V 64-bits support
  package/Makefile.in: Fix NOMMU RISC-V 64-bits toolchain base name

Damien Le Moal (7):
  arch/config: Make RISC-V 64-bits MMU optional
  board: Add Sipeed MAIX-bit support
  board: Add Sipeed MAIX-Go support
  board: Add Sipeed MAIXDUINO support
  board: Add Sipeed MAIX-Dock support
  board: Add Canaan KD233 support
  board: Document Canaan K210 based boards support

 arch/Config.in                                |   1 -
 arch/Config.in.riscv                          |   2 +
 board/canaan/k210-common/README.md            | 318 ++++++++++++++++++
 board/canaan/k210-common/busybox-tiny.config  | 243 +++++++++++++
 board/canaan/k210-common/rootfs_overlay/init  |   1 +
 .../k210-common/rootfs_overlay/sbin/init      |  27 ++
 board/canaan/kd233/README.md                  |   4 +
 board/canaan/kd233/linux-dtb.config           |   2 +
 board/sipeed/maix-bit/README.md               |   4 +
 board/sipeed/maix-bit/linux-dtb.config        |   2 +
 board/sipeed/maix-dock/README.md              |   4 +
 board/sipeed/maix-dock/linux-dtb.config       |   2 +
 board/sipeed/maix-go/README.md                |   4 +
 board/sipeed/maix-go/linux-dtb.config         |   2 +
 board/sipeed/maixduino/README.md              |   4 +
 board/sipeed/maixduino/linux-dtb.config       |   2 +
 configs/canaan_kd233_defconfig                |  15 +
 configs/canaan_kd233_sdcard_defconfig         |  14 +
 configs/sipeed_maix_bit_defconfig             |  15 +
 configs/sipeed_maix_bit_sdcard_defconfig      |  14 +
 configs/sipeed_maix_dock_defconfig            |  15 +
 configs/sipeed_maix_dock_sdcard_defconfig     |  14 +
 configs/sipeed_maix_go_defconfig              |  15 +
 configs/sipeed_maix_go_sdcard_defconfig       |  14 +
 configs/sipeed_maixduino_defconfig            |  15 +
 configs/sipeed_maixduino_sdcard_defconfig     |  14 +
 package/Makefile.in                           |   5 +-
 ...04-elf2flt-add-riscv-64-bits-support.patch | 299 ++++++++++++++++
 package/elf2flt/Config.in.host                |   2 +-
 29 files changed, 1069 insertions(+), 4 deletions(-)
 create mode 100644 board/canaan/k210-common/README.md
 create mode 100644 board/canaan/k210-common/busybox-tiny.config
 create mode 120000 board/canaan/k210-common/rootfs_overlay/init
 create mode 100755 board/canaan/k210-common/rootfs_overlay/sbin/init
 create mode 100644 board/canaan/kd233/README.md
 create mode 100644 board/canaan/kd233/linux-dtb.config
 create mode 100644 board/sipeed/maix-bit/README.md
 create mode 100644 board/sipeed/maix-bit/linux-dtb.config
 create mode 100644 board/sipeed/maix-dock/README.md
 create mode 100644 board/sipeed/maix-dock/linux-dtb.config
 create mode 100644 board/sipeed/maix-go/README.md
 create mode 100644 board/sipeed/maix-go/linux-dtb.config
 create mode 100644 board/sipeed/maixduino/README.md
 create mode 100644 board/sipeed/maixduino/linux-dtb.config
 create mode 100644 configs/canaan_kd233_defconfig
 create mode 100644 configs/canaan_kd233_sdcard_defconfig
 create mode 100644 configs/sipeed_maix_bit_defconfig
 create mode 100644 configs/sipeed_maix_bit_sdcard_defconfig
 create mode 100644 configs/sipeed_maix_dock_defconfig
 create mode 100644 configs/sipeed_maix_dock_sdcard_defconfig
 create mode 100644 configs/sipeed_maix_go_defconfig
 create mode 100644 configs/sipeed_maix_go_sdcard_defconfig
 create mode 100644 configs/sipeed_maixduino_defconfig
 create mode 100644 configs/sipeed_maixduino_sdcard_defconfig
 create mode 100644 package/elf2flt/0004-elf2flt-add-riscv-64-bits-support.patch

Comments

Thomas Petazzoni Aug. 30, 2021, 9:32 p.m. UTC | #1
Hello Damien,

On Mon, 30 Aug 2021 13:40:51 +0900
Damien Le Moal <damien.lemoal@wdc.com> wrote:

> Christoph Hellwig (2):
>   package/elf2flt: add RISC-V 64-bits support
>   package/Makefile.in: Fix NOMMU RISC-V 64-bits toolchain base name
> 
> Damien Le Moal (7):
>   arch/config: Make RISC-V 64-bits MMU optional

Just tested with the first 3 patches applied the following defconfig:

BR2_riscv=y
# BR2_USE_MMU is not set

It fails to build with:

/home/thomas/buildroot/buildroot/output/host/riscv64-buildroot-linux-uclibc/bin/elf2flt: Loading to RAM ('-r' option) 
is required

This is using the default Busybox configuration, i.e
package/busybox/busybox.config. I haven't tested if other noMMU
architectures exhibit the same issue.

The package/busybox/busybox-minimal.config causes the same issue.

I'm gonna try on ARM noMMU and see.

Best regards,

Thomas
Damien Le Moal Aug. 30, 2021, 9:42 p.m. UTC | #2
On 2021/08/31 6:32, Thomas Petazzoni wrote:
> Hello Damien,
> 
> On Mon, 30 Aug 2021 13:40:51 +0900
> Damien Le Moal <damien.lemoal@wdc.com> wrote:
> 
>> Christoph Hellwig (2):
>>   package/elf2flt: add RISC-V 64-bits support
>>   package/Makefile.in: Fix NOMMU RISC-V 64-bits toolchain base name
>>
>> Damien Le Moal (7):
>>   arch/config: Make RISC-V 64-bits MMU optional
> 
> Just tested with the first 3 patches applied the following defconfig:
> 
> BR2_riscv=y
> # BR2_USE_MMU is not set
> 
> It fails to build with:
> 
> /home/thomas/buildroot/buildroot/output/host/riscv64-buildroot-linux-uclibc/bin/elf2flt: Loading to RAM ('-r' option) 
> is required

Yes, this option is mandatory for rv64. The elf2flt patch checks for it, but
only for rv64. Other architectures should not be affected.
The following patch that adds the Sipeed MAIX bit board support adds that option
to busybox build. So I guess that build option should be moved to this patch ?

To be frank, I did not test generic nommu rv64 builds. I should have...

> 
> This is using the default Busybox configuration, i.e
> package/busybox/busybox.config. I haven't tested if other noMMU
> architectures exhibit the same issue.
> 
> The package/busybox/busybox-minimal.config causes the same issue.
> 
> I'm gonna try on ARM noMMU and see.
> 
> Best regards,
> 
> Thomas
>
Thomas Petazzoni Aug. 30, 2021, 9:52 p.m. UTC | #3
Hello Damien,

On Mon, 30 Aug 2021 23:32:04 +0200
Thomas Petazzoni <thomas.petazzoni@bootlin.com> wrote:

> I'm gonna try on ARM noMMU and see.

Everything builds fine in ARM noMMU, i.e the following defconfig builds fine:

BR2_arm=y
BR2_cortex_m7=y
BR2_ARM_ENABLE_VFP=y

So there is really a RISC-V noMMU specific issue it seems.

Best regards,

Thomas
Thomas Petazzoni Aug. 30, 2021, 9:55 p.m. UTC | #4
Hello Damien,

On Mon, 30 Aug 2021 21:42:02 +0000
Damien Le Moal <Damien.LeMoal@wdc.com> wrote:

> On 2021/08/31 6:32, Thomas Petazzoni wrote:
> > Hello Damien,
> > 
> > On Mon, 30 Aug 2021 13:40:51 +0900
> > Damien Le Moal <damien.lemoal@wdc.com> wrote:
> >   
> >> Christoph Hellwig (2):
> >>   package/elf2flt: add RISC-V 64-bits support
> >>   package/Makefile.in: Fix NOMMU RISC-V 64-bits toolchain base name
> >>
> >> Damien Le Moal (7):
> >>   arch/config: Make RISC-V 64-bits MMU optional  
> > 
> > Just tested with the first 3 patches applied the following defconfig:
> > 
> > BR2_riscv=y
> > # BR2_USE_MMU is not set
> > 
> > It fails to build with:
> > 
> > /home/thomas/buildroot/buildroot/output/host/riscv64-buildroot-linux-uclibc/bin/elf2flt: Loading to RAM ('-r' option) 
> > is required  
> 
> Yes, this option is mandatory for rv64. The elf2flt patch checks for it, but
> only for rv64. Other architectures should not be affected.
> The following patch that adds the Sipeed MAIX bit board support adds that option
> to busybox build. So I guess that build option should be moved to this patch ?

I see:

+CONFIG_EXTRA_LDFLAGS="-Os -static -Wl,-elf2flt=-r"

in your Busybox configuration file indeed. But what about other
packages ?

If this is needed for all packages built for RISC-V 64-bit noMMU, then
we need to have it set as part of the toolchain wrapper. Actually, the
toolchain wrapper already passes -Wl,-elf2flt, so it would only have to
be tweaked to pass -Wl,-elf2flt=-r instead.

See:

#ifdef BR_BINFMT_FLAT
        "-Wl,-elf2flt",
#endif

in toolchain/toolchain-wrapper.c

Best regards,

Thomas
Damien Le Moal Aug. 30, 2021, 9:59 p.m. UTC | #5
On 2021/08/31 6:56, Thomas Petazzoni wrote:
> Hello Damien,
> 
> On Mon, 30 Aug 2021 21:42:02 +0000
> Damien Le Moal <Damien.LeMoal@wdc.com> wrote:
> 
>> On 2021/08/31 6:32, Thomas Petazzoni wrote:
>>> Hello Damien,
>>>
>>> On Mon, 30 Aug 2021 13:40:51 +0900
>>> Damien Le Moal <damien.lemoal@wdc.com> wrote:
>>>   
>>>> Christoph Hellwig (2):
>>>>   package/elf2flt: add RISC-V 64-bits support
>>>>   package/Makefile.in: Fix NOMMU RISC-V 64-bits toolchain base name
>>>>
>>>> Damien Le Moal (7):
>>>>   arch/config: Make RISC-V 64-bits MMU optional  
>>>
>>> Just tested with the first 3 patches applied the following defconfig:
>>>
>>> BR2_riscv=y
>>> # BR2_USE_MMU is not set
>>>
>>> It fails to build with:
>>>
>>> /home/thomas/buildroot/buildroot/output/host/riscv64-buildroot-linux-uclibc/bin/elf2flt: Loading to RAM ('-r' option) 
>>> is required  
>>
>> Yes, this option is mandatory for rv64. The elf2flt patch checks for it, but
>> only for rv64. Other architectures should not be affected.
>> The following patch that adds the Sipeed MAIX bit board support adds that option
>> to busybox build. So I guess that build option should be moved to this patch ?
> 
> I see:
> 
> +CONFIG_EXTRA_LDFLAGS="-Os -static -Wl,-elf2flt=-r"
> 
> in your Busybox configuration file indeed. But what about other
> packages ?
> 
> If this is needed for all packages built for RISC-V 64-bit noMMU, then
> we need to have it set as part of the toolchain wrapper. Actually, the
> toolchain wrapper already passes -Wl,-elf2flt, so it would only have to
> be tweaked to pass -Wl,-elf2flt=-r instead.
> 
> See:
> 
> #ifdef BR_BINFMT_FLAT
>         "-Wl,-elf2flt",
> #endif
> 
> in toolchain/toolchain-wrapper.c

OK. Got it. Re-spinning with this.
Thanks !

> 
> Best regards,
> 
> Thomas
>