mirror of
https://github.com/xboot/xfel.git
synced 2025-05-10 02:38:53 +08:00
Compare commits
157 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
9e597927ca | ||
![]() |
849e9ad73d | ||
![]() |
65c84e67a1 | ||
![]() |
fa8a294cd0 | ||
![]() |
936512d6a4 | ||
![]() |
423b9fefe5 | ||
![]() |
7f941b3798 | ||
![]() |
6efd2b352b | ||
![]() |
f4a34064be | ||
![]() |
c485d172a4 | ||
![]() |
4b58d94d34 | ||
![]() |
d577d6b6cf | ||
![]() |
53a91c8365 | ||
![]() |
a2bdf9fcd9 | ||
![]() |
4df3bf1f80 | ||
![]() |
c8491bb265 | ||
![]() |
0e6f3b25c1 | ||
![]() |
a69481210f | ||
![]() |
0094f7f799 | ||
![]() |
3327271e0b | ||
![]() |
64ca4f0c68 | ||
![]() |
9ac73147cc | ||
![]() |
1849780f53 | ||
![]() |
fa90526af1 | ||
![]() |
905f913b0c | ||
![]() |
1667a847c8 | ||
![]() |
7de784f399 | ||
![]() |
703e2990e8 | ||
![]() |
a02562bf92 | ||
![]() |
8e76d5599b | ||
![]() |
28b1bcccc0 | ||
![]() |
109e5d4a38 | ||
![]() |
eb524b53a9 | ||
![]() |
37259360ab | ||
![]() |
9728d78cad | ||
![]() |
1383b836cb | ||
![]() |
3c8a35a5f8 | ||
![]() |
4dda7f238a | ||
![]() |
e3ef078242 | ||
![]() |
59411a03b3 | ||
![]() |
4302195ec5 | ||
![]() |
a933687c72 | ||
![]() |
02f3c51af7 | ||
![]() |
42cafeaf59 | ||
![]() |
6f92b44497 | ||
![]() |
688f4204ae | ||
![]() |
7525fbca1f | ||
![]() |
8bc4119bc2 | ||
![]() |
25eae0be8b | ||
![]() |
42ed459c28 | ||
![]() |
e821f8e69f | ||
![]() |
db7f87acf7 | ||
![]() |
3bca4fc658 | ||
![]() |
7cb32b719a | ||
![]() |
fad2a97608 | ||
![]() |
137e61bdc6 | ||
![]() |
452d18dc0b | ||
![]() |
eafc9da05a | ||
![]() |
189cf4c478 | ||
![]() |
0587e4a009 | ||
![]() |
eacb6c3f82 | ||
![]() |
3574a19f33 | ||
![]() |
cc2f619067 | ||
![]() |
0889c73657 | ||
![]() |
a0b8da2ce5 | ||
![]() |
5cc5569f86 | ||
![]() |
f4c621d3d0 | ||
![]() |
15a7ad9a67 | ||
![]() |
bf41e97246 | ||
![]() |
1766434969 | ||
![]() |
d91fda1063 | ||
![]() |
c0da01c469 | ||
![]() |
33b1e9709f | ||
![]() |
9b398ae5ad | ||
![]() |
580e769ed4 | ||
![]() |
734f7b444c | ||
![]() |
06d8dc9b4e | ||
![]() |
720ec98da8 | ||
![]() |
30494aa4b6 | ||
![]() |
ca7319bbe5 | ||
![]() |
aa35a6b72b | ||
![]() |
bea385ab1c | ||
![]() |
4c2d0a30e5 | ||
![]() |
8ec520e8b1 | ||
![]() |
2477b710f7 | ||
![]() |
337ee0a3a1 | ||
![]() |
824523dc85 | ||
![]() |
712dcdb507 | ||
![]() |
33f451e489 | ||
![]() |
7d41606522 | ||
![]() |
055fc75efa | ||
![]() |
a647a243e6 | ||
![]() |
ddf7451239 | ||
![]() |
4ffb51cf8b | ||
![]() |
52c1a60657 | ||
![]() |
1bf6a578ca | ||
![]() |
59205cfc82 | ||
![]() |
b733b3a4fa | ||
![]() |
8bcc3842ef | ||
![]() |
b49c4897f8 | ||
![]() |
0b1ca5d03a | ||
![]() |
457cbb99bd | ||
![]() |
a65f9a63f7 | ||
![]() |
e560857ecb | ||
![]() |
4a3fdb2540 | ||
![]() |
4e0357e93a | ||
![]() |
c70949d053 | ||
![]() |
4c803c9149 | ||
![]() |
b457ded5c1 | ||
![]() |
ded857ef41 | ||
![]() |
8d9c3a3a67 | ||
![]() |
acc4b326e8 | ||
![]() |
69094c53e2 | ||
![]() |
6c1e611e72 | ||
![]() |
fd301e44b9 | ||
![]() |
ae2d214650 | ||
![]() |
3853ac3bd6 | ||
![]() |
8b381e2164 | ||
![]() |
8fa4c53f76 | ||
![]() |
a10d00c9f6 | ||
![]() |
ea965acd24 | ||
![]() |
543875134e | ||
![]() |
963cc32c5d | ||
![]() |
24db667fcf | ||
![]() |
0f433a15cd | ||
![]() |
ce25f333ce | ||
![]() |
7eafcc0728 | ||
![]() |
77c78538c9 | ||
![]() |
ae832eb2b9 | ||
![]() |
1e183994a9 | ||
![]() |
8ead642a08 | ||
![]() |
23323803d6 | ||
![]() |
9c9454e912 | ||
![]() |
feb00fefa1 | ||
![]() |
c9dddfb44f | ||
![]() |
8f085c7863 | ||
![]() |
c5c2cd0e5f | ||
![]() |
7102ff7fc6 | ||
![]() |
d65f3c8dc9 | ||
![]() |
802a7a284f | ||
![]() |
ffd1b96c37 | ||
![]() |
5003a865d3 | ||
![]() |
8ac8194551 | ||
![]() |
467331c731 | ||
![]() |
f9648357b3 | ||
![]() |
e71e9b217d | ||
![]() |
35fb098c6b | ||
![]() |
dd6265284e | ||
![]() |
12b363aa1c | ||
![]() |
d9b15757d2 | ||
![]() |
024a09e941 | ||
![]() |
a80759bf4b | ||
![]() |
202a382a40 | ||
![]() |
919a1ff36f | ||
![]() |
de6ad01a39 | ||
![]() |
0be5dc287f | ||
![]() |
bbffa15af1 |
@ -2,6 +2,5 @@
|
|||||||
# If rules fail to reload automatically, you can refresh udev rules
|
# If rules fail to reload automatically, you can refresh udev rules
|
||||||
# with the command "sudo udevadm control --reload"
|
# with the command "sudo udevadm control --reload"
|
||||||
|
|
||||||
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1f3a", ATTRS{idProduct}=="efe8", MODE="666", GROUP="plugdev"
|
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1f3a", ATTRS{idProduct}=="efe8", MODE="666", GROUP="users" TEST=="power/autosuspend", ATTR{power/autosuspend}="-1"
|
||||||
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="1f3a", ATTRS{idProduct}=="efe8", TEST=="power/autosuspend", ATTR{power/autosuspend}="-1"
|
|
||||||
|
|
||||||
|
6
Makefile
6
Makefile
@ -28,7 +28,6 @@ LIBS := `pkg-config --libs libusb-1.0`
|
|||||||
INCDIRS := -I . `pkg-config --cflags libusb-1.0`
|
INCDIRS := -I . `pkg-config --cflags libusb-1.0`
|
||||||
SRCDIRS := . chips
|
SRCDIRS := . chips
|
||||||
|
|
||||||
|
|
||||||
SFILES := $(foreach dir, $(SRCDIRS), $(wildcard $(dir)/*.S))
|
SFILES := $(foreach dir, $(SRCDIRS), $(wildcard $(dir)/*.S))
|
||||||
CFILES := $(foreach dir, $(SRCDIRS), $(wildcard $(dir)/*.c))
|
CFILES := $(foreach dir, $(SRCDIRS), $(wildcard $(dir)/*.c))
|
||||||
CPPFILES := $(foreach dir, $(SRCDIRS), $(wildcard $(dir)/*.cpp))
|
CPPFILES := $(foreach dir, $(SRCDIRS), $(wildcard $(dir)/*.cpp))
|
||||||
@ -72,5 +71,10 @@ install:
|
|||||||
install -Dm0644 99-xfel.rules /etc/udev/rules.d/99-xfel.rules
|
install -Dm0644 99-xfel.rules /etc/udev/rules.d/99-xfel.rules
|
||||||
install -Dm0644 LICENSE /usr/share/licenses/xfel/LICENSE
|
install -Dm0644 LICENSE /usr/share/licenses/xfel/LICENSE
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
rm -f /usr/local/bin/xfel
|
||||||
|
rm -f /etc/udev/rules.d/99-xfel.rules
|
||||||
|
rm -f /usr/share/licenses/xfel/LICENSE
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@$(RM) $(DEPS) $(OBJS) $(NAME).exe $(NAME) *~
|
@$(RM) $(DEPS) $(OBJS) $(NAME).exe $(NAME) *~
|
||||||
|
70
Makefile.win
Normal file
70
Makefile.win
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
#
|
||||||
|
# Top makefile
|
||||||
|
#
|
||||||
|
|
||||||
|
CROSS ?= x86_64-w64-mingw32-
|
||||||
|
|
||||||
|
AS := $(CROSS)gcc -x assembler-with-cpp
|
||||||
|
CC := $(CROSS)gcc
|
||||||
|
CXX := $(CROSS)g++
|
||||||
|
LD := $(CROSS)ld
|
||||||
|
AR := $(CROSS)ar
|
||||||
|
OC := $(CROSS)objcopy
|
||||||
|
OD := $(CROSS)objdump
|
||||||
|
RM := rm -fr
|
||||||
|
|
||||||
|
ASFLAGS := -g -ggdb -Wall -O3
|
||||||
|
CFLAGS := -g -ggdb -Wall -O3
|
||||||
|
CXXFLAGS := -g -ggdb -Wall -O3
|
||||||
|
LDFLAGS :=
|
||||||
|
ARFLAGS := -rcs
|
||||||
|
OCFLAGS := -v -O binary
|
||||||
|
ODFLAGS :=
|
||||||
|
MCFLAGS :=
|
||||||
|
|
||||||
|
LIBDIRS :=
|
||||||
|
LIBS := -L/usr/x86_64-w64-mingw32/lib -lusb-1.0
|
||||||
|
|
||||||
|
INCDIRS := -I . -I /usr/x86_64-w64-mingw32/include/libusb-1.0
|
||||||
|
SRCDIRS := . chips
|
||||||
|
|
||||||
|
SFILES := $(foreach dir, $(SRCDIRS), $(wildcard $(dir)/*.S))
|
||||||
|
CFILES := $(foreach dir, $(SRCDIRS), $(wildcard $(dir)/*.c))
|
||||||
|
CPPFILES := $(foreach dir, $(SRCDIRS), $(wildcard $(dir)/*.cpp))
|
||||||
|
|
||||||
|
SDEPS := $(patsubst %, %, $(SFILES:.S=.o.d))
|
||||||
|
CDEPS := $(patsubst %, %, $(CFILES:.c=.o.d))
|
||||||
|
CPPDEPS := $(patsubst %, %, $(CPPFILES:.cpp=.o.d))
|
||||||
|
DEPS := $(SDEPS) $(CDEPS) $(CPPDEPS)
|
||||||
|
|
||||||
|
SOBJS := $(patsubst %, %, $(SFILES:.S=.o))
|
||||||
|
COBJS := $(patsubst %, %, $(CFILES:.c=.o))
|
||||||
|
CPPOBJS := $(patsubst %, %, $(CPPFILES:.cpp=.o))
|
||||||
|
OBJS := $(SOBJS) $(COBJS) $(CPPOBJS)
|
||||||
|
|
||||||
|
OBJDIRS := $(patsubst %, %, $(SRCDIRS))
|
||||||
|
NAME := xfel
|
||||||
|
VPATH := $(OBJDIRS)
|
||||||
|
|
||||||
|
.PHONY: all clean
|
||||||
|
|
||||||
|
all : $(NAME)
|
||||||
|
|
||||||
|
$(NAME) : $(OBJS)
|
||||||
|
@echo [LD] Linking $@
|
||||||
|
@$(CC) $(LDFLAGS) $(LIBDIRS) $^ -o $@ $(LIBS) -static
|
||||||
|
|
||||||
|
$(SOBJS) : %.o : %.S
|
||||||
|
@echo [AS] $<
|
||||||
|
@$(AS) $(ASFLAGS) -MD -MP -MF $@.d $(INCDIRS) -c $< -o $@
|
||||||
|
|
||||||
|
$(COBJS) : %.o : %.c
|
||||||
|
@echo [CC] $<
|
||||||
|
@$(CC) $(CFLAGS) -MD -MP -MF $@.d $(INCDIRS) -c $< -o $@
|
||||||
|
|
||||||
|
$(CPPOBJS) : %.o : %.cpp
|
||||||
|
@echo [CXX] $<
|
||||||
|
@$(CXX) $(CXXFLAGS) -MD -MP -MF $@.d $(INCDIRS) -c $< -o $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@$(RM) $(DEPS) $(OBJS) $(NAME).exe $(NAME) *~
|
@ -16,15 +16,16 @@ usage:
|
|||||||
xfel version - Show chip version
|
xfel version - Show chip version
|
||||||
xfel hexdump <address> <length> - Dumps memory region in hex
|
xfel hexdump <address> <length> - Dumps memory region in hex
|
||||||
xfel dump <address> <length> - Binary memory dump to stdout
|
xfel dump <address> <length> - Binary memory dump to stdout
|
||||||
xfel exec <address> - Call function address
|
|
||||||
xfel read32 <address> - Read 32-bits value from device memory
|
xfel read32 <address> - Read 32-bits value from device memory
|
||||||
xfel write32 <address> <value> - Write 32-bits value to device memory
|
xfel write32 <address> <value> - Write 32-bits value to device memory
|
||||||
xfel read <address> <length> <file> - Read memory to file
|
xfel read <address> <length> <file> - Read memory to file
|
||||||
xfel write <address> <file> - Write file to memory
|
xfel write <address> <file> - Write file to memory
|
||||||
|
xfel exec <address> - Call function address
|
||||||
xfel reset - Reset device using watchdog
|
xfel reset - Reset device using watchdog
|
||||||
xfel sid - Show sid information
|
xfel sid - Show sid information
|
||||||
xfel jtag - Enable jtag debug
|
xfel jtag - Enable jtag debug
|
||||||
xfel ddr [type] - Initial ddr controller with optional type
|
xfel ddr [type] - Initial ddr controller with optional type
|
||||||
|
xfel sign <public-key> <private-key> <file> - Generate ecdsa256 signature file for sha256 of sid
|
||||||
xfel spinor - Detect spi nor flash
|
xfel spinor - Detect spi nor flash
|
||||||
xfel spinor erase <address> <length> - Erase spi nor flash
|
xfel spinor erase <address> <length> - Erase spi nor flash
|
||||||
xfel spinor read <address> <length> <file> - Read spi nor flash to file
|
xfel spinor read <address> <length> <file> - Read spi nor flash to file
|
||||||
@ -34,6 +35,7 @@ usage:
|
|||||||
xfel spinand read <address> <length> <file> - Read spi nand flash to file
|
xfel spinand read <address> <length> <file> - Read spi nand flash to file
|
||||||
xfel spinand write <address> <file> - Write file to spi nand flash
|
xfel spinand write <address> <file> - Write file to spi nand flash
|
||||||
xfel spinand splwrite <split-size> <address> <file> - Write file to spi nand flash with split support
|
xfel spinand splwrite <split-size> <address> <file> - Write file to spi nand flash with split support
|
||||||
|
xfel extra [...] - The extra commands
|
||||||
```
|
```
|
||||||
|
|
||||||
## Links
|
## Links
|
||||||
|
@ -37,6 +37,11 @@ static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int chip_extra(struct xfel_ctx_t * ctx, int argc, char * argv[])
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct chip_t a10 = {
|
struct chip_t a10 = {
|
||||||
.name = "A10",
|
.name = "A10",
|
||||||
.detect = chip_detect,
|
.detect = chip_detect,
|
||||||
@ -46,4 +51,5 @@ struct chip_t a10 = {
|
|||||||
.ddr = chip_ddr,
|
.ddr = chip_ddr,
|
||||||
.spi_init = chip_spi_init,
|
.spi_init = chip_spi_init,
|
||||||
.spi_run = chip_spi_run,
|
.spi_run = chip_spi_run,
|
||||||
|
.extra = chip_extra,
|
||||||
};
|
};
|
||||||
|
@ -37,6 +37,11 @@ static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int chip_extra(struct xfel_ctx_t * ctx, int argc, char * argv[])
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct chip_t a13_a10s_r8 = {
|
struct chip_t a13_a10s_r8 = {
|
||||||
.name = "A13/A10S/R8",
|
.name = "A13/A10S/R8",
|
||||||
.detect = chip_detect,
|
.detect = chip_detect,
|
||||||
@ -46,4 +51,5 @@ struct chip_t a13_a10s_r8 = {
|
|||||||
.ddr = chip_ddr,
|
.ddr = chip_ddr,
|
||||||
.spi_init = chip_spi_init,
|
.spi_init = chip_spi_init,
|
||||||
.spi_run = chip_spi_run,
|
.spi_run = chip_spi_run,
|
||||||
|
.extra = chip_extra,
|
||||||
};
|
};
|
||||||
|
@ -37,6 +37,11 @@ static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int chip_extra(struct xfel_ctx_t * ctx, int argc, char * argv[])
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct chip_t a20 = {
|
struct chip_t a20 = {
|
||||||
.name = "A20",
|
.name = "A20",
|
||||||
.detect = chip_detect,
|
.detect = chip_detect,
|
||||||
@ -46,4 +51,5 @@ struct chip_t a20 = {
|
|||||||
.ddr = chip_ddr,
|
.ddr = chip_ddr,
|
||||||
.spi_init = chip_spi_init,
|
.spi_init = chip_spi_init,
|
||||||
.spi_run = chip_spi_run,
|
.spi_run = chip_spi_run,
|
||||||
|
.extra = chip_extra,
|
||||||
};
|
};
|
||||||
|
@ -37,6 +37,11 @@ static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int chip_extra(struct xfel_ctx_t * ctx, int argc, char * argv[])
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct chip_t a23 = {
|
struct chip_t a23 = {
|
||||||
.name = "A23",
|
.name = "A23",
|
||||||
.detect = chip_detect,
|
.detect = chip_detect,
|
||||||
@ -46,4 +51,5 @@ struct chip_t a23 = {
|
|||||||
.ddr = chip_ddr,
|
.ddr = chip_ddr,
|
||||||
.spi_init = chip_spi_init,
|
.spi_init = chip_spi_init,
|
||||||
.spi_run = chip_spi_run,
|
.spi_run = chip_spi_run,
|
||||||
|
.extra = chip_extra,
|
||||||
};
|
};
|
||||||
|
@ -37,6 +37,11 @@ static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int chip_extra(struct xfel_ctx_t * ctx, int argc, char * argv[])
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct chip_t a31 = {
|
struct chip_t a31 = {
|
||||||
.name = "A31",
|
.name = "A31",
|
||||||
.detect = chip_detect,
|
.detect = chip_detect,
|
||||||
@ -46,4 +51,5 @@ struct chip_t a31 = {
|
|||||||
.ddr = chip_ddr,
|
.ddr = chip_ddr,
|
||||||
.spi_init = chip_spi_init,
|
.spi_init = chip_spi_init,
|
||||||
.spi_run = chip_spi_run,
|
.spi_run = chip_spi_run,
|
||||||
|
.extra = chip_extra,
|
||||||
};
|
};
|
||||||
|
@ -37,6 +37,11 @@ static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int chip_extra(struct xfel_ctx_t * ctx, int argc, char * argv[])
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct chip_t a33_r16 = {
|
struct chip_t a33_r16 = {
|
||||||
.name = "A33/R16",
|
.name = "A33/R16",
|
||||||
.detect = chip_detect,
|
.detect = chip_detect,
|
||||||
@ -46,4 +51,5 @@ struct chip_t a33_r16 = {
|
|||||||
.ddr = chip_ddr,
|
.ddr = chip_ddr,
|
||||||
.spi_init = chip_spi_init,
|
.spi_init = chip_spi_init,
|
||||||
.spi_run = chip_spi_run,
|
.spi_run = chip_spi_run,
|
||||||
|
.extra = chip_extra,
|
||||||
};
|
};
|
||||||
|
1530
chips/a40i_r40.c
1530
chips/a40i_r40.c
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
static int chip_detect(struct xfel_ctx_t * ctx, uint32_t id)
|
static int chip_detect(struct xfel_ctx_t * ctx, uint32_t id)
|
||||||
{
|
{
|
||||||
if(id == 0x00182300)
|
if(id == 0x00175500)
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -37,8 +37,13 @@ static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct chip_t t507 = {
|
static int chip_extra(struct xfel_ctx_t * ctx, int argc, char * argv[])
|
||||||
.name = "T507",
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct chip_t a50 = {
|
||||||
|
.name = "A50",
|
||||||
.detect = chip_detect,
|
.detect = chip_detect,
|
||||||
.reset = chip_reset,
|
.reset = chip_reset,
|
||||||
.sid = chip_sid,
|
.sid = chip_sid,
|
||||||
@ -46,4 +51,5 @@ struct chip_t t507 = {
|
|||||||
.ddr = chip_ddr,
|
.ddr = chip_ddr,
|
||||||
.spi_init = chip_spi_init,
|
.spi_init = chip_spi_init,
|
||||||
.spi_run = chip_spi_run,
|
.spi_run = chip_spi_run,
|
||||||
|
.extra = chip_extra,
|
||||||
};
|
};
|
2996
chips/a523_a527_t527.c
Normal file
2996
chips/a523_a527_t527.c
Normal file
File diff suppressed because it is too large
Load Diff
98
chips/a537_a333.c
Normal file
98
chips/a537_a333.c
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
#include <fel.h>
|
||||||
|
|
||||||
|
static int chip_detect(struct xfel_ctx_t * ctx, uint32_t id)
|
||||||
|
{
|
||||||
|
if(id == 0x00191900)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32_t payload_read32(struct xfel_ctx_t * ctx, uint32_t addr)
|
||||||
|
{
|
||||||
|
static const uint8_t payload[] = {
|
||||||
|
0x00, 0x00, 0xa0, 0xe3, 0x17, 0x0f, 0x08, 0xee, 0x15, 0x0f, 0x07, 0xee,
|
||||||
|
0xd5, 0x0f, 0x07, 0xee, 0x9a, 0x0f, 0x07, 0xee, 0x95, 0x0f, 0x07, 0xee,
|
||||||
|
0xff, 0xff, 0xff, 0xea, 0x0c, 0x00, 0x9f, 0xe5, 0x0c, 0x10, 0x8f, 0xe2,
|
||||||
|
0x00, 0x20, 0x90, 0xe5, 0x00, 0x20, 0x81, 0xe5, 0x1e, 0xff, 0x2f, 0xe1,
|
||||||
|
};
|
||||||
|
uint32_t adr = cpu_to_le32(addr);
|
||||||
|
uint32_t val;
|
||||||
|
|
||||||
|
fel_write(ctx, ctx->version.scratchpad, (void *)payload, sizeof(payload));
|
||||||
|
fel_write(ctx, ctx->version.scratchpad + sizeof(payload), (void *)&adr, sizeof(adr));
|
||||||
|
fel_exec(ctx, ctx->version.scratchpad);
|
||||||
|
fel_read(ctx, ctx->version.scratchpad + sizeof(payload) + sizeof(adr), (void *)&val, sizeof(val));
|
||||||
|
return le32_to_cpu(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void payload_write32(struct xfel_ctx_t * ctx, uint32_t addr, uint32_t val)
|
||||||
|
{
|
||||||
|
static const uint8_t payload[] = {
|
||||||
|
0x00, 0x00, 0xa0, 0xe3, 0x17, 0x0f, 0x08, 0xee, 0x15, 0x0f, 0x07, 0xee,
|
||||||
|
0xd5, 0x0f, 0x07, 0xee, 0x9a, 0x0f, 0x07, 0xee, 0x95, 0x0f, 0x07, 0xee,
|
||||||
|
0xff, 0xff, 0xff, 0xea, 0x08, 0x00, 0x9f, 0xe5, 0x08, 0x10, 0x9f, 0xe5,
|
||||||
|
0x00, 0x10, 0x80, 0xe5, 0x1e, 0xff, 0x2f, 0xe1,
|
||||||
|
};
|
||||||
|
uint32_t params[2] = {
|
||||||
|
cpu_to_le32(addr),
|
||||||
|
cpu_to_le32(val),
|
||||||
|
};
|
||||||
|
|
||||||
|
fel_write(ctx, ctx->version.scratchpad, (void *)payload, sizeof(payload));
|
||||||
|
fel_write(ctx, ctx->version.scratchpad + sizeof(payload), (void *)params, sizeof(params));
|
||||||
|
fel_exec(ctx, ctx->version.scratchpad);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chip_reset(struct xfel_ctx_t * ctx)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chip_sid(struct xfel_ctx_t * ctx, char * sid)
|
||||||
|
{
|
||||||
|
uint32_t id[4];
|
||||||
|
|
||||||
|
id[0] = payload_read32(ctx, 0x03006200 + 0x0);
|
||||||
|
id[1] = payload_read32(ctx, 0x03006200 + 0x4);
|
||||||
|
id[2] = payload_read32(ctx, 0x03006200 + 0x8);
|
||||||
|
id[3] = payload_read32(ctx, 0x03006200 + 0xc);
|
||||||
|
sprintf(sid, "%08x%08x%08x%08x", id[0], id[1], id[2], id[3]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chip_jtag(struct xfel_ctx_t * ctx)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chip_ddr(struct xfel_ctx_t * ctx, const char * type)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chip_spi_init(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t * swaplen, uint32_t * cmdlen)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chip_extra(struct xfel_ctx_t * ctx, int argc, char * argv[])
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct chip_t a537_a333 = {
|
||||||
|
.name = "A537/A333",
|
||||||
|
.detect = chip_detect,
|
||||||
|
.reset = chip_reset,
|
||||||
|
.sid = chip_sid,
|
||||||
|
.jtag = chip_jtag,
|
||||||
|
.ddr = chip_ddr,
|
||||||
|
.spi_init = chip_spi_init,
|
||||||
|
.spi_run = chip_spi_run,
|
||||||
|
.extra = chip_extra,
|
||||||
|
};
|
@ -37,6 +37,11 @@ static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int chip_extra(struct xfel_ctx_t * ctx, int argc, char * argv[])
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct chip_t a64 = {
|
struct chip_t a64 = {
|
||||||
.name = "A64",
|
.name = "A64",
|
||||||
.detect = chip_detect,
|
.detect = chip_detect,
|
||||||
@ -46,4 +51,5 @@ struct chip_t a64 = {
|
|||||||
.ddr = chip_ddr,
|
.ddr = chip_ddr,
|
||||||
.spi_init = chip_spi_init,
|
.spi_init = chip_spi_init,
|
||||||
.spi_run = chip_spi_run,
|
.spi_run = chip_spi_run,
|
||||||
|
.extra = chip_extra,
|
||||||
};
|
};
|
||||||
|
258
chips/a733.c
Normal file
258
chips/a733.c
Normal file
@ -0,0 +1,258 @@
|
|||||||
|
#include <fel.h>
|
||||||
|
|
||||||
|
static int chip_detect(struct xfel_ctx_t * ctx, uint32_t id)
|
||||||
|
{
|
||||||
|
if(id == 0x00190300)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32_t payload_read32(struct xfel_ctx_t * ctx, uint32_t addr)
|
||||||
|
{
|
||||||
|
static const uint8_t payload[] = {
|
||||||
|
0x00, 0x00, 0xa0, 0xe3, 0x17, 0x0f, 0x08, 0xee, 0x15, 0x0f, 0x07, 0xee,
|
||||||
|
0xd5, 0x0f, 0x07, 0xee, 0x9a, 0x0f, 0x07, 0xee, 0x95, 0x0f, 0x07, 0xee,
|
||||||
|
0xff, 0xff, 0xff, 0xea, 0x0c, 0x00, 0x9f, 0xe5, 0x0c, 0x10, 0x8f, 0xe2,
|
||||||
|
0x00, 0x20, 0x90, 0xe5, 0x00, 0x20, 0x81, 0xe5, 0x1e, 0xff, 0x2f, 0xe1,
|
||||||
|
};
|
||||||
|
uint32_t adr = cpu_to_le32(addr);
|
||||||
|
uint32_t val;
|
||||||
|
|
||||||
|
fel_write(ctx, ctx->version.scratchpad, (void *)payload, sizeof(payload));
|
||||||
|
fel_write(ctx, ctx->version.scratchpad + sizeof(payload), (void *)&adr, sizeof(adr));
|
||||||
|
fel_exec(ctx, ctx->version.scratchpad);
|
||||||
|
fel_read(ctx, ctx->version.scratchpad + sizeof(payload) + sizeof(adr), (void *)&val, sizeof(val));
|
||||||
|
return le32_to_cpu(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void payload_write32(struct xfel_ctx_t * ctx, uint32_t addr, uint32_t val)
|
||||||
|
{
|
||||||
|
static const uint8_t payload[] = {
|
||||||
|
0x00, 0x00, 0xa0, 0xe3, 0x17, 0x0f, 0x08, 0xee, 0x15, 0x0f, 0x07, 0xee,
|
||||||
|
0xd5, 0x0f, 0x07, 0xee, 0x9a, 0x0f, 0x07, 0xee, 0x95, 0x0f, 0x07, 0xee,
|
||||||
|
0xff, 0xff, 0xff, 0xea, 0x08, 0x00, 0x9f, 0xe5, 0x08, 0x10, 0x9f, 0xe5,
|
||||||
|
0x00, 0x10, 0x80, 0xe5, 0x1e, 0xff, 0x2f, 0xe1,
|
||||||
|
};
|
||||||
|
uint32_t params[2] = {
|
||||||
|
cpu_to_le32(addr),
|
||||||
|
cpu_to_le32(val),
|
||||||
|
};
|
||||||
|
|
||||||
|
fel_write(ctx, ctx->version.scratchpad, (void *)payload, sizeof(payload));
|
||||||
|
fel_write(ctx, ctx->version.scratchpad + sizeof(payload), (void *)params, sizeof(params));
|
||||||
|
fel_exec(ctx, ctx->version.scratchpad);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chip_reset(struct xfel_ctx_t * ctx)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chip_sid(struct xfel_ctx_t * ctx, char * sid)
|
||||||
|
{
|
||||||
|
uint32_t id[4];
|
||||||
|
|
||||||
|
id[0] = payload_read32(ctx, 0x03006200 + 0x0);
|
||||||
|
id[1] = payload_read32(ctx, 0x03006200 + 0x4);
|
||||||
|
id[2] = payload_read32(ctx, 0x03006200 + 0x8);
|
||||||
|
id[3] = payload_read32(ctx, 0x03006200 + 0xc);
|
||||||
|
sprintf(sid, "%08x%08x%08x%08x", id[0], id[1], id[2], id[3]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chip_jtag(struct xfel_ctx_t * ctx)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chip_ddr(struct xfel_ctx_t * ctx, const char * type)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chip_spi_init(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t * swaplen, uint32_t * cmdlen)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum {
|
||||||
|
SID_PRCTL = 0x03006000 + 0x040,
|
||||||
|
SID_PRKEY = 0x03006000 + 0x050,
|
||||||
|
SID_RDKEY = 0x03006000 + 0x060,
|
||||||
|
EFUSE_HV_SWITCH = 0x07090000 + 0x204,
|
||||||
|
};
|
||||||
|
|
||||||
|
static uint32_t efuse_read(struct xfel_ctx_t * ctx, uint32_t offset)
|
||||||
|
{
|
||||||
|
uint32_t val;
|
||||||
|
|
||||||
|
val = payload_read32(ctx, SID_PRCTL);
|
||||||
|
val &= ~((0x1ff << 16) | 0x3);
|
||||||
|
val |= offset << 16;
|
||||||
|
payload_write32(ctx, SID_PRCTL, val);
|
||||||
|
val &= ~((0xff << 8) | 0x3);
|
||||||
|
val |= (0xac << 8) | 0x2;
|
||||||
|
payload_write32(ctx, SID_PRCTL, val);
|
||||||
|
while(payload_read32(ctx, SID_PRCTL) & 0x2);
|
||||||
|
val &= ~((0x1ff << 16) | (0xff << 8) | 0x3);
|
||||||
|
payload_write32(ctx, SID_PRCTL, val);
|
||||||
|
val = payload_read32(ctx, SID_RDKEY);
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void efuse_write(struct xfel_ctx_t * ctx, uint32_t offset, uint32_t value)
|
||||||
|
{
|
||||||
|
uint32_t val;
|
||||||
|
|
||||||
|
payload_write32(ctx, EFUSE_HV_SWITCH, 0x1);
|
||||||
|
payload_write32(ctx, SID_PRKEY, value);
|
||||||
|
val = payload_read32(ctx, SID_PRCTL);
|
||||||
|
val &= ~((0x1ff << 16) | 0x3);
|
||||||
|
val |= offset << 16;
|
||||||
|
payload_write32(ctx, SID_PRCTL, val);
|
||||||
|
val &= ~((0xff << 8) | 0x3);
|
||||||
|
val |= (0xac << 8) | 0x1;
|
||||||
|
payload_write32(ctx, SID_PRCTL, val);
|
||||||
|
while(payload_read32(ctx, SID_PRCTL) & 0x1);
|
||||||
|
val &= ~((0x1ff << 16) | (0xff << 8) | 0x3);
|
||||||
|
payload_write32(ctx, SID_PRCTL, val);
|
||||||
|
payload_write32(ctx, EFUSE_HV_SWITCH, 0x0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct sid_section_t {
|
||||||
|
char * name;
|
||||||
|
uint32_t offset;
|
||||||
|
uint32_t size_bits;
|
||||||
|
} sids[] = {
|
||||||
|
{ "chipid", 0x00, 128 },
|
||||||
|
{ "brom-config", 0x10, 32 },
|
||||||
|
{ "tf-zone", 0x28, 128 },
|
||||||
|
{ "thermal-sensor", 0x30, 64 },
|
||||||
|
{ "oem-program", 0x3c, 160 },
|
||||||
|
{ "write-protect", 0x80, 32 },
|
||||||
|
{ "read-protect", 0x84, 32 },
|
||||||
|
{ "lcjs", 0x88, 32 },
|
||||||
|
{ "attr", 0x90, 32 },
|
||||||
|
{ "huk", 0x94, 192 },
|
||||||
|
{ "reserved1", 0xac, 64 },
|
||||||
|
{ "rotpk", 0xb4, 256 },
|
||||||
|
{ "ssk", 0xd4, 128 },
|
||||||
|
{ "rssk", 0xf4, 256 },
|
||||||
|
{ "sn", 0xb0, 192 },
|
||||||
|
{ "nv1", 0x124, 32 },
|
||||||
|
{ "nv2", 0x128, 224 },
|
||||||
|
{ "hdcp-hash", 0x114, 128 },
|
||||||
|
{ "backup-key", 0x164, 192 },
|
||||||
|
{ "backup-key2", 0x1a4, 72 }
|
||||||
|
};
|
||||||
|
|
||||||
|
static int chip_extra(struct xfel_ctx_t * ctx, int argc, char * argv[])
|
||||||
|
{
|
||||||
|
if(argc > 0)
|
||||||
|
{
|
||||||
|
if(!strcmp(argv[0], "efuse"))
|
||||||
|
{
|
||||||
|
argc -= 1;
|
||||||
|
argv += 1;
|
||||||
|
if(argc > 0)
|
||||||
|
{
|
||||||
|
if(!strcmp(argv[0], "dump") && (argc == 1))
|
||||||
|
{
|
||||||
|
uint32_t buffer[2048 / 4];
|
||||||
|
for(int n = 0; n < ARRAY_SIZE(sids); n++)
|
||||||
|
{
|
||||||
|
uint32_t count = sids[n].size_bits / 32;
|
||||||
|
for(int i = 0; i < count; i++)
|
||||||
|
buffer[i] = efuse_read(ctx, sids[n].offset + i * 4);
|
||||||
|
printf("%s:(0x%04x %d-bits)", sids[n].name, sids[n].offset, sids[n].size_bits);
|
||||||
|
for(int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
if(i >= 0 && ((i % 8) == 0))
|
||||||
|
printf("\r\n%-4s", "");
|
||||||
|
printf("%08x ", buffer[i]);
|
||||||
|
}
|
||||||
|
printf("\r\n");
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if(!strcmp(argv[0], "read32") && (argc == 2))
|
||||||
|
{
|
||||||
|
uint32_t offset = strtoul(argv[1], NULL, 0);
|
||||||
|
printf("0x%08x\r\n", efuse_read(ctx, offset));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if(!strcmp(argv[0], "write32") && (argc == 3))
|
||||||
|
{
|
||||||
|
uint32_t offset = strtoul(argv[1], NULL, 0);
|
||||||
|
size_t value = strtoul(argv[2], NULL, 0);
|
||||||
|
efuse_write(ctx, offset, value);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else if(!strcmp(argv[0], "write") && (argc == 3))
|
||||||
|
{
|
||||||
|
uint32_t offset = strtoul(argv[1], NULL, 0);
|
||||||
|
uint64_t len;
|
||||||
|
void * buf = file_load(argv[2], &len);
|
||||||
|
if(buf && (len > 0))
|
||||||
|
{
|
||||||
|
uint8_t * p = buf;
|
||||||
|
uint32_t l = len;
|
||||||
|
uint32_t o = 0;
|
||||||
|
uint32_t v;
|
||||||
|
while(l >= 4)
|
||||||
|
{
|
||||||
|
v = *((uint32_t *)p);
|
||||||
|
efuse_write(ctx, offset + o, v);
|
||||||
|
l -= 4;
|
||||||
|
o += 4;
|
||||||
|
p += 4;
|
||||||
|
}
|
||||||
|
if(l > 0)
|
||||||
|
{
|
||||||
|
uint32_t v = 0;
|
||||||
|
for(int i = 0; i < l; i++)
|
||||||
|
v = ((v << 8) & 0xffffff00) | p[i];
|
||||||
|
efuse_write(ctx, offset + o, v);
|
||||||
|
}
|
||||||
|
free(buf);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(!strcmp(argv[0], "checksboot"))
|
||||||
|
{
|
||||||
|
uint32_t secure_status = payload_read32(ctx, 0x03006000 + 0xA0);
|
||||||
|
if(secure_status)
|
||||||
|
printf("The device enabled the security boot.\r\n");
|
||||||
|
else
|
||||||
|
printf("The device does not enabled the security boot.\r\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("usage:\r\n");
|
||||||
|
printf(" xfel extra efuse dump - Dump all of the efuse information\r\n");
|
||||||
|
printf(" xfel extra efuse read32 <offset> - Read 32-bits value from efuse\r\n");
|
||||||
|
printf(" xfel extra efuse write32 <offset> <value> - Write 32-bits value to efuse\r\n");
|
||||||
|
printf(" xfel extra efuse write <offset> <file> - Write file to efuse\r\n");
|
||||||
|
printf(" xfel extra checksboot - Check whether security boot is enabled on the device\r\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct chip_t a733 = {
|
||||||
|
.name = "A733",
|
||||||
|
.detect = chip_detect,
|
||||||
|
.reset = chip_reset,
|
||||||
|
.sid = chip_sid,
|
||||||
|
.jtag = chip_jtag,
|
||||||
|
.ddr = chip_ddr,
|
||||||
|
.spi_init = chip_spi_init,
|
||||||
|
.spi_run = chip_spi_run,
|
||||||
|
.extra = chip_extra,
|
||||||
|
};
|
@ -37,6 +37,11 @@ static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int chip_extra(struct xfel_ctx_t * ctx, int argc, char * argv[])
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct chip_t a80 = {
|
struct chip_t a80 = {
|
||||||
.name = "A80",
|
.name = "A80",
|
||||||
.detect = chip_detect,
|
.detect = chip_detect,
|
||||||
@ -46,4 +51,5 @@ struct chip_t a80 = {
|
|||||||
.ddr = chip_ddr,
|
.ddr = chip_ddr,
|
||||||
.spi_init = chip_spi_init,
|
.spi_init = chip_spi_init,
|
||||||
.spi_run = chip_spi_run,
|
.spi_run = chip_spi_run,
|
||||||
|
.extra = chip_extra,
|
||||||
};
|
};
|
||||||
|
@ -37,6 +37,11 @@ static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int chip_extra(struct xfel_ctx_t * ctx, int argc, char * argv[])
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct chip_t a83t = {
|
struct chip_t a83t = {
|
||||||
.name = "A83T",
|
.name = "A83T",
|
||||||
.detect = chip_detect,
|
.detect = chip_detect,
|
||||||
@ -46,4 +51,5 @@ struct chip_t a83t = {
|
|||||||
.ddr = chip_ddr,
|
.ddr = chip_ddr,
|
||||||
.spi_init = chip_spi_init,
|
.spi_init = chip_spi_init,
|
||||||
.spi_run = chip_spi_run,
|
.spi_run = chip_spi_run,
|
||||||
|
.extra = chip_extra,
|
||||||
};
|
};
|
||||||
|
3271
chips/d1_f133.c
3271
chips/d1_f133.c
File diff suppressed because it is too large
Load Diff
@ -424,7 +424,7 @@ static int chip_spi_init(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t *
|
|||||||
0xff, 0xff, 0xff, 0xea, 0x40, 0x00, 0xa0, 0xe3, 0x00, 0xd0, 0x80, 0xe5,
|
0xff, 0xff, 0xff, 0xea, 0x40, 0x00, 0xa0, 0xe3, 0x00, 0xd0, 0x80, 0xe5,
|
||||||
0x04, 0xe0, 0x80, 0xe5, 0x00, 0xe0, 0x0f, 0xe1, 0x08, 0xe0, 0x80, 0xe5,
|
0x04, 0xe0, 0x80, 0xe5, 0x00, 0xe0, 0x0f, 0xe1, 0x08, 0xe0, 0x80, 0xe5,
|
||||||
0x10, 0xef, 0x11, 0xee, 0x0c, 0xe0, 0x80, 0xe5, 0x10, 0xef, 0x11, 0xee,
|
0x10, 0xef, 0x11, 0xee, 0x0c, 0xe0, 0x80, 0xe5, 0x10, 0xef, 0x11, 0xee,
|
||||||
0x10, 0xe0, 0x80, 0xe5, 0x26, 0x0b, 0xa0, 0xe3, 0x85, 0x00, 0x00, 0xeb,
|
0x10, 0xe0, 0x80, 0xe5, 0x26, 0x0b, 0xa0, 0xe3, 0x8b, 0x00, 0x00, 0xeb,
|
||||||
0x04, 0x00, 0xa0, 0xe3, 0x65, 0x10, 0xa0, 0xe3, 0x00, 0x10, 0xc0, 0xe5,
|
0x04, 0x00, 0xa0, 0xe3, 0x65, 0x10, 0xa0, 0xe3, 0x00, 0x10, 0xc0, 0xe5,
|
||||||
0x47, 0x10, 0xa0, 0xe3, 0x01, 0x10, 0xc0, 0xe5, 0x4f, 0x10, 0xa0, 0xe3,
|
0x47, 0x10, 0xa0, 0xe3, 0x01, 0x10, 0xc0, 0xe5, 0x4f, 0x10, 0xa0, 0xe3,
|
||||||
0x02, 0x10, 0xc0, 0xe5, 0x4e, 0x10, 0xa0, 0xe3, 0x03, 0x10, 0xc0, 0xe5,
|
0x02, 0x10, 0xc0, 0xe5, 0x4e, 0x10, 0xa0, 0xe3, 0x03, 0x10, 0xc0, 0xe5,
|
||||||
@ -435,40 +435,42 @@ static int chip_spi_init(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t *
|
|||||||
0x10, 0x1f, 0x01, 0xee, 0x0c, 0x10, 0x90, 0xe5, 0x10, 0x1f, 0x01, 0xee,
|
0x10, 0x1f, 0x01, 0xee, 0x0c, 0x10, 0x90, 0xe5, 0x10, 0x1f, 0x01, 0xee,
|
||||||
0x08, 0x10, 0x90, 0xe5, 0x01, 0xf0, 0x29, 0xe1, 0x1e, 0xff, 0x2f, 0xe1,
|
0x08, 0x10, 0x90, 0xe5, 0x01, 0xf0, 0x29, 0xe1, 0x1e, 0xff, 0x2f, 0xe1,
|
||||||
0xf0, 0x40, 0x2d, 0xe9, 0x00, 0x50, 0x51, 0xe2, 0xf0, 0x80, 0xbd, 0x08,
|
0xf0, 0x40, 0x2d, 0xe9, 0x00, 0x50, 0x51, 0xe2, 0xf0, 0x80, 0xbd, 0x08,
|
||||||
0xc8, 0xe0, 0x9f, 0xe5, 0xc8, 0x60, 0x9f, 0xe5, 0xc8, 0x40, 0x9f, 0xe5,
|
0xd4, 0x10, 0x9f, 0xe5, 0xd4, 0x60, 0x9f, 0xe5, 0xd4, 0x40, 0x9f, 0xe5,
|
||||||
0x00, 0x70, 0xe0, 0xe3, 0x40, 0x00, 0x55, 0xe3, 0x05, 0x20, 0xa0, 0x31,
|
0x00, 0x70, 0xe0, 0xe3, 0x40, 0x00, 0x55, 0xe3, 0x05, 0x20, 0xa0, 0x31,
|
||||||
0x40, 0x20, 0xa0, 0x23, 0x00, 0x30, 0xa0, 0xe3, 0x07, 0x10, 0xa0, 0xe1,
|
0x40, 0x20, 0xa0, 0x23, 0x00, 0x30, 0xa0, 0xe3, 0x07, 0xc0, 0xa0, 0xe1,
|
||||||
0x30, 0x20, 0x8e, 0xe5, 0x34, 0x20, 0x8e, 0xe5, 0x38, 0x20, 0x8e, 0xe5,
|
0x30, 0x20, 0x81, 0xe5, 0x34, 0x20, 0x81, 0xe5, 0x38, 0x20, 0x81, 0xe5,
|
||||||
0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1, 0x00, 0x10, 0xc6, 0xe5,
|
0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1, 0x00, 0xc0, 0xc6, 0xe5,
|
||||||
0xfb, 0xff, 0xff, 0xca, 0x08, 0x30, 0x9e, 0xe5, 0x02, 0x31, 0x83, 0xe3,
|
0xfb, 0xff, 0xff, 0xca, 0x08, 0x30, 0x91, 0xe5, 0x02, 0x31, 0x83, 0xe3,
|
||||||
0x08, 0x30, 0x8e, 0xe5, 0x1c, 0x30, 0x9e, 0xe5, 0xff, 0x30, 0x03, 0xe2,
|
0x08, 0x30, 0x81, 0xe5, 0x08, 0x30, 0x91, 0xe5, 0x00, 0x00, 0x53, 0xe3,
|
||||||
|
0xfc, 0xff, 0xff, 0xba, 0x1c, 0x30, 0x91, 0xe5, 0xff, 0x30, 0x03, 0xe2,
|
||||||
0x03, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0x8a, 0x00, 0x30, 0xa0, 0xe3,
|
0x03, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0x8a, 0x00, 0x30, 0xa0, 0xe3,
|
||||||
0x00, 0xc0, 0xd4, 0xe5, 0x00, 0x00, 0x50, 0xe3, 0x00, 0x10, 0xa0, 0xe1,
|
0x00, 0xe0, 0xd4, 0xe5, 0x00, 0x00, 0x50, 0xe3, 0x00, 0xc0, 0xa0, 0xe1,
|
||||||
0xff, 0xc0, 0x0c, 0xe2, 0x07, 0x00, 0x00, 0x0a, 0x01, 0x30, 0x83, 0xe2,
|
0xff, 0xe0, 0x0e, 0xe2, 0x07, 0x00, 0x00, 0x0a, 0x01, 0x30, 0x83, 0xe2,
|
||||||
0x03, 0x00, 0x52, 0xe1, 0x01, 0xc0, 0xc1, 0xe4, 0x01, 0x00, 0xa0, 0xe1,
|
0x03, 0x00, 0x52, 0xe1, 0x01, 0xe0, 0xcc, 0xe4, 0x0c, 0x00, 0xa0, 0xe1,
|
||||||
0xf5, 0xff, 0xff, 0xca, 0x02, 0x50, 0x55, 0xe0, 0xdf, 0xff, 0xff, 0x1a,
|
0xf5, 0xff, 0xff, 0xca, 0x02, 0x50, 0x55, 0xe0, 0xdc, 0xff, 0xff, 0x1a,
|
||||||
0xf0, 0x80, 0xbd, 0xe8, 0x01, 0x10, 0x83, 0xe2, 0x02, 0x00, 0x51, 0xe1,
|
0xf0, 0x80, 0xbd, 0xe8, 0x01, 0xc0, 0x83, 0xe2, 0x02, 0x00, 0x5c, 0xe1,
|
||||||
0x02, 0x30, 0x83, 0xe2, 0xf8, 0xff, 0xff, 0xaa, 0x03, 0x00, 0x52, 0xe1,
|
0x02, 0x30, 0x83, 0xe2, 0xf8, 0xff, 0xff, 0xaa, 0x03, 0x00, 0x52, 0xe1,
|
||||||
0x00, 0x10, 0xd4, 0xe5, 0xf5, 0xff, 0xff, 0xda, 0x00, 0x10, 0xd4, 0xe5,
|
0x00, 0xc0, 0xd4, 0xe5, 0xf5, 0xff, 0xff, 0xda, 0x00, 0xc0, 0xd4, 0xe5,
|
||||||
0x01, 0x10, 0x83, 0xe2, 0x02, 0x00, 0x51, 0xe1, 0x02, 0x30, 0x83, 0xe2,
|
0x01, 0xc0, 0x83, 0xe2, 0x02, 0x00, 0x5c, 0xe1, 0x02, 0x30, 0x83, 0xe2,
|
||||||
0xf7, 0xff, 0xff, 0xba, 0x02, 0x50, 0x55, 0xe0, 0xd0, 0xff, 0xff, 0x1a,
|
0xf7, 0xff, 0xff, 0xba, 0x02, 0x50, 0x55, 0xe0, 0xcd, 0xff, 0xff, 0x1a,
|
||||||
0xf0, 0x80, 0xbd, 0xe8, 0x00, 0x50, 0xc0, 0x01, 0x00, 0x52, 0xc0, 0x01,
|
0xf0, 0x80, 0xbd, 0xe8, 0x00, 0x50, 0xc0, 0x01, 0x00, 0x52, 0xc0, 0x01,
|
||||||
0x00, 0x53, 0xc0, 0x01, 0xf0, 0x40, 0x2d, 0xe9, 0x00, 0x60, 0x51, 0xe2,
|
0x00, 0x53, 0xc0, 0x01, 0xf0, 0x40, 0x2d, 0xe9, 0x00, 0x60, 0x51, 0xe2,
|
||||||
0xf0, 0x80, 0xbd, 0x08, 0xa4, 0x10, 0x9f, 0xe5, 0xa4, 0x50, 0x9f, 0xe5,
|
0xf0, 0x80, 0xbd, 0x08, 0xb0, 0x10, 0x9f, 0xe5, 0xb0, 0x50, 0x9f, 0xe5,
|
||||||
0xa4, 0x40, 0x9f, 0xe5, 0x00, 0x70, 0xe0, 0xe3, 0x40, 0x00, 0x56, 0xe3,
|
0xb0, 0x40, 0x9f, 0xe5, 0x00, 0x70, 0xe0, 0xe3, 0x40, 0x00, 0x56, 0xe3,
|
||||||
0x06, 0x20, 0xa0, 0x31, 0x40, 0x20, 0xa0, 0x23, 0x00, 0x00, 0x50, 0xe3,
|
0x06, 0x20, 0xa0, 0x31, 0x40, 0x20, 0xa0, 0x23, 0x00, 0x00, 0x50, 0xe3,
|
||||||
0x30, 0x20, 0x81, 0xe5, 0x34, 0x20, 0x81, 0xe5, 0x38, 0x20, 0x81, 0xe5,
|
0x30, 0x20, 0x81, 0xe5, 0x34, 0x20, 0x81, 0xe5, 0x38, 0x20, 0x81, 0xe5,
|
||||||
0x17, 0x00, 0x00, 0x0a, 0x00, 0xc0, 0xa0, 0xe1, 0x00, 0x30, 0xa0, 0xe3,
|
0x1a, 0x00, 0x00, 0x0a, 0x00, 0xc0, 0xa0, 0xe1, 0x00, 0x30, 0xa0, 0xe3,
|
||||||
0x01, 0xe0, 0xdc, 0xe4, 0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1,
|
0x01, 0xe0, 0xdc, 0xe4, 0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1,
|
||||||
0x00, 0xe0, 0xc5, 0xe5, 0xfa, 0xff, 0xff, 0xca, 0x08, 0x30, 0x91, 0xe5,
|
0x00, 0xe0, 0xc5, 0xe5, 0xfa, 0xff, 0xff, 0xca, 0x08, 0x30, 0x91, 0xe5,
|
||||||
0x02, 0x31, 0x83, 0xe3, 0x08, 0x30, 0x81, 0xe5, 0x1c, 0x30, 0x91, 0xe5,
|
0x02, 0x31, 0x83, 0xe3, 0x08, 0x30, 0x81, 0xe5, 0x08, 0x30, 0x91, 0xe5,
|
||||||
|
0x00, 0x00, 0x53, 0xe3, 0xfc, 0xff, 0xff, 0xba, 0x1c, 0x30, 0x91, 0xe5,
|
||||||
0xff, 0x30, 0x03, 0xe2, 0x03, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0x8a,
|
0xff, 0x30, 0x03, 0xe2, 0x03, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0x8a,
|
||||||
0x00, 0x30, 0xa0, 0xe3, 0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1,
|
0x00, 0x30, 0xa0, 0xe3, 0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1,
|
||||||
0x00, 0xc0, 0xd4, 0xe5, 0xfb, 0xff, 0xff, 0xca, 0x00, 0x00, 0x50, 0xe3,
|
0x00, 0xc0, 0xd4, 0xe5, 0xfb, 0xff, 0xff, 0xca, 0x00, 0x00, 0x50, 0xe3,
|
||||||
0x02, 0x00, 0x80, 0x10, 0x02, 0x60, 0x56, 0xe0, 0xe0, 0xff, 0xff, 0x1a,
|
0x02, 0x00, 0x80, 0x10, 0x02, 0x60, 0x56, 0xe0, 0xdd, 0xff, 0xff, 0x1a,
|
||||||
0xf0, 0x80, 0xbd, 0xe8, 0x00, 0x30, 0xa0, 0xe1, 0x07, 0xc0, 0xa0, 0xe1,
|
0xf0, 0x80, 0xbd, 0xe8, 0x00, 0x30, 0xa0, 0xe1, 0x07, 0xc0, 0xa0, 0xe1,
|
||||||
0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1, 0x00, 0xc0, 0xc5, 0xe5,
|
0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1, 0x00, 0xc0, 0xc5, 0xe5,
|
||||||
0xfb, 0xff, 0xff, 0xca, 0xe7, 0xff, 0xff, 0xea, 0x00, 0x50, 0xc0, 0x01,
|
0xfb, 0xff, 0xff, 0xca, 0xe4, 0xff, 0xff, 0xea, 0x00, 0x50, 0xc0, 0x01,
|
||||||
0x00, 0x52, 0xc0, 0x01, 0x00, 0x53, 0xc0, 0x01, 0xf0, 0x43, 0x2d, 0xe9,
|
0x00, 0x52, 0xc0, 0x01, 0x00, 0x53, 0xc0, 0x01, 0xf0, 0x43, 0x2d, 0xe9,
|
||||||
0x50, 0x82, 0x9f, 0xe5, 0x50, 0x52, 0x9f, 0xe5, 0x50, 0x72, 0x9f, 0xe5,
|
0x50, 0x82, 0x9f, 0xe5, 0x50, 0x52, 0x9f, 0xe5, 0x50, 0x72, 0x9f, 0xe5,
|
||||||
0x14, 0xd0, 0x4d, 0xe2, 0x00, 0x60, 0xa0, 0xe1, 0x06, 0x40, 0xa0, 0xe1,
|
0x14, 0xd0, 0x4d, 0xe2, 0x00, 0x60, 0xa0, 0xe1, 0x06, 0x40, 0xa0, 0xe1,
|
||||||
@ -479,8 +481,8 @@ static int chip_spi_init(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t *
|
|||||||
0x60, 0x00, 0x00, 0x0a, 0x07, 0x00, 0x53, 0xe3, 0x6f, 0x00, 0x00, 0x0a,
|
0x60, 0x00, 0x00, 0x0a, 0x07, 0x00, 0x53, 0xe3, 0x6f, 0x00, 0x00, 0x0a,
|
||||||
0x08, 0x00, 0x53, 0xe3, 0x7c, 0x00, 0x00, 0x1a, 0x0d, 0x90, 0xa0, 0xe1,
|
0x08, 0x00, 0x53, 0xe3, 0x7c, 0x00, 0x00, 0x1a, 0x0d, 0x90, 0xa0, 0xe1,
|
||||||
0x08, 0x60, 0x8d, 0xe2, 0xb0, 0x80, 0xcd, 0xe1, 0x02, 0x10, 0xa0, 0xe3,
|
0x08, 0x60, 0x8d, 0xe2, 0xb0, 0x80, 0xcd, 0xe1, 0x02, 0x10, 0xa0, 0xe3,
|
||||||
0x09, 0x00, 0xa0, 0xe1, 0xb0, 0xff, 0xff, 0xeb, 0x01, 0x10, 0xa0, 0xe3,
|
0x09, 0x00, 0xa0, 0xe1, 0xad, 0xff, 0xff, 0xeb, 0x01, 0x10, 0xa0, 0xe3,
|
||||||
0x06, 0x00, 0xa0, 0xe1, 0x73, 0xff, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5,
|
0x06, 0x00, 0xa0, 0xe1, 0x6d, 0xff, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5,
|
||||||
0x01, 0x00, 0x13, 0xe3, 0xf6, 0xff, 0xff, 0x1a, 0x04, 0x60, 0xa0, 0xe1,
|
0x01, 0x00, 0x13, 0xe3, 0xf6, 0xff, 0xff, 0x1a, 0x04, 0x60, 0xa0, 0xe1,
|
||||||
0x06, 0x40, 0xa0, 0xe1, 0x01, 0x30, 0xd4, 0xe4, 0x01, 0x00, 0x53, 0xe3,
|
0x06, 0x40, 0xa0, 0xe1, 0x01, 0x30, 0xd4, 0xe4, 0x01, 0x00, 0x53, 0xe3,
|
||||||
0xe0, 0xff, 0xff, 0x1a, 0x48, 0x38, 0x97, 0xe5, 0xb8, 0x21, 0x9f, 0xe5,
|
0xe0, 0xff, 0xff, 0x1a, 0x48, 0x38, 0x97, 0xe5, 0xb8, 0x21, 0x9f, 0xe5,
|
||||||
@ -502,22 +504,22 @@ static int chip_spi_init(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t *
|
|||||||
0x04, 0x60, 0xa0, 0xe1, 0xb0, 0x30, 0xc3, 0xe3, 0x80, 0x30, 0x83, 0xe3,
|
0x04, 0x60, 0xa0, 0xe1, 0xb0, 0x30, 0xc3, 0xe3, 0x80, 0x30, 0x83, 0xe3,
|
||||||
0x08, 0x30, 0x85, 0xe5, 0xa8, 0xff, 0xff, 0xea, 0x01, 0x90, 0xd6, 0xe5,
|
0x08, 0x30, 0x85, 0xe5, 0xa8, 0xff, 0xff, 0xea, 0x01, 0x90, 0xd6, 0xe5,
|
||||||
0x02, 0x00, 0x86, 0xe2, 0x09, 0x10, 0xa0, 0xe1, 0x01, 0x60, 0x89, 0xe2,
|
0x02, 0x00, 0x86, 0xe2, 0x09, 0x10, 0xa0, 0xe1, 0x01, 0x60, 0x89, 0xe2,
|
||||||
0x6c, 0xff, 0xff, 0xeb, 0x06, 0x60, 0x84, 0xe0, 0xa1, 0xff, 0xff, 0xea,
|
0x69, 0xff, 0xff, 0xeb, 0x06, 0x60, 0x84, 0xe0, 0xa1, 0xff, 0xff, 0xea,
|
||||||
0x05, 0x20, 0xd6, 0xe5, 0x06, 0x90, 0xd6, 0xe5, 0x01, 0x30, 0xd6, 0xe5,
|
0x05, 0x20, 0xd6, 0xe5, 0x06, 0x90, 0xd6, 0xe5, 0x01, 0x30, 0xd6, 0xe5,
|
||||||
0x02, 0x40, 0xd6, 0xe5, 0x07, 0xe0, 0xd6, 0xe5, 0x03, 0xc0, 0xd6, 0xe5,
|
0x02, 0x40, 0xd6, 0xe5, 0x07, 0xe0, 0xd6, 0xe5, 0x03, 0xc0, 0xd6, 0xe5,
|
||||||
0x08, 0x10, 0xd6, 0xe5, 0x04, 0x00, 0xd6, 0xe5, 0x09, 0x24, 0x82, 0xe1,
|
0x08, 0x10, 0xd6, 0xe5, 0x04, 0x00, 0xd6, 0xe5, 0x09, 0x24, 0x82, 0xe1,
|
||||||
0x04, 0x34, 0x83, 0xe1, 0x0e, 0x28, 0x82, 0xe1, 0x0c, 0x38, 0x83, 0xe1,
|
0x04, 0x34, 0x83, 0xe1, 0x0e, 0x28, 0x82, 0xe1, 0x0c, 0x38, 0x83, 0xe1,
|
||||||
0x01, 0x1c, 0x82, 0xe1, 0x00, 0x0c, 0x83, 0xe1, 0x5b, 0xff, 0xff, 0xeb,
|
0x01, 0x1c, 0x82, 0xe1, 0x00, 0x0c, 0x83, 0xe1, 0x58, 0xff, 0xff, 0xeb,
|
||||||
0x09, 0x60, 0x86, 0xe2, 0x90, 0xff, 0xff, 0xea, 0x05, 0x20, 0xd6, 0xe5,
|
0x09, 0x60, 0x86, 0xe2, 0x90, 0xff, 0xff, 0xea, 0x05, 0x20, 0xd6, 0xe5,
|
||||||
0x06, 0x90, 0xd6, 0xe5, 0x01, 0x30, 0xd6, 0xe5, 0x02, 0x40, 0xd6, 0xe5,
|
0x06, 0x90, 0xd6, 0xe5, 0x01, 0x30, 0xd6, 0xe5, 0x02, 0x40, 0xd6, 0xe5,
|
||||||
0x07, 0xe0, 0xd6, 0xe5, 0x03, 0xc0, 0xd6, 0xe5, 0x08, 0x10, 0xd6, 0xe5,
|
0x07, 0xe0, 0xd6, 0xe5, 0x03, 0xc0, 0xd6, 0xe5, 0x08, 0x10, 0xd6, 0xe5,
|
||||||
0x04, 0x00, 0xd6, 0xe5, 0x09, 0x24, 0x82, 0xe1, 0x04, 0x34, 0x83, 0xe1,
|
0x04, 0x00, 0xd6, 0xe5, 0x09, 0x24, 0x82, 0xe1, 0x04, 0x34, 0x83, 0xe1,
|
||||||
0x0e, 0x28, 0x82, 0xe1, 0x0c, 0x38, 0x83, 0xe1, 0x01, 0x1c, 0x82, 0xe1,
|
0x0e, 0x28, 0x82, 0xe1, 0x0c, 0x38, 0x83, 0xe1, 0x01, 0x1c, 0x82, 0xe1,
|
||||||
0x00, 0x0c, 0x83, 0xe1, 0x10, 0xff, 0xff, 0xeb, 0x09, 0x60, 0x86, 0xe2,
|
0x00, 0x0c, 0x83, 0xe1, 0x0a, 0xff, 0xff, 0xeb, 0x09, 0x60, 0x86, 0xe2,
|
||||||
0x7f, 0xff, 0xff, 0xea, 0x05, 0x30, 0xa0, 0xe3, 0x0d, 0x90, 0xa0, 0xe1,
|
0x7f, 0xff, 0xff, 0xea, 0x05, 0x30, 0xa0, 0xe3, 0x0d, 0x90, 0xa0, 0xe1,
|
||||||
0x08, 0x60, 0x8d, 0xe2, 0x00, 0x30, 0xcd, 0xe5, 0x01, 0x10, 0xa0, 0xe3,
|
0x08, 0x60, 0x8d, 0xe2, 0x00, 0x30, 0xcd, 0xe5, 0x01, 0x10, 0xa0, 0xe3,
|
||||||
0x09, 0x00, 0xa0, 0xe1, 0x41, 0xff, 0xff, 0xeb, 0x01, 0x10, 0xa0, 0xe3,
|
0x09, 0x00, 0xa0, 0xe1, 0x3e, 0xff, 0xff, 0xeb, 0x01, 0x10, 0xa0, 0xe3,
|
||||||
0x06, 0x00, 0xa0, 0xe1, 0x04, 0xff, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5,
|
0x06, 0x00, 0xa0, 0xe1, 0xfe, 0xfe, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5,
|
||||||
0x01, 0x00, 0x13, 0xe3, 0xf6, 0xff, 0xff, 0x1a, 0x04, 0x60, 0xa0, 0xe1,
|
0x01, 0x00, 0x13, 0xe3, 0xf6, 0xff, 0xff, 0x1a, 0x04, 0x60, 0xa0, 0xe1,
|
||||||
0x8f, 0xff, 0xff, 0xea, 0x14, 0xd0, 0x8d, 0xe2, 0xf0, 0x83, 0xbd, 0xe8,
|
0x8f, 0xff, 0xff, 0xea, 0x14, 0xd0, 0x8d, 0xe2, 0xf0, 0x83, 0xbd, 0xe8,
|
||||||
0x0f, 0xc0, 0xff, 0xff, 0x00, 0x50, 0xc0, 0x01, 0x00, 0x00, 0xc2, 0x01,
|
0x0f, 0xc0, 0xff, 0xff, 0x00, 0x50, 0xc0, 0x01, 0x00, 0x00, 0xc2, 0x01,
|
||||||
@ -540,6 +542,11 @@ static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int chip_extra(struct xfel_ctx_t * ctx, int argc, char * argv[])
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct chip_t f1c100s_f1c200s_f1c500s = {
|
struct chip_t f1c100s_f1c200s_f1c500s = {
|
||||||
.name = "F1C100S/F1C200S/F1C500S",
|
.name = "F1C100S/F1C200S/F1C500S",
|
||||||
.detect = chip_detect,
|
.detect = chip_detect,
|
||||||
@ -549,4 +556,5 @@ struct chip_t f1c100s_f1c200s_f1c500s = {
|
|||||||
.ddr = chip_ddr,
|
.ddr = chip_ddr,
|
||||||
.spi_init = chip_spi_init,
|
.spi_init = chip_spi_init,
|
||||||
.spi_run = chip_spi_run,
|
.spi_run = chip_spi_run,
|
||||||
|
.extra = chip_extra,
|
||||||
};
|
};
|
||||||
|
@ -1017,8 +1017,9 @@ static int chip_ddr(struct xfel_ctx_t * ctx, const char * type)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("xfel ddr h2 - Initial h2 ddr controller\r\n");
|
printf("usage:\r\n");
|
||||||
printf("xfel ddr h3 - Initial h3 ddr controller\r\n");
|
printf(" xfel ddr h2 - Initial h2 ddr controller\r\n");
|
||||||
|
printf(" xfel ddr h3 - Initial h3 ddr controller\r\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1029,47 +1030,49 @@ static int chip_spi_init(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t *
|
|||||||
0x04, 0xe0, 0x80, 0xe5, 0x00, 0xe0, 0x0f, 0xe1, 0x08, 0xe0, 0x80, 0xe5,
|
0x04, 0xe0, 0x80, 0xe5, 0x00, 0xe0, 0x0f, 0xe1, 0x08, 0xe0, 0x80, 0xe5,
|
||||||
0x10, 0xef, 0x11, 0xee, 0x0c, 0xe0, 0x80, 0xe5, 0x10, 0xef, 0x1c, 0xee,
|
0x10, 0xef, 0x11, 0xee, 0x0c, 0xe0, 0x80, 0xe5, 0x10, 0xef, 0x1c, 0xee,
|
||||||
0x10, 0xe0, 0x80, 0xe5, 0x10, 0xef, 0x11, 0xee, 0x14, 0xe0, 0x80, 0xe5,
|
0x10, 0xe0, 0x80, 0xe5, 0x10, 0xef, 0x11, 0xee, 0x14, 0xe0, 0x80, 0xe5,
|
||||||
0x09, 0x0a, 0xa0, 0xe3, 0x76, 0x00, 0x00, 0xeb, 0x40, 0x00, 0xa0, 0xe3,
|
0x09, 0x0a, 0xa0, 0xe3, 0x7c, 0x00, 0x00, 0xeb, 0x40, 0x00, 0xa0, 0xe3,
|
||||||
0x00, 0xd0, 0x90, 0xe5, 0x04, 0xe0, 0x90, 0xe5, 0x14, 0x10, 0x90, 0xe5,
|
0x00, 0xd0, 0x90, 0xe5, 0x04, 0xe0, 0x90, 0xe5, 0x14, 0x10, 0x90, 0xe5,
|
||||||
0x10, 0x1f, 0x01, 0xee, 0x10, 0x10, 0x90, 0xe5, 0x10, 0x1f, 0x0c, 0xee,
|
0x10, 0x1f, 0x01, 0xee, 0x10, 0x10, 0x90, 0xe5, 0x10, 0x1f, 0x0c, 0xee,
|
||||||
0x0c, 0x10, 0x90, 0xe5, 0x10, 0x1f, 0x01, 0xee, 0x08, 0x10, 0x90, 0xe5,
|
0x0c, 0x10, 0x90, 0xe5, 0x10, 0x1f, 0x01, 0xee, 0x08, 0x10, 0x90, 0xe5,
|
||||||
0x01, 0xf0, 0x29, 0xe1, 0x1e, 0xff, 0x2f, 0xe1, 0xf0, 0x40, 0x2d, 0xe9,
|
0x01, 0xf0, 0x29, 0xe1, 0x1e, 0xff, 0x2f, 0xe1, 0xf0, 0x40, 0x2d, 0xe9,
|
||||||
0x00, 0x50, 0x51, 0xe2, 0xf0, 0x80, 0xbd, 0x08, 0x02, 0xe9, 0xa0, 0xe3,
|
0x00, 0x50, 0x51, 0xe2, 0xf0, 0x80, 0xbd, 0x08, 0x02, 0x19, 0xa0, 0xe3,
|
||||||
0x82, 0x6c, 0xa0, 0xe3, 0xc6, 0xe1, 0x40, 0xe3, 0x83, 0x4c, 0xa0, 0xe3,
|
0x82, 0x6c, 0xa0, 0xe3, 0xc6, 0x11, 0x40, 0xe3, 0x83, 0x4c, 0xa0, 0xe3,
|
||||||
0xc6, 0x61, 0x40, 0xe3, 0x00, 0x70, 0xe0, 0xe3, 0xc6, 0x41, 0x40, 0xe3,
|
0xc6, 0x61, 0x40, 0xe3, 0x00, 0x70, 0xe0, 0xe3, 0xc6, 0x41, 0x40, 0xe3,
|
||||||
0x40, 0x00, 0x55, 0xe3, 0x00, 0x30, 0xa0, 0xe3, 0x07, 0x10, 0xa0, 0xe1,
|
0x40, 0x00, 0x55, 0xe3, 0x00, 0x30, 0xa0, 0xe3, 0x07, 0xc0, 0xa0, 0xe1,
|
||||||
0x05, 0x20, 0xa0, 0x31, 0x40, 0x20, 0xa0, 0x23, 0x30, 0x20, 0x8e, 0xe5,
|
0x05, 0x20, 0xa0, 0x31, 0x40, 0x20, 0xa0, 0x23, 0x30, 0x20, 0x81, 0xe5,
|
||||||
0x34, 0x20, 0x8e, 0xe5, 0x38, 0x20, 0x8e, 0xe5, 0x00, 0x10, 0xc6, 0xe5,
|
0x34, 0x20, 0x81, 0xe5, 0x38, 0x20, 0x81, 0xe5, 0x00, 0xc0, 0xc6, 0xe5,
|
||||||
0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0xca,
|
0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0xca,
|
||||||
0x08, 0x30, 0x9e, 0xe5, 0x02, 0x31, 0x83, 0xe3, 0x08, 0x30, 0x8e, 0xe5,
|
0x08, 0x30, 0x91, 0xe5, 0x02, 0x31, 0x83, 0xe3, 0x08, 0x30, 0x81, 0xe5,
|
||||||
0x1c, 0x30, 0x9e, 0xe5, 0x73, 0x30, 0xef, 0xe6, 0x03, 0x00, 0x52, 0xe1,
|
0x08, 0x30, 0x91, 0xe5, 0x00, 0x00, 0x53, 0xe3, 0xfc, 0xff, 0xff, 0xba,
|
||||||
0xfb, 0xff, 0xff, 0x8a, 0x00, 0x30, 0xa0, 0xe3, 0x00, 0xc0, 0xd4, 0xe5,
|
0x1c, 0x30, 0x91, 0xe5, 0x73, 0x30, 0xef, 0xe6, 0x03, 0x00, 0x52, 0xe1,
|
||||||
0x00, 0x00, 0x50, 0xe3, 0x00, 0x10, 0xa0, 0xe1, 0x01, 0x30, 0x83, 0xe2,
|
0xfb, 0xff, 0xff, 0x8a, 0x00, 0x30, 0xa0, 0xe3, 0x00, 0xe0, 0xd4, 0xe5,
|
||||||
0x7c, 0xc0, 0xef, 0xe6, 0x06, 0x00, 0x00, 0x0a, 0x03, 0x00, 0x52, 0xe1,
|
0x00, 0x00, 0x50, 0xe3, 0x00, 0xc0, 0xa0, 0xe1, 0x01, 0x30, 0x83, 0xe2,
|
||||||
0x01, 0xc0, 0xc1, 0xe4, 0x01, 0x00, 0xa0, 0xe1, 0xf5, 0xff, 0xff, 0xca,
|
0x7e, 0xe0, 0xef, 0xe6, 0x06, 0x00, 0x00, 0x0a, 0x03, 0x00, 0x52, 0xe1,
|
||||||
0x02, 0x50, 0x55, 0xe0, 0xdf, 0xff, 0xff, 0x1a, 0xf0, 0x80, 0xbd, 0xe8,
|
0x01, 0xe0, 0xcc, 0xe4, 0x0c, 0x00, 0xa0, 0xe1, 0xf5, 0xff, 0xff, 0xca,
|
||||||
0x03, 0x00, 0x52, 0xe1, 0x01, 0x10, 0x83, 0xe2, 0x02, 0x30, 0x83, 0xe2,
|
0x02, 0x50, 0x55, 0xe0, 0xdc, 0xff, 0xff, 0x1a, 0xf0, 0x80, 0xbd, 0xe8,
|
||||||
0xf8, 0xff, 0xff, 0xda, 0x01, 0x00, 0x52, 0xe1, 0x00, 0x10, 0xd4, 0xe5,
|
0x03, 0x00, 0x52, 0xe1, 0x01, 0xc0, 0x83, 0xe2, 0x02, 0x30, 0x83, 0xe2,
|
||||||
0xf5, 0xff, 0xff, 0xda, 0x03, 0x00, 0x52, 0xe1, 0x00, 0x10, 0xd4, 0xe5,
|
0xf8, 0xff, 0xff, 0xda, 0x0c, 0x00, 0x52, 0xe1, 0x00, 0xc0, 0xd4, 0xe5,
|
||||||
0x01, 0x10, 0x83, 0xe2, 0x02, 0x30, 0x83, 0xe2, 0xf7, 0xff, 0xff, 0xca,
|
0xf5, 0xff, 0xff, 0xda, 0x03, 0x00, 0x52, 0xe1, 0x00, 0xc0, 0xd4, 0xe5,
|
||||||
0x02, 0x50, 0x55, 0xe0, 0xd0, 0xff, 0xff, 0x1a, 0xf0, 0x80, 0xbd, 0xe8,
|
0x01, 0xc0, 0x83, 0xe2, 0x02, 0x30, 0x83, 0xe2, 0xf7, 0xff, 0xff, 0xca,
|
||||||
|
0x02, 0x50, 0x55, 0xe0, 0xcd, 0xff, 0xff, 0x1a, 0xf0, 0x80, 0xbd, 0xe8,
|
||||||
0xf0, 0x40, 0x2d, 0xe9, 0x00, 0x60, 0x51, 0xe2, 0xf0, 0x80, 0xbd, 0x08,
|
0xf0, 0x40, 0x2d, 0xe9, 0x00, 0x60, 0x51, 0xe2, 0xf0, 0x80, 0xbd, 0x08,
|
||||||
0x02, 0x19, 0xa0, 0xe3, 0x82, 0x5c, 0xa0, 0xe3, 0xc6, 0x11, 0x40, 0xe3,
|
0x02, 0x19, 0xa0, 0xe3, 0x82, 0x5c, 0xa0, 0xe3, 0xc6, 0x11, 0x40, 0xe3,
|
||||||
0x83, 0x4c, 0xa0, 0xe3, 0xc6, 0x51, 0x40, 0xe3, 0x00, 0x70, 0xe0, 0xe3,
|
0x83, 0x4c, 0xa0, 0xe3, 0xc6, 0x51, 0x40, 0xe3, 0x00, 0x70, 0xe0, 0xe3,
|
||||||
0xc6, 0x41, 0x40, 0xe3, 0x40, 0x00, 0x56, 0xe3, 0x06, 0x20, 0xa0, 0x31,
|
0xc6, 0x41, 0x40, 0xe3, 0x40, 0x00, 0x56, 0xe3, 0x06, 0x20, 0xa0, 0x31,
|
||||||
0x40, 0x20, 0xa0, 0x23, 0x30, 0x20, 0x81, 0xe5, 0x00, 0x00, 0x50, 0xe3,
|
0x40, 0x20, 0xa0, 0x23, 0x30, 0x20, 0x81, 0xe5, 0x00, 0x00, 0x50, 0xe3,
|
||||||
0x34, 0x20, 0x81, 0xe5, 0x38, 0x20, 0x81, 0xe5, 0x17, 0x00, 0x00, 0x0a,
|
0x34, 0x20, 0x81, 0xe5, 0x38, 0x20, 0x81, 0xe5, 0x1a, 0x00, 0x00, 0x0a,
|
||||||
0x00, 0xc0, 0xa0, 0xe1, 0x00, 0x30, 0xa0, 0xe3, 0x01, 0xe0, 0xdc, 0xe4,
|
0x00, 0xc0, 0xa0, 0xe1, 0x00, 0x30, 0xa0, 0xe3, 0x01, 0xe0, 0xdc, 0xe4,
|
||||||
0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1, 0x00, 0xe0, 0xc5, 0xe5,
|
0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1, 0x00, 0xe0, 0xc5, 0xe5,
|
||||||
0xfa, 0xff, 0xff, 0xca, 0x08, 0x30, 0x91, 0xe5, 0x02, 0x31, 0x83, 0xe3,
|
0xfa, 0xff, 0xff, 0xca, 0x08, 0x30, 0x91, 0xe5, 0x02, 0x31, 0x83, 0xe3,
|
||||||
0x08, 0x30, 0x81, 0xe5, 0x1c, 0x30, 0x91, 0xe5, 0x73, 0x30, 0xef, 0xe6,
|
0x08, 0x30, 0x81, 0xe5, 0x08, 0x30, 0x91, 0xe5, 0x00, 0x00, 0x53, 0xe3,
|
||||||
|
0xfc, 0xff, 0xff, 0xba, 0x1c, 0x30, 0x91, 0xe5, 0x73, 0x30, 0xef, 0xe6,
|
||||||
0x03, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0x8a, 0x00, 0x30, 0xa0, 0xe3,
|
0x03, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0x8a, 0x00, 0x30, 0xa0, 0xe3,
|
||||||
0x00, 0xc0, 0xd4, 0xe5, 0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1,
|
0x00, 0xc0, 0xd4, 0xe5, 0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1,
|
||||||
0xfb, 0xff, 0xff, 0xca, 0x00, 0x00, 0x50, 0xe3, 0x02, 0x00, 0x80, 0x10,
|
0xfb, 0xff, 0xff, 0xca, 0x00, 0x00, 0x50, 0xe3, 0x02, 0x00, 0x80, 0x10,
|
||||||
0x02, 0x60, 0x56, 0xe0, 0xe0, 0xff, 0xff, 0x1a, 0xf0, 0x80, 0xbd, 0xe8,
|
0x02, 0x60, 0x56, 0xe0, 0xdd, 0xff, 0xff, 0x1a, 0xf0, 0x80, 0xbd, 0xe8,
|
||||||
0x00, 0x30, 0xa0, 0xe1, 0x07, 0xc0, 0xa0, 0xe1, 0x00, 0xc0, 0xc5, 0xe5,
|
0x00, 0x30, 0xa0, 0xe1, 0x07, 0xc0, 0xa0, 0xe1, 0x00, 0xc0, 0xc5, 0xe5,
|
||||||
0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0xca,
|
0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0xca,
|
||||||
0xe7, 0xff, 0xff, 0xea, 0xf0, 0x43, 0x2d, 0xe9, 0x0f, 0x80, 0x0c, 0xe3,
|
0xe4, 0xff, 0xff, 0xea, 0xf0, 0x43, 0x2d, 0xe9, 0x0f, 0x80, 0x0c, 0xe3,
|
||||||
0xff, 0x8f, 0x4f, 0xe3, 0x02, 0x69, 0xa0, 0xe3, 0xc6, 0x61, 0x40, 0xe3,
|
0xff, 0x8f, 0x4f, 0xe3, 0x02, 0x69, 0xa0, 0xe3, 0xc6, 0x61, 0x40, 0xe3,
|
||||||
0x00, 0x40, 0xa0, 0xe3, 0xc2, 0x41, 0x40, 0xe3, 0x14, 0xd0, 0x4d, 0xe2,
|
0x00, 0x40, 0xa0, 0xe3, 0xc2, 0x41, 0x40, 0xe3, 0x14, 0xd0, 0x4d, 0xe2,
|
||||||
0x00, 0x70, 0xa0, 0xe1, 0x07, 0x50, 0xa0, 0xe1, 0x01, 0x30, 0xd5, 0xe4,
|
0x00, 0x70, 0xa0, 0xe1, 0x07, 0x50, 0xa0, 0xe1, 0x01, 0x30, 0xd5, 0xe4,
|
||||||
@ -1080,8 +1083,8 @@ static int chip_spi_init(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t *
|
|||||||
0x07, 0x00, 0x53, 0xe3, 0x7d, 0x00, 0x00, 0x0a, 0x08, 0x00, 0x53, 0xe3,
|
0x07, 0x00, 0x53, 0xe3, 0x7d, 0x00, 0x00, 0x0a, 0x08, 0x00, 0x53, 0xe3,
|
||||||
0x8a, 0x00, 0x00, 0x1a, 0xb0, 0x80, 0xcd, 0xe1, 0x0d, 0x90, 0xa0, 0xe1,
|
0x8a, 0x00, 0x00, 0x1a, 0xb0, 0x80, 0xcd, 0xe1, 0x0d, 0x90, 0xa0, 0xe1,
|
||||||
0x08, 0x70, 0x8d, 0xe2, 0x02, 0x10, 0xa0, 0xe3, 0x09, 0x00, 0xa0, 0xe1,
|
0x08, 0x70, 0x8d, 0xe2, 0x02, 0x10, 0xa0, 0xe3, 0x09, 0x00, 0xa0, 0xe1,
|
||||||
0xad, 0xff, 0xff, 0xeb, 0x01, 0x10, 0xa0, 0xe3, 0x07, 0x00, 0xa0, 0xe1,
|
0xaa, 0xff, 0xff, 0xeb, 0x01, 0x10, 0xa0, 0xe3, 0x07, 0x00, 0xa0, 0xe1,
|
||||||
0x70, 0xff, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5, 0x01, 0x00, 0x13, 0xe3,
|
0x6a, 0xff, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5, 0x01, 0x00, 0x13, 0xe3,
|
||||||
0xf6, 0xff, 0xff, 0x1a, 0x05, 0x70, 0xa0, 0xe1, 0x07, 0x50, 0xa0, 0xe1,
|
0xf6, 0xff, 0xff, 0x1a, 0x05, 0x70, 0xa0, 0xe1, 0x07, 0x50, 0xa0, 0xe1,
|
||||||
0x01, 0x30, 0xd5, 0xe4, 0x01, 0x00, 0x53, 0xe3, 0xe0, 0xff, 0xff, 0x1a,
|
0x01, 0x30, 0xd5, 0xe4, 0x01, 0x00, 0x53, 0xe3, 0xe0, 0xff, 0xff, 0x1a,
|
||||||
0x48, 0x38, 0x94, 0xe5, 0x01, 0x2a, 0xa0, 0xe3, 0x0f, 0x30, 0xc3, 0xe3,
|
0x48, 0x38, 0x94, 0xe5, 0x01, 0x2a, 0xa0, 0xe3, 0x0f, 0x30, 0xc3, 0xe3,
|
||||||
@ -1107,43 +1110,43 @@ static int chip_spi_init(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t *
|
|||||||
0x08, 0x30, 0x96, 0xe5, 0x05, 0x70, 0xa0, 0xe1, 0xb0, 0x30, 0xc3, 0xe3,
|
0x08, 0x30, 0x96, 0xe5, 0x05, 0x70, 0xa0, 0xe1, 0xb0, 0x30, 0xc3, 0xe3,
|
||||||
0x80, 0x30, 0x83, 0xe3, 0x08, 0x30, 0x86, 0xe5, 0x9a, 0xff, 0xff, 0xea,
|
0x80, 0x30, 0x83, 0xe3, 0x08, 0x30, 0x86, 0xe5, 0x9a, 0xff, 0xff, 0xea,
|
||||||
0x01, 0x90, 0xd7, 0xe5, 0x02, 0x00, 0x87, 0xe2, 0x09, 0x10, 0xa0, 0xe1,
|
0x01, 0x90, 0xd7, 0xe5, 0x02, 0x00, 0x87, 0xe2, 0x09, 0x10, 0xa0, 0xe1,
|
||||||
0x01, 0x70, 0x89, 0xe2, 0x07, 0x70, 0x85, 0xe0, 0x5a, 0xff, 0xff, 0xeb,
|
0x01, 0x70, 0x89, 0xe2, 0x07, 0x70, 0x85, 0xe0, 0x57, 0xff, 0xff, 0xeb,
|
||||||
0x93, 0xff, 0xff, 0xea, 0x06, 0x10, 0xd7, 0xe5, 0x09, 0x70, 0x87, 0xe2,
|
0x93, 0xff, 0xff, 0xea, 0x06, 0x10, 0xd7, 0xe5, 0x09, 0x70, 0x87, 0xe2,
|
||||||
0x07, 0x00, 0x57, 0xe5, 0x04, 0x20, 0x57, 0xe5, 0x08, 0x30, 0x57, 0xe5,
|
0x07, 0x00, 0x57, 0xe5, 0x04, 0x20, 0x57, 0xe5, 0x08, 0x30, 0x57, 0xe5,
|
||||||
0x02, 0xe0, 0x57, 0xe5, 0x06, 0xc0, 0x57, 0xe5, 0x01, 0x24, 0x82, 0xe1,
|
0x02, 0xe0, 0x57, 0xe5, 0x06, 0xc0, 0x57, 0xe5, 0x01, 0x24, 0x82, 0xe1,
|
||||||
0x00, 0x34, 0x83, 0xe1, 0x01, 0x10, 0x57, 0xe5, 0x05, 0x00, 0x57, 0xe5,
|
0x00, 0x34, 0x83, 0xe1, 0x01, 0x10, 0x57, 0xe5, 0x05, 0x00, 0x57, 0xe5,
|
||||||
0x0e, 0x28, 0x82, 0xe1, 0x0c, 0x38, 0x83, 0xe1, 0x01, 0x1c, 0x82, 0xe1,
|
0x0e, 0x28, 0x82, 0xe1, 0x0c, 0x38, 0x83, 0xe1, 0x01, 0x1c, 0x82, 0xe1,
|
||||||
0x00, 0x0c, 0x83, 0xe1, 0x49, 0xff, 0xff, 0xeb, 0x82, 0xff, 0xff, 0xea,
|
0x00, 0x0c, 0x83, 0xe1, 0x46, 0xff, 0xff, 0xeb, 0x82, 0xff, 0xff, 0xea,
|
||||||
0x06, 0x10, 0xd7, 0xe5, 0x09, 0x70, 0x87, 0xe2, 0x07, 0x00, 0x57, 0xe5,
|
0x06, 0x10, 0xd7, 0xe5, 0x09, 0x70, 0x87, 0xe2, 0x07, 0x00, 0x57, 0xe5,
|
||||||
0x04, 0x20, 0x57, 0xe5, 0x08, 0x30, 0x57, 0xe5, 0x02, 0xe0, 0x57, 0xe5,
|
0x04, 0x20, 0x57, 0xe5, 0x08, 0x30, 0x57, 0xe5, 0x02, 0xe0, 0x57, 0xe5,
|
||||||
0x06, 0xc0, 0x57, 0xe5, 0x01, 0x24, 0x82, 0xe1, 0x00, 0x34, 0x83, 0xe1,
|
0x06, 0xc0, 0x57, 0xe5, 0x01, 0x24, 0x82, 0xe1, 0x00, 0x34, 0x83, 0xe1,
|
||||||
0x01, 0x10, 0x57, 0xe5, 0x05, 0x00, 0x57, 0xe5, 0x0e, 0x28, 0x82, 0xe1,
|
0x01, 0x10, 0x57, 0xe5, 0x05, 0x00, 0x57, 0xe5, 0x0e, 0x28, 0x82, 0xe1,
|
||||||
0x0c, 0x38, 0x83, 0xe1, 0x01, 0x1c, 0x82, 0xe1, 0x00, 0x0c, 0x83, 0xe1,
|
0x0c, 0x38, 0x83, 0xe1, 0x01, 0x1c, 0x82, 0xe1, 0x00, 0x0c, 0x83, 0xe1,
|
||||||
0xfe, 0xfe, 0xff, 0xeb, 0x71, 0xff, 0xff, 0xea, 0x0d, 0x90, 0xa0, 0xe1,
|
0xf8, 0xfe, 0xff, 0xeb, 0x71, 0xff, 0xff, 0xea, 0x0d, 0x90, 0xa0, 0xe1,
|
||||||
0x08, 0x70, 0x8d, 0xe2, 0x05, 0x30, 0xa0, 0xe3, 0x00, 0x30, 0xcd, 0xe5,
|
0x08, 0x70, 0x8d, 0xe2, 0x05, 0x30, 0xa0, 0xe3, 0x00, 0x30, 0xcd, 0xe5,
|
||||||
0x01, 0x10, 0xa0, 0xe3, 0x09, 0x00, 0xa0, 0xe1, 0x30, 0xff, 0xff, 0xeb,
|
0x01, 0x10, 0xa0, 0xe3, 0x09, 0x00, 0xa0, 0xe1, 0x2d, 0xff, 0xff, 0xeb,
|
||||||
0x01, 0x10, 0xa0, 0xe3, 0x07, 0x00, 0xa0, 0xe1, 0xf3, 0xfe, 0xff, 0xeb,
|
0x01, 0x10, 0xa0, 0xe3, 0x07, 0x00, 0xa0, 0xe1, 0xed, 0xfe, 0xff, 0xeb,
|
||||||
0x08, 0x30, 0xdd, 0xe5, 0x01, 0x00, 0x13, 0xe3, 0xf6, 0xff, 0xff, 0x1a,
|
0x08, 0x30, 0xdd, 0xe5, 0x01, 0x00, 0x13, 0xe3, 0xf6, 0xff, 0xff, 0x1a,
|
||||||
0x05, 0x70, 0xa0, 0xe1, 0x81, 0xff, 0xff, 0xea, 0x14, 0xd0, 0x8d, 0xe2,
|
0x05, 0x70, 0xa0, 0xe1, 0x81, 0xff, 0xff, 0xea, 0x14, 0xd0, 0x8d, 0xe2,
|
||||||
0xf0, 0x83, 0xbd, 0xe8, 0x04, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
|
0xf0, 0x83, 0xbd, 0xe8, 0x04, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
|
||||||
0x03, 0x00, 0x00, 0x00, 0x47, 0x4e, 0x55, 0x00, 0x5e, 0xff, 0x86, 0x41,
|
0x03, 0x00, 0x00, 0x00, 0x47, 0x4e, 0x55, 0x00, 0x89, 0x4f, 0xb3, 0xca,
|
||||||
0x5f, 0x0c, 0x57, 0xc9, 0x77, 0xc7, 0x3f, 0xd6, 0xb6, 0xba, 0x19, 0x4e,
|
0xe0, 0xdc, 0x25, 0x96, 0xd3, 0xb0, 0xa9, 0xb1, 0x5f, 0x41, 0x72, 0x84,
|
||||||
0xf3, 0x48, 0xda, 0x8e, 0x2f, 0x6c, 0x69, 0x62, 0x2f, 0x6c, 0x64, 0x2d,
|
0x27, 0x2e, 0x3f, 0x4d, 0x2f, 0x6c, 0x69, 0x62, 0x2f, 0x6c, 0x64, 0x2d,
|
||||||
0x6c, 0x69, 0x6e, 0x75, 0x78, 0x2d, 0x61, 0x72, 0x6d, 0x68, 0x66, 0x2e,
|
0x6c, 0x69, 0x6e, 0x75, 0x78, 0x2d, 0x61, 0x72, 0x6d, 0x68, 0x66, 0x2e,
|
||||||
0x73, 0x6f, 0x2e, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x73, 0x6f, 0x2e, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0xf5, 0xfe, 0xff, 0x6f, 0x08, 0x85, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0xf5, 0xfe, 0xff, 0x6f, 0x20, 0x85, 0x00, 0x00,
|
||||||
0x05, 0x00, 0x00, 0x00, 0x04, 0x85, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
|
0x05, 0x00, 0x00, 0x00, 0x1c, 0x85, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
|
||||||
0xf4, 0x84, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
0x0c, 0x85, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
0x0b, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00,
|
0x0b, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
|
||||||
0xfb, 0xff, 0xff, 0x6f, 0x01, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
|
0xfb, 0xff, 0xff, 0x6f, 0x01, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x85, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x85, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||||
};
|
};
|
||||||
fel_write(ctx, 0x00008000, (void *)&payload[0], sizeof(payload));
|
fel_write(ctx, 0x00008000, (void *)&payload[0], sizeof(payload));
|
||||||
@ -1163,6 +1166,11 @@ static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int chip_extra(struct xfel_ctx_t * ctx, int argc, char * argv[])
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct chip_t h2_h3 = {
|
struct chip_t h2_h3 = {
|
||||||
.name = "H2/H3",
|
.name = "H2/H3",
|
||||||
.detect = chip_detect,
|
.detect = chip_detect,
|
||||||
@ -1172,4 +1180,5 @@ struct chip_t h2_h3 = {
|
|||||||
.ddr = chip_ddr,
|
.ddr = chip_ddr,
|
||||||
.spi_init = chip_spi_init,
|
.spi_init = chip_spi_init,
|
||||||
.spi_run = chip_spi_run,
|
.spi_run = chip_spi_run,
|
||||||
|
.extra = chip_extra,
|
||||||
};
|
};
|
||||||
|
@ -37,6 +37,11 @@ static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int chip_extra(struct xfel_ctx_t * ctx, int argc, char * argv[])
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct chip_t h5 = {
|
struct chip_t h5 = {
|
||||||
.name = "H5",
|
.name = "H5",
|
||||||
.detect = chip_detect,
|
.detect = chip_detect,
|
||||||
@ -46,4 +51,5 @@ struct chip_t h5 = {
|
|||||||
.ddr = chip_ddr,
|
.ddr = chip_ddr,
|
||||||
.spi_init = chip_spi_init,
|
.spi_init = chip_spi_init,
|
||||||
.spi_run = chip_spi_run,
|
.spi_run = chip_spi_run,
|
||||||
|
.extra = chip_extra,
|
||||||
};
|
};
|
||||||
|
@ -37,6 +37,11 @@ static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int chip_extra(struct xfel_ctx_t * ctx, int argc, char * argv[])
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct chip_t h6 = {
|
struct chip_t h6 = {
|
||||||
.name = "H6",
|
.name = "H6",
|
||||||
.detect = chip_detect,
|
.detect = chip_detect,
|
||||||
@ -46,4 +51,5 @@ struct chip_t h6 = {
|
|||||||
.ddr = chip_ddr,
|
.ddr = chip_ddr,
|
||||||
.spi_init = chip_spi_init,
|
.spi_init = chip_spi_init,
|
||||||
.spi_run = chip_spi_run,
|
.spi_run = chip_spi_run,
|
||||||
|
.extra = chip_extra,
|
||||||
};
|
};
|
||||||
|
2554
chips/h616.c
2554
chips/h616.c
File diff suppressed because it is too large
Load Diff
6203
chips/r128.c
Normal file
6203
chips/r128.c
Normal file
File diff suppressed because it is too large
Load Diff
32
chips/r328.c
32
chips/r328.c
@ -12,14 +12,32 @@ static int chip_reset(struct xfel_ctx_t * ctx)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint32_t payload_arm_read32(struct xfel_ctx_t * ctx, uint32_t addr)
|
||||||
|
{
|
||||||
|
uint32_t payload[] = {
|
||||||
|
cpu_to_le32(0xe59f000c), /* ldr r0, [pc, #12] */
|
||||||
|
cpu_to_le32(0xe28f100c), /* add r1, pc, #12 */
|
||||||
|
cpu_to_le32(0xe4902000), /* ldr r2, [r0], #0 */
|
||||||
|
cpu_to_le32(0xe4812000), /* str r2, [r1], #0 */
|
||||||
|
cpu_to_le32(0xe12fff1e), /* bx lr */
|
||||||
|
cpu_to_le32(addr),
|
||||||
|
};
|
||||||
|
uint32_t val;
|
||||||
|
|
||||||
|
fel_write(ctx, ctx->version.scratchpad, (void *)payload, sizeof(payload));
|
||||||
|
fel_exec(ctx, ctx->version.scratchpad);
|
||||||
|
fel_read(ctx, ctx->version.scratchpad + sizeof(payload), (void *)&val, sizeof(val));
|
||||||
|
return le32_to_cpu(val);
|
||||||
|
}
|
||||||
|
|
||||||
static int chip_sid(struct xfel_ctx_t * ctx, char * sid)
|
static int chip_sid(struct xfel_ctx_t * ctx, char * sid)
|
||||||
{
|
{
|
||||||
uint32_t id[4];
|
uint32_t id[4];
|
||||||
|
|
||||||
id[0] = R32(0x03006200 + 0x0);
|
id[0] = payload_arm_read32(ctx, 0x03006200 + 0x0);
|
||||||
id[1] = R32(0x03006200 + 0x4);
|
id[1] = payload_arm_read32(ctx, 0x03006200 + 0x4);
|
||||||
id[2] = R32(0x03006200 + 0x8);
|
id[2] = payload_arm_read32(ctx, 0x03006200 + 0x8);
|
||||||
id[3] = R32(0x03006200 + 0xc);
|
id[3] = payload_arm_read32(ctx, 0x03006200 + 0xc);
|
||||||
sprintf(sid, "%08x%08x%08x%08x", id[0], id[1], id[2], id[3]);
|
sprintf(sid, "%08x%08x%08x%08x", id[0], id[1], id[2], id[3]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -44,6 +62,11 @@ static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int chip_extra(struct xfel_ctx_t * ctx, int argc, char * argv[])
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct chip_t r328 = {
|
struct chip_t r328 = {
|
||||||
.name = "R328",
|
.name = "R328",
|
||||||
.detect = chip_detect,
|
.detect = chip_detect,
|
||||||
@ -53,4 +76,5 @@ struct chip_t r328 = {
|
|||||||
.ddr = chip_ddr,
|
.ddr = chip_ddr,
|
||||||
.spi_init = chip_spi_init,
|
.spi_init = chip_spi_init,
|
||||||
.spi_run = chip_spi_run,
|
.spi_run = chip_spi_run,
|
||||||
|
.extra = chip_extra,
|
||||||
};
|
};
|
||||||
|
@ -37,6 +37,11 @@ static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int chip_extra(struct xfel_ctx_t * ctx, int argc, char * argv[])
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct chip_t r329 = {
|
struct chip_t r329 = {
|
||||||
.name = "R329",
|
.name = "R329",
|
||||||
.detect = chip_detect,
|
.detect = chip_detect,
|
||||||
@ -46,4 +51,5 @@ struct chip_t r329 = {
|
|||||||
.ddr = chip_ddr,
|
.ddr = chip_ddr,
|
||||||
.spi_init = chip_spi_init,
|
.spi_init = chip_spi_init,
|
||||||
.spi_run = chip_spi_run,
|
.spi_run = chip_spi_run,
|
||||||
|
.extra = chip_extra,
|
||||||
};
|
};
|
||||||
|
2309
chips/r528.c
2309
chips/r528.c
File diff suppressed because it is too large
Load Diff
4610
chips/r528_t113.c
Normal file
4610
chips/r528_t113.c
Normal file
File diff suppressed because it is too large
Load Diff
55
chips/r818.c
Normal file
55
chips/r818.c
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#include <fel.h>
|
||||||
|
|
||||||
|
static int chip_detect(struct xfel_ctx_t * ctx, uint32_t id)
|
||||||
|
{
|
||||||
|
if(id == 0x00185500)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chip_reset(struct xfel_ctx_t * ctx)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chip_sid(struct xfel_ctx_t * ctx, char * sid)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chip_jtag(struct xfel_ctx_t * ctx)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chip_ddr(struct xfel_ctx_t * ctx, const char * type)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chip_spi_init(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t * swaplen, uint32_t * cmdlen)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chip_extra(struct xfel_ctx_t * ctx, int argc, char * argv[])
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct chip_t r818 = {
|
||||||
|
.name = "R818",
|
||||||
|
.detect = chip_detect,
|
||||||
|
.reset = chip_reset,
|
||||||
|
.sid = chip_sid,
|
||||||
|
.jtag = chip_jtag,
|
||||||
|
.ddr = chip_ddr,
|
||||||
|
.spi_init = chip_spi_init,
|
||||||
|
.spi_run = chip_spi_run,
|
||||||
|
.extra = chip_extra,
|
||||||
|
};
|
55
chips/t536.c
Normal file
55
chips/t536.c
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#include <fel.h>
|
||||||
|
|
||||||
|
static int chip_detect(struct xfel_ctx_t * ctx, uint32_t id)
|
||||||
|
{
|
||||||
|
if(id == 0x00191200)
|
||||||
|
return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chip_reset(struct xfel_ctx_t * ctx)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chip_sid(struct xfel_ctx_t * ctx, char * sid)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chip_jtag(struct xfel_ctx_t * ctx)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chip_ddr(struct xfel_ctx_t * ctx, const char * type)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chip_spi_init(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t * swaplen, uint32_t * cmdlen)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int chip_extra(struct xfel_ctx_t * ctx, int argc, char * argv[])
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct chip_t t536 = {
|
||||||
|
.name = "T536/MR536",
|
||||||
|
.detect = chip_detect,
|
||||||
|
.reset = chip_reset,
|
||||||
|
.sid = chip_sid,
|
||||||
|
.jtag = chip_jtag,
|
||||||
|
.ddr = chip_ddr,
|
||||||
|
.spi_init = chip_spi_init,
|
||||||
|
.spi_run = chip_spi_run,
|
||||||
|
.extra = chip_extra,
|
||||||
|
};
|
202
chips/v3s_s3.c
202
chips/v3s_s3.c
@ -7,52 +7,62 @@ static int chip_detect(struct xfel_ctx_t * ctx, uint32_t id)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint32_t payload_read32(struct xfel_ctx_t * ctx, uint32_t addr)
|
||||||
|
{
|
||||||
|
static const uint8_t payload[] = {
|
||||||
|
0x00, 0x00, 0xa0, 0xe3, 0x17, 0x0f, 0x08, 0xee, 0x15, 0x0f, 0x07, 0xee,
|
||||||
|
0xd5, 0x0f, 0x07, 0xee, 0x9a, 0x0f, 0x07, 0xee, 0x95, 0x0f, 0x07, 0xee,
|
||||||
|
0xff, 0xff, 0xff, 0xea, 0x0c, 0x00, 0x9f, 0xe5, 0x0c, 0x10, 0x8f, 0xe2,
|
||||||
|
0x00, 0x20, 0x90, 0xe5, 0x00, 0x20, 0x81, 0xe5, 0x1e, 0xff, 0x2f, 0xe1,
|
||||||
|
};
|
||||||
|
uint32_t adr = cpu_to_le32(addr);
|
||||||
|
uint32_t val;
|
||||||
|
|
||||||
|
fel_write(ctx, ctx->version.scratchpad, (void *)payload, sizeof(payload));
|
||||||
|
fel_write(ctx, ctx->version.scratchpad + sizeof(payload), (void *)&adr, sizeof(adr));
|
||||||
|
fel_exec(ctx, ctx->version.scratchpad);
|
||||||
|
fel_read(ctx, ctx->version.scratchpad + sizeof(payload) + sizeof(adr), (void *)&val, sizeof(val));
|
||||||
|
return le32_to_cpu(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void payload_write32(struct xfel_ctx_t * ctx, uint32_t addr, uint32_t val)
|
||||||
|
{
|
||||||
|
static const uint8_t payload[] = {
|
||||||
|
0x00, 0x00, 0xa0, 0xe3, 0x17, 0x0f, 0x08, 0xee, 0x15, 0x0f, 0x07, 0xee,
|
||||||
|
0xd5, 0x0f, 0x07, 0xee, 0x9a, 0x0f, 0x07, 0xee, 0x95, 0x0f, 0x07, 0xee,
|
||||||
|
0xff, 0xff, 0xff, 0xea, 0x08, 0x00, 0x9f, 0xe5, 0x08, 0x10, 0x9f, 0xe5,
|
||||||
|
0x00, 0x10, 0x80, 0xe5, 0x1e, 0xff, 0x2f, 0xe1,
|
||||||
|
};
|
||||||
|
uint32_t params[2] = {
|
||||||
|
cpu_to_le32(addr),
|
||||||
|
cpu_to_le32(val),
|
||||||
|
};
|
||||||
|
|
||||||
|
fel_write(ctx, ctx->version.scratchpad, (void *)payload, sizeof(payload));
|
||||||
|
fel_write(ctx, ctx->version.scratchpad + sizeof(payload), (void *)params, sizeof(params));
|
||||||
|
fel_exec(ctx, ctx->version.scratchpad);
|
||||||
|
}
|
||||||
|
|
||||||
static int chip_reset(struct xfel_ctx_t * ctx)
|
static int chip_reset(struct xfel_ctx_t * ctx)
|
||||||
{
|
{
|
||||||
uint32_t val;
|
uint32_t val;
|
||||||
|
|
||||||
val = R32(0x01c20ca0 + 0x18);
|
val = payload_read32(ctx, 0x01c20ca0 + 0x18);
|
||||||
val &= ~(0xf << 4);
|
val &= ~(0xf << 4);
|
||||||
val |= (1 << 4) | (0x1 << 0);
|
val |= (1 << 4) | (0x1 << 0);
|
||||||
W32(0x01c20ca0 + 0x18, val);
|
payload_write32(ctx, 0x01c20ca0 + 0x18, val);
|
||||||
W32(0x01c20ca0 + 0x10, (0xa57 << 1) | (1 << 0));
|
payload_write32(ctx, 0x01c20ca0 + 0x10, (0xa57 << 1) | (1 << 0));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t fel_read32_fixed(struct xfel_ctx_t * ctx, uint32_t addr)
|
|
||||||
{
|
|
||||||
uint32_t payload[] = {
|
|
||||||
cpu_to_le32(0xe59f0020), /* ldr r0, [pc, #32] ; ldr r0,[read_addr] */
|
|
||||||
cpu_to_le32(0xe28f1024), /* add r1, pc, #36 ; adr r1, read_data */
|
|
||||||
cpu_to_le32(0xe59f201c), /* ldr r2, [pc, #28] ; ldr r2,[read_count] */
|
|
||||||
cpu_to_le32(0xe3520000 + 208), /* cmp r2, #208 */
|
|
||||||
cpu_to_le32(0xc3a02000 + 208), /* movgt r2, #208 */
|
|
||||||
/* read_loop: */
|
|
||||||
cpu_to_le32(0xe2522001), /* subs r2, r2, #1 ; r2 -= 1 */
|
|
||||||
cpu_to_le32(0x412fff1e), /* bxmi lr ; return if (r2 < 0) */
|
|
||||||
cpu_to_le32(0xe4903004), /* ldr r3, [r0], #4 ; load and post-inc */
|
|
||||||
cpu_to_le32(0xe4813004), /* str r3, [r1], #4 ; store and post-inc */
|
|
||||||
cpu_to_le32(0xeafffffa), /* b read_loop */
|
|
||||||
cpu_to_le32(addr), /* read_addr */
|
|
||||||
cpu_to_le32(0x1) /* read_count */
|
|
||||||
/* read_data values go here */
|
|
||||||
};
|
|
||||||
uint32_t val;
|
|
||||||
|
|
||||||
fel_write(ctx, ctx->version.scratchpad, (void *)payload, sizeof(payload));
|
|
||||||
fel_exec(ctx, ctx->version.scratchpad);
|
|
||||||
fel_read(ctx, ctx->version.scratchpad + sizeof(payload), (void *)&val, sizeof(val));
|
|
||||||
return le32_to_cpu(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int chip_sid(struct xfel_ctx_t * ctx, char * sid)
|
static int chip_sid(struct xfel_ctx_t * ctx, char * sid)
|
||||||
{
|
{
|
||||||
uint32_t id[4];
|
uint32_t id[4];
|
||||||
|
|
||||||
id[0] = fel_read32_fixed(ctx, 0x01c23800 + 0x0);
|
id[0] = payload_read32(ctx, 0x01c23800 + 0x0);
|
||||||
id[1] = fel_read32_fixed(ctx, 0x01c23800 + 0x4);
|
id[1] = payload_read32(ctx, 0x01c23800 + 0x4);
|
||||||
id[2] = fel_read32_fixed(ctx, 0x01c23800 + 0x8);
|
id[2] = payload_read32(ctx, 0x01c23800 + 0x8);
|
||||||
id[3] = fel_read32_fixed(ctx, 0x01c23800 + 0xc);
|
id[3] = payload_read32(ctx, 0x01c23800 + 0xc);
|
||||||
sprintf(sid, "%08x%08x%08x%08x", id[0], id[1], id[2], id[3]);
|
sprintf(sid, "%08x%08x%08x%08x", id[0], id[1], id[2], id[3]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -967,8 +977,9 @@ static int chip_ddr(struct xfel_ctx_t * ctx, const char * type)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("xfel ddr v3s - Initial v3s ddr controller\r\n");
|
printf("usage:\r\n");
|
||||||
printf("xfel ddr s3 - Initial s3 ddr controller\r\n");
|
printf(" xfel ddr v3s - Initial v3s ddr controller\r\n");
|
||||||
|
printf(" xfel ddr s3 - Initial s3 ddr controller\r\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -981,47 +992,49 @@ static int chip_spi_init(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t *
|
|||||||
0x04, 0xe0, 0x80, 0xe5, 0x00, 0xe0, 0x0f, 0xe1, 0x08, 0xe0, 0x80, 0xe5,
|
0x04, 0xe0, 0x80, 0xe5, 0x00, 0xe0, 0x0f, 0xe1, 0x08, 0xe0, 0x80, 0xe5,
|
||||||
0x10, 0xef, 0x11, 0xee, 0x0c, 0xe0, 0x80, 0xe5, 0x10, 0xef, 0x1c, 0xee,
|
0x10, 0xef, 0x11, 0xee, 0x0c, 0xe0, 0x80, 0xe5, 0x10, 0xef, 0x1c, 0xee,
|
||||||
0x10, 0xe0, 0x80, 0xe5, 0x10, 0xef, 0x11, 0xee, 0x14, 0xe0, 0x80, 0xe5,
|
0x10, 0xe0, 0x80, 0xe5, 0x10, 0xef, 0x11, 0xee, 0x14, 0xe0, 0x80, 0xe5,
|
||||||
0x09, 0x0a, 0xa0, 0xe3, 0x76, 0x00, 0x00, 0xeb, 0x40, 0x00, 0xa0, 0xe3,
|
0x09, 0x0a, 0xa0, 0xe3, 0x7c, 0x00, 0x00, 0xeb, 0x40, 0x00, 0xa0, 0xe3,
|
||||||
0x00, 0xd0, 0x90, 0xe5, 0x04, 0xe0, 0x90, 0xe5, 0x14, 0x10, 0x90, 0xe5,
|
0x00, 0xd0, 0x90, 0xe5, 0x04, 0xe0, 0x90, 0xe5, 0x14, 0x10, 0x90, 0xe5,
|
||||||
0x10, 0x1f, 0x01, 0xee, 0x10, 0x10, 0x90, 0xe5, 0x10, 0x1f, 0x0c, 0xee,
|
0x10, 0x1f, 0x01, 0xee, 0x10, 0x10, 0x90, 0xe5, 0x10, 0x1f, 0x0c, 0xee,
|
||||||
0x0c, 0x10, 0x90, 0xe5, 0x10, 0x1f, 0x01, 0xee, 0x08, 0x10, 0x90, 0xe5,
|
0x0c, 0x10, 0x90, 0xe5, 0x10, 0x1f, 0x01, 0xee, 0x08, 0x10, 0x90, 0xe5,
|
||||||
0x01, 0xf0, 0x29, 0xe1, 0x1e, 0xff, 0x2f, 0xe1, 0xf0, 0x40, 0x2d, 0xe9,
|
0x01, 0xf0, 0x29, 0xe1, 0x1e, 0xff, 0x2f, 0xe1, 0xf0, 0x40, 0x2d, 0xe9,
|
||||||
0x00, 0x50, 0x51, 0xe2, 0xf0, 0x80, 0xbd, 0x08, 0x02, 0xe9, 0xa0, 0xe3,
|
0x00, 0x50, 0x51, 0xe2, 0xf0, 0x80, 0xbd, 0x08, 0x02, 0x19, 0xa0, 0xe3,
|
||||||
0x82, 0x6c, 0xa0, 0xe3, 0xc6, 0xe1, 0x40, 0xe3, 0x83, 0x4c, 0xa0, 0xe3,
|
0x82, 0x6c, 0xa0, 0xe3, 0xc6, 0x11, 0x40, 0xe3, 0x83, 0x4c, 0xa0, 0xe3,
|
||||||
0xc6, 0x61, 0x40, 0xe3, 0x00, 0x70, 0xe0, 0xe3, 0xc6, 0x41, 0x40, 0xe3,
|
0xc6, 0x61, 0x40, 0xe3, 0x00, 0x70, 0xe0, 0xe3, 0xc6, 0x41, 0x40, 0xe3,
|
||||||
0x40, 0x00, 0x55, 0xe3, 0x00, 0x30, 0xa0, 0xe3, 0x07, 0x10, 0xa0, 0xe1,
|
0x40, 0x00, 0x55, 0xe3, 0x00, 0x30, 0xa0, 0xe3, 0x07, 0xc0, 0xa0, 0xe1,
|
||||||
0x05, 0x20, 0xa0, 0x31, 0x40, 0x20, 0xa0, 0x23, 0x30, 0x20, 0x8e, 0xe5,
|
0x05, 0x20, 0xa0, 0x31, 0x40, 0x20, 0xa0, 0x23, 0x30, 0x20, 0x81, 0xe5,
|
||||||
0x34, 0x20, 0x8e, 0xe5, 0x38, 0x20, 0x8e, 0xe5, 0x00, 0x10, 0xc6, 0xe5,
|
0x34, 0x20, 0x81, 0xe5, 0x38, 0x20, 0x81, 0xe5, 0x00, 0xc0, 0xc6, 0xe5,
|
||||||
0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0xca,
|
0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0xca,
|
||||||
0x08, 0x30, 0x9e, 0xe5, 0x02, 0x31, 0x83, 0xe3, 0x08, 0x30, 0x8e, 0xe5,
|
0x08, 0x30, 0x91, 0xe5, 0x02, 0x31, 0x83, 0xe3, 0x08, 0x30, 0x81, 0xe5,
|
||||||
0x1c, 0x30, 0x9e, 0xe5, 0x73, 0x30, 0xef, 0xe6, 0x03, 0x00, 0x52, 0xe1,
|
0x08, 0x30, 0x91, 0xe5, 0x00, 0x00, 0x53, 0xe3, 0xfc, 0xff, 0xff, 0xba,
|
||||||
0xfb, 0xff, 0xff, 0x8a, 0x00, 0x30, 0xa0, 0xe3, 0x00, 0xc0, 0xd4, 0xe5,
|
0x1c, 0x30, 0x91, 0xe5, 0x73, 0x30, 0xef, 0xe6, 0x03, 0x00, 0x52, 0xe1,
|
||||||
0x00, 0x00, 0x50, 0xe3, 0x00, 0x10, 0xa0, 0xe1, 0x01, 0x30, 0x83, 0xe2,
|
0xfb, 0xff, 0xff, 0x8a, 0x00, 0x30, 0xa0, 0xe3, 0x00, 0xe0, 0xd4, 0xe5,
|
||||||
0x7c, 0xc0, 0xef, 0xe6, 0x06, 0x00, 0x00, 0x0a, 0x03, 0x00, 0x52, 0xe1,
|
0x00, 0x00, 0x50, 0xe3, 0x00, 0xc0, 0xa0, 0xe1, 0x01, 0x30, 0x83, 0xe2,
|
||||||
0x01, 0xc0, 0xc1, 0xe4, 0x01, 0x00, 0xa0, 0xe1, 0xf5, 0xff, 0xff, 0xca,
|
0x7e, 0xe0, 0xef, 0xe6, 0x06, 0x00, 0x00, 0x0a, 0x03, 0x00, 0x52, 0xe1,
|
||||||
0x02, 0x50, 0x55, 0xe0, 0xdf, 0xff, 0xff, 0x1a, 0xf0, 0x80, 0xbd, 0xe8,
|
0x01, 0xe0, 0xcc, 0xe4, 0x0c, 0x00, 0xa0, 0xe1, 0xf5, 0xff, 0xff, 0xca,
|
||||||
0x03, 0x00, 0x52, 0xe1, 0x01, 0x10, 0x83, 0xe2, 0x02, 0x30, 0x83, 0xe2,
|
0x02, 0x50, 0x55, 0xe0, 0xdc, 0xff, 0xff, 0x1a, 0xf0, 0x80, 0xbd, 0xe8,
|
||||||
0xf8, 0xff, 0xff, 0xda, 0x01, 0x00, 0x52, 0xe1, 0x00, 0x10, 0xd4, 0xe5,
|
0x03, 0x00, 0x52, 0xe1, 0x01, 0xc0, 0x83, 0xe2, 0x02, 0x30, 0x83, 0xe2,
|
||||||
0xf5, 0xff, 0xff, 0xda, 0x03, 0x00, 0x52, 0xe1, 0x00, 0x10, 0xd4, 0xe5,
|
0xf8, 0xff, 0xff, 0xda, 0x0c, 0x00, 0x52, 0xe1, 0x00, 0xc0, 0xd4, 0xe5,
|
||||||
0x01, 0x10, 0x83, 0xe2, 0x02, 0x30, 0x83, 0xe2, 0xf7, 0xff, 0xff, 0xca,
|
0xf5, 0xff, 0xff, 0xda, 0x03, 0x00, 0x52, 0xe1, 0x00, 0xc0, 0xd4, 0xe5,
|
||||||
0x02, 0x50, 0x55, 0xe0, 0xd0, 0xff, 0xff, 0x1a, 0xf0, 0x80, 0xbd, 0xe8,
|
0x01, 0xc0, 0x83, 0xe2, 0x02, 0x30, 0x83, 0xe2, 0xf7, 0xff, 0xff, 0xca,
|
||||||
|
0x02, 0x50, 0x55, 0xe0, 0xcd, 0xff, 0xff, 0x1a, 0xf0, 0x80, 0xbd, 0xe8,
|
||||||
0xf0, 0x40, 0x2d, 0xe9, 0x00, 0x60, 0x51, 0xe2, 0xf0, 0x80, 0xbd, 0x08,
|
0xf0, 0x40, 0x2d, 0xe9, 0x00, 0x60, 0x51, 0xe2, 0xf0, 0x80, 0xbd, 0x08,
|
||||||
0x02, 0x19, 0xa0, 0xe3, 0x82, 0x5c, 0xa0, 0xe3, 0xc6, 0x11, 0x40, 0xe3,
|
0x02, 0x19, 0xa0, 0xe3, 0x82, 0x5c, 0xa0, 0xe3, 0xc6, 0x11, 0x40, 0xe3,
|
||||||
0x83, 0x4c, 0xa0, 0xe3, 0xc6, 0x51, 0x40, 0xe3, 0x00, 0x70, 0xe0, 0xe3,
|
0x83, 0x4c, 0xa0, 0xe3, 0xc6, 0x51, 0x40, 0xe3, 0x00, 0x70, 0xe0, 0xe3,
|
||||||
0xc6, 0x41, 0x40, 0xe3, 0x40, 0x00, 0x56, 0xe3, 0x06, 0x20, 0xa0, 0x31,
|
0xc6, 0x41, 0x40, 0xe3, 0x40, 0x00, 0x56, 0xe3, 0x06, 0x20, 0xa0, 0x31,
|
||||||
0x40, 0x20, 0xa0, 0x23, 0x30, 0x20, 0x81, 0xe5, 0x00, 0x00, 0x50, 0xe3,
|
0x40, 0x20, 0xa0, 0x23, 0x30, 0x20, 0x81, 0xe5, 0x00, 0x00, 0x50, 0xe3,
|
||||||
0x34, 0x20, 0x81, 0xe5, 0x38, 0x20, 0x81, 0xe5, 0x17, 0x00, 0x00, 0x0a,
|
0x34, 0x20, 0x81, 0xe5, 0x38, 0x20, 0x81, 0xe5, 0x1a, 0x00, 0x00, 0x0a,
|
||||||
0x00, 0xc0, 0xa0, 0xe1, 0x00, 0x30, 0xa0, 0xe3, 0x01, 0xe0, 0xdc, 0xe4,
|
0x00, 0xc0, 0xa0, 0xe1, 0x00, 0x30, 0xa0, 0xe3, 0x01, 0xe0, 0xdc, 0xe4,
|
||||||
0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1, 0x00, 0xe0, 0xc5, 0xe5,
|
0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1, 0x00, 0xe0, 0xc5, 0xe5,
|
||||||
0xfa, 0xff, 0xff, 0xca, 0x08, 0x30, 0x91, 0xe5, 0x02, 0x31, 0x83, 0xe3,
|
0xfa, 0xff, 0xff, 0xca, 0x08, 0x30, 0x91, 0xe5, 0x02, 0x31, 0x83, 0xe3,
|
||||||
0x08, 0x30, 0x81, 0xe5, 0x1c, 0x30, 0x91, 0xe5, 0x73, 0x30, 0xef, 0xe6,
|
0x08, 0x30, 0x81, 0xe5, 0x08, 0x30, 0x91, 0xe5, 0x00, 0x00, 0x53, 0xe3,
|
||||||
|
0xfc, 0xff, 0xff, 0xba, 0x1c, 0x30, 0x91, 0xe5, 0x73, 0x30, 0xef, 0xe6,
|
||||||
0x03, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0x8a, 0x00, 0x30, 0xa0, 0xe3,
|
0x03, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0x8a, 0x00, 0x30, 0xa0, 0xe3,
|
||||||
0x00, 0xc0, 0xd4, 0xe5, 0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1,
|
0x00, 0xc0, 0xd4, 0xe5, 0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1,
|
||||||
0xfb, 0xff, 0xff, 0xca, 0x00, 0x00, 0x50, 0xe3, 0x02, 0x00, 0x80, 0x10,
|
0xfb, 0xff, 0xff, 0xca, 0x00, 0x00, 0x50, 0xe3, 0x02, 0x00, 0x80, 0x10,
|
||||||
0x02, 0x60, 0x56, 0xe0, 0xe0, 0xff, 0xff, 0x1a, 0xf0, 0x80, 0xbd, 0xe8,
|
0x02, 0x60, 0x56, 0xe0, 0xdd, 0xff, 0xff, 0x1a, 0xf0, 0x80, 0xbd, 0xe8,
|
||||||
0x00, 0x30, 0xa0, 0xe1, 0x07, 0xc0, 0xa0, 0xe1, 0x00, 0xc0, 0xc5, 0xe5,
|
0x00, 0x30, 0xa0, 0xe1, 0x07, 0xc0, 0xa0, 0xe1, 0x00, 0xc0, 0xc5, 0xe5,
|
||||||
0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0xca,
|
0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0xca,
|
||||||
0xe7, 0xff, 0xff, 0xea, 0xf0, 0x43, 0x2d, 0xe9, 0x0f, 0x80, 0x0c, 0xe3,
|
0xe4, 0xff, 0xff, 0xea, 0xf0, 0x43, 0x2d, 0xe9, 0x0f, 0x80, 0x0c, 0xe3,
|
||||||
0xff, 0x8f, 0x4f, 0xe3, 0x02, 0x69, 0xa0, 0xe3, 0xc6, 0x61, 0x40, 0xe3,
|
0xff, 0x8f, 0x4f, 0xe3, 0x02, 0x69, 0xa0, 0xe3, 0xc6, 0x61, 0x40, 0xe3,
|
||||||
0x00, 0x40, 0xa0, 0xe3, 0xc2, 0x41, 0x40, 0xe3, 0x14, 0xd0, 0x4d, 0xe2,
|
0x00, 0x40, 0xa0, 0xe3, 0xc2, 0x41, 0x40, 0xe3, 0x14, 0xd0, 0x4d, 0xe2,
|
||||||
0x00, 0x70, 0xa0, 0xe1, 0x07, 0x50, 0xa0, 0xe1, 0x01, 0x30, 0xd5, 0xe4,
|
0x00, 0x70, 0xa0, 0xe1, 0x07, 0x50, 0xa0, 0xe1, 0x01, 0x30, 0xd5, 0xe4,
|
||||||
@ -1032,8 +1045,8 @@ static int chip_spi_init(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t *
|
|||||||
0x07, 0x00, 0x53, 0xe3, 0x7d, 0x00, 0x00, 0x0a, 0x08, 0x00, 0x53, 0xe3,
|
0x07, 0x00, 0x53, 0xe3, 0x7d, 0x00, 0x00, 0x0a, 0x08, 0x00, 0x53, 0xe3,
|
||||||
0x8a, 0x00, 0x00, 0x1a, 0xb0, 0x80, 0xcd, 0xe1, 0x0d, 0x90, 0xa0, 0xe1,
|
0x8a, 0x00, 0x00, 0x1a, 0xb0, 0x80, 0xcd, 0xe1, 0x0d, 0x90, 0xa0, 0xe1,
|
||||||
0x08, 0x70, 0x8d, 0xe2, 0x02, 0x10, 0xa0, 0xe3, 0x09, 0x00, 0xa0, 0xe1,
|
0x08, 0x70, 0x8d, 0xe2, 0x02, 0x10, 0xa0, 0xe3, 0x09, 0x00, 0xa0, 0xe1,
|
||||||
0xad, 0xff, 0xff, 0xeb, 0x01, 0x10, 0xa0, 0xe3, 0x07, 0x00, 0xa0, 0xe1,
|
0xaa, 0xff, 0xff, 0xeb, 0x01, 0x10, 0xa0, 0xe3, 0x07, 0x00, 0xa0, 0xe1,
|
||||||
0x70, 0xff, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5, 0x01, 0x00, 0x13, 0xe3,
|
0x6a, 0xff, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5, 0x01, 0x00, 0x13, 0xe3,
|
||||||
0xf6, 0xff, 0xff, 0x1a, 0x05, 0x70, 0xa0, 0xe1, 0x07, 0x50, 0xa0, 0xe1,
|
0xf6, 0xff, 0xff, 0x1a, 0x05, 0x70, 0xa0, 0xe1, 0x07, 0x50, 0xa0, 0xe1,
|
||||||
0x01, 0x30, 0xd5, 0xe4, 0x01, 0x00, 0x53, 0xe3, 0xe0, 0xff, 0xff, 0x1a,
|
0x01, 0x30, 0xd5, 0xe4, 0x01, 0x00, 0x53, 0xe3, 0xe0, 0xff, 0xff, 0x1a,
|
||||||
0x48, 0x38, 0x94, 0xe5, 0x01, 0x2a, 0xa0, 0xe3, 0x0f, 0x30, 0xc3, 0xe3,
|
0x48, 0x38, 0x94, 0xe5, 0x01, 0x2a, 0xa0, 0xe3, 0x0f, 0x30, 0xc3, 0xe3,
|
||||||
@ -1059,43 +1072,43 @@ static int chip_spi_init(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t *
|
|||||||
0x08, 0x30, 0x96, 0xe5, 0x05, 0x70, 0xa0, 0xe1, 0xb0, 0x30, 0xc3, 0xe3,
|
0x08, 0x30, 0x96, 0xe5, 0x05, 0x70, 0xa0, 0xe1, 0xb0, 0x30, 0xc3, 0xe3,
|
||||||
0x80, 0x30, 0x83, 0xe3, 0x08, 0x30, 0x86, 0xe5, 0x9a, 0xff, 0xff, 0xea,
|
0x80, 0x30, 0x83, 0xe3, 0x08, 0x30, 0x86, 0xe5, 0x9a, 0xff, 0xff, 0xea,
|
||||||
0x01, 0x90, 0xd7, 0xe5, 0x02, 0x00, 0x87, 0xe2, 0x09, 0x10, 0xa0, 0xe1,
|
0x01, 0x90, 0xd7, 0xe5, 0x02, 0x00, 0x87, 0xe2, 0x09, 0x10, 0xa0, 0xe1,
|
||||||
0x01, 0x70, 0x89, 0xe2, 0x07, 0x70, 0x85, 0xe0, 0x5a, 0xff, 0xff, 0xeb,
|
0x01, 0x70, 0x89, 0xe2, 0x07, 0x70, 0x85, 0xe0, 0x57, 0xff, 0xff, 0xeb,
|
||||||
0x93, 0xff, 0xff, 0xea, 0x06, 0x10, 0xd7, 0xe5, 0x09, 0x70, 0x87, 0xe2,
|
0x93, 0xff, 0xff, 0xea, 0x06, 0x10, 0xd7, 0xe5, 0x09, 0x70, 0x87, 0xe2,
|
||||||
0x07, 0x00, 0x57, 0xe5, 0x04, 0x20, 0x57, 0xe5, 0x08, 0x30, 0x57, 0xe5,
|
0x07, 0x00, 0x57, 0xe5, 0x04, 0x20, 0x57, 0xe5, 0x08, 0x30, 0x57, 0xe5,
|
||||||
0x02, 0xe0, 0x57, 0xe5, 0x06, 0xc0, 0x57, 0xe5, 0x01, 0x24, 0x82, 0xe1,
|
0x02, 0xe0, 0x57, 0xe5, 0x06, 0xc0, 0x57, 0xe5, 0x01, 0x24, 0x82, 0xe1,
|
||||||
0x00, 0x34, 0x83, 0xe1, 0x01, 0x10, 0x57, 0xe5, 0x05, 0x00, 0x57, 0xe5,
|
0x00, 0x34, 0x83, 0xe1, 0x01, 0x10, 0x57, 0xe5, 0x05, 0x00, 0x57, 0xe5,
|
||||||
0x0e, 0x28, 0x82, 0xe1, 0x0c, 0x38, 0x83, 0xe1, 0x01, 0x1c, 0x82, 0xe1,
|
0x0e, 0x28, 0x82, 0xe1, 0x0c, 0x38, 0x83, 0xe1, 0x01, 0x1c, 0x82, 0xe1,
|
||||||
0x00, 0x0c, 0x83, 0xe1, 0x49, 0xff, 0xff, 0xeb, 0x82, 0xff, 0xff, 0xea,
|
0x00, 0x0c, 0x83, 0xe1, 0x46, 0xff, 0xff, 0xeb, 0x82, 0xff, 0xff, 0xea,
|
||||||
0x06, 0x10, 0xd7, 0xe5, 0x09, 0x70, 0x87, 0xe2, 0x07, 0x00, 0x57, 0xe5,
|
0x06, 0x10, 0xd7, 0xe5, 0x09, 0x70, 0x87, 0xe2, 0x07, 0x00, 0x57, 0xe5,
|
||||||
0x04, 0x20, 0x57, 0xe5, 0x08, 0x30, 0x57, 0xe5, 0x02, 0xe0, 0x57, 0xe5,
|
0x04, 0x20, 0x57, 0xe5, 0x08, 0x30, 0x57, 0xe5, 0x02, 0xe0, 0x57, 0xe5,
|
||||||
0x06, 0xc0, 0x57, 0xe5, 0x01, 0x24, 0x82, 0xe1, 0x00, 0x34, 0x83, 0xe1,
|
0x06, 0xc0, 0x57, 0xe5, 0x01, 0x24, 0x82, 0xe1, 0x00, 0x34, 0x83, 0xe1,
|
||||||
0x01, 0x10, 0x57, 0xe5, 0x05, 0x00, 0x57, 0xe5, 0x0e, 0x28, 0x82, 0xe1,
|
0x01, 0x10, 0x57, 0xe5, 0x05, 0x00, 0x57, 0xe5, 0x0e, 0x28, 0x82, 0xe1,
|
||||||
0x0c, 0x38, 0x83, 0xe1, 0x01, 0x1c, 0x82, 0xe1, 0x00, 0x0c, 0x83, 0xe1,
|
0x0c, 0x38, 0x83, 0xe1, 0x01, 0x1c, 0x82, 0xe1, 0x00, 0x0c, 0x83, 0xe1,
|
||||||
0xfe, 0xfe, 0xff, 0xeb, 0x71, 0xff, 0xff, 0xea, 0x0d, 0x90, 0xa0, 0xe1,
|
0xf8, 0xfe, 0xff, 0xeb, 0x71, 0xff, 0xff, 0xea, 0x0d, 0x90, 0xa0, 0xe1,
|
||||||
0x08, 0x70, 0x8d, 0xe2, 0x05, 0x30, 0xa0, 0xe3, 0x00, 0x30, 0xcd, 0xe5,
|
0x08, 0x70, 0x8d, 0xe2, 0x05, 0x30, 0xa0, 0xe3, 0x00, 0x30, 0xcd, 0xe5,
|
||||||
0x01, 0x10, 0xa0, 0xe3, 0x09, 0x00, 0xa0, 0xe1, 0x30, 0xff, 0xff, 0xeb,
|
0x01, 0x10, 0xa0, 0xe3, 0x09, 0x00, 0xa0, 0xe1, 0x2d, 0xff, 0xff, 0xeb,
|
||||||
0x01, 0x10, 0xa0, 0xe3, 0x07, 0x00, 0xa0, 0xe1, 0xf3, 0xfe, 0xff, 0xeb,
|
0x01, 0x10, 0xa0, 0xe3, 0x07, 0x00, 0xa0, 0xe1, 0xed, 0xfe, 0xff, 0xeb,
|
||||||
0x08, 0x30, 0xdd, 0xe5, 0x01, 0x00, 0x13, 0xe3, 0xf6, 0xff, 0xff, 0x1a,
|
0x08, 0x30, 0xdd, 0xe5, 0x01, 0x00, 0x13, 0xe3, 0xf6, 0xff, 0xff, 0x1a,
|
||||||
0x05, 0x70, 0xa0, 0xe1, 0x81, 0xff, 0xff, 0xea, 0x14, 0xd0, 0x8d, 0xe2,
|
0x05, 0x70, 0xa0, 0xe1, 0x81, 0xff, 0xff, 0xea, 0x14, 0xd0, 0x8d, 0xe2,
|
||||||
0xf0, 0x83, 0xbd, 0xe8, 0x04, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
|
0xf0, 0x83, 0xbd, 0xe8, 0x04, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
|
||||||
0x03, 0x00, 0x00, 0x00, 0x47, 0x4e, 0x55, 0x00, 0xa5, 0x20, 0xc7, 0xeb,
|
0x03, 0x00, 0x00, 0x00, 0x47, 0x4e, 0x55, 0x00, 0x1d, 0x30, 0x49, 0x7e,
|
||||||
0xa1, 0x10, 0x58, 0x97, 0xad, 0xa8, 0xd2, 0x63, 0x9e, 0xe3, 0x9c, 0x98,
|
0xc1, 0xa7, 0xed, 0x9e, 0x86, 0x26, 0xb6, 0x2d, 0x72, 0x23, 0xfe, 0x65,
|
||||||
0x21, 0x5c, 0x23, 0x45, 0x2f, 0x6c, 0x69, 0x62, 0x2f, 0x6c, 0x64, 0x2d,
|
0x09, 0x25, 0x9d, 0xb7, 0x2f, 0x6c, 0x69, 0x62, 0x2f, 0x6c, 0x64, 0x2d,
|
||||||
0x6c, 0x69, 0x6e, 0x75, 0x78, 0x2d, 0x61, 0x72, 0x6d, 0x68, 0x66, 0x2e,
|
0x6c, 0x69, 0x6e, 0x75, 0x78, 0x2d, 0x61, 0x72, 0x6d, 0x68, 0x66, 0x2e,
|
||||||
0x73, 0x6f, 0x2e, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x73, 0x6f, 0x2e, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0xf5, 0xfe, 0xff, 0x6f, 0x20, 0x85, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0xf5, 0xfe, 0xff, 0x6f, 0x38, 0x85, 0x00, 0x00,
|
||||||
0x05, 0x00, 0x00, 0x00, 0x1c, 0x85, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
|
0x05, 0x00, 0x00, 0x00, 0x34, 0x85, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
|
||||||
0x0c, 0x85, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
0x24, 0x85, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
0x0b, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00,
|
0x0b, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
|
||||||
0xfb, 0xff, 0xff, 0x6f, 0x01, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
|
0xfb, 0xff, 0xff, 0x6f, 0x01, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x85, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x85, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||||
};
|
};
|
||||||
fel_write(ctx, 0x00008000, (void *)&payload[0], sizeof(payload));
|
fel_write(ctx, 0x00008000, (void *)&payload[0], sizeof(payload));
|
||||||
@ -1115,6 +1128,52 @@ static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct sid_section_t {
|
||||||
|
char * name;
|
||||||
|
uint32_t offset;
|
||||||
|
uint32_t size_bits;
|
||||||
|
} sids[] = {
|
||||||
|
{ "chipid", 0x0000, 128 },
|
||||||
|
{ "unknown", 0x0010, 1920 },
|
||||||
|
};
|
||||||
|
|
||||||
|
static int chip_extra(struct xfel_ctx_t * ctx, int argc, char * argv[])
|
||||||
|
{
|
||||||
|
if(argc > 0)
|
||||||
|
{
|
||||||
|
if(!strcmp(argv[0], "efuse"))
|
||||||
|
{
|
||||||
|
argc -= 1;
|
||||||
|
argv += 1;
|
||||||
|
if(argc > 0)
|
||||||
|
{
|
||||||
|
if(!strcmp(argv[0], "dump") && (argc == 1))
|
||||||
|
{
|
||||||
|
uint32_t buffer[2048 / 4];
|
||||||
|
for(int n = 0; n < ARRAY_SIZE(sids); n++)
|
||||||
|
{
|
||||||
|
uint32_t count = sids[n].size_bits / 32;
|
||||||
|
for(int i = 0; i < count; i++)
|
||||||
|
buffer[i] = payload_read32(ctx, 0x01c23800 + sids[n].offset + i * 4);
|
||||||
|
printf("%s:(0x%04x %d-bits)", sids[n].name, sids[n].offset, sids[n].size_bits);
|
||||||
|
for(int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
if(i >= 0 && ((i % 8) == 0))
|
||||||
|
printf("\r\n%-4s", "");
|
||||||
|
printf("%08x ", buffer[i]);
|
||||||
|
}
|
||||||
|
printf("\r\n");
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("usage:\r\n");
|
||||||
|
printf(" xfel extra efuse dump - Dump all of the efuse information\r\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct chip_t v3s_s3 = {
|
struct chip_t v3s_s3 = {
|
||||||
.name = "V3S/S3",
|
.name = "V3S/S3",
|
||||||
.detect = chip_detect,
|
.detect = chip_detect,
|
||||||
@ -1124,4 +1183,5 @@ struct chip_t v3s_s3 = {
|
|||||||
.ddr = chip_ddr,
|
.ddr = chip_ddr,
|
||||||
.spi_init = chip_spi_init,
|
.spi_init = chip_spi_init,
|
||||||
.spi_run = chip_spi_run,
|
.spi_run = chip_spi_run,
|
||||||
|
.extra = chip_extra,
|
||||||
};
|
};
|
||||||
|
@ -37,6 +37,11 @@ static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int chip_extra(struct xfel_ctx_t * ctx, int argc, char * argv[])
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct chip_t v536 = {
|
struct chip_t v536 = {
|
||||||
.name = "V536",
|
.name = "V536",
|
||||||
.detect = chip_detect,
|
.detect = chip_detect,
|
||||||
@ -46,4 +51,5 @@ struct chip_t v536 = {
|
|||||||
.ddr = chip_ddr,
|
.ddr = chip_ddr,
|
||||||
.spi_init = chip_spi_init,
|
.spi_init = chip_spi_init,
|
||||||
.spi_run = chip_spi_run,
|
.spi_run = chip_spi_run,
|
||||||
|
.extra = chip_extra,
|
||||||
};
|
};
|
||||||
|
1742
chips/v821.c
Normal file
1742
chips/v821.c
Normal file
File diff suppressed because it is too large
Load Diff
179
chips/v831.c
179
chips/v831.c
@ -7,15 +7,51 @@ static int chip_detect(struct xfel_ctx_t * ctx, uint32_t id)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint32_t payload_read32(struct xfel_ctx_t * ctx, uint32_t addr)
|
||||||
|
{
|
||||||
|
static const uint8_t payload[] = {
|
||||||
|
0x00, 0x00, 0xa0, 0xe3, 0x17, 0x0f, 0x08, 0xee, 0x15, 0x0f, 0x07, 0xee,
|
||||||
|
0xd5, 0x0f, 0x07, 0xee, 0x9a, 0x0f, 0x07, 0xee, 0x95, 0x0f, 0x07, 0xee,
|
||||||
|
0xff, 0xff, 0xff, 0xea, 0x0c, 0x00, 0x9f, 0xe5, 0x0c, 0x10, 0x8f, 0xe2,
|
||||||
|
0x00, 0x20, 0x90, 0xe5, 0x00, 0x20, 0x81, 0xe5, 0x1e, 0xff, 0x2f, 0xe1,
|
||||||
|
};
|
||||||
|
uint32_t adr = cpu_to_le32(addr);
|
||||||
|
uint32_t val;
|
||||||
|
|
||||||
|
fel_write(ctx, ctx->version.scratchpad, (void *)payload, sizeof(payload));
|
||||||
|
fel_write(ctx, ctx->version.scratchpad + sizeof(payload), (void *)&adr, sizeof(adr));
|
||||||
|
fel_exec(ctx, ctx->version.scratchpad);
|
||||||
|
fel_read(ctx, ctx->version.scratchpad + sizeof(payload) + sizeof(adr), (void *)&val, sizeof(val));
|
||||||
|
return le32_to_cpu(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void payload_write32(struct xfel_ctx_t * ctx, uint32_t addr, uint32_t val)
|
||||||
|
{
|
||||||
|
static const uint8_t payload[] = {
|
||||||
|
0x00, 0x00, 0xa0, 0xe3, 0x17, 0x0f, 0x08, 0xee, 0x15, 0x0f, 0x07, 0xee,
|
||||||
|
0xd5, 0x0f, 0x07, 0xee, 0x9a, 0x0f, 0x07, 0xee, 0x95, 0x0f, 0x07, 0xee,
|
||||||
|
0xff, 0xff, 0xff, 0xea, 0x08, 0x00, 0x9f, 0xe5, 0x08, 0x10, 0x9f, 0xe5,
|
||||||
|
0x00, 0x10, 0x80, 0xe5, 0x1e, 0xff, 0x2f, 0xe1,
|
||||||
|
};
|
||||||
|
uint32_t params[2] = {
|
||||||
|
cpu_to_le32(addr),
|
||||||
|
cpu_to_le32(val),
|
||||||
|
};
|
||||||
|
|
||||||
|
fel_write(ctx, ctx->version.scratchpad, (void *)payload, sizeof(payload));
|
||||||
|
fel_write(ctx, ctx->version.scratchpad + sizeof(payload), (void *)params, sizeof(params));
|
||||||
|
fel_exec(ctx, ctx->version.scratchpad);
|
||||||
|
}
|
||||||
|
|
||||||
static int chip_reset(struct xfel_ctx_t * ctx)
|
static int chip_reset(struct xfel_ctx_t * ctx)
|
||||||
{
|
{
|
||||||
uint32_t val;
|
uint32_t val;
|
||||||
|
|
||||||
val = R32(0x030090a0 + 0x18);
|
val = payload_read32(ctx, 0x030090a0 + 0x18);
|
||||||
val &= ~(0xf << 4);
|
val &= ~(0xf << 4);
|
||||||
val |= (1 << 4) | (0x1 << 0);
|
val |= (1 << 4) | (0x1 << 0);
|
||||||
W32(0x030090a0 + 0x18, val);
|
payload_write32(ctx, 0x030090a0 + 0x18, val);
|
||||||
W32(0x030090a0 + 0x10, (0xa57 << 1) | (1 << 0));
|
payload_write32(ctx, 0x030090a0 + 0x10, (0xa57 << 1) | (1 << 0));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,10 +59,10 @@ static int chip_sid(struct xfel_ctx_t * ctx, char * sid)
|
|||||||
{
|
{
|
||||||
uint32_t id[4];
|
uint32_t id[4];
|
||||||
|
|
||||||
id[0] = R32(0x03006200 + 0x0);
|
id[0] = payload_read32(ctx, 0x03006200 + 0x0);
|
||||||
id[1] = R32(0x03006200 + 0x4);
|
id[1] = payload_read32(ctx, 0x03006200 + 0x4);
|
||||||
id[2] = R32(0x03006200 + 0x8);
|
id[2] = payload_read32(ctx, 0x03006200 + 0x8);
|
||||||
id[3] = R32(0x03006200 + 0xc);
|
id[3] = payload_read32(ctx, 0x03006200 + 0xc);
|
||||||
sprintf(sid, "%08x%08x%08x%08x", id[0], id[1], id[2], id[3]);
|
sprintf(sid, "%08x%08x%08x%08x", id[0], id[1], id[2], id[3]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -34,6 +70,8 @@ static int chip_sid(struct xfel_ctx_t * ctx, char * sid)
|
|||||||
static int chip_jtag(struct xfel_ctx_t * ctx)
|
static int chip_jtag(struct xfel_ctx_t * ctx)
|
||||||
{
|
{
|
||||||
static const uint8_t payload[] = {
|
static const uint8_t payload[] = {
|
||||||
|
0x00, 0x00, 0xa0, 0xe3, 0x17, 0x0f, 0x08, 0xee, 0x15, 0x0f, 0x07, 0xee,
|
||||||
|
0xd5, 0x0f, 0x07, 0xee, 0x9a, 0x0f, 0x07, 0xee, 0x95, 0x0f, 0x07, 0xee,
|
||||||
0xff, 0xff, 0xff, 0xea, 0x58, 0x00, 0x9f, 0xe5, 0x00, 0xd0, 0x80, 0xe5,
|
0xff, 0xff, 0xff, 0xea, 0x58, 0x00, 0x9f, 0xe5, 0x00, 0xd0, 0x80, 0xe5,
|
||||||
0x04, 0xe0, 0x80, 0xe5, 0x00, 0xe0, 0x0f, 0xe1, 0x08, 0xe0, 0x80, 0xe5,
|
0x04, 0xe0, 0x80, 0xe5, 0x00, 0xe0, 0x0f, 0xe1, 0x08, 0xe0, 0x80, 0xe5,
|
||||||
0x10, 0xef, 0x11, 0xee, 0x0c, 0xe0, 0x80, 0xe5, 0x10, 0xef, 0x1c, 0xee,
|
0x10, 0xef, 0x11, 0xee, 0x0c, 0xe0, 0x80, 0xe5, 0x10, 0xef, 0x1c, 0xee,
|
||||||
@ -50,16 +88,16 @@ static int chip_jtag(struct xfel_ctx_t * ctx)
|
|||||||
0xb4, 0x20, 0x83, 0xe5, 0xb4, 0x20, 0x93, 0xe5, 0x0f, 0x26, 0xc2, 0xe3,
|
0xb4, 0x20, 0x83, 0xe5, 0xb4, 0x20, 0x93, 0xe5, 0x0f, 0x26, 0xc2, 0xe3,
|
||||||
0x03, 0x26, 0x82, 0xe3, 0xb4, 0x20, 0x83, 0xe5, 0x1e, 0xff, 0x2f, 0xe1,
|
0x03, 0x26, 0x82, 0xe3, 0xb4, 0x20, 0x83, 0xe5, 0x1e, 0xff, 0x2f, 0xe1,
|
||||||
0x04, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
0x04, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||||
0x47, 0x4e, 0x55, 0x00, 0x90, 0xef, 0xd5, 0xd4, 0xf9, 0x31, 0x90, 0x65,
|
0x47, 0x4e, 0x55, 0x00, 0x09, 0xd0, 0xba, 0x36, 0x1c, 0xcc, 0x6b, 0x64,
|
||||||
0x03, 0xd6, 0xb2, 0x35, 0x09, 0xe0, 0x16, 0x82, 0x15, 0xe2, 0xb6, 0xcc,
|
0xc9, 0x91, 0x95, 0xfd, 0x5a, 0xd8, 0x85, 0x3e, 0xe9, 0x1d, 0x1f, 0x00,
|
||||||
0x2f, 0x6c, 0x69, 0x62, 0x2f, 0x6c, 0x64, 0x2d, 0x6c, 0x69, 0x6e, 0x75,
|
0x2f, 0x6c, 0x69, 0x62, 0x2f, 0x6c, 0x64, 0x2d, 0x6c, 0x69, 0x6e, 0x75,
|
||||||
0x78, 0x2d, 0x61, 0x72, 0x6d, 0x68, 0x66, 0x2e, 0x73, 0x6f, 0x2e, 0x33,
|
0x78, 0x2d, 0x61, 0x72, 0x6d, 0x68, 0x66, 0x2e, 0x73, 0x6f, 0x2e, 0x33,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0xf5, 0xfe, 0xff, 0x6f, 0x08, 0x21, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00,
|
0xf5, 0xfe, 0xff, 0x6f, 0x20, 0x21, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00,
|
||||||
0x04, 0x21, 0x02, 0x00, 0x06, 0x00, 0x00, 0x00, 0xf4, 0x20, 0x02, 0x00,
|
0x1c, 0x21, 0x02, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0c, 0x21, 0x02, 0x00,
|
||||||
0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00,
|
0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00,
|
||||||
0x10, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x10, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x1e, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0xfb, 0xff, 0xff, 0x6f,
|
0x1e, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0xfb, 0xff, 0xff, 0x6f,
|
||||||
@ -67,7 +105,7 @@ static int chip_jtag(struct xfel_ctx_t * ctx)
|
|||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x20, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x38, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00
|
0x00, 0x00, 0x00, 0x00
|
||||||
};
|
};
|
||||||
fel_write(ctx, 0x00022000, (void *)&payload[0], sizeof(payload));
|
fel_write(ctx, 0x00022000, (void *)&payload[0], sizeof(payload));
|
||||||
@ -1199,51 +1237,55 @@ static int chip_ddr(struct xfel_ctx_t * ctx, const char * type)
|
|||||||
static int chip_spi_init(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t * swaplen, uint32_t * cmdlen)
|
static int chip_spi_init(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t * swaplen, uint32_t * cmdlen)
|
||||||
{
|
{
|
||||||
static const uint8_t payload[] = {
|
static const uint8_t payload[] = {
|
||||||
|
0x00, 0x00, 0xa0, 0xe3, 0x17, 0x0f, 0x08, 0xee, 0x15, 0x0f, 0x07, 0xee,
|
||||||
|
0xd5, 0x0f, 0x07, 0xee, 0x9a, 0x0f, 0x07, 0xee, 0x95, 0x0f, 0x07, 0xee,
|
||||||
0xff, 0xff, 0xff, 0xea, 0x5c, 0x00, 0x9f, 0xe5, 0x00, 0xd0, 0x80, 0xe5,
|
0xff, 0xff, 0xff, 0xea, 0x5c, 0x00, 0x9f, 0xe5, 0x00, 0xd0, 0x80, 0xe5,
|
||||||
0x04, 0xe0, 0x80, 0xe5, 0x00, 0xe0, 0x0f, 0xe1, 0x08, 0xe0, 0x80, 0xe5,
|
0x04, 0xe0, 0x80, 0xe5, 0x00, 0xe0, 0x0f, 0xe1, 0x08, 0xe0, 0x80, 0xe5,
|
||||||
0x10, 0xef, 0x11, 0xee, 0x0c, 0xe0, 0x80, 0xe5, 0x10, 0xef, 0x1c, 0xee,
|
0x10, 0xef, 0x11, 0xee, 0x0c, 0xe0, 0x80, 0xe5, 0x10, 0xef, 0x1c, 0xee,
|
||||||
0x10, 0xe0, 0x80, 0xe5, 0x10, 0xef, 0x11, 0xee, 0x14, 0xe0, 0x80, 0xe5,
|
0x10, 0xe0, 0x80, 0xe5, 0x10, 0xef, 0x11, 0xee, 0x14, 0xe0, 0x80, 0xe5,
|
||||||
0x23, 0x0a, 0xa0, 0xe3, 0x77, 0x00, 0x00, 0xeb, 0x28, 0x00, 0x9f, 0xe5,
|
0x23, 0x0a, 0xa0, 0xe3, 0x7d, 0x00, 0x00, 0xeb, 0x28, 0x00, 0x9f, 0xe5,
|
||||||
0x00, 0xd0, 0x90, 0xe5, 0x04, 0xe0, 0x90, 0xe5, 0x14, 0x10, 0x90, 0xe5,
|
0x00, 0xd0, 0x90, 0xe5, 0x04, 0xe0, 0x90, 0xe5, 0x14, 0x10, 0x90, 0xe5,
|
||||||
0x10, 0x1f, 0x01, 0xee, 0x10, 0x10, 0x90, 0xe5, 0x10, 0x1f, 0x0c, 0xee,
|
0x10, 0x1f, 0x01, 0xee, 0x10, 0x10, 0x90, 0xe5, 0x10, 0x1f, 0x0c, 0xee,
|
||||||
0x0c, 0x10, 0x90, 0xe5, 0x10, 0x1f, 0x01, 0xee, 0x08, 0x10, 0x90, 0xe5,
|
0x0c, 0x10, 0x90, 0xe5, 0x10, 0x1f, 0x01, 0xee, 0x08, 0x10, 0x90, 0xe5,
|
||||||
0x01, 0xf0, 0x29, 0xe1, 0x1e, 0xff, 0x2f, 0xe1, 0xf8, 0x7f, 0x03, 0x00,
|
0x01, 0xf0, 0x29, 0xe1, 0x1e, 0xff, 0x2f, 0xe1, 0xf8, 0x7f, 0x03, 0x00,
|
||||||
0xf0, 0x40, 0x2d, 0xe9, 0x00, 0x50, 0x51, 0xe2, 0xf0, 0x80, 0xbd, 0x08,
|
0xf0, 0x40, 0x2d, 0xe9, 0x00, 0x50, 0x51, 0xe2, 0xf0, 0x80, 0xbd, 0x08,
|
||||||
0x00, 0xe0, 0xa0, 0xe3, 0x02, 0x6c, 0xa0, 0xe3, 0x01, 0xe5, 0x40, 0xe3,
|
0x00, 0x10, 0xa0, 0xe3, 0x02, 0x6c, 0xa0, 0xe3, 0x01, 0x15, 0x40, 0xe3,
|
||||||
0x03, 0x4c, 0xa0, 0xe3, 0x01, 0x65, 0x40, 0xe3, 0x00, 0x70, 0xe0, 0xe3,
|
0x03, 0x4c, 0xa0, 0xe3, 0x01, 0x65, 0x40, 0xe3, 0x00, 0x70, 0xe0, 0xe3,
|
||||||
0x01, 0x45, 0x40, 0xe3, 0x40, 0x00, 0x55, 0xe3, 0x00, 0x30, 0xa0, 0xe3,
|
0x01, 0x45, 0x40, 0xe3, 0x40, 0x00, 0x55, 0xe3, 0x00, 0x30, 0xa0, 0xe3,
|
||||||
0x07, 0x10, 0xa0, 0xe1, 0x05, 0x20, 0xa0, 0x31, 0x40, 0x20, 0xa0, 0x23,
|
0x07, 0xc0, 0xa0, 0xe1, 0x05, 0x20, 0xa0, 0x31, 0x40, 0x20, 0xa0, 0x23,
|
||||||
0x30, 0x20, 0x8e, 0xe5, 0x34, 0x20, 0x8e, 0xe5, 0x38, 0x20, 0x8e, 0xe5,
|
0x30, 0x20, 0x81, 0xe5, 0x34, 0x20, 0x81, 0xe5, 0x38, 0x20, 0x81, 0xe5,
|
||||||
0x00, 0x10, 0xc6, 0xe5, 0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1,
|
0x00, 0xc0, 0xc6, 0xe5, 0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1,
|
||||||
0xfb, 0xff, 0xff, 0xca, 0x08, 0x30, 0x9e, 0xe5, 0x02, 0x31, 0x83, 0xe3,
|
0xfb, 0xff, 0xff, 0xca, 0x08, 0x30, 0x91, 0xe5, 0x02, 0x31, 0x83, 0xe3,
|
||||||
0x08, 0x30, 0x8e, 0xe5, 0x1c, 0x30, 0x9e, 0xe5, 0x73, 0x30, 0xef, 0xe6,
|
0x08, 0x30, 0x81, 0xe5, 0x08, 0x30, 0x91, 0xe5, 0x00, 0x00, 0x53, 0xe3,
|
||||||
|
0xfc, 0xff, 0xff, 0xba, 0x1c, 0x30, 0x91, 0xe5, 0x73, 0x30, 0xef, 0xe6,
|
||||||
0x03, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0x8a, 0x00, 0x30, 0xa0, 0xe3,
|
0x03, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0x8a, 0x00, 0x30, 0xa0, 0xe3,
|
||||||
0x00, 0xc0, 0xd4, 0xe5, 0x00, 0x00, 0x50, 0xe3, 0x00, 0x10, 0xa0, 0xe1,
|
0x00, 0xe0, 0xd4, 0xe5, 0x00, 0x00, 0x50, 0xe3, 0x00, 0xc0, 0xa0, 0xe1,
|
||||||
0x01, 0x30, 0x83, 0xe2, 0x7c, 0xc0, 0xef, 0xe6, 0x06, 0x00, 0x00, 0x0a,
|
0x01, 0x30, 0x83, 0xe2, 0x7e, 0xe0, 0xef, 0xe6, 0x06, 0x00, 0x00, 0x0a,
|
||||||
0x03, 0x00, 0x52, 0xe1, 0x01, 0xc0, 0xc1, 0xe4, 0x01, 0x00, 0xa0, 0xe1,
|
0x03, 0x00, 0x52, 0xe1, 0x01, 0xe0, 0xcc, 0xe4, 0x0c, 0x00, 0xa0, 0xe1,
|
||||||
0xf5, 0xff, 0xff, 0xca, 0x02, 0x50, 0x55, 0xe0, 0xdf, 0xff, 0xff, 0x1a,
|
0xf5, 0xff, 0xff, 0xca, 0x02, 0x50, 0x55, 0xe0, 0xdc, 0xff, 0xff, 0x1a,
|
||||||
0xf0, 0x80, 0xbd, 0xe8, 0x03, 0x00, 0x52, 0xe1, 0x01, 0x10, 0x83, 0xe2,
|
0xf0, 0x80, 0xbd, 0xe8, 0x03, 0x00, 0x52, 0xe1, 0x01, 0xc0, 0x83, 0xe2,
|
||||||
0x02, 0x30, 0x83, 0xe2, 0xf8, 0xff, 0xff, 0xda, 0x01, 0x00, 0x52, 0xe1,
|
0x02, 0x30, 0x83, 0xe2, 0xf8, 0xff, 0xff, 0xda, 0x0c, 0x00, 0x52, 0xe1,
|
||||||
0x00, 0x10, 0xd4, 0xe5, 0xf5, 0xff, 0xff, 0xda, 0x03, 0x00, 0x52, 0xe1,
|
0x00, 0xc0, 0xd4, 0xe5, 0xf5, 0xff, 0xff, 0xda, 0x03, 0x00, 0x52, 0xe1,
|
||||||
0x00, 0x10, 0xd4, 0xe5, 0x01, 0x10, 0x83, 0xe2, 0x02, 0x30, 0x83, 0xe2,
|
0x00, 0xc0, 0xd4, 0xe5, 0x01, 0xc0, 0x83, 0xe2, 0x02, 0x30, 0x83, 0xe2,
|
||||||
0xf7, 0xff, 0xff, 0xca, 0x02, 0x50, 0x55, 0xe0, 0xd0, 0xff, 0xff, 0x1a,
|
0xf7, 0xff, 0xff, 0xca, 0x02, 0x50, 0x55, 0xe0, 0xcd, 0xff, 0xff, 0x1a,
|
||||||
0xf0, 0x80, 0xbd, 0xe8, 0xf0, 0x40, 0x2d, 0xe9, 0x00, 0x60, 0x51, 0xe2,
|
0xf0, 0x80, 0xbd, 0xe8, 0xf0, 0x40, 0x2d, 0xe9, 0x00, 0x60, 0x51, 0xe2,
|
||||||
0xf0, 0x80, 0xbd, 0x08, 0x00, 0x10, 0xa0, 0xe3, 0x02, 0x5c, 0xa0, 0xe3,
|
0xf0, 0x80, 0xbd, 0x08, 0x00, 0x10, 0xa0, 0xe3, 0x02, 0x5c, 0xa0, 0xe3,
|
||||||
0x01, 0x15, 0x40, 0xe3, 0x03, 0x4c, 0xa0, 0xe3, 0x01, 0x55, 0x40, 0xe3,
|
0x01, 0x15, 0x40, 0xe3, 0x03, 0x4c, 0xa0, 0xe3, 0x01, 0x55, 0x40, 0xe3,
|
||||||
0x00, 0x70, 0xe0, 0xe3, 0x01, 0x45, 0x40, 0xe3, 0x40, 0x00, 0x56, 0xe3,
|
0x00, 0x70, 0xe0, 0xe3, 0x01, 0x45, 0x40, 0xe3, 0x40, 0x00, 0x56, 0xe3,
|
||||||
0x06, 0x20, 0xa0, 0x31, 0x40, 0x20, 0xa0, 0x23, 0x30, 0x20, 0x81, 0xe5,
|
0x06, 0x20, 0xa0, 0x31, 0x40, 0x20, 0xa0, 0x23, 0x30, 0x20, 0x81, 0xe5,
|
||||||
0x00, 0x00, 0x50, 0xe3, 0x34, 0x20, 0x81, 0xe5, 0x38, 0x20, 0x81, 0xe5,
|
0x00, 0x00, 0x50, 0xe3, 0x34, 0x20, 0x81, 0xe5, 0x38, 0x20, 0x81, 0xe5,
|
||||||
0x17, 0x00, 0x00, 0x0a, 0x00, 0xc0, 0xa0, 0xe1, 0x00, 0x30, 0xa0, 0xe3,
|
0x1a, 0x00, 0x00, 0x0a, 0x00, 0xc0, 0xa0, 0xe1, 0x00, 0x30, 0xa0, 0xe3,
|
||||||
0x01, 0xe0, 0xdc, 0xe4, 0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1,
|
0x01, 0xe0, 0xdc, 0xe4, 0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1,
|
||||||
0x00, 0xe0, 0xc5, 0xe5, 0xfa, 0xff, 0xff, 0xca, 0x08, 0x30, 0x91, 0xe5,
|
0x00, 0xe0, 0xc5, 0xe5, 0xfa, 0xff, 0xff, 0xca, 0x08, 0x30, 0x91, 0xe5,
|
||||||
0x02, 0x31, 0x83, 0xe3, 0x08, 0x30, 0x81, 0xe5, 0x1c, 0x30, 0x91, 0xe5,
|
0x02, 0x31, 0x83, 0xe3, 0x08, 0x30, 0x81, 0xe5, 0x08, 0x30, 0x91, 0xe5,
|
||||||
|
0x00, 0x00, 0x53, 0xe3, 0xfc, 0xff, 0xff, 0xba, 0x1c, 0x30, 0x91, 0xe5,
|
||||||
0x73, 0x30, 0xef, 0xe6, 0x03, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0x8a,
|
0x73, 0x30, 0xef, 0xe6, 0x03, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0x8a,
|
||||||
0x00, 0x30, 0xa0, 0xe3, 0x00, 0xc0, 0xd4, 0xe5, 0x01, 0x30, 0x83, 0xe2,
|
0x00, 0x30, 0xa0, 0xe3, 0x00, 0xc0, 0xd4, 0xe5, 0x01, 0x30, 0x83, 0xe2,
|
||||||
0x03, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0xca, 0x00, 0x00, 0x50, 0xe3,
|
0x03, 0x00, 0x52, 0xe1, 0xfb, 0xff, 0xff, 0xca, 0x00, 0x00, 0x50, 0xe3,
|
||||||
0x02, 0x00, 0x80, 0x10, 0x02, 0x60, 0x56, 0xe0, 0xe0, 0xff, 0xff, 0x1a,
|
0x02, 0x00, 0x80, 0x10, 0x02, 0x60, 0x56, 0xe0, 0xdd, 0xff, 0xff, 0x1a,
|
||||||
0xf0, 0x80, 0xbd, 0xe8, 0x00, 0x30, 0xa0, 0xe1, 0x07, 0xc0, 0xa0, 0xe1,
|
0xf0, 0x80, 0xbd, 0xe8, 0x00, 0x30, 0xa0, 0xe1, 0x07, 0xc0, 0xa0, 0xe1,
|
||||||
0x00, 0xc0, 0xc5, 0xe5, 0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1,
|
0x00, 0xc0, 0xc5, 0xe5, 0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1,
|
||||||
0xfb, 0xff, 0xff, 0xca, 0xe7, 0xff, 0xff, 0xea, 0xf0, 0x43, 0x2d, 0xe9,
|
0xfb, 0xff, 0xff, 0xca, 0xe4, 0xff, 0xff, 0xea, 0xf0, 0x43, 0x2d, 0xe9,
|
||||||
0x0f, 0x80, 0x0c, 0xe3, 0xff, 0x8f, 0x4f, 0xe3, 0x00, 0x50, 0xa0, 0xe3,
|
0x0f, 0x80, 0x0c, 0xe3, 0xff, 0x8f, 0x4f, 0xe3, 0x00, 0x50, 0xa0, 0xe3,
|
||||||
0x01, 0x55, 0x40, 0xe3, 0x0b, 0x7a, 0xa0, 0xe3, 0x00, 0x73, 0x40, 0xe3,
|
0x01, 0x55, 0x40, 0xe3, 0x0b, 0x7a, 0xa0, 0xe3, 0x00, 0x73, 0x40, 0xe3,
|
||||||
0x14, 0xd0, 0x4d, 0xe2, 0x00, 0x60, 0xa0, 0xe1, 0x06, 0x40, 0xa0, 0xe1,
|
0x14, 0xd0, 0x4d, 0xe2, 0x00, 0x60, 0xa0, 0xe1, 0x06, 0x40, 0xa0, 0xe1,
|
||||||
@ -1254,8 +1296,8 @@ static int chip_spi_init(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t *
|
|||||||
0x70, 0x00, 0x00, 0x0a, 0x07, 0x00, 0x53, 0xe3, 0x7f, 0x00, 0x00, 0x0a,
|
0x70, 0x00, 0x00, 0x0a, 0x07, 0x00, 0x53, 0xe3, 0x7f, 0x00, 0x00, 0x0a,
|
||||||
0x08, 0x00, 0x53, 0xe3, 0x8c, 0x00, 0x00, 0x1a, 0xb0, 0x80, 0xcd, 0xe1,
|
0x08, 0x00, 0x53, 0xe3, 0x8c, 0x00, 0x00, 0x1a, 0xb0, 0x80, 0xcd, 0xe1,
|
||||||
0x0d, 0x90, 0xa0, 0xe1, 0x08, 0x60, 0x8d, 0xe2, 0x02, 0x10, 0xa0, 0xe3,
|
0x0d, 0x90, 0xa0, 0xe1, 0x08, 0x60, 0x8d, 0xe2, 0x02, 0x10, 0xa0, 0xe3,
|
||||||
0x09, 0x00, 0xa0, 0xe1, 0xad, 0xff, 0xff, 0xeb, 0x01, 0x10, 0xa0, 0xe3,
|
0x09, 0x00, 0xa0, 0xe1, 0xaa, 0xff, 0xff, 0xeb, 0x01, 0x10, 0xa0, 0xe3,
|
||||||
0x06, 0x00, 0xa0, 0xe1, 0x70, 0xff, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5,
|
0x06, 0x00, 0xa0, 0xe1, 0x6a, 0xff, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5,
|
||||||
0x01, 0x00, 0x13, 0xe3, 0xf6, 0xff, 0xff, 0x1a, 0x04, 0x60, 0xa0, 0xe1,
|
0x01, 0x00, 0x13, 0xe3, 0xf6, 0xff, 0xff, 0x1a, 0x04, 0x60, 0xa0, 0xe1,
|
||||||
0x06, 0x40, 0xa0, 0xe1, 0x01, 0x30, 0xd4, 0xe4, 0x01, 0x00, 0x53, 0xe3,
|
0x06, 0x40, 0xa0, 0xe1, 0x01, 0x30, 0xd4, 0xe4, 0x01, 0x00, 0x53, 0xe3,
|
||||||
0xe0, 0xff, 0xff, 0x1a, 0x48, 0x20, 0x97, 0xe5, 0x01, 0x3a, 0xa0, 0xe3,
|
0xe0, 0xff, 0xff, 0x1a, 0x48, 0x20, 0x97, 0xe5, 0x01, 0x3a, 0xa0, 0xe3,
|
||||||
@ -1282,36 +1324,36 @@ static int chip_spi_init(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t *
|
|||||||
0x08, 0x30, 0x95, 0xe5, 0x04, 0x60, 0xa0, 0xe1, 0xb0, 0x30, 0xc3, 0xe3,
|
0x08, 0x30, 0x95, 0xe5, 0x04, 0x60, 0xa0, 0xe1, 0xb0, 0x30, 0xc3, 0xe3,
|
||||||
0x80, 0x30, 0x83, 0xe3, 0x08, 0x30, 0x85, 0xe5, 0x98, 0xff, 0xff, 0xea,
|
0x80, 0x30, 0x83, 0xe3, 0x08, 0x30, 0x85, 0xe5, 0x98, 0xff, 0xff, 0xea,
|
||||||
0x01, 0x90, 0xd6, 0xe5, 0x02, 0x00, 0x86, 0xe2, 0x09, 0x10, 0xa0, 0xe1,
|
0x01, 0x90, 0xd6, 0xe5, 0x02, 0x00, 0x86, 0xe2, 0x09, 0x10, 0xa0, 0xe1,
|
||||||
0x01, 0x60, 0x89, 0xe2, 0x06, 0x60, 0x84, 0xe0, 0x58, 0xff, 0xff, 0xeb,
|
0x01, 0x60, 0x89, 0xe2, 0x06, 0x60, 0x84, 0xe0, 0x55, 0xff, 0xff, 0xeb,
|
||||||
0x91, 0xff, 0xff, 0xea, 0x06, 0x10, 0xd6, 0xe5, 0x09, 0x60, 0x86, 0xe2,
|
0x91, 0xff, 0xff, 0xea, 0x06, 0x10, 0xd6, 0xe5, 0x09, 0x60, 0x86, 0xe2,
|
||||||
0x07, 0x00, 0x56, 0xe5, 0x04, 0x20, 0x56, 0xe5, 0x08, 0x30, 0x56, 0xe5,
|
0x07, 0x00, 0x56, 0xe5, 0x04, 0x20, 0x56, 0xe5, 0x08, 0x30, 0x56, 0xe5,
|
||||||
0x02, 0xe0, 0x56, 0xe5, 0x06, 0xc0, 0x56, 0xe5, 0x01, 0x24, 0x82, 0xe1,
|
0x02, 0xe0, 0x56, 0xe5, 0x06, 0xc0, 0x56, 0xe5, 0x01, 0x24, 0x82, 0xe1,
|
||||||
0x00, 0x34, 0x83, 0xe1, 0x01, 0x10, 0x56, 0xe5, 0x05, 0x00, 0x56, 0xe5,
|
0x00, 0x34, 0x83, 0xe1, 0x01, 0x10, 0x56, 0xe5, 0x05, 0x00, 0x56, 0xe5,
|
||||||
0x0e, 0x28, 0x82, 0xe1, 0x0c, 0x38, 0x83, 0xe1, 0x01, 0x1c, 0x82, 0xe1,
|
0x0e, 0x28, 0x82, 0xe1, 0x0c, 0x38, 0x83, 0xe1, 0x01, 0x1c, 0x82, 0xe1,
|
||||||
0x00, 0x0c, 0x83, 0xe1, 0x47, 0xff, 0xff, 0xeb, 0x80, 0xff, 0xff, 0xea,
|
0x00, 0x0c, 0x83, 0xe1, 0x44, 0xff, 0xff, 0xeb, 0x80, 0xff, 0xff, 0xea,
|
||||||
0x06, 0x10, 0xd6, 0xe5, 0x09, 0x60, 0x86, 0xe2, 0x07, 0x00, 0x56, 0xe5,
|
0x06, 0x10, 0xd6, 0xe5, 0x09, 0x60, 0x86, 0xe2, 0x07, 0x00, 0x56, 0xe5,
|
||||||
0x04, 0x20, 0x56, 0xe5, 0x08, 0x30, 0x56, 0xe5, 0x02, 0xe0, 0x56, 0xe5,
|
0x04, 0x20, 0x56, 0xe5, 0x08, 0x30, 0x56, 0xe5, 0x02, 0xe0, 0x56, 0xe5,
|
||||||
0x06, 0xc0, 0x56, 0xe5, 0x01, 0x24, 0x82, 0xe1, 0x00, 0x34, 0x83, 0xe1,
|
0x06, 0xc0, 0x56, 0xe5, 0x01, 0x24, 0x82, 0xe1, 0x00, 0x34, 0x83, 0xe1,
|
||||||
0x01, 0x10, 0x56, 0xe5, 0x05, 0x00, 0x56, 0xe5, 0x0e, 0x28, 0x82, 0xe1,
|
0x01, 0x10, 0x56, 0xe5, 0x05, 0x00, 0x56, 0xe5, 0x0e, 0x28, 0x82, 0xe1,
|
||||||
0x0c, 0x38, 0x83, 0xe1, 0x01, 0x1c, 0x82, 0xe1, 0x00, 0x0c, 0x83, 0xe1,
|
0x0c, 0x38, 0x83, 0xe1, 0x01, 0x1c, 0x82, 0xe1, 0x00, 0x0c, 0x83, 0xe1,
|
||||||
0xfc, 0xfe, 0xff, 0xeb, 0x6f, 0xff, 0xff, 0xea, 0x0d, 0x90, 0xa0, 0xe1,
|
0xf6, 0xfe, 0xff, 0xeb, 0x6f, 0xff, 0xff, 0xea, 0x0d, 0x90, 0xa0, 0xe1,
|
||||||
0x08, 0x60, 0x8d, 0xe2, 0x05, 0x30, 0xa0, 0xe3, 0x00, 0x30, 0xcd, 0xe5,
|
0x08, 0x60, 0x8d, 0xe2, 0x05, 0x30, 0xa0, 0xe3, 0x00, 0x30, 0xcd, 0xe5,
|
||||||
0x01, 0x10, 0xa0, 0xe3, 0x09, 0x00, 0xa0, 0xe1, 0x2e, 0xff, 0xff, 0xeb,
|
0x01, 0x10, 0xa0, 0xe3, 0x09, 0x00, 0xa0, 0xe1, 0x2b, 0xff, 0xff, 0xeb,
|
||||||
0x01, 0x10, 0xa0, 0xe3, 0x06, 0x00, 0xa0, 0xe1, 0xf1, 0xfe, 0xff, 0xeb,
|
0x01, 0x10, 0xa0, 0xe3, 0x06, 0x00, 0xa0, 0xe1, 0xeb, 0xfe, 0xff, 0xeb,
|
||||||
0x08, 0x30, 0xdd, 0xe5, 0x01, 0x00, 0x13, 0xe3, 0xf6, 0xff, 0xff, 0x1a,
|
0x08, 0x30, 0xdd, 0xe5, 0x01, 0x00, 0x13, 0xe3, 0xf6, 0xff, 0xff, 0x1a,
|
||||||
0x04, 0x60, 0xa0, 0xe1, 0x7f, 0xff, 0xff, 0xea, 0x14, 0xd0, 0x8d, 0xe2,
|
0x04, 0x60, 0xa0, 0xe1, 0x7f, 0xff, 0xff, 0xea, 0x14, 0xd0, 0x8d, 0xe2,
|
||||||
0xf0, 0x83, 0xbd, 0xe8, 0x04, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
|
0xf0, 0x83, 0xbd, 0xe8, 0x04, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
|
||||||
0x03, 0x00, 0x00, 0x00, 0x47, 0x4e, 0x55, 0x00, 0xbe, 0x5b, 0x1d, 0xa0,
|
0x03, 0x00, 0x00, 0x00, 0x47, 0x4e, 0x55, 0x00, 0x7e, 0xf1, 0x42, 0x24,
|
||||||
0x00, 0xaf, 0x04, 0x3c, 0x40, 0x15, 0xc5, 0xde, 0x21, 0x29, 0xbc, 0xb6,
|
0x25, 0xf1, 0x0c, 0x1b, 0x69, 0xe5, 0x0b, 0x13, 0x65, 0x6b, 0x15, 0x0a,
|
||||||
0x9f, 0x83, 0xa6, 0x42, 0x2f, 0x6c, 0x69, 0x62, 0x2f, 0x6c, 0x64, 0x2d,
|
0xcb, 0x0f, 0xb5, 0xcb, 0x2f, 0x6c, 0x69, 0x62, 0x2f, 0x6c, 0x64, 0x2d,
|
||||||
0x6c, 0x69, 0x6e, 0x75, 0x78, 0x2d, 0x61, 0x72, 0x6d, 0x68, 0x66, 0x2e,
|
0x6c, 0x69, 0x6e, 0x75, 0x78, 0x2d, 0x61, 0x72, 0x6d, 0x68, 0x66, 0x2e,
|
||||||
0x73, 0x6f, 0x2e, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x73, 0x6f, 0x2e, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf5, 0xfe, 0xff, 0x6f,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf5, 0xfe, 0xff, 0x6f,
|
||||||
0x14, 0x25, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x10, 0x25, 0x02, 0x00,
|
0x44, 0x25, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x40, 0x25, 0x02, 0x00,
|
||||||
0x06, 0x00, 0x00, 0x00, 0x00, 0x25, 0x02, 0x00, 0x0a, 0x00, 0x00, 0x00,
|
0x06, 0x00, 0x00, 0x00, 0x30, 0x25, 0x02, 0x00, 0x0a, 0x00, 0x00, 0x00,
|
||||||
0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
|
0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
|
||||||
0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00,
|
0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00,
|
||||||
0x08, 0x00, 0x00, 0x00, 0xfb, 0xff, 0xff, 0x6f, 0x01, 0x00, 0x00, 0x08,
|
0x08, 0x00, 0x00, 0x00, 0xfb, 0xff, 0xff, 0x6f, 0x01, 0x00, 0x00, 0x08,
|
||||||
@ -1319,7 +1361,7 @@ static int chip_spi_init(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t *
|
|||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x30, 0x25, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
0x60, 0x25, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||||
};
|
};
|
||||||
fel_write(ctx, 0x00022000, (void *)&payload[0], sizeof(payload));
|
fel_write(ctx, 0x00022000, (void *)&payload[0], sizeof(payload));
|
||||||
if(swapbuf)
|
if(swapbuf)
|
||||||
@ -1338,6 +1380,52 @@ static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct sid_section_t {
|
||||||
|
char * name;
|
||||||
|
uint32_t offset;
|
||||||
|
uint32_t size_bits;
|
||||||
|
} sids[] = {
|
||||||
|
{ "chipid", 0x0000, 128 },
|
||||||
|
{ "unknown", 0x0010, 1920 },
|
||||||
|
};
|
||||||
|
|
||||||
|
static int chip_extra(struct xfel_ctx_t * ctx, int argc, char * argv[])
|
||||||
|
{
|
||||||
|
if(argc > 0)
|
||||||
|
{
|
||||||
|
if(!strcmp(argv[0], "efuse"))
|
||||||
|
{
|
||||||
|
argc -= 1;
|
||||||
|
argv += 1;
|
||||||
|
if(argc > 0)
|
||||||
|
{
|
||||||
|
if(!strcmp(argv[0], "dump") && (argc == 1))
|
||||||
|
{
|
||||||
|
uint32_t buffer[2048 / 4];
|
||||||
|
for(int n = 0; n < ARRAY_SIZE(sids); n++)
|
||||||
|
{
|
||||||
|
uint32_t count = sids[n].size_bits / 32;
|
||||||
|
for(int i = 0; i < count; i++)
|
||||||
|
buffer[i] = payload_read32(ctx, 0x03006200 + sids[n].offset + i * 4);
|
||||||
|
printf("%s:(0x%04x %d-bits)", sids[n].name, sids[n].offset, sids[n].size_bits);
|
||||||
|
for(int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
if(i >= 0 && ((i % 8) == 0))
|
||||||
|
printf("\r\n%-4s", "");
|
||||||
|
printf("%08x ", buffer[i]);
|
||||||
|
}
|
||||||
|
printf("\r\n");
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("usage:\r\n");
|
||||||
|
printf(" xfel extra efuse dump - Dump all of the efuse information\r\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
struct chip_t v831 = {
|
struct chip_t v831 = {
|
||||||
.name = "V831",
|
.name = "V831",
|
||||||
.detect = chip_detect,
|
.detect = chip_detect,
|
||||||
@ -1347,4 +1435,5 @@ struct chip_t v831 = {
|
|||||||
.ddr = chip_ddr,
|
.ddr = chip_ddr,
|
||||||
.spi_init = chip_spi_init,
|
.spi_init = chip_spi_init,
|
||||||
.spi_run = chip_spi_run,
|
.spi_run = chip_spi_run,
|
||||||
|
.extra = chip_extra,
|
||||||
};
|
};
|
||||||
|
1773
chips/v851_v853.c
Normal file
1773
chips/v851_v853.c
Normal file
File diff suppressed because it is too large
Load Diff
158
docs/README.md
158
docs/README.md
@ -9,9 +9,38 @@ Tiny FEL tools for Allwinner SOC.
|
|||||||
## FEL
|
## FEL
|
||||||
FEL is a low-level subroutine contained in the BootROM on Allwinner devices. It is used for initial programming and recovery of devices using USB.
|
FEL is a low-level subroutine contained in the BootROM on Allwinner devices. It is used for initial programming and recovery of devices using USB.
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
|
||||||
|
```
|
||||||
|
usage:
|
||||||
|
xfel version - Show chip version
|
||||||
|
xfel hexdump <address> <length> - Dumps memory region in hex
|
||||||
|
xfel dump <address> <length> - Binary memory dump to stdout
|
||||||
|
xfel read32 <address> - Read 32-bits value from device memory
|
||||||
|
xfel write32 <address> <value> - Write 32-bits value to device memory
|
||||||
|
xfel read <address> <length> <file> - Read memory to file
|
||||||
|
xfel write <address> <file> - Write file to memory
|
||||||
|
xfel exec <address> - Call function address
|
||||||
|
xfel reset - Reset device using watchdog
|
||||||
|
xfel sid - Show sid information
|
||||||
|
xfel jtag - Enable jtag debug
|
||||||
|
xfel ddr [type] - Initial ddr controller with optional type
|
||||||
|
xfel sign <public-key> <private-key> <file> - Generate ecdsa256 signature file for sha256 of sid
|
||||||
|
xfel spinor - Detect spi nor flash
|
||||||
|
xfel spinor erase <address> <length> - Erase spi nor flash
|
||||||
|
xfel spinor read <address> <length> <file> - Read spi nor flash to file
|
||||||
|
xfel spinor write <address> <file> - Write file to spi nor flash
|
||||||
|
xfel spinand - Detect spi nand flash
|
||||||
|
xfel spinand erase <address> <length> - Erase spi nand flash
|
||||||
|
xfel spinand read <address> <length> <file> - Read spi nand flash to file
|
||||||
|
xfel spinand write <address> <file> - Write file to spi nand flash
|
||||||
|
xfel spinand splwrite <split-size> <address> <file> - Write file to spi nand flash with split support
|
||||||
|
xfel extra [...] - The extra commands
|
||||||
|
```
|
||||||
|
|
||||||
# Support Lists
|
# Support Lists
|
||||||
|
|
||||||
✅: Supported — ❌: Not Supported Yet — ⚠️: Not Fully Supported Yet
|
✅: Supported — ❌: Not Supported Yet — 🚫: None
|
||||||
|
|
||||||
| Chip | CPU | ID | Basic | Reset | Sid | Jtag | DDR | SPI Nor Flash | SPI Nand Flash |
|
| Chip | CPU | ID | Basic | Reset | Sid | Jtag | DDR | SPI Nor Flash | SPI Nand Flash |
|
||||||
| -------- | :----- | :----- | -------- | :------- | -------- | -------- | -------- | -------- | -------- |
|
| -------- | :----- | :----- | -------- | :------- | -------- | -------- | -------- | -------- | -------- |
|
||||||
@ -24,73 +53,42 @@ FEL is a low-level subroutine contained in the BootROM on Allwinner devices. It
|
|||||||
| A31 | Quad-Core ARM Cortex-A7 | 0x00163300 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| A31 | Quad-Core ARM Cortex-A7 | 0x00163300 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||||
| A33 | Quad-Core ARM Cortex-A7 @ 1.2GHz | 0x00166700 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| A33 | Quad-Core ARM Cortex-A7 @ 1.2GHz | 0x00166700 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||||
| R16 | Quad-Core ARM Cortex-A7 @ 1.2GHz | 0x00166700 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| R16 | Quad-Core ARM Cortex-A7 @ 1.2GHz | 0x00166700 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||||
| A40i | Quad-Core ARM Cortex-A7 @ 1.2 GHz | 0x00170100 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| A40i | Quad-Core ARM Cortex-A7 @ 1.2 GHz | 0x00170100 | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ |
|
||||||
| R40 | Quad-Core ARM Cortex-A7 @ 1.2 GHz | 0x00170100 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| R40 | Quad-Core ARM Cortex-A7 @ 1.2 GHz | 0x00170100 | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ |
|
||||||
|
| A50 | Quad-Core ARM Cortex-A7 @ 1.8GHz | 0x00175500 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||||
| A64 | Quad-Core ARM Cortex-A53 | 0x00168900 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| A64 | Quad-Core ARM Cortex-A53 | 0x00168900 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||||
| A80 | Octa-core big.LITTLE Cortex-A15/7 | 0x00163900 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| A80 | Octa-core big.LITTLE Cortex-A15/7 | 0x00163900 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||||
| A83T | Octa-core Cortex-A7 @ 1.6GHz | 0x00167300 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| A83T | Octa-core Cortex-A7 @ 1.6GHz | 0x00167300 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||||
| D1 | XuanTie C906 RISC-V | 0x00185900 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
| D1 | XuanTie C906 RISC-V | 0x00185900 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
| D1s | XuanTie C906 RISC-V | 0x00185900 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
| D1s | XuanTie C906 RISC-V | 0x00185900 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
| F133 | XuanTie C906 RISC-V | 0x00185900 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
| F133 | XuanTie C906 RISC-V | 0x00185900 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
| F1C100S | Single-core ARM9 | 0x00166300 | ✅ | ✅ | ⚠️ | ✅ | ✅ | ✅ | ✅ |
|
| F1C100S | Single-core ARM9 | 0x00166300 | ✅ | ✅ | 🚫 | ✅ | ✅ | ✅ | ✅ |
|
||||||
| F1C200S | Single-core ARM9 | 0x00166300 | ✅ | ✅ | ⚠️ | ✅ | ✅ | ✅ | ✅ |
|
| F1C200S | Single-core ARM9 | 0x00166300 | ✅ | ✅ | 🚫 | ✅ | ✅ | ✅ | ✅ |
|
||||||
| F1C500S | Single-core ARM9 | 0x00166300 | ✅ | ✅ | ⚠️ | ✅ | ✅ | ✅ | ✅ |
|
| F1C500S | Single-core ARM9 | 0x00166300 | ✅ | ✅ | 🚫 | ✅ | ✅ | ✅ | ✅ |
|
||||||
| H2 | Quad-Core ARM Cortex-A7 | 0x00168000 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
| H2 | Quad-Core ARM Cortex-A7 | 0x00168000 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
| H3 | Quad-Core ARM Cortex-A7 @ 1.296GHz | 0x00168000 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
| H3 | Quad-Core ARM Cortex-A7 @ 1.296GHz | 0x00168000 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
| H5 | Quad-Core ARM Cortex-A53 | 0x00171800 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| H5 | Quad-Core ARM Cortex-A53 | 0x00171800 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||||
| H6 | Quad-Core ARM Cortex-A53 @ 1.8GHz | 0x00172800 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| H6 | Quad-Core ARM Cortex-A53 @ 1.8GHz | 0x00172800 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||||
| H616 | Quad-Core ARM Cortex-A53 | 0x00182300 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| H313 | Quad-Core ARM Cortex-A53 | 0x00182300 | ✅ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ |
|
||||||
|
| H616 | Quad-Core ARM Cortex-A53 | 0x00182300 | ✅ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ |
|
||||||
|
| H618 | Quad-Core ARM Cortex-A53 | 0x00182300 | ✅ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ |
|
||||||
|
| R128 | ARM Cortex-M33 and C906 RISC-V | 0x00188300 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
| R328 | Dual-Core Cortex-A7 | 0x00182100 | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ |
|
| R328 | Dual-Core Cortex-A7 | 0x00182100 | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ |
|
||||||
| R329 | Dual-Core Cortex-A53 | 0x00185100 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| R329 | Dual-Core Cortex-A53 | 0x00185100 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||||
| R528 | Dual-Core Cortex-A7 | 0x00185900 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
| R528 | Dual-Core Cortex-A7 | 0x00185900 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
| T507 | Quad-Core ARM Cortex-A53 | 0x00182300 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| T113 | Dual-Core Cortex-A7 | 0x00185900 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
|
| T507 | Quad-Core ARM Cortex-A53 | 0x00182300 | ✅ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ |
|
||||||
| V3s | Single-core Cortex-A7 | 0x00168100 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
| V3s | Single-core Cortex-A7 | 0x00168100 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
| S3 | Single-core Cortex-A7 | 0x00168100 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
| S3 | Single-core Cortex-A7 | 0x00168100 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
| V536 | Dual-Core Cortex-A7 | 0x00181600 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| V536 | Dual-Core Cortex-A7 | 0x00181600 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||||
|
| V821 | Andes A272L2 32Bit RISC-V and E907 RISC-V | 0x00188200 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
| V831 | Single-core Cortex-A7 800Mhz | 0x00181700 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
| V831 | Single-core Cortex-A7 800Mhz | 0x00181700 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
|
| V851 | Single-core Cortex-A7 1Ghz + E907 RISC-V | 0x00188600 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
# Download and install
|
| V853 | Single-core Cortex-A7 1Ghz + E907 RISC-V | 0x00188600 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
|
| A523 | Octa-core Cortex-A55 2.0Ghz + E906 RISC-V + HIFI4 DSP | 0x00189000 | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ |
|
||||||
## Linux platform
|
| A527 | Octa-core Cortex-A55 2.0Ghz + E906 RISC-V + HIFI4 DSP | 0x00189000 | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ |
|
||||||
|
| T527 | Octa-core Cortex-A55 2.0Ghz + E906 RISC-V + HIFI4 DSP | 0x00189000 | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ |
|
||||||
### ArchLinux
|
| MR527 | Octa-core Cortex-A55 2.0Ghz + E906 RISC-V + HIFI4 DSP | 0x00189000 | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ |
|
||||||
|
|
||||||
The xfel now avaliable at [AUR](https://aur.archlinux.org/packages/xfel/), You can use any AUR helper like `yay` to download.
|
|
||||||
|
|
||||||
```shell
|
|
||||||
yay -S xfel
|
|
||||||
```
|
|
||||||
|
|
||||||
## Windows platform
|
|
||||||
|
|
||||||
Get the latest prebuild at [RELEASE](https://github.com/xboot/xfel/releases/latest)
|
|
||||||
|
|
||||||
# Usage
|
|
||||||
|
|
||||||
```
|
|
||||||
usage:
|
|
||||||
xfel version - Show chip version
|
|
||||||
xfel hexdump <address> <length> - Dumps memory region in hex
|
|
||||||
xfel dump <address> <length> - Binary memory dump to stdout
|
|
||||||
xfel exec <address> - Call function address
|
|
||||||
xfel read32 <address> - Read 32-bits value from device memory
|
|
||||||
xfel write32 <address> <value> - Write 32-bits value to device memory
|
|
||||||
xfel read <address> <length> <file> - Read memory to file
|
|
||||||
xfel write <address> <file> - Write file to memory
|
|
||||||
xfel reset - Reset device using watchdog
|
|
||||||
xfel sid - Show sid information
|
|
||||||
xfel jtag - Enable jtag debug
|
|
||||||
xfel ddr [type] - Initial ddr controller with optional type
|
|
||||||
xfel spinor - Detect spi nor flash
|
|
||||||
xfel spinor erase <address> <length> - Erase spi nor flash
|
|
||||||
xfel spinor read <address> <length> <file> - Read spi nor flash to file
|
|
||||||
xfel spinor write <address> <file> - Write file to spi nor flash
|
|
||||||
xfel spinand - Detect spi nand flash
|
|
||||||
xfel spinand erase <address> <length> - Erase spi nand flash
|
|
||||||
xfel spinand read <address> <length> <file> - Read spi nand flash to file
|
|
||||||
xfel spinand write <address> <file> - Write file to spi nand flash
|
|
||||||
xfel spinand splwrite <split-size> <address> <file> - Write file to spi nand flash with split support
|
|
||||||
```
|
|
||||||
|
|
||||||
# Build from source
|
# Build from source
|
||||||
|
|
||||||
@ -110,25 +108,6 @@ make
|
|||||||
sudo make install
|
sudo make install
|
||||||
```
|
```
|
||||||
|
|
||||||
## macOS platform
|
|
||||||
|
|
||||||
?> _TODO_ Add macOS ARM support
|
|
||||||
|
|
||||||
Before start, make sure the `Command Line Tools` is installed.
|
|
||||||
|
|
||||||
Install `libusb` using [brew](https://brew.sh/)
|
|
||||||
|
|
||||||
```shell
|
|
||||||
brew install libusb
|
|
||||||
```
|
|
||||||
|
|
||||||
Then just type `make` at the root directory, you will see a binary program.
|
|
||||||
|
|
||||||
```shell
|
|
||||||
cd xfel
|
|
||||||
make
|
|
||||||
```
|
|
||||||
|
|
||||||
## Window platform
|
## Window platform
|
||||||
|
|
||||||
Windows adopts the cross-compilation method, to install the cross-compilation tool chain in Ubuntu, using:
|
Windows adopts the cross-compilation method, to install the cross-compilation tool chain in Ubuntu, using:
|
||||||
@ -158,6 +137,31 @@ CROSS=i686-w64-mingw32- make
|
|||||||
|
|
||||||
For 64-bits windows, you can using `x86_64-w64-mingw32-` instead of `i686-w64-mingw32` above.
|
For 64-bits windows, you can using `x86_64-w64-mingw32-` instead of `i686-w64-mingw32` above.
|
||||||
|
|
||||||
|
## macOS platform
|
||||||
|
|
||||||
|
?> _TODO_ Add macOS ARM support
|
||||||
|
|
||||||
|
Before start, make sure the `Command Line Tools` is installed.
|
||||||
|
|
||||||
|
Install `libusb` using [brew](https://brew.sh/)
|
||||||
|
|
||||||
|
```shell
|
||||||
|
brew install libusb
|
||||||
|
```
|
||||||
|
|
||||||
|
Then just type `make` at the root directory, you will see a binary program.
|
||||||
|
|
||||||
|
```shell
|
||||||
|
cd xfel
|
||||||
|
make
|
||||||
|
```
|
||||||
|
|
||||||
|
# Download and install
|
||||||
|
|
||||||
|
## Windows platform
|
||||||
|
|
||||||
|
Get the latest prebuild at [RELEASE](https://github.com/xboot/xfel/releases/latest)
|
||||||
|
|
||||||
# Examples
|
# Examples
|
||||||
|
|
||||||
## F1C100s: Write U-Boot to DDR and execute U-Boot
|
## F1C100s: Write U-Boot to DDR and execute U-Boot
|
||||||
@ -168,12 +172,22 @@ xfel write 0x81700000 u-boot.bin # write uboot to 0x81700000
|
|||||||
xfel exec 0x81700000 # Call the function and exectue
|
xfel exec 0x81700000 # Call the function and exectue
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## F1C200s: Write System to SPI NAND Flash
|
||||||
|
```
|
||||||
|
xfel spinand
|
||||||
|
xfel spinand erase 0x000000 134217728
|
||||||
|
xfel spinand write 0x000000 u-boot-sunxi-with-nand-spl.bin
|
||||||
|
xfel spinand write 0x80000 splash.bmp
|
||||||
|
xfel spinand write 0x100000 kernel.itb
|
||||||
|
xfel spinand write 0x600000 rootfs.squashfs
|
||||||
|
```
|
||||||
|
|
||||||
## F133: Write OpenSBI to DDR and execute it
|
## F133: Write OpenSBI to DDR and execute it
|
||||||
|
|
||||||
```
|
```
|
||||||
xfel ddr ddr2 # Initial ddr controller with ddr2 type
|
xfel ddr f133 # Initial ddr controller for f133
|
||||||
xfel write 0x80200000 opensbi.bin # write opensbi to 0x80200000
|
xfel write 0x80200000 opensbi.bin # write opensbi to 0x80200000
|
||||||
xfel exec 0x80200000 # Call the function and exectue
|
xfel exec 0x80200000 # Call the function and exectue
|
||||||
```
|
```
|
||||||
|
|
||||||
?> _TODO_ Want to add more examples? Using the pull requests at [https://github.com/xboot/xfel/pulls](https://github.com/xboot/xfel/pulls)
|
?> Want to add more examples? Using the pull requests at [https://github.com/xboot/xfel/pulls](https://github.com/xboot/xfel/pulls)
|
||||||
|
@ -9,9 +9,39 @@
|
|||||||
## 什么是FEL
|
## 什么是FEL
|
||||||
FEL 是全志 SOC 中上 BootROM 中包含的低级程序。可以通过它使用 USB OTG 对 SOC 进行编程和恢复。
|
FEL 是全志 SOC 中上 BootROM 中包含的低级程序。可以通过它使用 USB OTG 对 SOC 进行编程和恢复。
|
||||||
|
|
||||||
|
|
||||||
|
# 使用方法
|
||||||
|
|
||||||
|
```
|
||||||
|
usage:
|
||||||
|
xfel version - 显示芯片ID
|
||||||
|
xfel hexdump <address> <length> - 以HEX文件转储内存区域
|
||||||
|
xfel dump <address> <length> - 转储内存区域并输出
|
||||||
|
xfel read32 <address> - 从设备内存中读取 32 位值
|
||||||
|
xfel write32 <address> <value> - 向设备内存中写入 32 位值
|
||||||
|
xfel read <address> <length> <file> - 向文件写入内存
|
||||||
|
xfel write <address> <file> - 向内存写入文件
|
||||||
|
xfel exec <address> - 调用函数地址
|
||||||
|
xfel reset - 使用看门狗重置设备
|
||||||
|
xfel sid - 显示sid信息
|
||||||
|
xfel jtag - 启用 jtag 调试
|
||||||
|
xfel ddr [type] - 初始化 DDR 控制器
|
||||||
|
xfel sign <public-key> <private-key> <file> - 依据sid的sha256摘要信息生成ECDSA256签名文件
|
||||||
|
xfel spinor - 检测 spi nor flash
|
||||||
|
xfel spinor erase <address> <length> - 擦除 spi nor flash
|
||||||
|
xfel spinor read <address> <length> <file> - 读取 spi nor flash 到文件
|
||||||
|
xfel spinor write <address> <file> - 将文件写入 spi nor flash
|
||||||
|
xfel spinand - 检测 spi nand flash
|
||||||
|
xfel spinand erase <address> <length> - 擦除 spi nand flash
|
||||||
|
xfel spinand read <address> <length> <file> - 读取 spi nand flash 到文件
|
||||||
|
xfel spinand write <address> <file> - 将文件写入 spi nand flash
|
||||||
|
xfel spinand splwrite <split-size> <address> <file> - 使用拆分支持将文件写入 spi nand flash
|
||||||
|
xfel extra [...] - 扩展命令
|
||||||
|
```
|
||||||
|
|
||||||
# 支持列表
|
# 支持列表
|
||||||
|
|
||||||
✅: 已经支持 — ❌: 还未支持 — ⚠️: 还未完全支持
|
✅: 已经支持 — ❌: 还未支持 — 🚫: 无
|
||||||
|
|
||||||
| Chip | CPU | ID | Basic | Reset | Sid | Jtag | DDR | SPI Nor Flash | SPI Nand Flash |
|
| Chip | CPU | ID | Basic | Reset | Sid | Jtag | DDR | SPI Nor Flash | SPI Nand Flash |
|
||||||
| -------- | :----- | :----- | -------- | :------- | -------- | -------- | -------- | -------- | -------- |
|
| -------- | :----- | :----- | -------- | :------- | -------- | -------- | -------- | -------- | -------- |
|
||||||
@ -24,74 +54,42 @@ FEL 是全志 SOC 中上 BootROM 中包含的低级程序。可以通过它使
|
|||||||
| A31 | Quad-Core ARM Cortex-A7 | 0x00163300 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| A31 | Quad-Core ARM Cortex-A7 | 0x00163300 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||||
| A33 | Quad-Core ARM Cortex-A7 @ 1.2GHz | 0x00166700 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| A33 | Quad-Core ARM Cortex-A7 @ 1.2GHz | 0x00166700 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||||
| R16 | Quad-Core ARM Cortex-A7 @ 1.2GHz | 0x00166700 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| R16 | Quad-Core ARM Cortex-A7 @ 1.2GHz | 0x00166700 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||||
| A40i | Quad-Core ARM Cortex-A7 @ 1.2 GHz | 0x00170100 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| A40i | Quad-Core ARM Cortex-A7 @ 1.2 GHz | 0x00170100 | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ |
|
||||||
| R40 | Quad-Core ARM Cortex-A7 @ 1.2 GHz | 0x00170100 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| R40 | Quad-Core ARM Cortex-A7 @ 1.2 GHz | 0x00170100 | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ |
|
||||||
|
| A50 | Quad-Core ARM Cortex-A7 @ 1.8GHz | 0x00175500 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||||
| A64 | Quad-Core ARM Cortex-A53 | 0x00168900 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| A64 | Quad-Core ARM Cortex-A53 | 0x00168900 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||||
| A80 | Octa-core big.LITTLE Cortex-A15/7 | 0x00163900 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| A80 | Octa-core big.LITTLE Cortex-A15/7 | 0x00163900 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||||
| A83T | Octa-core Cortex-A7 @ 1.6GHz | 0x00167300 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| A83T | Octa-core Cortex-A7 @ 1.6GHz | 0x00167300 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||||
| D1 | XuanTie C906 RISC-V | 0x00185900 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
| D1 | XuanTie C906 RISC-V | 0x00185900 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
| D1s | XuanTie C906 RISC-V | 0x00185900 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
| D1s | XuanTie C906 RISC-V | 0x00185900 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
| F133 | XuanTie C906 RISC-V | 0x00185900 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
| F133 | XuanTie C906 RISC-V | 0x00185900 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
| F1C100S | Single-core ARM9 | 0x00166300 | ✅ | ✅ | ⚠️ | ✅ | ✅ | ✅ | ✅ |
|
| F1C100S | Single-core ARM9 | 0x00166300 | ✅ | ✅ | 🚫 | ✅ | ✅ | ✅ | ✅ |
|
||||||
| F1C200S | Single-core ARM9 | 0x00166300 | ✅ | ✅ | ⚠️ | ✅ | ✅ | ✅ | ✅ |
|
| F1C200S | Single-core ARM9 | 0x00166300 | ✅ | ✅ | 🚫 | ✅ | ✅ | ✅ | ✅ |
|
||||||
| F1C500S | Single-core ARM9 | 0x00166300 | ✅ | ✅ | ⚠️ | ✅ | ✅ | ✅ | ✅ |
|
| F1C500S | Single-core ARM9 | 0x00166300 | ✅ | ✅ | 🚫 | ✅ | ✅ | ✅ | ✅ |
|
||||||
| H2 | Quad-Core ARM Cortex-A7 | 0x00168000 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
| H2 | Quad-Core ARM Cortex-A7 | 0x00168000 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
| H3 | Quad-Core ARM Cortex-A7 @ 1.296GHz | 0x00168000 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
| H3 | Quad-Core ARM Cortex-A7 @ 1.296GHz | 0x00168000 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
| H5 | Quad-Core ARM Cortex-A53 | 0x00171800 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| H5 | Quad-Core ARM Cortex-A53 | 0x00171800 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||||
| H6 | Quad-Core ARM Cortex-A53 @ 1.8GHz | 0x00172800 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| H6 | Quad-Core ARM Cortex-A53 @ 1.8GHz | 0x00172800 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||||
| H616 | Quad-Core ARM Cortex-A53 | 0x00182300 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| H313 | Quad-Core ARM Cortex-A53 | 0x00182300 | ✅ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ |
|
||||||
|
| H616 | Quad-Core ARM Cortex-A53 | 0x00182300 | ✅ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ |
|
||||||
|
| H618 | Quad-Core ARM Cortex-A53 | 0x00182300 | ✅ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ |
|
||||||
|
| R128 | ARM Cortex-M33 and C906 RISC-V | 0x00188300 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
| R328 | Dual-Core Cortex-A7 | 0x00182100 | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ |
|
| R328 | Dual-Core Cortex-A7 | 0x00182100 | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ |
|
||||||
| R329 | Dual-Core Cortex-A53 | 0x00185100 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| R329 | Dual-Core Cortex-A53 | 0x00185100 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||||
| R528 | Dual-Core Cortex-A7 | 0x00185900 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
| R528 | Dual-Core Cortex-A7 | 0x00185900 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
| T507 | Quad-Core ARM Cortex-A53 | 0x00182300 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| T113 | Dual-Core Cortex-A7 | 0x00185900 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
|
| T507 | Quad-Core ARM Cortex-A53 | 0x00182300 | ✅ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ |
|
||||||
| V3s | Single-core Cortex-A7 | 0x00168100 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
| V3s | Single-core Cortex-A7 | 0x00168100 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
| S3 | Single-core Cortex-A7 | 0x00168100 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
| S3 | Single-core Cortex-A7 | 0x00168100 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
| V536 | Dual-Core Cortex-A7 | 0x00181600 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
| V536 | Dual-Core Cortex-A7 | 0x00181600 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
|
||||||
|
| V821 | Andes A272L2 32Bit RISC-V and E907 RISC-V | 0x00188200 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
| V831 | Single-core Cortex-A7 800Mhz | 0x00181700 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
| V831 | Single-core Cortex-A7 800Mhz | 0x00181700 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
|
| V851 | Single-core Cortex-A7 1Ghz + E907 RISC-V | 0x00188600 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
# 下载安装
|
| V853 | Single-core Cortex-A7 1Ghz + E907 RISC-V | 0x00188600 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
||||||
|
| A523 | Octa-core Cortex-A55 2.0Ghz + E906 RISC-V + HIFI4 DSP | 0x00189000 | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ |
|
||||||
## Linux
|
| A527 | Octa-core Cortex-A55 2.0Ghz + E906 RISC-V + HIFI4 DSP | 0x00189000 | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ |
|
||||||
|
| T527 | Octa-core Cortex-A55 2.0Ghz + E906 RISC-V + HIFI4 DSP | 0x00189000 | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ |
|
||||||
### ArchLinux
|
| MR527 | Octa-core Cortex-A55 2.0Ghz + E906 RISC-V + HIFI4 DSP | 0x00189000 | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ |
|
||||||
|
|
||||||
xfel 现在可以在 [AUR](https://aur.archlinux.org/packages/xfel/) 下载到, 对于 ArchLinux 只需要使用 AUR 管理器就可以安装。例如`yay`。
|
|
||||||
|
|
||||||
```shell
|
|
||||||
yay -S xfel
|
|
||||||
```
|
|
||||||
|
|
||||||
## Windows
|
|
||||||
|
|
||||||
在 [RELEASE](https://github.com/xboot/xfel/releases/latest) 找到预编译的Windows软件。
|
|
||||||
|
|
||||||
|
|
||||||
# 使用方法
|
|
||||||
|
|
||||||
```
|
|
||||||
usage:
|
|
||||||
xfel version - 显示芯片ID
|
|
||||||
xfel hexdump <address> <length> - 以HEX文件转储内存区域
|
|
||||||
xfel dump <address> <length> - 转储内存区域并输出
|
|
||||||
xfel exec <address> - 调用函数地址
|
|
||||||
xfel read32 <address> - 从设备内存中读取 32 位值
|
|
||||||
xfel write32 <address> <value> - 向设备内存中写入 32 位值
|
|
||||||
xfel read <address> <length> <file> - 向文件写入内存
|
|
||||||
xfel write <address> <file> - 向内存写入文件
|
|
||||||
xfel reset - 使用看门狗重置设备
|
|
||||||
xfel sid - 显示sid信息
|
|
||||||
xfel jtag - 启用 jtag 调试
|
|
||||||
xfel ddr [type] - 初始化 DDR 控制器
|
|
||||||
xfel spinor - 检测 spi nor flash
|
|
||||||
xfel spinor erase - 擦除 spi nor flash
|
|
||||||
xfel spinor read <address> <length> <file> - 读取 spi nor flash 到文件
|
|
||||||
xfel spinor write <address> <file> - 将文件写入 spi nor flash
|
|
||||||
xfel spinand - 检测 spi nand flash
|
|
||||||
xfel spinand erase - 擦除 spi nand flash
|
|
||||||
xfel spinand read <address> <length> <file> - 读取 spi nand flash 到文件
|
|
||||||
xfel spinand write <address> <file> - 将文件写入 spi nand flash
|
|
||||||
xfel spinand splwrite <split-size> <address> <file> - 使用拆分支持将文件写入 spi nand flash
|
|
||||||
```
|
|
||||||
|
|
||||||
# 编译安装
|
# 编译安装
|
||||||
|
|
||||||
@ -111,26 +109,6 @@ make
|
|||||||
sudo make install
|
sudo make install
|
||||||
```
|
```
|
||||||
|
|
||||||
## macOS
|
|
||||||
|
|
||||||
?> _TODO_ Add macOS ARM support
|
|
||||||
|
|
||||||
在开始之前,请先安装完成`Command Line Tools`.
|
|
||||||
|
|
||||||
使用 [brew](https://brew.sh/) 安装`libusb` 依赖。
|
|
||||||
|
|
||||||
```shell
|
|
||||||
brew install libusb
|
|
||||||
```
|
|
||||||
|
|
||||||
然后在程序根目录输入`make`就编译完成了。
|
|
||||||
|
|
||||||
```shell
|
|
||||||
cd xfel
|
|
||||||
make
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## Window
|
## Window
|
||||||
|
|
||||||
Windows 采用交叉编译方法,在 Ubuntu 中安装交叉编译工具链:
|
Windows 采用交叉编译方法,在 Ubuntu 中安装交叉编译工具链:
|
||||||
@ -160,6 +138,33 @@ CROSS=i686-w64-mingw32- make
|
|||||||
|
|
||||||
对于交叉编译64位Windows程序,您可以使用 `x86_64-w64-mingw32-` 代替上面的 `i686-w64-mingw32`。
|
对于交叉编译64位Windows程序,您可以使用 `x86_64-w64-mingw32-` 代替上面的 `i686-w64-mingw32`。
|
||||||
|
|
||||||
|
|
||||||
|
## macOS
|
||||||
|
|
||||||
|
?> _TODO_ Add macOS ARM support
|
||||||
|
|
||||||
|
在开始之前,请先安装完成`Command Line Tools`.
|
||||||
|
|
||||||
|
使用 [brew](https://brew.sh/) 安装`libusb` 依赖。
|
||||||
|
|
||||||
|
```shell
|
||||||
|
brew install libusb
|
||||||
|
```
|
||||||
|
|
||||||
|
然后在程序根目录输入`make`就编译完成了。
|
||||||
|
|
||||||
|
```shell
|
||||||
|
cd xfel
|
||||||
|
make
|
||||||
|
```
|
||||||
|
|
||||||
|
# 下载安装
|
||||||
|
|
||||||
|
## Windows
|
||||||
|
|
||||||
|
在 [RELEASE](https://github.com/xboot/xfel/releases/latest) 找到预编译的Windows软件。
|
||||||
|
|
||||||
|
|
||||||
# 例子
|
# 例子
|
||||||
|
|
||||||
## F1C100s: 使用XEFL写入 U-Boot 并运行
|
## F1C100s: 使用XEFL写入 U-Boot 并运行
|
||||||
@ -170,13 +175,23 @@ xfel write 0x81700000 u-boot.bin # 将uboot写入0x81700000
|
|||||||
xfel exec 0x81700000 # 调用函数地址运行
|
xfel exec 0x81700000 # 调用函数地址运行
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## F1C200s: 向 SPI NAND 写入系统
|
||||||
|
```
|
||||||
|
xfel spinand
|
||||||
|
xfel spinand erase 0x000000 134217728
|
||||||
|
xfel spinand write 0x000000 u-boot-sunxi-with-nand-spl.bin
|
||||||
|
xfel spinand write 0x80000 splash.bmp
|
||||||
|
xfel spinand write 0x100000 kernel.itb
|
||||||
|
xfel spinand write 0x600000 rootfs.squashfs
|
||||||
|
```
|
||||||
|
|
||||||
## F133: 使用XEFL写入 OpenSBI 并运行
|
## F133: 使用XEFL写入 OpenSBI 并运行
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
xfel ddr ddr2 # 使用ddr2方式初始化DDR控制器
|
xfel ddr f133 # 初始化F133 DDR控制器
|
||||||
xfel write 0x80200000 opensbi.bin # 将opensbi写入0x80200000
|
xfel write 0x80200000 opensbi.bin # 将opensbi写入0x80200000
|
||||||
xfel exec 0x80200000 # 调用函数地址运行
|
xfel exec 0x80200000 # 调用函数地址运行
|
||||||
```
|
```
|
||||||
|
|
||||||
?> _TODO_ 还想添加其他例子? 请给我们提交 Pull Requests [https://github.com/xboot/xfel/pulls](https://github.com/xboot/xfel/pulls)
|
?> 还想添加其他例子? 请给我们提交 Pull Requests [https://github.com/xboot/xfel/pulls](https://github.com/xboot/xfel/pulls)
|
||||||
|
804
ecdsa256.c
Normal file
804
ecdsa256.c
Normal file
@ -0,0 +1,804 @@
|
|||||||
|
#include <ecdsa256.h>
|
||||||
|
|
||||||
|
#define ECDSA256_NUM_DIGITS (ECDSA256_BYTES / 8)
|
||||||
|
#define MAX_RETRY (16)
|
||||||
|
|
||||||
|
struct ecdsa256_uint128_t {
|
||||||
|
uint64_t m_low;
|
||||||
|
uint64_t m_high;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ecdsa256_point_t {
|
||||||
|
uint64_t x[ECDSA256_NUM_DIGITS];
|
||||||
|
uint64_t y[ECDSA256_NUM_DIGITS];
|
||||||
|
};
|
||||||
|
|
||||||
|
static uint64_t curve_p[ECDSA256_NUM_DIGITS] = { 0xFFFFFFFFFFFFFFFFull, 0x00000000FFFFFFFFull, 0x0000000000000000ull, 0xFFFFFFFF00000001ull };
|
||||||
|
static uint64_t curve_b[ECDSA256_NUM_DIGITS] = { 0x3BCE3C3E27D2604Bull, 0x651D06B0CC53B0F6ull, 0xB3EBBD55769886BCull, 0x5AC635D8AA3A93E7ull };
|
||||||
|
static uint64_t curve_n[ECDSA256_NUM_DIGITS] = { 0xF3B9CAC2FC632551ull, 0xBCE6FAADA7179E84ull, 0xFFFFFFFFFFFFFFFFull, 0xFFFFFFFF00000000ull };
|
||||||
|
static struct ecdsa256_point_t curve_g = { { 0xF4A13945D898C296ull, 0x77037D812DEB33A0ull, 0xF8BCE6E563A440F2ull, 0x6B17D1F2E12C4247ull }, { 0xCBB6406837BF51F5ull, 0x2BCE33576B315ECEull, 0x8EE7EB4A7C0F9E16ull, 0x4FE342E2FE1A7F9Bull } };
|
||||||
|
|
||||||
|
static int get_random_number(uint64_t * vli)
|
||||||
|
{
|
||||||
|
uint64_t v;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i = 0; i < ECDSA256_NUM_DIGITS; i++)
|
||||||
|
{
|
||||||
|
v = (uint64_t)(rand() & 0xffff) << 0;
|
||||||
|
v |= (uint64_t)(rand() & 0xffff) << 16;
|
||||||
|
v |= (uint64_t)(rand() & 0xffff) << 32;
|
||||||
|
v |= (uint64_t)(rand() & 0xffff) << 48;
|
||||||
|
vli[i] = v;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void vli_clear(uint64_t * vli)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i = 0; i < ECDSA256_NUM_DIGITS; i++)
|
||||||
|
vli[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int vli_iszero(uint64_t * vli)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i = 0; i < ECDSA256_NUM_DIGITS; i++)
|
||||||
|
{
|
||||||
|
if(vli[i])
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint64_t vli_testbit(uint64_t * vli, unsigned int bit)
|
||||||
|
{
|
||||||
|
return (vli[bit / 64] & ((uint64_t)1 << (bit % 64)));
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned int vli_numdigits(uint64_t * vli)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i = ECDSA256_NUM_DIGITS - 1; i >= 0 && vli[i] == 0; --i);
|
||||||
|
return (i + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned int vli_numbits(uint64_t * vli)
|
||||||
|
{
|
||||||
|
uint64_t digit;
|
||||||
|
unsigned int i;
|
||||||
|
unsigned int n = vli_numdigits(vli);
|
||||||
|
|
||||||
|
if(n == 0)
|
||||||
|
return 0;
|
||||||
|
digit = vli[n - 1];
|
||||||
|
for(i = 0; digit; i++)
|
||||||
|
digit >>= 1;
|
||||||
|
return ((n - 1) * 64 + i);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void vli_set(uint64_t * dst, uint64_t * src)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i = 0; i < ECDSA256_NUM_DIGITS; i++)
|
||||||
|
dst[i] = src[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
static int vli_cmp(uint64_t * left, uint64_t * right)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i = ECDSA256_NUM_DIGITS - 1; i >= 0; --i)
|
||||||
|
{
|
||||||
|
if(left[i] > right[i])
|
||||||
|
return 1;
|
||||||
|
else if(left[i] < right[i])
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint64_t vli_lshift(uint64_t * result, uint64_t * in, unsigned int shift)
|
||||||
|
{
|
||||||
|
uint64_t carry = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i = 0; i < ECDSA256_NUM_DIGITS; i++)
|
||||||
|
{
|
||||||
|
uint64_t temp = in[i];
|
||||||
|
result[i] = (temp << shift) | carry;
|
||||||
|
carry = temp >> (64 - shift);
|
||||||
|
}
|
||||||
|
return carry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void vli_rshift1(uint64_t * vli)
|
||||||
|
{
|
||||||
|
uint64_t * end = vli;
|
||||||
|
uint64_t carry = 0;
|
||||||
|
|
||||||
|
vli += ECDSA256_NUM_DIGITS;
|
||||||
|
while(vli-- > end)
|
||||||
|
{
|
||||||
|
uint64_t temp = *vli;
|
||||||
|
*vli = (temp >> 1) | carry;
|
||||||
|
carry = temp << 63;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint64_t vli_add(uint64_t * result, uint64_t * left, uint64_t * right)
|
||||||
|
{
|
||||||
|
uint64_t carry = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i = 0; i < ECDSA256_NUM_DIGITS; i++)
|
||||||
|
{
|
||||||
|
uint64_t sum = left[i] + right[i] + carry;
|
||||||
|
if(sum != left[i])
|
||||||
|
carry = (sum < left[i]);
|
||||||
|
result[i] = sum;
|
||||||
|
}
|
||||||
|
return carry;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint64_t vli_sub(uint64_t * result, uint64_t * left, uint64_t * right)
|
||||||
|
{
|
||||||
|
uint64_t borrow = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i = 0; i < ECDSA256_NUM_DIGITS; i++)
|
||||||
|
{
|
||||||
|
uint64_t diff = left[i] - right[i] - borrow;
|
||||||
|
if(diff != left[i])
|
||||||
|
borrow = (diff > left[i]);
|
||||||
|
result[i] = diff;
|
||||||
|
}
|
||||||
|
return borrow;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct ecdsa256_uint128_t mul_64_64(uint64_t left, uint64_t right)
|
||||||
|
{
|
||||||
|
struct ecdsa256_uint128_t result;
|
||||||
|
|
||||||
|
uint64_t a0 = left & 0xffffffffull;
|
||||||
|
uint64_t a1 = left >> 32;
|
||||||
|
uint64_t b0 = right & 0xffffffffull;
|
||||||
|
uint64_t b1 = right >> 32;
|
||||||
|
uint64_t m0 = a0 * b0;
|
||||||
|
uint64_t m1 = a0 * b1;
|
||||||
|
uint64_t m2 = a1 * b0;
|
||||||
|
uint64_t m3 = a1 * b1;
|
||||||
|
|
||||||
|
m2 += (m0 >> 32);
|
||||||
|
m2 += m1;
|
||||||
|
if(m2 < m1)
|
||||||
|
m3 += 0x100000000ull;
|
||||||
|
result.m_low = (m0 & 0xffffffffull) | (m2 << 32);
|
||||||
|
result.m_high = m3 + (m2 >> 32);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct ecdsa256_uint128_t add_128_128(struct ecdsa256_uint128_t a, struct ecdsa256_uint128_t b)
|
||||||
|
{
|
||||||
|
struct ecdsa256_uint128_t result;
|
||||||
|
result.m_low = a.m_low + b.m_low;
|
||||||
|
result.m_high = a.m_high + b.m_high + (result.m_low < a.m_low);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void vli_mult(uint64_t * result, uint64_t * left, uint64_t * right)
|
||||||
|
{
|
||||||
|
struct ecdsa256_uint128_t r01 = { 0, 0 };
|
||||||
|
uint64_t r2 = 0;
|
||||||
|
unsigned int i, k;
|
||||||
|
|
||||||
|
for(k = 0; k < ECDSA256_NUM_DIGITS * 2 - 1; ++k)
|
||||||
|
{
|
||||||
|
unsigned int min = (k < ECDSA256_NUM_DIGITS ? 0 : (k + 1) - ECDSA256_NUM_DIGITS);
|
||||||
|
for(i = min; i <= k && i < ECDSA256_NUM_DIGITS; i++)
|
||||||
|
{
|
||||||
|
struct ecdsa256_uint128_t product = mul_64_64(left[i], right[k - i]);
|
||||||
|
r01 = add_128_128(r01, product);
|
||||||
|
r2 += (r01.m_high < product.m_high);
|
||||||
|
}
|
||||||
|
result[k] = r01.m_low;
|
||||||
|
r01.m_low = r01.m_high;
|
||||||
|
r01.m_high = r2;
|
||||||
|
r2 = 0;
|
||||||
|
}
|
||||||
|
result[ECDSA256_NUM_DIGITS * 2 - 1] = r01.m_low;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void vli_square(uint64_t *result, uint64_t *left)
|
||||||
|
{
|
||||||
|
struct ecdsa256_uint128_t r01 = { 0, 0 };
|
||||||
|
uint64_t r2 = 0;
|
||||||
|
unsigned int i, k;
|
||||||
|
|
||||||
|
for(k = 0; k < ECDSA256_NUM_DIGITS * 2 - 1; ++k)
|
||||||
|
{
|
||||||
|
unsigned int min = (k < ECDSA256_NUM_DIGITS ? 0 : (k + 1) - ECDSA256_NUM_DIGITS);
|
||||||
|
for(i = min; i <= k && i <= k - i; i++)
|
||||||
|
{
|
||||||
|
struct ecdsa256_uint128_t product = mul_64_64(left[i], left[k - i]);
|
||||||
|
if(i < k - i)
|
||||||
|
{
|
||||||
|
r2 += product.m_high >> 63;
|
||||||
|
product.m_high = (product.m_high << 1) | (product.m_low >> 63);
|
||||||
|
product.m_low <<= 1;
|
||||||
|
}
|
||||||
|
r01 = add_128_128(r01, product);
|
||||||
|
r2 += (r01.m_high < product.m_high);
|
||||||
|
}
|
||||||
|
result[k] = r01.m_low;
|
||||||
|
r01.m_low = r01.m_high;
|
||||||
|
r01.m_high = r2;
|
||||||
|
r2 = 0;
|
||||||
|
}
|
||||||
|
result[ECDSA256_NUM_DIGITS * 2 - 1] = r01.m_low;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void vli_modadd(uint64_t * result, uint64_t * left, uint64_t * right, uint64_t * mod)
|
||||||
|
{
|
||||||
|
uint64_t carry = vli_add(result, left, right);
|
||||||
|
if(carry || vli_cmp(result, mod) >= 0)
|
||||||
|
vli_sub(result, result, mod);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void vli_modsub(uint64_t * result, uint64_t * left, uint64_t * right, uint64_t * mod)
|
||||||
|
{
|
||||||
|
uint64_t borrow = vli_sub(result, left, right);
|
||||||
|
if(borrow)
|
||||||
|
vli_add(result, result, mod);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void vli_mmod_fast(uint64_t * result, uint64_t * product)
|
||||||
|
{
|
||||||
|
uint64_t tmp[ECDSA256_NUM_DIGITS];
|
||||||
|
int carry;
|
||||||
|
|
||||||
|
vli_set(result, product);
|
||||||
|
|
||||||
|
tmp[0] = 0;
|
||||||
|
tmp[1] = product[5] & 0xffffffff00000000ull;
|
||||||
|
tmp[2] = product[6];
|
||||||
|
tmp[3] = product[7];
|
||||||
|
carry = vli_lshift(tmp, tmp, 1);
|
||||||
|
carry += vli_add(result, result, tmp);
|
||||||
|
|
||||||
|
tmp[1] = product[6] << 32;
|
||||||
|
tmp[2] = (product[6] >> 32) | (product[7] << 32);
|
||||||
|
tmp[3] = product[7] >> 32;
|
||||||
|
carry += vli_lshift(tmp, tmp, 1);
|
||||||
|
carry += vli_add(result, result, tmp);
|
||||||
|
|
||||||
|
tmp[0] = product[4];
|
||||||
|
tmp[1] = product[5] & 0xffffffff;
|
||||||
|
tmp[2] = 0;
|
||||||
|
tmp[3] = product[7];
|
||||||
|
carry += vli_add(result, result, tmp);
|
||||||
|
|
||||||
|
tmp[0] = (product[4] >> 32) | (product[5] << 32);
|
||||||
|
tmp[1] = (product[5] >> 32) | (product[6] & 0xffffffff00000000ull);
|
||||||
|
tmp[2] = product[7];
|
||||||
|
tmp[3] = (product[6] >> 32) | (product[4] << 32);
|
||||||
|
carry += vli_add(result, result, tmp);
|
||||||
|
|
||||||
|
tmp[0] = (product[5] >> 32) | (product[6] << 32);
|
||||||
|
tmp[1] = (product[6] >> 32);
|
||||||
|
tmp[2] = 0;
|
||||||
|
tmp[3] = (product[4] & 0xffffffff) | (product[5] << 32);
|
||||||
|
carry -= vli_sub(result, result, tmp);
|
||||||
|
|
||||||
|
tmp[0] = product[6];
|
||||||
|
tmp[1] = product[7];
|
||||||
|
tmp[2] = 0;
|
||||||
|
tmp[3] = (product[4] >> 32) | (product[5] & 0xffffffff00000000ull);
|
||||||
|
carry -= vli_sub(result, result, tmp);
|
||||||
|
|
||||||
|
tmp[0] = (product[6] >> 32) | (product[7] << 32);
|
||||||
|
tmp[1] = (product[7] >> 32) | (product[4] << 32);
|
||||||
|
tmp[2] = (product[4] >> 32) | (product[5] << 32);
|
||||||
|
tmp[3] = (product[6] << 32);
|
||||||
|
carry -= vli_sub(result, result, tmp);
|
||||||
|
|
||||||
|
tmp[0] = product[7];
|
||||||
|
tmp[1] = product[4] & 0xffffffff00000000ull;
|
||||||
|
tmp[2] = product[5];
|
||||||
|
tmp[3] = product[6] & 0xffffffff00000000ull;
|
||||||
|
carry -= vli_sub(result, result, tmp);
|
||||||
|
|
||||||
|
if(carry < 0)
|
||||||
|
{
|
||||||
|
do
|
||||||
|
{
|
||||||
|
carry += vli_add(result, result, curve_p);
|
||||||
|
} while(carry < 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while(carry || vli_cmp(curve_p, result) != 1)
|
||||||
|
{
|
||||||
|
carry -= vli_sub(result, result, curve_p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void vli_modMult_fast(uint64_t * result, uint64_t * left, uint64_t * right)
|
||||||
|
{
|
||||||
|
uint64_t product[2 * ECDSA256_NUM_DIGITS];
|
||||||
|
vli_mult(product, left, right);
|
||||||
|
vli_mmod_fast(result, product);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void vli_modSquare_fast(uint64_t * result, uint64_t * left)
|
||||||
|
{
|
||||||
|
uint64_t product[2 * ECDSA256_NUM_DIGITS];
|
||||||
|
vli_square(product, left);
|
||||||
|
vli_mmod_fast(result, product);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void vli_modinv(uint64_t * result, uint64_t * input, uint64_t * mod)
|
||||||
|
{
|
||||||
|
uint64_t a[ECDSA256_NUM_DIGITS], b[ECDSA256_NUM_DIGITS], u[ECDSA256_NUM_DIGITS], v[ECDSA256_NUM_DIGITS];
|
||||||
|
uint64_t carry;
|
||||||
|
int cmpresult;
|
||||||
|
|
||||||
|
if(vli_iszero(input))
|
||||||
|
{
|
||||||
|
vli_clear(result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
vli_set(a, input);
|
||||||
|
vli_set(b, mod);
|
||||||
|
vli_clear(u);
|
||||||
|
u[0] = 1;
|
||||||
|
vli_clear(v);
|
||||||
|
|
||||||
|
while((cmpresult = vli_cmp(a, b)) != 0)
|
||||||
|
{
|
||||||
|
carry = 0;
|
||||||
|
if(!(a[0] & 1))
|
||||||
|
{
|
||||||
|
vli_rshift1(a);
|
||||||
|
if(u[0] & 1)
|
||||||
|
carry = vli_add(u, u, mod);
|
||||||
|
vli_rshift1(u);
|
||||||
|
if(carry)
|
||||||
|
u[ECDSA256_NUM_DIGITS - 1] |= 0x8000000000000000ull;
|
||||||
|
}
|
||||||
|
else if(!(b[0] & 1))
|
||||||
|
{
|
||||||
|
vli_rshift1(b);
|
||||||
|
if(v[0] & 1)
|
||||||
|
carry = vli_add(v, v, mod);
|
||||||
|
vli_rshift1(v);
|
||||||
|
if(carry)
|
||||||
|
v[ECDSA256_NUM_DIGITS - 1] |= 0x8000000000000000ull;
|
||||||
|
}
|
||||||
|
else if(cmpresult > 0)
|
||||||
|
{
|
||||||
|
vli_sub(a, a, b);
|
||||||
|
vli_rshift1(a);
|
||||||
|
if(vli_cmp(u, v) < 0)
|
||||||
|
vli_add(u, u, mod);
|
||||||
|
vli_sub(u, u, v);
|
||||||
|
if(u[0] & 1)
|
||||||
|
carry = vli_add(u, u, mod);
|
||||||
|
vli_rshift1(u);
|
||||||
|
if(carry)
|
||||||
|
u[ECDSA256_NUM_DIGITS - 1] |= 0x8000000000000000ull;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vli_sub(b, b, a);
|
||||||
|
vli_rshift1(b);
|
||||||
|
if(vli_cmp(v, u) < 0)
|
||||||
|
vli_add(v, v, mod);
|
||||||
|
vli_sub(v, v, u);
|
||||||
|
if(v[0] & 1)
|
||||||
|
carry = vli_add(v, v, mod);
|
||||||
|
vli_rshift1(v);
|
||||||
|
if(carry)
|
||||||
|
v[ECDSA256_NUM_DIGITS - 1] |= 0x8000000000000000ull;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vli_set(result, u);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int eccpoint_iszero(struct ecdsa256_point_t * point)
|
||||||
|
{
|
||||||
|
return (vli_iszero(point->x) && vli_iszero(point->y));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void eccpoint_double_jacobian(uint64_t * x1, uint64_t * y1, uint64_t * z1)
|
||||||
|
{
|
||||||
|
uint64_t t4[ECDSA256_NUM_DIGITS];
|
||||||
|
uint64_t t5[ECDSA256_NUM_DIGITS];
|
||||||
|
|
||||||
|
if(vli_iszero(z1))
|
||||||
|
return;
|
||||||
|
vli_modSquare_fast(t4, y1);
|
||||||
|
vli_modMult_fast(t5, x1, t4);
|
||||||
|
vli_modSquare_fast(t4, t4);
|
||||||
|
vli_modMult_fast(y1, y1, z1);
|
||||||
|
vli_modSquare_fast(z1, z1);
|
||||||
|
vli_modadd(x1, x1, z1, curve_p);
|
||||||
|
vli_modadd(z1, z1, z1, curve_p);
|
||||||
|
vli_modsub(z1, x1, z1, curve_p);
|
||||||
|
vli_modMult_fast(x1, x1, z1);
|
||||||
|
vli_modadd(z1, x1, x1, curve_p);
|
||||||
|
vli_modadd(x1, x1, z1, curve_p);
|
||||||
|
if(vli_testbit(x1, 0))
|
||||||
|
{
|
||||||
|
uint64_t carry = vli_add(x1, x1, curve_p);
|
||||||
|
vli_rshift1(x1);
|
||||||
|
x1[ECDSA256_NUM_DIGITS - 1] |= carry << 63;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vli_rshift1(x1);
|
||||||
|
}
|
||||||
|
vli_modSquare_fast(z1, x1);
|
||||||
|
vli_modsub(z1, z1, t5, curve_p);
|
||||||
|
vli_modsub(z1, z1, t5, curve_p);
|
||||||
|
vli_modsub(t5, t5, z1, curve_p);
|
||||||
|
vli_modMult_fast(x1, x1, t5);
|
||||||
|
vli_modsub(t4, x1, t4, curve_p);
|
||||||
|
vli_set(x1, z1);
|
||||||
|
vli_set(z1, y1);
|
||||||
|
vli_set(y1, t4);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void apply_z(uint64_t * x1, uint64_t * y1, uint64_t * z)
|
||||||
|
{
|
||||||
|
uint64_t t1[ECDSA256_NUM_DIGITS];
|
||||||
|
|
||||||
|
vli_modSquare_fast(t1, z);
|
||||||
|
vli_modMult_fast(x1, x1, t1);
|
||||||
|
vli_modMult_fast(t1, t1, z);
|
||||||
|
vli_modMult_fast(y1, y1, t1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void xycz_initial_double(uint64_t * x1, uint64_t * y1, uint64_t * x2, uint64_t * y2, uint64_t * initialz)
|
||||||
|
{
|
||||||
|
uint64_t z[ECDSA256_NUM_DIGITS];
|
||||||
|
|
||||||
|
vli_set(x2, x1);
|
||||||
|
vli_set(y2, y1);
|
||||||
|
vli_clear(z);
|
||||||
|
z[0] = 1;
|
||||||
|
if(initialz)
|
||||||
|
vli_set(z, initialz);
|
||||||
|
apply_z(x1, y1, z);
|
||||||
|
eccpoint_double_jacobian(x1, y1, z);
|
||||||
|
apply_z(x2, y2, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void xycz_add(uint64_t * x1, uint64_t * y1, uint64_t * x2, uint64_t * y2)
|
||||||
|
{
|
||||||
|
uint64_t t5[ECDSA256_NUM_DIGITS];
|
||||||
|
|
||||||
|
vli_modsub(t5, x2, x1, curve_p);
|
||||||
|
vli_modSquare_fast(t5, t5);
|
||||||
|
vli_modMult_fast(x1, x1, t5);
|
||||||
|
vli_modMult_fast(x2, x2, t5);
|
||||||
|
vli_modsub(y2, y2, y1, curve_p);
|
||||||
|
vli_modSquare_fast(t5, y2);
|
||||||
|
vli_modsub(t5, t5, x1, curve_p);
|
||||||
|
vli_modsub(t5, t5, x2, curve_p);
|
||||||
|
vli_modsub(x2, x2, x1, curve_p);
|
||||||
|
vli_modMult_fast(y1, y1, x2);
|
||||||
|
vli_modsub(x2, x1, t5, curve_p);
|
||||||
|
vli_modMult_fast(y2, y2, x2);
|
||||||
|
vli_modsub(y2, y2, y1, curve_p);
|
||||||
|
vli_set(x2, t5);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void xycz_addc(uint64_t * x1, uint64_t * y1, uint64_t * x2, uint64_t * y2)
|
||||||
|
{
|
||||||
|
uint64_t t5[ECDSA256_NUM_DIGITS];
|
||||||
|
uint64_t t6[ECDSA256_NUM_DIGITS];
|
||||||
|
uint64_t t7[ECDSA256_NUM_DIGITS];
|
||||||
|
|
||||||
|
vli_modsub(t5, x2, x1, curve_p);
|
||||||
|
vli_modSquare_fast(t5, t5);
|
||||||
|
vli_modMult_fast(x1, x1, t5);
|
||||||
|
vli_modMult_fast(x2, x2, t5);
|
||||||
|
vli_modadd(t5, y2, y1, curve_p);
|
||||||
|
vli_modsub(y2, y2, y1, curve_p);
|
||||||
|
vli_modsub(t6, x2, x1, curve_p);
|
||||||
|
vli_modMult_fast(y1, y1, t6);
|
||||||
|
vli_modadd(t6, x1, x2, curve_p);
|
||||||
|
vli_modSquare_fast(x2, y2);
|
||||||
|
vli_modsub(x2, x2, t6, curve_p);
|
||||||
|
vli_modsub(t7, x1, x2, curve_p);
|
||||||
|
vli_modMult_fast(y2, y2, t7);
|
||||||
|
vli_modsub(y2, y2, y1, curve_p);
|
||||||
|
vli_modSquare_fast(t7, t5);
|
||||||
|
vli_modsub(t7, t7, t6, curve_p);
|
||||||
|
vli_modsub(t6, t7, x1, curve_p);
|
||||||
|
vli_modMult_fast(t6, t6, t5);
|
||||||
|
vli_modsub(y1, t6, y1, curve_p);
|
||||||
|
vli_set(x1, t7);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void eccpoint_mult(struct ecdsa256_point_t * result, struct ecdsa256_point_t * point, uint64_t * scalar, uint64_t * initialz)
|
||||||
|
{
|
||||||
|
uint64_t Rx[2][ECDSA256_NUM_DIGITS];
|
||||||
|
uint64_t Ry[2][ECDSA256_NUM_DIGITS];
|
||||||
|
uint64_t z[ECDSA256_NUM_DIGITS];
|
||||||
|
int i, nb;
|
||||||
|
|
||||||
|
vli_set(Rx[1], point->x);
|
||||||
|
vli_set(Ry[1], point->y);
|
||||||
|
xycz_initial_double(Rx[1], Ry[1], Rx[0], Ry[0], initialz);
|
||||||
|
for(i = vli_numbits(scalar) - 2; i > 0; --i)
|
||||||
|
{
|
||||||
|
nb = !vli_testbit(scalar, i);
|
||||||
|
xycz_addc(Rx[1 - nb], Ry[1 - nb], Rx[nb], Ry[nb]);
|
||||||
|
xycz_add(Rx[nb], Ry[nb], Rx[1 - nb], Ry[1 - nb]);
|
||||||
|
}
|
||||||
|
nb = !vli_testbit(scalar, 0);
|
||||||
|
xycz_addc(Rx[1 - nb], Ry[1 - nb], Rx[nb], Ry[nb]);
|
||||||
|
vli_modsub(z, Rx[1], Rx[0], curve_p);
|
||||||
|
vli_modMult_fast(z, z, Ry[1 - nb]);
|
||||||
|
vli_modMult_fast(z, z, point->x);
|
||||||
|
vli_modinv(z, z, curve_p);
|
||||||
|
vli_modMult_fast(z, z, point->y);
|
||||||
|
vli_modMult_fast(z, z, Rx[1 - nb]);
|
||||||
|
xycz_add(Rx[nb], Ry[nb], Rx[1 - nb], Ry[1 - nb]);
|
||||||
|
apply_z(Rx[0], Ry[0], z);
|
||||||
|
vli_set(result->x, Rx[0]);
|
||||||
|
vli_set(result->y, Ry[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ecc_bytes2native(uint64_t * native, const uint8_t * bytes)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i = 0; i < ECDSA256_NUM_DIGITS; i++)
|
||||||
|
{
|
||||||
|
const uint8_t * digit = bytes + 8 * (ECDSA256_NUM_DIGITS - 1 - i);
|
||||||
|
native[i] = ((uint64_t)digit[0] << 56) | ((uint64_t)digit[1] << 48) | ((uint64_t)digit[2] << 40) | ((uint64_t)digit[3] << 32)
|
||||||
|
| ((uint64_t)digit[4] << 24) | ((uint64_t)digit[5] << 16) | ((uint64_t)digit[6] << 8) | (uint64_t)digit[7];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ecc_native2bytes(uint8_t * bytes, const uint64_t * native)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i = 0; i < ECDSA256_NUM_DIGITS; i++)
|
||||||
|
{
|
||||||
|
uint8_t *digit = bytes + 8 * (ECDSA256_NUM_DIGITS - 1 - i);
|
||||||
|
digit[0] = native[i] >> 56;
|
||||||
|
digit[1] = native[i] >> 48;
|
||||||
|
digit[2] = native[i] >> 40;
|
||||||
|
digit[3] = native[i] >> 32;
|
||||||
|
digit[4] = native[i] >> 24;
|
||||||
|
digit[5] = native[i] >> 16;
|
||||||
|
digit[6] = native[i] >> 8;
|
||||||
|
digit[7] = native[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mod_sqrt(uint64_t * a)
|
||||||
|
{
|
||||||
|
uint64_t p1[ECDSA256_NUM_DIGITS] = { 1 };
|
||||||
|
uint64_t result[ECDSA256_NUM_DIGITS] = { 1 };
|
||||||
|
int i;
|
||||||
|
|
||||||
|
vli_add(p1, curve_p, p1);
|
||||||
|
for(i = vli_numbits(p1) - 1; i > 1; --i)
|
||||||
|
{
|
||||||
|
vli_modSquare_fast(result, result);
|
||||||
|
if(vli_testbit(p1, i))
|
||||||
|
vli_modMult_fast(result, result, a);
|
||||||
|
}
|
||||||
|
vli_set(a, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ecc_point_decompress(struct ecdsa256_point_t * point, const uint8_t * compressed)
|
||||||
|
{
|
||||||
|
uint64_t _3[ECDSA256_NUM_DIGITS] = { 3 };
|
||||||
|
|
||||||
|
ecc_bytes2native(point->x, compressed + 1);
|
||||||
|
vli_modSquare_fast(point->y, point->x);
|
||||||
|
vli_modsub(point->y, point->y, _3, curve_p);
|
||||||
|
vli_modMult_fast(point->y, point->y, point->x);
|
||||||
|
vli_modadd(point->y, point->y, curve_b, curve_p);
|
||||||
|
mod_sqrt(point->y);
|
||||||
|
if((point->y[0] & 0x01) != (compressed[0] & 0x01))
|
||||||
|
vli_sub(point->y, curve_p, point->y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void vli_modmult(uint64_t * result, uint64_t * left, uint64_t * right, uint64_t * mod)
|
||||||
|
{
|
||||||
|
uint64_t product[2 * ECDSA256_NUM_DIGITS];
|
||||||
|
uint64_t modmultiple[2 * ECDSA256_NUM_DIGITS];
|
||||||
|
unsigned int digitshift, bitshift;
|
||||||
|
unsigned int productbits;
|
||||||
|
unsigned int modbits = vli_numbits(mod);
|
||||||
|
|
||||||
|
vli_mult(product, left, right);
|
||||||
|
productbits = vli_numbits(product + ECDSA256_NUM_DIGITS);
|
||||||
|
if(productbits)
|
||||||
|
productbits += ECDSA256_NUM_DIGITS * 64;
|
||||||
|
else
|
||||||
|
productbits = vli_numbits(product);
|
||||||
|
if(productbits < modbits)
|
||||||
|
{
|
||||||
|
vli_set(result, product);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
vli_clear(modmultiple);
|
||||||
|
vli_clear(modmultiple + ECDSA256_NUM_DIGITS);
|
||||||
|
digitshift = (productbits - modbits) / 64;
|
||||||
|
bitshift = (productbits - modbits) % 64;
|
||||||
|
if(bitshift)
|
||||||
|
modmultiple[digitshift + ECDSA256_NUM_DIGITS] = vli_lshift(modmultiple + digitshift, mod, bitshift);
|
||||||
|
else
|
||||||
|
vli_set(modmultiple + digitshift, mod);
|
||||||
|
vli_clear(result);
|
||||||
|
result[0] = 1;
|
||||||
|
while(productbits > ECDSA256_NUM_DIGITS * 64 || vli_cmp(modmultiple, mod) >= 0)
|
||||||
|
{
|
||||||
|
int l_cmp = vli_cmp(modmultiple + ECDSA256_NUM_DIGITS, product + ECDSA256_NUM_DIGITS);
|
||||||
|
if(l_cmp < 0 || (l_cmp == 0 && vli_cmp(modmultiple, product) <= 0))
|
||||||
|
{
|
||||||
|
if(vli_sub(product, product, modmultiple))
|
||||||
|
vli_sub(product + ECDSA256_NUM_DIGITS, product + ECDSA256_NUM_DIGITS, result);
|
||||||
|
vli_sub(product + ECDSA256_NUM_DIGITS, product + ECDSA256_NUM_DIGITS, modmultiple + ECDSA256_NUM_DIGITS);
|
||||||
|
}
|
||||||
|
uint64_t carry = (modmultiple[ECDSA256_NUM_DIGITS] & 0x01) << 63;
|
||||||
|
vli_rshift1(modmultiple + ECDSA256_NUM_DIGITS);
|
||||||
|
vli_rshift1(modmultiple);
|
||||||
|
modmultiple[ECDSA256_NUM_DIGITS - 1] |= carry;
|
||||||
|
--productbits;
|
||||||
|
}
|
||||||
|
vli_set(result, product);
|
||||||
|
}
|
||||||
|
|
||||||
|
static unsigned int umax(unsigned int a, unsigned int b)
|
||||||
|
{
|
||||||
|
return (a > b ? a : b);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ecdh256_keygen(const uint8_t * public, const uint8_t * private, uint8_t * shared)
|
||||||
|
{
|
||||||
|
struct ecdsa256_point_t lpublic;
|
||||||
|
struct ecdsa256_point_t product;
|
||||||
|
uint64_t lprivate[ECDSA256_NUM_DIGITS];
|
||||||
|
uint64_t lrandom[ECDSA256_NUM_DIGITS];
|
||||||
|
|
||||||
|
if(!get_random_number(lrandom))
|
||||||
|
return 0;
|
||||||
|
ecc_point_decompress(&lpublic, public);
|
||||||
|
ecc_bytes2native(lprivate, private);
|
||||||
|
eccpoint_mult(&product, &lpublic, lprivate, lrandom);
|
||||||
|
ecc_native2bytes(shared, product.x);
|
||||||
|
return !eccpoint_iszero(&product);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ecdsa256_keygen(uint8_t * public, uint8_t * private)
|
||||||
|
{
|
||||||
|
uint64_t lprivate[ECDSA256_NUM_DIGITS];
|
||||||
|
struct ecdsa256_point_t lpublic;
|
||||||
|
int retry = 0;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if(!get_random_number(lprivate) || (retry++ >= MAX_RETRY))
|
||||||
|
return 0;
|
||||||
|
if(vli_iszero(lprivate))
|
||||||
|
continue;
|
||||||
|
if(vli_cmp(curve_n, lprivate) != 1)
|
||||||
|
vli_sub(lprivate, lprivate, curve_n);
|
||||||
|
eccpoint_mult(&lpublic, &curve_g, lprivate, NULL);
|
||||||
|
} while(eccpoint_iszero(&lpublic));
|
||||||
|
ecc_native2bytes(private, lprivate);
|
||||||
|
ecc_native2bytes(public + 1, lpublic.x);
|
||||||
|
public[0] = 2 + (lpublic.y[0] & 0x01);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ecdsa256_sign(const uint8_t * private, const uint8_t * sha256, uint8_t * signature)
|
||||||
|
{
|
||||||
|
uint64_t k[ECDSA256_NUM_DIGITS];
|
||||||
|
uint64_t tmp[ECDSA256_NUM_DIGITS];
|
||||||
|
uint64_t s[ECDSA256_NUM_DIGITS];
|
||||||
|
struct ecdsa256_point_t p;
|
||||||
|
int retry = 0;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if(!get_random_number(k) || (retry++ >= MAX_RETRY))
|
||||||
|
return 0;
|
||||||
|
if(vli_iszero(k))
|
||||||
|
continue;
|
||||||
|
if(vli_cmp(curve_n, k) != 1)
|
||||||
|
vli_sub(k, k, curve_n);
|
||||||
|
eccpoint_mult(&p, &curve_g, k, NULL);
|
||||||
|
if(vli_cmp(curve_n, p.x) != 1)
|
||||||
|
vli_sub(p.x, p.x, curve_n);
|
||||||
|
} while(vli_iszero(p.x));
|
||||||
|
ecc_native2bytes(signature, p.x);
|
||||||
|
ecc_bytes2native(tmp, private);
|
||||||
|
vli_modmult(s, p.x, tmp, curve_n);
|
||||||
|
ecc_bytes2native(tmp, sha256);
|
||||||
|
vli_modadd(s, tmp, s, curve_n);
|
||||||
|
vli_modinv(k, k, curve_n);
|
||||||
|
vli_modmult(s, s, k, curve_n);
|
||||||
|
ecc_native2bytes(signature + ECDSA256_BYTES, s);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ecdsa256_verify(const uint8_t * public, const uint8_t * sha256, const uint8_t * signature)
|
||||||
|
{
|
||||||
|
uint64_t u1[ECDSA256_NUM_DIGITS], u2[ECDSA256_NUM_DIGITS];
|
||||||
|
uint64_t z[ECDSA256_NUM_DIGITS];
|
||||||
|
struct ecdsa256_point_t lpublic, sum;
|
||||||
|
uint64_t rx[ECDSA256_NUM_DIGITS];
|
||||||
|
uint64_t ry[ECDSA256_NUM_DIGITS];
|
||||||
|
uint64_t tx[ECDSA256_NUM_DIGITS];
|
||||||
|
uint64_t ty[ECDSA256_NUM_DIGITS];
|
||||||
|
uint64_t tz[ECDSA256_NUM_DIGITS];
|
||||||
|
uint64_t r[ECDSA256_NUM_DIGITS], s[ECDSA256_NUM_DIGITS];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
ecc_point_decompress(&lpublic, public);
|
||||||
|
ecc_bytes2native(r, signature);
|
||||||
|
ecc_bytes2native(s, signature + ECDSA256_BYTES);
|
||||||
|
if(vli_iszero(r) || vli_iszero(s))
|
||||||
|
return 0;
|
||||||
|
if(vli_cmp(curve_n, r) != 1 || vli_cmp(curve_n, s) != 1)
|
||||||
|
return 0;
|
||||||
|
vli_modinv(z, s, curve_n);
|
||||||
|
ecc_bytes2native(u1, sha256);
|
||||||
|
vli_modmult(u1, u1, z, curve_n);
|
||||||
|
vli_modmult(u2, r, z, curve_n);
|
||||||
|
vli_set(sum.x, lpublic.x);
|
||||||
|
vli_set(sum.y, lpublic.y);
|
||||||
|
vli_set(tx, curve_g.x);
|
||||||
|
vli_set(ty, curve_g.y);
|
||||||
|
vli_modsub(z, sum.x, tx, curve_p);
|
||||||
|
xycz_add(tx, ty, sum.x, sum.y);
|
||||||
|
vli_modinv(z, z, curve_p);
|
||||||
|
apply_z(sum.x, sum.y, z);
|
||||||
|
struct ecdsa256_point_t * points[4] = { NULL, &curve_g, &lpublic, &sum };
|
||||||
|
unsigned int numbits = umax(vli_numbits(u1), vli_numbits(u2));
|
||||||
|
struct ecdsa256_point_t * point = points[(!!vli_testbit(u1, numbits - 1)) | ((!!vli_testbit(u2, numbits - 1)) << 1)];
|
||||||
|
vli_set(rx, point->x);
|
||||||
|
vli_set(ry, point->y);
|
||||||
|
vli_clear(z);
|
||||||
|
z[0] = 1;
|
||||||
|
for(i = numbits - 2; i >= 0; --i)
|
||||||
|
{
|
||||||
|
eccpoint_double_jacobian(rx, ry, z);
|
||||||
|
int index = (!!vli_testbit(u1, i)) | ((!!vli_testbit(u2, i)) << 1);
|
||||||
|
struct ecdsa256_point_t * point = points[index];
|
||||||
|
if(point)
|
||||||
|
{
|
||||||
|
vli_set(tx, point->x);
|
||||||
|
vli_set(ty, point->y);
|
||||||
|
apply_z(tx, ty, z);
|
||||||
|
vli_modsub(tz, rx, tx, curve_p);
|
||||||
|
xycz_add(tx, ty, rx, ry);
|
||||||
|
vli_modMult_fast(z, z, tz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vli_modinv(z, z, curve_p);
|
||||||
|
apply_z(rx, ry, z);
|
||||||
|
if(vli_cmp(curve_n, rx) != 1)
|
||||||
|
vli_sub(rx, rx, curve_n);
|
||||||
|
return (vli_cmp(rx, r) == 0);
|
||||||
|
}
|
25
ecdsa256.h
Normal file
25
ecdsa256.h
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#ifndef __ECDSA256_H__
|
||||||
|
#define __ECDSA256_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <x.h>
|
||||||
|
|
||||||
|
#define ECDSA256_BYTES (32)
|
||||||
|
#define ECDSA256_SHARED_KEY_SIZE (ECDSA256_BYTES)
|
||||||
|
#define ECDSA256_PRIVATE_KEY_SIZE (ECDSA256_BYTES)
|
||||||
|
#define ECDSA256_PUBLIC_KEY_SIZE (ECDSA256_BYTES + 1)
|
||||||
|
#define ECDSA256_SIGNATURE_SIZE (ECDSA256_BYTES * 2)
|
||||||
|
|
||||||
|
int ecdh256_keygen(const uint8_t * public, const uint8_t * private, uint8_t * shared);
|
||||||
|
int ecdsa256_keygen(uint8_t * public, uint8_t * private);
|
||||||
|
int ecdsa256_sign(const uint8_t * private, const uint8_t * sha256, uint8_t * signature);
|
||||||
|
int ecdsa256_verify(const uint8_t * public, const uint8_t * sha256, const uint8_t * signature);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __ECDSA256_H__ */
|
29
fel.c
29
fel.c
@ -7,6 +7,8 @@ extern struct chip_t a23;
|
|||||||
extern struct chip_t a31;
|
extern struct chip_t a31;
|
||||||
extern struct chip_t a33_r16;
|
extern struct chip_t a33_r16;
|
||||||
extern struct chip_t a40i_r40;
|
extern struct chip_t a40i_r40;
|
||||||
|
extern struct chip_t a50;
|
||||||
|
extern struct chip_t a523_a527_t527;
|
||||||
extern struct chip_t a64;
|
extern struct chip_t a64;
|
||||||
extern struct chip_t a80;
|
extern struct chip_t a80;
|
||||||
extern struct chip_t a83t;
|
extern struct chip_t a83t;
|
||||||
@ -16,13 +18,20 @@ extern struct chip_t h2_h3;
|
|||||||
extern struct chip_t h5;
|
extern struct chip_t h5;
|
||||||
extern struct chip_t h6;
|
extern struct chip_t h6;
|
||||||
extern struct chip_t h616;
|
extern struct chip_t h616;
|
||||||
|
extern struct chip_t r128;
|
||||||
extern struct chip_t r328;
|
extern struct chip_t r328;
|
||||||
extern struct chip_t r329;
|
extern struct chip_t r329;
|
||||||
extern struct chip_t r528;
|
extern struct chip_t r528_t113;
|
||||||
extern struct chip_t t507;
|
extern struct chip_t r818;
|
||||||
extern struct chip_t v3s_s3;
|
extern struct chip_t v3s_s3;
|
||||||
extern struct chip_t v536;
|
extern struct chip_t v536;
|
||||||
extern struct chip_t v831;
|
extern struct chip_t v831;
|
||||||
|
extern struct chip_t v851_v853;
|
||||||
|
extern struct chip_t v821;
|
||||||
|
extern struct chip_t a733;
|
||||||
|
extern struct chip_t t536;
|
||||||
|
extern struct chip_t a537_a333;
|
||||||
|
|
||||||
|
|
||||||
static struct chip_t * chips[] = {
|
static struct chip_t * chips[] = {
|
||||||
&a10,
|
&a10,
|
||||||
@ -32,6 +41,8 @@ static struct chip_t * chips[] = {
|
|||||||
&a31,
|
&a31,
|
||||||
&a33_r16,
|
&a33_r16,
|
||||||
&a40i_r40,
|
&a40i_r40,
|
||||||
|
&a50,
|
||||||
|
&a523_a527_t527,
|
||||||
&a64,
|
&a64,
|
||||||
&a80,
|
&a80,
|
||||||
&a83t,
|
&a83t,
|
||||||
@ -41,13 +52,19 @@ static struct chip_t * chips[] = {
|
|||||||
&h5,
|
&h5,
|
||||||
&h6,
|
&h6,
|
||||||
&h616,
|
&h616,
|
||||||
|
&r128,
|
||||||
&r328,
|
&r328,
|
||||||
&r329,
|
&r329,
|
||||||
&r528,
|
&r528_t113,
|
||||||
&t507,
|
&r818,
|
||||||
&v3s_s3,
|
&v3s_s3,
|
||||||
&v536,
|
&v536,
|
||||||
&v831,
|
&v831,
|
||||||
|
&v851_v853,
|
||||||
|
&v821,
|
||||||
|
&a733,
|
||||||
|
&t536,
|
||||||
|
&a537_a333,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct usb_request_t {
|
struct usb_request_t {
|
||||||
@ -183,6 +200,10 @@ int fel_init(struct xfel_ctx_t * ctx)
|
|||||||
const struct libusb_interface * iface;
|
const struct libusb_interface * iface;
|
||||||
const struct libusb_interface_descriptor * setting;
|
const struct libusb_interface_descriptor * setting;
|
||||||
const struct libusb_endpoint_descriptor * ep;
|
const struct libusb_endpoint_descriptor * ep;
|
||||||
|
|
||||||
|
if(libusb_kernel_driver_active(ctx->hdl, 0))
|
||||||
|
libusb_detach_kernel_driver(ctx->hdl, 0);
|
||||||
|
|
||||||
if(libusb_claim_interface(ctx->hdl, 0) == 0)
|
if(libusb_claim_interface(ctx->hdl, 0) == 0)
|
||||||
{
|
{
|
||||||
if(libusb_get_active_config_descriptor(libusb_get_device(ctx->hdl), &config) == 0)
|
if(libusb_get_active_config_descriptor(libusb_get_device(ctx->hdl), &config) == 0)
|
||||||
|
37
fel.h
37
fel.h
@ -6,6 +6,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <x.h>
|
#include <x.h>
|
||||||
|
#include <misc.h>
|
||||||
#include <progress.h>
|
#include <progress.h>
|
||||||
|
|
||||||
struct xfel_ctx_t;
|
struct xfel_ctx_t;
|
||||||
@ -37,6 +38,7 @@ struct chip_t {
|
|||||||
int (*ddr)(struct xfel_ctx_t * ctx, const char * type);
|
int (*ddr)(struct xfel_ctx_t * ctx, const char * type);
|
||||||
int (*spi_init)(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t * swaplen, uint32_t * cmdlen);
|
int (*spi_init)(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t * swaplen, uint32_t * cmdlen);
|
||||||
int (*spi_run)(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen);
|
int (*spi_run)(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen);
|
||||||
|
int (*extra)(struct xfel_ctx_t * ctx, int argc, char * argv[]);
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -61,37 +63,58 @@ enum {
|
|||||||
|
|
||||||
static inline int fel_chip_detect(struct xfel_ctx_t * ctx, uint32_t id)
|
static inline int fel_chip_detect(struct xfel_ctx_t * ctx, uint32_t id)
|
||||||
{
|
{
|
||||||
return ctx->chip->detect(ctx, id);
|
if(ctx->chip->detect)
|
||||||
|
return ctx->chip->detect(ctx, id);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int fel_chip_reset(struct xfel_ctx_t * ctx)
|
static inline int fel_chip_reset(struct xfel_ctx_t * ctx)
|
||||||
{
|
{
|
||||||
return ctx->chip->reset(ctx);
|
if(ctx->chip->reset)
|
||||||
|
return ctx->chip->reset(ctx);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int fel_chip_sid(struct xfel_ctx_t * ctx, char * sid)
|
static inline int fel_chip_sid(struct xfel_ctx_t * ctx, char * sid)
|
||||||
{
|
{
|
||||||
return ctx->chip->sid(ctx, sid);
|
if(ctx->chip->sid)
|
||||||
|
return ctx->chip->sid(ctx, sid);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int fel_chip_jtag(struct xfel_ctx_t * ctx)
|
static inline int fel_chip_jtag(struct xfel_ctx_t * ctx)
|
||||||
{
|
{
|
||||||
return ctx->chip->jtag(ctx);
|
if(ctx->chip->jtag)
|
||||||
|
return ctx->chip->jtag(ctx);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int fel_chip_ddr(struct xfel_ctx_t * ctx, const char * type)
|
static inline int fel_chip_ddr(struct xfel_ctx_t * ctx, const char * type)
|
||||||
{
|
{
|
||||||
return ctx->chip->ddr(ctx, type);
|
if(ctx->chip->ddr)
|
||||||
|
return ctx->chip->ddr(ctx, type);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int fel_chip_spi_init(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t * swaplen, uint32_t * cmdlen)
|
static inline int fel_chip_spi_init(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t * swaplen, uint32_t * cmdlen)
|
||||||
{
|
{
|
||||||
return ctx->chip->spi_init(ctx, swapbuf, swaplen, cmdlen);
|
if(ctx->chip->spi_init)
|
||||||
|
return ctx->chip->spi_init(ctx, swapbuf, swaplen, cmdlen);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int fel_chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
|
static inline int fel_chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
|
||||||
{
|
{
|
||||||
return ctx->chip->spi_run(ctx, cbuf, clen);
|
if(ctx->chip->spi_run)
|
||||||
|
return ctx->chip->spi_run(ctx, cbuf, clen);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int fel_chip_extra(struct xfel_ctx_t * ctx, int argc, char * argv[])
|
||||||
|
{
|
||||||
|
if(ctx->chip->extra)
|
||||||
|
return ctx->chip->extra(ctx, argc, argv);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fel_init(struct xfel_ctx_t * ctx);
|
int fel_init(struct xfel_ctx_t * ctx);
|
||||||
|
221
main.c
221
main.c
@ -1,100 +1,27 @@
|
|||||||
#include <fel.h>
|
#include <fel.h>
|
||||||
|
#include <sha256.h>
|
||||||
|
#include <ecdsa256.h>
|
||||||
#include <spinor.h>
|
#include <spinor.h>
|
||||||
#include <spinand.h>
|
#include <spinand.h>
|
||||||
|
#include <libusb.h>
|
||||||
static uint64_t file_save(const char * filename, void * buf, uint64_t len)
|
|
||||||
{
|
|
||||||
FILE * out = fopen(filename, "wb");
|
|
||||||
int r;
|
|
||||||
if(!out)
|
|
||||||
{
|
|
||||||
perror("Failed to open output file");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
r = fwrite(buf, len, 1, out);
|
|
||||||
fclose(out);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void * file_load(const char * filename, uint64_t * len)
|
|
||||||
{
|
|
||||||
uint64_t offset = 0, bufsize = 8192;
|
|
||||||
char * buf = malloc(bufsize);
|
|
||||||
FILE * in;
|
|
||||||
if(strcmp(filename, "-") == 0)
|
|
||||||
in = stdin;
|
|
||||||
else
|
|
||||||
in = fopen(filename, "rb");
|
|
||||||
if(!in)
|
|
||||||
{
|
|
||||||
perror("Failed to open input file");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
while(1)
|
|
||||||
{
|
|
||||||
uint64_t len = bufsize - offset;
|
|
||||||
uint64_t n = fread(buf + offset, 1, len, in);
|
|
||||||
offset += n;
|
|
||||||
if(n < len)
|
|
||||||
break;
|
|
||||||
bufsize *= 2;
|
|
||||||
buf = realloc(buf, bufsize);
|
|
||||||
if(!buf)
|
|
||||||
{
|
|
||||||
perror("Failed to resize load_file() buffer");
|
|
||||||
exit(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(len)
|
|
||||||
*len = offset;
|
|
||||||
if(in != stdin)
|
|
||||||
fclose(in);
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void hexdump(uint32_t addr, void * buf, size_t len)
|
|
||||||
{
|
|
||||||
unsigned char * p = buf;
|
|
||||||
size_t i, j;
|
|
||||||
|
|
||||||
for(j = 0; j < len; j += 16)
|
|
||||||
{
|
|
||||||
printf("%08x: ", (uint32_t)(addr + j));
|
|
||||||
for(i = 0; i < 16; i++)
|
|
||||||
{
|
|
||||||
if(j + i < len)
|
|
||||||
printf("%02x ", p[j + i]);
|
|
||||||
else
|
|
||||||
printf(" ");
|
|
||||||
}
|
|
||||||
putchar(' ');
|
|
||||||
for(i = 0; i < 16; i++)
|
|
||||||
{
|
|
||||||
if(j + i >= len)
|
|
||||||
putchar(' ');
|
|
||||||
else
|
|
||||||
putchar(isprint(p[j + i]) ? p[j + i] : '.');
|
|
||||||
}
|
|
||||||
printf("\r\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void usage(void)
|
static void usage(void)
|
||||||
{
|
{
|
||||||
printf("xfel(v1.2.4) - https://github.com/xboot/xfel\r\n");
|
printf("xfel(v1.3.3) - https://github.com/xboot/xfel\r\n");
|
||||||
printf("usage:\r\n");
|
printf("usage:\r\n");
|
||||||
printf(" xfel version - Show chip version\r\n");
|
printf(" xfel version - Show chip version\r\n");
|
||||||
printf(" xfel hexdump <address> <length> - Dumps memory region in hex\r\n");
|
printf(" xfel hexdump <address> <length> - Dumps memory region in hex\r\n");
|
||||||
printf(" xfel dump <address> <length> - Binary memory dump to stdout\r\n");
|
printf(" xfel dump <address> <length> - Binary memory dump to stdout\r\n");
|
||||||
printf(" xfel exec <address> - Call function address\r\n");
|
|
||||||
printf(" xfel read32 <address> - Read 32-bits value from device memory\r\n");
|
printf(" xfel read32 <address> - Read 32-bits value from device memory\r\n");
|
||||||
printf(" xfel write32 <address> <value> - Write 32-bits value to device memory\r\n");
|
printf(" xfel write32 <address> <value> - Write 32-bits value to device memory\r\n");
|
||||||
printf(" xfel read <address> <length> <file> - Read memory to file\r\n");
|
printf(" xfel read <address> <length> <file> - Read memory to file\r\n");
|
||||||
printf(" xfel write <address> <file> - Write file to memory\r\n");
|
printf(" xfel write <address> <file> - Write file to memory\r\n");
|
||||||
|
printf(" xfel exec <address> - Call function address\r\n");
|
||||||
printf(" xfel reset - Reset device using watchdog\r\n");
|
printf(" xfel reset - Reset device using watchdog\r\n");
|
||||||
printf(" xfel sid - Show sid information\r\n");
|
printf(" xfel sid - Show sid information\r\n");
|
||||||
printf(" xfel jtag - Enable jtag debug\r\n");
|
printf(" xfel jtag - Enable jtag debug\r\n");
|
||||||
printf(" xfel ddr [type] - Initial ddr controller with optional type\r\n");
|
printf(" xfel ddr [type] - Initial ddr controller with optional type\r\n");
|
||||||
|
printf(" xfel sign <public-key> <private-key> <file> - Generate ecdsa256 signature file for sha256 of sid\r\n");
|
||||||
printf(" xfel spinor - Detect spi nor flash\r\n");
|
printf(" xfel spinor - Detect spi nor flash\r\n");
|
||||||
printf(" xfel spinor erase <address> <length> - Erase spi nor flash\r\n");
|
printf(" xfel spinor erase <address> <length> - Erase spi nor flash\r\n");
|
||||||
printf(" xfel spinor read <address> <length> <file> - Read spi nor flash to file\r\n");
|
printf(" xfel spinor read <address> <length> <file> - Read spi nor flash to file\r\n");
|
||||||
@ -104,11 +31,12 @@ static void usage(void)
|
|||||||
printf(" xfel spinand read <address> <length> <file> - Read spi nand flash to file\r\n");
|
printf(" xfel spinand read <address> <length> <file> - Read spi nand flash to file\r\n");
|
||||||
printf(" xfel spinand write <address> <file> - Write file to spi nand flash\r\n");
|
printf(" xfel spinand write <address> <file> - Write file to spi nand flash\r\n");
|
||||||
printf(" xfel spinand splwrite <split-size> <address> <file> - Write file to spi nand flash with split support\r\n");
|
printf(" xfel spinand splwrite <split-size> <address> <file> - Write file to spi nand flash with split support\r\n");
|
||||||
|
printf(" xfel extra [...] - The extra commands\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
struct xfel_ctx_t ctx;
|
struct xfel_ctx_t ctx = { 0 };
|
||||||
|
|
||||||
if(argc < 2)
|
if(argc < 2)
|
||||||
{
|
{
|
||||||
@ -124,11 +52,27 @@ int main(int argc, char * argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
libusb_init(NULL);
|
libusb_device ** list = NULL;
|
||||||
ctx.hdl = libusb_open_device_with_vid_pid(NULL, 0x1f3a, 0xefe8);
|
libusb_context * context = NULL;
|
||||||
|
libusb_init(&context);
|
||||||
|
int count = libusb_get_device_list(context, &list);
|
||||||
|
for(int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
libusb_device * device = list[i];
|
||||||
|
struct libusb_device_descriptor desc;
|
||||||
|
if(libusb_get_device_descriptor(device, &desc) != 0)
|
||||||
|
printf("ERROR: Can't get device list\r\n");
|
||||||
|
if((desc.idVendor == 0x1f3a) && (desc.idProduct == 0xefe8))
|
||||||
|
{
|
||||||
|
if(libusb_open(device, &ctx.hdl) != 0)
|
||||||
|
printf("ERROR: Can't connect to device\r\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!fel_init(&ctx))
|
if(!fel_init(&ctx))
|
||||||
{
|
{
|
||||||
printf("ERROR: Can't found any FEL device\r\n");
|
printf("ERROR: No FEL device found!\r\n");
|
||||||
if(ctx.hdl)
|
if(ctx.hdl)
|
||||||
libusb_close(ctx.hdl);
|
libusb_close(ctx.hdl);
|
||||||
libusb_exit(NULL);
|
libusb_exit(NULL);
|
||||||
@ -178,18 +122,6 @@ int main(int argc, char * argv[])
|
|||||||
else
|
else
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
else if(!strcmp(argv[1], "exec"))
|
|
||||||
{
|
|
||||||
argc -= 2;
|
|
||||||
argv += 2;
|
|
||||||
if(argc == 1)
|
|
||||||
{
|
|
||||||
uint32_t addr = strtoul(argv[0], NULL, 0);
|
|
||||||
fel_exec(&ctx, addr);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
usage();
|
|
||||||
}
|
|
||||||
else if(!strcmp(argv[1], "read32"))
|
else if(!strcmp(argv[1], "read32"))
|
||||||
{
|
{
|
||||||
argc -= 2;
|
argc -= 2;
|
||||||
@ -209,7 +141,7 @@ int main(int argc, char * argv[])
|
|||||||
if(argc == 2)
|
if(argc == 2)
|
||||||
{
|
{
|
||||||
uint32_t addr = strtoul(argv[0], NULL, 0);
|
uint32_t addr = strtoul(argv[0], NULL, 0);
|
||||||
size_t val = strtoul(argv[1], NULL, 0);
|
uint32_t val = strtoul(argv[1], NULL, 0);
|
||||||
fel_write32(&ctx, addr, val);
|
fel_write32(&ctx, addr, val);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -252,6 +184,18 @@ int main(int argc, char * argv[])
|
|||||||
else
|
else
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
else if(!strcmp(argv[1], "exec"))
|
||||||
|
{
|
||||||
|
argc -= 2;
|
||||||
|
argv += 2;
|
||||||
|
if(argc == 1)
|
||||||
|
{
|
||||||
|
uint32_t addr = strtoul(argv[0], NULL, 0);
|
||||||
|
fel_exec(&ctx, addr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
usage();
|
||||||
|
}
|
||||||
else if(!strcmp(argv[1], "reset"))
|
else if(!strcmp(argv[1], "reset"))
|
||||||
{
|
{
|
||||||
if(!fel_chip_reset(&ctx))
|
if(!fel_chip_reset(&ctx))
|
||||||
@ -274,11 +218,79 @@ int main(int argc, char * argv[])
|
|||||||
{
|
{
|
||||||
argc -= 2;
|
argc -= 2;
|
||||||
argv += 2;
|
argv += 2;
|
||||||
if(fel_chip_ddr(&ctx, (argc == 1) ? argv[0] : NULL))
|
if(!fel_chip_ddr(&ctx, (argc == 1) ? argv[0] : ""))
|
||||||
printf("Initial ddr controller succeeded\r\n");
|
|
||||||
else
|
|
||||||
printf("Failed to initial ddr controller\r\n");
|
printf("Failed to initial ddr controller\r\n");
|
||||||
}
|
}
|
||||||
|
else if(!strcmp(argv[1], "sign"))
|
||||||
|
{
|
||||||
|
argc -= 2;
|
||||||
|
argv += 2;
|
||||||
|
if(argc == 3)
|
||||||
|
{
|
||||||
|
uint8_t public_key[33] = {
|
||||||
|
0x03, 0xcf, 0xd1, 0x8e, 0x4a, 0x4b, 0x40, 0xd6,
|
||||||
|
0x52, 0x94, 0x48, 0xaa, 0x2d, 0xf8, 0xbb, 0xb6,
|
||||||
|
0x77, 0x12, 0x82, 0x58, 0xb8, 0xfb, 0xfc, 0x5b,
|
||||||
|
0x9e, 0x49, 0x2f, 0xbb, 0xba, 0x4e, 0x84, 0x83,
|
||||||
|
0x2f,
|
||||||
|
};
|
||||||
|
uint8_t private_key[32] = {
|
||||||
|
0xdc, 0x57, 0xb8, 0xa9, 0xe0, 0xe2, 0xb7, 0xf8,
|
||||||
|
0xb4, 0xc9, 0x29, 0xbd, 0x8d, 0xb2, 0x84, 0x4e,
|
||||||
|
0x53, 0xf0, 0x1f, 0x17, 0x1b, 0xbc, 0xdf, 0x6e,
|
||||||
|
0x62, 0x89, 0x08, 0xdb, 0xf2, 0xb2, 0xe6, 0xa9,
|
||||||
|
};
|
||||||
|
char * p = argv[0];
|
||||||
|
if(p && (strcmp(p, "") != 0) && (strlen(p) == sizeof(public_key) * 2))
|
||||||
|
{
|
||||||
|
for(int i = 0; i < sizeof(public_key); i++)
|
||||||
|
public_key[i] = hex_string(p, i * 2);
|
||||||
|
}
|
||||||
|
char * q = argv[1];
|
||||||
|
if(q && (strcmp(q, "") != 0) && (strlen(q) == sizeof(private_key) * 2))
|
||||||
|
{
|
||||||
|
for(int i = 0; i < sizeof(private_key); i++)
|
||||||
|
private_key[i] = hex_string(q, i * 2);
|
||||||
|
}
|
||||||
|
char sid[256];
|
||||||
|
uint8_t sha256[32];
|
||||||
|
uint8_t signature[64];
|
||||||
|
if(fel_chip_sid(&ctx, sid))
|
||||||
|
{
|
||||||
|
sha256_hash(sid, strlen(sid), sha256);
|
||||||
|
ecdsa256_sign(private_key, sha256, signature);
|
||||||
|
printf("Unique ID:\r\n\t");
|
||||||
|
printf("%s\r\n", sid);
|
||||||
|
printf("Sha256 digest:\r\n\t");
|
||||||
|
for(int i = 0; i < sizeof(sha256); i++)
|
||||||
|
printf("%02x", sha256[i]);
|
||||||
|
printf("\r\n");
|
||||||
|
printf("Ecdsa256 public key:\r\n\t");
|
||||||
|
for(int i = 0; i < sizeof(public_key); i++)
|
||||||
|
printf("%02x", public_key[i]);
|
||||||
|
printf("\r\n");
|
||||||
|
printf("Ecdsa256 private key:\r\n\t");
|
||||||
|
for(int i = 0; i < sizeof(private_key); i++)
|
||||||
|
printf("%02x", private_key[i]);
|
||||||
|
printf("\r\n");
|
||||||
|
printf("Ecdsa256 signature:\r\n\t");
|
||||||
|
for(int i = 0; i < sizeof(signature); i++)
|
||||||
|
printf("%02x", signature[i]);
|
||||||
|
printf("\r\n");
|
||||||
|
if(ecdsa256_verify(public_key, sha256, signature))
|
||||||
|
{
|
||||||
|
file_save(argv[2], signature, sizeof(signature));
|
||||||
|
printf("Ecdsa256 signature verify successed and saved to '%s'.\r\n", argv[2]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printf("Ecdsa256 signature verify failed, please check the ecdsa256 public and private key.\r\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printf("The '%s' chip don't support sid command\r\n", ctx.chip->name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
usage();
|
||||||
|
}
|
||||||
else if(!strcmp(argv[1], "spinor"))
|
else if(!strcmp(argv[1], "spinor"))
|
||||||
{
|
{
|
||||||
argc -= 2;
|
argc -= 2;
|
||||||
@ -295,7 +307,7 @@ int main(int argc, char * argv[])
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(!strcmp(argv[0], "erase") && (argc == 2))
|
if(!strcmp(argv[0], "erase") && (argc == 3))
|
||||||
{
|
{
|
||||||
argc -= 1;
|
argc -= 1;
|
||||||
argv += 1;
|
argv += 1;
|
||||||
@ -354,7 +366,7 @@ int main(int argc, char * argv[])
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(!strcmp(argv[0], "erase") && (argc == 2))
|
if(!strcmp(argv[0], "erase") && (argc == 3))
|
||||||
{
|
{
|
||||||
argc -= 1;
|
argc -= 1;
|
||||||
argv += 1;
|
argv += 1;
|
||||||
@ -412,6 +424,13 @@ int main(int argc, char * argv[])
|
|||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(!strcmp(argv[1], "extra"))
|
||||||
|
{
|
||||||
|
argc -= 2;
|
||||||
|
argv += 2;
|
||||||
|
if(!fel_chip_extra(&ctx, argc, argv))
|
||||||
|
printf("Not support any extra commands\r\n");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
usage();
|
usage();
|
||||||
if(ctx.hdl)
|
if(ctx.hdl)
|
||||||
|
100
misc.c
Normal file
100
misc.c
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
#include <misc.h>
|
||||||
|
|
||||||
|
uint64_t file_save(const char * filename, void * buf, uint64_t len)
|
||||||
|
{
|
||||||
|
FILE * out;
|
||||||
|
int r;
|
||||||
|
|
||||||
|
if(strcmp(filename, "-") == 0)
|
||||||
|
out = stdout;
|
||||||
|
else
|
||||||
|
out = fopen(filename, "wb");
|
||||||
|
if(!out)
|
||||||
|
{
|
||||||
|
perror("Failed to open output file");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
r = fwrite(buf, len, 1, out);
|
||||||
|
if(out != stdout)
|
||||||
|
fclose(out);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
void * file_load(const char * filename, uint64_t * len)
|
||||||
|
{
|
||||||
|
uint64_t offset = 0, bufsize = 8192;
|
||||||
|
char * buf = malloc(bufsize);
|
||||||
|
FILE * in;
|
||||||
|
if(strcmp(filename, "-") == 0)
|
||||||
|
in = stdin;
|
||||||
|
else
|
||||||
|
in = fopen(filename, "rb");
|
||||||
|
if(!in)
|
||||||
|
{
|
||||||
|
perror("Failed to open input file");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
uint64_t len = bufsize - offset;
|
||||||
|
uint64_t n = fread(buf + offset, 1, len, in);
|
||||||
|
offset += n;
|
||||||
|
if(n < len)
|
||||||
|
break;
|
||||||
|
bufsize *= 2;
|
||||||
|
buf = realloc(buf, bufsize);
|
||||||
|
if(!buf)
|
||||||
|
{
|
||||||
|
perror("Failed to resize load_file() buffer");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(len)
|
||||||
|
*len = offset;
|
||||||
|
if(in != stdin)
|
||||||
|
fclose(in);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned char hex_to_bin(char c)
|
||||||
|
{
|
||||||
|
if((c >= 'a') && (c <= 'f'))
|
||||||
|
return c - 'a' + 10;
|
||||||
|
if((c >= '0') && (c <= '9'))
|
||||||
|
return c - '0';
|
||||||
|
if((c >= 'A') && (c <= 'F'))
|
||||||
|
return c - 'A' + 10;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char hex_string(const char * s, int o)
|
||||||
|
{
|
||||||
|
return (hex_to_bin(s[o]) << 4) | hex_to_bin(s[o + 1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void hexdump(uint32_t addr, void * buf, size_t len)
|
||||||
|
{
|
||||||
|
unsigned char * p = buf;
|
||||||
|
size_t i, j;
|
||||||
|
|
||||||
|
for(j = 0; j < len; j += 16)
|
||||||
|
{
|
||||||
|
printf("%08x: ", (uint32_t)(addr + j));
|
||||||
|
for(i = 0; i < 16; i++)
|
||||||
|
{
|
||||||
|
if(j + i < len)
|
||||||
|
printf("%02x ", p[j + i]);
|
||||||
|
else
|
||||||
|
printf(" ");
|
||||||
|
}
|
||||||
|
putchar(' ');
|
||||||
|
for(i = 0; i < 16; i++)
|
||||||
|
{
|
||||||
|
if(j + i >= len)
|
||||||
|
putchar(' ');
|
||||||
|
else
|
||||||
|
putchar(isprint(p[j + i]) ? p[j + i] : '.');
|
||||||
|
}
|
||||||
|
printf("\r\n");
|
||||||
|
}
|
||||||
|
}
|
19
misc.h
Normal file
19
misc.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#ifndef __MISC_H__
|
||||||
|
#define __MISC_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <x.h>
|
||||||
|
|
||||||
|
uint64_t file_save(const char * filename, void * buf, uint64_t len);
|
||||||
|
void * file_load(const char * filename, uint64_t * len);
|
||||||
|
unsigned char hex_string(const char * s, int o);
|
||||||
|
void hexdump(uint32_t addr, void * buf, size_t len);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __MISC_H__ */
|
120
payloads/a523_a527_t527/jmp-arm64/Makefile
Normal file
120
payloads/a523_a527_t527/jmp-arm64/Makefile
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
#
|
||||||
|
# Top makefile
|
||||||
|
#
|
||||||
|
|
||||||
|
CROSS ?= arm-linux-gnueabihf-
|
||||||
|
NAME := jmp-arm64
|
||||||
|
|
||||||
|
#
|
||||||
|
# System environment variable.
|
||||||
|
#
|
||||||
|
ifeq ($(OS), Windows_NT)
|
||||||
|
HOSTOS := windows
|
||||||
|
else
|
||||||
|
ifneq (,$(findstring Linux, $(shell uname -a)))
|
||||||
|
HOSTOS := linux
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
#
|
||||||
|
# Load default variables.
|
||||||
|
#
|
||||||
|
ASFLAGS := -g -ggdb -Wall -O3
|
||||||
|
CFLAGS := -g -ggdb -Wall -O3
|
||||||
|
CXXFLAGS := -g -ggdb -Wall -O3
|
||||||
|
LDFLAGS := -T link.ld -nostdlib
|
||||||
|
ARFLAGS := -rcs
|
||||||
|
OCFLAGS := -v -O binary
|
||||||
|
ODFLAGS :=
|
||||||
|
MCFLAGS := -march=armv7-a -mtune=cortex-a7 -mfpu=vfpv4 -mfloat-abi=hard -marm -mno-thumb-interwork -mno-unaligned-access -fno-stack-protector
|
||||||
|
|
||||||
|
LIBDIRS :=
|
||||||
|
LIBS :=
|
||||||
|
INCDIRS :=
|
||||||
|
SRCDIRS :=
|
||||||
|
|
||||||
|
#
|
||||||
|
# Add external library
|
||||||
|
#
|
||||||
|
INCDIRS += include \
|
||||||
|
include/external
|
||||||
|
SRCDIRS += source \
|
||||||
|
source/external
|
||||||
|
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
OC := $(CROSS)objcopy
|
||||||
|
OD := $(CROSS)objdump
|
||||||
|
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
|
||||||
|
|
||||||
|
$(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)
|
6
payloads/a523_a527_t527/jmp-arm64/include/t527/reg-ccu.h
Normal file
6
payloads/a523_a527_t527/jmp-arm64/include/t527/reg-ccu.h
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#ifndef __T527_REG_CCU_H__
|
||||||
|
#define __T527_REG_CCU_H__
|
||||||
|
|
||||||
|
#define T527_CCU_BASE (0x02001000)
|
||||||
|
|
||||||
|
#endif /* __T527_REG_CCU_H__ */
|
122
payloads/a523_a527_t527/jmp-arm64/link.ld
Normal file
122
payloads/a523_a527_t527/jmp-arm64/link.ld
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
|
||||||
|
OUTPUT_ARCH(arm)
|
||||||
|
ENTRY(_start)
|
||||||
|
|
||||||
|
STACK_UND_SIZE = 0x010;
|
||||||
|
STACK_ABT_SIZE = 0x010;
|
||||||
|
STACK_IRQ_SIZE = 0x010;
|
||||||
|
STACK_FIQ_SIZE = 0x010;
|
||||||
|
STACK_SRV_SIZE = 0x400;
|
||||||
|
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
ram : org = 0x00020000, len = 0x00002000 /* 8 KB */
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.text :
|
||||||
|
{
|
||||||
|
PROVIDE(__image_start = .);
|
||||||
|
PROVIDE(__text_start = .);
|
||||||
|
.obj/source/start.o (.text)
|
||||||
|
.obj/source/sys-jmp-arm64.o (.text*)
|
||||||
|
*(.text*)
|
||||||
|
*(.glue*)
|
||||||
|
*(.note.gnu.build-id)
|
||||||
|
PROVIDE(__text_end = .);
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
.ARM.exidx ALIGN(8) :
|
||||||
|
{
|
||||||
|
PROVIDE (__exidx_start = .);
|
||||||
|
*(.ARM.exidx*)
|
||||||
|
PROVIDE (__exidx_end = .);
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
.ARM.extab ALIGN(8) :
|
||||||
|
{
|
||||||
|
PROVIDE (__extab_start = .);
|
||||||
|
*(.ARM.extab*)
|
||||||
|
PROVIDE (__extab_end = .);
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
.ksymtab ALIGN(16) :
|
||||||
|
{
|
||||||
|
PROVIDE(__ksymtab_start = .);
|
||||||
|
KEEP(*(.ksymtab.text))
|
||||||
|
PROVIDE(__ksymtab_end = .);
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
.romdisk ALIGN(8) :
|
||||||
|
{
|
||||||
|
PROVIDE(__romdisk_start = .);
|
||||||
|
KEEP(*(.romdisk))
|
||||||
|
PROVIDE(__romdisk_end = .);
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
.rodata ALIGN(8) :
|
||||||
|
{
|
||||||
|
PROVIDE(__rodata_start = .);
|
||||||
|
*(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*)))
|
||||||
|
PROVIDE(__rodata_end = .);
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
.data ALIGN(8) :
|
||||||
|
{
|
||||||
|
PROVIDE(__data_start = .);
|
||||||
|
*(.data*)
|
||||||
|
. = ALIGN(8);
|
||||||
|
PROVIDE(__data_end = .);
|
||||||
|
PROVIDE(__image_end = .);
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
.bss ALIGN(8) (NOLOAD) :
|
||||||
|
{
|
||||||
|
PROVIDE(__bss_start = .);
|
||||||
|
*(.bss*)
|
||||||
|
*(.sbss*)
|
||||||
|
*(COMMON)
|
||||||
|
. = ALIGN(8);
|
||||||
|
PROVIDE(__bss_end = .);
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
.stack ALIGN(8) (NOLOAD) :
|
||||||
|
{
|
||||||
|
PROVIDE(__stack_start = .);
|
||||||
|
PROVIDE(__stack_und_start = .);
|
||||||
|
. += STACK_UND_SIZE;
|
||||||
|
PROVIDE(__stack_und_end = .);
|
||||||
|
. = ALIGN(8);
|
||||||
|
PROVIDE(__stack_abt_start = .);
|
||||||
|
. += STACK_ABT_SIZE;
|
||||||
|
PROVIDE(__stack_abt_end = .);
|
||||||
|
. = ALIGN(8);
|
||||||
|
PROVIDE(__stack_irq_start = .);
|
||||||
|
. += STACK_IRQ_SIZE;
|
||||||
|
PROVIDE(__stack_irq_end = .);
|
||||||
|
. = ALIGN(8);
|
||||||
|
PROVIDE(__stack_fiq_start = .);
|
||||||
|
. += STACK_FIQ_SIZE;
|
||||||
|
PROVIDE(__stack_fiq_end = .);
|
||||||
|
. = ALIGN(8);
|
||||||
|
PROVIDE(__stack_srv_start = .);
|
||||||
|
. += STACK_SRV_SIZE;
|
||||||
|
PROVIDE(__stack_srv_end = .);
|
||||||
|
. = ALIGN(8);
|
||||||
|
PROVIDE(__stack_end = .);
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
.stab 0 : { *(.stab) }
|
||||||
|
.stabstr 0 : { *(.stabstr) }
|
||||||
|
.stab.excl 0 : { *(.stab.excl) }
|
||||||
|
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||||
|
.stab.index 0 : { *(.stab.index) }
|
||||||
|
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||||
|
.comment 0 : { *(.comment) }
|
||||||
|
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||||
|
.debug_info 0 : { *(.debug_info) }
|
||||||
|
.debug_line 0 : { *(.debug_line) }
|
||||||
|
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||||
|
.debug_aranges 0 : { *(.debug_aranges) }
|
||||||
|
}
|
69
payloads/a523_a527_t527/jmp-arm64/source/start.S
Normal file
69
payloads/a523_a527_t527/jmp-arm64/source/start.S
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/*
|
||||||
|
* start.S
|
||||||
|
*
|
||||||
|
* Copyright(c) 2007-2021 Jianjun Jiang <8192542@qq.com>
|
||||||
|
* Official site: http://xboot.org
|
||||||
|
* Mobile phone: +86-18665388956
|
||||||
|
* QQ: 8192542
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
.global _start
|
||||||
|
_start:
|
||||||
|
mov r0, #0
|
||||||
|
mcr p15, 0, r0, c8, c7, 0
|
||||||
|
mcr p15, 0, r0, c7, c5, 0
|
||||||
|
mcr p15, 0, r0, c7, c5, 6
|
||||||
|
mcr p15, 0, r0, c7, c10, 4
|
||||||
|
mcr p15, 0, r0, c7, c5, 4
|
||||||
|
b reset
|
||||||
|
|
||||||
|
_adr:
|
||||||
|
.word 0x40000000
|
||||||
|
|
||||||
|
reset:
|
||||||
|
ldr r0, =0x00047fe0
|
||||||
|
str sp, [r0, #0]
|
||||||
|
str lr, [r0, #4]
|
||||||
|
mrs lr, cpsr
|
||||||
|
str lr, [r0, #8]
|
||||||
|
mrc p15, 0, lr, c1, c0, 0
|
||||||
|
str lr, [r0, #12]
|
||||||
|
mrc p15, 0, lr, c12, c0, 0
|
||||||
|
str lr, [r0, #16]
|
||||||
|
mrc p15, 0, lr, c1, c0, 0
|
||||||
|
str lr, [r0, #20]
|
||||||
|
|
||||||
|
ldr r0, _adr
|
||||||
|
bl sys_jmp_to_arm64
|
||||||
|
|
||||||
|
ldr r0, =0x00047fe0
|
||||||
|
ldr sp, [r0, #0]
|
||||||
|
ldr lr, [r0, #4]
|
||||||
|
ldr r1, [r0, #20]
|
||||||
|
mcr p15, 0, r1, c1, c0, 0
|
||||||
|
ldr r1, [r0, #16]
|
||||||
|
mcr p15, 0, r1, c12, c0, 0
|
||||||
|
ldr r1, [r0, #12]
|
||||||
|
mcr p15, 0, r1, c1, c0, 0
|
||||||
|
ldr r1, [r0, #8]
|
||||||
|
msr cpsr, r1
|
||||||
|
bx lr
|
47
payloads/a523_a527_t527/jmp-arm64/source/sys-jmp-arm64.c
Normal file
47
payloads/a523_a527_t527/jmp-arm64/source/sys-jmp-arm64.c
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* sys-uart.c
|
||||||
|
*
|
||||||
|
* Copyright(c) 2007-2021 Jianjun Jiang <8192542@qq.com>
|
||||||
|
* Official site: http://xboot.org
|
||||||
|
* Mobile phone: +86-18665388956
|
||||||
|
* QQ: 8192542
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <xboot.h>
|
||||||
|
|
||||||
|
void sys_jmp_to_arm64(uint32_t val)
|
||||||
|
{
|
||||||
|
virtual_addr_t addr = 0x08000000;
|
||||||
|
|
||||||
|
write32(addr + 0x40, val);
|
||||||
|
write32(addr + 0x44, 0x0);
|
||||||
|
|
||||||
|
__asm__ __volatile__("mrc p15, 0, r2, c12, c0, 2");
|
||||||
|
__asm__ __volatile__("orr r2, r2, #(0x3 << 0)");
|
||||||
|
__asm__ __volatile__("dsb");
|
||||||
|
__asm__ __volatile__("mcr p15, 0, r2, c12, c0, 2");
|
||||||
|
__asm__ __volatile__("isb");
|
||||||
|
|
||||||
|
_loop:
|
||||||
|
__asm__ __volatile__("wfi");
|
||||||
|
goto _loop;
|
||||||
|
}
|
@ -2,12 +2,9 @@
|
|||||||
# Top makefile
|
# Top makefile
|
||||||
#
|
#
|
||||||
|
|
||||||
CROSS ?= ~/Xuantie-900-gcc-elf-newlib-x86_64-V2.0.3/bin/riscv64-unknown-elf-
|
CROSS ?= ~/Xuantie-900-gcc-elf-newlib-x86_64-V2.2.4/bin/riscv64-unknown-elf-
|
||||||
NAME := d1-ddr
|
NAME := d1-ddr
|
||||||
|
|
||||||
#
|
|
||||||
# System environment variable.
|
|
||||||
#
|
|
||||||
#
|
#
|
||||||
# System environment variable.
|
# System environment variable.
|
||||||
#
|
#
|
||||||
|
@ -2,12 +2,9 @@
|
|||||||
# Top makefile
|
# Top makefile
|
||||||
#
|
#
|
||||||
|
|
||||||
CROSS ?= ~/Xuantie-900-gcc-elf-newlib-x86_64-V2.0.3/bin/riscv64-unknown-elf-
|
CROSS ?= ~/Xuantie-900-gcc-elf-newlib-x86_64-V2.2.4/bin/riscv64-unknown-elf-
|
||||||
NAME := f133-ddr
|
NAME := f133-ddr
|
||||||
|
|
||||||
#
|
|
||||||
# System environment variable.
|
|
||||||
#
|
|
||||||
#
|
#
|
||||||
# System environment variable.
|
# System environment variable.
|
||||||
#
|
#
|
||||||
|
@ -2,12 +2,9 @@
|
|||||||
# Top makefile
|
# Top makefile
|
||||||
#
|
#
|
||||||
|
|
||||||
CROSS ?= ~/test/tina-d1-open/prebuilt/gcc/linux-x86/riscv/toolchain-thead-glibc/riscv64-glibc-gcc-thead_20200702/bin/riscv64-unknown-linux-gnu-
|
CROSS ?= ~/Xuantie-900-gcc-elf-newlib-x86_64-V2.2.4/bin/riscv64-unknown-elf-
|
||||||
NAME := jtag
|
NAME := jtag
|
||||||
|
|
||||||
#
|
|
||||||
# System environment variable.
|
|
||||||
#
|
|
||||||
#
|
#
|
||||||
# System environment variable.
|
# System environment variable.
|
||||||
#
|
#
|
||||||
|
120
payloads/d1_f133/read32/Makefile
Normal file
120
payloads/d1_f133/read32/Makefile
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
#
|
||||||
|
# Top makefile
|
||||||
|
#
|
||||||
|
|
||||||
|
CROSS ?= ~/Xuantie-900-gcc-elf-newlib-x86_64-V2.2.4/bin/riscv64-unknown-elf-
|
||||||
|
NAME := read32
|
||||||
|
|
||||||
|
#
|
||||||
|
# System environment variable.
|
||||||
|
#
|
||||||
|
ifeq ($(OS), Windows_NT)
|
||||||
|
HOSTOS := windows
|
||||||
|
else
|
||||||
|
ifneq (,$(findstring Linux, $(shell uname -a)))
|
||||||
|
HOSTOS := linux
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
#
|
||||||
|
# Load default variables.
|
||||||
|
#
|
||||||
|
ASFLAGS := -g -ggdb -Wall -O3 -ffreestanding
|
||||||
|
CFLAGS := -g -ggdb -Wall -O3 -ffreestanding
|
||||||
|
CXXFLAGS := -g -ggdb -Wall -O3 -ffreestanding
|
||||||
|
LDFLAGS := -T link.ld -nostdlib
|
||||||
|
ARFLAGS := -rcs
|
||||||
|
OCFLAGS := -v -O binary
|
||||||
|
ODFLAGS :=
|
||||||
|
MCFLAGS := -march=rv64gvxthead -mabi=lp64d -mcmodel=medany -fno-stack-protector
|
||||||
|
|
||||||
|
LIBDIRS :=
|
||||||
|
LIBS :=
|
||||||
|
INCDIRS :=
|
||||||
|
SRCDIRS :=
|
||||||
|
|
||||||
|
#
|
||||||
|
# Add external library
|
||||||
|
#
|
||||||
|
INCDIRS += include \
|
||||||
|
include/external
|
||||||
|
SRCDIRS += source \
|
||||||
|
source/external
|
||||||
|
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
OC := $(CROSS)objcopy
|
||||||
|
OD := $(CROSS)objdump
|
||||||
|
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
|
||||||
|
|
||||||
|
$(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)
|
27
payloads/d1_f133/read32/include/endian.h
Normal file
27
payloads/d1_f133/read32/include/endian.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#ifndef __RISCV64_ENDIAN_H__
|
||||||
|
#define __RISCV64_ENDIAN_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define LITTLE_ENDIAN (0x1234)
|
||||||
|
#define BIG_ENDIAN (0x4321)
|
||||||
|
|
||||||
|
#if ( !defined(__LITTLE_ENDIAN) && !defined(__BIG_ENDIAN) )
|
||||||
|
#define __LITTLE_ENDIAN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__LITTLE_ENDIAN)
|
||||||
|
#define BYTE_ORDER LITTLE_ENDIAN
|
||||||
|
#elif defined(__BIG_ENDIAN)
|
||||||
|
#define BYTE_ORDER BIG_ENDIAN
|
||||||
|
#else
|
||||||
|
#error "Unknown byte order!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __RISCV64_ENDIAN_H__ */
|
24
payloads/d1_f133/read32/include/linkage.h
Normal file
24
payloads/d1_f133/read32/include/linkage.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#ifndef __RISCV64_LINKAGE_H__
|
||||||
|
#define __RISCV64_LINKAGE_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __riscv_xlen == 64
|
||||||
|
#define LREG ld
|
||||||
|
#define SREG sd
|
||||||
|
#define REGSZ 8
|
||||||
|
#define RVPTR .dword
|
||||||
|
#elif __riscv_xlen == 32
|
||||||
|
#define LREG lw
|
||||||
|
#define SREG sw
|
||||||
|
#define REGSZ 4
|
||||||
|
#define RVPTR .word
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __RISCV64_LINKAGE_H__ */
|
113
payloads/d1_f133/read32/include/riscv64.h
Normal file
113
payloads/d1_f133/read32/include/riscv64.h
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
#ifndef __RISCV64_H__
|
||||||
|
#define __RISCV64_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define MSTATUS_UIE (1 << 0)
|
||||||
|
#define MSTATUS_SIE (1 << 1)
|
||||||
|
#define MSTATUS_MIE (1 << 3)
|
||||||
|
#define MSTATUS_UPIE (1 << 4)
|
||||||
|
#define MSTATUS_SPIE (1 << 5)
|
||||||
|
#define MSTATUS_MPIE (1 << 7)
|
||||||
|
#define MSTATUS_SPP (1 << 8)
|
||||||
|
#define MSTATUS_MPP (3 << 11)
|
||||||
|
#define MSTATUS_FS (3 << 13)
|
||||||
|
#define MSTATUS_XS (3 << 15)
|
||||||
|
#define MSTATUS_MPRV (1 << 17)
|
||||||
|
#define MSTATUS_SUM (1 << 18)
|
||||||
|
#define MSTATUS_MXR (1 << 19)
|
||||||
|
#define MSTATUS_TVM (1 << 20)
|
||||||
|
#define MSTATUS_TW (1 << 21)
|
||||||
|
#define MSTATUS_TSR (1 << 22)
|
||||||
|
#define MSTATUS32_SD (1 << 31)
|
||||||
|
#define MSTATUS_UXL (3ULL << 32)
|
||||||
|
#define MSTATUS_SXL (3ULL << 34)
|
||||||
|
#define MSTATUS64_SD (1ULL << 63)
|
||||||
|
|
||||||
|
#define MIP_USIP (1 << 0)
|
||||||
|
#define MIP_SSIP (1 << 1)
|
||||||
|
#define MIP_MSIP (1 << 3)
|
||||||
|
#define MIP_UTIP (1 << 4)
|
||||||
|
#define MIP_STIP (1 << 5)
|
||||||
|
#define MIP_MTIP (1 << 7)
|
||||||
|
#define MIP_UEIP (1 << 8)
|
||||||
|
#define MIP_SEIP (1 << 9)
|
||||||
|
#define MIP_MEIP (1 << 11)
|
||||||
|
|
||||||
|
#define MIE_USIE (1 << 0)
|
||||||
|
#define MIE_SSIE (1 << 1)
|
||||||
|
#define MIE_MSIE (1 << 3)
|
||||||
|
#define MIE_UTIE (1 << 4)
|
||||||
|
#define MIE_STIE (1 << 5)
|
||||||
|
#define MIE_MTIE (1 << 7)
|
||||||
|
#define MIE_UEIE (1 << 8)
|
||||||
|
#define MIE_SEIE (1 << 9)
|
||||||
|
#define MIE_MEIE (1 << 11)
|
||||||
|
|
||||||
|
#define csr_swap(csr, val) \
|
||||||
|
({ \
|
||||||
|
unsigned long __v = (unsigned long)(val); \
|
||||||
|
__asm__ __volatile__ ("csrrw %0, " #csr ", %1" \
|
||||||
|
: "=r" (__v) : "rK" (__v) \
|
||||||
|
: "memory"); \
|
||||||
|
__v; \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define csr_read(csr) \
|
||||||
|
({ \
|
||||||
|
register unsigned long __v; \
|
||||||
|
__asm__ __volatile__ ("csrr %0, " #csr \
|
||||||
|
: "=r" (__v) : \
|
||||||
|
: "memory"); \
|
||||||
|
__v; \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define csr_write(csr, val) \
|
||||||
|
({ \
|
||||||
|
unsigned long __v = (unsigned long)(val); \
|
||||||
|
__asm__ __volatile__ ("csrw " #csr ", %0" \
|
||||||
|
: : "rK" (__v) \
|
||||||
|
: "memory"); \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define csr_read_set(csr, val) \
|
||||||
|
({ \
|
||||||
|
unsigned long __v = (unsigned long)(val); \
|
||||||
|
__asm__ __volatile__ ("csrrs %0, " #csr ", %1" \
|
||||||
|
: "=r" (__v) : "rK" (__v) \
|
||||||
|
: "memory"); \
|
||||||
|
__v; \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define csr_set(csr, val) \
|
||||||
|
({ \
|
||||||
|
unsigned long __v = (unsigned long)(val); \
|
||||||
|
__asm__ __volatile__ ("csrs " #csr ", %0" \
|
||||||
|
: : "rK" (__v) \
|
||||||
|
: "memory"); \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define csr_read_clear(csr, val) \
|
||||||
|
({ \
|
||||||
|
unsigned long __v = (unsigned long)(val); \
|
||||||
|
__asm__ __volatile__ ("csrrc %0, " #csr ", %1" \
|
||||||
|
: "=r" (__v) : "rK" (__v) \
|
||||||
|
: "memory"); \
|
||||||
|
__v; \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define csr_clear(csr, val) \
|
||||||
|
({ \
|
||||||
|
unsigned long __v = (unsigned long)(val); \
|
||||||
|
__asm__ __volatile__ ("csrc " #csr ", %0" \
|
||||||
|
: : "rK" (__v) \
|
||||||
|
: "memory"); \
|
||||||
|
})
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __RISCV64_H__ */
|
53
payloads/d1_f133/read32/include/types.h
Normal file
53
payloads/d1_f133/read32/include/types.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#ifndef __RISCV64_TYPES_H__
|
||||||
|
#define __RISCV64_TYPES_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef signed char s8_t;
|
||||||
|
typedef unsigned char u8_t;
|
||||||
|
|
||||||
|
typedef signed short s16_t;
|
||||||
|
typedef unsigned short u16_t;
|
||||||
|
|
||||||
|
typedef signed int s32_t;
|
||||||
|
typedef unsigned int u32_t;
|
||||||
|
|
||||||
|
typedef signed long long s64_t;
|
||||||
|
typedef unsigned long long u64_t;
|
||||||
|
|
||||||
|
typedef signed long long intmax_t;
|
||||||
|
typedef unsigned long long uintmax_t;
|
||||||
|
|
||||||
|
typedef signed long long ptrdiff_t;
|
||||||
|
typedef signed long long intptr_t;
|
||||||
|
typedef unsigned long long uintptr_t;
|
||||||
|
|
||||||
|
typedef unsigned long long size_t;
|
||||||
|
typedef signed long long ssize_t;
|
||||||
|
|
||||||
|
typedef signed long off_t;
|
||||||
|
typedef signed long long loff_t;
|
||||||
|
|
||||||
|
typedef signed int bool_t;
|
||||||
|
typedef unsigned long irq_flags_t;
|
||||||
|
|
||||||
|
typedef unsigned long long virtual_addr_t;
|
||||||
|
typedef unsigned long long virtual_size_t;
|
||||||
|
typedef unsigned long long physical_addr_t;
|
||||||
|
typedef unsigned long long physical_size_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
volatile int counter;
|
||||||
|
} atomic_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
volatile int lock;
|
||||||
|
} spinlock_t;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __RISCV64_TYPES_H__ */
|
82
payloads/d1_f133/read32/link.ld
Normal file
82
payloads/d1_f133/read32/link.ld
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
OUTPUT_FORMAT("elf64-littleriscv", "elf64-littleriscv", "elf64-littleriscv")
|
||||||
|
OUTPUT_ARCH(riscv)
|
||||||
|
ENTRY(_start)
|
||||||
|
|
||||||
|
STACK_SIZE = 0x010;
|
||||||
|
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
ram : org = 0x00045000, len = 0x00000200 /* 512B */
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.text :
|
||||||
|
{
|
||||||
|
PROVIDE(__image_start = .);
|
||||||
|
PROVIDE(__text_start = .);
|
||||||
|
.obj/source/start.o (.text*)
|
||||||
|
*(.text*)
|
||||||
|
*(.iplt)
|
||||||
|
*(.note.gnu.build-id)
|
||||||
|
PROVIDE(__text_end = .);
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
.ksymtab ALIGN(16) :
|
||||||
|
{
|
||||||
|
PROVIDE(__ksymtab_start = .);
|
||||||
|
KEEP(*(.ksymtab.text))
|
||||||
|
PROVIDE(__ksymtab_end = .);
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
.romdisk ALIGN(8) :
|
||||||
|
{
|
||||||
|
PROVIDE(__romdisk_start = .);
|
||||||
|
KEEP(*(.romdisk))
|
||||||
|
PROVIDE(__romdisk_end = .);
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
.rodata ALIGN(8) :
|
||||||
|
{
|
||||||
|
PROVIDE(__rodata_start = .);
|
||||||
|
*(.rodata*)
|
||||||
|
*(.srodata*)
|
||||||
|
PROVIDE(__rodata_end = .);
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
.data ALIGN(8) :
|
||||||
|
{
|
||||||
|
PROVIDE(__data_start = .);
|
||||||
|
PROVIDE(__global_pointer$ = . + 0x800);
|
||||||
|
*(.sdata*)
|
||||||
|
*(.data*)
|
||||||
|
. = ALIGN(8);
|
||||||
|
PROVIDE(__data_end = .);
|
||||||
|
PROVIDE(__image_end = .);
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
.bss ALIGN(8) (NOLOAD) :
|
||||||
|
{
|
||||||
|
PROVIDE(__bss_start = .);
|
||||||
|
*(.bss*)
|
||||||
|
*(.sbss*)
|
||||||
|
*(COMMON)
|
||||||
|
. = ALIGN(8);
|
||||||
|
PROVIDE(__bss_end = .);
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
.stack ALIGN(16) (NOLOAD) :
|
||||||
|
{
|
||||||
|
PROVIDE(__stack_start = .);
|
||||||
|
. += STACK_SIZE;
|
||||||
|
. = ALIGN(16);
|
||||||
|
PROVIDE(__stack_end = .);
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
/DISCARD/ : { *(.dynsym) }
|
||||||
|
/DISCARD/ : { *(.dynstr*) }
|
||||||
|
/DISCARD/ : { *(.dynamic*) }
|
||||||
|
/DISCARD/ : { *(.plt*) }
|
||||||
|
/DISCARD/ : { *(.interp*) }
|
||||||
|
/DISCARD/ : { *(.gnu*) }
|
||||||
|
}
|
51
payloads/d1_f133/read32/source/start.S
Normal file
51
payloads/d1_f133/read32/source/start.S
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* start.S
|
||||||
|
*
|
||||||
|
* Copyright(c) 2007-2021 Jianjun Jiang <8192542@qq.com>
|
||||||
|
* Official site: http://xboot.org
|
||||||
|
* Mobile phone: +86-18665388956
|
||||||
|
* QQ: 8192542
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <linkage.h>
|
||||||
|
#include <riscv64.h>
|
||||||
|
|
||||||
|
.global _start
|
||||||
|
_start:
|
||||||
|
li t1, 0x1 << 22
|
||||||
|
csrs mxstatus, t1
|
||||||
|
li t1, 0x30013
|
||||||
|
csrs mcor, t1
|
||||||
|
j reset
|
||||||
|
|
||||||
|
reset:
|
||||||
|
la t0, _adr
|
||||||
|
lw t0, (t0)
|
||||||
|
lw t0, (t0)
|
||||||
|
la t1, _val
|
||||||
|
sw t0, (t1)
|
||||||
|
ret
|
||||||
|
.align 2
|
||||||
|
_adr:
|
||||||
|
.word 0x11223344
|
||||||
|
_val:
|
||||||
|
.word 0x55667788
|
@ -2,12 +2,9 @@
|
|||||||
# Top makefile
|
# Top makefile
|
||||||
#
|
#
|
||||||
|
|
||||||
CROSS ?= ~/test/tina-d1-open/prebuilt/gcc/linux-x86/riscv/toolchain-thead-glibc/riscv64-glibc-gcc-thead_20200702/bin/riscv64-unknown-linux-gnu-
|
CROSS ?= ~/Xuantie-900-gcc-elf-newlib-x86_64-V2.2.4/bin/riscv64-unknown-elf-
|
||||||
NAME := spi
|
NAME := spi
|
||||||
|
|
||||||
#
|
|
||||||
# System environment variable.
|
|
||||||
#
|
|
||||||
#
|
#
|
||||||
# System environment variable.
|
# System environment variable.
|
||||||
#
|
#
|
||||||
|
@ -186,6 +186,8 @@ static void sys_spi_transfer(void * txbuf, void * rxbuf, u32_t len)
|
|||||||
write32(addr + SPI_MBC, n);
|
write32(addr + SPI_MBC, n);
|
||||||
sys_spi_write_txbuf(tx, n);
|
sys_spi_write_txbuf(tx, n);
|
||||||
write32(addr + SPI_TCR, read32(addr + SPI_TCR) | (1 << 31));
|
write32(addr + SPI_TCR, read32(addr + SPI_TCR) | (1 << 31));
|
||||||
|
while(read32(addr + SPI_TCR) & (1 << 31));
|
||||||
|
|
||||||
while((read32(addr + SPI_FSR) & 0xff) < n);
|
while((read32(addr + SPI_FSR) & 0xff) < n);
|
||||||
for(i = 0; i < n; i++)
|
for(i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
|
10
payloads/d1_f133/write32/.gitignore
vendored
Normal file
10
payloads/d1_f133/write32/.gitignore
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#
|
||||||
|
# Normal rules
|
||||||
|
#
|
||||||
|
*~
|
||||||
|
|
||||||
|
#
|
||||||
|
# Generated files
|
||||||
|
#
|
||||||
|
/.obj
|
||||||
|
/output
|
120
payloads/d1_f133/write32/Makefile
Normal file
120
payloads/d1_f133/write32/Makefile
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
#
|
||||||
|
# Top makefile
|
||||||
|
#
|
||||||
|
|
||||||
|
CROSS ?= ~/Xuantie-900-gcc-elf-newlib-x86_64-V2.2.4/bin/riscv64-unknown-elf-
|
||||||
|
NAME := write32
|
||||||
|
|
||||||
|
#
|
||||||
|
# System environment variable.
|
||||||
|
#
|
||||||
|
ifeq ($(OS), Windows_NT)
|
||||||
|
HOSTOS := windows
|
||||||
|
else
|
||||||
|
ifneq (,$(findstring Linux, $(shell uname -a)))
|
||||||
|
HOSTOS := linux
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
#
|
||||||
|
# Load default variables.
|
||||||
|
#
|
||||||
|
ASFLAGS := -g -ggdb -Wall -O3 -ffreestanding
|
||||||
|
CFLAGS := -g -ggdb -Wall -O3 -ffreestanding
|
||||||
|
CXXFLAGS := -g -ggdb -Wall -O3 -ffreestanding
|
||||||
|
LDFLAGS := -T link.ld -nostdlib
|
||||||
|
ARFLAGS := -rcs
|
||||||
|
OCFLAGS := -v -O binary
|
||||||
|
ODFLAGS :=
|
||||||
|
MCFLAGS := -march=rv64gvxthead -mabi=lp64d -mcmodel=medany -fno-stack-protector
|
||||||
|
|
||||||
|
LIBDIRS :=
|
||||||
|
LIBS :=
|
||||||
|
INCDIRS :=
|
||||||
|
SRCDIRS :=
|
||||||
|
|
||||||
|
#
|
||||||
|
# Add external library
|
||||||
|
#
|
||||||
|
INCDIRS += include \
|
||||||
|
include/external
|
||||||
|
SRCDIRS += source \
|
||||||
|
source/external
|
||||||
|
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
OC := $(CROSS)objcopy
|
||||||
|
OD := $(CROSS)objdump
|
||||||
|
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
|
||||||
|
|
||||||
|
$(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)
|
83
payloads/d1_f133/write32/include/byteorder.h
Normal file
83
payloads/d1_f133/write32/include/byteorder.h
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
#ifndef __BYTEORDER_H__
|
||||||
|
#define __BYTEORDER_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <types.h>
|
||||||
|
|
||||||
|
static inline u16_t __swab16(u16_t x)
|
||||||
|
{
|
||||||
|
return ( (x<<8) | (x>>8) );
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline u32_t __swab32(u32_t x)
|
||||||
|
{
|
||||||
|
return ( (x<<24) | (x>>24) | \
|
||||||
|
((x & (u32_t)0x0000ff00UL)<<8) | \
|
||||||
|
((x & (u32_t)0x00ff0000UL)>>8) );
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline u64_t __swab64(u64_t x)
|
||||||
|
{
|
||||||
|
return ( (x<<56) | (x>>56) | \
|
||||||
|
((x & (u64_t)0x000000000000ff00ULL)<<40) | \
|
||||||
|
((x & (u64_t)0x0000000000ff0000ULL)<<24) | \
|
||||||
|
((x & (u64_t)0x00000000ff000000ULL)<< 8) | \
|
||||||
|
((x & (u64_t)0x000000ff00000000ULL)>> 8) | \
|
||||||
|
((x & (u64_t)0x0000ff0000000000ULL)>>24) | \
|
||||||
|
((x & (u64_t)0x00ff000000000000ULL)>>40) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* swap bytes bizarrely.
|
||||||
|
* swahw32 - swap 16-bit half-words in a 32-bit word
|
||||||
|
*/
|
||||||
|
static inline u32_t __swahw32(u32_t x)
|
||||||
|
{
|
||||||
|
return ( ((x & (u32_t)0x0000ffffUL)<<16) | ((x & (u32_t)0xffff0000UL)>>16) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* swap bytes bizarrely.
|
||||||
|
* swahb32 - swap 8-bit halves of each 16-bit half-word in a 32-bit word
|
||||||
|
*/
|
||||||
|
static inline u32_t __swahb32(u32_t x)
|
||||||
|
{
|
||||||
|
return ( ((x & (u32_t)0x00ff00ffUL)<<8) | ((x & (u32_t)0xff00ff00UL)>>8) );
|
||||||
|
}
|
||||||
|
|
||||||
|
#if (BYTE_ORDER == BIG_ENDIAN)
|
||||||
|
#define cpu_to_le64(x) (__swab64((u64_t)(x)))
|
||||||
|
#define le64_to_cpu(x) (__swab64((u64_t)(x)))
|
||||||
|
#define cpu_to_le32(x) (__swab32((u32_t)(x)))
|
||||||
|
#define le32_to_cpu(x) (__swab32((u32_t)(x)))
|
||||||
|
#define cpu_to_le16(x) (__swab16((u16_t)(x)))
|
||||||
|
#define le16_to_cpu(x) (__swab16((u16_t)(x)))
|
||||||
|
#define cpu_to_be64(x) ((u64_t)(x))
|
||||||
|
#define be64_to_cpu(x) ((u64_t)(x))
|
||||||
|
#define cpu_to_be32(x) ((u32_t)(x))
|
||||||
|
#define be32_to_cpu(x) ((u32_t)(x))
|
||||||
|
#define cpu_to_be16(x) ((u16_t)(x))
|
||||||
|
#define be16_to_cpu(x) ((u16_t)(x))
|
||||||
|
#else
|
||||||
|
#define cpu_to_le64(x) ((u64_t)(x))
|
||||||
|
#define le64_to_cpu(x) ((u64_t)(x))
|
||||||
|
#define cpu_to_le32(x) ((u32_t)(x))
|
||||||
|
#define le32_to_cpu(x) ((u32_t)(x))
|
||||||
|
#define cpu_to_le16(x) ((u16_t)(x))
|
||||||
|
#define le16_to_cpu(x) ((u16_t)(x))
|
||||||
|
#define cpu_to_be64(x) (__swab64((u64_t)(x)))
|
||||||
|
#define be64_to_cpu(x) (__swab64((u64_t)(x)))
|
||||||
|
#define cpu_to_be32(x) (__swab32((u32_t)(x)))
|
||||||
|
#define be32_to_cpu(x) (__swab32((u32_t)(x)))
|
||||||
|
#define cpu_to_be16(x) (__swab16((u16_t)(x)))
|
||||||
|
#define be16_to_cpu(x) (__swab16((u16_t)(x)))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __BYTEORDER_H__ */
|
27
payloads/d1_f133/write32/include/endian.h
Normal file
27
payloads/d1_f133/write32/include/endian.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#ifndef __RISCV64_ENDIAN_H__
|
||||||
|
#define __RISCV64_ENDIAN_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define LITTLE_ENDIAN (0x1234)
|
||||||
|
#define BIG_ENDIAN (0x4321)
|
||||||
|
|
||||||
|
#if ( !defined(__LITTLE_ENDIAN) && !defined(__BIG_ENDIAN) )
|
||||||
|
#define __LITTLE_ENDIAN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__LITTLE_ENDIAN)
|
||||||
|
#define BYTE_ORDER LITTLE_ENDIAN
|
||||||
|
#elif defined(__BIG_ENDIAN)
|
||||||
|
#define BYTE_ORDER BIG_ENDIAN
|
||||||
|
#else
|
||||||
|
#error "Unknown byte order!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __RISCV64_ENDIAN_H__ */
|
54
payloads/d1_f133/write32/include/io.h
Normal file
54
payloads/d1_f133/write32/include/io.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
#ifndef __IO_H__
|
||||||
|
#define __IO_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <types.h>
|
||||||
|
|
||||||
|
static inline u8_t read8(virtual_addr_t addr)
|
||||||
|
{
|
||||||
|
return( *((volatile u8_t *)(addr)) );
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline u16_t read16(virtual_addr_t addr)
|
||||||
|
{
|
||||||
|
return( *((volatile u16_t *)(addr)) );
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline u32_t read32(virtual_addr_t addr)
|
||||||
|
{
|
||||||
|
return( *((volatile u32_t *)(addr)) );
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline u64_t read64(virtual_addr_t addr)
|
||||||
|
{
|
||||||
|
return( *((volatile u64_t *)(addr)) );
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void write8(virtual_addr_t addr, u8_t value)
|
||||||
|
{
|
||||||
|
*((volatile u8_t *)(addr)) = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void write16(virtual_addr_t addr, u16_t value)
|
||||||
|
{
|
||||||
|
*((volatile u16_t *)(addr)) = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void write32(virtual_addr_t addr, u32_t value)
|
||||||
|
{
|
||||||
|
*((volatile u32_t *)(addr)) = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void write64(virtual_addr_t addr, u64_t value)
|
||||||
|
{
|
||||||
|
*((volatile u64_t *)(addr)) = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __IO_H__ */
|
24
payloads/d1_f133/write32/include/linkage.h
Normal file
24
payloads/d1_f133/write32/include/linkage.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#ifndef __RISCV64_LINKAGE_H__
|
||||||
|
#define __RISCV64_LINKAGE_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if __riscv_xlen == 64
|
||||||
|
#define LREG ld
|
||||||
|
#define SREG sd
|
||||||
|
#define REGSZ 8
|
||||||
|
#define RVPTR .dword
|
||||||
|
#elif __riscv_xlen == 32
|
||||||
|
#define LREG lw
|
||||||
|
#define SREG sw
|
||||||
|
#define REGSZ 4
|
||||||
|
#define RVPTR .word
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __RISCV64_LINKAGE_H__ */
|
113
payloads/d1_f133/write32/include/riscv64.h
Normal file
113
payloads/d1_f133/write32/include/riscv64.h
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
#ifndef __RISCV64_H__
|
||||||
|
#define __RISCV64_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define MSTATUS_UIE (1 << 0)
|
||||||
|
#define MSTATUS_SIE (1 << 1)
|
||||||
|
#define MSTATUS_MIE (1 << 3)
|
||||||
|
#define MSTATUS_UPIE (1 << 4)
|
||||||
|
#define MSTATUS_SPIE (1 << 5)
|
||||||
|
#define MSTATUS_MPIE (1 << 7)
|
||||||
|
#define MSTATUS_SPP (1 << 8)
|
||||||
|
#define MSTATUS_MPP (3 << 11)
|
||||||
|
#define MSTATUS_FS (3 << 13)
|
||||||
|
#define MSTATUS_XS (3 << 15)
|
||||||
|
#define MSTATUS_MPRV (1 << 17)
|
||||||
|
#define MSTATUS_SUM (1 << 18)
|
||||||
|
#define MSTATUS_MXR (1 << 19)
|
||||||
|
#define MSTATUS_TVM (1 << 20)
|
||||||
|
#define MSTATUS_TW (1 << 21)
|
||||||
|
#define MSTATUS_TSR (1 << 22)
|
||||||
|
#define MSTATUS32_SD (1 << 31)
|
||||||
|
#define MSTATUS_UXL (3ULL << 32)
|
||||||
|
#define MSTATUS_SXL (3ULL << 34)
|
||||||
|
#define MSTATUS64_SD (1ULL << 63)
|
||||||
|
|
||||||
|
#define MIP_USIP (1 << 0)
|
||||||
|
#define MIP_SSIP (1 << 1)
|
||||||
|
#define MIP_MSIP (1 << 3)
|
||||||
|
#define MIP_UTIP (1 << 4)
|
||||||
|
#define MIP_STIP (1 << 5)
|
||||||
|
#define MIP_MTIP (1 << 7)
|
||||||
|
#define MIP_UEIP (1 << 8)
|
||||||
|
#define MIP_SEIP (1 << 9)
|
||||||
|
#define MIP_MEIP (1 << 11)
|
||||||
|
|
||||||
|
#define MIE_USIE (1 << 0)
|
||||||
|
#define MIE_SSIE (1 << 1)
|
||||||
|
#define MIE_MSIE (1 << 3)
|
||||||
|
#define MIE_UTIE (1 << 4)
|
||||||
|
#define MIE_STIE (1 << 5)
|
||||||
|
#define MIE_MTIE (1 << 7)
|
||||||
|
#define MIE_UEIE (1 << 8)
|
||||||
|
#define MIE_SEIE (1 << 9)
|
||||||
|
#define MIE_MEIE (1 << 11)
|
||||||
|
|
||||||
|
#define csr_swap(csr, val) \
|
||||||
|
({ \
|
||||||
|
unsigned long __v = (unsigned long)(val); \
|
||||||
|
__asm__ __volatile__ ("csrrw %0, " #csr ", %1" \
|
||||||
|
: "=r" (__v) : "rK" (__v) \
|
||||||
|
: "memory"); \
|
||||||
|
__v; \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define csr_read(csr) \
|
||||||
|
({ \
|
||||||
|
register unsigned long __v; \
|
||||||
|
__asm__ __volatile__ ("csrr %0, " #csr \
|
||||||
|
: "=r" (__v) : \
|
||||||
|
: "memory"); \
|
||||||
|
__v; \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define csr_write(csr, val) \
|
||||||
|
({ \
|
||||||
|
unsigned long __v = (unsigned long)(val); \
|
||||||
|
__asm__ __volatile__ ("csrw " #csr ", %0" \
|
||||||
|
: : "rK" (__v) \
|
||||||
|
: "memory"); \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define csr_read_set(csr, val) \
|
||||||
|
({ \
|
||||||
|
unsigned long __v = (unsigned long)(val); \
|
||||||
|
__asm__ __volatile__ ("csrrs %0, " #csr ", %1" \
|
||||||
|
: "=r" (__v) : "rK" (__v) \
|
||||||
|
: "memory"); \
|
||||||
|
__v; \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define csr_set(csr, val) \
|
||||||
|
({ \
|
||||||
|
unsigned long __v = (unsigned long)(val); \
|
||||||
|
__asm__ __volatile__ ("csrs " #csr ", %0" \
|
||||||
|
: : "rK" (__v) \
|
||||||
|
: "memory"); \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define csr_read_clear(csr, val) \
|
||||||
|
({ \
|
||||||
|
unsigned long __v = (unsigned long)(val); \
|
||||||
|
__asm__ __volatile__ ("csrrc %0, " #csr ", %1" \
|
||||||
|
: "=r" (__v) : "rK" (__v) \
|
||||||
|
: "memory"); \
|
||||||
|
__v; \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define csr_clear(csr, val) \
|
||||||
|
({ \
|
||||||
|
unsigned long __v = (unsigned long)(val); \
|
||||||
|
__asm__ __volatile__ ("csrc " #csr ", %0" \
|
||||||
|
: : "rK" (__v) \
|
||||||
|
: "memory"); \
|
||||||
|
})
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __RISCV64_H__ */
|
34
payloads/d1_f133/write32/include/stdarg.h
Normal file
34
payloads/d1_f133/write32/include/stdarg.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#ifndef __STDARG_H__
|
||||||
|
#define __STDARG_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef __builtin_va_list va_list;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* prepare to access variable args
|
||||||
|
*/
|
||||||
|
#define va_start(v, l) __builtin_va_start(v, l)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* the caller will get the value of current argument
|
||||||
|
*/
|
||||||
|
#define va_arg(v, l) __builtin_va_arg(v, l)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* end for variable args
|
||||||
|
*/
|
||||||
|
#define va_end(v) __builtin_va_end(v)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* copy variable args
|
||||||
|
*/
|
||||||
|
#define va_copy(d, s) __builtin_va_copy(d, s)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __STDARG_H__ */
|
49
payloads/d1_f133/write32/include/stddef.h
Normal file
49
payloads/d1_f133/write32/include/stddef.h
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#ifndef __STDDEF_H__
|
||||||
|
#define __STDDEF_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__cplusplus)
|
||||||
|
#define NULL (0)
|
||||||
|
#else
|
||||||
|
#define NULL ((void *)0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if (defined(__GNUC__) && (__GNUC__ >= 4))
|
||||||
|
#define offsetof(type, member) __builtin_offsetof(type, member)
|
||||||
|
#else
|
||||||
|
#define offsetof(type, field) ((size_t)(&((type *)0)->field))
|
||||||
|
#endif
|
||||||
|
#define container_of(ptr, type, member) ({const typeof(((type *)0)->member) *__mptr = (ptr); (type *)((char *)__mptr - offsetof(type,member));})
|
||||||
|
|
||||||
|
#if (defined(__GNUC__) && (__GNUC__ >= 3))
|
||||||
|
#define likely(expr) (__builtin_expect(!!(expr), 1))
|
||||||
|
#define unlikely(expr) (__builtin_expect(!!(expr), 0))
|
||||||
|
#else
|
||||||
|
#define likely(expr) (!!(expr))
|
||||||
|
#define unlikely(expr) (!!(expr))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define min(a, b) ({typeof(a) _amin = (a); typeof(b) _bmin = (b); (void)(&_amin == &_bmin); _amin < _bmin ? _amin : _bmin;})
|
||||||
|
#define max(a, b) ({typeof(a) _amax = (a); typeof(b) _bmax = (b); (void)(&_amax == &_bmax); _amax > _bmax ? _amax : _bmax;})
|
||||||
|
#define clamp(v, a, b) min(max(a, v), b)
|
||||||
|
|
||||||
|
#define ifloor(x) ((x) > 0 ? (int)(x) : (int)((x) - 0.9999999999))
|
||||||
|
#define iround(x) ((x) > 0 ? (int)((x) + 0.5) : (int)((x) - 0.5))
|
||||||
|
#define iceil(x) ((x) > 0 ? (int)((x) + 0.9999999999) : (int)(x))
|
||||||
|
#define idiv255(x) ((((int)(x) + 1) * 257) >> 16)
|
||||||
|
|
||||||
|
#define X(...) ("" #__VA_ARGS__ "")
|
||||||
|
|
||||||
|
enum {
|
||||||
|
FALSE = 0,
|
||||||
|
TRUE = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __STDDEF_H__ */
|
31
payloads/d1_f133/write32/include/stdint.h
Normal file
31
payloads/d1_f133/write32/include/stdint.h
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#ifndef __STDINT_H__
|
||||||
|
#define __STDINT_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <types.h>
|
||||||
|
|
||||||
|
typedef s8_t int8_t;
|
||||||
|
typedef u8_t uint8_t;
|
||||||
|
|
||||||
|
typedef s16_t int16_t;
|
||||||
|
typedef u16_t uint16_t;
|
||||||
|
|
||||||
|
typedef s32_t int32_t;
|
||||||
|
typedef u32_t uint32_t;
|
||||||
|
|
||||||
|
typedef s64_t int64_t;
|
||||||
|
typedef u64_t uint64_t;
|
||||||
|
|
||||||
|
#define UINT8_MAX (0xff)
|
||||||
|
#define UINT16_MAX (0xffff)
|
||||||
|
#define UINT32_MAX (0xffffffff)
|
||||||
|
#define UINT64_MAX (0xffffffffffffffffULL)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __STDINT_H__ */
|
17
payloads/d1_f133/write32/include/string.h
Normal file
17
payloads/d1_f133/write32/include/string.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef __STRING_H__
|
||||||
|
#define __STRING_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <types.h>
|
||||||
|
|
||||||
|
void * memset(void * s, int c, size_t n);
|
||||||
|
void * memcpy(void * dest, const void * src, size_t len);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __STRING_H__ */
|
53
payloads/d1_f133/write32/include/types.h
Normal file
53
payloads/d1_f133/write32/include/types.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
#ifndef __RISCV64_TYPES_H__
|
||||||
|
#define __RISCV64_TYPES_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef signed char s8_t;
|
||||||
|
typedef unsigned char u8_t;
|
||||||
|
|
||||||
|
typedef signed short s16_t;
|
||||||
|
typedef unsigned short u16_t;
|
||||||
|
|
||||||
|
typedef signed int s32_t;
|
||||||
|
typedef unsigned int u32_t;
|
||||||
|
|
||||||
|
typedef signed long long s64_t;
|
||||||
|
typedef unsigned long long u64_t;
|
||||||
|
|
||||||
|
typedef signed long long intmax_t;
|
||||||
|
typedef unsigned long long uintmax_t;
|
||||||
|
|
||||||
|
typedef signed long long ptrdiff_t;
|
||||||
|
typedef signed long long intptr_t;
|
||||||
|
typedef unsigned long long uintptr_t;
|
||||||
|
|
||||||
|
typedef unsigned long long size_t;
|
||||||
|
typedef signed long long ssize_t;
|
||||||
|
|
||||||
|
typedef signed long off_t;
|
||||||
|
typedef signed long long loff_t;
|
||||||
|
|
||||||
|
typedef signed int bool_t;
|
||||||
|
typedef unsigned long irq_flags_t;
|
||||||
|
|
||||||
|
typedef unsigned long long virtual_addr_t;
|
||||||
|
typedef unsigned long long virtual_size_t;
|
||||||
|
typedef unsigned long long physical_addr_t;
|
||||||
|
typedef unsigned long long physical_size_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
volatile int counter;
|
||||||
|
} atomic_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
volatile int lock;
|
||||||
|
} spinlock_t;
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __RISCV64_TYPES_H__ */
|
21
payloads/d1_f133/write32/include/xboot.h
Normal file
21
payloads/d1_f133/write32/include/xboot.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef __XBOOT_H__
|
||||||
|
#define __XBOOT_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <types.h>
|
||||||
|
#include <io.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <endian.h>
|
||||||
|
#include <byteorder.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __XBOOT_H__ */
|
82
payloads/d1_f133/write32/link.ld
Normal file
82
payloads/d1_f133/write32/link.ld
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
OUTPUT_FORMAT("elf64-littleriscv", "elf64-littleriscv", "elf64-littleriscv")
|
||||||
|
OUTPUT_ARCH(riscv)
|
||||||
|
ENTRY(_start)
|
||||||
|
|
||||||
|
STACK_SIZE = 0x010;
|
||||||
|
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
ram : org = 0x00045000, len = 0x00000200 /* 512B */
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.text :
|
||||||
|
{
|
||||||
|
PROVIDE(__image_start = .);
|
||||||
|
PROVIDE(__text_start = .);
|
||||||
|
.obj/source/start.o (.text*)
|
||||||
|
*(.text*)
|
||||||
|
*(.iplt)
|
||||||
|
*(.note.gnu.build-id)
|
||||||
|
PROVIDE(__text_end = .);
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
.ksymtab ALIGN(16) :
|
||||||
|
{
|
||||||
|
PROVIDE(__ksymtab_start = .);
|
||||||
|
KEEP(*(.ksymtab.text))
|
||||||
|
PROVIDE(__ksymtab_end = .);
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
.romdisk ALIGN(8) :
|
||||||
|
{
|
||||||
|
PROVIDE(__romdisk_start = .);
|
||||||
|
KEEP(*(.romdisk))
|
||||||
|
PROVIDE(__romdisk_end = .);
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
.rodata ALIGN(8) :
|
||||||
|
{
|
||||||
|
PROVIDE(__rodata_start = .);
|
||||||
|
*(.rodata*)
|
||||||
|
*(.srodata*)
|
||||||
|
PROVIDE(__rodata_end = .);
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
.data ALIGN(8) :
|
||||||
|
{
|
||||||
|
PROVIDE(__data_start = .);
|
||||||
|
PROVIDE(__global_pointer$ = . + 0x800);
|
||||||
|
*(.sdata*)
|
||||||
|
*(.data*)
|
||||||
|
. = ALIGN(8);
|
||||||
|
PROVIDE(__data_end = .);
|
||||||
|
PROVIDE(__image_end = .);
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
.bss ALIGN(8) (NOLOAD) :
|
||||||
|
{
|
||||||
|
PROVIDE(__bss_start = .);
|
||||||
|
*(.bss*)
|
||||||
|
*(.sbss*)
|
||||||
|
*(COMMON)
|
||||||
|
. = ALIGN(8);
|
||||||
|
PROVIDE(__bss_end = .);
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
.stack ALIGN(16) (NOLOAD) :
|
||||||
|
{
|
||||||
|
PROVIDE(__stack_start = .);
|
||||||
|
. += STACK_SIZE;
|
||||||
|
. = ALIGN(16);
|
||||||
|
PROVIDE(__stack_end = .);
|
||||||
|
} > ram
|
||||||
|
|
||||||
|
/DISCARD/ : { *(.dynsym) }
|
||||||
|
/DISCARD/ : { *(.dynstr*) }
|
||||||
|
/DISCARD/ : { *(.dynamic*) }
|
||||||
|
/DISCARD/ : { *(.plt*) }
|
||||||
|
/DISCARD/ : { *(.interp*) }
|
||||||
|
/DISCARD/ : { *(.gnu*) }
|
||||||
|
}
|
51
payloads/d1_f133/write32/source/start.S
Normal file
51
payloads/d1_f133/write32/source/start.S
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* start.S
|
||||||
|
*
|
||||||
|
* Copyright(c) 2007-2021 Jianjun Jiang <8192542@qq.com>
|
||||||
|
* Official site: http://xboot.org
|
||||||
|
* Mobile phone: +86-18665388956
|
||||||
|
* QQ: 8192542
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all
|
||||||
|
* copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <linkage.h>
|
||||||
|
#include <riscv64.h>
|
||||||
|
|
||||||
|
.global _start
|
||||||
|
_start:
|
||||||
|
li t1, 0x1 << 22
|
||||||
|
csrs mxstatus, t1
|
||||||
|
li t1, 0x30013
|
||||||
|
csrs mcor, t1
|
||||||
|
j reset
|
||||||
|
|
||||||
|
reset:
|
||||||
|
la t0, _adr
|
||||||
|
lw t0, (t0)
|
||||||
|
la t1, _val
|
||||||
|
lw t1, (t1)
|
||||||
|
sw t1, (t0)
|
||||||
|
ret
|
||||||
|
.align 2
|
||||||
|
_adr:
|
||||||
|
.word 0x11223344
|
||||||
|
_val:
|
||||||
|
.word 0x55667788
|
@ -5,9 +5,6 @@
|
|||||||
CROSS ?= arm-none-eabi-
|
CROSS ?= arm-none-eabi-
|
||||||
NAME := ddr
|
NAME := ddr
|
||||||
|
|
||||||
#
|
|
||||||
# System environment variable.
|
|
||||||
#
|
|
||||||
#
|
#
|
||||||
# System environment variable.
|
# System environment variable.
|
||||||
#
|
#
|
||||||
|
@ -5,9 +5,6 @@
|
|||||||
CROSS ?= arm-none-eabi-
|
CROSS ?= arm-none-eabi-
|
||||||
NAME := jtag
|
NAME := jtag
|
||||||
|
|
||||||
#
|
|
||||||
# System environment variable.
|
|
||||||
#
|
|
||||||
#
|
#
|
||||||
# System environment variable.
|
# System environment variable.
|
||||||
#
|
#
|
||||||
|
@ -5,9 +5,6 @@
|
|||||||
CROSS ?= arm-none-eabi-
|
CROSS ?= arm-none-eabi-
|
||||||
NAME := spi
|
NAME := spi
|
||||||
|
|
||||||
#
|
|
||||||
# System environment variable.
|
|
||||||
#
|
|
||||||
#
|
#
|
||||||
# System environment variable.
|
# System environment variable.
|
||||||
#
|
#
|
||||||
|
@ -159,6 +159,8 @@ static void sys_spi_transfer(void * txbuf, void * rxbuf, u32_t len)
|
|||||||
write32(addr + SPI_MBC, n);
|
write32(addr + SPI_MBC, n);
|
||||||
sys_spi_write_txbuf(tx, n);
|
sys_spi_write_txbuf(tx, n);
|
||||||
write32(addr + SPI_TCR, read32(addr + SPI_TCR) | (1 << 31));
|
write32(addr + SPI_TCR, read32(addr + SPI_TCR) | (1 << 31));
|
||||||
|
while(read32(addr + SPI_TCR) & (1 << 31));
|
||||||
|
|
||||||
while((read32(addr + SPI_FSR) & 0xff) < n);
|
while((read32(addr + SPI_FSR) & 0xff) < n);
|
||||||
for(i = 0; i < n; i++)
|
for(i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
|
@ -5,9 +5,6 @@
|
|||||||
CROSS ?= arm-linux-gnueabihf-
|
CROSS ?= arm-linux-gnueabihf-
|
||||||
NAME := h2-ddr
|
NAME := h2-ddr
|
||||||
|
|
||||||
#
|
|
||||||
# System environment variable.
|
|
||||||
#
|
|
||||||
#
|
#
|
||||||
# System environment variable.
|
# System environment variable.
|
||||||
#
|
#
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user