foss-for-synopsys-dwc-arc-processors/toolchain

Crosstool-NG builds uClibc for HS5x with wrong page size

kolerov opened this issue · 2 comments

By default, Crosstool-NG builds uClibc for HS5x with CONFIG_ARC_PAGE_SIZE_8K turned on. However, Buildroot expects CONFIG_ARC_PAGE_SIZE_4K for HS5x which uClibc.

Try to build vmlinux in Buildroot using this configuration file:

BR2_arcle=y
BR2_arc32=y
# BR2_STRIP_strip is not set
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_16=y
BR2_TOOLCHAIN_BUILDROOT_UCLIBC=y
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_GIT=y
BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/foss-for-synopsys-dwc-arc-processors/linux.git"
BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="arc64"
BR2_LINUX_KERNEL_DEFCONFIG="haps_hs5x"
BR2_LINUX_KERNEL_VMLINUX=y
BR2_PACKAGE_LINUX_TOOLS_PERF=y
BR2_TARGET_ROOTFS_INITRAMFS=y

You will see that Buildroot forces uClibc to use 4K pages:

$ grep "ARC_PAGE_SIZE_4K" build/uclibc-upstream/.config
CONFIG_ARC_PAGE_SIZE_4K=y

However, if you will try to build vmlinux using a toolchain built by Crosstoll-NG:

BR2_arcle=y
BR2_arc32=y
# BR2_STRIP_strip is not set
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_5_16=y
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_GIT=y
BR2_LINUX_KERNEL_CUSTOM_REPO_URL="https://github.com/foss-for-synopsys-dwc-arc-processors/linux.git"
BR2_LINUX_KERNEL_CUSTOM_REPO_VERSION="arc64"
BR2_LINUX_KERNEL_DEFCONFIG="haps_hs5x"
BR2_LINUX_KERNEL_VMLINUX=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
BR2_TOOLCHAIN_EXTERNAL_URL="https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/releases/download/arc-2022.09-rc2/arc_gnu_2022.09-rc2_prebuilt_arc32_uclibc_linux_install.tar.gz"
BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_16=y
BR2_TOOLCHAIN_EXTERNAL_LOCALE=y
BR2_TOOLCHAIN_EXTERNAL_HAS_SSP=y
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_TOOLCHAIN_EXTERNAL_INET_RPC=n
BR2_TOOLCHAIN_EXTERNAL_GCC_12
BR2_PACKAGE_LINUX_TOOLS_PERF=y
BR2_TARGET_ROOTFS_INITRAMFS=y

... you will see an error after running in nSIM:

$ nsimdrv -propsfile hs5x.props images/vmlinux
Run /init as init process
  with arguments:
    /init
  with environment:
    HOME=/
    TERM=linux
/bin/sh:683: can't map '/lib/libc.so.0'
/bin/sh:683: can't map '/lib/libc.so.0'
/bin/sh: can't load library 'libc.so.0'
Kernel panic - not syncing: Attempted to kill init! exitcode=0x00001000
---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x00001000 ]---

Content of hs5x.props:

nsim_isa_family=av3hs
nsim_isa_dc_hw_prefetch=1
nsim_isa_dual_issue_option=1
nsim_isa_atomic_option=1
nsim_isa_m128_option=0
nsim_isa_ll64_option=1
nsim_isa_mpy_option=9
nsim_isa_div_rem_option=2
nsim_isa_enable_timer_0=1
nsim_isa_enable_timer_1=1
nsim_isa_rtc_option=1
icache=16384,64,4
dcache=16384,64,2
mmu_version=16
mmu_pagesize=4096
mmu_address_space=32
nsim_mem-dev=uart0,kind=dwuart,base=0xf0000000,irq=24
nsim_isa_number_of_interrupts=32
nsim_isa_number_of_external_interrupts=32

It happens because uClibc selects CONFIG_ARC_PAGE_SIZE_8K by default (https://github.com/foss-for-synopsys-dwc-arc-processors/uClibc/blob/arc-mainline-dev/extra/Configs/Config.arc):

choice
    prompt "MMU Page Size"
    default CONFIG_ARC_PAGE_SIZE_8K

config CONFIG_ARC_PAGE_SIZE_8K
    bool "8KB"
    help
      Choose between 4k, 8k (default) or 16k

config CONFIG_ARC_PAGE_SIZE_16K
    bool "16KB"

config CONFIG_ARC_PAGE_SIZE_4K
    bool "4KB"

endchoice

But Buildroot selects 4K pages for HS5x by default (https://github.com/foss-for-synopsys-dwc-arc-processors/uClibc/blob/arc-mainline-dev/extra/Configs/Config.arc):

choice
    prompt "MMU Page Size"
    default BR2_ARC_PAGE_SIZE_4K	if BR2_arc64 || BR2_arc32
    default BR2_ARC_PAGE_SIZE_8K

Indeed, in Crosstool-NG we didn't select 4 Kb page size for ARC HS58.
Now fixed with foss-for-synopsys-dwc-arc-processors/crosstool-ng@ceb33c7.
Once RC3 gets built and we see that it works, this one will be closed.