summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)
14OBJ:=$(OBJ:.S=.o) 14OBJ:=$(OBJ:.S=.o)
15OBJ_EXCEPT_CRT0=$(filter-out $(BUILD_DIR)/crt0.o,$(OBJ)) 15OBJ_EXCEPT_CRT0=$(filter-out $(BUILD_DIR)/crt0.o,$(OBJ))
16EXEC_ELF=$(BUILD_DIR)/hwstub.elf 16EXEC_ELF=$(BUILD_DIR)/hwstub.elf
17EXEC_BIN=$(BUILD_DIR)/hwstub.bin
17DEPS=$(foreach obj,$(OBJ),$(obj).d) 18DEPS=$(foreach obj,$(OBJ),$(obj).d)
18 19
19EXEC=$(EXEC_ELF) 20EXEC+=$(EXEC_ELF) $(EXEC_BIN)
20 21
21SILENT?=@ 22SILENT?=@
22PRINTS=$(SILENT)$(call info,$(1)) 23PRINTS=$(SILENT)$(call info,$(1))
@@ -44,6 +45,10 @@ $(TMP_LDS): $(LINKER_FILE)
44$(EXEC_ELF): $(OBJ) $(TMP_LDS) 45$(EXEC_ELF): $(OBJ) $(TMP_LDS)
45 $(call PRINTS,LD $(@F)) 46 $(call PRINTS,LD $(@F))
46 $(SILENT)$(LD) $(LDFLAGS) -o $@ $(OBJ_EXCEPT_CRT0) 47 $(SILENT)$(LD) $(LDFLAGS) -o $@ $(OBJ_EXCEPT_CRT0)
48
49$(EXEC_BIN): $(EXEC_ELF)
50 $(call PRINTS,OC $(@F))
51 $(SILENT)$(OC) -O binary $< $@
47 52
48clean: 53clean:
49 $(SILENT)rm -rf $(OBJ) $(DEPS) $(EXEC) $(TMP_LDS) $(TMP_MAP) 54 $(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
5LD=arm-elf-eabi-gcc 5LD=arm-elf-eabi-gcc
6AS=arm-elf-eabi-gcc 6AS=arm-elf-eabi-gcc
7OC=arm-elf-eabi-objcopy 7OC=arm-elf-eabi-objcopy
8SBTOELF=$(CURDIR)/../../../imxtools/sbtools/elftosb
8DEFINES= 9DEFINES=
9INCLUDES=-I$(CURDIR) 10INCLUDES=-I$(CURDIR)
10GCCOPTS=-mcpu=arm926ej-s 11GCCOPTS=-mcpu=arm926ej-s
11BUILD_DIR=$(CURDIR)/build/ 12BUILD_DIR=$(CURDIR)/build/
12ROOT_DIR=$(CURDIR)/.. 13ROOT_DIR=$(CURDIR)/..
13 14EXEC=$(BUILD_DIR)/hwstub.sb
14include ../hwstub.make \ No newline at end of file 15
16include ../hwstub.make
17
18$(BUILD_DIR)/hwstub.sb: $(EXEC_BIN)
19 $(call PRINTS,SBTOELF $(@F))
20 $(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)
273 return; 273 return;
274 } 274 }
275} 275}
276
277void target_udelay(int us)
278{
279 uint32_t cur = HW_DIGCTL_MICROSECONDS;
280 uint32_t end = cur + us;
281 if(cur < end)
282 while(HW_DIGCTL_MICROSECONDS < end) {}
283 else
284 while(HW_DIGCTL_MICROSECONDS >= cur) {}
285}
286
287void target_mdelay(int ms)
288{
289 return target_udelay(ms * 1000);
290}
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);
31int target_get_info(int info, void **buffer); 31int target_get_info(int info, void **buffer);
32/* set atexit action or return -1 on error */ 32/* set atexit action or return -1 on error */
33int target_atexit(int action); 33int target_atexit(int action);
34/* Wait a very short time (us<=1000) */
35void target_udelay(int us);
36/* Wait for a short time (ms <= 1000) */
37void target_mdelay(int ms);
34 38
35#endif /* __TARGET_H__ */ 39#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 @@
23#include "usb_drv.h" 23#include "usb_drv.h"
24#include "config.h" 24#include "config.h"
25#include "memory.h" 25#include "memory.h"
26#include "target.h"
26 27
27#define MAX_PKT_SIZE 1024 28#define MAX_PKT_SIZE 1024
28#define MAX_PKT_SIZE_EP0 64 29#define MAX_PKT_SIZE_EP0 64
@@ -323,9 +324,11 @@ void usb_drv_init(void)
323 /* we don't know if USB was connected or not. In USB recovery mode it will 324 /* we don't know if USB was connected or not. In USB recovery mode it will
324 * but in other cases it might not be. In doubt, disconnect */ 325 * but in other cases it might not be. In doubt, disconnect */
325 REG_USBCMD &= ~USBCMD_RUN; 326 REG_USBCMD &= ~USBCMD_RUN;
327 /* wait a short time for the host to realise */
328 target_mdelay(50);
326 /* reset the controller */ 329 /* reset the controller */
327 REG_USBCMD |= USBCMD_CTRL_RESET; 330 REG_USBCMD |= USBCMD_CTRL_RESET;
328 while (REG_USBCMD & USBCMD_CTRL_RESET); 331 while(REG_USBCMD & USBCMD_CTRL_RESET);
329 /* put it in device mode */ 332 /* put it in device mode */
330 REG_USBMODE = USBMODE_CTRL_MODE_DEVICE; 333 REG_USBMODE = USBMODE_CTRL_MODE_DEVICE;
331 /* reset address */ 334 /* reset address */