diff options
-rw-r--r-- | utils/hwstub/stub/hwstub.make | 7 | ||||
-rw-r--r-- | utils/hwstub/stub/stmp/Makefile | 10 | ||||
-rw-r--r-- | utils/hwstub/stub/stmp/target.c | 15 | ||||
-rw-r--r-- | utils/hwstub/stub/target.h | 4 | ||||
-rw-r--r-- | utils/hwstub/stub/usb_drv_arc.c | 5 |
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) | |||
14 | OBJ:=$(OBJ:.S=.o) | 14 | OBJ:=$(OBJ:.S=.o) |
15 | OBJ_EXCEPT_CRT0=$(filter-out $(BUILD_DIR)/crt0.o,$(OBJ)) | 15 | OBJ_EXCEPT_CRT0=$(filter-out $(BUILD_DIR)/crt0.o,$(OBJ)) |
16 | EXEC_ELF=$(BUILD_DIR)/hwstub.elf | 16 | EXEC_ELF=$(BUILD_DIR)/hwstub.elf |
17 | EXEC_BIN=$(BUILD_DIR)/hwstub.bin | ||
17 | DEPS=$(foreach obj,$(OBJ),$(obj).d) | 18 | DEPS=$(foreach obj,$(OBJ),$(obj).d) |
18 | 19 | ||
19 | EXEC=$(EXEC_ELF) | 20 | EXEC+=$(EXEC_ELF) $(EXEC_BIN) |
20 | 21 | ||
21 | SILENT?=@ | 22 | SILENT?=@ |
22 | PRINTS=$(SILENT)$(call info,$(1)) | 23 | PRINTS=$(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 | ||
48 | clean: | 53 | clean: |
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 | |||
5 | LD=arm-elf-eabi-gcc | 5 | LD=arm-elf-eabi-gcc |
6 | AS=arm-elf-eabi-gcc | 6 | AS=arm-elf-eabi-gcc |
7 | OC=arm-elf-eabi-objcopy | 7 | OC=arm-elf-eabi-objcopy |
8 | SBTOELF=$(CURDIR)/../../../imxtools/sbtools/elftosb | ||
8 | DEFINES= | 9 | DEFINES= |
9 | INCLUDES=-I$(CURDIR) | 10 | INCLUDES=-I$(CURDIR) |
10 | GCCOPTS=-mcpu=arm926ej-s | 11 | GCCOPTS=-mcpu=arm926ej-s |
11 | BUILD_DIR=$(CURDIR)/build/ | 12 | BUILD_DIR=$(CURDIR)/build/ |
12 | ROOT_DIR=$(CURDIR)/.. | 13 | ROOT_DIR=$(CURDIR)/.. |
13 | 14 | EXEC=$(BUILD_DIR)/hwstub.sb | |
14 | include ../hwstub.make \ No newline at end of file | 15 | |
16 | include ../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 | |||
277 | void 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 | |||
287 | void 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); | |||
31 | int target_get_info(int info, void **buffer); | 31 | int 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 */ |
33 | int target_atexit(int action); | 33 | int target_atexit(int action); |
34 | /* Wait a very short time (us<=1000) */ | ||
35 | void target_udelay(int us); | ||
36 | /* Wait for a short time (ms <= 1000) */ | ||
37 | void 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 */ |