Created
October 26, 2013 23:01
-
-
Save pamaury/7175612 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/utils/hwstub/hwstub_protocol.h b/utils/hwstub/hwstub_protocol.h | |
index 99131aa..33c61dd 100644 | |
--- a/utils/hwstub/hwstub_protocol.h | |
+++ b/utils/hwstub/hwstub_protocol.h | |
@@ -101,6 +101,7 @@ struct usb_resp_info_features_t | |
#define HWSTUB_TARGET_UNK ('U' | 'N' << 8 | 'K' << 16 | ' ' << 24) | |
#define HWSTUB_TARGET_STMP ('S' | 'T' << 8 | 'M' << 16 | 'P' << 24) | |
+#define HWSTUB_TARGET_RKNANO ('R' | 'K' << 8 | 'N' << 16 | 'A' << 24) | |
struct usb_resp_info_target_t | |
{ | |
diff --git a/utils/hwstub/stub/SOURCES b/utils/hwstub/stub/SOURCES | |
index bfb847c..208c42a 100644 | |
--- a/utils/hwstub/stub/SOURCES | |
+++ b/utils/hwstub/stub/SOURCES | |
@@ -1,12 +1,26 @@ | |
main.c | |
+#if ARM_ARCH == 7 | |
+crt0-arm7.S | |
+#else | |
crt0.S | |
+#endif | |
logf.c | |
+#if ARM_ARCH == 7 | |
+memcpy-arm7.S | |
+memmove-arm7.S | |
+memset-arm7.S | |
+#else | |
memcpy.S | |
memmove.S | |
memset.S | |
+#endif | |
string.c | |
format.c | |
#ifdef CONFIG_STMP | |
usb_drv_arc.c | |
stmp/target.c | |
#endif | |
+#ifdef CONFIG_RKNANO | |
+usb_drv_synopsys.c | |
+rknano/target.c | |
+#endif | |
\ No newline at end of file | |
diff --git a/utils/hwstub/stub/crt0-arm7.S b/utils/hwstub/stub/crt0-arm7.S | |
new file mode 100644 | |
index 0000000..c2ac12b | |
--- /dev/null | |
+++ b/utils/hwstub/stub/crt0-arm7.S | |
@@ -0,0 +1,31 @@ | |
+.section .text.start,"ax",%progbits | |
+.code 16 | |
+.syntax unified | |
+.thumb | |
+.thumb_func | |
+.align 0x02 | |
+.global start | |
+start: | |
+vector_table: | |
+ /* stack address */ | |
+ .word 0x20010000 | |
+ /* vectors */ | |
+ .word reset | |
+ .rept 33 | |
+ .word hang | |
+ .endr | |
+/* actual start */ | |
+.thumb_func | |
+reset: | |
+ /* make sure interrupts are disabled */ | |
+ cpsid i | |
+ /* change vector table */ | |
+ ldr r0, =start | |
+ ldr r1, =0xe000ed08 /* VTOR */ | |
+ str r0, [r1] | |
+ /* jump to main */ | |
+ b main | |
+/* hang */ | |
+.thumb_func | |
+hang: | |
+ b hang | |
\ No newline at end of file | |
diff --git a/utils/hwstub/stub/crt0.S b/utils/hwstub/stub/crt0.S | |
index 8b21978..49019d1 100644 | |
--- a/utils/hwstub/stub/crt0.S | |
+++ b/utils/hwstub/stub/crt0.S | |
@@ -1,4 +1,4 @@ | |
-.section .text,"ax",%progbits | |
+.section .text.start,"ax",%progbits | |
.code 32 | |
.align 0x04 | |
.global start | |
diff --git a/utils/hwstub/stub/hwstub.lds b/utils/hwstub/stub/hwstub.lds | |
index 549e4ab..c2f9d69 100644 | |
--- a/utils/hwstub/stub/hwstub.lds | |
+++ b/utils/hwstub/stub/hwstub.lds | |
@@ -23,7 +23,11 @@ | |
ENTRY(start) | |
OUTPUT_FORMAT(elf32-littlearm) | |
OUTPUT_ARCH(arm) | |
+#if ARM_ARCH == 7 | |
+STARTUP(crt0-arm7.o) | |
+#else | |
STARTUP(crt0.o) | |
+#endif | |
#define IRAM_END_ADDR (IRAM_ORIG + IRAM_SIZE) | |
diff --git a/utils/hwstub/stub/hwstub.make b/utils/hwstub/stub/hwstub.make | |
index d40fa87..855edca 100644 | |
--- a/utils/hwstub/stub/hwstub.make | |
+++ b/utils/hwstub/stub/hwstub.make | |
@@ -2,9 +2,9 @@ INCLUDES+=-I$(ROOT_DIR) | |
LINKER_FILE=$(ROOT_DIR)/hwstub.lds | |
TMP_LDS=$(BUILD_DIR)/link.lds | |
TMP_MAP=$(BUILD_DIR)/hwstub.map | |
-CFLAGS=$(GCCOPTS) $(DEFINES) -W -Wall -Wundef -O -nostdlib -ffreestanding -Wstrict-prototypes -pipe -std=gnu99 -fomit-frame-pointer -Wno-pointer-sign -Wno-override-init $(INCLUDES) | |
+CFLAGS=$(GCCOPTS) $(DEFINES) -W -Wall -Wundef -O -nostdlib -ffreestanding -Wstrict-prototypes -pipe -std=gnu99 -fomit-frame-pointer -Wno-pointer-sign -Wno-override-init $(INCLUDES) -ffunction-sections | |
ASFLAGS=$(CFLAGS) -D__ASSEMBLER__ | |
-LDFLAGS=-lgcc -Os -nostdlib -T$(TMP_LDS) -Wl,-Map,$(TMP_MAP) $(INCLUDES) -L$(BUILD_DIR) | |
+LDFLAGS=-Os -nostdlib -T$(TMP_LDS) -Wl,-Map,$(TMP_MAP) $(INCLUDES) -L$(BUILD_DIR) | |
SRC:=$(shell cat $(ROOT_DIR)/SOURCES | $(CC) $(INCLUDES) \ | |
$(DEFINES) -E -P -include "config.h" - 2>/dev/null \ | |
@@ -12,7 +12,7 @@ SRC:=$(shell cat $(ROOT_DIR)/SOURCES | $(CC) $(INCLUDES) \ | |
SRC:=$(foreach src,$(SRC),$(BUILD_DIR)/$(src)) | |
OBJ=$(SRC:.c=.o) | |
OBJ:=$(OBJ:.S=.o) | |
-OBJ_EXCEPT_CRT0=$(filter-out $(BUILD_DIR)/crt0.o,$(OBJ)) | |
+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) | |
diff --git a/utils/hwstub/stub/main.c b/utils/hwstub/stub/main.c | |
index 0923bf8..73fb6a8 100644 | |
--- a/utils/hwstub/stub/main.c | |
+++ b/utils/hwstub/stub/main.c | |
@@ -174,8 +174,6 @@ uint32_t usb_buffer_size = 0; | |
static void set_config(void) | |
{ | |
- usb_drv_configure_endpoint(EP_BULK, USB_ENDPOINT_XFER_BULK); | |
- usb_drv_configure_endpoint(EP_INT, USB_ENDPOINT_XFER_INT); | |
} | |
static void handle_std_dev_desc(struct usb_ctrlrequest *req) | |
@@ -252,6 +250,8 @@ static void handle_std_dev_desc(struct usb_ctrlrequest *req) | |
usb_drv_stall(EP_CONTROL, true, true); | |
break; | |
default: | |
+ ptr = 0; | |
+ size = 0; | |
break; | |
} | |
diff --git a/utils/hwstub/stub/memcpy-arm7.S b/utils/hwstub/stub/memcpy-arm7.S | |
new file mode 100644 | |
index 0000000..f919998 | |
--- /dev/null | |
+++ b/utils/hwstub/stub/memcpy-arm7.S | |
@@ -0,0 +1,321 @@ | |
+/* | |
+ * Copyright (c) 2013 ARM Ltd | |
+ * All rights reserved. | |
+ * | |
+ * Redistribution and use in source and binary forms, with or without | |
+ * modification, are permitted provided that the following conditions | |
+ * are met: | |
+ * 1. Redistributions of source code must retain the above copyright | |
+ * notice, this list of conditions and the following disclaimer. | |
+ * 2. Redistributions in binary form must reproduce the above copyright | |
+ * notice, this list of conditions and the following disclaimer in the | |
+ * documentation and/or other materials provided with the distribution. | |
+ * 3. The name of the company may not be used to endorse or promote | |
+ * products derived from this software without specific prior written | |
+ * permission. | |
+ * | |
+ * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED | |
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
+ * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED | |
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
+ */ | |
+ | |
+/* This memcpy routine is optimised for Cortex-M3/M4 cores with/without | |
+ unaligned access. | |
+ | |
+ If compiled with GCC, this file should be enclosed within following | |
+ pre-processing check: | |
+ if defined (__ARM_ARCH_7M__) || defined (__ARM_ARCH_7EM__) | |
+ | |
+ Prototype: void *memcpy (void *dst, const void *src, size_t count); | |
+ | |
+ The job will be done in 5 steps. | |
+ Step 1: Align src/dest pointers, copy mis-aligned if fail to align both | |
+ Step 2: Repeatedly copy big block size of __OPT_BIG_BLOCK_SIZE | |
+ Step 3: Repeatedly copy big block size of __OPT_MID_BLOCK_SIZE | |
+ Step 4: Copy word by word | |
+ Step 5: Copy byte-to-byte | |
+ | |
+ Tunable options: | |
+ __OPT_BIG_BLOCK_SIZE: Size of big block in words. Default to 64. | |
+ __OPT_MID_BLOCK_SIZE: Size of big block in words. Default to 16. | |
+ */ | |
+#ifndef __OPT_BIG_BLOCK_SIZE | |
+#define __OPT_BIG_BLOCK_SIZE (4 * 16) | |
+#endif | |
+ | |
+#ifndef __OPT_MID_BLOCK_SIZE | |
+#define __OPT_MID_BLOCK_SIZE (4 * 4) | |
+#endif | |
+ | |
+#if __OPT_BIG_BLOCK_SIZE == 16 | |
+#define BEGIN_UNROLL_BIG_BLOCK \ | |
+ .irp offset, 0,4,8,12 | |
+#elif __OPT_BIG_BLOCK_SIZE == 32 | |
+#define BEGIN_UNROLL_BIG_BLOCK \ | |
+ .irp offset, 0,4,8,12,16,20,24,28 | |
+#elif __OPT_BIG_BLOCK_SIZE == 64 | |
+#define BEGIN_UNROLL_BIG_BLOCK \ | |
+ .irp offset, 0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60 | |
+#else | |
+#error "Illegal __OPT_BIG_BLOCK_SIZE" | |
+#endif | |
+ | |
+#if __OPT_MID_BLOCK_SIZE == 8 | |
+#define BEGIN_UNROLL_MID_BLOCK \ | |
+ .irp offset, 0,4 | |
+#elif __OPT_MID_BLOCK_SIZE == 16 | |
+#define BEGIN_UNROLL_MID_BLOCK \ | |
+ .irp offset, 0,4,8,12 | |
+#else | |
+#error "Illegal __OPT_MID_BLOCK_SIZE" | |
+#endif | |
+ | |
+#define END_UNROLL .endr | |
+ | |
+ .syntax unified | |
+ .section .text.memcpy,"ax",%progbits | |
+ .align 2 | |
+ .global memcpy | |
+ .thumb | |
+ .thumb_func | |
+ .type memcpy, %function | |
+memcpy: | |
+ @ r0: dst | |
+ @ r1: src | |
+ @ r2: len | |
+#ifdef __ARM_FEATURE_UNALIGNED | |
+ /* In case of UNALIGNED access supported, ip is not used in | |
+ function body. */ | |
+ mov ip, r0 | |
+#else | |
+ push {r0} | |
+#endif | |
+ orr r3, r1, r0 | |
+ ands r3, r3, #3 | |
+ bne .Lmisaligned_copy | |
+ | |
+.Lbig_block: | |
+ subs r2, __OPT_BIG_BLOCK_SIZE | |
+ blo .Lmid_block | |
+ | |
+ /* Kernel loop for big block copy */ | |
+ .align 2 | |
+.Lbig_block_loop: | |
+ BEGIN_UNROLL_BIG_BLOCK | |
+#ifdef __ARM_ARCH_7EM__ | |
+ ldr r3, [r1], #4 | |
+ str r3, [r0], #4 | |
+ END_UNROLL | |
+#else /* __ARM_ARCH_7M__ */ | |
+ ldr r3, [r1, \offset] | |
+ str r3, [r0, \offset] | |
+ END_UNROLL | |
+ adds r0, __OPT_BIG_BLOCK_SIZE | |
+ adds r1, __OPT_BIG_BLOCK_SIZE | |
+#endif | |
+ subs r2, __OPT_BIG_BLOCK_SIZE | |
+ bhs .Lbig_block_loop | |
+ | |
+.Lmid_block: | |
+ adds r2, __OPT_BIG_BLOCK_SIZE - __OPT_MID_BLOCK_SIZE | |
+ blo .Lcopy_word_by_word | |
+ | |
+ /* Kernel loop for mid-block copy */ | |
+ .align 2 | |
+.Lmid_block_loop: | |
+ BEGIN_UNROLL_MID_BLOCK | |
+#ifdef __ARM_ARCH_7EM__ | |
+ ldr r3, [r1], #4 | |
+ str r3, [r0], #4 | |
+ END_UNROLL | |
+#else /* __ARM_ARCH_7M__ */ | |
+ ldr r3, [r1, \offset] | |
+ str r3, [r0, \offset] | |
+ END_UNROLL | |
+ adds r0, __OPT_MID_BLOCK_SIZE | |
+ adds r1, __OPT_MID_BLOCK_SIZE | |
+#endif | |
+ subs r2, __OPT_MID_BLOCK_SIZE | |
+ bhs .Lmid_block_loop | |
+ | |
+.Lcopy_word_by_word: | |
+ adds r2, __OPT_MID_BLOCK_SIZE - 4 | |
+ blo .Lcopy_less_than_4 | |
+ | |
+ /* Kernel loop for small block copy */ | |
+ .align 2 | |
+.Lcopy_word_by_word_loop: | |
+ ldr r3, [r1], #4 | |
+ str r3, [r0], #4 | |
+ subs r2, #4 | |
+ bhs .Lcopy_word_by_word_loop | |
+ | |
+.Lcopy_less_than_4: | |
+ adds r2, #4 | |
+ beq .Ldone | |
+ | |
+ lsls r2, r2, #31 | |
+ itt ne | |
+ ldrbne r3, [r1], #1 | |
+ strbne r3, [r0], #1 | |
+ | |
+ bcc .Ldone | |
+#ifdef __ARM_FEATURE_UNALIGNED | |
+ ldrh r3, [r1] | |
+ strh r3, [r0] | |
+#else | |
+ ldrb r3, [r1] | |
+ strb r3, [r0] | |
+ ldrb r3, [r1, #1] | |
+ strb r3, [r0, #1] | |
+#endif /* __ARM_FEATURE_UNALIGNED */ | |
+ | |
+.Ldone: | |
+#ifdef __ARM_FEATURE_UNALIGNED | |
+ mov r0, ip | |
+#else | |
+ pop {r0} | |
+#endif | |
+ bx lr | |
+ | |
+ .align 2 | |
+.Lmisaligned_copy: | |
+#ifdef __ARM_FEATURE_UNALIGNED | |
+ /* Define label DST_ALIGNED to BIG_BLOCK. It will go to aligned copy | |
+ once destination is adjusted to aligned. */ | |
+#define Ldst_aligned Lbig_block | |
+ | |
+ /* Copy word by word using LDR when alignment can be done in hardware, | |
+ i.e., SCTLR.A is set, supporting unaligned access in LDR and STR. */ | |
+ | |
+ cmp r2, #8 | |
+ blo .Lbyte_copy | |
+ | |
+ /* if src is aligned, just go to the big block loop. */ | |
+ lsls r3, r1, #30 | |
+ beq .Ldst_aligned | |
+#else | |
+ /* if len < 12, misalignment adjustment has more overhead than | |
+ just byte-to-byte copy. Also, len must >=8 to guarantee code | |
+ afterward work correctly. */ | |
+ cmp r2, #12 | |
+ blo .Lbyte_copy | |
+#endif /* __ARM_FEATURE_UNALIGNED */ | |
+ | |
+ /* Align dst only, not trying to align src. That is the because | |
+ handling of aligned src and misaligned dst need more overhead than | |
+ otherwise. By doing this the worst case is when initial src is aligned, | |
+ additional up to 4 byte additional copy will executed, which is | |
+ acceptable. */ | |
+ | |
+ ands r3, r0, #3 | |
+ beq .Ldst_aligned | |
+ | |
+ rsb r3, #4 | |
+ subs r2, r3 | |
+ | |
+ lsls r3, r3, #31 | |
+ itt ne | |
+ ldrbne r3, [r1], #1 | |
+ strbne r3, [r0], #1 | |
+ | |
+ bcc .Ldst_aligned | |
+ | |
+#ifdef __ARM_FEATURE_UNALIGNED | |
+ ldrh r3, [r1], #2 | |
+ strh r3, [r0], #2 | |
+ b .Ldst_aligned | |
+#else | |
+ ldrb r3, [r1], #1 | |
+ strb r3, [r0], #1 | |
+ ldrb r3, [r1], #1 | |
+ strb r3, [r0], #1 | |
+ /* Now that dst is aligned */ | |
+.Ldst_aligned: | |
+ /* if r1 is aligned now, it means r0/r1 has the same misalignment, | |
+ and they are both aligned now. Go aligned copy. */ | |
+ ands r3, r1, #3 | |
+ beq .Lbig_block | |
+ | |
+ /* dst is aligned, but src isn't. Misaligned copy. */ | |
+ | |
+ push {r4, r5} | |
+ subs r2, #4 | |
+ | |
+ /* Backward r1 by misaligned bytes, to make r1 aligned. | |
+ Since we need to restore r1 to unaligned address after the loop, | |
+ we need keep the offset bytes to ip and sub it from r1 afterward. */ | |
+ subs r1, r3 | |
+ rsb ip, r3, #4 | |
+ | |
+ /* Pre-load on word */ | |
+ ldr r4, [r1], #4 | |
+ | |
+ cmp r3, #2 | |
+ beq .Lmisaligned_copy_2_2 | |
+ cmp r3, #3 | |
+ beq .Lmisaligned_copy_3_1 | |
+ | |
+ .macro mis_src_copy shift | |
+1: | |
+ lsrs r4, r4, \shift | |
+ ldr r3, [r1], #4 | |
+ lsls r5, r3, 32-\shift | |
+ orr r4, r4, r5 | |
+ str r4, [r0], #4 | |
+ mov r4, r3 | |
+ subs r2, #4 | |
+ bhs 1b | |
+ .endm | |
+ | |
+.Lmisaligned_copy_1_3: | |
+ mis_src_copy shift=8 | |
+ b .Lsrc_misaligned_tail | |
+ | |
+.Lmisaligned_copy_3_1: | |
+ mis_src_copy shift=24 | |
+ b .Lsrc_misaligned_tail | |
+ | |
+.Lmisaligned_copy_2_2: | |
+ /* For 2_2 misalignment, ldr is still faster than 2 x ldrh. */ | |
+ mis_src_copy shift=16 | |
+ | |
+.Lsrc_misaligned_tail: | |
+ adds r2, #4 | |
+ subs r1, ip | |
+ pop {r4, r5} | |
+ | |
+#endif /* __ARM_FEATURE_UNALIGNED */ | |
+ | |
+.Lbyte_copy: | |
+ subs r2, #4 | |
+ blo .Lcopy_less_than_4 | |
+ | |
+.Lbyte_copy_loop: | |
+ subs r2, #1 | |
+ ldrb r3, [r1], #1 | |
+ strb r3, [r0], #1 | |
+ bhs .Lbyte_copy_loop | |
+ | |
+ ldrb r3, [r1] | |
+ strb r3, [r0] | |
+ ldrb r3, [r1, #1] | |
+ strb r3, [r0, #1] | |
+ ldrb r3, [r1, #2] | |
+ strb r3, [r0, #2] | |
+ | |
+#ifdef __ARM_FEATURE_UNALIGNED | |
+ mov r0, ip | |
+#else | |
+ pop {r0} | |
+#endif | |
+ bx lr | |
+ | |
+ .size memcpy, .-memcpy | |
diff --git a/utils/hwstub/stub/memcpy.S b/utils/hwstub/stub/memcpy.S | |
index 2a55fb5..2ce312e 100644 | |
--- a/utils/hwstub/stub/memcpy.S | |
+++ b/utils/hwstub/stub/memcpy.S | |
@@ -37,7 +37,7 @@ | |
/* Prototype: void *memcpy(void *dest, const void *src, size_t n); */ | |
- .section .icode,"ax",%progbits | |
+ .section .text.memcpy,"ax",%progbits | |
.align 2 | |
.global memcpy | |
diff --git a/utils/hwstub/stub/memmove-arm7.S b/utils/hwstub/stub/memmove-arm7.S | |
new file mode 100644 | |
index 0000000..6a2ab2d | |
--- /dev/null | |
+++ b/utils/hwstub/stub/memmove-arm7.S | |
@@ -0,0 +1,9 @@ | |
+ .section .text.memmove,"ax",%progbits | |
+ .align 2 | |
+ .global memmove | |
+ .thumb | |
+ .thumb_func | |
+ .type memmove, %function | |
+memmove: | |
+ b memcpy | |
+.size memmove, .-memmove | |
diff --git a/utils/hwstub/stub/memmove.S b/utils/hwstub/stub/memmove.S | |
index d8cab04..4fb8f08 100644 | |
--- a/utils/hwstub/stub/memmove.S | |
+++ b/utils/hwstub/stub/memmove.S | |
@@ -46,7 +46,7 @@ | |
* normally a bit faster. Otherwise the copy is done going downwards. | |
*/ | |
- .section .icode,"ax",%progbits | |
+ .section .text.memmove,"ax",%progbits | |
.align 2 | |
.global memmove | |
diff --git a/utils/hwstub/stub/memset-arm7.S b/utils/hwstub/stub/memset-arm7.S | |
new file mode 100644 | |
index 0000000..e7ccdaa | |
--- /dev/null | |
+++ b/utils/hwstub/stub/memset-arm7.S | |
@@ -0,0 +1,10 @@ | |
+ .section .text.memset,"ax",%progbits | |
+ .align 2 | |
+ .global memset | |
+ .thumb | |
+ .thumb_func | |
+ .type memset, %function | |
+memset: | |
+ bx lr | |
+.size memset, .-memse | |
+ | |
diff --git a/utils/hwstub/stub/rknano/Makefile b/utils/hwstub/stub/rknano/Makefile | |
new file mode 100644 | |
index 0000000..bcbaf4e | |
--- /dev/null | |
+++ b/utils/hwstub/stub/rknano/Makefile | |
@@ -0,0 +1,14 @@ | |
+# | |
+# common | |
+# | |
+CC=arm-none-eabi-gcc | |
+LD=arm-none-eabi-gcc | |
+AS=arm-none-eabi-gcc | |
+OC=arm-none-eabi-objcopy | |
+DEFINES= | |
+INCLUDES=-I$(CURDIR) | |
+GCCOPTS= -mthumb -mcpu=cortex-m3 | |
+BUILD_DIR=$(CURDIR)/build/ | |
+ROOT_DIR=$(CURDIR)/.. | |
+ | |
+include ../hwstub.make | |
diff --git a/utils/hwstub/stub/rknano/target-config.h b/utils/hwstub/stub/rknano/target-config.h | |
new file mode 100644 | |
index 0000000..446130d | |
--- /dev/null | |
+++ b/utils/hwstub/stub/rknano/target-config.h | |
@@ -0,0 +1,9 @@ | |
+#define CONFIG_RKNANO | |
+#define IRAM_ORIG 0x1000000 | |
+#define IRAM_SIZE 0x8000 | |
+#define DRAM_ORIG 0x20000000 | |
+#define DRAM_SIZE (MEMORYSIZE * 0x100000) | |
+#define CPU_ARM | |
+#define ARM_ARCH 7 | |
+#define USB_BASE 0x62000000 | |
+#define USB_NUM_ENDPOINTS 2 | |
\ No newline at end of file | |
diff --git a/utils/hwstub/stub/rknano/target.c b/utils/hwstub/stub/rknano/target.c | |
new file mode 100644 | |
index 0000000..4f89702 | |
--- /dev/null | |
+++ b/utils/hwstub/stub/rknano/target.c | |
@@ -0,0 +1,98 @@ | |
+/*************************************************************************** | |
+ * __________ __ ___. | |
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | |
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | |
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | |
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | |
+ * \/ \/ \/ \/ \/ | |
+ * $Id$ | |
+ * | |
+ * Copyright (C) 2013 by Amaury Pouly | |
+ * | |
+ * 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 2 | |
+ * of the License, or (at your option) any later version. | |
+ * | |
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | |
+ * KIND, either express or implied. | |
+ * | |
+ ****************************************************************************/ | |
+#include "stddef.h" | |
+#include "target.h" | |
+#include "system.h" | |
+#include "logf.h" | |
+ | |
+/** | |
+ * | |
+ * Global | |
+ * | |
+ */ | |
+ | |
+static int g_atexit = HWSTUB_ATEXIT_OFF; | |
+ | |
+/** | |
+ * | |
+ * Power | |
+ * | |
+ */ | |
+ | |
+void power_off(void) | |
+{ | |
+} | |
+ | |
+void reset(void) | |
+{ | |
+} | |
+ | |
+void target_init(void) | |
+{ | |
+} | |
+ | |
+static struct usb_resp_info_target_t g_target = | |
+{ | |
+ .id = HWSTUB_TARGET_RKNANO, | |
+ .name = "RkNano-B/C" | |
+}; | |
+ | |
+int target_get_info(int info, void **buffer) | |
+{ | |
+ if(info == HWSTUB_INFO_TARGET) | |
+ { | |
+ *buffer = &g_target; | |
+ return sizeof(g_target); | |
+ } | |
+ else | |
+ return -1; | |
+} | |
+ | |
+int target_atexit(int method) | |
+{ | |
+ g_atexit = method; | |
+ return 0; | |
+} | |
+ | |
+void target_exit(void) | |
+{ | |
+ switch(g_atexit) | |
+ { | |
+ case HWSTUB_ATEXIT_OFF: | |
+ power_off(); | |
+ // fallthrough in case of return | |
+ case HWSTUB_ATEXIT_REBOOT: | |
+ reset(); | |
+ // fallthrough in case of return | |
+ case HWSTUB_ATEXIT_NOP: | |
+ default: | |
+ return; | |
+ } | |
+} | |
+ | |
+void target_udelay(int us) | |
+{ | |
+} | |
+ | |
+void target_mdelay(int ms) | |
+{ | |
+ return target_udelay(ms * 1000); | |
+} | |
diff --git a/utils/hwstub/stub/usb_drv_synopsys.c b/utils/hwstub/stub/usb_drv_synopsys.c | |
new file mode 100644 | |
index 0000000..98a2a22 | |
--- /dev/null | |
+++ b/utils/hwstub/stub/usb_drv_synopsys.c | |
@@ -0,0 +1,72 @@ | |
+/*************************************************************************** | |
+ * __________ __ ___. | |
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | |
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | |
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | |
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | |
+ * \/ \/ \/ \/ \/ | |
+ * $Id$ | |
+ * | |
+ * Copyright (C) 2013 by Amaury Pouly | |
+ * | |
+ * 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 2 | |
+ * of the License, or (at your option) any later version. | |
+ * | |
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | |
+ * KIND, either express or implied. | |
+ * | |
+ ****************************************************************************/ | |
+#include "usb_drv.h" | |
+#include "config.h" | |
+#include "memory.h" | |
+#include "target.h" | |
+ | |
+#define REG(x) (*(volatile uint32_t *)(x)) | |
+ | |
+#define USB_DEV (USB_BASE + 0x800) | |
+ | |
+/* Device Control Register */ | |
+#define DCTL REG(USB_DEV + 4) | |
+#define DCTL_SDIS (1 << 1) | |
+ | |
+void usb_drv_set_address(int address) | |
+{ | |
+} | |
+ | |
+int usb_drv_send(int endpoint, void* ptr, int length) | |
+{ | |
+ return -1; | |
+} | |
+ | |
+int usb_drv_recv(int endpoint, void* ptr, int length) | |
+{ | |
+ return -1; | |
+} | |
+ | |
+ | |
+int usb_drv_port_speed(void) | |
+{ | |
+ return 0; | |
+} | |
+ | |
+void usb_drv_stall(int endpoint, bool stall, bool in) | |
+{ | |
+} | |
+ | |
+ | |
+void usb_drv_init(void) | |
+{ | |
+ /* disconnect */ | |
+ DCTL |= DCTL_SDIS; | |
+} | |
+ | |
+void usb_drv_exit(void) | |
+{ | |
+} | |
+ | |
+int usb_drv_recv_setup(struct usb_ctrlrequest *req) | |
+{ | |
+ return -1; | |
+} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment