OpenCores
URL https://opencores.org/ocsvn/neorv32/neorv32/trunk

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [docs/] [userguide/] [customizing_the_bootloader.adoc] - Blame information for rev 69

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 69 zero_gravi
<<<
2
:sectnums:
3
== Customizing the Internal Bootloader
4
 
5
The NEORV32 bootloader provides several options to configure and customize it for a certain application setup.
6
This configuration is done by passing _defines_ when compiling the bootloader. Of course you can also
7
modify to bootloader source code to provide a setup that perfectly fits your needs.
8
 
9
[IMPORTANT]
10
Each time the bootloader sources are modified, the bootloader has to be re-compiled (and re-installed to the
11
bootloader ROM) and the processor has to be re-synthesized.
12
 
13
[NOTE]
14
Keep in mind that the maximum size for the bootloader is limited to 32kB and should be compiled using the
15
base ISA `rv32i` only to ensure it can work independently of the actual CPU configuration.
16
 
17
.Bootloader configuration parameters
18
[cols="<2,^1,^2,<6"]
19
[options="header", grid="rows"]
20
|=======================
21
| Parameter | Default | Legal values | Description
22
4+^| Serial console interface
23
| `UART_EN`   | `1` | `0`, `1` | Set to `0` to disable UART0 (no serial console at all)
24
| `UART_BAUD` | `19200` | _any_ | Baud rate of UART0
25
4+^| Status LED
26
| `STATUS_LED_EN`  | `1` | `0`, `1` | Enable bootloader status led ("heart beat") at `GPIO` output port pin #`STATUS_LED_PIN` when `1`
27
| `STATUS_LED_PIN` | `0` | `0` ... `31` | `GPIO` output pin used for the high-active status LED
28
4+^| Boot configuration
29
| `AUTO_BOOT_SPI_EN`  | `0` | `0`, `1` | Set `1` to enable immediate boot from external SPI flash
30
| `AUTO_BOOT_OCD_EN`  | `0` | `0`, `1` | Set `1` to enable boot via on-chip debugger (OCD)
31
| `AUTO_BOOT_TIMEOUT` | `8` | _any_ | Time in seconds after the auto-boot sequence starts (if there is no UART input by user); set to 0 to disabled auto-boot sequence
32
4+^| SPI configuration
33
| `SPI_EN`                | `1` | `0`, `1` | Set `1` to enable the usage of the SPI module (including load/store executables from/to SPI flash options)
34
| `SPI_FLASH_CS`          | `0` | `0` ... `7` | SPI chip select output (`spi_csn_o`) for selecting flash
35
| `SPI_FLASH_SECTOR_SIZE` | `65536` | _any_ | SPI flash sector size in bytes
36
| `SPI_FLASH_CLK_PRSC`    | `CLK_PRSC_8`  | `CLK_PRSC_2` `CLK_PRSC_4` `CLK_PRSC_8` `CLK_PRSC_64` `CLK_PRSC_128` `CLK_PRSC_1024` `CLK_PRSC_2024` `CLK_PRSC_4096` | SPI clock pre-scaler (dividing main processor clock)
37
| `SPI_BOOT_BASE_ADDR`    | `0x08000000` | _any_ 32-bit value | Defines the _base_ address of the executable in external flash
38
|=======================
39
 
40
Each configuration parameter is implemented as C-language `define` that can be manually overridden (_redefined_) when
41
invoking the bootloader's makefile. The according parameter and its new value has to be _appended_
42
(using `+=`) to the makefile `USER_FLAGS` variable. Make sure to use the `-D` prefix here.
43
 
44
For example, to configure a UART Baud rate of 57600 and redirecting the status LED to output pin 20
45
use the following command (_in_ the bootloader's source folder `sw/bootloader`):
46
 
47
.Example: customizing, re-compiling and re-installing the bootloader
48
[source,console]
49
----
50
$ make USER_FLAGS+=-DUART_BAUD=57600 USER_FLAGS+=-DSTATUS_LED_PIN=20 clean_all bootloader
51
----
52
 
53
[NOTE]
54
The `clean_all` target ensure that all libraries are re-compiled. The `bootloader` target will automatically
55
compile and install the bootloader to the HDL boot ROM (updating `rtl/core/neorv32_bootloader_image.vhd`).
56
 
57
:sectnums:
58
=== Bootloader Boot Configuration
59
 
60
The bootloader provides several _boot configurations_ that define where the actual application's executable
61
shall be fetched from. Note that the non-default boot configurations provide a smaller memory footprint
62
reducing boot ROM implementation costs.
63
 
64
:sectnums!:
65
==== Default Boot Configuration
66
 
67
The _default_ bootloader configuration provides a UART-based user interface that allows to upload new executables
68
at any time. Optionally, the executable can also be programmed to an external SPI flash by the bootloader (see
69
section <<_programming_an_external_spi_flash_via_the_bootloader>>).
70
 
71
This configuration also provides an _automatic boot sequence_ (auto-boot) which will start fetching an executable
72
from external SPI flash using the default SPI configuration. By this, the default bootloader configuration
73
provides a "non volatile program storage" mechanism that automatically boot from external SPI flash
74
(after `AUTO_BOOT_TIMEOUT`) while still providing the option to re-program SPI flash at any time
75
via the UART interface.
76
 
77
:sectnums!:
78
==== `AUTO_BOOT_SPI_EN`
79
 
80
The automatic boot from SPI flash (enabled when `AUTO_BOOT_SPI_EN` is `1`) will fetch an executable from an external
81
SPI flash (using the according _SPI configuration_) right after reset. The bootloader will start fetching
82
the image at SPI flash base address `SPI_BOOT_BASE_ADDR`.
83
 
84
Note that there is _no_ UART console to interact with the bootloader. However, this boot configuration will
85
output minimal status messages via UART (if `UART_EN` is `1`).
86
 
87
:sectnums!:
88
==== `AUTO_BOOT_OCD_EN`
89
 
90
If `AUTO_BOOT_OCD_EN` is `1` the bootloader is implemented as minimal "halt loop" to be used with the on-chip debugger.
91
After initializing the hardware, the CPU waits in this endless loop until the on-chip debugger takes control over
92
the core (to upload and run the actual executable). See section <<_debugging_using_the_on_chip_debugger>>
93
for more information on how to use the on-chip debugger to upload and run executables.
94
 
95
[NOTE]
96
All bootloader boot configuration support uploading new executables via the on-chip debugger.
97
 
98
[WARNING]
99
Note that this boot configuration does not load any executable at all! Hence,
100
this boot configuration is intended to be used with the on-chip debugger only.

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.