Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
32
Issues
32
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Software for White Rabbit PTP Core
Commits
ec7eb6b8
Commit
ec7eb6b8
authored
Nov 18, 2020
by
Tomasz Wlostowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: clean up the eRTM14 UART bootloader
parent
0d6df9e0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
47 additions
and
31456 deletions
+47
-31456
Makefile
tools/uart-bootloader/Makefile
+3
-1
board.h
tools/uart-bootloader/board.h
+0
-54
boot.c
tools/uart-bootloader/boot.c
+22
-24
timer.c
tools/uart-bootloader/timer.c
+12
-2
usb-bootloader.py
tools/uart-bootloader/usb-bootloader.py
+10
-3
wrc-bootloader.ram
tools/uart-bootloader/wrc-bootloader.ram
+0
-31372
No files found.
tools/uart-bootloader/Makefile
View file @
ec7eb6b8
...
...
@@ -7,7 +7,9 @@ OBJDUMP = $(CROSS_COMPILE)objdump
OBJCOPY
=
$(CROSS_COMPILE)
objcopy
SIZE
=
$(CROSS_COMPILE)
size
CFLAGS
=
-Os
-I
../common
-I
.
-mmultiply-enabled
-mbarrel-shift-enabled
-ffunction-sections
-fdata-sections
-I
../../include
-DCONFIG_ERTM14
-I
../../pp_printf
-DCONFIG_PRINT_BUFSIZE
=
128
AUTOCONF
?=
../../include/generated/autoconf.h
CFLAGS
=
-Werror
-include
$(AUTOCONF)
-I
../../
-Os
-I
../common
-I
.
-mmultiply-enabled
-mbarrel-shift-enabled
-ffunction-sections
-fdata-sections
-I
../../include
-DCONFIG_ERTM14
-I
../../pp_printf
-DCONFIG_PRINT_BUFSIZE
=
128
OBJS
=
boot-crt0.o boot.o timer.o ../../dev/bb_spi.o ../../dev/gpio.o ../../dev/spi_flash.o ../../dev/simple_uart.o ../../pp_printf/printf.o ../../pp_printf/vsprintf-mini.o ../../pp_printf/div64.o
LDS
=
boot.ld
LDFLAGS
=
-Os
-mmultiply-enabled
-mbarrel-shift-enabled
-Wl
,--gc-sections
...
...
tools/uart-bootloader/board.h
deleted
100644 → 0
View file @
0d6df9e0
/*
* DSI Shield
*
* Copyright (C) 2013-2014 twl
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* board.h - system/hardware definitions */
#ifndef __BOARD_H
#define __BOARD_H
#include <stdint.h>
#define BASE_CLOCK 62500000 // Xtal frequency
#define CPU_CLOCK 62500000 // Xtal frequency
#define CONSOLE_UART_BAUDRATE 921600 // Xtal frequency
#define BASE_UART 0x20500
#define BASE_SYSCON 0x20400
#define UART_BAUDRATE 115200
void
timer_init
();
uint32_t
timer_get_tics
();
static
inline
void
writel
(
uint32_t
reg
,
uint32_t
val
)
{
*
(
volatile
uint32_t
*
)(
reg
)
=
val
;
}
static
inline
uint32_t
readl
(
uint32_t
reg
)
{
return
*
(
volatile
uint32_t
*
)(
reg
);
}
static
inline
uint32_t
get_ms_ticks
()
{
return
timer_get_tics
();
}
#endif
tools/uart-bootloader/boot.c
View file @
ec7eb6b8
...
...
@@ -21,8 +21,13 @@
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#undef CONFIG_ERTM14_FLASH
#ifndef CONFIG_TARGET_ERTM14
#error "The bootloader is made so far only for the eRTM14/15 boards. If you're building it for another board, comment out this error (but beware, here be dragons!)"
#endif
#define CONFIG_ERTM14_FLASH
#include "board.h"
...
...
@@ -67,20 +72,15 @@ int boot_wait;
static
uint32_t
orig_reset_vector
=
0x4
;
typedef
void
(
*
voidfunc_t
)();
void
start_user
(
void
);
struct
simple_uart_device
dev_uart
;
#ifdef CONFIG_ERTM14_FLASH
#define BASE_AUXWB 0x48000
struct
gpio_device
gpio_aux
;
struct
spi_bus
spi_flash
;
struct
spi_flash_device
dev_flash
;
void
start_user
();
static
void
boot_sysc_gpio_set_dir
(
const
struct
gpio_pin
*
pin
,
int
dir
)
{
}
...
...
@@ -89,14 +89,14 @@ static void boot_sysc_gpio_set_out(const struct gpio_pin *pin, int value)
{
if
(
value
)
writel
(
(
1
<<
pin
->
pin
),
(
void
*
)
(
BASE_SYSCON
+
SYSC_REG_GPSR
)
);
writel
(
(
1
<<
pin
->
pin
),
(
void
*
)
(
(
void
*
)
BASE_SYSCON
+
SYSC_REG_GPSR
)
);
else
writel
(
(
1
<<
pin
->
pin
),
(
void
*
)
(
BASE_SYSCON
+
SYSC_REG_GPCR
)
);
writel
(
(
1
<<
pin
->
pin
),
(
void
*
)
(
(
void
*
)
BASE_SYSCON
+
SYSC_REG_GPCR
)
);
}
static
int
boot_sysc_gpio_read_pin
(
const
struct
gpio_pin
*
pin
)
{
return
readl
(
BASE_SYSCON
+
SYSC_REG_GPSR
)
&
(
1
<<
pin
->
pin
)
?
1
:
0
;
return
readl
(
(
void
*
)
BASE_SYSCON
+
SYSC_REG_GPSR
)
&
(
1
<<
pin
->
pin
)
?
1
:
0
;
}
static
const
struct
gpio_device
boot_syscon_gpio
=
{
...
...
@@ -106,22 +106,20 @@ static const struct gpio_device boot_syscon_gpio = {
boot_sysc_gpio_read_pin
};
static
const
struct
gpio_pin
boot_pin_sysc_spi_sclk
=
{
&
boot_syscon_gpio
,
10
};
static
const
struct
gpio_pin
boot_pin_sysc_spi_ncs
=
{
&
boot_syscon_gpio
,
11
};
static
const
struct
gpio_pin
boot_pin_sysc_spi_mosi
=
{
&
boot_syscon_gpio
,
12
};
static
const
struct
gpio_pin
boot_pin_sysc_spi_miso
=
{
&
boot_syscon_gpio
,
13
};
static
struct
gpio_pin
boot_pin_sysc_spi_sclk
=
{
&
boot_syscon_gpio
,
10
};
static
struct
gpio_pin
boot_pin_sysc_spi_ncs
=
{
&
boot_syscon_gpio
,
11
};
static
struct
gpio_pin
boot_pin_sysc_spi_mosi
=
{
&
boot_syscon_gpio
,
12
};
static
struct
gpio_pin
boot_pin_sysc_spi_miso
=
{
&
boot_syscon_gpio
,
13
};
void
boot_flash_init
()
{
wb_gpio_create
(
&
gpio_aux
,
BASE_AUXWB
);
bb_spi_create
(
&
spi_flash
,
&
boot_pin_sysc_spi_ncs
,
&
boot_pin_sysc_spi_mosi
,
&
boot_pin_sysc_spi_miso
,
&
boot_pin_sysc_spi_sclk
,
10
);
spi_flash_create
(
&
dev_flash
,
&
spi_flash
,
16384
,
0x0
);
spi_flash_create
(
&
dev_flash
,
&
spi_flash
,
16384
,
0
);
}
#endif
...
...
@@ -250,7 +248,7 @@ void on_cmd_get_flash_id(uint8_t *payload, int len)
{
uint32_t
id
=
spi_flash_read_id
(
&
dev_flash
);
send_reply
(
RSP_OK
,
4
,
&
id
);
send_reply
(
RSP_OK
,
4
,
(
uint8_t
*
)
&
id
);
}
#endif
...
...
@@ -400,10 +398,8 @@ void boot_fsm()
#define ERTM14_FLASH_PAGE_SIZE 65536
#define ERTM14_FLASH_SIZE 16777216
#define ERTM14_FIRMWARE_MAGIC 0xf1dee41a
void
try_flash_boot
()
{
#ifdef CONFIG_ERTM14_FLASH
uint8_t
buf
[
512
];
uint32_t
offset
;
for
(
offset
=
0
;
offset
<
ERTM14_FLASH_SIZE
;
offset
+=
ERTM14_FLASH_PAGE_SIZE
)
...
...
@@ -419,19 +415,21 @@ void try_flash_boot()
start_user
();
}
}
#endif
}
void
start_user
()
void
start_user
(
void
)
{
voidfunc_t
f
=
(
voidfunc_t
)
orig_reset_vector
;
f
();
}
void
dev_dbg
()
{
/* stub to avoid linking errors */
}
int
boot_main
()
{
suart_init_default_baudrate
(
&
dev_uart
,
BASE_UART
);
...
...
tools/uart-bootloader/timer.c
View file @
ec7eb6b8
/*
* This work is part of the White Rabbit project
*
* Copyright (C) 2011 CERN (www.cern.ch)
* Author: Grzegorz Daniluk <grzegorz.daniluk@cern.ch>
*
* Released according to the GNU GPL, version 2 or any later version.
*/
#include "board.h"
#include "hw/wrc_syscon_regs.h"
void
timer_init
(
int
enable
)
{
writel
(
SYSC_TCR_ENABLE
,
BASE_SYSCON
+
SYSC_REG_TCR
);
writel
(
SYSC_TCR_ENABLE
,
(
void
*
)
BASE_SYSCON
+
SYSC_REG_TCR
);
}
uint32_t
timer_get_tics
()
{
return
readl
(
BASE_SYSCON
+
SYSC_REG_TVR
);
return
readl
(
(
void
*
)
BASE_SYSCON
+
SYSC_REG_TVR
);
}
tools/uart-bootloader/usb-bootloader.py
View file @
ec7eb6b8
...
...
@@ -344,8 +344,9 @@ def main(argv):
our_port
=
"/dev/ttyUSB0"
do_flash
=
False
run_term
=
False
try
:
opts
,
args
=
getopt
.
getopt
(
argv
[
1
:],
"hf:p:"
,
[
"uart"
])
opts
,
args
=
getopt
.
getopt
(
argv
[
1
:],
"hf:p:
t
"
,
[
"uart"
])
except
getopt
.
GetoptError
:
print
(
'Usage:
%
s [-f] [-p serial_port_device] file.bin'
%
argv
[
0
])
sys
.
exit
(
2
)
...
...
@@ -359,12 +360,16 @@ def main(argv):
print
(
'-p / --port: - specifies the serial port device (default:
%
s)'
%
our_port
)
print
(
'-t / --term: - runs a serial terminal on the specified port after programming'
)
sys
.
exit
()
elif
opt
in
(
"-f"
,
"--flash"
):
flash_target
=
arg
flash_target
=
arg
do_flash
=
True
elif
opt
in
(
"-p"
,
"--port"
):
our_port
=
arg
elif
opt
in
(
"-t"
,
"--term"
):
run_term
=
True
else
:
print
(
"Unrecognized option '
%
s'"
%
opt
)
...
...
@@ -380,7 +385,9 @@ def main(argv):
boot
.
program_flash
(
fw
,
flash_target
)
else
:
boot
.
load_ram
(
fw
,
0x0
)
run_terminal
(
boot
.
sock
)
if
run_term
:
run_terminal
(
boot
.
sock
)
if
__name__
==
"__main__"
:
...
...
tools/uart-bootloader/wrc-bootloader.ram
deleted
100644 → 0
View file @
0d6df9e0
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment