PlatformIO Community

PIO debug error: Unable to decode 6 byte instructions in prologue at 0x0000000020010648

GDB for risc-v throws an error as shown in picture for Hifive1 Rev B board.

Screen Shot 2020-10-12 at 9.28.57 AM

I also see a fix in gdb, https://sourceware.org/legacy-ml/gdb-cvs/2019-06/msg00013.html
But, don’t know how to get this fix into my vscode environment.

For reproduction, what’s the full platformio.ini and code?

.ini code

[env:hifive1-revb]

platform = sifive

board = hifive1-revb

framework = freedom-e-sdk

Main code you can see in picture.

The code is cut off at line 17 with more down there though? Also the printf misses a \n btw, but that doesn’t cause the error.

Even this

#include <stdio.h>

int main (void)
{
    printf("Hello World\n");

    return 0;
}

Causes the same error. It has to do with the bug in gdb, but could n’t pull the fix into my environment. Any idea?

Well the problem here is that the used toolchain-risv toolchain is

meaning gcc 8.3.0. According to the bintray, the latest package there has a datecode of 2019, 27th of September. So it seems that that patch didn’t make it in there at time it was built…

Thankfully https://www.sifive.com/software has precompiled RISC-V toolchains for all platforms, the latest of which is 8.3.0-2020.04.1.

Although it’s still seemingly 8.3.0, maybe it does include the patch. I’ve downloaded and repacked SiFive’s latest version for Mac with an updated package.json file and uploaded it on my Github.

Please try adding these lines to your platformio.ini:

platform_packages = 
    toolchain-riscv@https://github.com/maxgerhardt/toolchain-riscv-macos.git

This should attempt to install the updated toolchain and use it upon next compilation (docs).

Though it also seems very odd to me that simply starting a debugging session (I assume) with the simplest code leads to GDB crashing and that that wasn’t noticed by the people releasing and maintaining the SiFive support for PlatformIO. If it still doesn’t work with the latest toolchain, please contact https://github.com/platformio/platform-sifive/issues. Maybe the issue lies in something else completely.

Now, same error

/scratch/jenkins/workspace/tpp-freedom-tools/tpp01–toolchain-only-package–scratch-carsteng/obj/x86_64-apple-darwin/build/riscv-gnu-toolchain/riscv-gdb/gdb/riscv-tdep.c:1381: internal-error: unable to decode 6 byte instructions in prologue at 0x0000000020010608
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB?

Terminal logs below for your aid.
Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: https://docs.platformio.org/page/boards/sifive/hifive1-revb.html
PLATFORM: SiFive (2.4.0) > HiFive1 Rev B
HARDWARE: FE310 320MHz, 16KB RAM, 16MB Flash
DEBUG: Current (jlink) On-board (jlink, renode)
PACKAGES:

  • framework-freedom-e-sdk 2.20050003.200818 (2005.0.3)
    - toolchain-riscv 1.80300.200401+sha.128e838
    LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
    LDF Modes: Finder ~ chain, Compatibility ~ soft

Does this ring anything?

Just in case you want the .ini content.

[env:hifive1-revb]
platform = sifive
board = hifive1-revb
framework = freedom-e-sdk
platform_packages = toolchain-riscv@https://github.com/maxgerhardt/toolchain-riscv-macos.git

Will try to post it in git issue to see if any help

This shows that indeed the right version from my repo pulled, but it it didn’t seem to help much.

Too bad. The riscv-binutils-gdb repo clearly shows that the patch is indeed present through this commit.

That is the main patch code, all others are just testsuites.

This repository is then referenced in the main toolchain repo.

There are also build instructions for Mac OS if you’re up for the task. This might get you the latest RISC-V toolchain (for 64-bit riscv).

Other than that, it’s up to the people at the SiFive platform to integrate the latest toolchain packages, so an issue there is the right place.

EDIT: tracked in https://github.com/platformio/platform-sifive/issues/10

Thanks, I shall track your issue.

I see both GDB server and JlinkGDBserver, any chance it should be configured to run jlinkgdbserver ?

There may be the possibility to use JlinkGDBserver or openocd as the GDB server (the thing that connects to the board and accepts connections from GDB client), but your GDB client will always be riscv64-unknown-elf-gdb. So that shouldn’t make a difference.

If you know the commandline to start the JlinkGDBserver so that it connects and opens a gdbserver on a certain port, you can use the debug_server directives (and debug_tool = custom, debug_port = localhost:<port of opened gdbserver>).

1 Like