1
0
mirror of git://projects.qi-hardware.com/iris.git synced 2024-06-25 09:36:42 +03:00

usb boot working again

This commit is contained in:
Bas Wijnen 2012-09-26 22:20:38 +02:00
parent d9a12225eb
commit 223ed86672
13 changed files with 106 additions and 214 deletions

View File

@ -18,6 +18,7 @@
AUTOMAKE_OPTIONS = subdir-objects foreign
# Define some variables.
OBJDUMP = $(host_alias)-objdump
OBJCOPY = $(host_alias)-objcopy
SERIAL = /dev/ttyUSB0
junk = mdebug.abi32 reginfo comment pdr note.gnu.build-id
@ -26,15 +27,15 @@ objcopyflags = -S $(addprefix --remove-section=.,$(junk))
start_load = 0x80400000
load = 0x80000000
noinst_DATA = iris.raw
noinst_PROGRAMS = iris.elf
noinst_DATA = iris.raw mips/start.raw mips/start-hack.S mips/nanonote/sdram-setup.raw
noinst_PROGRAMS = iris.elf mips/start.elf mips/nanonote/sdram-setup.elf
%.raw: %.elf
$(OBJCOPY) $(objcopyflags) -Obinary $< $@
# Define boot_threads depending on selected mode.
if UDC
boot_threads = bootinit udc
boot_threads = udc
else
if UNBRICK
boot_threads = nand sdmmc usbmassstorage
@ -52,29 +53,18 @@ iris_elf_CXXFLAGS = -Wno-unused-parameter -fno-strict-aliasing -fno-builtin -ggd
iris_elf_LDFLAGS = -Wl,--omagic -Wl,-Ttext -Wl,$(load) -nostdlib
iris_elf_SOURCES = mips/entry.S ${iris_sources} mips/boot.S ${boot_sources} ${headers}
program_sources = \
source/alarm.cc \
source/ball.cc \
source/boot.cc \
source/booter.cc \
source/bootinit.cc \
source/bsquare.cc \
source/buzzer.cc \
source/elfrun.cc \
source/fat.cc \
source/font.cc \
source/gpio.cc \
source/gui.cc \
source/init.cc \
source/lcd.cc \
source/metronome.cc \
source/nand.cc \
source/partition.cc \
source/rtc.cc \
source/sdmmc.cc \
source/test.cc \
source/udc.cc \
source/usbmassstorage.cc
mips_start_elf_CPPFLAGS = -O5 -fno-inline -Wa,-mips32 -DSTART="0x$(shell /bin/sh -c '$(OBJDUMP) -t iris.elf | grep __start$$ | cut -b1-8')"
mips_start_elf_LDFLAGS = -Wl,--omagic -Wl,-Ttext -Wl,$(start_load) -nostdlib
mips_start_elf_SOURCES = mips/start-hack.S iris.raw
mips/start-hack.S: mips/start.S iris.raw
cp $< $@
mips_nanonote_sdram_setup_elf_DEPENDENCIES = mips/nanonote/sdram-setup.ld
mips_nanonote_sdram_setup_elf_CPPFLAGS = -O5 -fno-inline -I. -Imips -Imips/nanonote -Wa,-mips32
mips_nanonote_sdram_setup_elf_CXXFLAGS = -Wno-unused-parameter -fno-strict-aliasing -fno-builtin -ggdb3
mips_nanonote_sdram_setup_elf_LDFLAGS = -Wl,--omagic -Wl,-T -Wl,mips/nanonote/sdram-setup.ld -nostdlib
mips_nanonote_sdram_setup_elf_SOURCES = mips/nanonote/sdram-setup.cc
program_targets = \
fs/alarm.elf \
@ -101,14 +91,14 @@ program_targets = \
fs/usbmassstorage.elf
noinst_PROGRAMS += $(program_targets)
AM_CPPFLAGS = -O5 -fno-inline -I. -Imips -Imips/nanonote -Wa,-mips32 -DNANONOTE
AM_CPPFLAGS = -O5 -fno-inline -I. -I./mips -I./mips/nanonote -Wa,-mips32 -DNANONOTE
AM_CXXFLAGS = -Wno-unused-parameter -fno-strict-aliasing -fno-builtin -ggdb3
AM_LDFLAGS = -nostdlib
BUILT_SOURCES = $(iris_sources) $(boot_sources) $(program_sources) $(headers) mips/nanonote/threadlist.S source/charset.data fs/font.dat fs/init.config
BUILT_SOURCES = $(headers) source/charset.data server
threadlist.S: mkthreadlist Makefile $(addprefix fs/,$(addsuffix .elf,$(boot_threads)))
$(top_srcdir)/$< $(boot_threads) > $@
threadlist.S: mkthreadlist Makefile $(addprefix fs/,$(addsuffix .elf,bootinit $(boot_threads)))
$(top_srcdir)/$< bootinit $(boot_threads) > $@
PYPP = /usr/bin/pypp
%.cc: %.ccp
@ -123,28 +113,63 @@ fs/font.dat: courier-10+8+32.png makefont
fs/%: %
ln -s ../$< $@
fs_alarm_elf_SOURCES = source/crt0.cc source/alarm.cc
fs_ball_elf_SOURCES = source/crt0.cc source/ball.cc
fs_boot_elf_SOURCES = source/crt0.cc source/boot.cc
fs_booter_elf_SOURCES = source/crt0.cc source/booter.cc
fs_bootinit_elf_SOURCES = source/crt0.cc source/bootinit.cc
fs_bsquare_elf_SOURCES = source/crt0.cc source/bsquare.cc
fs_buzzer_elf_SOURCES = source/crt0.cc source/buzzer.cc
fs_elfrun_elf_SOURCES = source/crt0.cc source/elfrun.cc
fs_fat_elf_SOURCES = source/crt0.cc source/fat.cc
fs_font_elf_SOURCES = source/crt0.cc source/font.cc
fs_gpio_elf_SOURCES = source/crt0.cc source/gpio.cc
fs_gui_elf_SOURCES = source/crt0.cc source/gui.cc
fs_init_elf_SOURCES = source/crt0.cc source/init.cc
fs_lcd_elf_SOURCES = source/crt0.cc source/lcd.cc
fs_metronome_elf_SOURCES = source/crt0.cc source/metronome.cc
fs_nand_elf_SOURCES = source/crt0.cc source/nand.cc
fs_partition_elf_SOURCES = source/crt0.cc source/partition.cc
fs_rtc_elf_SOURCES = source/crt0.cc source/rtc.cc
fs_sdmmc_elf_SOURCES = source/crt0.cc source/sdmmc.cc
fs_test_elf_SOURCES = source/crt0.cc source/test.cc
fs_udc_elf_SOURCES = source/crt0.cc source/udc.cc
fs_usbmassstorage_elf_SOURCES = source/crt0.cc source/usbmassstorage.cc
fs_alarm_elf_SOURCES = source/crt0.cc source/alarm.cc ${headers}
fs_ball_elf_SOURCES = source/crt0.cc source/ball.cc ${headers}
fs_boot_elf_SOURCES = source/crt0.cc source/boot.cc ${headers}
fs_booter_elf_SOURCES = source/crt0.cc source/booter.cc ${headers}
fs_bootinit_elf_SOURCES = source/crt0.cc source/bootinit.cc ${headers}
fs_bsquare_elf_SOURCES = source/crt0.cc source/bsquare.cc ${headers}
fs_buzzer_elf_SOURCES = source/crt0.cc source/buzzer.cc ${headers}
fs_elfrun_elf_SOURCES = source/crt0.cc source/elfrun.cc ${headers}
fs_fat_elf_SOURCES = source/crt0.cc source/fat.cc ${headers}
fs_font_elf_SOURCES = source/crt0.cc source/font.cc ${headers}
fs_gpio_elf_SOURCES = source/crt0.cc source/gpio.cc ${headers}
fs_gui_elf_SOURCES = source/crt0.cc source/gui.cc ${headers}
fs_init_elf_SOURCES = source/crt0.cc source/init.cc ${headers}
fs_lcd_elf_SOURCES = source/crt0.cc source/lcd.cc ${headers}
fs_metronome_elf_SOURCES = source/crt0.cc source/metronome.cc ${headers}
fs_nand_elf_SOURCES = source/crt0.cc source/nand.cc ${headers}
fs_partition_elf_SOURCES = source/crt0.cc source/partition.cc ${headers}
fs_rtc_elf_SOURCES = source/crt0.cc source/rtc.cc ${headers}
fs_sdmmc_elf_SOURCES = source/crt0.cc source/sdmmc.cc ${headers}
fs_test_elf_SOURCES = source/crt0.cc source/test.cc ${headers}
fs_udc_elf_SOURCES = source/crt0.cc source/udc.cc ${headers}
fs_usbmassstorage_elf_SOURCES = source/crt0.cc source/usbmassstorage.cc ${headers}
server:
test -e native/Makefile || native/autogen.sh
$(MAKE) -C native
# This target is meaningless for SD boot mode.
test: mips/start.raw mips/start.elf server mips/nanonote/sdram-setup.raw fs/init.config fs/font.dat
echo shutdown | nc localhost 5050 || true
native/usb-server
echo 'reboot $(start_load) 0x$(shell /bin/sh -c '$(OBJDUMP) -t mips/start.elf | grep __start$$ | cut -b1-8') mips/start.raw' | nc localhost 5050
sources = \
source/alarm.cc \
source/ball.cc \
source/boot.cc \
source/booter.cc \
source/bootinit.cc \
source/bsquare.cc \
source/buzzer.cc \
source/elfrun.cc \
source/fat.cc \
source/font.cc \
source/gpio.cc \
source/gui.cc \
source/init.cc \
source/lcd.cc \
source/metronome.cc \
source/nand.cc \
source/partition.cc \
source/rtc.cc \
source/sdmmc.cc \
source/test.cc \
source/udc.cc \
source/usbmassstorage.cc
autoclean: maintainer-clean
rm -rf aclocal.m4 configure depcomp fs install-sh iris.raw iris-sd.tar Makefile.in missing
$(MAKE) -C native autoclean
rm -rf aclocal.m4 configure depcomp fs install-sh iris.raw iris-sd.tar Makefile.in missing $(iris_sources) $(boot_sources) $(sources) $(headers) mips/start-hack.S mips/start.raw

3
autogen.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
autoreconf --force --install --symlink
./configure --host mipsel-linux-gnu "$@"

View File

@ -1 +0,0 @@
nanonote/Makefile.arch

View File

@ -138,7 +138,7 @@ extern "C":
// These are "extern", not "EXTERN", because they really are defined elsewhere.
#ifdef INIT
extern unsigned *thread_start
extern unsigned thread_start[]
#endif
// Fast pointer to page directory, for tlb miss events
extern Table **directory

View File

@ -119,7 +119,7 @@ static void init_threads ():
first_alarm = NULL
kReceiver *init_receiver = NULL
unsigned i = 0
while thread_start[i] != 0:
while thread_start[i + 1] != 0:
kMemory *mem = top_memory.alloc_memory ()
assert (mem)
kThread *thread = mem->alloc_thread (NUM_SLOTS)

View File

@ -1,140 +0,0 @@
# Iris: micro-kernel for a capability-based operating system.
# mips/nanonote/Makefile.arch: nanonote-specific parts of the build rules
# Copyright 2009 Bas Wijnen <wijnen@debian.org>
#
# 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/>.
start_load = 0x80400000
load = 0x80000000
# Uncomment exactly one of these to select the boot method for the image.
UDC_BOOT = yes
#SD_BOOT = yes
#UNBRICK = yes
arch_iris_sources = mips/interrupts.cc mips/arch.cc
boot_sources = mips/init.cc mips/nanonote/board.cc
arch_headers = mips/arch.hh mips/nanonote/jz4740.hh mips/nanonote/board.hh mips/nand.hh
udc_boot_programs = udc
sd_boot_programs = sd+mmc partition fat
unbrick_boot_programs = nand sd+mmc usb-mass-storage
standard_boot_programs = bootinit
# use sort to remove duplicates.
programs = $(sort init gpio font lcd bsquare ball buzzer metronome elfrun alarm rtc gui test boot booter $(udc_boot_programs) $(sd_boot_programs) $(unbrick_boot_programs) $(standard_boot_programs))
ARCH_CPPFLAGS = -I. -Imips -Imips/nanonote -Wa,-mips32 -DNANONOTE -DUSE_SERIAL
CROSS = mipsel-linux-gnu-
OBJDUMP = $(CROSS)objdump
junk = mdebug.abi32 reginfo comment pdr
OBJCOPYFLAGS = $(addprefix --remove-section=.,$(junk))
ifneq ($(UDC_BOOT),)
boot_threads = $(standard_boot_programs) $(udc_boot_programs)
ARCH_CXXFLAGS = -DNUM_THREADS=2
BOOT_CPPFLAGS = -DUDCBOOT
all: mips/nanonote/nand-boot.raw test
mips/start.o: TARGET =
else
ifneq ($(SD_BOOT),)
boot_threads = $(standard_boot_programs) $(sd_boot_programs)
ARCH_CXXFLAGS = -DNUM_THREADS=4
BOOT_CPPFLAGS = -DSDBOOT
all: mips/nanonote/nand-boot.raw iris-sd.tar
mips/start.o: TARGET = -DWRAPPED
iris-sd.tar: $(addprefix fs/,$(addsuffix .elf,$(programs))) mips/start.raw.gz fs/init.config
mkimage -A mips -T kernel -a $(start_load) -e $(shell /bin/sh -c '$(OBJDUMP) -t mips/start.elf | grep __start$$ | cut -b1-8') -n Iris -d mips/start.raw.gz fs/uimage | sed -e 's/:/;/g'
cd fs && tar cvf ../$@ uimage init.config $(addsuffix .elf,$(programs)) --dereference
else
ifneq ($(UNBRICK),)
boot_threads = $(standard_boot_programs) $(unbrick_boot_programs) sd+mmc
ARCH_CXXFLAGS = -DNUM_THREADS=3
BOOT_CPPFLAGS = -DUNBRICK
all: mips/start.raw
mips/start.o: TARGET =
else
error Please define your boot method.
endif
endif
endif
iris.elf: LDFLAGS = --omagic -Ttext $(load)
mips/start.elf: LDFLAGS = --omagic -Ttext $(start_load)
mips/nanonote/nand-boot.elf: LDFLAGS = --omagic -Ttext 0x80000000
mips/nanonote/nand-boot.o: mips/nand.hh
source/nand.o: mips/nand.hh
mips/start.o:mips/start.S Makefile Makefile.arch iris.raw
$(CC) $(CPPFLAGS) $(TARGET) -DSTART=0x$(shell /bin/sh -c '$(OBJDUMP) -t iris.elf | grep __start$$ | cut -b1-8') -c $< -o $@
test: mips/start.raw mips/start.elf mips/nanonote/server/usb-server mips/nanonote/sdram-setup.raw $(addsuffix .elf,$(addprefix fs/,$(programs))) fs/init.config
echo "reboot $(start_load) 0x$(shell /bin/sh -c '$(OBJDUMP) -t mips/start.elf | grep __start$$ | cut -b1-8') $<" | nc localhost 5050
mips/nanonote/server/usb-server: mips/nanonote/server/usb-server.ccp mips/nanonote/server/Makefile.am mips/nanonote/server/configure.ac devices.hh
$(MAKE) -C mips/nanonote/server
echo "shutdown" | nc localhost 5050
sleep 1
%.elf: %.o
$(LD) $(LDFLAGS) -o $@ $<
%.raw: %.elf
$(OBJCOPY) -S $(OBJCOPYFLAGS) -Obinary $< $@
%.raw.gz: %.raw
gzip < $< > $@
nanonote-boot: mips/nanonote/nanonote-boot.cc mips/nanonote/sdram-setup.raw
g++ `pkg-config --cflags --libs shevek` $< -o $@ -lusb
mips/nanonote/sdram-setup.elf: mips/nanonote/sdram-setup.ld
mips/nanonote/sdram-setup.elf: LDFLAGS = --omagic -T mips/nanonote/sdram-setup.ld
mips/nanonote/threadlist.o: $(addprefix fs/,$(addsuffix .elf,$(boot_threads)))
mips/boot.o: TARGET_FLAGS = -DMEMORY_SIZE="32 << 20"
mips/init.o: TARGET_FLAGS = -I/usr/mipsel-linux-gnu/include
source/bootinit.o: TARGET_FLAGS = -I/usr/mipsel-linux-gnu/include
source/elfrun.o: TARGET_FLAGS = -I/usr/mipsel-linux-gnu/include
source/gpio.ccp: source/nanonote-gpio.ccp
ln -s $(subst source/,,$<) $@
$(addprefix fs/,$(addsuffix .elf,$(boot_threads))): TARGET_FLAGS = -I.
$(addprefix fs/,$(addsuffix .elf,$(boot_threads))): LDFLAGS = -EL
$(addprefix fs/,$(addsuffix .elf,$(programs))): LDFLAGS = -EL
source/lcd.o: source/charset.data
source/charset.data: source/charset
$< > $@
%.o:%.S Makefile Makefile.arch mips/arch.hh
$(CC) $(CPPFLAGS) $(BOOT_CPPFLAGS) $(TARGET_FLAGS) -DKERNEL_STACK_SIZE=0x1000 -c $< -o $@
# entry.o must be the first file. threadlist.o must be the first of the init objects (which can be freed after loading).
iris.elf: mips/entry.o $(subst .cc,.o,$(iris_sources)) mips/nanonote/threadlist.o mips/boot.o $(subst .cc,.o,$(boot_sources))
$(LD) $(LDFLAGS) $^ -o $@
mips/start.elf: mips/start.o
$(LD) $(LDFLAGS) $^ -o $@
server:
while mips/nanonote/server/usb-server ; do : ; done
servers:
while : ; do $(MAKE) server ; done
setup:
x-terminal-emulator -e make debug &
x-terminal-emulator -e make servers &
ARCH_CLEAN_FILES = $(boot_sources) $(addsuffix .elf,$(boot_threads)) $(arch_headers) devices.hh keys.hh mips/*.o mips/nanonote/*.o source/charset.data iris.elf iris.raw mips/nanonote/sdram-setup.elf mips/nanonote/sdram-setup.raw mips/start.elf mips/start.raw
.PRECIOUS: mips/arch.hh mips/nanonote/jz4740.hh mips/nanonote/board.hh
.PHONY: test all monitor server servers setup

View File

@ -11,7 +11,7 @@ SECTIONS
.text : { *(.text*) } > ram
. = ALIGN(4);
.rodata : { *(.rodata*) } > ram
.rodata : { *(.rodata*) *(.note*) } > ram
. = ALIGN(4);
.sdata : { *(.sdata*) } > ram
@ -28,4 +28,3 @@ SECTIONS
.bss : { *(.bss*) } > ram
. = ALIGN (4);
}

View File

@ -1,9 +0,0 @@
AC_INIT(usb-server, 1.0, wijnen@debian.org)
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
AC_PROG_CXX
PKG_CHECK_MODULES(SHEVEK, shevek,, AC_MSG_ERROR(You need libshevek to compile AC_PACKAGE_NAME))
AC_CONFIG_FILES(Makefile)
AC_OUTPUT

View File

@ -27,5 +27,6 @@ EOF
done
cat << EOF
.word end_threads
.word 0
EOF

View File

@ -1,6 +1,6 @@
# Iris: micro-kernel for a capability-based operating system.
# mips/nanonote/server/Makefile.am: build rules
# Copyright 2009 Bas Wijnen <wijnen@debian.org>
# Makefile.am: build rules
# Copyright 2009-2012 Bas Wijnen <wijnen@debian.org>
#
# 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
@ -20,14 +20,14 @@ AUTOMAKE_OPTIONS = foreign
bin_PROGRAMS = usb-server
usb_server_SOURCES = usb-server.cc
usb_server_CPPFLAGS = $(SHEVEK_CFLAGS) -DSTAGE1_FILE=\"mips/nanonote/sdram-setup.raw\" -I../../.. -DCOPYRIGHT_YEARS=\"2009-2012\" -DCOPYRIGHT_AUTHOR=\"Bas\ Wijnen\" -DCOPYRIGHT_EMAIL=\"wijnen@debian.org\"
usb_server_CPPFLAGS = $(SHEVEK_CFLAGS) -DSTAGE1_FILE=\"mips/nanonote/sdram-setup.raw\" -I.. -DCOPYRIGHT_YEARS=\"2009-2012\" -DCOPYRIGHT_AUTHOR=\"Bas\ Wijnen\" -DCOPYRIGHT_EMAIL=\"wijnen@debian.org\"
usb_server_LDFLAGS = $(SHEVEK_LIBS) -lusb
PYPP = /usr/bin/pypp
%.cc: %.ccp
$(PYPP) --name $< < $< > $@
%.hh: %.hhp
$(PYPP) --name $< < $< > $@
run:
$(top_buiddir)/usb-server
BUILT_SOURCES = usb-server.cc
autoclean: maintainer-clean
rm -rf aclocal.m4 configure Makefile.in usb-server.cc

4
native/autogen.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
cd "`dirname "$0"`"
autoreconf --force --install --symlink
./configure "$@"

8
native/configure.ac Normal file
View File

@ -0,0 +1,8 @@
AC_INIT([iris-helpers], [0.2], [wijnen@debian.org])
AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
AC_PROG_CXX
PKG_CHECK_MODULES(SHEVEK, shevek,, AC_MSG_ERROR([You need libshevek to compile AC_PACKAGE_NAME]))
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

View File

@ -27,6 +27,7 @@
#include <shevek/server.hh>
#include <shevek/args.hh>
#include <shevek/dir.hh>
#include <shevek/bg.hh>
#include <shevek/error.hh>
#include "devices.hh"
@ -343,5 +344,6 @@ int main (int argc, char **argv):
shevek::args args (argc, argv, opts, 0, 0, "device server for testing Iris on NanoNote")
data d (port)
dump_devices ()
shevek::bg ()
shevek::loop ()
return 0