Skip to content
This repository has been archived by the owner on Apr 27, 2023. It is now read-only.

Commit

Permalink
FSBL improvmenets
Browse files Browse the repository at this point in the history
 On branch master
 Your branch is up-to-date with 'origin/master'.

 Changes to be committed:
	modified:   src/fsbl/README.md
	modified:   src/fsbl/fsbl.c
  • Loading branch information
ben-marshall committed Sep 5, 2019
1 parent 1428572 commit 073b91e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/fsbl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ It is designed to work with the Xilinx UARTLite IP core.
- That there is a Xilinx UARTLite IP core accessible at
`0x4060000`.

- That there is a Xilinx AXI GPIO IP core accessible at
`0x40000000`.

- That the FSBL runs out of a *read only* memory.

- That the core is set up such that the post-reset PC value points
Expand Down Expand Up @@ -43,3 +46,7 @@ It is designed to work with the Xilinx UARTLite IP core.

6. The FSBL jumps to the specified start address, and relinquishes
control to the downloaded program.

At each step, an additional GPIO LED is turned on as a sort of "progress"
indicator for debugging.

24 changes: 22 additions & 2 deletions src/fsbl/fsbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
#define UART_BASE 0x40600000
#endif

#ifndef GPIO_BASE
#define GPIO_BASE 0x40000000
#endif

#define GPIO_LEDS 2

#define UART_RX 0
#define UART_TX 1
#define UART_ST 2
Expand All @@ -13,6 +19,8 @@
// Pointer to the UART register space.
static volatile uint32_t * uart = (volatile uint32_t*)(UART_BASE);

static volatile uint32_t * gpio = (volatile uint32_t*)(GPIO_BASE);

const uint32_t UART_CTRL_RST_TX_FIFO = 0x00000001;
const uint32_t UART_CTRL_RST_RX_FIFO = 0x00000002;
const uint32_t UART_CTRL_INT_ENA = 0x00000010;
Expand Down Expand Up @@ -51,12 +59,12 @@ void fsbl_print_welcome() {
// Welcome message
char * welcome = "scarv-cpu fsbl\n";

for(char * p = welcome; *p != 0; p++ ) {
for(int i = 0; welcome[i]; i ++) {

while(uart[UART_ST] & UART_STATUS_TX_FULL) {
// Do nothing.
}
uart[UART_TX] = *p;
uart[UART_TX] = welcome[i];

}
}
Expand All @@ -66,23 +74,33 @@ void fsbl_print_welcome() {
*/
void fsbl() {

gpio[GPIO_LEDS] = 0x1;

fsbl_uart_setup();

gpio[GPIO_LEDS] = 0x3;

fsbl_print_welcome();

gpio[GPIO_LEDS] = 0x7;

// First 4 bytes are the size of the program (in bytes).
uint32_t program_size =
((uint32_t)uart_rd_char() << 24) |
((uint32_t)uart_rd_char() << 16) |
((uint32_t)uart_rd_char() << 8) |
((uint32_t)uart_rd_char() << 0) ;

gpio[GPIO_LEDS] = 0xF;

// Next 4 bytes are a 32-bit destination address.
uint32_t program_dest =
((uint32_t)uart_rd_char() << 24) |
((uint32_t)uart_rd_char() << 16) |
((uint32_t)uart_rd_char() << 8) |
((uint32_t)uart_rd_char() << 0) ;

gpio[GPIO_LEDS] = 0x1F;

uint8_t * dest_ptr = (uint8_t*)program_dest;

Expand All @@ -92,6 +110,8 @@ void fsbl() {
dest_ptr[i] = uart_rd_char();

}

gpio[GPIO_LEDS] = 0x3F;

// Jump to the downloaded program.
__fsbl_goto_main((uint32_t*)program_dest);
Expand Down

0 comments on commit 073b91e

Please sign in to comment.