# 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>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tk233.gitbook.io/notes/risc-v-soc/other-chipyard-stuff/booting-bearlyml-with-external-spi-flash.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
