Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OMAP335x Support #1

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ CPPFLAGS = -Iinclude -D__LITTLE_ENDIAN__ -DTEXT_BASE=$(TEXT_BASE) -DBUILD_STYLE=
-DBUILD_TAG=\"$(BUILD_TAG)\"
ASFLAGS = -mcpu=cortex-a8 -DTEXT_BASE=$(TEXT_BASE) -D__ASSEMBLY__
LDFLAGS = -nostdlib -Wl,-Tldscript.ld
TEXT_BASE = 0x80000040
LOAD_BASE = 0x88000000
TEXT_BASE = 0x88000000
CROSS = arm-none-eabi-
CC = $(CROSS)gcc
AS = $(CROSS)gcc
CC = $(CROSS)gcc
AS = $(CROSS)gcc
LD = $(CROSS)ld
OBJCOPY = $(CROSS)objcopy
TARGET = SampleBooter.elf

Expand All @@ -22,22 +24,22 @@ SIZE = 32768
all: $(TARGET) $(OBJECTS)

mach.o: mach.img3
$(CROSS)ld -r -b binary -o mach.o mach.img3
$(CROSS)objcopy --rename-section .data=.kernel mach.o mach.o
$(LD) -r -b binary -o mach.o mach.img3
$(OBJCOPY) --rename-section .data=.kernel mach.o mach.o

rdsk.o: rdsk.img3
$(CROSS)ld -r -b binary -o rdsk.o rdsk.img3
$(CROSS)objcopy --rename-section .data=.ramdisk rdsk.o rdsk.o
$(LD) -r -b binary -o rdsk.o rdsk.img3
$(OBJCOPY) --rename-section .data=.ramdisk rdsk.o rdsk.o

xmdt.o: xmdt.img3
$(CROSS)ld -r -b binary -o xmdt.o xmdt.img3
$(CROSS)objcopy --rename-section .data=.devicetree xmdt.o xmdt.o
$(LD) -r -b binary -o xmdt.o xmdt.img3
$(OBJCOPY) --rename-section .data=.devicetree xmdt.o xmdt.o

$(TARGET): $(OBJECTS)
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o version.o version.c
$(CC) $(LDFLAGS) $(OBJECTS) version.o -o $(TARGET) -lgcc
$(OBJCOPY) -g -S -O binary $(TARGET) $(TARGET).raw
mkimage -A arm -O linux -T kernel -C none -a $(TEXT_BASE) -e $(TEXT_BASE) -n "Linux 2.6" -d $(TARGET).raw $(TARGET).uImage
mkimage -A arm -O linux -T kernel -C none -a $(LOAD_BASE) -e $(TEXT_BASE) -n "XNU" -d $(TARGET).raw $(TARGET).uImage
# rm -f $(TARGET) $(TARGET).raw

%.o: %.s
Expand Down
3 changes: 3 additions & 0 deletions bootx.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,12 +525,15 @@ void start_darwin(void)
/* Map device tree. */
assert(prepare_devicetree());

printf("Enter ramdisk into /chosen/memory-map and flatten.\n");
/* Enter ramdisk into /chosen/memory-map and flatten. */
assert(prepare_devicetree_stage2());

printf("Copy boot-args over to kernel region...\n");
/* Copy boot-args over to kernel region. */
assert((args = prepare_finalized_boot_args()) != NULL);

printf("Fire the kernel!\n");
/* Jump to the kernel. */
start_routine = (kernel_start *) kernel_entrypoint;
printf
Expand Down
30 changes: 16 additions & 14 deletions debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,21 @@
#include <stdarg.h>

/* Uart stuff */
#define AMBA_UART_DR(base) (*(volatile unsigned char *)((base) + 0x00))
#define AMBA_UART_LCRH(base) (*(volatile unsigned char *)((base) + 0x2c))
#define AMBA_UART_CR(base) (*(volatile unsigned char *)((base) + 0x30))
#define AMBA_UART_FR(base) (*(volatile unsigned char *)((base) + 0x18))
#define REALVIEW_PBA8_SDRAM6_BASE 0x70000000 /* SDRAM bank 6 256MB */
#define REALVIEW_PBA8_SDRAM7_BASE 0x80000000 /* SDRAM bank 7 256MB */
#define REALVIEW_PBA8_UART0_BASE 0x10009000 /* UART 0 */

#define UART_FR_TXFE (1 << 7)
#define UART_FR_TXFF (1 << 5)
#define SDRAM_BASE 0x80000000 // spruh73i.pdf, Page:170, EMIF0 SDRAM, up to 1G

#define UART_FR_RXFE (1 << 4)
#define UART_FR_RXFF (1 << 6)
#define UART0_BASE 0x44E09000 // spruh73i.pdf, Page:171
#define UART1_BASE 0x48022000 // spruh73i.pdf, Page:172
#define UART2_BASE 0x48024000 // spruh73i.pdf, Page:172
#define UART3_BASE 0x481A6000 // spruh73i.pdf, Page:174
#define UART4_BASE 0x481A8000 // spruh73i.pdf, Page:174
#define UART5_BASE 0x481AA000 // spruh73i.pdf, Page:174

#define AMBA_UART_DR(base) (*(volatile uint16_t *)((base) + 0x00))
#define AMBA_UART_SSR(base) (*(volatile uint16_t *)((base) + 0x44)) // SSR Register, spruh73i.pdf, Page:4074

#define UART_TX_IS_FULL(base) (AMBA_UART_SSR(base) & 1) // SSR Register, spruh73i.pdf, Page:4074
#define UART_QUEUE_CHAR(base, c) (AMBA_UART_DR(base) = c)

#define barrier() __asm__ __volatile__("": : :"memory");

Expand All @@ -52,7 +54,7 @@
*
* Put a character to the system console.
*/
uint32_t uart_base = 0x10009000;
uint32_t uart_base = UART0_BASE;
static int inited_printf = 1;
void uart_putchar(int c)
{
Expand All @@ -62,12 +64,12 @@ void uart_putchar(int c)
if (c == '\n')
uart_putchar('\r');

while (AMBA_UART_FR(uart_base) & UART_FR_TXFF) {
while (UART_TX_IS_FULL(uart_base)) {
/* Transmit FIFO full, wait */
barrier();
}

AMBA_UART_DR(uart_base) = c;
UART_QUEUE_CHAR(uart_base, c);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions ldscript.ld
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ENTRY(_start)
SECTIONS
{
/* Read-only sections, merged into text segment: */
. = 0x80000040;
. = 0x88000000;
.text :
{
*(.text)
Expand Down Expand Up @@ -78,8 +78,8 @@ so
. = _start + 32768;
__end = . ;
.mach : { mach.o }
.ramdisk : { rdsk.o }
.xmdt : { xmdt.o }


PROVIDE (__end = .);
}
Expand Down
9 changes: 7 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,13 @@ static void populate_memory_info(struct atag *atags)

is_first_region = 1;

printf("mem_start = %02lx\n", atags->u.mem.start);
printf("mem_size = %02lx\n", atags->u.mem.size);

gBootArgs.physBase = atags->u.mem.start;
gBootArgs.memSize = atags->u.mem.size;

malloc_init((char *)atags->u.mem.start + atags->u.mem.size -
malloc_init((char *)gBootArgs.physBase + gBootArgs.memSize -
MALLOC_SIZE, MALLOC_SIZE);

is_malloc_inited = 1;
Expand Down Expand Up @@ -111,6 +114,7 @@ corestart_main(uint32_t __unused, uint32_t machine_type, struct atag *atags)
/*
* Verify machine type.
*/
#if 0
if (machine_type != MACH_TYPE_REALVIEW_PBA8) {
printf("********************************\n"
"* *\n"
Expand All @@ -121,7 +125,8 @@ corestart_main(uint32_t __unused, uint32_t machine_type, struct atag *atags)
MACH_TYPE_REALVIEW_PBA8);
_locore_halt_system();
}

#endif

/*
* Announce ourselves.
*/
Expand Down
4 changes: 4 additions & 0 deletions printf.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

#include "printf.h"

#ifndef PRINTF_LONG_SUPPORT
#define PRINTF_LONG_SUPPORT
#endif

typedef void (*putcf) (void *, char);
static putcf stdout_putf;
static void *stdout_putp;
Expand Down
2 changes: 2 additions & 0 deletions start.S
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ EnterARM(locore_jump_to)
bic r0, r0, #(1 << 2)
mcr p15, 0, r0, c1, c0, 0

#if 0
/* Disable VFP/SIMD */
mov r0, #0x00000000
mcr p10, #0x7, r0, c8, c0, #0
Expand All @@ -92,6 +93,7 @@ EnterARM(locore_jump_to)
mrc p15, 0, r0, c1, c0, 2
bic r0, r0, #0x00f00000
mcr p15, 0, r0, c1, c0, 2
#endif

/* Clear caches. */
mov r0, #0
Expand Down
8 changes: 8 additions & 0 deletions uEnv.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
console=ttyO0,115200n8

ipaddr=10.0.76.192
serverip=10.0.76.20
ethaddr=de:ad:be:ef:c0:fc
bootargs=-v -s serial=3 symbolicate-panics=1 rd=md0 silence_kprintf=1
uenvcmd=tftpboot 0x88000000 /boot.uImage; bootm 0x88000000