Error: invalid ELF file, only 32bits files are supported

I’m trying to Debug a hello world application on HiFive Unleashed using PlatformIO Core (CLI) tool. I’ve setup the utility using this Wiki:
https://docs.platformio.org/en/latest/core/installation.html#installation

And used these commands to debug the application:

I’m facing a strange error while starting the debug session:

Error: invalid ELF file, only 32bits files are supported
embedded:startup.tcl:486: Error: ** Programming Failed **

Here are the complete verbose logs:

arshadaleem@lmlpt52:~/platformio/platform-sifive/examples/freedom-e-sdk_hello$ platformio run -e sifive-hifive-unleashed --target upload -v
Processing sifive-hifive-unleashed (platform: sifive; framework: freedom-e-sdk; board: hifive-unleashed; monitor_speed: 115200)
----------------------------------------------------------------------------------------------------------------------------------------------
CONFIGURATION: https://docs.platformio.org/page/boards/sifive/hifive-unleashed.html
PLATFORM: SiFive (2.4.0) > HiFive Unleashed
HARDWARE: FU540 1500MHz, 8GB RAM, 32MB Flash
DEBUG: Current (ftdi) On-board (ftdi, qemu, renode)
PACKAGES: 
 - framework-freedom-e-sdk 2.20050003.200818 (2005.0.3) 
 - tool-jlink 1.65200.0 (6.52.0) 
 - tool-openocd-riscv 2.1000.20190927 (10.0) 
 - toolchain-riscv 1.80300.190927 (8.3.0)
LDF: Library Dependency Finder -> 
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 0 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
MethodWrapper(["checkprogsize"], [".pio/build/sifive-hifive-unleashed/firmware.elf"])
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   0.0% (used 17380 bytes from 8589934592 bytes)
Flash: [          ]   0.1% (used 23612 bytes from 33554432 bytes)
text	   data	    bss	    dec	    hex	filename
  13716	   9896	   7484	  31096	   7978	.pio/build/sifive-hifive-unleashed/firmware.elf
<lambda>(["upload"], [".pio/build/sifive-hifive-unleashed/firmware.elf"])
AVAILABLE: ftdi
CURRENT: upload_protocol = ftdi
openocd -c "debug_level 2" -s /home/arshadaleem/.platformio/packages/tool-openocd-riscv -s /share/openocd/scripts -f /home/arshadaleem/.platformio/packages/framework-freedom-e-sdk/bsp/sifive-hifive-unleashed/openocd.cfg -c "program {.pio/build/sifive-hifive-unleashed/firmware.elf}  verify; shutdown;"
Open On-Chip Debugger 0.10.0+dev (SiFive OpenOCD 0.10.0-2019.08.2)
Licensed under GNU GPL v2
For bug reports:
	https://github.com/sifive/freedom-tools/issues
debug_level: 2
adapter speed: 10000 kHz
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
Info : Hardware thread awareness created
Info : ftdi: if you experience problems at higher adapter clocks, try the command "ftdi_tdo_sample_edge falling"
Info : clock speed 10000 kHz
Info : JTAG tap: riscv.cpu tap/device found: 0x20000913 (mfg: 0x489 (SiFive Inc), part: 0x0000, ver: 0x2)
Info : datacount=2 progbufsize=16
Info : Disabling abstract command reads from CSRs.
Info : Core 0 could not be made part of halt group 1.
Info : Examined RISC-V core; found 5 harts
Info :  hart 0: XLEN=64, misa=0x8000000000101105
Info :  hart 1: currently disabled
Info :  hart 2: currently disabled
Info :  hart 3: currently disabled
Info :  hart 4: currently disabled
Info : datacount=2 progbufsize=16
Info : Disabling abstract command reads from CSRs.
Info : Core 1 could not be made part of halt group 1.
Info : Examined RISC-V core; found 5 harts
Info :  hart 0: currently disabled
Info :  hart 1: XLEN=64, misa=0x800000000014112d
Info :  hart 2: currently disabled
Info :  hart 3: currently disabled
Info :  hart 4: currently disabled
Info : datacount=2 progbufsize=16
Info : Disabling abstract command reads from CSRs.
Info : Core 2 could not be made part of halt group 1.
Info : Examined RISC-V core; found 5 harts
Info :  hart 0: currently disabled
Info :  hart 1: currently disabled
Info :  hart 2: XLEN=64, misa=0x800000000014112d
Info :  hart 3: currently disabled
Info :  hart 4: currently disabled
Info : datacount=2 progbufsize=16
Info : Disabling abstract command reads from CSRs.
Info : Core 3 could not be made part of halt group 1.
Info : Examined RISC-V core; found 5 harts
Info :  hart 0: currently disabled
Info :  hart 1: currently disabled
Info :  hart 2: currently disabled
Info :  hart 3: XLEN=64, misa=0x800000000014112d
Info :  hart 4: currently disabled
Info : datacount=2 progbufsize=16
Info : Disabling abstract command reads from CSRs.
Info : Core 4 could not be made part of halt group 1.
Info : Examined RISC-V core; found 5 harts
Info :  hart 0: currently disabled
Info :  hart 1: currently disabled
Info :  hart 2: currently disabled
Info :  hart 3: currently disabled
Info :  hart 4: XLEN=64, misa=0x800000000014112d
Info : Listening on port 3333 for gdb connections
Info : Found flash device 'issi is25wp256d' (ID 0x0019709d)
Warn : device needs paging or 4-byte addresses - not implemented
cleared protection for sectors 64 through 511 on flash bank 0
Ready for Remote Connections
Info : JTAG tap: riscv.cpu tap/device found: 0x20000913 (mfg: 0x489 (SiFive Inc), part: 0x0000, ver: 0x2)
** Programming Started **
auto erase enabled
Error: invalid ELF file, only 32bits files are supported
embedded:startup.tcl:486: Error: ** Programming Failed **
in procedure 'program' 
in procedure 'program_error' called at file "embedded:startup.tcl", line 545
at file "embedded:startup.tcl", line 486
*** [upload] Error 1
========================================================= [FAILED] Took 0.82 seconds =========================================================
(penv) 

Output of readelf is as follows:

arshadaleem@lmlpt52:~/platformio/platform-sifive/examples/freedom-e-sdk_hello$ readelf -h .pio/build/sifive-hifive-unleashed/firmware.elf
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           RISC-V
  Version:                           0x1
  Entry point address:               0x20000000
  Start of program headers:          64 (bytes into file)
  Start of section headers:          47872 (bytes into file)
  Flags:                             0x1, RVC, soft-float ABI
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         6
  Size of section headers:           64 (bytes)
  Number of section headers:         15
  Section header string table index: 14

Any pointer in eliminating this error will be much appreciated.

Thanks.

Well there’s the mismatch. I don’t know on the top of my head whether the HiFive Unleashed is the only RISC-V 64bit (or RV64) acrhitecture type board and all others are RV32. Please directly open an issue at Issues · platformio/platform-sifive · GitHub to let them know that the openocd version they’re using only handles RV32.

You’re right @maxgerhardt, HiFive Unleashed is the only rv64 architecture SoC. I’ve opened an issue as suggested: openocd does not support 64 bit target HiFive Unleashed · Issue #9 · platformio/platform-sifive · GitHub