1 |
69 |
zero_gravi |
<<<
|
2 |
|
|
:sectnums:
|
3 |
|
|
== Uploading and Starting of a Binary Executable Image via UART
|
4 |
|
|
|
5 |
|
|
Follow this guide to use the bootloader to upload an executable via UART.
|
6 |
|
|
|
7 |
|
|
[NOTE]
|
8 |
|
|
This concept uses the default "Indirect Boot" scenario that uses the bootloader to upload new executables.
|
9 |
|
|
See datasheet section https://stnolting.github.io/neorv32/#_indirect_boot[Indirect Boot] for more information.
|
10 |
|
|
|
11 |
|
|
[IMPORTANT]
|
12 |
|
|
If your FPGA board does not provide such an interface - don't worry!
|
13 |
|
|
Section <<_installing_an_executable_directly_into_memory>> shows how to
|
14 |
|
|
run custom programs on your FPGA setup without having a UART.
|
15 |
|
|
|
16 |
|
|
[start=1]
|
17 |
|
|
. Connect the primary UART (UART0) interface of your FPGA board to a serial port of your host computer.
|
18 |
|
|
. Start a terminal program. In this tutorial, I am using TeraTerm for Windows. You can download it for free
|
19 |
|
|
from https://ttssh2.osdn.jp/index.html.en . On Linux you could use GTKTerm, which you can get here
|
20 |
|
|
https://github.com/Jeija/gtkterm.git (or install via your package manager).
|
21 |
|
|
|
22 |
70 |
zero_gravi |
[IMPORTANT]
|
23 |
69 |
zero_gravi |
_Any_ terminal program that can connect to a serial port should work. However, make sure the program
|
24 |
70 |
zero_gravi |
can transfer data in _raw_ byte mode without any protocol overhead around it. Some terminal programs struggle with
|
25 |
|
|
transmitting files larger than 4kB (see https://github.com/stnolting/neorv32/pull/215). Try a different program
|
26 |
|
|
if uploading a binary does not work (terminal stall).
|
27 |
69 |
zero_gravi |
|
28 |
|
|
[start=3]
|
29 |
|
|
. Open a connection to the the serial port your UART is connected to. Configure the terminal setting according to the
|
30 |
|
|
following parameters:
|
31 |
|
|
|
32 |
|
|
* 19200 Baud
|
33 |
|
|
* 8 data bits
|
34 |
|
|
* 1 stop bit
|
35 |
|
|
* no parity bits
|
36 |
|
|
* _no_ transmission/flow control protocol
|
37 |
|
|
* receiver (host computer) newline on `\r\n` (carriage return & newline)
|
38 |
|
|
|
39 |
|
|
[start=4]
|
40 |
|
|
. Also make sure that single chars are send from your computer _without_ any consecutive "new line" or "carriage
|
41 |
|
|
return" commands (this is highly dependent on your terminal application of choice, TeraTerm only
|
42 |
|
|
sends the raw chars by default).
|
43 |
|
|
. Press the NEORV32 reset button to restart the bootloader. The status LED starts blinking and the
|
44 |
|
|
bootloader intro screen appears in your console. Hurry up and press any key (hit space!) to abort the
|
45 |
|
|
automatic boot sequence and to start the actual bootloader user interface console.
|
46 |
|
|
|
47 |
|
|
.Bootloader console; aborted auto-boot sequence
|
48 |
|
|
[source,bash]
|
49 |
|
|
----
|
50 |
|
|
<< NEORV32 Bootloader >>
|
51 |
|
|
|
52 |
|
|
BLDV: Mar 23 2021
|
53 |
|
|
HWV: 0x01050208
|
54 |
|
|
CLK: 0x05F5E100
|
55 |
|
|
MISA: 0x40901105
|
56 |
|
|
ZEXT: 0x00000023
|
57 |
|
|
PROC: 0x0EFF0037
|
58 |
|
|
IMEM: 0x00004000 bytes @ 0x00000000
|
59 |
|
|
DMEM: 0x00002000 bytes @ 0x80000000
|
60 |
|
|
|
61 |
|
|
Autoboot in 8s. Press key to abort.
|
62 |
|
|
Aborted.
|
63 |
|
|
|
64 |
|
|
Available commands:
|
65 |
|
|
h: Help
|
66 |
|
|
r: Restart
|
67 |
|
|
u: Upload
|
68 |
|
|
s: Store to flash
|
69 |
|
|
l: Load from flash
|
70 |
|
|
e: Execute
|
71 |
|
|
CMD:>
|
72 |
|
|
----
|
73 |
|
|
|
74 |
|
|
[start=6]
|
75 |
|
|
. Execute the "Upload" command by typing `u`. Now the bootloader is waiting for a binary executable to be send.
|
76 |
|
|
|
77 |
|
|
[source,bash]
|
78 |
|
|
----
|
79 |
|
|
CMD:> u
|
80 |
|
|
Awaiting neorv32_exe.bin...
|
81 |
|
|
----
|
82 |
|
|
|
83 |
|
|
[start=7]
|
84 |
|
|
. Use the "send file" option of your terminal program to send a NEORV32 executable (`neorv32_exe.bin`).
|
85 |
|
|
. Again, make sure to transmit the executable in raw binary mode (no transfer protocol).
|
86 |
|
|
When using TeraTerm, select the "binary" option in the send file dialog.
|
87 |
|
|
. If everything went fine, OK will appear in your terminal:
|
88 |
|
|
|
89 |
|
|
[source,bash]
|
90 |
|
|
----
|
91 |
|
|
CMD:> u
|
92 |
|
|
Awaiting neorv32_exe.bin... OK
|
93 |
|
|
----
|
94 |
|
|
|
95 |
|
|
[start=10]
|
96 |
|
|
. The executable is now in the instruction memory of the processor. To execute the program right
|
97 |
|
|
now run the "Execute" command by typing `e`:
|
98 |
|
|
|
99 |
|
|
[source,bash]
|
100 |
|
|
----
|
101 |
|
|
CMD:> u
|
102 |
|
|
Awaiting neorv32_exe.bin... OK
|
103 |
|
|
CMD:> e
|
104 |
|
|
Booting...
|
105 |
|
|
Blinking LED demo program
|
106 |
|
|
----
|
107 |
|
|
|
108 |
|
|
[start=11]
|
109 |
|
|
. If everything went fine, you should see the LEDs blinking.
|
110 |
|
|
|
111 |
|
|
[NOTE]
|
112 |
|
|
The bootloader will print error codes if something went wrong.
|
113 |
|
|
See section https://stnolting.github.io/neorv32/#_bootloader[Bootloader] of the NEORV32 datasheet for more information.
|
114 |
|
|
|
115 |
|
|
[TIP]
|
116 |
|
|
See section <<_programming_an_external_spi_flash_via_the_bootloader>> to learn how to use an external SPI
|
117 |
|
|
flash for nonvolatile program storage.
|
118 |
|
|
|
119 |
|
|
[TIP]
|
120 |
|
|
Executables can also be uploaded via the **on-chip debugger**.
|
121 |
|
|
See section <<_debugging_with_gdb>> for more information.
|