Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openocd does not support 64 bit target HiFive Unleashed #9

Open
arshadaleem-lm opened this issue Sep 30, 2020 · 6 comments
Open

openocd does not support 64 bit target HiFive Unleashed #9

arshadaleem-lm opened this issue Sep 30, 2020 · 6 comments

Comments

@arshadaleem-lm
Copy link

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:
https://github.com/platformio/platform-sifive/tree/master/examples/freedom-e-sdk_hello?utm_source=platformio.org&utm_medium=docs

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

It appears that openocd available with PlatformIO only supports 32 bits targets.

Thanks.

@jatanpandya83
Copy link

Does OpenOCD support 64 bit targets?

@arshadaleem-lm
Copy link
Author

Does OpenOCD support 64 bit targets?

Well, the OpenOCD shipped with FreedomStudio does support HiFive Unleashed, i.e. 64 bit target.

@jatanpandya83
Copy link

Thanks Arshad ! This is very helpful.

I was discouraged when I read the below on openocd.org:
http://openocd.org/doc/doxygen/html/targetnotarm.html#:~:text=64%20bit,only%20supports%2032%20bit%20targets

I will try with the forked version of openocd from freedom studio.

Thanks once again,
Jatan

@jatanpandya83
Copy link

Hi Arshad,

Did you use the already built OpenOCD from freedom studio? I couldn't use that because I need OpenOCD with bitbang driver. Looks like the pre-built OpenOCD on freedom studio supports USB.

Thanks,
Jatan

@arshadaleem-lm
Copy link
Author

Hi Arshad,

Did you use the already built OpenOCD from freedom studio? I couldn't use that because I need OpenOCD with bitbang driver. Looks like the pre-built OpenOCD on freedom studio supports USB.

Thanks,
Jatan

Hi Jatan,
Yes I used the already built OpenOCD from Freedom Studio. And yes, it supports USB debugging.

Regards,
Arshad

@jatanpandya83
Copy link

Thanks Arshad !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants