Skip to content

Commit

Permalink
[payload]add dump-arm32 payload
Browse files Browse the repository at this point in the history
  • Loading branch information
jianjunjiang committed Sep 21, 2024
1 parent e5177de commit 82ddda3
Show file tree
Hide file tree
Showing 10 changed files with 562 additions and 30 deletions.
85 changes: 56 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ usage:
xrock flash write <sector> <file> - Write file to flash sector
extra:
xrock extra maskrom --rc4 <on|off> [--sram <file> --delay <ms>] [--dram <file> --delay <ms>] [...]
xrock extra maskrom-dump-arm32 --rc4 <on|off> --uart <register> <address> <length>
xrock extra maskrom-dump-arm64 --rc4 <on|off> --uart <register> <address> <length>
xrock extra maskrom-write-arm32 --rc4 <on|off> <address> <file>
xrock extra maskrom-write-arm64 --rc4 <on|off> <address> <file>
xrock extra maskrom-exec-arm32 --rc4 <on|off> <address>
Expand Down Expand Up @@ -111,98 +113,123 @@ diff --git a/u-boot/cmd/rockusb.c b/u-boot/cmd/rockusb.c
### RV1106

```shell
sudo xrock maskrom rv1106_ddr_924MHz_v1.15.bin rv1106_usbplug_v1.09.bin --rc4-off
sudo xrock version
xrock maskrom rv1106_ddr_924MHz_v1.15.bin rv1106_usbplug_v1.09.bin --rc4-off
xrock version
```

- Initial ddr memory

```shell
xrock extra maskrom --rc4 off --sram rv1106_ddr_924MHz_v1.15.bin --delay 10
```

- Dump memory region in hex format by debug uart

```shell
xrock extra maskrom-dump-arm32 --rc4 off --uart 0xff4c0000 0xffff0000 1024
```

- Initial ddr memory and wirte `xstar.bin` to memory and jump to running

```shell
sudo xrock extra maskrom --rc4 off --sram rv1106_ddr_924MHz_v1.15.bin --delay 10
sudo xrock extra maskrom-write-arm32 --rc4 off 0x00000000 xstar.bin
sudo xrock extra maskrom-exec-arm32 --rc4 off 0x00000000
xrock extra maskrom --rc4 off --sram rv1106_ddr_924MHz_v1.15.bin --delay 10
xrock extra maskrom-write-arm32 --rc4 off 0x00000000 xstar.bin
xrock extra maskrom-exec-arm32 --rc4 off 0x00000000
```

### RK1808

```shell
sudo xrock maskrom rk1808_ddr_933MHz_v1.05.bin rk1808_usbplug_v1.05.bin
sudo xrock version
xrock maskrom rk1808_ddr_933MHz_v1.05.bin rk1808_usbplug_v1.05.bin
xrock version
```

### RK3128

```shell
sudo xrock maskrom rk3128_ddr_300MHz_v2.12.bin rk3128_usbplug_v2.63.bin
sudo xrock version
xrock maskrom rk3128_ddr_300MHz_v2.12.bin rk3128_usbplug_v2.63.bin
xrock version
```

### RK3288

```shell
sudo xrock maskrom rk3288_ddr_400MHz_v1.11.bin rk3288_usbplug_v2.63.bin
sudo xrock version
xrock maskrom rk3288_ddr_400MHz_v1.11.bin rk3288_usbplug_v2.63.bin
xrock version
```

### RK3399

```shell
sudo xrock maskrom rk3399_ddr_800MHz_v1.25.bin rk3399_usbplug_v1.26.bin
sudo xrock version
xrock maskrom rk3399_ddr_800MHz_v1.25.bin rk3399_usbplug_v1.26.bin
xrock version
```

### RK3399PRO

```shell
sudo xrock maskrom rk3399pro_ddr_666MHz_v1.25.bin rk3399pro_usbplug_v1.26.bin
sudo xrock version
xrock maskrom rk3399pro_ddr_666MHz_v1.25.bin rk3399pro_usbplug_v1.26.bin
xrock version
```

### PX30

```shell
sudo xrock maskrom px30_ddr_333MHz_v1.16.bin px30_usbplug_v1.31.bin
sudo xrock version
xrock maskrom px30_ddr_333MHz_v1.16.bin px30_usbplug_v1.31.bin
xrock version
```

### RK3308

```shell
sudo xrock maskrom rk3308_ddr_589MHz_uart2_m1_v1.31.bin rk3308_usbplug_v1.27.bin
sudo xrock version
xrock maskrom rk3308_ddr_589MHz_uart2_m1_v1.31.bin rk3308_usbplug_v1.27.bin
xrock version
```

### RK3566

```shell
sudo xrock maskrom rk3566_ddr_1056MHz_v1.11.bin rk356x_usbplug_v1.13.bin --rc4-off
sudo xrock version
xrock maskrom rk3566_ddr_1056MHz_v1.11.bin rk356x_usbplug_v1.13.bin --rc4-off
xrock version
```

### RK3568

```shell
sudo xrock maskrom rk3568_ddr_1560MHz_v1.11.bin rk356x_usbplug_v1.13.bin --rc4-off
sudo xrock version
xrock maskrom rk3568_ddr_1560MHz_v1.11.bin rk356x_usbplug_v1.13.bin --rc4-off
xrock version
```

### RK3588

```shell
sudo xrock maskrom rk3588_ddr_lp4_2112MHz_lp5_2736MHz_v1.05.bin rk3588_usbplug_v1.07.bin --rc4-off
sudo xrock version
xrock maskrom rk3588_ddr_lp4_2112MHz_lp5_2736MHz_v1.05.bin rk3588_usbplug_v1.07.bin --rc4-off
xrock version
```

### RK3562

```shell
sudo xrock maskrom rk3562_ddr_1332MHz_v1.05.bin rk3562_usbplug_v1.04.bin --rc4-off
sudo xrock version
xrock maskrom rk3562_ddr_1332MHz_v1.05.bin rk3562_usbplug_v1.04.bin --rc4-off
xrock version
```

### RK3576

```shell
sudo xrock maskrom rk3576_ddr_lp4_2112MHz_lp5_2736MHz_v1.05.bin rk3576_usbplug_v1.02.bin --rc4-off
sudo xrock version
xrock maskrom rk3576_ddr_lp4_2112MHz_lp5_2736MHz_v1.05.bin rk3576_usbplug_v1.02.bin --rc4-off
xrock version
```
- Initial ddr memory

```shell
xrock extra maskrom --rc4 off --sram rk3576_ddr_lp4_2112MHz_lp5_2736MHz_v1.05.bin --delay 10
```

- Dump memory region in hex format by debug uart

```shell
xrock extra maskrom-dump-arm64 --rc4 off --uart 0x2ad40000 0x3ff81000 1024
```

## Links
Expand Down
49 changes: 49 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ static void usage(void)

printf("extra:\r\n");
printf(" xrock extra maskrom --rc4 <on|off> [--sram <file> --delay <ms>] [--dram <file> --delay <ms>] [...]\r\n");
printf(" xrock extra maskrom-dump-arm32 --rc4 <on|off> --uart <register> <address> <length>\r\n");
printf(" xrock extra maskrom-dump-arm64 --rc4 <on|off> --uart <register> <address> <length>\r\n");
printf(" xrock extra maskrom-write-arm32 --rc4 <on|off> <address> <file>\r\n");
printf(" xrock extra maskrom-write-arm64 --rc4 <on|off> <address> <file>\r\n");
Expand Down Expand Up @@ -658,6 +659,54 @@ int main(int argc, char * argv[])
else
usage();
}
else if(!strcmp(argv[0], "maskrom-dump-arm32"))
{
argc -= 1;
argv += 1;
if(argc >= 2)
{
if(ctx.maskrom)
{
int rc4 = 0;
uint32_t uart = 0x0;
uint32_t addr = 0x0;
uint32_t len = 0x0;
for(int i = 0, idx = 0; i < argc; i++)
{
if(!strcmp(argv[i], "--rc4") && (argc > i + 1))
{
if(!strcmp(argv[i + 1], "on"))
rc4 = 1;
else if(!strcmp(argv[i + 1], "off"))
rc4 = 0;
i++;
}
else if(!strcmp(argv[i], "--uart") && (argc > i + 1))
{
uart = strtoul(argv[i + 1], NULL, 0);
i++;
}
else if(*argv[i] == '-')
{
usage();
}
else if(*argv[i] != '-' && strcmp(argv[i], "-") != 0)
{
if(idx == 0)
addr = strtoul(argv[i], NULL, 0);
else if(idx == 1)
len = strtoul(argv[i], NULL, 0);
idx++;
}
}
rock_maskrom_dump_arm32(&ctx, uart, addr, len, rc4);
}
else
printf("ERROR: The chip '%s' does not in maskrom mode\r\n", ctx.chip->name);
}
else
usage();
}
else if(!strcmp(argv[0], "maskrom-dump-arm64"))
{
argc -= 1;
Expand Down
10 changes: 10 additions & 0 deletions payloads/dump-arm32/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# Normal rules
#
*~

#
# Generated files
#
/.obj
/output
121 changes: 121 additions & 0 deletions payloads/dump-arm32/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
#
# Top makefile
#

CROSS ?= arm-none-eabi-
NAME := dump-arm32

#
# System environment variable.
#
ifeq ($(OS), Windows_NT)
HOSTOS := windows
else
ifneq (,$(findstring Linux, $(shell uname -a)))
HOSTOS := linux
endif
endif

#
# Load default variables.
#
ASFLAGS := -Wall -O3 -ffunction-sections -fdata-sections -ffreestanding -std=gnu99
CFLAGS := -Wall -O3 -ffunction-sections -fdata-sections -ffreestanding -std=gnu99
CXXFLAGS := -Wall -O3 -ffunction-sections -fdata-sections -ffreestanding
LDFLAGS := -Wl,-gc-sections -T link.ld -nostartfiles -nostdinc -nostdlib
OCFLAGS := -v -O binary
ODFLAGS :=
MCFLAGS := -march=armv7-a -mtune=cortex-a7 -mfpu=vfpv4 -mfloat-abi=softfp -marm -mno-thumb-interwork -mno-unaligned-access -fno-stack-protector

LIBDIRS :=
LIBS :=
INCDIRS :=
SRCDIRS :=

#
# Add external library
#
INCDIRS += src
SRCDIRS += src

#
# You shouldn't need to change anything below this point.
#
AS := $(CROSS)gcc -x assembler-with-cpp
CC := $(CROSS)gcc
CXX := $(CROSS)g++
LD := $(CROSS)ld
AR := $(CROSS)ar
SZ := $(CROSS_COMPILE)size
OC := $(CROSS)objcopy
OD := $(CROSS)objdump
STRIP := $(CROSS_COMPILE)strip
MKDIR := mkdir -p
CP := cp -af
RM := rm -fr
CD := cd
FIND := find

#
# X variables
#
X_ASFLAGS := $(MCFLAGS) $(ASFLAGS)
X_CFLAGS := $(MCFLAGS) $(CFLAGS)
X_CXXFLAGS := $(MCFLAGS) $(CXXFLAGS)
X_LDFLAGS := $(LDFLAGS)
X_OCFLAGS := $(OCFLAGS)
X_LIBDIRS := $(LIBDIRS)
X_LIBS := $(LIBS) -lgcc

X_OUT := output
X_NAME := $(patsubst %, $(X_OUT)/%, $(NAME))
X_INCDIRS := $(patsubst %, -I %, $(INCDIRS))
X_SRCDIRS := $(patsubst %, %, $(SRCDIRS))
X_OBJDIRS := $(patsubst %, .obj/%, $(X_SRCDIRS))

X_SFILES := $(foreach dir, $(X_SRCDIRS), $(wildcard $(dir)/*.S))
X_CFILES := $(foreach dir, $(X_SRCDIRS), $(wildcard $(dir)/*.c))
X_CPPFILES := $(foreach dir, $(X_SRCDIRS), $(wildcard $(dir)/*.cpp))

X_SDEPS := $(patsubst %, .obj/%, $(X_SFILES:.S=.o.d))
X_CDEPS := $(patsubst %, .obj/%, $(X_CFILES:.c=.o.d))
X_CPPDEPS := $(patsubst %, .obj/%, $(X_CPPFILES:.cpp=.o.d))
X_DEPS := $(X_SDEPS) $(X_CDEPS) $(X_CPPDEPS)

X_SOBJS := $(patsubst %, .obj/%, $(X_SFILES:.S=.o))
X_COBJS := $(patsubst %, .obj/%, $(X_CFILES:.c=.o))
X_CPPOBJS := $(patsubst %, .obj/%, $(X_CPPFILES:.cpp=.o))
X_OBJS := $(X_SOBJS) $(X_COBJS) $(X_CPPOBJS)

VPATH := $(X_OBJDIRS)

.PHONY: all clean
all : $(X_NAME)

$(X_NAME) : $(X_OBJS)
@echo [LD] Linking $@.elf
@$(CC) $(X_LDFLAGS) $(X_LIBDIRS) -Wl,--cref,-Map=$@.map $^ -o $@.elf $(X_LIBS)
@echo [OC] Objcopying $@.bin
@$(OC) $(X_OCFLAGS) $@.elf $@.bin
@echo [SZ] Listing $@.elf
@$(SZ) $@.elf

$(X_SOBJS) : .obj/%.o : %.S
@echo [AS] $<
@$(AS) $(X_ASFLAGS) -MD -MP -MF $@.d $(X_INCDIRS) -c $< -o $@

$(X_COBJS) : .obj/%.o : %.c
@echo [CC] $<
@$(CC) $(X_CFLAGS) -MD -MP -MF $@.d $(X_INCDIRS) -c $< -o $@

$(X_CPPOBJS) : .obj/%.o : %.cpp
@echo [CXX] $<
@$(CXX) $(X_CXXFLAGS) -MD -MP -MF $@.d $(X_INCDIRS) -c $< -o $@

clean:
@$(RM) .obj $(X_OUT)

#
# Include the dependency files, should be place the last of makefile
#
sinclude $(shell $(MKDIR) $(X_OBJDIRS) $(X_OUT)) $(X_DEPS)
Loading

0 comments on commit 82ddda3

Please sign in to comment.