This commit is contained in:
2015-11-15 18:18:42 +00:00
parent 9ac343fc45
commit 72be7b0c2f
580 changed files with 356252 additions and 6 deletions
+36
View File
@@ -0,0 +1,36 @@
CC=arm-elf-gcc
LD=arm-elf-ld
AR=arm-elf-ar
AS=arm-elf-as
OBJCOPY=arm-elf-objcopy
OBJDUMP=arm-elf-objdump
CFLAGS=-nostartfiles -nostdlib -nodefaultlibs -g -O2
LDFLAGS=-Tloader.lds
all: loader128.bin loader256.bin
headers: loader128.bin loader256.bin
gcc -o bin2c bin2c.c
./bin2c loader128_data < loader128.bin > ../loader128_data.h
./bin2c loader256_data < loader256.bin > ../loader256_data.h
loader128.elf: crt0.o loader128.o
${CC} ${CFLAGS} ${LDFLAGS} -o $@ $^
loader256.elf: crt0.o loader256.o
${CC} ${CFLAGS} ${LDFLAGS} -o $@ $^
loader128.o: loader.c
${CC} ${CFLAGS} -DPAGE_SIZE=128 -c -o $@ $^
loader256.o: loader.c
${CC} ${CFLAGS} -DPAGE_SIZE=256 -c -o $@ $^
%.bin: %.elf
${OBJCOPY} -O binary $^ $@
clean:
rm -f loader128.o loader256.o loader128.elf loader256.elf \
loader128.bin loader256.bin crt0.o bin2c bin2c.exe
+61
View File
@@ -0,0 +1,61 @@
/*
* loader/at91.h
*
* Copyright (C) 2006 Erik Gilling, all rights reserved
*
* 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, version 2.
*
*/
#define AT91_FLASH_ADDR ((uint32_t *) 0x100000)
typedef unsigned int uint32_t;
typedef signed int int32_t;
typedef unsigned short uint16_t;
typedef signed short int16_t;
typedef unsigned char uint8_t;
typedef signed char int8_t;
typedef volatile uint32_t arm_reg_t;
typedef struct {
arm_reg_t rcr; /* 00 - Remap Control Register */
arm_reg_t asr; /* 04 - Abort Status Rebister */
arm_reg_t aasr; /* 08 - Abort Address Status Register */
arm_reg_t res[21]; /* 0C..5C - Reserved */
arm_reg_t fmr; /* 60 - Flash Mode Register */
arm_reg_t fcr; /* 64 - Flash Command Register */
arm_reg_t fsr; /* 68 - Flash Status Register */
} at91_mc_t;
extern volatile at91_mc_t mc;
#define AT91_MC_FMR_FRDY (1<<0)
#define AT91_MC_FMR_LOCKE (1<<2)
#define AT91_MC_FMR_PROGE (1<<3)
#define AT91_MC_FMR_NEBP (1<<7)
#define AT91_MC_FMR_WAIT_STATE_1_2 (0<<8)
#define AT91_MC_FMR_WAIT_STATE_2_3 (1<<8)
#define AT91_MC_FMR_WAIT_STATE_3_4 (2<<8)
#define AT91_MC_FMR_WAIT_STATE_4_4 (3<<8)
#define AT91_MC_FMR_FMCN( x ) (((x)&0xff) << 16)
#define AT91_MC_FCR_FCMD_NOP 0x0
#define AT91_MC_FCR_FCMD_WP 0x1
#define AT91_MC_FCR_FCMD_SLB 0x2
#define AT91_MC_FCR_FCMD_WPL 0x3
#define AT91_MC_FCR_FCMD_CLB 0x4
#define AT91_MC_FCR_FCMD_EA 0x8
#define AT91_MC_FCR_FCMD_SGPB 0xb
#define AT91_MC_FCR_FCMD_CGPB 0xd
#define AT91_MC_FCR_FCMD_SSB 0xf
#define AT91_MC_FCR_PAGEN( x ) (((x)&0x3ff)<<8)
#define AT91_MC_FCR_KEY (0x5A << 24)
+30
View File
@@ -0,0 +1,30 @@
#include <stdio.h>
int main( int argc, char *argv[] )
{
char *data_name = "data";
int c;
int i=0;
if( argc == 2 ) {
data_name = argv[1];
}
printf( "uint8_t %s[] = {\n", data_name );
while( (c = getchar()) >= 0 ) {
if( i== 0 ) {
printf( "\t" );
} else if( i%8 == 0 ) {
printf( ",\n\t" );
} else {
printf( ", " );
}
i++;
printf( "0x%02x", c );
}
printf( "\n};\n" );
return 0;
}
+28
View File
@@ -0,0 +1,28 @@
//
// loader/crt0.S
//
// Copyright (C) 2006 Erik Gilling, all rights reserved
//
// 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, version 2.
//
//
.EQU STACK, 0x201C00
.code 32
.align 2
.global _entry
.func _entry
_entry:
// init stack
ldr sp, =STACK
// save lr
stmfd sp!, {lr}
bl main
ldmia sp!, {r0}
bx r0
+48
View File
@@ -0,0 +1,48 @@
/*
* loader/loader.c
*
* Copyright (C) 2006 Erik Gilling, all rights reserved
*
* 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, version 2.
*
*/
#include "at91.h"
// SAM-BA apears to write the following data to 0x201400
//
// 0x00: data0
// 0x01: data1
// ...
// PAGE_SIZE-1: last data byte
// PAGE_SIZE : page number to write
#define SAMBA_PAGE_BUFF ((uint32_t *) 0x201400)
int main( void )
{
int i;
uint32_t *page_buff = SAMBA_PAGE_BUFF;
// keep this in units of 32 bit words
int page_num = *(page_buff+PAGE_SIZE/4);
int page_offset = page_num * PAGE_SIZE/4;
// wait for mc to be ready
while( !(mc.fsr & AT91_MC_FMR_FRDY) ) { }
// write samba page buffer to flash buffer
for( i=0 ; i < (PAGE_SIZE/4) ; i++ ) {
AT91_FLASH_ADDR[ page_offset + i ] = page_buff[i];
}
// write page
mc.fcr = AT91_MC_FCR_FCMD_WP | AT91_MC_FCR_PAGEN(page_num) |
AT91_MC_FCR_KEY;
// dont wait for mc to be ready here so that flash ops can stack
return 0;
}
+128
View File
@@ -0,0 +1,128 @@
/***********************************************************************/
/* */
/* ROM.ld: Linker Script File */
/* */
/***********************************************************************/
ENTRY(_entry)
MEMORY
{
LOADER(rwx) : ORIGIN = 0x00201600, LENGTH = 0xEA00
}
/* Section Definitions */
SECTIONS
{
/* first section is .text which is used for code */
.text :
{
_text = .;
PROVIDE (text = _text);
*crt0.o (.text) /* Startup code */
*(.text .text.*) /* remaining code */
*(.gnu.linkonce.t.*)
*(.glue_7)
*(.glue_7t)
*(.gcc_except_table)
*(.rodata) /* read-only data (constants) */
*(.rodata*)
*(.gnu.linkonce.r.*)
} > LOADER
. = ALIGN(4);
_etext = . ;
PROVIDE (etext = .);
/* .data section which is used for initialized data */
.data : AT (_etext)
{
_data = .;
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
SORT(CONSTRUCTORS) /* mt 4/2005 */
} > LOADER
. = ALIGN(4);
_edata = . ;
PROVIDE (edata = .);
/* .bss section which is used for uninitialized data */
.bss (NOLOAD) :
{
__bss_start = . ;
__bss_start__ = . ;
*(.bss)
*(.gnu.linkonce.b*)
*(COMMON)
. = ALIGN(4);
} > LOADER
. = ALIGN(4);
__bss_end__ = . ;
PROVIDE (__bss_end = .);
_end = . ;
PROVIDE (end = .);
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
}
PROVIDE(tc = 0xFFFA0000);
PROVIDE(udp = 0xFFFB0000);
PROVIDE(twi = 0xFFFB8000);
PROVIDE(usart0 = 0xFFFC0000);
PROVIDE(usart1 = 0xFFFC4000);
PROVIDE(pwmc = 0xFFFCC000);
PROVIDE(ssc = 0xFFFD4000);
PROVIDE(adc = 0xFFFD8000);
PROVIDE(spi = 0xFFFE0000);
PROVIDE(aic = 0xFFFFF000);
PROVIDE(dbgu = 0xFFFFF200);
PROVIDE(pioa = 0xFFFFF400);
PROVIDE(pmc = 0xFFFFFC00);
PROVIDE(rstc = 0xFFFFFD00);
PROVIDE(rtt = 0xFFFFFD20);
PROVIDE(pit = 0xFFFFFD30);
PROVIDE(wdt = 0xFFFFFD40);
PROVIDE(vreg = 0xFFFFFD60);
PROVIDE(mc = 0xFFFFFF00);