diff --git a/README.md b/README.md index 9590571d..ef91a830 100644 --- a/README.md +++ b/README.md @@ -315,7 +315,9 @@ Prefixes which start with `arc-` correspond to little endian toolchains. Prefixe ### Using nSIM simulator to run bare metal ARC applications nSIM simulator supports GNU IO hostlink used by the libc library of bare metal -GNU toolchain for ARC. nSIM option `nsim_emt=1` enables GNU IO hostlink. +GNU toolchain for ARC. nSIM option `nsim_emt=1` enables GNU IO hostlink. nSIM +simulator also supports semihosting, which is essential for ARC-V targets, more +details can be found in nSIM documentation. To start nSIM in gdbserver mode for ARC EM6: diff --git a/dejagnu/arc-common.exp b/dejagnu/arc-common.exp index 4bb52b5c..4aec2585 100644 --- a/dejagnu/arc-common.exp +++ b/dejagnu/arc-common.exp @@ -49,18 +49,22 @@ proc arc_get_cflags {} { # Use cflags instead ldflags because lto tests of ld testsuite ignore # ldflags - if { ![info exists env(ARC_HOSTLINK_LIBRARY)] } { - if [board_info $board exists arc,hostlink] { - if { [board_info $board arc,hostlink] == "nsim" } { - lappend cflags --specs=nsim.specs - } elseif { [board_info $board arc,hostlink] == "metaware" } { - lappend cflags --specs=hl.specs - } else { - lappend cflags --specs=nosys.specs - } - } else { - lappend cflags --specs=nosys.specs - } + if {![info exists env(ARC_HOSTLINK_LIBRARY)]} { + if {[board_info $board exists arc,hostlink]} { + if {[board_info $board arc,hostlink] == "nsim"} { + lappend cflags --specs=nsim.specs + } elseif {[board_info $board arc,hostlink] == "metaware"} { + lappend cflags --specs=hl.specs + } elseif {[board_info $board arc,hostlink] == "semihost"} { + lappend cflags --specs=semihost.specs --specs=arcv.specs \ + -mabi=ilp32 -march=rv32im_zba_zbb_zbs_zca_zcb_zcmp_zicsr \ + -T arcv.ld + } else { + lappend cflags --specs=nosys.specs + } + } else { + lappend cflags --specs=nosys.specs + } } # GCC generates improper DWARF info when frame-pointer is involved - all diff --git a/dejagnu/baseboards/arc-nsim.exp b/dejagnu/baseboards/arc-nsim.exp index 0063b76a..7a2ad587 100644 --- a/dejagnu/baseboards/arc-nsim.exp +++ b/dejagnu/baseboards/arc-nsim.exp @@ -100,25 +100,27 @@ if { $tool == "libstdc++" } { } # Check if nsim_download_elf_sections option is required - whether nSIM version -# is > 2015.06. If revision.txt doesn't exist - this is a private verification -# build of nSIM, so assume that this is the latest version. +# is > 2015.06 and a target is not ARC-V. If revision.txt doesn't exist - this +# is a private verification build of nSIM, so assume that this is the latest +# version. set nsim_version_path "$::env(NSIM_HOME)/revision.txt" -if [file exists $nsim_version_path] { - set nsim_version_fid [open $nsim_version_path r] - set nsim_version_text [read $nsim_version_fid] - close $nsim_version_fid - regexp "Version\\s+: (\\d+)\.(\\d+)" $nsim_version_text -> \ - nsim_version_year nsim_version_month - if { $nsim_version_year > 2015 || \ - ($nsim_version_year == 2015 && $nsim_version_month > 6) } { - # Avoid performance penalty of useless initialization of heap and stack - # sections. - lappend nsim_flags "-on nsim_download_elf_sections" +if {![check_target_arcv]} { + if {[file exists $nsim_version_path]} { + set nsim_version_fid [open $nsim_version_path r] + set nsim_version_text [read $nsim_version_fid] + close $nsim_version_fid + regexp "Version\\s+: (\\d+)\.(\\d+)" $nsim_version_text -> \ + nsim_version_year nsim_version_month + if {$nsim_version_year > 2015 || \ + ($nsim_version_year == 2015 && $nsim_version_month > 6)} { + # Avoid performance penalty of useless initialization of heap and + # stack sections. + lappend nsim_flags "-on nsim_download_elf_sections" + } + } else { + lappend nsim_flags "-on nsim_download_elf_sections" } -} else { - lappend nsim_flags "-on nsim_download_elf_sections" } - set_board_info nsim_flags [join $nsim_flags] # nSIM is an exclusive resource -- only one client can connect at a time. diff --git a/dejagnu/baseboards/arc-sim-nsimdrv.exp b/dejagnu/baseboards/arc-sim-nsimdrv.exp index bffc999c..324b158c 100644 --- a/dejagnu/baseboards/arc-sim-nsimdrv.exp +++ b/dejagnu/baseboards/arc-sim-nsimdrv.exp @@ -80,23 +80,26 @@ if { $tool == "libstdc++" } { } # Check if nsim_download_elf_sections option is required - whether nSIM version -# is > 2015.06. If revision.txt doesn't exist - this is a private verification -# build of nSIM, so assume that this is the latest version. +# is > 2015.06 and a target is not ARC-V. If revision.txt doesn't exist - this +# is a private verification build of nSIM, so assume that this is the latest +# version. set nsim_version_path "$::env(NSIM_HOME)/revision.txt" -if [file exists $nsim_version_path] { - set nsim_version_fid [open $nsim_version_path r] - set nsim_version_text [read $nsim_version_fid] - close $nsim_version_fid - regexp "Version\\s+: (\\d+)\.(\\d+)" $nsim_version_text -> \ - nsim_version_year nsim_version_month - if { $nsim_version_year > 2015 || \ - ($nsim_version_year == 2015 && $nsim_version_month > 6) } { - # Avoid performance penalty of useless initialization of heap and stack - # sections. - lappend nsim_flags "-on nsim_download_elf_sections" +if {![check_target_arcv]} { + if {[file exists $nsim_version_path]} { + set nsim_version_fid [open $nsim_version_path r] + set nsim_version_text [read $nsim_version_fid] + close $nsim_version_fid + regexp "Version\\s+: (\\d+)\.(\\d+)" $nsim_version_text -> \ + nsim_version_year nsim_version_month + if {$nsim_version_year > 2015 || \ + ($nsim_version_year == 2015 && $nsim_version_month > 6)} { + # Avoid performance penalty of useless initialization of heap and + # stack sections. + lappend nsim_flags "-on nsim_download_elf_sections" + } + } else { + lappend nsim_flags "-on nsim_download_elf_sections" } -} else { - lappend nsim_flags "-on nsim_download_elf_sections" } # Hostlink library support @@ -106,8 +109,9 @@ if { [info exists env(ARC_HOSTLINK_LIBRARY)] } { } elseif { [info exists env(ARC_NSIM_HOSTLINK)] } { set_board_info arc,hostlink $env(ARC_NSIM_HOSTLINK) - if { [board_info $board arc,hostlink] != "metaware" && \ - [board_info $board arc,hostlink] != "nsim" } { + if {[board_info $board arc,hostlink] != "metaware" && \ + [board_info $board arc,hostlink] != "nsim" && \ + [board_info $board arc,hostlink] != "semihost"} { perror "Unknown nSIM HOSTLINK type $env(ARC_NSIM_HOSTLINK)" exit 1 } @@ -210,6 +214,13 @@ if { [check_target_arc64_64] } { -p nsim_isa_family=av2em \ -p nsim_isa_core=3 \ -on nsim_isa_sat +} elseif {[check_target_arcv]} { + set ext "-all.i.zicsr.zifencei.zihintpause.b.zca.zcb.zcmp.zcmt.a.m.zbb" + lappend nsim_flags \ + -p nsim_isa_family=rv32 \ + -p nsim_isa_ext=${ext} \ + -p nsim_semihosting=1 \ + -off=enable_exceptions } else { perror "Unknown CPU configuration" } diff --git a/dejagnu/tool-extra.exp b/dejagnu/tool-extra.exp index 23033ab1..a69f238c 100644 --- a/dejagnu/tool-extra.exp +++ b/dejagnu/tool-extra.exp @@ -86,6 +86,11 @@ proc compile_quarkse_em_nsim_apex { } { } } +# Return 1 if we compile for ARC-V +proc check_target_arcv { } { + return [check_target_arc "__riscv"] +} + # Return 1 if we compile for ARC64 proc check_target_arc64_64 { } { return [check_target_arc "__ARC64_ARCH64__"]