summaryrefslogtreecommitdiffstats
path: root/utils/hwstub/stub
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2013-09-10 23:07:40 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2013-09-10 23:19:34 +0200
commit3b6d2ac28afc1c987e480790fff1b652f3ade5cd (patch)
treebe89e88b7f2b23acef34e22aa8f94b97104b6328 /utils/hwstub/stub
parentacf3af4ae305a70a8f3da777d0dffcccac6db6f7 (diff)
downloadrockbox-3b6d2ac28afc1c987e480790fff1b652f3ade5cd.tar.gz
rockbox-3b6d2ac28afc1c987e480790fff1b652f3ade5cd.tar.bz2
rockbox-3b6d2ac28afc1c987e480790fff1b652f3ade5cd.zip
hwstub: add delay functions, and plain binary/sb file generation
Change-Id: Idbedb9277b355edcd93975ec5a268428c7b89633
Diffstat (limited to 'utils/hwstub/stub')
-rw-r--r--utils/hwstub/stub/hwstub.make7
-rw-r--r--utils/hwstub/stub/stmp/Makefile10
-rw-r--r--utils/hwstub/stub/stmp/target.c15
-rw-r--r--utils/hwstub/stub/target.h4
-rw-r--r--utils/hwstub/stub/usb_drv_arc.c5
5 files changed, 37 insertions, 4 deletions
diff --git a/utils/hwstub/stub/hwstub.make b/utils/hwstub/stub/hwstub.make
index b46a2736ef..d40fa87755 100644
--- a/utils/hwstub/stub/hwstub.make
+++ b/utils/hwstub/stub/hwstub.make
@@ -14,9 +14,10 @@ OBJ=$(SRC:.c=.o)
OBJ:=$(OBJ:.S=.o)
OBJ_EXCEPT_CRT0=$(filter-out $(BUILD_DIR)/crt0.o,$(OBJ))
EXEC_ELF=$(BUILD_DIR)/hwstub.elf
+EXEC_BIN=$(BUILD_DIR)/hwstub.bin
DEPS=$(foreach obj,$(OBJ),$(obj).d)
-EXEC=$(EXEC_ELF)
+EXEC+=$(EXEC_ELF) $(EXEC_BIN)
SILENT?=@
PRINTS=$(SILENT)$(call info,$(1))
@@ -44,6 +45,10 @@ $(TMP_LDS): $(LINKER_FILE)
$(EXEC_ELF): $(OBJ) $(TMP_LDS)
$(call PRINTS,LD $(@F))
$(SILENT)$(LD) $(LDFLAGS) -o $@ $(OBJ_EXCEPT_CRT0)
+
+$(EXEC_BIN): $(EXEC_ELF)
+ $(call PRINTS,OC $(@F))
+ $(SILENT)$(OC) -O binary $< $@
clean:
$(SILENT)rm -rf $(OBJ) $(DEPS) $(EXEC) $(TMP_LDS) $(TMP_MAP)
diff --git a/utils/hwstub/stub/stmp/Makefile b/utils/hwstub/stub/stmp/Makefile
index 14e6d0fbba..3ac7e3bbd4 100644
--- a/utils/hwstub/stub/stmp/Makefile
+++ b/utils/hwstub/stub/stmp/Makefile
@@ -5,10 +5,16 @@ CC=arm-elf-eabi-gcc
LD=arm-elf-eabi-gcc
AS=arm-elf-eabi-gcc
OC=arm-elf-eabi-objcopy
+SBTOELF=$(CURDIR)/../../../imxtools/sbtools/elftosb
DEFINES=
INCLUDES=-I$(CURDIR)
GCCOPTS=-mcpu=arm926ej-s
BUILD_DIR=$(CURDIR)/build/
ROOT_DIR=$(CURDIR)/..
-
-include ../hwstub.make \ No newline at end of file
+EXEC=$(BUILD_DIR)/hwstub.sb
+
+include ../hwstub.make
+
+$(BUILD_DIR)/hwstub.sb: $(EXEC_BIN)
+ $(call PRINTS,SBTOELF $(@F))
+ $(SILENT)$(SBTOELF) -z -c hwstub.db -o $@ $< \ No newline at end of file
diff --git a/utils/hwstub/stub/stmp/target.c b/utils/hwstub/stub/stmp/target.c
index 390480a71c..9b005063bd 100644
--- a/utils/hwstub/stub/stmp/target.c
+++ b/utils/hwstub/stub/stmp/target.c
@@ -273,3 +273,18 @@ void target_exit(void)
return;
}
}
+
+void target_udelay(int us)
+{
+ uint32_t cur = HW_DIGCTL_MICROSECONDS;
+ uint32_t end = cur + us;
+ if(cur < end)
+ while(HW_DIGCTL_MICROSECONDS < end) {}
+ else
+ while(HW_DIGCTL_MICROSECONDS >= cur) {}
+}
+
+void target_mdelay(int ms)
+{
+ return target_udelay(ms * 1000);
+}
diff --git a/utils/hwstub/stub/target.h b/utils/hwstub/stub/target.h
index 56c960741f..43151e9a34 100644
--- a/utils/hwstub/stub/target.h
+++ b/utils/hwstub/stub/target.h
@@ -31,5 +31,9 @@ void target_exit(void);
int target_get_info(int info, void **buffer);
/* set atexit action or return -1 on error */
int target_atexit(int action);
+/* Wait a very short time (us<=1000) */
+void target_udelay(int us);
+/* Wait for a short time (ms <= 1000) */
+void target_mdelay(int ms);
#endif /* __TARGET_H__ */
diff --git a/utils/hwstub/stub/usb_drv_arc.c b/utils/hwstub/stub/usb_drv_arc.c
index 32275b6adb..ab87be8a4c 100644
--- a/utils/hwstub/stub/usb_drv_arc.c
+++ b/utils/hwstub/stub/usb_drv_arc.c
@@ -23,6 +23,7 @@
#include "usb_drv.h"
#include "config.h"
#include "memory.h"
+#include "target.h"
#define MAX_PKT_SIZE 1024
#define MAX_PKT_SIZE_EP0 64
@@ -323,9 +324,11 @@ void usb_drv_init(void)
/* we don't know if USB was connected or not. In USB recovery mode it will
* but in other cases it might not be. In doubt, disconnect */
REG_USBCMD &= ~USBCMD_RUN;
+ /* wait a short time for the host to realise */
+ target_mdelay(50);
/* reset the controller */
REG_USBCMD |= USBCMD_CTRL_RESET;
- while (REG_USBCMD & USBCMD_CTRL_RESET);
+ while(REG_USBCMD & USBCMD_CTRL_RESET);
/* put it in device mode */
REG_USBMODE = USBMODE_CTRL_MODE_DEVICE;
/* reset address */