# HG changeset patch # User Paul Boddie # Date 1433525656 -7200 # Node ID d94bf387cc1127cdf807f04386a86eb58dd5e243 # Parent ed647dd06e43ce41b9c69ffc204f0676b7f46a67 Added support for multiple stages. diff -r ed647dd06e43 -r d94bf387cc11 Makefile --- a/Makefile Fri Jun 05 19:07:33 2015 +0200 +++ b/Makefile Fri Jun 05 19:34:16 2015 +0200 @@ -32,35 +32,42 @@ -ffreestanding -fno-hosted -fno-builtin \ -march=mips32 -mno-abicalls \ -Iinclude -I$(ASM_INC) -I$(ASM_INC)/asm/mach-generic -LDFLAGS = -nostdlib -EL -T target.ld +LDFLAGS = -nostdlib -EL -PAYLOAD = stage1.bin +PAYLOAD = stage1.bin stage2.bin TARGET = $(PAYLOAD:.bin=.elf) DUMP = $(PAYLOAD:.bin=.dump) MAP = $(PAYLOAD:.bin=.map) -SRC = head.S stage1.c board-nanonote.c -OBJ = $(filter %.o,$(SRC:.c=.o) $(SRC:.S=.o)) + +SRC1 = head1.S stage1.c board-nanonote.c +SRC2 = head2.S stage2.c board-nanonote.c +OBJ1 = $(filter %.o,$(SRC1:.c=.o) $(SRC1:.S=.o)) +OBJ2 = $(filter %.o,$(SRC2:.c=.o) $(SRC2:.S=.o)) +OBJ = $(OBJ1) $(OBJ2) .PHONY: all clean distclean all: $(PAYLOAD) clean: - rm -f $(OBJ) $(TARGET) $(PAYLOAD) $(DUMP) $(MAP) System.map + rm -f $(OBJ) $(TARGET) $(PAYLOAD) $(DUMP) $(MAP) #System.map distclean: clean echo "Nothing else to clean." $(PAYLOAD): $(TARGET) - $(OBJCOPY) -O binary $< $@+ - $(OBJDUMP) -D $< > $(DUMP) - $(OBJDUMP) -h $< > $(MAP) - $(NM) -n $< > System.map + $(OBJCOPY) -O binary $(@:.bin=.elf) $@+ + $(OBJDUMP) -D $(@:.bin=.elf) > $(@:.bin=.dump) + $(OBJDUMP) -h $(@:.bin=.elf) > $(@:.bin=.map) + #$(NM) -n $< > System.map chmod -x $@+ mv -f $@+ $@ -$(TARGET): $(OBJ) - $(LD) $(LDFLAGS) $(OBJ) -o $@ +stage1.elf: $(OBJ1) + $(LD) $(LDFLAGS) -T $(@:.elf=.ld) $(OBJ1) -o $@ + +stage2.elf: $(OBJ2) + $(LD) $(LDFLAGS) -T $(@:.elf=.ld) $(OBJ2) -o $@ .c.o: $(CC) -c $(CFLAGS) $< -o $@ diff -r ed647dd06e43 -r d94bf387cc11 board-nanonote.c --- a/board-nanonote.c Fri Jun 05 19:07:33 2015 +0200 +++ b/board-nanonote.c Fri Jun 05 19:34:16 2015 +0200 @@ -34,7 +34,10 @@ * Initialize SDRAM pins */ __gpio_as_sdram_32bit(); +} +void gpio_init2(void) +{ /* * Initialize LCD pins */ diff -r ed647dd06e43 -r d94bf387cc11 head.S --- a/head.S Fri Jun 05 19:07:33 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - * head.S - * - * Entry point of the firmware. - * The firmware code are executed in the ICache. - * - * Copyright 2009 (C) Qi Hardware Inc., - * Author: Xiangfu Liu - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 3 as published by the Free Software Foundation. - * - * 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, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA - */ - - .text - - .extern c_main - - .globl _start - .set noreorder -_start: - b real_start - nop - .word 0x0 /* address: 0x80002008 */ - .word 0x0 - .word 0x0 - .word 0x0 - .word 0x0 - .word 0x0 - .word 0x0 - .word 0x0 - /* reserve 8 words for args - * this is must big then sizeof(sturct fw_args) - */ -real_start: - /* - * setup stack, jump to C code - */ - la $29, 0x80004000 /* sp */ - j c_main - nop - - .set reorder diff -r ed647dd06e43 -r d94bf387cc11 head1.S --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/head1.S Fri Jun 05 19:34:16 2015 +0200 @@ -0,0 +1,53 @@ +/* + * head.S + * + * Entry point of the firmware. + * The firmware code are executed in the ICache. + * + * Copyright 2009 (C) Qi Hardware Inc., + * Author: Xiangfu Liu + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 3 as published by the Free Software Foundation. + * + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA + */ + + .text + + .extern c_main + + .globl _start + .set noreorder +_start: + b real_start + nop + .word 0x0 /* address: 0x80002008 */ + .word 0x0 + .word 0x0 + .word 0x0 + .word 0x0 + .word 0x0 + .word 0x0 + .word 0x0 + /* reserve 8 words for args + * this is must big then sizeof(sturct fw_args) + */ +real_start: + /* + * setup stack, jump to C code + */ + la $29, 0x80004000 /* sp */ + j c_main + nop + + .set reorder diff -r ed647dd06e43 -r d94bf387cc11 include/nanonote.h --- a/include/nanonote.h Fri Jun 05 19:07:33 2015 +0200 +++ b/include/nanonote.h Fri Jun 05 19:34:16 2015 +0200 @@ -36,6 +36,8 @@ #define GPIO_SD_CD_N GPIO_SD_DETECT /* SD Card insert detect */ #define GPIO_SD_VCC_EN_N GPIO_SDPW_EN /* SD Card Power Enable */ +#define GPIO_SD_CMD (3 * 32 + 8) + #define SPEN GPIO_LCD_CS /* LCDCS :Serial command enable */ #define SPDA (2 * 32 + 22) /* LCDSCL:Serial command clock input */ #define SPCK (2 * 32 + 23) /* LCDSDA:Serial command data input */ diff -r ed647dd06e43 -r d94bf387cc11 stage1.ld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stage1.ld Fri Jun 05 19:34:16 2015 +0200 @@ -0,0 +1,31 @@ +OUTPUT_ARCH(mips) +ENTRY(_start) +MEMORY +{ + ram : ORIGIN = 0x80002000 , LENGTH = 0x100000 +} + +SECTIONS +{ + . = ALIGN(4); + .text : { *(.text*) } > ram + + . = ALIGN(4); + .rodata : { *(.rodata*) } > ram + + . = ALIGN(4); + .sdata : { *(.sdata*) } > ram + + . = ALIGN(4); + .data : { *(.data*) *(.scommon*) *(.reginfo*) } > ram + + _gp = ABSOLUTE(.); /* Base of small data */ + + .got : { *(.got*) } > ram + + . = ALIGN(4); + .sbss : { *(.sbss*) } > ram + .bss : { *(.bss*) } > ram + . = ALIGN (4); +} + diff -r ed647dd06e43 -r d94bf387cc11 stage2.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stage2.c Fri Jun 05 19:34:16 2015 +0200 @@ -0,0 +1,46 @@ +/* + * Ben NanoNote stage 2 payload test. + * + * Copyright (C) 2015 Paul Boddie + * Copyright (C) Wolfgang Spraul + * + * 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 . + */ + +#include "jz4740.h" +#include "board-nanonote.h" +#include "nanonote.h" + +/* These arguments are initialised by usbboot and are defined in... + /etc/xburst-tools/usbboot.cfg. */ + +struct fw_args *fw_args; +volatile u32 CPU_ID; +volatile u32 UART_BASE; +volatile u32 CONFIG_BAUDRATE; +volatile u8 SDRAM_BW16; +volatile u8 SDRAM_BANK4; +volatile u8 SDRAM_ROW; +volatile u8 SDRAM_COL; +volatile u8 CONFIG_MOBILE_SDRAM; +volatile u32 CFG_CPU_SPEED; +volatile u32 CFG_EXTAL; +volatile u8 PHM_DIV; +volatile u8 IS_SHARE; + +void c_main(void) +{ + __gpio_as_output(GPIO_SD_CMD); + __gpio_set_pin(GPIO_SD_CMD); +} diff -r ed647dd06e43 -r d94bf387cc11 stage2.ld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stage2.ld Fri Jun 05 19:34:16 2015 +0200 @@ -0,0 +1,32 @@ +OUTPUT_ARCH(mips) +ENTRY(_start) +MEMORY +{ + ram : ORIGIN = 0x80000000 , LENGTH = 3M +} + +SECTIONS +{ + . = ALIGN(4); + .text : { *(.text*) } > ram + + . = ALIGN(4); + .rodata : { *(.rodata*) } > ram + + . = ALIGN(4); + .sdata : { *(.sdata*) } > ram + + . = ALIGN(4); + .data : { *(.data*) *(.scommon*) *(.reginfo*) } > ram + + _gp = ALIGN(16); + + .got : { *(.got*) } > ram + _got_end = ABSOLUTE(.); + + . = ALIGN(4); + .sbss : { *(.sbss*) } > ram + .bss : { *(.bss*) } > ram + . = ALIGN (4); +} + diff -r ed647dd06e43 -r d94bf387cc11 target.ld --- a/target.ld Fri Jun 05 19:07:33 2015 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -OUTPUT_ARCH(mips) -ENTRY(_start) -MEMORY -{ - ram : ORIGIN = 0x80002000 , LENGTH = 0x100000 -} - -SECTIONS -{ - . = ALIGN(4); - .text : { *(.text*) } > ram - - . = ALIGN(4); - .rodata : { *(.rodata*) } > ram - - . = ALIGN(4); - .sdata : { *(.sdata*) } > ram - - . = ALIGN(4); - .data : { *(.data*) *(.scommon*) *(.reginfo*) } > ram - - _gp = ABSOLUTE(.); /* Base of small data */ - - .got : { *(.got*) } > ram - - . = ALIGN(4); - .sbss : { *(.sbss*) } > ram - .bss : { *(.bss*) } > ram - . = ALIGN (4); -} -