> For the complete documentation index, see [llms.txt](https://tk233.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tk233.gitbook.io/notes/risc-v-soc/other-chipyard-stuff/booting-bearlyml-with-external-spi-flash.md).

# Booting BearlyML With External SPI Flash

Connect SPI to FE310.

We need to use J-Link to communicate with the board/chip. So run `JLink.exe`

## J-Link Commands

[Here](https://wiki.segger.com/J-Link_Commander) and [here](https://docs.rs-online.com/5cbd/0900766b8165024a.pdf) are some references. Can also type `?` in terminal to see list of command.

To connect device

```
connect FE310
```

List Regs

```
Regs
RReg pc
```

Examine memory content

```
Mem32 0x20000000, 2
```

Erase Flash

```
Erase 0x20000000, 0x20001000
```

Load file to Flash

```
LoadFile C:\Users\TK\Desktop\HAL\firmware\build\firmware.bin, 0x20000000
```

Common commands as GDB

```
Halt
Go
Reset
Step
```

## SPI Wiring

<figure><img src="/files/jk2uvZ593y2jN3ChScDU" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/3DXVVn1u2JfCsEMyZHOL" alt=""><figcaption><p>Sparkfun FE310 Board Connection</p></figcaption></figure>

<figure><img src="/files/ZQmwwbYUYtEdTSIThqcW" alt=""><figcaption><p>Arty 35T Board Connection</p></figcaption></figure>

*Note: the #RESET pin need to be tied to HIGH.*

<figure><img src="/files/hFnKlI3AgKjnc9c18TVA" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/JPvpHKTnsWtONM7zHJmT" alt=""><figcaption></figcaption></figure>
