1
0
mirror of git://projects.qi-hardware.com/iris.git synced 2025-04-21 12:27:27 +03:00

bug hunting

This commit is contained in:
Bas Wijnen
2009-12-26 14:17:06 +01:00
parent ad2f531ab0
commit d97f1a4ff2
23 changed files with 334 additions and 83 deletions

View File

@@ -18,7 +18,7 @@
load = 0x80000000
ARCH_CXXFLAGS = -DNUM_THREADS=6
ARCH_CPPFLAGS = -I. -Imips -Imips/nanonote -Wa,-mips32 -DNANONOTE -DUSE_SERIAL
ARCH_CPPFLAGS = -I. -Imips -Imips/nanonote -Wa,-mips32 -DNANONOTE #-DUSE_SERIAL
CROSS = mipsel-linux-gnu-
OBJDUMP = $(CROSS)objdump
junk = mdebug.abi32 reginfo comment pdr
@@ -30,12 +30,14 @@ boot_sources = mips/init.cc mips/nanonote/board.cc
arch_headers = mips/arch.hh mips/nanonote/jz4740.hh mips/nanonote/board.hh
boot_threads = init udc nanonote-gpio buzzer metronome lcd
test: iris.raw mips/nanonote/server/usb-server
test: iris.raw mips/nanonote/server/usb-server mips/nanonote/sdram-setup.raw
echo "reboot 0xa$(shell /bin/sh -c '$(OBJDUMP) -t iris.elf | grep __start$$ | cut -b2-8')" | nc localhost 5050
.PHONY: test
mips/nanonote/server/usb-server: mips/nanonote/server/usb-server.ccp mips/nanonote/server/Makefile.am mips/nanonote/server/configure.ac
$(MAKE) -C mips/nanonote/server
echo "shutdown" | nc localhost 5050
sleep 1
%.elf: %.o
$(LD) $(LDFLAGS) -o $@ $<
@@ -66,6 +68,10 @@ boot-programs/charset.data: boot-programs/charset
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 $@
server:
while mips/nanonote/server/usb-server ; do : ; done
ARCH_CLEAN_FILES = $(boot_sources) $(addsuffix .elf,$(boot_threads)) $(arch_headers) devices.hh keys.hh mips/*.o mips/nanonote/*.o boot-programs/charset.data iris.elf iris.raw mips/nanonote/sdram-setup.elf mips/nanonote/sdram-setup.raw
.PRECIOUS: mips/arch.hh mips/nanonote/jz4740.hh mips/nanonote/board.hh
.PHONY: server

View File

@@ -27,4 +27,7 @@ PYPP = /usr/bin/pypp
%.cc: %.ccp
$(PYPP) --name $< < $< > $@
run:
$(top_buiddir)/usb-server
BUILT_SOURCES = usb-server.cc

View File

@@ -54,15 +54,34 @@ struct data:
VR_FLUSH_CACHES = 3
VR_PROGRAM_START1 = 4
VR_PROGRAM_START2 = 5
POLL = 10
void request (requests num, unsigned data = 0)
void send_file (unsigned address, unsigned size, char const *data)
void reboot ():
// This always fails, because the device doesn't answer. However, that means there's nothing wrong, so don't complain.
usb_control_msg (handle, USB_ENDPOINT_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, VR_GET_CPU_INFO, 0, 0, NULL, 8, timeout)
char buffer[8]
if usb_control_msg (handle, USB_ENDPOINT_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, VR_GET_CPU_INFO, 0, 0, buffer, 8, timeout) < 0:
std::cerr << "unable to send reboot message to device: " << usb_strerror () << std::endl
usb_release_interface (handle, 0)
usb_close (handle)
handle = NULL
void get_device (unsigned vendor, unsigned product, unsigned tries)
void poll ()
void data::poll ():
while true:
char buffer[2]
int s = usb_control_msg (handle, USB_ENDPOINT_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, POLL, 0, 0, buffer, 8, timeout)
if s < 1 || s > 2 || buffer[0] != '#':
std::cerr << "unable to send poll message to device: " << usb_strerror () << std::endl
usb_release_interface (handle, 0)
usb_close (handle)
handle = NULL
return
if s != 1:
std::cout << buffer[1] << std::flush
else:
break
(shevek::absolute_time () + shevek::relative_time (1, 0)).schedule (sigc::mem_fun (*this, &data::poll))
struct client : public shevek::server <client, data *>::connection:
static Glib::RefPtr <client> create ():
@@ -75,6 +94,9 @@ struct client : public shevek::server <client, data *>::connection:
unsigned entry
if l ("reboot %x%", entry):
get_server ()->data ()->boot (entry)
else if l ("shutdown%"):
std::cerr << "shutting down\n"
shevek::end_loop ()
else:
out->write ("invalid command\n")
if !keep:
@@ -112,10 +134,11 @@ void data::get_device (unsigned vendor, unsigned product, unsigned tries):
continue
handle = usb_open (dev)
if usb_claim_interface (handle, 0) < 0:
std::cerr << "unable to claim interface\n"
std::cerr << "unable to claim interface: " << usb_strerror () << "\n"
usb_close (handle)
handle = NULL
continue
(shevek::absolute_time () + shevek::relative_time (1, 0)).schedule (sigc::mem_fun (*this, &data::poll))
return
if i + 1 < tries:
//std::cerr << "failed to find device, still trying...\n"

View File

@@ -25,7 +25,7 @@ thread0:
.balign 0x1000
thread1:
.incbin "lcd.elf"
.incbin "udc.elf"
.balign 0x1000
thread2:
@@ -41,8 +41,9 @@ thread4:
.balign 0x1000
thread5:
.incbin "udc.elf"
.incbin "lcd.elf"
.balign 0x1000
thread6:
// Everything from here may be freed after kernel initialization.