diff --git a/devices/base_device/Makefile b/devices/base_device/Makefile new file mode 100644 index 0000000..6ce4e5a --- /dev/null +++ b/devices/base_device/Makefile @@ -0,0 +1,16 @@ +ifeq ($(ANDROID_NDK_ROOT),) +$(error Error : Set the env variable 'ANDROID_NDK_ROOT' with the path of the Android NDK (version 20)) +endif + +CC := $(ANDROID_NDK_ROOT)/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android27-clang +AR := $(ANDROID_NDK_ROOT)/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-ar +OBJCOPY := $(ANDROID_NDK_ROOT)/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-objcopy +LD := $(ANDROID_NDK_ROOT)/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-ld.bfd + +CFLAGS_BASE_DEVICE := -Werror -Wno-unused-variable -Os -Idevices/base_device/ +base_device: + [ -d bin/base_device ] || mkdir -p bin/base_device/ + $(CC) arm64_stub.S -c -o bin/base_device/entry.o $(CFLAGS_BASE_DEVICE) + $(CC) debugger.c -c -o bin/base_device/debugger.o $(CFLAGS_BASE_DEVICE) + $(LD) -T devices/base_device/linkscript.ld bin/base_device/entry.o bin/base_device/debugger.o -o bin/base_device/debugger.elf --just-symbols=devices/base_device/symbols.txt + $(OBJCOPY) -O binary bin/base_device/debugger.elf bin/base_device/debugger.bin \ No newline at end of file diff --git a/devices/base_device/device.h b/devices/base_device/device.h new file mode 100644 index 0000000..c76ac3d --- /dev/null +++ b/devices/base_device/device.h @@ -0,0 +1,38 @@ + +void send(void *buffer, uint32_t size, uint32_t *num_xfer){ + // TODO implement +} + +int recv(void *buffer, uint32_t size, uint32_t *num_xfer){ + // TODO implement + return 0; +} + +void recv_data(void *data, uint32_t len) { + uint32_t rx_err_code; + uint32_t xfer = 0; + while(1) { + recv(data, len, &xfer); + if(xfer >= len) { + break; + } + } +} + +int mystrlen(char *data) { + int i=0; + while(1) { + if(data[i++] == '\0'){ + break; + } + } + return i-1; +} + +void usb_log(char * msg, uint32_t * error){ + send(msg, mystrlen(msg), error); +} + +void concrete_main(uint32_t debugger){ + // TODO device specific code +} \ No newline at end of file diff --git a/devices/base_device/linkscript.ld b/devices/base_device/linkscript.ld new file mode 100644 index 0000000..e69de29 diff --git a/devices/base_device/symbols.txt b/devices/base_device/symbols.txt new file mode 100644 index 0000000..bf48e20 --- /dev/null +++ b/devices/base_device/symbols.txt @@ -0,0 +1,6 @@ +send = 0x001065C0; +recv = 0x00106612; + + +debugger_storage = 0x40013000; +debugger_stack = 0x40014000; \ No newline at end of file