NEORV32 - Software Framework Documentation
Loading...
Searching...
No Matches
Macros | Enumerations
main.c File Reference

Interactive console program to upload and execute a XIP program. More...

#include <neorv32.h>

Macros

#define EXE_SIGNATURE   0x4788CAFE
 
User configuration
#define BAUD_RATE   19200
 
#define FLASH_BASE   0x00400000
 
#define FLASH_ABYTES   3
 
#define XIP_CLK_PRSC   CLK_PRSC_128
 
#define BUFFER_SIZE   (7*1024)
 

Enumerations

enum  SPI_FLASH_CMD {
  SPI_FLASH_CMD_WRITE = 0x02 , SPI_FLASH_CMD_READ = 0x03 , SPI_FLASH_CMD_READ_STATUS = 0x05 , SPI_FLASH_CMD_WRITE_ENABLE = 0x06 ,
  SPI_FLASH_CMD_SECTOR_ERASE = 0xD8
}
 

Functions

Prototypes
void xip_flash_erase_sector (uint32_t base_addr)
 
void xip_flash_program (uint32_t *src, uint32_t base_addr, uint32_t size)
 
int uart_get_executable (uint32_t *dst, uint32_t *size)
 
uint32_t uart_get_word (void)
 

RAM storage for executable

uint32_t ram_buffer [BUFFER_SIZE/4]
 
int main ()
 

Detailed Description

Interactive console program to upload and execute a XIP program.

Author
Stephan Nolting

Macro Definition Documentation

◆ BAUD_RATE

#define BAUD_RATE   19200

UART BAUD rate

◆ BUFFER_SIZE

#define BUFFER_SIZE   (7*1024)

Executable RAM buffer size in bytes

◆ EXE_SIGNATURE

#define EXE_SIGNATURE   0x4788CAFE

Valid executable identification signature

◆ FLASH_ABYTES

#define FLASH_ABYTES   3

Flash address bytes

◆ FLASH_BASE

#define FLASH_BASE   0x00400000

Flash base address (32-bit)

◆ XIP_CLK_PRSC

#define XIP_CLK_PRSC   CLK_PRSC_128

XIP SPI clock prescaler select

Enumeration Type Documentation

◆ SPI_FLASH_CMD

SPI flash commands

Enumerator
SPI_FLASH_CMD_WRITE 

Write data

SPI_FLASH_CMD_READ 

Read data

SPI_FLASH_CMD_READ_STATUS 

Get status register

SPI_FLASH_CMD_WRITE_ENABLE 

Allow write access

SPI_FLASH_CMD_SECTOR_ERASE 

Erase complete sector

Function Documentation

◆ main()

int main ( void )

Main function

Note
This program requires the XIP module and UART0.
Returns
0 if execution was successful

◆ uart_get_executable()

int uart_get_executable ( uint32_t * dst,
uint32_t * length )

Get NEORV32 executable via UART.

Parameters
[in]dstPointer to uin32_t data array where the executable will be stored.
[out]lengthPointer to a uin32_t to store the executable size in bytes.
Returns
Returns 0 on success.

◆ uart_get_word()

uint32_t uart_get_word ( void )

Get 32-bit word from UART.

Returns
32-bit data word.

◆ xip_flash_erase_sector()

void xip_flash_erase_sector ( uint32_t base_addr)

Erase sector starting at base address.

Parameters
[in]base_addrBase address of sector to erase.

◆ xip_flash_program()

void xip_flash_program ( uint32_t * src,
uint32_t base_addr,
uint32_t size )

Helper function to program the XIP flash via the direct SPI access feature of the XIP module.

Warning
This function can only be used BEFORE the XIP-mode is activated!
Note
This function is blocking and performs individual writes for each byte (little-endian byte order!).
Parameters
[in]srcPointer to data that will be copied to flash (32-bit).
[in]base_addrImage base address (in flash).
[in]sizeImage size in bytes.
Returns
Returns 0 if write was successful.

Variable Documentation

◆ ram_buffer

uint32_t ram_buffer[BUFFER_SIZE/4]

Main function

Note
This program requires the XIP module and UART0.
Returns
0 if execution was successful