Skip to content

Commit 2c1dc75

Browse files
committed
de0_nano: Update the tutorial to be step by step
1 parent 2186783 commit 2c1dc75

1 file changed

Lines changed: 29 additions & 25 deletions

File tree

de0_nano/index.md

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -60,29 +60,53 @@ cd /tmp/or1k-de0nano
6060
curl -L -O https://openrisc.io/tutorials/sw/hello/hello.c
6161
curl -L -O https://openrisc.io/tutorials/sw/timer/timer.c
6262

63+
CFLAGS="-mboard=de0_nano -DDE0_NANO"
64+
or1k-elf-gcc -g -Og $CFLAGS -o hello.elf hello.c
65+
or1k-elf-gcc -g -Og $CFLAGS -o timer.elf timer.c
66+
67+
# Add IP cores to the environment
68+
fusesoc library add fusesoc-cores https://github.com/fusesoc/fusesoc-cores
69+
fusesoc library add elf-loader https://github.com/fusesoc/elf-loader.git
70+
fusesoc library add openrisc-cores https://github.com/openrisc/openrisc-cores
6371
fusesoc library add de0_nano https://github.com/olofk/de0_nano.git
72+
73+
# Check the SoC is available
74+
fusesoc core show de0_nano
6475
```
6576

6677
### Build the FPGA bitstream
6778

6879
```bash
69-
fusesoc build de0_nano
80+
fusesoc run de0_nano
7081
```
7182

83+
The FuseSoC `run` command will run the default target, for `de0_nano` this is
84+
synthesis using the tool `quartus`. You could also specify this using `fusesoc
85+
run --target synth --tool quartus de0_nano`. The `run` command has 3 phases:
86+
87+
* **setup** - Creates the project directories and project files
88+
* **build** - Builds the artifacts, for quartus this means the FPGA bitstream.
89+
* **run** - Runs the SoC, this will perform programming, but by default this is disabled.
90+
7291
### Program the FPGA bitstream
7392

74-
Once the board is setup, you can download the FPGA bitstream by
75-
running
93+
Once the board is setup and built, you can download the FPGA bitstream by
94+
running the following:
7695

7796
```bash
78-
fusesoc pgm de0_nano
97+
fusesoc run --run de0_nano --pgm quartus
7998
```
8099

100+
Passing the `--run` argument allows only the run stage to be run. This is useful
101+
as we do not want to build the entire project again. Passing `--pgm quartus`
102+
enables the run stage to use `quartus_pgm` to program the bitstream to fpga
103+
board.
104+
81105
### Start the OpenOCD daemon
82106

83107
In one terminal execute the following command:
84108

85-
openocd -s ${OPENOCD}/share/openocd/scripts/ -f interface/altera-usb-blaster.cfg -f ../or1k-dev.tcl
109+
openocd -s ${OPENOCD}/share/openocd/scripts/ -f interface/altera-usb-blaster.cfg -f ../or1k-dev.tcl
86110

87111
### Run software with gdb
88112

@@ -99,23 +123,3 @@ In gdb execute the following steps:
99123
continue
100124

101125
You should see the LEDs counting and UART output once a second.
102-
103-
## (Re-)build the hardware
104-
105-
You can rebuilt the hardware by running:
106-
107-
```bash
108-
fusesoc build de0_nano
109-
```
110-
111-
## (Re-)build the software
112-
113-
Some example software is available, that you can (re-)build for the
114-
DE0 nano board by running
115-
116-
```bash
117-
CFLAGS=-mboard=de0_nano -DDE0_NANO
118-
119-
or1k-elf-gcc -g -o hello.elf ${CFLAGS} ../sw/hello/hello.c
120-
or1k-elf-gcc -g -o timer.elf ${CFLAGS} ../sw/timer/timer.c
121-
```

0 commit comments

Comments
 (0)