Skip to content

Commit

Permalink
arcv: Update expect scripts of dejagnu to define compiler and nSIM AR…
Browse files Browse the repository at this point in the history
…C-V options
  • Loading branch information
qwersem committed Mar 28, 2024
1 parent 8e1ca51 commit 69b41f7
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 40 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
11 changes: 8 additions & 3 deletions dejagnu/arc-common.exp
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,16 @@ proc arc_get_cflags {} {
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
lappend cflags --specs=nsim.specs
} elseif { [board_info $board arc,hostlink] == "metaware" } {
lappend cflags --specs=hl.specs
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
lappend cflags --specs=nosys.specs
}
} else {
lappend cflags --specs=nosys.specs
Expand Down
36 changes: 19 additions & 17 deletions dejagnu/baseboards/arc-nsim.exp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
} else {
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"
}
}

set_board_info nsim_flags [join $nsim_flags]

# nSIM is an exclusive resource -- only one client can connect at a time.
Expand Down
47 changes: 28 additions & 19 deletions dejagnu/baseboards/arc-sim-nsimdrv.exp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
} else {
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"
}
}

# Hostlink library support
Expand All @@ -105,14 +108,14 @@ if { [info exists env(ARC_HOSTLINK_LIBRARY)] } {
-Wl,--no-whole-archive"
} 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" } {
[board_info $board arc,hostlink] != "nsim" && \
[board_info $board arc,hostlink] != "semihost" } {
perror "Unknown nSIM HOSTLINK type $env(ARC_NSIM_HOSTLINK)"
exit 1
}
} else {
# Use nSIM GNU IO hostlink by default
verbose "Use nSIM GNU IO hostlink by default"
set_board_info arc,hostlink "nsim"
}

Expand Down Expand Up @@ -210,6 +213,12 @@ if { [check_target_arc64_64] } {
-p nsim_isa_family=av2em \
-p nsim_isa_core=3 \
-on nsim_isa_sat
} elseif { [check_target_arcv] } {
lappend nsim_flags \
-p nsim_isa_family=rv32 \
-p nsim_isa_ext=-all.i.zicsr.zifencei.zihintpause.b.zca.zcb.zcmp.zcmt.a.m.zbb \
-p nsim_semihosting=1 \
-off=enable_exceptions
} else {
perror "Unknown CPU configuration"
}
Expand Down
5 changes: 5 additions & 0 deletions dejagnu/tool-extra.exp
Original file line number Diff line number Diff line change
Expand Up @@ -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__"]
Expand Down

0 comments on commit 69b41f7

Please sign in to comment.