Lofive Toolchain, getting it working
.

** This post is mostly here so that people googling for an issue I ran
into can find how I worked through it. Unlikely to be interesting to
casual readers.


I recently purchased a Risc-V SOC called the Lofive.
(https://groupgets.com/manufacturers/qwerty-embedded-design/products/lofive-risc-v)

Towards getting it working, I have been seeking to check out the toolchain,
https://github.com/mwelling/freedom-e-sdk

Sifive make binary distributions of their tools available. This is referred to
in the README.md of the link above. But when I went to compile micropython, I
found the sifive tools were missing the board definitions for the lofive
hardware. Maybe this is not all that hard to replicate, but in the
circumstances it seemed that the sensible think would be to do a source build
for the fork of the freedom sdk that is maintained by Mr Welling, using the
link above.

I have had significant difficulties with this. Here is a brief explanation
of how I worked around it. It may help others.

For context, I run a minimal build of debian-stable with no desktop
environment.

During checkout, I would repeatedly get a message, "a tls packet with
unexpected length was received".

Googling suggests this can be caused by several causes. Perspective,

- There have been historic issues with a library, gnutls.

- Perhaps it can be caused by incorrect certificates.

- For all I know my ISP has a faulty transparent proxy, and is truncating
  packets in some circumstances.

I have encountered these problems before. The first thing I do is to move away
from HTTPS and to use the ssh approach to git checkout instead.

This may require you to have a configured github account. (Can't remember, but
I think it does. Create a github account if you don't already have one, make
sure you have your ssh-keys registered. An easy way to do this is to create a
simple repository, and check you can push code to it.)

The mwilliams repo says to do this,
```
git clone --recursive https://github.com/mwelling/freedom-e-sdk.git
```

Instead, we now do this,
```
git clone --recursive git@github.com:mwelling/freedom-e-sdk.git
```

When it comes to submodules, it still crashes. Because they are using
HTTPS paths.

Edit this file,
```
.git/modules/riscv-gnu-toolchain/config
```

Change all of the git paths to the git@github.com: form.

Attempt to recover the checkout like this,
```
git submodule update --init --recursive
```

In my case, it now got further, but then crashed with a different error whilst
checking out a qemu rom.

I edited this file,
```
.git/modules/riscv-gnu-toolchain/modules/riscv-qemu/config
```

I changed a git:github.com style address for the not-working download to the
ssh form.

I now have a complete pull.

The reason I am interested in Risc V, is for the purpose of creating a minimal
async OS on it, and to work towards a low-dependency, not-complex buildchain.
This experience highlights why I have these ambitions. (This situation does
not reflect on the lofive team. They have structured their codebase
carefully.)