mirror of
https://github.com/im-tomu/foboot.git
synced 2024-09-20 02:40:09 +00:00
foboot-main: wip commit
Now foboot-main has been proven to kind of work. When it's loaded to 0x1a000, the recovery image is able to properly locate it and jump to it. What isn't yet working is USB, however we are confident that our image is getting loaded properly, and other images load just fine, so it's a start at least. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
b6f3cc503d
commit
ffb0845971
@ -642,6 +642,53 @@ static inline unsigned char usb_ep_2_in_ibuf_empty_read(void) {
|
||||
return r;
|
||||
}
|
||||
|
||||
/* version */
|
||||
#define CSR_VERSION_BASE 0xe0007000
|
||||
#define CSR_VERSION_MAJOR_ADDR 0xe0007000
|
||||
#define CSR_VERSION_MAJOR_SIZE 1
|
||||
static inline unsigned char version_major_read(void) {
|
||||
unsigned char r = csr_readl(0xe0007000);
|
||||
return r;
|
||||
}
|
||||
#define CSR_VERSION_MINOR_ADDR 0xe0007004
|
||||
#define CSR_VERSION_MINOR_SIZE 1
|
||||
static inline unsigned char version_minor_read(void) {
|
||||
unsigned char r = csr_readl(0xe0007004);
|
||||
return r;
|
||||
}
|
||||
#define CSR_VERSION_REVISION_ADDR 0xe0007008
|
||||
#define CSR_VERSION_REVISION_SIZE 1
|
||||
static inline unsigned char version_revision_read(void) {
|
||||
unsigned char r = csr_readl(0xe0007008);
|
||||
return r;
|
||||
}
|
||||
#define CSR_VERSION_GITREV_ADDR 0xe000700c
|
||||
#define CSR_VERSION_GITREV_SIZE 4
|
||||
static inline unsigned int version_gitrev_read(void) {
|
||||
unsigned int r = csr_readl(0xe000700c);
|
||||
r <<= 8;
|
||||
r |= csr_readl(0xe0007010);
|
||||
r <<= 8;
|
||||
r |= csr_readl(0xe0007014);
|
||||
r <<= 8;
|
||||
r |= csr_readl(0xe0007018);
|
||||
return r;
|
||||
}
|
||||
#define CSR_VERSION_GITEXTRA_ADDR 0xe000701c
|
||||
#define CSR_VERSION_GITEXTRA_SIZE 2
|
||||
static inline unsigned short int version_gitextra_read(void) {
|
||||
unsigned short int r = csr_readl(0xe000701c);
|
||||
r <<= 8;
|
||||
r |= csr_readl(0xe0007020);
|
||||
return r;
|
||||
}
|
||||
#define CSR_VERSION_DIRTY_ADDR 0xe0007024
|
||||
#define CSR_VERSION_DIRTY_SIZE 1
|
||||
static inline unsigned char version_dirty_read(void) {
|
||||
unsigned char r = csr_readl(0xe0007024);
|
||||
return r;
|
||||
}
|
||||
|
||||
/* constants */
|
||||
#define NMI_INTERRUPT 0
|
||||
static inline int nmi_interrupt_read(void) {
|
||||
|
@ -11,19 +11,27 @@ SECTIONS
|
||||
{
|
||||
_ftext = .;
|
||||
*(.text.start)
|
||||
*(.text .stub .text.* .gnu.linkonce.t.*)
|
||||
_etext = .;
|
||||
} > sram
|
||||
} > rom
|
||||
|
||||
.data : AT (ADDR(.text) + SIZEOF (.text))
|
||||
.rodata :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_fdata = .;
|
||||
*(.text .stub .text.* .gnu.linkonce.t.*)
|
||||
_frodata = .;
|
||||
*(.rodata .rodata.* .gnu.linkonce.r.*)
|
||||
*(.rodata1)
|
||||
*(.srodata)
|
||||
_erodata = .;
|
||||
} > rom
|
||||
|
||||
.data : AT (ADDR(.rodata) + SIZEOF (.rodata))
|
||||
{
|
||||
. = ALIGN(4);
|
||||
_fdata = .;
|
||||
*(.data .data.* .gnu.linkonce.d.*)
|
||||
*(.data1)
|
||||
*(.ramtext .ramtext.*)
|
||||
_gp = ALIGN(16);
|
||||
*(.sdata .sdata.* .gnu.linkonce.s.* .sdata2 .sdata2.*)
|
||||
_edata = ALIGN(16); /* Make sure _edata is >= _gp. */
|
||||
|
@ -1,4 +1,4 @@
|
||||
MEMORY {
|
||||
sram : ORIGIN = 0x10001000, LENGTH = 131072-4096
|
||||
rom : ORIGIN = 0x00000000, LENGTH = 0x00002000
|
||||
sram : ORIGIN = 0x10000000, LENGTH = 128k
|
||||
rom : ORIGIN = 0x20000000 + 0x1a00, LENGTH = 0xc000
|
||||
}
|
||||
|
@ -6,8 +6,7 @@
|
||||
|
||||
_start:
|
||||
j crt_init
|
||||
.word 0x17ab0f23 // Magic number indicating we'll load to RAM
|
||||
.word 0x10001000 // Address in RAM to load
|
||||
.word 0x032bd37d // Magic number indicating this is a valid FBM
|
||||
|
||||
crt_init:
|
||||
la sp, _fstack + 4
|
||||
@ -25,7 +24,7 @@ bss_loop:
|
||||
bss_done:
|
||||
|
||||
// Load DATA section
|
||||
la t0, _etext
|
||||
la t0, _erodata
|
||||
la t1, _fdata
|
||||
la t2, _edata
|
||||
3:
|
||||
@ -43,7 +42,7 @@ bss_done:
|
||||
|
||||
call main
|
||||
|
||||
.section .text
|
||||
.section .ramtext
|
||||
.global trap_entry
|
||||
trap_entry:
|
||||
sw x1, - 1*4(sp)
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
struct ff_spi *spi;
|
||||
|
||||
__attribute__((section(".ramtext")))
|
||||
void isr(void)
|
||||
{
|
||||
unsigned int irqs;
|
||||
@ -110,21 +111,9 @@ static void init(void)
|
||||
usb_init();
|
||||
time_init();
|
||||
rgb_init();
|
||||
|
||||
spi = spiAlloc();
|
||||
spiSetPin(spi, SP_MOSI, 0);
|
||||
spiSetPin(spi, SP_MISO, 1);
|
||||
spiSetPin(spi, SP_WP, 2);
|
||||
spiSetPin(spi, SP_HOLD, 3);
|
||||
spiSetPin(spi, SP_CLK, 4);
|
||||
spiSetPin(spi, SP_CS, 5);
|
||||
spiSetPin(spi, SP_D0, 0);
|
||||
spiSetPin(spi, SP_D1, 1);
|
||||
spiSetPin(spi, SP_D2, 2);
|
||||
spiSetPin(spi, SP_D3, 3);
|
||||
spiInit(spi);
|
||||
}
|
||||
|
||||
__attribute__((section(".ramtext")))
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
(void)argc;
|
||||
|
@ -73,7 +73,7 @@ static void rgb_switch_mode(uint8_t mode,
|
||||
}
|
||||
|
||||
void rgb_mode_idle(void) {
|
||||
rgb_switch_mode(IDLE, 12, 14, 2, 3, 0x00/4, 0x4a/4, 0xe1/4);
|
||||
rgb_switch_mode(IDLE, 18, 5, 20, 3, 0x00/4, 0x7a/4, 0x31/4);
|
||||
}
|
||||
|
||||
void rgb_mode_writing(void) {
|
||||
|
@ -12,6 +12,7 @@ static uint8_t usb_configuration = 0;
|
||||
static uint32_t rx_buffer[USB_MAX_PACKET_SIZE/4];
|
||||
uint16_t last_request_and_type;
|
||||
|
||||
__attribute__((section(".ramtext")))
|
||||
void usb_setup(const struct usb_setup_request *setup)
|
||||
{
|
||||
const uint8_t *data = NULL;
|
||||
|
@ -79,6 +79,7 @@ void usb_disconnect(void) {
|
||||
usb_pullup_out_write(0);
|
||||
}
|
||||
|
||||
__attribute__((section(".ramtext")))
|
||||
void usb_connect(void) {
|
||||
|
||||
usb_ep_0_out_ev_pending_write(usb_ep_0_out_ev_enable_read());
|
||||
@ -114,6 +115,7 @@ void usb_init(void) {
|
||||
return;
|
||||
}
|
||||
|
||||
__attribute__((section(".ramtext")))
|
||||
void usb_isr(void) {
|
||||
uint8_t ep0o_pending = usb_ep_0_out_ev_pending_read();
|
||||
uint8_t ep0i_pending = usb_ep_0_in_ev_pending_read();
|
||||
@ -380,6 +382,7 @@ void usb_send_cb(int epnum, int (*cb)(uint8_t *, size_t, void *), void *ptr) {
|
||||
}
|
||||
}
|
||||
|
||||
__attribute__((section(".ramtext")))
|
||||
void usb_send(int epnum, const void *data, size_t total_count) {
|
||||
switch (epnum) {
|
||||
case 0:
|
||||
@ -431,6 +434,7 @@ int usb_recv(void *buffer, unsigned int buffer_len) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
__attribute__((section(".ramtext")))
|
||||
void usb_poll(void) {
|
||||
// If some data was received, then process it.
|
||||
while (usb_ep0out_rd_ptr != usb_ep0out_wr_ptr) {
|
||||
|
Loading…
Reference in New Issue
Block a user