Compare commits

...

69 Commits

Author SHA1 Message Date
SamulKyull
9e597927ca [chip] add chip a537 a333 2025-05-01 21:55:30 +08:00
Jiang Jianjun
849e9ad73d [xfel]bump version to v1.3.3 2025-05-01 21:50:54 +08:00
Jiang Jianjun
65c84e67a1 [xfel]add Makefile for win 2025-05-01 21:49:56 +08:00
Jiang Jianjun
fa8a294cd0 [v821]remove v821 uart test payload 2025-05-01 21:34:45 +08:00
Jiang Jianjun
936512d6a4 [v821]chang spi swap buffer to 96KB 2025-05-01 21:23:00 +08:00
Jiang Jianjun
423b9fefe5 [v821]add jtag support and update readme 2025-05-01 21:06:31 +08:00
Jiang Jianjun
7f941b3798 [v821]add spi flash support 2025-05-01 21:00:12 +08:00
Jiang Jianjun
6efd2b352b [v821]add v821 spi payload 2025-05-01 20:59:48 +08:00
Jianjun Jiang
f4a34064be [readme]update some readme 2025-04-13 11:48:19 +08:00
Jianjun Jiang
c485d172a4 [main]cleanup some code 2025-04-13 11:32:44 +08:00
Jianjun Jiang
4b58d94d34 [x.h]update x.h 2025-04-13 11:23:03 +08:00
Jianjun Jiang
d577d6b6cf [v821]update some comment 2025-04-13 11:08:21 +08:00
JianjunJiang
53a91c8365 [v821]add extra boot A27L command 2025-04-12 17:45:03 +08:00
JianjunJiang
a2bdf9fcd9 [v821]temp add uart payload for test 2025-04-12 15:51:57 +08:00
JianjunJiang
4df3bf1f80 [v821]update read32 and write32 payload 2025-04-12 15:48:29 +08:00
JianjunJiang
c8491bb265 [v821]update ddr initial 2025-04-12 15:13:11 +08:00
JianjunJiang
0e6f3b25c1 [v821]update toolchain for v821 payload 2025-04-03 17:03:30 +08:00
JianjunJiang
a69481210f [spinor]cleanup the spinor_infos 2025-04-03 16:34:17 +08:00
zwim
0094f7f799 Add W25Q256JV 2025-04-03 16:31:42 +08:00
jiang jianjun
3327271e0b
Merge pull request #69 from YuzukiHD/master
Add chip support
2025-01-18 09:11:37 +08:00
JianjunJiang
64ca4f0c68 [v821]add ddr support 2025-01-17 18:16:44 +08:00
JianjunJiang
9ac73147cc [v821]add v821 reset support 2025-01-17 16:20:32 +08:00
JianjunJiang
1849780f53 [v821]add v821 efuse support, but no support dump twice, why? 2025-01-17 16:02:25 +08:00
JianjunJiang
fa90526af1 [v821]add read32 and write32 riscv32 payload for v821 chip 2025-01-17 15:50:36 +08:00
Samuel Abdullah Krull
905f913b0c
Merge branch 'master' into master 2025-01-09 21:41:35 +08:00
SamulKyull
1667a847c8 [chip] add chip support 2025-01-09 21:33:59 +08:00
SamulKyull
7de784f399 [chip] add chip support 2025-01-08 16:12:42 +08:00
SamulKyull
703e2990e8 [chip] add chip support 2025-01-07 23:42:02 +08:00
taotieren
a02562bf92 update ldflags 2024-10-25 10:54:49 +08:00
柚木 鉉
8e76d5599b
Merge pull request #66 from leojrfs/master
main: fix incorrect grammar in error message
2024-10-10 08:20:56 +08:00
Leo Soares
28b1bcccc0 main: fix incorrect grammar in error message 2024-08-08 11:28:37 +01:00
JianjunJiang
109e5d4a38 [payload]update default address, payloads/a523_a527_t527/jmp-arm64/source/start.S 2024-08-01 15:24:15 +08:00
JianjunJiang
eb524b53a9 [t527]add reset support for t527 platform 2024-08-01 14:47:08 +08:00
JianjunJiang
37259360ab [a523]add jump arm64 extra command for A523/A527/T527/MR527 2024-07-31 21:48:53 +08:00
JianjunJiang
9728d78cad [a523]rename some files 2024-07-31 21:31:02 +08:00
YuzukiTsuru
1383b836cb [chip] a523 support efuse and sid 2024-02-01 12:09:58 +08:00
Yilin Sun
3c8a35a5f8 spinand: Add FORESEE F35SQA001G/002G devices ID.
Signed-off-by: Yilin Sun <imi415@imi.moe>
2024-02-01 12:09:15 +08:00
YuzukiTsuru
4dda7f238a [doc] update support list 2024-01-02 11:41:54 +08:00
YuzukiTsuru
e3ef078242 [chip] add ddr init support for a523 platform 2024-01-02 11:41:54 +08:00
YuzukiTsuru
59411a03b3 delete libusb 2024-01-02 11:41:54 +08:00
YuzukiTsuru
4302195ec5 [docs] update docs add h616 h313 h618 a523 2024-01-02 11:41:54 +08:00
YuzukiTsuru
a933687c72 [chip] add chip a523 2024-01-02 11:41:54 +08:00
YuzukiTsuru
02f3c51af7 [chip] support h618 dram 2024-01-02 11:41:54 +08:00
YuzukiTsuru
42cafeaf59 [chip] delete t507 due to duplicated chip id 2024-01-02 11:41:54 +08:00
KunYi Chen
6f92b44497 [r818] add r818 chip support
run 'xfel version' will show the below message
-----------------------------------------------------------------------------
AWUSBFEX ID=0x00185500(R818) dflag=0x44 dlength=0x08 scratchpad=0x00042200
2023-08-02 09:42:19 +08:00
JianjunJiang
688f4204ae [efuse]fix efuse write file command 2023-07-12 15:33:14 +08:00
JianjunJiang
7525fbca1f [v851/v853]add efuse support 2023-07-12 12:47:50 +08:00
JianjunJiang
8bc4119bc2 [d1/f133]add efuse command for d1/f133 2023-07-12 10:25:59 +08:00
JianjunJiang
25eae0be8b [d1]remove sid payload 2023-07-12 10:22:43 +08:00
JianjunJiang
42ed459c28 [f133/d1]add read32 and write32 2023-07-12 10:21:18 +08:00
Jianjun Jiang
e821f8e69f [t113]update t113 efuse write 2023-07-11 23:09:25 +08:00
Jianjun Jiang
db7f87acf7 [fel]rename file.c to misc.c 2023-07-11 21:54:54 +08:00
JianjunJiang
3bca4fc658 [t113]update t113 efuse 2023-07-11 20:31:04 +08:00
JianjunJiang
7cb32b719a [fel]move some source to file.c 2023-07-11 20:27:34 +08:00
JianjunJiang
fad2a97608 [efuse]add some efuse command for t113 2023-07-11 18:48:30 +08:00
JianjunJiang
137e61bdc6 [fel]fix write32 2023-07-11 18:33:04 +08:00
JianjunJiang
452d18dc0b [r128]add efuse extra command for r128 2023-07-11 15:43:07 +08:00
JianjunJiang
eafc9da05a [v851]add efuse extra command for v851 2023-07-11 15:19:41 +08:00
JianjunJiang
189cf4c478 [v831]update v831 payload and add efuse extra command 2023-07-11 15:16:09 +08:00
JianjunJiang
0587e4a009 [v3s]add efuse extra command for v3s 2023-07-11 15:05:27 +08:00
JianjunJiang
eacb6c3f82 [a40i]add efuse extra command for a40i 2023-07-11 15:01:21 +08:00
JianjunJiang
3574a19f33 [t113]add xfel extra efuse dump command support 2023-07-11 14:43:48 +08:00
JianjunJiang
cc2f619067 [t113]add payload read32 and write32 for t113 2023-07-10 20:34:25 +08:00
JianjunJiang
0889c73657 [xfel]bump version to v1.3.2 2023-06-10 18:49:56 +08:00
JianjunJiang
a0b8da2ce5 [payloads][d1]update some Makefiles 2023-06-10 18:48:54 +08:00
JianjunJiang
5cc5569f86 [spi]add wait XCH bit cleared for spi burst transfer 2023-06-10 18:47:02 +08:00
Jianjun Jiang
f4c621d3d0 [t113]add init t113-s4 ddr support 2023-05-28 13:54:20 +08:00
Jianjun Jiang
15a7ad9a67 [README]update readme 2023-05-23 23:13:07 +08:00
Jianjun Jiang
bf41e97246 [xfel]remove some tips for initial ddr sucessed 2023-05-23 23:09:22 +08:00
161 changed files with 15054 additions and 904 deletions

View File

@ -2,7 +2,6 @@
# Top makefile
#
PREFIX ?= /usr/local
CROSS ?=
AS := $(CROSS)gcc -x assembler-with-cpp
@ -10,6 +9,8 @@ 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
@ -17,6 +18,8 @@ CFLAGS := -g -ggdb -Wall -O3
CXXFLAGS := -g -ggdb -Wall -O3
LDFLAGS :=
ARFLAGS := -rcs
OCFLAGS := -v -O binary
ODFLAGS :=
MCFLAGS :=
LIBDIRS :=
@ -25,7 +28,6 @@ LIBS := `pkg-config --libs libusb-1.0`
INCDIRS := -I . `pkg-config --cflags 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))
@ -65,14 +67,14 @@ $(CPPOBJS) : %.o : %.cpp
@$(CXX) $(CXXFLAGS) -MD -MP -MF $@.d $(INCDIRS) -c $< -o $@
install:
install -Dm0755 xfel $(DESTDIR)$(PREFIX)/bin/xfel
install -Dm0644 99-xfel.rules $(DESTDIR)/lib/udev/rules.d/99-xfel.rules
install -Dm0644 LICENSE $(DESTDIR)$(PREFIX)/share/licenses/xfel/LICENSE
install -Dm0755 xfel /usr/local/bin/xfel
install -Dm0644 99-xfel.rules /etc/udev/rules.d/99-xfel.rules
install -Dm0644 LICENSE /usr/share/licenses/xfel/LICENSE
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/xfel
rm -f $(DESTDIR)/lib/udev/rules.d/99-xfel.rules
rm -f $(DESTDIR)$(PREFIX)/share/licenses/xfel/LICENSE
rm -f /usr/local/bin/xfel
rm -f /etc/udev/rules.d/99-xfel.rules
rm -f /usr/share/licenses/xfel/LICENSE
clean:
@$(RM) $(DEPS) $(OBJS) $(NAME).exe $(NAME) *~

70
Makefile.win Normal file
View 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) *~

View File

@ -35,6 +35,7 @@ usage:
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
```
## Links

View File

@ -35,44 +35,62 @@ static int chip_detect(struct xfel_ctx_t * ctx, uint32_t id)
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)
{
uint32_t val;
val = R32(0x01c20c00 + 0x94);
val = payload_read32(ctx, 0x01c20c00 + 0x94);
val &= ~(0xf << 3);
val |= (1 << 3) | (0x1 << 1) | (0x1 << 0);
W32(0x01c20c00 + 0x94, val);
W32(0x01c20c00 + 0x90, (0xa57 << 1) | (1 << 0));
payload_write32(ctx, 0x01c20c00 + 0x94, val);
payload_write32(ctx, 0x01c20c00 + 0x90, (0xa57 << 1) | (1 << 0));
return 1;
}
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)
{
uint32_t id[4];
id[0] = payload_arm_read32(ctx, 0x01c1b200 + 0x0);
id[1] = payload_arm_read32(ctx, 0x01c1b200 + 0x4);
id[2] = payload_arm_read32(ctx, 0x01c1b200 + 0x8);
id[3] = payload_arm_read32(ctx, 0x01c1b200 + 0xc);
id[0] = payload_read32(ctx, 0x01c1b200 + 0x0);
id[1] = payload_read32(ctx, 0x01c1b200 + 0x4);
id[2] = payload_read32(ctx, 0x01c1b200 + 0x8);
id[3] = payload_read32(ctx, 0x01c1b200 + 0xc);
sprintf(sid, "%08x%08x%08x%08x", id[0], id[1], id[2], id[3]);
return 1;
}
@ -1491,8 +1509,56 @@ static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
return 0;
}
static const struct sid_section_t {
char * name;
uint32_t offset;
uint32_t size_bits;
} sids[] = {
{ "chipid", 0x0000, 128 },
{ "in", 0x0010, 256 },
{ "ssk", 0x0030, 128 },
{ "thermal", 0x0040, 32 },
{ "ft-zone", 0x0044, 64 },
{ "tvout", 0x004c, 128 },
{ "rssk", 0x005c, 256 },
{ "hdcp-hash", 0x007c, 128 },
{ "reserved", 0x0090, 896 },
};
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, 0x01c1b200 + 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;
}

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
View 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,
};

258
chips/a733.c Normal file
View 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,
};

View File

@ -69,32 +69,58 @@ static int chip_detect(struct xfel_ctx_t * ctx, uint32_t id)
return 0;
}
static uint32_t payload_read32(struct xfel_ctx_t * ctx, uint32_t addr)
{
static const uint8_t payload[] = {
0x37, 0x03, 0x40, 0x00, 0x73, 0x20, 0x03, 0x7c, 0x37, 0x03, 0x03, 0x00,
0x1b, 0x03, 0x33, 0x01, 0x73, 0x20, 0x23, 0x7c, 0x6f, 0x00, 0x40, 0x00,
0x97, 0x02, 0x00, 0x00, 0x93, 0x82, 0x02, 0x02, 0x83, 0xa2, 0x02, 0x00,
0x83, 0xa2, 0x02, 0x00, 0x17, 0x03, 0x00, 0x00, 0x13, 0x03, 0x43, 0x01,
0x23, 0x20, 0x53, 0x00, 0x67, 0x80, 0x00, 0x00,
};
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[] = {
0x37, 0x03, 0x40, 0x00, 0x73, 0x20, 0x03, 0x7c, 0x37, 0x03, 0x03, 0x00,
0x1b, 0x03, 0x33, 0x01, 0x73, 0x20, 0x23, 0x7c, 0x6f, 0x00, 0x40, 0x00,
0x97, 0x02, 0x00, 0x00, 0x93, 0x82, 0x02, 0x02, 0x83, 0xa2, 0x02, 0x00,
0x17, 0x03, 0x00, 0x00, 0x13, 0x03, 0x83, 0x01, 0x03, 0x23, 0x03, 0x00,
0x23, 0xa0, 0x62, 0x00, 0x67, 0x80, 0x00, 0x00,
};
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)
{
W32(0x020500a0 + 0x08, (0x16aa << 16) | (0x1 << 0));
payload_write32(ctx, 0x020500a0 + 0x08, (0x16aa << 16) | (0x1 << 0));
return 1;
}
static int chip_sid(struct xfel_ctx_t * ctx, char * sid)
{
static const uint8_t payload[] = {
0x37, 0x03, 0x40, 0x00, 0x73, 0x20, 0x03, 0x7c, 0x37, 0x03, 0x03, 0x00,
0x1b, 0x03, 0x33, 0x01, 0x73, 0x20, 0x23, 0x7c, 0x6f, 0x00, 0x40, 0x00,
0x13, 0x01, 0x01, 0xfe, 0x23, 0x34, 0x81, 0x00, 0x23, 0x38, 0x91, 0x00,
0x23, 0x3c, 0x11, 0x00, 0x13, 0x04, 0x05, 0x00, 0x37, 0x15, 0x02, 0x00,
0xef, 0x00, 0x00, 0x02, 0x83, 0x30, 0x81, 0x01, 0x03, 0x34, 0x81, 0x00,
0x83, 0x34, 0x01, 0x01, 0x13, 0x01, 0x01, 0x02, 0x67, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb7, 0x67, 0x00, 0x03,
0x03, 0xa7, 0x07, 0x20, 0x23, 0x20, 0xe5, 0x00, 0x03, 0xa7, 0x47, 0x20,
0x23, 0x22, 0xe5, 0x00, 0x03, 0xa7, 0x87, 0x20, 0x23, 0x24, 0xe5, 0x00,
0x83, 0xa7, 0xc7, 0x20, 0x23, 0x26, 0xf5, 0x00, 0x67, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
uint32_t id[4];
fel_write(ctx, 0x00020000, (void *)&payload[0], sizeof(payload));
fel_exec(ctx, 0x00020000);
fel_read(ctx, 0x00021000, (void *)id, sizeof(id));
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;
}
@ -2977,107 +3003,126 @@ static int chip_spi_init(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t *
0x1b, 0x03, 0x33, 0x01, 0x73, 0x20, 0x23, 0x7c, 0x6f, 0x00, 0x40, 0x00,
0x13, 0x01, 0x01, 0xfe, 0x23, 0x34, 0x81, 0x00, 0x23, 0x38, 0x91, 0x00,
0x23, 0x3c, 0x11, 0x00, 0x13, 0x04, 0x05, 0x00, 0x37, 0x15, 0x02, 0x00,
0xef, 0x00, 0x00, 0x19, 0x83, 0x30, 0x81, 0x01, 0x03, 0x34, 0x81, 0x00,
0xef, 0x00, 0x00, 0x02, 0x83, 0x30, 0x81, 0x01, 0x03, 0x34, 0x81, 0x00,
0x83, 0x34, 0x01, 0x01, 0x13, 0x01, 0x01, 0x02, 0x67, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x88, 0x05, 0x08,
0x93, 0x0e, 0x00, 0x04, 0x13, 0x0e, 0x00, 0x04, 0xb7, 0x56, 0x02, 0x04,
0x93, 0x08, 0xf0, 0xff, 0x37, 0x03, 0x00, 0x80, 0xb3, 0xb7, 0xbe, 0x00,
0x13, 0x07, 0x0e, 0x00, 0x0b, 0x97, 0xf5, 0x40, 0x23, 0xa8, 0xe6, 0x02,
0x93, 0x07, 0x07, 0x00, 0x23, 0xaa, 0xe6, 0x02, 0x23, 0xac, 0xf6, 0x02,
0x1b, 0x07, 0x07, 0x00, 0x93, 0x07, 0x00, 0x00, 0x13, 0x86, 0x06, 0x20,
0x23, 0x00, 0x16, 0x01, 0x9b, 0x87, 0x17, 0x00, 0xe3, 0xcc, 0xe7, 0xfe,
0x83, 0xa7, 0x86, 0x00, 0xb3, 0xe7, 0x67, 0x00, 0x23, 0xa4, 0xf6, 0x00,
0x83, 0xa7, 0xc6, 0x01, 0x93, 0xf7, 0xf7, 0x0f, 0xe3, 0xec, 0xe7, 0xfe,
0x93, 0x07, 0x00, 0x00, 0x03, 0xc8, 0x06, 0x30, 0x13, 0x06, 0x05, 0x00,
0x9b, 0x87, 0x17, 0x00, 0x13, 0x78, 0xf8, 0x0f, 0x63, 0x0e, 0x05, 0x00,
0x0b, 0x58, 0x16, 0x18, 0x13, 0x05, 0x06, 0x00, 0xe3, 0xc2, 0xe7, 0xfe,
0xbb, 0x85, 0xe5, 0x40, 0xe3, 0x96, 0x05, 0xf8, 0x67, 0x80, 0x00, 0x00,
0x1b, 0x86, 0x17, 0x00, 0xe3, 0xd8, 0xe7, 0xfe, 0x03, 0xc8, 0x06, 0x30,
0x9b, 0x87, 0x27, 0x00, 0xe3, 0x52, 0xe6, 0xfe, 0x03, 0xc6, 0x06, 0x30,
0x1b, 0x86, 0x17, 0x00, 0xe3, 0xc6, 0xe7, 0xfe, 0xbb, 0x85, 0xe5, 0x40,
0xe3, 0x90, 0x05, 0xf6, 0x6f, 0xf0, 0x5f, 0xfd, 0x63, 0x86, 0x05, 0x08,
0x93, 0x0e, 0x00, 0x04, 0x13, 0x0e, 0x00, 0x04, 0xb7, 0x56, 0x02, 0x04,
0x93, 0x08, 0xf0, 0xff, 0x37, 0x03, 0x00, 0x80, 0x33, 0xb7, 0xbe, 0x00,
0x93, 0x07, 0x0e, 0x00, 0x8b, 0x97, 0xe5, 0x40, 0x1b, 0x87, 0x07, 0x00,
0x23, 0xa8, 0xe6, 0x02, 0x23, 0xaa, 0xe6, 0x02, 0x23, 0xac, 0xe6, 0x02,
0x93, 0x07, 0x00, 0x00, 0x63, 0x0c, 0x05, 0x04, 0x13, 0x00, 0x00, 0x00,
0x0b, 0x48, 0xf5, 0x80, 0x93, 0x87, 0x17, 0x00, 0x1b, 0x86, 0x07, 0x00,
0x23, 0x80, 0x06, 0x21, 0xe3, 0x48, 0xe6, 0xfe, 0x83, 0xa7, 0x86, 0x00,
0xb3, 0xe7, 0x67, 0x00, 0x23, 0xa4, 0xf6, 0x00, 0x83, 0xa7, 0xc6, 0x01,
0x93, 0xf7, 0xf7, 0x0f, 0xe3, 0xec, 0xe7, 0xfe, 0x93, 0x07, 0x00, 0x00,
0x03, 0xc6, 0x06, 0x30, 0x9b, 0x87, 0x17, 0x00, 0xe3, 0xcc, 0xe7, 0xfe,
0xb3, 0x07, 0xe5, 0x00, 0xbb, 0x85, 0xe5, 0x40, 0x0b, 0x95, 0xa7, 0x42,
0xe3, 0x98, 0x05, 0xf8, 0x67, 0x80, 0x00, 0x00, 0x13, 0x86, 0x06, 0x20,
0x13, 0x00, 0x00, 0x00, 0x23, 0x00, 0x16, 0x01, 0x9b, 0x87, 0x17, 0x00,
0xe3, 0xcc, 0xe7, 0xfe, 0x6f, 0xf0, 0x1f, 0xfb, 0x13, 0x00, 0x00, 0x00,
0x13, 0x00, 0x00, 0x00, 0x13, 0x01, 0x01, 0xf9, 0x13, 0x07, 0x05, 0x00,
0x23, 0x30, 0x41, 0x05, 0x23, 0x3c, 0x51, 0x03, 0x23, 0x38, 0x61, 0x03,
0x23, 0x34, 0x71, 0x03, 0x23, 0x30, 0x81, 0x03, 0x23, 0x34, 0x11, 0x06,
0x23, 0x30, 0x81, 0x06, 0x23, 0x3c, 0x91, 0x04, 0x23, 0x38, 0x21, 0x05,
0x23, 0x34, 0x31, 0x05, 0x23, 0x3c, 0x91, 0x01, 0x13, 0x0c, 0x07, 0x00,
0x8b, 0x47, 0x1c, 0x98, 0xb7, 0xcb, 0xff, 0xff, 0x37, 0xfb, 0xff, 0xff,
0xb7, 0x1a, 0xff, 0xff, 0x37, 0x0a, 0xf1, 0xff, 0x93, 0x06, 0x10, 0x00,
0x9b, 0x8b, 0xfb, 0x00, 0x13, 0x0b, 0xfb, 0x0f, 0x93, 0x8a, 0xfa, 0xff,
0x13, 0x0a, 0xfa, 0xff, 0x63, 0x8a, 0xd7, 0x0a, 0x13, 0x00, 0x00, 0x00,
0x93, 0x06, 0x20, 0x00, 0x63, 0x80, 0xd7, 0x1c, 0x93, 0x06, 0x30, 0x00,
0x63, 0x88, 0xd7, 0x1c, 0x93, 0x06, 0x40, 0x00, 0x63, 0x82, 0xd7, 0x1e,
0x93, 0x06, 0x50, 0x00, 0x63, 0x8e, 0xd7, 0x1e, 0x13, 0x06, 0x60, 0x00,
0x63, 0x86, 0xc7, 0x20, 0x13, 0x07, 0x70, 0x00, 0x63, 0x8e, 0xe7, 0x20,
0x13, 0x07, 0x80, 0x00, 0x63, 0x94, 0xe7, 0x24, 0x23, 0x10, 0x71, 0x01,
0x93, 0x04, 0x01, 0x00, 0x37, 0x54, 0x02, 0x04, 0x93, 0x0c, 0x10, 0x00,
0x93, 0x09, 0xf0, 0xff, 0x37, 0x09, 0x00, 0x80, 0x93, 0x05, 0x20, 0x00,
0x13, 0x85, 0x04, 0x00, 0xef, 0xf0, 0x1f, 0xe9, 0x23, 0x28, 0x94, 0x03,
0x23, 0x2a, 0x94, 0x03, 0x23, 0x2c, 0x94, 0x03, 0x23, 0x00, 0x34, 0x21,
0x83, 0x27, 0x84, 0x00, 0xb3, 0xe7, 0x27, 0x01, 0x23, 0x24, 0xf4, 0x00,
0x83, 0x27, 0xc4, 0x01, 0x93, 0xf7, 0xf7, 0x0f, 0xe3, 0x8c, 0x07, 0xfe,
0x83, 0x47, 0x04, 0x30, 0x93, 0xf7, 0xf7, 0x0f, 0x23, 0x04, 0xf1, 0x00,
0x93, 0xf7, 0x17, 0x00, 0xe3, 0x9e, 0x07, 0xfa, 0x13, 0x07, 0x0c, 0x00,
0x13, 0x0c, 0x07, 0x00, 0x8b, 0x47, 0x1c, 0x98, 0x93, 0x06, 0x10, 0x00,
0xe3, 0x9c, 0xd7, 0xf4, 0x37, 0x07, 0x00, 0x02, 0x83, 0x27, 0x07, 0x06,
0xb7, 0x26, 0x00, 0x00, 0x37, 0x06, 0x02, 0x00, 0xb3, 0xf7, 0x67, 0x01,
0x93, 0xe7, 0x07, 0x20, 0x23, 0x20, 0xf7, 0x06, 0x83, 0x27, 0x07, 0x06,
0x37, 0x05, 0x00, 0xfd, 0x13, 0x05, 0xf5, 0xff, 0xb3, 0xf7, 0x57, 0x01,
0xb3, 0xe7, 0xd7, 0x00, 0x23, 0x20, 0xf7, 0x06, 0x83, 0x26, 0x07, 0x06,
0xb7, 0x27, 0x00, 0x02, 0xb7, 0x55, 0x02, 0x04, 0xb3, 0xf6, 0x46, 0x01,
0xb3, 0xe6, 0xc6, 0x00, 0x23, 0x20, 0xd7, 0x06, 0x83, 0x26, 0x07, 0x06,
0x37, 0x06, 0x10, 0xff, 0x13, 0x06, 0xf6, 0xff, 0xb3, 0xf6, 0xc6, 0x00,
0x37, 0x06, 0x20, 0x00, 0xb3, 0xe6, 0xc6, 0x00, 0x23, 0x20, 0xd7, 0x06,
0x03, 0xa7, 0xc7, 0x96, 0xb7, 0x06, 0x01, 0x00, 0x37, 0x06, 0x00, 0x80,
0x33, 0x67, 0xd7, 0x00, 0x23, 0xa6, 0xe7, 0x96, 0x03, 0xa7, 0x07, 0x94,
0xb7, 0x06, 0x00, 0x80, 0x1b, 0x06, 0x36, 0x08, 0x33, 0x67, 0xd7, 0x00,
0x23, 0xa0, 0xe7, 0x94, 0x03, 0xa7, 0xc7, 0x96, 0x13, 0x67, 0x17, 0x00,
0x23, 0xa6, 0xe7, 0x96, 0x83, 0xa6, 0x07, 0x94, 0x37, 0x57, 0x02, 0x04,
0xb3, 0xf6, 0xa6, 0x00, 0x37, 0x05, 0x00, 0x01, 0xb3, 0xe6, 0xa6, 0x00,
0x23, 0xa0, 0xd7, 0x94, 0x83, 0xa6, 0x07, 0x94, 0x93, 0xf6, 0xf6, 0xcf,
0x23, 0xa0, 0xd7, 0x94, 0x83, 0xa6, 0x07, 0x94, 0x93, 0xf6, 0x06, 0xff,
0x93, 0xe6, 0x56, 0x00, 0x23, 0xa0, 0xd7, 0x94, 0xb7, 0x17, 0x00, 0x00,
0x23, 0xa2, 0xf5, 0x02, 0x83, 0xa7, 0x45, 0x00, 0xb3, 0x67, 0xf6, 0x00,
0x23, 0xa2, 0xf5, 0x00, 0x83, 0x27, 0x47, 0x00, 0x93, 0x96, 0x07, 0x02,
0xe3, 0xcc, 0x06, 0xfe, 0x83, 0x27, 0x87, 0x00, 0xb7, 0x86, 0x00, 0x80,
0x93, 0xf7, 0xc7, 0xff, 0x93, 0xe7, 0x47, 0x04, 0x23, 0x24, 0xf7, 0x00,
0x83, 0x27, 0x87, 0x01, 0xb3, 0xe7, 0xd7, 0x00, 0x23, 0x2c, 0xf7, 0x00,
0x13, 0x07, 0x0c, 0x00, 0x6f, 0xf0, 0xdf, 0xed, 0x37, 0x57, 0x02, 0x04,
0x83, 0x27, 0x87, 0x00, 0x93, 0xf7, 0xf7, 0xf4, 0x23, 0x24, 0xf7, 0x00,
0x13, 0x07, 0x0c, 0x00, 0x6f, 0xf0, 0x5f, 0xec, 0x37, 0x57, 0x02, 0x04,
0x83, 0x27, 0x87, 0x00, 0x93, 0xf7, 0xf7, 0xf4, 0x93, 0xe7, 0x07, 0x08,
0x23, 0x24, 0xf7, 0x00, 0x13, 0x07, 0x0c, 0x00, 0x6f, 0xf0, 0x9f, 0xea,
0x03, 0x44, 0x17, 0x00, 0x13, 0x05, 0x27, 0x00, 0x93, 0x05, 0x04, 0x00,
0x13, 0x04, 0x14, 0x00, 0xef, 0xf0, 0x1f, 0xce, 0x33, 0x0c, 0x8c, 0x00,
0x13, 0x07, 0x0c, 0x00, 0x6f, 0xf0, 0x9f, 0xe8, 0x83, 0x25, 0x57, 0x00,
0x03, 0x65, 0x17, 0x00, 0x13, 0x0c, 0x97, 0x00, 0xef, 0xf0, 0x5f, 0xcc,
0x13, 0x07, 0x0c, 0x00, 0x6f, 0xf0, 0x1f, 0xe7, 0x83, 0x25, 0x57, 0x00,
0x03, 0x65, 0x17, 0x00, 0x13, 0x0c, 0x97, 0x00, 0xef, 0xf0, 0xdf, 0xbe,
0x13, 0x07, 0x0c, 0x00, 0x6f, 0xf0, 0x9f, 0xe5, 0x23, 0x00, 0xd1, 0x00,
0x93, 0x04, 0x01, 0x00, 0x93, 0x05, 0x10, 0x00, 0x13, 0x85, 0x04, 0x00,
0xef, 0xf0, 0x1f, 0xc9, 0x93, 0x05, 0x10, 0x00, 0x13, 0x05, 0x81, 0x00,
0xef, 0xf0, 0x5f, 0xbc, 0x83, 0x47, 0x81, 0x00, 0x93, 0xf7, 0x17, 0x00,
0xe3, 0x90, 0x07, 0xfe, 0x13, 0x07, 0x0c, 0x00, 0x6f, 0xf0, 0x5f, 0xe2,
0x83, 0x30, 0x81, 0x06, 0x03, 0x34, 0x01, 0x06, 0x83, 0x34, 0x81, 0x05,
0x03, 0x39, 0x01, 0x05, 0x83, 0x39, 0x81, 0x04, 0x03, 0x3a, 0x01, 0x04,
0x83, 0x3a, 0x81, 0x03, 0x03, 0x3b, 0x01, 0x03, 0x83, 0x3b, 0x81, 0x02,
0x03, 0x3c, 0x01, 0x02, 0x83, 0x3c, 0x81, 0x01, 0x13, 0x01, 0x01, 0x07,
0x67, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x01, 0x01, 0xfb,
0x23, 0x34, 0x81, 0x04, 0x23, 0x30, 0x91, 0x04, 0x23, 0x3c, 0x21, 0x03,
0x23, 0x38, 0x31, 0x03, 0x23, 0x34, 0x41, 0x03, 0x23, 0x30, 0x51, 0x03,
0x23, 0x3c, 0x61, 0x01, 0x23, 0x38, 0x71, 0x01, 0x23, 0x34, 0x81, 0x01,
0x23, 0x30, 0x91, 0x01, 0x13, 0x08, 0x05, 0x00, 0x0b, 0x47, 0x18, 0x98,
0xb7, 0x57, 0x02, 0x04, 0xb7, 0xcf, 0x00, 0x00, 0x37, 0xfa, 0xff, 0xff,
0xb7, 0x19, 0xff, 0xff, 0x37, 0x09, 0xf1, 0xff, 0xb7, 0x04, 0x10, 0xff,
0x37, 0x04, 0x00, 0xfd, 0xb7, 0x03, 0x00, 0x80, 0x93, 0x06, 0x10, 0x00,
0x13, 0x0f, 0x20, 0x00, 0x93, 0x8f, 0xff, 0x00, 0x93, 0x85, 0x07, 0x03,
0x13, 0x06, 0x20, 0x00, 0x93, 0x08, 0xf0, 0xff, 0x93, 0x0e, 0xf0, 0xff,
0x13, 0x0a, 0xfa, 0x0f, 0x93, 0x89, 0xf9, 0xff, 0x13, 0x09, 0xf9, 0xff,
0x93, 0x84, 0xf4, 0xff, 0x13, 0x04, 0xf4, 0xff, 0x93, 0x83, 0x33, 0x08,
0x63, 0x0c, 0xd7, 0x0c, 0x63, 0x06, 0xe7, 0x1d, 0x13, 0x03, 0x30, 0x00,
0x63, 0x0c, 0x67, 0x1c, 0x13, 0x03, 0x40, 0x00, 0x63, 0x04, 0x67, 0x1e,
0x13, 0x03, 0x50, 0x00, 0x63, 0x06, 0x67, 0x28, 0x13, 0x03, 0x60, 0x00,
0x63, 0x0e, 0x67, 0x32, 0x13, 0x05, 0x70, 0x00, 0x63, 0x00, 0xa7, 0x40,
0x13, 0x05, 0x80, 0x00, 0x63, 0x16, 0xa7, 0x48, 0x37, 0x07, 0xff, 0xff,
0xb3, 0xf2, 0xe2, 0x00, 0xb3, 0xe2, 0xf2, 0x01, 0x13, 0xf3, 0xff, 0x0f,
0x0b, 0xbe, 0x8f, 0x3c, 0x37, 0x05, 0x00, 0x80, 0x23, 0xa0, 0xc5, 0x00,
0x23, 0xaa, 0xc7, 0x02, 0x23, 0xac, 0xc7, 0x02, 0x23, 0x80, 0x67, 0x20,
0x23, 0x80, 0xc7, 0x21, 0x03, 0xa7, 0x87, 0x00, 0x33, 0x67, 0xa7, 0x00,
0x23, 0xa4, 0xe7, 0x00, 0x03, 0xa7, 0x87, 0x00, 0xe3, 0x4e, 0x07, 0xfe,
0x03, 0xa7, 0xc7, 0x01, 0x13, 0x77, 0xe7, 0x0f, 0xe3, 0x0c, 0x07, 0xfe,
0x03, 0xc7, 0x07, 0x30, 0x03, 0xc7, 0x07, 0x30, 0x23, 0xa0, 0xd5, 0x00,
0x23, 0xaa, 0xd7, 0x02, 0x23, 0xac, 0xd7, 0x02, 0x23, 0x80, 0x17, 0x21,
0x03, 0xa7, 0x87, 0x00, 0x33, 0x67, 0xa7, 0x00, 0x23, 0xa4, 0xe7, 0x00,
0x03, 0xa7, 0x87, 0x00, 0xe3, 0x4e, 0x07, 0xfe, 0x03, 0xa7, 0xc7, 0x01,
0x13, 0x77, 0xf7, 0x0f, 0xe3, 0x0c, 0x07, 0xfe, 0x03, 0xc7, 0x07, 0x30,
0x13, 0x77, 0x17, 0x00, 0xe3, 0x16, 0x07, 0xf8, 0x13, 0x05, 0x08, 0x00,
0x13, 0x08, 0x05, 0x00, 0x0b, 0x47, 0x18, 0x98, 0xe3, 0x18, 0xd7, 0xf2,
0x37, 0x05, 0x00, 0x02, 0x03, 0x27, 0x05, 0x06, 0x37, 0x23, 0x00, 0x00,
0x33, 0x77, 0x47, 0x01, 0x13, 0x67, 0x07, 0x20, 0x23, 0x20, 0xe5, 0x06,
0x03, 0x27, 0x05, 0x06, 0x37, 0x0e, 0x20, 0x00, 0x33, 0x77, 0x37, 0x01,
0x33, 0x67, 0x67, 0x00, 0x23, 0x20, 0xe5, 0x06, 0x03, 0x27, 0x05, 0x06,
0x37, 0x03, 0x02, 0x00, 0x33, 0x77, 0x27, 0x01, 0x33, 0x67, 0x67, 0x00,
0x23, 0x20, 0xe5, 0x06, 0x03, 0x23, 0x05, 0x06, 0x37, 0x27, 0x00, 0x02,
0x33, 0x73, 0x93, 0x00, 0x33, 0x63, 0xc3, 0x01, 0x23, 0x20, 0x65, 0x06,
0x03, 0x25, 0xc7, 0x96, 0x37, 0x03, 0x01, 0x00, 0x33, 0x65, 0x65, 0x00,
0x23, 0x26, 0xa7, 0x96, 0x03, 0x25, 0x07, 0x94, 0x37, 0x03, 0x00, 0x80,
0x33, 0x65, 0x65, 0x00, 0x23, 0x20, 0xa7, 0x94, 0x03, 0x25, 0xc7, 0x96,
0x37, 0x03, 0x00, 0x01, 0x13, 0x65, 0x15, 0x00, 0x23, 0x26, 0xa7, 0x96,
0x03, 0x25, 0x07, 0x94, 0x33, 0x75, 0x85, 0x00, 0x33, 0x65, 0x65, 0x00,
0x23, 0x20, 0xa7, 0x94, 0x03, 0x25, 0x07, 0x94, 0x13, 0x75, 0xf5, 0xcf,
0x23, 0x20, 0xa7, 0x94, 0x03, 0x25, 0x07, 0x94, 0x13, 0x75, 0x05, 0xff,
0x13, 0x65, 0x55, 0x00, 0x23, 0x20, 0xa7, 0x94, 0x37, 0x17, 0x00, 0x00,
0x23, 0xa2, 0xe7, 0x02, 0x03, 0xa7, 0x47, 0x00, 0x33, 0xe7, 0xe3, 0x00,
0x1b, 0x07, 0x07, 0x00, 0x23, 0xa2, 0xe7, 0x00, 0x03, 0xa7, 0x47, 0x00,
0xe3, 0x4e, 0x07, 0xfe, 0x03, 0xa7, 0x87, 0x00, 0x37, 0x85, 0x00, 0x80,
0x13, 0x77, 0xc7, 0xff, 0x13, 0x67, 0x47, 0x04, 0x23, 0xa4, 0xe7, 0x00,
0x03, 0xa7, 0x87, 0x01, 0x33, 0x67, 0xa7, 0x00, 0x23, 0xac, 0xe7, 0x00,
0x13, 0x05, 0x08, 0x00, 0x6f, 0xf0, 0x1f, 0xf0, 0x03, 0xa7, 0x87, 0x00,
0x13, 0x05, 0x08, 0x00, 0x13, 0x77, 0xf7, 0xf4, 0x23, 0xa4, 0xe7, 0x00,
0x6f, 0xf0, 0xdf, 0xee, 0x03, 0xa7, 0x87, 0x00, 0x13, 0x05, 0x08, 0x00,
0x13, 0x77, 0xf7, 0xf4, 0x13, 0x67, 0x07, 0x08, 0x23, 0xa4, 0xe7, 0x00,
0x6f, 0xf0, 0x5f, 0xed, 0x03, 0x4e, 0x15, 0x00, 0x13, 0x0c, 0x00, 0x04,
0x93, 0x0a, 0x0e, 0x00, 0x13, 0x05, 0x25, 0x00, 0x93, 0x0b, 0x00, 0x04,
0x37, 0x0b, 0x00, 0x80, 0x63, 0x00, 0x0e, 0x08, 0x33, 0x33, 0xcc, 0x01,
0x13, 0x43, 0x13, 0x00, 0x13, 0x87, 0x0b, 0x00, 0x0b, 0x17, 0x6e, 0x42,
0x23, 0xa0, 0xe5, 0x00, 0x23, 0xaa, 0xe7, 0x02, 0x1b, 0x03, 0x07, 0x00,
0x23, 0xac, 0xe7, 0x02, 0x13, 0x07, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00,
0x8b, 0x4c, 0xe5, 0x80, 0x13, 0x07, 0x17, 0x00, 0x23, 0x80, 0x97, 0x21,
0x9b, 0x0c, 0x07, 0x00, 0xe3, 0xc8, 0x6c, 0xfe, 0x03, 0xa7, 0x87, 0x00,
0x33, 0x67, 0x67, 0x01, 0x23, 0xa4, 0xe7, 0x00, 0x03, 0xa7, 0x87, 0x00,
0xe3, 0x4e, 0x07, 0xfe, 0x03, 0xa7, 0xc7, 0x01, 0x13, 0x77, 0xf7, 0x0f,
0xe3, 0x6c, 0x67, 0xfe, 0x13, 0x07, 0x00, 0x00, 0x83, 0xcc, 0x07, 0x30,
0x1b, 0x07, 0x17, 0x00, 0xe3, 0x4c, 0x67, 0xfe, 0x0b, 0x37, 0x03, 0x7c,
0x3b, 0x0e, 0x6e, 0x40, 0x33, 0x05, 0xe5, 0x00, 0xe3, 0x14, 0x0e, 0xf8,
0x1b, 0x87, 0x1a, 0x00, 0x0b, 0x37, 0x07, 0x7c, 0x33, 0x08, 0xe8, 0x00,
0x13, 0x05, 0x08, 0x00, 0x6f, 0xf0, 0x9f, 0xe2, 0x03, 0x2e, 0x55, 0x00,
0x03, 0x63, 0x15, 0x00, 0x93, 0x0b, 0x00, 0x04, 0x13, 0x0b, 0x00, 0x04,
0xb7, 0x0a, 0x00, 0x80, 0x63, 0x02, 0x0e, 0x08, 0x33, 0xb7, 0xcb, 0x01,
0x13, 0x47, 0x17, 0x00, 0x13, 0x08, 0x0b, 0x00, 0x0b, 0x18, 0xee, 0x42,
0x23, 0xa0, 0x05, 0x01, 0x23, 0xaa, 0x07, 0x03, 0x23, 0xac, 0x07, 0x03,
0x13, 0x07, 0x00, 0x00, 0x63, 0x06, 0x03, 0x06, 0x13, 0x00, 0x00, 0x00,
0x0b, 0x4c, 0xe3, 0x80, 0x13, 0x07, 0x17, 0x00, 0x23, 0x80, 0x87, 0x21,
0x1b, 0x0c, 0x07, 0x00, 0xe3, 0x48, 0x0c, 0xff, 0x03, 0xa7, 0x87, 0x00,
0x33, 0x67, 0x57, 0x01, 0x23, 0xa4, 0xe7, 0x00, 0x03, 0xa7, 0x87, 0x00,
0xe3, 0x4e, 0x07, 0xfe, 0x03, 0xa7, 0xc7, 0x01, 0x13, 0x77, 0xf7, 0x0f,
0xe3, 0x6c, 0x07, 0xff, 0x13, 0x07, 0x00, 0x00, 0x03, 0xcc, 0x07, 0x30,
0x1b, 0x07, 0x17, 0x00, 0xe3, 0x4c, 0x07, 0xff, 0x0b, 0x37, 0x08, 0x7c,
0x33, 0x07, 0xe3, 0x00, 0x3b, 0x0e, 0x0e, 0x41, 0x0b, 0x13, 0x67, 0x42,
0xe3, 0x12, 0x0e, 0xf8, 0x13, 0x08, 0x95, 0x00, 0x13, 0x05, 0x08, 0x00,
0x6f, 0xf0, 0x5f, 0xd8, 0x13, 0x8c, 0x07, 0x20, 0x23, 0x00, 0xdc, 0x01,
0x1b, 0x07, 0x17, 0x00, 0xe3, 0x4c, 0x07, 0xff, 0x6f, 0xf0, 0x1f, 0xfa,
0x03, 0x2e, 0x55, 0x00, 0x03, 0x63, 0x15, 0x00, 0x93, 0x0b, 0x00, 0x04,
0x13, 0x0b, 0x00, 0x04, 0xb7, 0x0a, 0x00, 0x80, 0xe3, 0x06, 0x0e, 0xfc,
0x33, 0xb8, 0xcb, 0x01, 0x13, 0x48, 0x18, 0x00, 0x13, 0x07, 0x0b, 0x00,
0x0b, 0x17, 0x0e, 0x43, 0x23, 0xa0, 0xe5, 0x00, 0x23, 0xaa, 0xe7, 0x02,
0x13, 0x08, 0x07, 0x00, 0x23, 0xac, 0xe7, 0x02, 0x13, 0x8c, 0x07, 0x20,
0x13, 0x07, 0x00, 0x00, 0x23, 0x00, 0xdc, 0x01, 0x1b, 0x07, 0x17, 0x00,
0xe3, 0x4c, 0x07, 0xff, 0x03, 0xa7, 0x87, 0x00, 0x33, 0x67, 0x57, 0x01,
0x23, 0xa4, 0xe7, 0x00, 0x03, 0xa7, 0x87, 0x00, 0xe3, 0x4e, 0x07, 0xfe,
0x03, 0xa7, 0xc7, 0x01, 0x13, 0x77, 0xf7, 0x0f, 0xe3, 0x6c, 0x07, 0xff,
0x13, 0x07, 0x00, 0x00, 0x83, 0xcc, 0x07, 0x30, 0x13, 0x0c, 0x03, 0x00,
0x93, 0xfc, 0xfc, 0x0f, 0x1b, 0x07, 0x17, 0x00, 0x63, 0x00, 0x03, 0x02,
0x8b, 0x5c, 0x1c, 0x18, 0x13, 0x03, 0x0c, 0x00, 0xe3, 0x42, 0x07, 0xff,
0x3b, 0x0e, 0x0e, 0x41, 0xe3, 0x12, 0x0e, 0xf8, 0x13, 0x08, 0x95, 0x00,
0x6f, 0xf0, 0x9f, 0xf4, 0x1b, 0x0c, 0x17, 0x00, 0xe3, 0x56, 0x07, 0xff,
0x83, 0xcc, 0x07, 0x30, 0xe3, 0x52, 0x0c, 0xff, 0x03, 0xcc, 0x07, 0x30,
0x1b, 0x07, 0x27, 0x00, 0x1b, 0x0c, 0x17, 0x00, 0xe3, 0x46, 0x07, 0xff,
0x3b, 0x0e, 0x0e, 0x41, 0xe3, 0x1a, 0x0e, 0xf4, 0x6f, 0xf0, 0x1f, 0xfd,
0x93, 0xf2, 0x02, 0xf0, 0x93, 0xe2, 0x52, 0x00, 0x13, 0x03, 0x50, 0x00,
0x13, 0x0e, 0x10, 0x00, 0x37, 0x05, 0x00, 0x80, 0x23, 0xa0, 0xc5, 0x01,
0x23, 0xaa, 0xc7, 0x03, 0x23, 0xac, 0xc7, 0x03, 0x23, 0x80, 0x67, 0x20,
0x03, 0xa7, 0x87, 0x00, 0x33, 0x67, 0xa7, 0x00, 0x23, 0xa4, 0xe7, 0x00,
0x13, 0x00, 0x00, 0x00, 0x03, 0xa7, 0x87, 0x00, 0xe3, 0x4e, 0x07, 0xfe,
0x03, 0xa7, 0xc7, 0x01, 0x13, 0x77, 0xf7, 0x0f, 0xe3, 0x0c, 0x07, 0xfe,
0x03, 0xc7, 0x07, 0x30, 0x23, 0xa0, 0xd5, 0x00, 0x23, 0xaa, 0xd7, 0x02,
0x23, 0xac, 0xd7, 0x02, 0x23, 0x80, 0x17, 0x21, 0x03, 0xa7, 0x87, 0x00,
0x33, 0x67, 0xa7, 0x00, 0x23, 0xa4, 0xe7, 0x00, 0x13, 0x00, 0x00, 0x00,
0x03, 0xa7, 0x87, 0x00, 0xe3, 0x4e, 0x07, 0xfe, 0x03, 0xa7, 0xc7, 0x01,
0x13, 0x77, 0xf7, 0x0f, 0xe3, 0x0c, 0x07, 0xfe, 0x03, 0xc7, 0x07, 0x30,
0x13, 0x77, 0x17, 0x00, 0xe3, 0x16, 0x07, 0xf8, 0x13, 0x05, 0x08, 0x00,
0x6f, 0xf0, 0x1f, 0xc1, 0x03, 0x34, 0x81, 0x04, 0x83, 0x34, 0x01, 0x04,
0x03, 0x39, 0x81, 0x03, 0x83, 0x39, 0x01, 0x03, 0x03, 0x3a, 0x81, 0x02,
0x83, 0x3a, 0x01, 0x02, 0x03, 0x3b, 0x81, 0x01, 0x83, 0x3b, 0x01, 0x01,
0x03, 0x3c, 0x81, 0x00, 0x83, 0x3c, 0x01, 0x00, 0x13, 0x01, 0x01, 0x05,
0x67, 0x80, 0x00, 0x00
};
fel_write(ctx, 0x00020000, (void *)&payload[0], sizeof(payload));
if(swapbuf)
@ -3096,8 +3141,158 @@ static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
return 1;
}
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", 0x0000, 128 },
{ "brom-conf-try", 0x0010, 32 },
{ "thermal-sensor", 0x0014, 64 },
{ "ft-zone", 0x001c, 128 },
{ "tvout", 0x002c, 32 },
{ "tvout-gamma", 0x0030, 64 },
{ "oem-program", 0x0038, 64 },
{ "write-protect", 0x0040, 32 },
{ "read-protect", 0x0044, 32 },
{ "reserved1", 0x0048, 64 },
{ "huk", 0x0050, 192 },
{ "reserved2", 0x0068, 64 },
{ "rotpk", 0x0070, 256 },
{ "ssk", 0x0090, 256 },
{ "rssk", 0x00b0, 128 },
{ "hdcp-hash", 0x00c0, 128 },
{ "nv1", 0x00d0, 32 },
{ "nv2", 0x00d4, 32 },
{ "reserved3", 0x00d8, 96 },
{ "oem-program-secure", 0x00e4, 224 },
};
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;
}
}
}
}
}
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");
return 0;
}

View File

@ -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,
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, 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,
0x47, 0x10, 0xa0, 0xe3, 0x01, 0x10, 0xc0, 0xe5, 0x4f, 0x10, 0xa0, 0xe3,
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,
0x08, 0x10, 0x90, 0xe5, 0x01, 0xf0, 0x29, 0xe1, 0x1e, 0xff, 0x2f, 0xe1,
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,
0x40, 0x20, 0xa0, 0x23, 0x00, 0x30, 0xa0, 0xe3, 0x07, 0x10, 0xa0, 0xe1,
0x30, 0x20, 0x8e, 0xe5, 0x34, 0x20, 0x8e, 0xe5, 0x38, 0x20, 0x8e, 0xe5,
0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1, 0x00, 0x10, 0xc6, 0xe5,
0xfb, 0xff, 0xff, 0xca, 0x08, 0x30, 0x9e, 0xe5, 0x02, 0x31, 0x83, 0xe3,
0x08, 0x30, 0x8e, 0xe5, 0x1c, 0x30, 0x9e, 0xe5, 0xff, 0x30, 0x03, 0xe2,
0x40, 0x20, 0xa0, 0x23, 0x00, 0x30, 0xa0, 0xe3, 0x07, 0xc0, 0xa0, 0xe1,
0x30, 0x20, 0x81, 0xe5, 0x34, 0x20, 0x81, 0xe5, 0x38, 0x20, 0x81, 0xe5,
0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1, 0x00, 0xc0, 0xc6, 0xe5,
0xfb, 0xff, 0xff, 0xca, 0x08, 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, 0x00, 0x30, 0xa0, 0xe3,
0x00, 0xc0, 0xd4, 0xe5, 0x00, 0x00, 0x50, 0xe3, 0x00, 0x10, 0xa0, 0xe1,
0xff, 0xc0, 0x0c, 0xe2, 0x07, 0x00, 0x00, 0x0a, 0x01, 0x30, 0x83, 0xe2,
0x03, 0x00, 0x52, 0xe1, 0x01, 0xc0, 0xc1, 0xe4, 0x01, 0x00, 0xa0, 0xe1,
0xf5, 0xff, 0xff, 0xca, 0x02, 0x50, 0x55, 0xe0, 0xdf, 0xff, 0xff, 0x1a,
0xf0, 0x80, 0xbd, 0xe8, 0x01, 0x10, 0x83, 0xe2, 0x02, 0x00, 0x51, 0xe1,
0x00, 0xe0, 0xd4, 0xe5, 0x00, 0x00, 0x50, 0xe3, 0x00, 0xc0, 0xa0, 0xe1,
0xff, 0xe0, 0x0e, 0xe2, 0x07, 0x00, 0x00, 0x0a, 0x01, 0x30, 0x83, 0xe2,
0x03, 0x00, 0x52, 0xe1, 0x01, 0xe0, 0xcc, 0xe4, 0x0c, 0x00, 0xa0, 0xe1,
0xf5, 0xff, 0xff, 0xca, 0x02, 0x50, 0x55, 0xe0, 0xdc, 0xff, 0xff, 0x1a,
0xf0, 0x80, 0xbd, 0xe8, 0x01, 0xc0, 0x83, 0xe2, 0x02, 0x00, 0x5c, 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,
0x01, 0x10, 0x83, 0xe2, 0x02, 0x00, 0x51, 0xe1, 0x02, 0x30, 0x83, 0xe2,
0xf7, 0xff, 0xff, 0xba, 0x02, 0x50, 0x55, 0xe0, 0xd0, 0xff, 0xff, 0x1a,
0x00, 0xc0, 0xd4, 0xe5, 0xf5, 0xff, 0xff, 0xda, 0x00, 0xc0, 0xd4, 0xe5,
0x01, 0xc0, 0x83, 0xe2, 0x02, 0x00, 0x5c, 0xe1, 0x02, 0x30, 0x83, 0xe2,
0xf7, 0xff, 0xff, 0xba, 0x02, 0x50, 0x55, 0xe0, 0xcd, 0xff, 0xff, 0x1a,
0xf0, 0x80, 0xbd, 0xe8, 0x00, 0x50, 0xc0, 0x01, 0x00, 0x52, 0xc0, 0x01,
0x00, 0x53, 0xc0, 0x01, 0xf0, 0x40, 0x2d, 0xe9, 0x00, 0x60, 0x51, 0xe2,
0xf0, 0x80, 0xbd, 0x08, 0xa4, 0x10, 0x9f, 0xe5, 0xa4, 0x50, 0x9f, 0xe5,
0xa4, 0x40, 0x9f, 0xe5, 0x00, 0x70, 0xe0, 0xe3, 0x40, 0x00, 0x56, 0xe3,
0xf0, 0x80, 0xbd, 0x08, 0xb0, 0x10, 0x9f, 0xe5, 0xb0, 0x50, 0x9f, 0xe5,
0xb0, 0x40, 0x9f, 0xe5, 0x00, 0x70, 0xe0, 0xe3, 0x40, 0x00, 0x56, 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,
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,
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,
0x00, 0x30, 0xa0, 0xe3, 0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1,
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,
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,
0x50, 0x82, 0x9f, 0xe5, 0x50, 0x52, 0x9f, 0xe5, 0x50, 0x72, 0x9f, 0xe5,
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,
0x08, 0x00, 0x53, 0xe3, 0x7c, 0x00, 0x00, 0x1a, 0x0d, 0x90, 0xa0, 0xe1,
0x08, 0x60, 0x8d, 0xe2, 0xb0, 0x80, 0xcd, 0xe1, 0x02, 0x10, 0xa0, 0xe3,
0x09, 0x00, 0xa0, 0xe1, 0xb0, 0xff, 0xff, 0xeb, 0x01, 0x10, 0xa0, 0xe3,
0x06, 0x00, 0xa0, 0xe1, 0x73, 0xff, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5,
0x09, 0x00, 0xa0, 0xe1, 0xad, 0xff, 0xff, 0xeb, 0x01, 0x10, 0xa0, 0xe3,
0x06, 0x00, 0xa0, 0xe1, 0x6d, 0xff, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5,
0x01, 0x00, 0x13, 0xe3, 0xf6, 0xff, 0xff, 0x1a, 0x04, 0x60, 0xa0, 0xe1,
0x06, 0x40, 0xa0, 0xe1, 0x01, 0x30, 0xd4, 0xe4, 0x01, 0x00, 0x53, 0xe3,
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,
0x08, 0x30, 0x85, 0xe5, 0xa8, 0xff, 0xff, 0xea, 0x01, 0x90, 0xd6, 0xe5,
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,
0x02, 0x40, 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, 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,
0x06, 0x90, 0xd6, 0xe5, 0x01, 0x30, 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, 0x04, 0x34, 0x83, 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,
0x08, 0x60, 0x8d, 0xe2, 0x00, 0x30, 0xcd, 0xe5, 0x01, 0x10, 0xa0, 0xe3,
0x09, 0x00, 0xa0, 0xe1, 0x41, 0xff, 0xff, 0xeb, 0x01, 0x10, 0xa0, 0xe3,
0x06, 0x00, 0xa0, 0xe1, 0x04, 0xff, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5,
0x09, 0x00, 0xa0, 0xe1, 0x3e, 0xff, 0xff, 0xeb, 0x01, 0x10, 0xa0, 0xe3,
0x06, 0x00, 0xa0, 0xe1, 0xfe, 0xfe, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5,
0x01, 0x00, 0x13, 0xe3, 0xf6, 0xff, 0xff, 0x1a, 0x04, 0x60, 0xa0, 0xe1,
0x8f, 0xff, 0xff, 0xea, 0x14, 0xd0, 0x8d, 0xe2, 0xf0, 0x83, 0xbd, 0xe8,
0x0f, 0xc0, 0xff, 0xff, 0x00, 0x50, 0xc0, 0x01, 0x00, 0x00, 0xc2, 0x01,

View File

@ -1030,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,
0x10, 0xef, 0x11, 0xee, 0x0c, 0xe0, 0x80, 0xe5, 0x10, 0xef, 0x1c, 0xee,
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,
0x10, 0x1f, 0x01, 0xee, 0x10, 0x10, 0x90, 0xe5, 0x10, 0x1f, 0x0c, 0xee,
0x0c, 0x10, 0x90, 0xe5, 0x10, 0x1f, 0x01, 0xee, 0x08, 0x10, 0x90, 0xe5,
0x01, 0xf0, 0x29, 0xe1, 0x1e, 0xff, 0x2f, 0xe1, 0xf0, 0x40, 0x2d, 0xe9,
0x00, 0x50, 0x51, 0xe2, 0xf0, 0x80, 0xbd, 0x08, 0x02, 0xe9, 0xa0, 0xe3,
0x82, 0x6c, 0xa0, 0xe3, 0xc6, 0xe1, 0x40, 0xe3, 0x83, 0x4c, 0xa0, 0xe3,
0x00, 0x50, 0x51, 0xe2, 0xf0, 0x80, 0xbd, 0x08, 0x02, 0x19, 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,
0x40, 0x00, 0x55, 0xe3, 0x00, 0x30, 0xa0, 0xe3, 0x07, 0x10, 0xa0, 0xe1,
0x05, 0x20, 0xa0, 0x31, 0x40, 0x20, 0xa0, 0x23, 0x30, 0x20, 0x8e, 0xe5,
0x34, 0x20, 0x8e, 0xe5, 0x38, 0x20, 0x8e, 0xe5, 0x00, 0x10, 0xc6, 0xe5,
0x40, 0x00, 0x55, 0xe3, 0x00, 0x30, 0xa0, 0xe3, 0x07, 0xc0, 0xa0, 0xe1,
0x05, 0x20, 0xa0, 0x31, 0x40, 0x20, 0xa0, 0x23, 0x30, 0x20, 0x81, 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,
0x08, 0x30, 0x9e, 0xe5, 0x02, 0x31, 0x83, 0xe3, 0x08, 0x30, 0x8e, 0xe5,
0x1c, 0x30, 0x9e, 0xe5, 0x73, 0x30, 0xef, 0xe6, 0x03, 0x00, 0x52, 0xe1,
0xfb, 0xff, 0xff, 0x8a, 0x00, 0x30, 0xa0, 0xe3, 0x00, 0xc0, 0xd4, 0xe5,
0x00, 0x00, 0x50, 0xe3, 0x00, 0x10, 0xa0, 0xe1, 0x01, 0x30, 0x83, 0xe2,
0x7c, 0xc0, 0xef, 0xe6, 0x06, 0x00, 0x00, 0x0a, 0x03, 0x00, 0x52, 0xe1,
0x01, 0xc0, 0xc1, 0xe4, 0x01, 0x00, 0xa0, 0xe1, 0xf5, 0xff, 0xff, 0xca,
0x02, 0x50, 0x55, 0xe0, 0xdf, 0xff, 0xff, 0x1a, 0xf0, 0x80, 0xbd, 0xe8,
0x03, 0x00, 0x52, 0xe1, 0x01, 0x10, 0x83, 0xe2, 0x02, 0x30, 0x83, 0xe2,
0xf8, 0xff, 0xff, 0xda, 0x01, 0x00, 0x52, 0xe1, 0x00, 0x10, 0xd4, 0xe5,
0xf5, 0xff, 0xff, 0xda, 0x03, 0x00, 0x52, 0xe1, 0x00, 0x10, 0xd4, 0xe5,
0x01, 0x10, 0x83, 0xe2, 0x02, 0x30, 0x83, 0xe2, 0xf7, 0xff, 0xff, 0xca,
0x02, 0x50, 0x55, 0xe0, 0xd0, 0xff, 0xff, 0x1a, 0xf0, 0x80, 0xbd, 0xe8,
0x08, 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, 0x00, 0x30, 0xa0, 0xe3, 0x00, 0xe0, 0xd4, 0xe5,
0x00, 0x00, 0x50, 0xe3, 0x00, 0xc0, 0xa0, 0xe1, 0x01, 0x30, 0x83, 0xe2,
0x7e, 0xe0, 0xef, 0xe6, 0x06, 0x00, 0x00, 0x0a, 0x03, 0x00, 0x52, 0xe1,
0x01, 0xe0, 0xcc, 0xe4, 0x0c, 0x00, 0xa0, 0xe1, 0xf5, 0xff, 0xff, 0xca,
0x02, 0x50, 0x55, 0xe0, 0xdc, 0xff, 0xff, 0x1a, 0xf0, 0x80, 0xbd, 0xe8,
0x03, 0x00, 0x52, 0xe1, 0x01, 0xc0, 0x83, 0xe2, 0x02, 0x30, 0x83, 0xe2,
0xf8, 0xff, 0xff, 0xda, 0x0c, 0x00, 0x52, 0xe1, 0x00, 0xc0, 0xd4, 0xe5,
0xf5, 0xff, 0xff, 0xda, 0x03, 0x00, 0x52, 0xe1, 0x00, 0xc0, 0xd4, 0xe5,
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,
0x02, 0x19, 0xa0, 0xe3, 0x82, 0x5c, 0xa0, 0xe3, 0xc6, 0x11, 0x40, 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,
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,
0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1, 0x00, 0xe0, 0xc5, 0xe5,
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,
0x00, 0xc0, 0xd4, 0xe5, 0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1,
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,
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,
0x00, 0x40, 0xa0, 0xe3, 0xc2, 0x41, 0x40, 0xe3, 0x14, 0xd0, 0x4d, 0xe2,
0x00, 0x70, 0xa0, 0xe1, 0x07, 0x50, 0xa0, 0xe1, 0x01, 0x30, 0xd5, 0xe4,
@ -1081,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,
0x8a, 0x00, 0x00, 0x1a, 0xb0, 0x80, 0xcd, 0xe1, 0x0d, 0x90, 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,
0x70, 0xff, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5, 0x01, 0x00, 0x13, 0xe3,
0xaa, 0xff, 0xff, 0xeb, 0x01, 0x10, 0xa0, 0xe3, 0x07, 0x00, 0xa0, 0xe1,
0x6a, 0xff, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5, 0x01, 0x00, 0x13, 0xe3,
0xf6, 0xff, 0xff, 0x1a, 0x05, 0x70, 0xa0, 0xe1, 0x07, 0x50, 0xa0, 0xe1,
0x01, 0x30, 0xd5, 0xe4, 0x01, 0x00, 0x53, 0xe3, 0xe0, 0xff, 0xff, 0x1a,
0x48, 0x38, 0x94, 0xe5, 0x01, 0x2a, 0xa0, 0xe3, 0x0f, 0x30, 0xc3, 0xe3,
@ -1108,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,
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, 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,
0x07, 0x00, 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, 0x01, 0x10, 0x57, 0xe5, 0x05, 0x00, 0x57, 0xe5,
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,
0x04, 0x20, 0x57, 0xe5, 0x08, 0x30, 0x57, 0xe5, 0x02, 0xe0, 0x57, 0xe5,
0x06, 0xc0, 0x57, 0xe5, 0x01, 0x24, 0x82, 0xe1, 0x00, 0x34, 0x83, 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,
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,
0x01, 0x10, 0xa0, 0xe3, 0x09, 0x00, 0xa0, 0xe1, 0x30, 0xff, 0xff, 0xeb,
0x01, 0x10, 0xa0, 0xe3, 0x07, 0x00, 0xa0, 0xe1, 0xf3, 0xfe, 0xff, 0xeb,
0x01, 0x10, 0xa0, 0xe3, 0x09, 0x00, 0xa0, 0xe1, 0x2d, 0xff, 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,
0x05, 0x70, 0xa0, 0xe1, 0x81, 0xff, 0xff, 0xea, 0x14, 0xd0, 0x8d, 0xe2,
0xf0, 0x83, 0xbd, 0xe8, 0x04, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x47, 0x4e, 0x55, 0x00, 0x5e, 0xff, 0x86, 0x41,
0x5f, 0x0c, 0x57, 0xc9, 0x77, 0xc7, 0x3f, 0xd6, 0xb6, 0xba, 0x19, 0x4e,
0xf3, 0x48, 0xda, 0x8e, 0x2f, 0x6c, 0x69, 0x62, 0x2f, 0x6c, 0x64, 0x2d,
0x03, 0x00, 0x00, 0x00, 0x47, 0x4e, 0x55, 0x00, 0x89, 0x4f, 0xb3, 0xca,
0xe0, 0xdc, 0x25, 0x96, 0xd3, 0xb0, 0xa9, 0xb1, 0x5f, 0x41, 0x72, 0x84,
0x27, 0x2e, 0x3f, 0x4d, 0x2f, 0x6c, 0x69, 0x62, 0x2f, 0x6c, 0x64, 0x2d,
0x6c, 0x69, 0x6e, 0x75, 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, 0x01, 0x00, 0x00, 0x00, 0x01, 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,
0x05, 0x00, 0x00, 0x00, 0x04, 0x85, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
0xf4, 0x84, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xf5, 0xfe, 0xff, 0x6f, 0x20, 0x85, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x1c, 0x85, 0x00, 0x00, 0x06, 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,
0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x08, 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, 0x20, 0x85, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x85, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
fel_write(ctx, 0x00008000, (void *)&payload[0], sizeof(payload));

File diff suppressed because it is too large Load Diff

View File

@ -5863,74 +5863,83 @@ static int chip_spi_init(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t *
0xbf, 0xf3, 0x4f, 0x8f, 0xbf, 0xf3, 0x6f, 0x8f, 0xdf, 0xf8, 0x14, 0x00,
0x4f, 0xf0, 0x00, 0x01, 0xc0, 0xf8, 0x00, 0x10, 0xbf, 0xf3, 0x4f, 0x8f,
0xbf, 0xf3, 0x6f, 0x8f, 0x00, 0xf0, 0x02, 0xb8, 0x50, 0xef, 0x00, 0xe0,
0x4d, 0xf8, 0x04, 0xed, 0xdf, 0xf8, 0x0c, 0x00, 0x00, 0xf0, 0x8c, 0xf8,
0x4d, 0xf8, 0x04, 0xed, 0xdf, 0xf8, 0x0c, 0x00, 0x00, 0xf0, 0xb8, 0xf8,
0x5d, 0xf8, 0x04, 0xeb, 0x70, 0x47, 0x00, 0x00, 0x00, 0x10, 0x0b, 0x04,
0x00, 0x29, 0x40, 0xd0, 0x70, 0xb5, 0xff, 0x26, 0x8e, 0x46, 0x1f, 0x4d,
0x1f, 0x49, 0x20, 0x4c, 0x72, 0x46, 0x40, 0x2a, 0x28, 0xbf, 0x40, 0x22,
0x00, 0x23, 0xb4, 0x46, 0x0a, 0x63, 0x4a, 0x63, 0x8a, 0x63, 0x01, 0x33,
0x9a, 0x42, 0x85, 0xf8, 0x00, 0xc0, 0xfa, 0xdc, 0x8b, 0x68, 0x43, 0xf0,
0x00, 0x43, 0x8b, 0x60, 0xcb, 0x69, 0xdb, 0xb2, 0x9a, 0x42, 0xfb, 0xd8,
0x00, 0x23, 0x94, 0xf8, 0x00, 0xc0, 0x5f, 0xfa, 0x8c, 0xfc, 0x40, 0xb1,
0x01, 0x33, 0x9a, 0x42, 0x00, 0xf8, 0x01, 0xcb, 0xf5, 0xdc, 0xbe, 0xeb,
0x02, 0x0e, 0xdb, 0xd1, 0x70, 0xbd, 0x03, 0xf1, 0x01, 0x0c, 0x94, 0x45,
0x03, 0xf1, 0x02, 0x03, 0xf5, 0xda, 0x9a, 0x42, 0x94, 0xf8, 0x00, 0xc0,
0xf1, 0xdd, 0x94, 0xf8, 0x00, 0xc0, 0x03, 0xf1, 0x01, 0x0c, 0x94, 0x45,
0x03, 0xf1, 0x02, 0x03, 0xf3, 0xdb, 0xbe, 0xeb, 0x02, 0x0e, 0xc5, 0xd1,
0xe8, 0xe7, 0x70, 0x47, 0x00, 0x92, 0x00, 0x40, 0x00, 0x90, 0x00, 0x40,
0x00, 0x93, 0x00, 0x40, 0x91, 0xb3, 0xf0, 0xb5, 0xff, 0x27, 0x05, 0x46,
0x0e, 0x46, 0x18, 0x4c, 0x18, 0x49, 0x19, 0x48, 0x40, 0x2e, 0x32, 0x46,
0x28, 0xbf, 0x40, 0x22, 0x0a, 0x63, 0x4a, 0x63, 0x8a, 0x63, 0xdd, 0xb1,
0xac, 0x46, 0x00, 0x23, 0x1c, 0xf8, 0x01, 0xeb, 0x01, 0x33, 0x9a, 0x42,
0x84, 0xf8, 0x00, 0xe0, 0xf8, 0xdc, 0x8b, 0x68, 0x43, 0xf0, 0x00, 0x43,
0x8b, 0x60, 0xcb, 0x69, 0xdb, 0xb2, 0x9a, 0x42, 0xfb, 0xd8, 0x00, 0x23,
0x01, 0x33, 0x9a, 0x42, 0x90, 0xf8, 0x00, 0xc0, 0xfa, 0xdc, 0x05, 0xb1,
0x15, 0x44, 0xb6, 0x1a, 0xdc, 0xd1, 0xf0, 0xbd, 0x2b, 0x46, 0xbc, 0x46,
0x01, 0x33, 0x9a, 0x42, 0x84, 0xf8, 0x00, 0xc0, 0xfa, 0xdc, 0xe4, 0xe7,
0x70, 0x47, 0x00, 0xbf, 0x00, 0x92, 0x00, 0x40, 0x00, 0x90, 0x00, 0x40,
0x00, 0x93, 0x00, 0x40, 0x2d, 0xe9, 0xf0, 0x43, 0x06, 0x46, 0x7c, 0x4c,
0xdf, 0xf8, 0xf0, 0x81, 0x7c, 0x4f, 0x85, 0xb0, 0x35, 0x46, 0x15, 0xf8,
0x01, 0x3b, 0x01, 0x2b, 0x2c, 0xd0, 0x02, 0x2b, 0x00, 0xf0, 0x8a, 0x80,
0x03, 0x2b, 0x00, 0xf0, 0x8d, 0x80, 0x04, 0x2b, 0x00, 0xf0, 0x92, 0x80,
0x05, 0x2b, 0x00, 0xf0, 0x99, 0x80, 0x06, 0x2b, 0x00, 0xf0, 0xb0, 0x80,
0x07, 0x2b, 0x00, 0xf0, 0xc7, 0x80, 0x08, 0x2b, 0x40, 0xf0, 0xd7, 0x80,
0x4c, 0xf2, 0x0f, 0x03, 0xe9, 0x46, 0x02, 0xae, 0xad, 0xf8, 0x00, 0x30,
0x02, 0x21, 0x48, 0x46, 0xff, 0xf7, 0x98, 0xff, 0x01, 0x21, 0x30, 0x46,
0xff, 0xf7, 0x4a, 0xff, 0x9d, 0xf8, 0x08, 0x30, 0xdb, 0x07, 0xf3, 0xd4,
0x2e, 0x46, 0x35, 0x46, 0x15, 0xf8, 0x01, 0x3b, 0x01, 0x2b, 0xd2, 0xd1,
0xd8, 0xf8, 0x28, 0x34, 0x4f, 0xf4, 0x80, 0x52, 0x23, 0xf0, 0x0f, 0x03,
0x43, 0xf0, 0x03, 0x03, 0xc8, 0xf8, 0x28, 0x34, 0xd8, 0xf8, 0x28, 0x34,
0x23, 0xf0, 0xf0, 0x03, 0x43, 0xf0, 0x30, 0x03, 0xc8, 0xf8, 0x28, 0x34,
0xd8, 0xf8, 0x28, 0x34, 0x23, 0xf4, 0x70, 0x63, 0x43, 0xf4, 0x40, 0x73,
0xc8, 0xf8, 0x28, 0x34, 0xd8, 0xf8, 0x28, 0x34, 0x23, 0xf4, 0x70, 0x43,
0x43, 0xf4, 0x40, 0x53, 0xc8, 0xf8, 0x28, 0x34, 0xd8, 0xf8, 0x28, 0x34,
0x23, 0xf4, 0x70, 0x23, 0x43, 0xf4, 0x40, 0x33, 0xc8, 0xf8, 0x28, 0x34,
0xd8, 0xf8, 0x28, 0x34, 0x23, 0xf4, 0x70, 0x03, 0x43, 0xf4, 0x40, 0x13,
0xc8, 0xf8, 0x28, 0x34, 0xfb, 0x68, 0x43, 0xf0, 0x01, 0x03, 0xfb, 0x60,
0x7b, 0x68, 0x43, 0xf0, 0x01, 0x03, 0x7b, 0x60, 0x3b, 0x6a, 0x43, 0xf0,
0x00, 0x43, 0x3b, 0x62, 0x3b, 0x6a, 0x23, 0xf0, 0x40, 0x73, 0x3b, 0x62,
0x3b, 0x6a, 0x23, 0xf4, 0x40, 0x33, 0x3b, 0x62, 0x3b, 0x6a, 0x23, 0xf0,
0x0f, 0x03, 0x3b, 0x62, 0x62, 0x62, 0x63, 0x68, 0x43, 0xf0, 0x00, 0x43,
0x43, 0xf0, 0x83, 0x03, 0x63, 0x60, 0x63, 0x68, 0x00, 0x2b, 0xfc, 0xdb,
0xa3, 0x68, 0x2e, 0x46, 0x23, 0xf0, 0x03, 0x03, 0x43, 0xf0, 0x44, 0x03,
0xa3, 0x60, 0xa3, 0x69, 0x43, 0xf0, 0x80, 0x23, 0xa3, 0x61, 0x6d, 0xe7,
0xa3, 0x68, 0x2e, 0x46, 0x23, 0xf0, 0xb0, 0x03, 0xa3, 0x60, 0x67, 0xe7,
0xa3, 0x68, 0x2e, 0x46, 0x23, 0xf0, 0xb0, 0x03, 0x43, 0xf0, 0x80, 0x03,
0xa3, 0x60, 0x5f, 0xe7, 0x96, 0xf8, 0x01, 0x90, 0xb0, 0x1c, 0x49, 0x46,
0x09, 0xf1, 0x01, 0x06, 0xff, 0xf7, 0x14, 0xff, 0x2e, 0x44, 0x55, 0xe7,
0xb0, 0x79, 0x72, 0x79, 0x73, 0x78, 0x96, 0xf8, 0x02, 0xe0, 0x96, 0xf8,
0x07, 0xc0, 0xf5, 0x78, 0x31, 0x7a, 0x42, 0xea, 0x00, 0x22, 0x43, 0xea,
0x0e, 0x23, 0x30, 0x79, 0x42, 0xea, 0x0c, 0x42, 0x43, 0xea, 0x05, 0x43,
0x42, 0xea, 0x01, 0x61, 0x43, 0xea, 0x00, 0x60, 0xff, 0xf7, 0xfa, 0xfe,
0x09, 0x36, 0x3b, 0xe7, 0xb0, 0x79, 0x72, 0x79, 0x73, 0x78, 0x96, 0xf8,
0x02, 0xe0, 0x96, 0xf8, 0x07, 0xc0, 0xf5, 0x78, 0x31, 0x7a, 0x42, 0xea,
0x00, 0x22, 0x43, 0xea, 0x0e, 0x23, 0x30, 0x79, 0x42, 0xea, 0x0c, 0x42,
0x43, 0xea, 0x05, 0x43, 0x42, 0xea, 0x01, 0x61, 0x43, 0xea, 0x00, 0x60,
0xff, 0xf7, 0x96, 0xfe, 0x09, 0x36, 0x21, 0xe7, 0x05, 0x23, 0xe9, 0x46,
0x02, 0xae, 0x8d, 0xf8, 0x00, 0x30, 0x01, 0x21, 0x48, 0x46, 0xff, 0xf7,
0xd5, 0xfe, 0x01, 0x21, 0x30, 0x46, 0xff, 0xf7, 0x87, 0xfe, 0x9d, 0xf8,
0x08, 0x30, 0xda, 0x07, 0xf3, 0xd4, 0x2e, 0x46, 0x3b, 0xe7, 0x05, 0xb0,
0xbd, 0xe8, 0xf0, 0x83, 0x00, 0x90, 0x00, 0x40, 0x00, 0xa0, 0x04, 0x40,
0x00, 0xc0, 0x03, 0x40
0x00, 0x29, 0x4d, 0xd0, 0x2d, 0xe9, 0xf0, 0x47, 0x4f, 0xf0, 0xff, 0x09,
0xdf, 0xf8, 0xa4, 0x80, 0xdf, 0xf8, 0xa4, 0xe0, 0xdf, 0xf8, 0xa4, 0xc0,
0x22, 0x4f, 0x23, 0x4c, 0x23, 0x4d, 0x24, 0x4e, 0x40, 0x29, 0x0a, 0x46,
0x28, 0xbf, 0x40, 0x22, 0x00, 0x23, 0xca, 0x46, 0xc8, 0xf8, 0x00, 0x20,
0xce, 0xf8, 0x00, 0x20, 0xcc, 0xf8, 0x00, 0x20, 0x01, 0x33, 0x9a, 0x42,
0x87, 0xf8, 0x00, 0xa0, 0xfa, 0xdc, 0x23, 0x68, 0x43, 0xf0, 0x00, 0x43,
0x23, 0x60, 0x23, 0x68, 0x00, 0x2b, 0xfc, 0xdb, 0x2b, 0x68, 0xdb, 0xb2,
0x9a, 0x42, 0xfb, 0xd8, 0x00, 0x23, 0x96, 0xf8, 0x00, 0xa0, 0x5f, 0xfa,
0x8a, 0xfa, 0x40, 0xb1, 0x01, 0x33, 0x9a, 0x42, 0x00, 0xf8, 0x01, 0xab,
0xf5, 0xdc, 0x89, 0x1a, 0xd6, 0xd1, 0xbd, 0xe8, 0xf0, 0x87, 0x03, 0xf1,
0x01, 0x0a, 0x92, 0x45, 0x03, 0xf1, 0x02, 0x03, 0xf5, 0xda, 0x9a, 0x42,
0x96, 0xf8, 0x00, 0xa0, 0xf1, 0xdd, 0x96, 0xf8, 0x00, 0xa0, 0x03, 0xf1,
0x01, 0x0a, 0x92, 0x45, 0x03, 0xf1, 0x02, 0x03, 0xf3, 0xdb, 0x89, 0x1a,
0xc0, 0xd1, 0xe8, 0xe7, 0x70, 0x47, 0x00, 0xbf, 0x00, 0x92, 0x00, 0x40,
0x08, 0x90, 0x00, 0x40, 0x1c, 0x90, 0x00, 0x40, 0x00, 0x93, 0x00, 0x40,
0x30, 0x90, 0x00, 0x40, 0x34, 0x90, 0x00, 0x40, 0x38, 0x90, 0x00, 0x40,
0x00, 0x29, 0x40, 0xd0, 0x2d, 0xe9, 0xf0, 0x4f, 0x4f, 0xf0, 0xff, 0x09,
0xdf, 0xf8, 0x88, 0x80, 0xdf, 0xf8, 0x88, 0xe0, 0xdf, 0xf8, 0x88, 0xc0,
0x1b, 0x4f, 0x1c, 0x4c, 0x1c, 0x4d, 0x1d, 0x4e, 0x40, 0x29, 0x0a, 0x46,
0x28, 0xbf, 0x40, 0x22, 0xc8, 0xf8, 0x00, 0x20, 0xce, 0xf8, 0x00, 0x20,
0xcc, 0xf8, 0x00, 0x20, 0xf8, 0xb1, 0x82, 0x46, 0x00, 0x23, 0x1a, 0xf8,
0x01, 0xbb, 0x01, 0x33, 0x9a, 0x42, 0x87, 0xf8, 0x00, 0xb0, 0xf8, 0xdc,
0x23, 0x68, 0x43, 0xf0, 0x00, 0x43, 0x23, 0x60, 0x23, 0x68, 0x00, 0x2b,
0xfc, 0xdb, 0x2b, 0x68, 0xdb, 0xb2, 0x9a, 0x42, 0xfb, 0xd8, 0x00, 0x23,
0x01, 0x33, 0x9a, 0x42, 0x96, 0xf8, 0x00, 0xa0, 0xfa, 0xdc, 0x00, 0xb1,
0x10, 0x44, 0x89, 0x1a, 0xd6, 0xd1, 0xbd, 0xe8, 0xf0, 0x8f, 0x03, 0x46,
0xca, 0x46, 0x01, 0x33, 0x9a, 0x42, 0x87, 0xf8, 0x00, 0xa0, 0xfa, 0xdc,
0xe0, 0xe7, 0x70, 0x47, 0x00, 0x92, 0x00, 0x40, 0x08, 0x90, 0x00, 0x40,
0x1c, 0x90, 0x00, 0x40, 0x00, 0x93, 0x00, 0x40, 0x30, 0x90, 0x00, 0x40,
0x34, 0x90, 0x00, 0x40, 0x38, 0x90, 0x00, 0x40, 0x2d, 0xe9, 0xf0, 0x4f,
0x06, 0x46, 0x7c, 0x4f, 0x7c, 0x4c, 0xdf, 0xf8, 0x04, 0x92, 0xdf, 0xf8,
0x04, 0x82, 0x7b, 0x4d, 0x85, 0xb0, 0xb2, 0x46, 0x1a, 0xf8, 0x01, 0x3b,
0x01, 0x2b, 0x2c, 0xd0, 0x02, 0x2b, 0x00, 0xf0, 0x86, 0x80, 0x03, 0x2b,
0x00, 0xf0, 0x89, 0x80, 0x04, 0x2b, 0x00, 0xf0, 0x8e, 0x80, 0x05, 0x2b,
0x00, 0xf0, 0x95, 0x80, 0x06, 0x2b, 0x00, 0xf0, 0xac, 0x80, 0x07, 0x2b,
0x00, 0xf0, 0xc3, 0x80, 0x08, 0x2b, 0x40, 0xf0, 0xd3, 0x80, 0x4c, 0xf2,
0x0f, 0x03, 0xeb, 0x46, 0xad, 0xf8, 0x00, 0x30, 0x02, 0xae, 0x02, 0x21,
0x58, 0x46, 0xff, 0xf7, 0x7f, 0xff, 0x01, 0x21, 0x30, 0x46, 0xff, 0xf7,
0x1b, 0xff, 0x9d, 0xf8, 0x08, 0x30, 0xdb, 0x07, 0xf3, 0xd4, 0x56, 0x46,
0xb2, 0x46, 0x1a, 0xf8, 0x01, 0x3b, 0x01, 0x2b, 0xd2, 0xd1, 0x23, 0x68,
0x4f, 0xf4, 0x80, 0x56, 0x23, 0xf0, 0x0f, 0x03, 0x43, 0xf0, 0x03, 0x03,
0x23, 0x60, 0x23, 0x68, 0x5d, 0x48, 0x23, 0xf0, 0xf0, 0x03, 0x43, 0xf0,
0x30, 0x03, 0x23, 0x60, 0x23, 0x68, 0x01, 0x46, 0x23, 0xf4, 0x70, 0x63,
0x43, 0xf4, 0x40, 0x73, 0x23, 0x60, 0x23, 0x68, 0x23, 0xf4, 0x70, 0x43,
0x43, 0xf4, 0x40, 0x53, 0x23, 0x60, 0x23, 0x68, 0x23, 0xf4, 0x70, 0x23,
0x43, 0xf4, 0x40, 0x33, 0x23, 0x60, 0x23, 0x68, 0x23, 0xf4, 0x70, 0x03,
0x43, 0xf4, 0x40, 0x13, 0x23, 0x60, 0xd9, 0xf8, 0x00, 0x30, 0x43, 0xf0,
0x01, 0x03, 0xc9, 0xf8, 0x00, 0x30, 0xd8, 0xf8, 0x00, 0x30, 0x43, 0xf0,
0x01, 0x03, 0xc8, 0xf8, 0x00, 0x30, 0x2b, 0x68, 0x43, 0xf0, 0x00, 0x43,
0x2b, 0x60, 0x2b, 0x68, 0x23, 0xf0, 0x40, 0x73, 0x2b, 0x60, 0x2b, 0x68,
0x23, 0xf4, 0x40, 0x33, 0x2b, 0x60, 0x2b, 0x68, 0x23, 0xf0, 0x0f, 0x03,
0x2b, 0x60, 0x41, 0x4b, 0x1e, 0x60, 0x03, 0x68, 0x43, 0xf0, 0x00, 0x43,
0x43, 0xf0, 0x83, 0x03, 0x03, 0x60, 0x0b, 0x68, 0x00, 0x2b, 0xfc, 0xdb,
0x3b, 0x68, 0x3c, 0x49, 0x23, 0xf0, 0x03, 0x03, 0x43, 0xf0, 0x44, 0x03,
0x3b, 0x60, 0x0b, 0x68, 0x56, 0x46, 0x43, 0xf0, 0x80, 0x23, 0x0b, 0x60,
0x71, 0xe7, 0x3b, 0x68, 0x56, 0x46, 0x23, 0xf0, 0xb0, 0x03, 0x3b, 0x60,
0x6b, 0xe7, 0x3b, 0x68, 0x56, 0x46, 0x23, 0xf0, 0xb0, 0x03, 0x43, 0xf0,
0x80, 0x03, 0x3b, 0x60, 0x63, 0xe7, 0x96, 0xf8, 0x01, 0xb0, 0xb0, 0x1c,
0x59, 0x46, 0x0b, 0xf1, 0x01, 0x06, 0xff, 0xf7, 0xff, 0xfe, 0x56, 0x44,
0x59, 0xe7, 0x96, 0xf8, 0x06, 0xc0, 0x72, 0x79, 0xb1, 0x78, 0xf0, 0x79,
0x73, 0x78, 0x42, 0xea, 0x0c, 0x22, 0x96, 0xf8, 0x03, 0xc0, 0x42, 0xea,
0x00, 0x42, 0x43, 0xea, 0x01, 0x23, 0x30, 0x79, 0x31, 0x7a, 0x43, 0xea,
0x0c, 0x43, 0x42, 0xea, 0x01, 0x61, 0x43, 0xea, 0x00, 0x60, 0xff, 0xf7,
0xe5, 0xfe, 0x09, 0x36, 0x3f, 0xe7, 0x96, 0xf8, 0x06, 0xc0, 0x72, 0x79,
0xb1, 0x78, 0xf0, 0x79, 0x73, 0x78, 0x42, 0xea, 0x0c, 0x22, 0x96, 0xf8,
0x03, 0xc0, 0x42, 0xea, 0x00, 0x42, 0x43, 0xea, 0x01, 0x23, 0x30, 0x79,
0x31, 0x7a, 0x43, 0xea, 0x0c, 0x43, 0x42, 0xea, 0x01, 0x61, 0x43, 0xea,
0x00, 0x60, 0xff, 0xf7, 0x6b, 0xfe, 0x09, 0x36, 0x25, 0xe7, 0x05, 0x23,
0xeb, 0x46, 0x8d, 0xf8, 0x00, 0x30, 0x02, 0xae, 0x01, 0x21, 0x58, 0x46,
0xff, 0xf7, 0xc0, 0xfe, 0x01, 0x21, 0x30, 0x46, 0xff, 0xf7, 0x5c, 0xfe,
0x9d, 0xf8, 0x08, 0x30, 0xda, 0x07, 0xf3, 0xd4, 0x56, 0x46, 0x3f, 0xe7,
0x05, 0xb0, 0xbd, 0xe8, 0xf0, 0x8f, 0x00, 0xbf, 0x08, 0x90, 0x00, 0x40,
0x28, 0xa4, 0x04, 0x40, 0x20, 0xc0, 0x03, 0x40, 0x04, 0x90, 0x00, 0x40,
0x24, 0x90, 0x00, 0x40, 0x18, 0x90, 0x00, 0x40, 0x0c, 0xc0, 0x03, 0x40,
0x04, 0xc0, 0x03, 0x40
};
fel_write(ctx, 0x040b0000, (void *)&payload[0], sizeof(payload));
if(swapbuf)
@ -5949,193 +5958,233 @@ static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
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], "exec"))
if(!strcmp(argv[0], "efuse"))
{
argc -= 1;
argv += 1;
if(!strcmp(argv[0], "riscv") && (argc == 2))
if(argc > 0)
{
uint64_t addr = strtoull(argv[1], NULL, 0);
uint32_t val;
/* Set cpu voltage to 1100mV */
val = payload_read32(ctx, 0x40050000 + 0x44);
val &= ~(0x1f << 9);
val |= 0x14 << 9;
payload_write32(ctx, 0x40050000 + 0x44, val);
/* Wakeup enable */
val = payload_read32(ctx, 0x40051400 + 0x100);
val |= 0x1 << 8;
payload_write32(ctx, 0x40051400 + 0x100, val);
/* Enable clk_ck1_c906 */
val = payload_read32(ctx, 0x4004c400 + 0xa4);
val |= 0x1 << 7;
payload_write32(ctx, 0x4004c400 + 0xa4, val);
/* Set clk_ck1_c906 clk to 480M */
val = payload_read32(ctx, 0x4004c400 + 0xa4);
val &= ~(0x7 << 4);
val |= 0x1 << 4;
payload_write32(ctx, 0x4004c400 + 0xa4, val);
/* Set clk_ck_c906 source to clk_ck1_c906 */
val = payload_read32(ctx, 0x4004c400 + 0xe0);
val &= ~(0x1 << 17);
payload_write32(ctx, 0x4004c400 + 0xe0, val);
/* Set clk_c906_sel source to clk_ck_c906 */
val = payload_read32(ctx, 0x4003c000 + 0x64);
val &= ~(0x3 << 4);
val |= 0x2 << 4;
payload_write32(ctx, 0x4003c000 + 0x64, val);
/* Set clk_c906_sel source to clk_ck_c906 */
val = payload_read32(ctx, 0x4003c000 + 0x64);
val |= 1 << 31;
payload_write32(ctx, 0x4003c000 + 0x64, val);
/* Set clk_ck_c906_div to 480M */
val = payload_read32(ctx, 0x4003c000 + 0x64);
val &= ~(0x3 << 0);
val |= 0x0 << 0;
payload_write32(ctx, 0x4003c000 + 0x64, val);
/* Enable riscv clk gating */
val = payload_read32(ctx, 0x4003c000 + 0x14);
val |= 1 << 19;
payload_write32(ctx, 0x4003c000 + 0x14, val);
/* Riscv clk rst */
val = payload_read32(ctx, 0x4003c000 + 0x18);
val |= 1 << 19;
payload_write32(ctx, 0x4003c000 + 0x18, val);
/* Riscv sys apb soft rst */
val = payload_read32(ctx, 0x4003c000 + 0x18);
val |= 1 << 21;
payload_write32(ctx, 0x4003c000 + 0x18, val);
/* Set riscv start address */
payload_write32(ctx, 0x40028000 + 0x004, (uint32_t)((addr >> 0) & 0xffffffff));
payload_write32(ctx, 0x40028000 + 0x008, (uint32_t)((addr >> 32) & 0x000000ff));
/* Riscv core reset */
val = payload_read32(ctx, 0x4003c000 + 0x18);
val |= 1 << 16;
payload_write32(ctx, 0x4003c000 + 0x18, val);
return 1;
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, 0x4004e600 + 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], "dsp") && (argc == 2))
}
else if(!strcmp(argv[0], "exec"))
{
argc -= 1;
argv += 1;
if(argc > 0)
{
uint64_t addr = strtoull(argv[1], NULL, 0);
uint32_t val;
if(!strcmp(argv[0], "riscv") && (argc == 2))
{
uint64_t addr = strtoull(argv[1], NULL, 0);
uint32_t val;
/* Set cpu voltage to 1100mV */
val = payload_read32(ctx, 0x40050000 + 0x44);
val &= ~(0x1f << 9);
val |= 0x14 << 9;
payload_write32(ctx, 0x40050000 + 0x44, val);
/* Set cpu voltage to 1100mV */
val = payload_read32(ctx, 0x40050000 + 0x44);
val &= ~(0x1f << 9);
val |= 0x14 << 9;
payload_write32(ctx, 0x40050000 + 0x44, val);
/* Set dsp voltage to 1200mV */
val = payload_read32(ctx, 0x40050000 + 0x4c);
val &= ~(0x1f << 4);
val |= 0x18 << 4;
payload_write32(ctx, 0x40050000 + 0x4c, val);
/* Wakeup enable */
val = payload_read32(ctx, 0x40051400 + 0x100);
val |= 0x1 << 8;
payload_write32(ctx, 0x40051400 + 0x100, val);
/* Wakeup enable */
val = payload_read32(ctx, 0x40051400 + 0x100);
val |= 0x1 << 12;
payload_write32(ctx, 0x40051400 + 0x100, val);
/* Enable clk_ck1_c906 */
val = payload_read32(ctx, 0x4004c400 + 0xa4);
val |= 0x1 << 7;
payload_write32(ctx, 0x4004c400 + 0xa4, val);
/* Enable clk_ck1_hifi5 */
val = payload_read32(ctx, 0x4004c400 + 0xa4);
val |= 0x1 << 11;
payload_write32(ctx, 0x4004c400 + 0xa4, val);
/* Set clk_ck1_c906 clk to 480M */
val = payload_read32(ctx, 0x4004c400 + 0xa4);
val &= ~(0x7 << 4);
val |= 0x1 << 4;
payload_write32(ctx, 0x4004c400 + 0xa4, val);
/* Enable clk_ck3_hifi5 */
val = payload_read32(ctx, 0x4004c400 + 0xa8);
val |= 0x1 << 11;
payload_write32(ctx, 0x4004c400 + 0xa8, val);
/* Set clk_ck_c906 source to clk_ck1_c906 */
val = payload_read32(ctx, 0x4004c400 + 0xe0);
val &= ~(0x1 << 17);
payload_write32(ctx, 0x4004c400 + 0xe0, val);
/* Set clk_ck3_hifi5 clk to 400M */
val = payload_read32(ctx, 0x4004c400 + 0xa8);
val &= ~(0x7 << 8);
val |= 0x3 << 8;
payload_write32(ctx, 0x4004c400 + 0xa8, val);
/* Set clk_c906_sel source to clk_ck_c906 */
val = payload_read32(ctx, 0x4003c000 + 0x64);
val &= ~(0x3 << 4);
val |= 0x2 << 4;
payload_write32(ctx, 0x4003c000 + 0x64, val);
/* Set clk_ck_hifi5 source to clk_ck3_hifi5 */
val = payload_read32(ctx, 0x4004c400 + 0xe0);
val |= 0x1 << 18;
payload_write32(ctx, 0x4004c400 + 0xe0, val);
/* Set clk_c906_sel source to clk_ck_c906 */
val = payload_read32(ctx, 0x4003c000 + 0x64);
val |= 1 << 31;
payload_write32(ctx, 0x4003c000 + 0x64, val);
/* Set clk_ck_hifi5_div source to clk_ck_hifi5 */
val = payload_read32(ctx, 0x4003c000 + 0x68);
val &= ~(0x3 << 4);
val |= 0x2 << 4;
payload_write32(ctx, 0x4003c000 + 0x68, val);
/* Set clk_ck_c906_div to 480M */
val = payload_read32(ctx, 0x4003c000 + 0x64);
val &= ~(0x3 << 0);
val |= 0x0 << 0;
payload_write32(ctx, 0x4003c000 + 0x64, val);
/* Set dsp_clk_hifi5_div to clk_ck_hifi5 / 1 */
val = payload_read32(ctx, 0x4003c000 + 0x68);
val &= ~(0x3 << 0);
val |= 0x0 << 0;
payload_write32(ctx, 0x4003c000 + 0x68, val);
/* Enable riscv clk gating */
val = payload_read32(ctx, 0x4003c000 + 0x14);
val |= 1 << 19;
payload_write32(ctx, 0x4003c000 + 0x14, val);
/* Hifi5 core clk enable */
val = payload_read32(ctx, 0x4003c000 + 0x68);
val |= 1 << 31;
payload_write32(ctx, 0x4003c000 + 0x68, val);
/* Riscv clk rst */
val = payload_read32(ctx, 0x4003c000 + 0x18);
val |= 1 << 19;
payload_write32(ctx, 0x4003c000 + 0x18, val);
/* Hifi5 clk gating */
val = payload_read32(ctx, 0x4003c000 + 0x14);
val |= 1 << 11;
payload_write32(ctx, 0x4003c000 + 0x14, val);
/* Riscv sys apb soft rst */
val = payload_read32(ctx, 0x4003c000 + 0x18);
val |= 1 << 21;
payload_write32(ctx, 0x4003c000 + 0x18, val);
/* Hifi5 config reset */
val = payload_read32(ctx, 0x4003c000 + 0x18);
val |= 1 << 11;
payload_write32(ctx, 0x4003c000 + 0x18, val);
/* Set riscv start address */
payload_write32(ctx, 0x40028000 + 0x004, (uint32_t)((addr >> 0) & 0xffffffff));
payload_write32(ctx, 0x40028000 + 0x008, (uint32_t)((addr >> 32) & 0x000000ff));
/* Set dsp address */
val = payload_read32(ctx, 0x40023c00 + 0x04);
val |= 1 << 1;
payload_write32(ctx, 0x40023c00 + 0x04, val);
usleep(1000);
payload_write32(ctx, 0x40023c00 + 0x00, (uint32_t)((addr >> 0) & 0xffffffff));
val = payload_read32(ctx, 0x40023c00 + 0x04);
val |= 1 << 0;
payload_write32(ctx, 0x40023c00 + 0x04, val);
/* Riscv core reset */
val = payload_read32(ctx, 0x4003c000 + 0x18);
val |= 1 << 16;
payload_write32(ctx, 0x4003c000 + 0x18, val);
/* Dsp debug reset */
val = payload_read32(ctx, 0x4003c000 + 0x18);
val |= 1 << 14;
payload_write32(ctx, 0x4003c000 + 0x18, val);
return 1;
}
else if(!strcmp(argv[0], "dsp") && (argc == 2))
{
uint64_t addr = strtoull(argv[1], NULL, 0);
uint32_t val;
/* Dsp core reset */
val = payload_read32(ctx, 0x4003c000 + 0x18);
val &= ~(1 << 8);
payload_write32(ctx, 0x4003c000 + 0x18, val);
usleep(10000);
val = payload_read32(ctx, 0x4003c000 + 0x18);
val |= 1 << 8;
payload_write32(ctx, 0x4003c000 + 0x18, val);
/* Set cpu voltage to 1100mV */
val = payload_read32(ctx, 0x40050000 + 0x44);
val &= ~(0x1f << 9);
val |= 0x14 << 9;
payload_write32(ctx, 0x40050000 + 0x44, val);
/* Run */
val = payload_read32(ctx, 0x40023c00 + 0x04);
val &= ~(1 << 0);
payload_write32(ctx, 0x40023c00 + 0x04, val);
/* Set dsp voltage to 1200mV */
val = payload_read32(ctx, 0x40050000 + 0x4c);
val &= ~(0x1f << 4);
val |= 0x18 << 4;
payload_write32(ctx, 0x40050000 + 0x4c, val);
return 1;
/* Wakeup enable */
val = payload_read32(ctx, 0x40051400 + 0x100);
val |= 0x1 << 12;
payload_write32(ctx, 0x40051400 + 0x100, val);
/* Enable clk_ck1_hifi5 */
val = payload_read32(ctx, 0x4004c400 + 0xa4);
val |= 0x1 << 11;
payload_write32(ctx, 0x4004c400 + 0xa4, val);
/* Enable clk_ck3_hifi5 */
val = payload_read32(ctx, 0x4004c400 + 0xa8);
val |= 0x1 << 11;
payload_write32(ctx, 0x4004c400 + 0xa8, val);
/* Set clk_ck3_hifi5 clk to 400M */
val = payload_read32(ctx, 0x4004c400 + 0xa8);
val &= ~(0x7 << 8);
val |= 0x3 << 8;
payload_write32(ctx, 0x4004c400 + 0xa8, val);
/* Set clk_ck_hifi5 source to clk_ck3_hifi5 */
val = payload_read32(ctx, 0x4004c400 + 0xe0);
val |= 0x1 << 18;
payload_write32(ctx, 0x4004c400 + 0xe0, val);
/* Set clk_ck_hifi5_div source to clk_ck_hifi5 */
val = payload_read32(ctx, 0x4003c000 + 0x68);
val &= ~(0x3 << 4);
val |= 0x2 << 4;
payload_write32(ctx, 0x4003c000 + 0x68, val);
/* Set dsp_clk_hifi5_div to clk_ck_hifi5 / 1 */
val = payload_read32(ctx, 0x4003c000 + 0x68);
val &= ~(0x3 << 0);
val |= 0x0 << 0;
payload_write32(ctx, 0x4003c000 + 0x68, val);
/* Hifi5 core clk enable */
val = payload_read32(ctx, 0x4003c000 + 0x68);
val |= 1 << 31;
payload_write32(ctx, 0x4003c000 + 0x68, val);
/* Hifi5 clk gating */
val = payload_read32(ctx, 0x4003c000 + 0x14);
val |= 1 << 11;
payload_write32(ctx, 0x4003c000 + 0x14, val);
/* Hifi5 config reset */
val = payload_read32(ctx, 0x4003c000 + 0x18);
val |= 1 << 11;
payload_write32(ctx, 0x4003c000 + 0x18, val);
/* Set dsp address */
val = payload_read32(ctx, 0x40023c00 + 0x04);
val |= 1 << 1;
payload_write32(ctx, 0x40023c00 + 0x04, val);
usleep(1000);
payload_write32(ctx, 0x40023c00 + 0x00, (uint32_t)((addr >> 0) & 0xffffffff));
val = payload_read32(ctx, 0x40023c00 + 0x04);
val |= 1 << 0;
payload_write32(ctx, 0x40023c00 + 0x04, val);
/* Dsp debug reset */
val = payload_read32(ctx, 0x4003c000 + 0x18);
val |= 1 << 14;
payload_write32(ctx, 0x4003c000 + 0x18, val);
/* Dsp core reset */
val = payload_read32(ctx, 0x4003c000 + 0x18);
val &= ~(1 << 8);
payload_write32(ctx, 0x4003c000 + 0x18, val);
usleep(10000);
val = payload_read32(ctx, 0x4003c000 + 0x18);
val |= 1 << 8;
payload_write32(ctx, 0x4003c000 + 0x18, val);
/* Run */
val = payload_read32(ctx, 0x40023c00 + 0x04);
val &= ~(1 << 0);
payload_write32(ctx, 0x40023c00 + 0x04, val);
return 1;
}
}
}
}
printf("usage:\r\n");
printf(" xfel extra efuse dump - Dump all of the efuse information\r\n");
printf(" xfel extra exec riscv <address> - Boot riscv and jump to address\r\n");
printf(" xfel extra exec dsp <address> - Boot dsp and jump to address\r\n");
return 0;

View File

@ -69,38 +69,56 @@ static int chip_detect(struct xfel_ctx_t * ctx, uint32_t id)
return 0;
}
static int chip_reset(struct xfel_ctx_t * ctx)
static uint32_t payload_read32(struct xfel_ctx_t * ctx, uint32_t addr)
{
W32(0x020500a0 + 0x08, (0x16aa << 16) | (0x1 << 0));
return 1;
}
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),
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), (void *)&val, sizeof(val));
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)
{
payload_write32(ctx, 0x020500a0 + 0x08, (0x16aa << 16) | (0x1 << 0));
return 1;
}
static int chip_sid(struct xfel_ctx_t * ctx, char * sid)
{
uint32_t id[4];
id[0] = payload_arm_read32(ctx, 0x03006200 + 0x0);
id[1] = payload_arm_read32(ctx, 0x03006200 + 0x4);
id[2] = payload_arm_read32(ctx, 0x03006200 + 0x8);
id[3] = payload_arm_read32(ctx, 0x03006200 + 0xc);
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;
}
@ -4237,10 +4255,44 @@ static int chip_ddr(struct xfel_ctx_t * ctx, const char * type)
fel_exec(ctx, 0x00028000);
return 1;
}
else if(strcmp(type, "t113-s4") == 0)
{
static const struct ddr3_param_t ddr3 = {
.dram_clk = 936,
.dram_type = 3,
.dram_zq = 0x7b7bfb,
.dram_odt_en = 0x00,
.dram_para1 = 0x000010d2,
.dram_para2 = 0x0000,
.dram_mr0 = 0x1c70,
.dram_mr1 = 0x042,
.dram_mr2 = 0x18,
.dram_mr3 = 0x0,
.dram_tpr0 = 0x004A2195,
.dram_tpr1 = 0x02423190,
.dram_tpr2 = 0x0008B061,
.dram_tpr3 = 0xB4787896,
.dram_tpr4 = 0x0,
.dram_tpr5 = 0x48484848,
.dram_tpr6 = 0x00000048,
.dram_tpr7 = 0x1620121e,
.dram_tpr8 = 0x0,
.dram_tpr9 = 0x0,
.dram_tpr10 = 0x0,
.dram_tpr11 = 0x00340000,
.dram_tpr12 = 0x00000046,
.dram_tpr13 = 0x34000100,
};
fel_write(ctx, 0x00028000, (void *)&t113_ddr_payload[0], sizeof(t113_ddr_payload));
fel_write(ctx, 0x00028038, (void *)&ddr3, sizeof(ddr3));
fel_exec(ctx, 0x00028000);
return 1;
}
}
printf("usage:\r\n");
printf(" xfel ddr r528-s3 - Initial ddr controller for R528-S3\r\n");
printf(" xfel ddr t113-s3 - Initial ddr controller for T113-S3\r\n");
printf(" xfel ddr t113-s4 - Initial ddr controller for T113-S4\r\n");
return 0;
}
@ -4253,47 +4305,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,
0x10, 0xef, 0x11, 0xee, 0x0c, 0xe0, 0x80, 0xe5, 0x10, 0xef, 0x1c, 0xee,
0x10, 0xe0, 0x80, 0xe5, 0x10, 0xef, 0x11, 0xee, 0x14, 0xe0, 0x80, 0xe5,
0x29, 0x0a, 0xa0, 0xe3, 0x77, 0x00, 0x00, 0xeb, 0x28, 0x00, 0x9f, 0xe5,
0x29, 0x0a, 0xa0, 0xe3, 0x7d, 0x00, 0x00, 0xeb, 0x28, 0x00, 0x9f, 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,
0x0c, 0x10, 0x90, 0xe5, 0x10, 0x1f, 0x01, 0xee, 0x08, 0x10, 0x90, 0xe5,
0x01, 0xf0, 0x29, 0xe1, 0x1e, 0xff, 0x2f, 0xe1, 0xe0, 0x7f, 0x04, 0x00,
0xf0, 0x40, 0x2d, 0xe9, 0x00, 0x50, 0x51, 0xe2, 0xf0, 0x80, 0xbd, 0x08,
0x05, 0xea, 0xa0, 0xe3, 0x52, 0x6c, 0xa0, 0xe3, 0x02, 0xe4, 0x40, 0xe3,
0x05, 0x1a, 0xa0, 0xe3, 0x52, 0x6c, 0xa0, 0xe3, 0x02, 0x14, 0x40, 0xe3,
0x53, 0x4c, 0xa0, 0xe3, 0x02, 0x64, 0x40, 0xe3, 0x00, 0x70, 0xe0, 0xe3,
0x02, 0x44, 0x40, 0xe3, 0x40, 0x00, 0x55, 0xe3, 0x00, 0x30, 0xa0, 0xe3,
0x07, 0x10, 0xa0, 0xe1, 0x05, 0x20, 0xa0, 0x31, 0x40, 0x20, 0xa0, 0x23,
0x30, 0x20, 0x8e, 0xe5, 0x34, 0x20, 0x8e, 0xe5, 0x38, 0x20, 0x8e, 0xe5,
0x00, 0x10, 0xc6, 0xe5, 0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1,
0xfb, 0xff, 0xff, 0xca, 0x08, 0x30, 0x9e, 0xe5, 0x02, 0x31, 0x83, 0xe3,
0x08, 0x30, 0x8e, 0xe5, 0x1c, 0x30, 0x9e, 0xe5, 0x73, 0x30, 0xef, 0xe6,
0x07, 0xc0, 0xa0, 0xe1, 0x05, 0x20, 0xa0, 0x31, 0x40, 0x20, 0xa0, 0x23,
0x30, 0x20, 0x81, 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, 0x08, 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, 0x00, 0x30, 0xa0, 0xe3,
0x00, 0xc0, 0xd4, 0xe5, 0x00, 0x00, 0x50, 0xe3, 0x00, 0x10, 0xa0, 0xe1,
0x01, 0x30, 0x83, 0xe2, 0x7c, 0xc0, 0xef, 0xe6, 0x06, 0x00, 0x00, 0x0a,
0x03, 0x00, 0x52, 0xe1, 0x01, 0xc0, 0xc1, 0xe4, 0x01, 0x00, 0xa0, 0xe1,
0xf5, 0xff, 0xff, 0xca, 0x02, 0x50, 0x55, 0xe0, 0xdf, 0xff, 0xff, 0x1a,
0xf0, 0x80, 0xbd, 0xe8, 0x03, 0x00, 0x52, 0xe1, 0x01, 0x10, 0x83, 0xe2,
0x02, 0x30, 0x83, 0xe2, 0xf8, 0xff, 0xff, 0xda, 0x01, 0x00, 0x52, 0xe1,
0x00, 0x10, 0xd4, 0xe5, 0xf5, 0xff, 0xff, 0xda, 0x03, 0x00, 0x52, 0xe1,
0x00, 0x10, 0xd4, 0xe5, 0x01, 0x10, 0x83, 0xe2, 0x02, 0x30, 0x83, 0xe2,
0xf7, 0xff, 0xff, 0xca, 0x02, 0x50, 0x55, 0xe0, 0xd0, 0xff, 0xff, 0x1a,
0x00, 0xe0, 0xd4, 0xe5, 0x00, 0x00, 0x50, 0xe3, 0x00, 0xc0, 0xa0, 0xe1,
0x01, 0x30, 0x83, 0xe2, 0x7e, 0xe0, 0xef, 0xe6, 0x06, 0x00, 0x00, 0x0a,
0x03, 0x00, 0x52, 0xe1, 0x01, 0xe0, 0xcc, 0xe4, 0x0c, 0x00, 0xa0, 0xe1,
0xf5, 0xff, 0xff, 0xca, 0x02, 0x50, 0x55, 0xe0, 0xdc, 0xff, 0xff, 0x1a,
0xf0, 0x80, 0xbd, 0xe8, 0x03, 0x00, 0x52, 0xe1, 0x01, 0xc0, 0x83, 0xe2,
0x02, 0x30, 0x83, 0xe2, 0xf8, 0xff, 0xff, 0xda, 0x0c, 0x00, 0x52, 0xe1,
0x00, 0xc0, 0xd4, 0xe5, 0xf5, 0xff, 0xff, 0xda, 0x03, 0x00, 0x52, 0xe1,
0x00, 0xc0, 0xd4, 0xe5, 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, 0x05, 0x1a, 0xa0, 0xe3, 0x52, 0x5c, 0xa0, 0xe3,
0x02, 0x14, 0x40, 0xe3, 0x53, 0x4c, 0xa0, 0xe3, 0x02, 0x54, 0x40, 0xe3,
0x00, 0x70, 0xe0, 0xe3, 0x02, 0x44, 0x40, 0xe3, 0x40, 0x00, 0x56, 0xe3,
0x06, 0x20, 0xa0, 0x31, 0x40, 0x20, 0xa0, 0x23, 0x30, 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,
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,
0x00, 0x30, 0xa0, 0xe3, 0x00, 0xc0, 0xd4, 0xe5, 0x01, 0x30, 0x83, 0xe2,
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,
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, 0x05, 0x5a, 0xa0, 0xe3,
0x02, 0x54, 0x40, 0xe3, 0x01, 0x7a, 0xa0, 0xe3, 0x00, 0x72, 0x40, 0xe3,
0x14, 0xd0, 0x4d, 0xe2, 0x00, 0x60, 0xa0, 0xe1, 0x06, 0x40, 0xa0, 0xe1,
@ -4304,8 +4358,8 @@ static int chip_spi_init(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t *
0x6f, 0x00, 0x00, 0x0a, 0x07, 0x00, 0x53, 0xe3, 0x7e, 0x00, 0x00, 0x0a,
0x08, 0x00, 0x53, 0xe3, 0x8b, 0x00, 0x00, 0x1a, 0xb0, 0x80, 0xcd, 0xe1,
0x0d, 0x90, 0xa0, 0xe1, 0x08, 0x60, 0x8d, 0xe2, 0x02, 0x10, 0xa0, 0xe3,
0x09, 0x00, 0xa0, 0xe1, 0xad, 0xff, 0xff, 0xeb, 0x01, 0x10, 0xa0, 0xe3,
0x06, 0x00, 0xa0, 0xe1, 0x70, 0xff, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5,
0x09, 0x00, 0xa0, 0xe1, 0xaa, 0xff, 0xff, 0xeb, 0x01, 0x10, 0xa0, 0xe3,
0x06, 0x00, 0xa0, 0xe1, 0x6a, 0xff, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5,
0x01, 0x00, 0x13, 0xe3, 0xf6, 0xff, 0xff, 0x1a, 0x04, 0x60, 0xa0, 0xe1,
0x06, 0x40, 0xa0, 0xe1, 0x01, 0x30, 0xd4, 0xe4, 0x01, 0x00, 0x53, 0xe3,
0xe0, 0xff, 0xff, 0x1a, 0x02, 0x34, 0xa0, 0xe3, 0x01, 0x1a, 0xa0, 0xe3,
@ -4332,35 +4386,35 @@ 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,
0x08, 0x30, 0x85, 0xe5, 0x99, 0xff, 0xff, 0xea, 0x01, 0x90, 0xd6, 0xe5,
0x02, 0x00, 0x86, 0xe2, 0x09, 0x10, 0xa0, 0xe1, 0x01, 0x60, 0x89, 0xe2,
0x06, 0x60, 0x84, 0xe0, 0x59, 0xff, 0xff, 0xeb, 0x92, 0xff, 0xff, 0xea,
0x06, 0x60, 0x84, 0xe0, 0x56, 0xff, 0xff, 0xeb, 0x92, 0xff, 0xff, 0xea,
0x06, 0x10, 0xd6, 0xe5, 0x09, 0x60, 0x86, 0xe2, 0x07, 0x00, 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,
0x01, 0x10, 0x56, 0xe5, 0x05, 0x00, 0x56, 0xe5, 0x0e, 0x28, 0x82, 0xe1,
0x0c, 0x38, 0x83, 0xe1, 0x01, 0x1c, 0x82, 0xe1, 0x00, 0x0c, 0x83, 0xe1,
0x48, 0xff, 0xff, 0xeb, 0x81, 0xff, 0xff, 0xea, 0x06, 0x10, 0xd6, 0xe5,
0x45, 0xff, 0xff, 0xeb, 0x81, 0xff, 0xff, 0xea, 0x06, 0x10, 0xd6, 0xe5,
0x09, 0x60, 0x86, 0xe2, 0x07, 0x00, 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, 0x01, 0x10, 0x56, 0xe5,
0x05, 0x00, 0x56, 0xe5, 0x0e, 0x28, 0x82, 0xe1, 0x0c, 0x38, 0x83, 0xe1,
0x01, 0x1c, 0x82, 0xe1, 0x00, 0x0c, 0x83, 0xe1, 0xfd, 0xfe, 0xff, 0xeb,
0x01, 0x1c, 0x82, 0xe1, 0x00, 0x0c, 0x83, 0xe1, 0xf7, 0xfe, 0xff, 0xeb,
0x70, 0xff, 0xff, 0xea, 0x0d, 0x90, 0xa0, 0xe1, 0x08, 0x60, 0x8d, 0xe2,
0x05, 0x30, 0xa0, 0xe3, 0x00, 0x30, 0xcd, 0xe5, 0x01, 0x10, 0xa0, 0xe3,
0x09, 0x00, 0xa0, 0xe1, 0x2f, 0xff, 0xff, 0xeb, 0x01, 0x10, 0xa0, 0xe3,
0x06, 0x00, 0xa0, 0xe1, 0xf2, 0xfe, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5,
0x09, 0x00, 0xa0, 0xe1, 0x2c, 0xff, 0xff, 0xeb, 0x01, 0x10, 0xa0, 0xe3,
0x06, 0x00, 0xa0, 0xe1, 0xec, 0xfe, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5,
0x01, 0x00, 0x13, 0xe3, 0xf6, 0xff, 0xff, 0x1a, 0x04, 0x60, 0xa0, 0xe1,
0x80, 0xff, 0xff, 0xea, 0x14, 0xd0, 0x8d, 0xe2, 0xf0, 0x83, 0xbd, 0xe8,
0x04, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x47, 0x4e, 0x55, 0x00, 0x56, 0xf9, 0xd9, 0x45, 0x24, 0x2e, 0xf0, 0x7f,
0xfd, 0xb5, 0xd0, 0xfc, 0xc7, 0x17, 0xf6, 0xf7, 0xcf, 0x29, 0x57, 0x51,
0x47, 0x4e, 0x55, 0x00, 0x22, 0x49, 0xdd, 0x5e, 0x04, 0xd9, 0x56, 0xe6,
0xf2, 0x18, 0x7b, 0x95, 0x0c, 0xc5, 0xa5, 0xff, 0xc5, 0x58, 0xd3, 0x90,
0x2f, 0x6c, 0x69, 0x62, 0x2f, 0x6c, 0x64, 0x2d, 0x6c, 0x69, 0x6e, 0x75,
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,
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xf5, 0xfe, 0xff, 0x6f, 0x28, 0x85, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00,
0x24, 0x85, 0x02, 0x00, 0x06, 0x00, 0x00, 0x00, 0x14, 0x85, 0x02, 0x00,
0xf5, 0xfe, 0xff, 0x6f, 0x40, 0x85, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00,
0x3c, 0x85, 0x02, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2c, 0x85, 0x02, 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,
0x1e, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0xfb, 0xff, 0xff, 0x6f,
@ -4368,7 +4422,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, 0x40, 0x85, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x58, 0x85, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00
};
fel_write(ctx, 0x00028000, (void *)&payload[0], sizeof(payload));
@ -4388,8 +4442,158 @@ static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
return 1;
}
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", 0x0000, 128 },
{ "brom-conf-try", 0x0010, 32 },
{ "thermal-sensor", 0x0014, 64 },
{ "ft-zone", 0x001c, 128 },
{ "tvout", 0x002c, 32 },
{ "tvout-gamma", 0x0030, 64 },
{ "oem-program", 0x0038, 64 },
{ "write-protect", 0x0040, 32 },
{ "read-protect", 0x0044, 32 },
{ "reserved1", 0x0048, 64 },
{ "huk", 0x0050, 192 },
{ "reserved2", 0x0068, 64 },
{ "rotpk", 0x0070, 256 },
{ "ssk", 0x0090, 256 },
{ "rssk", 0x00b0, 128 },
{ "hdcp-hash", 0x00c0, 128 },
{ "nv1", 0x00d0, 32 },
{ "nv2", 0x00d4, 32 },
{ "reserved3", 0x00d8, 96 },
{ "oem-program-secure", 0x00e4, 224 },
};
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;
}
}
}
}
}
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");
return 0;
}

View File

@ -2,7 +2,7 @@
static int chip_detect(struct xfel_ctx_t * ctx, uint32_t id)
{
if(id == 0x00182300)
if(id == 0x00185500)
return 1;
return 0;
}
@ -42,8 +42,8 @@ static int chip_extra(struct xfel_ctx_t * ctx, int argc, char * argv[])
return 0;
}
struct chip_t t507 = {
.name = "T507",
struct chip_t r818 = {
.name = "R818",
.detect = chip_detect,
.reset = chip_reset,
.sid = chip_sid,

55
chips/t536.c Normal file
View 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,
};

View File

@ -7,44 +7,62 @@ static int chip_detect(struct xfel_ctx_t * ctx, uint32_t id)
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)
{
uint32_t val;
val = R32(0x01c20ca0 + 0x18);
val = payload_read32(ctx, 0x01c20ca0 + 0x18);
val &= ~(0xf << 4);
val |= (1 << 4) | (0x1 << 0);
W32(0x01c20ca0 + 0x18, val);
W32(0x01c20ca0 + 0x10, (0xa57 << 1) | (1 << 0));
payload_write32(ctx, 0x01c20ca0 + 0x18, val);
payload_write32(ctx, 0x01c20ca0 + 0x10, (0xa57 << 1) | (1 << 0));
return 1;
}
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)
{
uint32_t id[4];
id[0] = payload_arm_read32(ctx, 0x01c23800 + 0x0);
id[1] = payload_arm_read32(ctx, 0x01c23800 + 0x4);
id[2] = payload_arm_read32(ctx, 0x01c23800 + 0x8);
id[3] = payload_arm_read32(ctx, 0x01c23800 + 0xc);
id[0] = payload_read32(ctx, 0x01c23800 + 0x0);
id[1] = payload_read32(ctx, 0x01c23800 + 0x4);
id[2] = payload_read32(ctx, 0x01c23800 + 0x8);
id[3] = payload_read32(ctx, 0x01c23800 + 0xc);
sprintf(sid, "%08x%08x%08x%08x", id[0], id[1], id[2], id[3]);
return 1;
}
@ -974,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,
0x10, 0xef, 0x11, 0xee, 0x0c, 0xe0, 0x80, 0xe5, 0x10, 0xef, 0x1c, 0xee,
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,
0x10, 0x1f, 0x01, 0xee, 0x10, 0x10, 0x90, 0xe5, 0x10, 0x1f, 0x0c, 0xee,
0x0c, 0x10, 0x90, 0xe5, 0x10, 0x1f, 0x01, 0xee, 0x08, 0x10, 0x90, 0xe5,
0x01, 0xf0, 0x29, 0xe1, 0x1e, 0xff, 0x2f, 0xe1, 0xf0, 0x40, 0x2d, 0xe9,
0x00, 0x50, 0x51, 0xe2, 0xf0, 0x80, 0xbd, 0x08, 0x02, 0xe9, 0xa0, 0xe3,
0x82, 0x6c, 0xa0, 0xe3, 0xc6, 0xe1, 0x40, 0xe3, 0x83, 0x4c, 0xa0, 0xe3,
0x00, 0x50, 0x51, 0xe2, 0xf0, 0x80, 0xbd, 0x08, 0x02, 0x19, 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,
0x40, 0x00, 0x55, 0xe3, 0x00, 0x30, 0xa0, 0xe3, 0x07, 0x10, 0xa0, 0xe1,
0x05, 0x20, 0xa0, 0x31, 0x40, 0x20, 0xa0, 0x23, 0x30, 0x20, 0x8e, 0xe5,
0x34, 0x20, 0x8e, 0xe5, 0x38, 0x20, 0x8e, 0xe5, 0x00, 0x10, 0xc6, 0xe5,
0x40, 0x00, 0x55, 0xe3, 0x00, 0x30, 0xa0, 0xe3, 0x07, 0xc0, 0xa0, 0xe1,
0x05, 0x20, 0xa0, 0x31, 0x40, 0x20, 0xa0, 0x23, 0x30, 0x20, 0x81, 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,
0x08, 0x30, 0x9e, 0xe5, 0x02, 0x31, 0x83, 0xe3, 0x08, 0x30, 0x8e, 0xe5,
0x1c, 0x30, 0x9e, 0xe5, 0x73, 0x30, 0xef, 0xe6, 0x03, 0x00, 0x52, 0xe1,
0xfb, 0xff, 0xff, 0x8a, 0x00, 0x30, 0xa0, 0xe3, 0x00, 0xc0, 0xd4, 0xe5,
0x00, 0x00, 0x50, 0xe3, 0x00, 0x10, 0xa0, 0xe1, 0x01, 0x30, 0x83, 0xe2,
0x7c, 0xc0, 0xef, 0xe6, 0x06, 0x00, 0x00, 0x0a, 0x03, 0x00, 0x52, 0xe1,
0x01, 0xc0, 0xc1, 0xe4, 0x01, 0x00, 0xa0, 0xe1, 0xf5, 0xff, 0xff, 0xca,
0x02, 0x50, 0x55, 0xe0, 0xdf, 0xff, 0xff, 0x1a, 0xf0, 0x80, 0xbd, 0xe8,
0x03, 0x00, 0x52, 0xe1, 0x01, 0x10, 0x83, 0xe2, 0x02, 0x30, 0x83, 0xe2,
0xf8, 0xff, 0xff, 0xda, 0x01, 0x00, 0x52, 0xe1, 0x00, 0x10, 0xd4, 0xe5,
0xf5, 0xff, 0xff, 0xda, 0x03, 0x00, 0x52, 0xe1, 0x00, 0x10, 0xd4, 0xe5,
0x01, 0x10, 0x83, 0xe2, 0x02, 0x30, 0x83, 0xe2, 0xf7, 0xff, 0xff, 0xca,
0x02, 0x50, 0x55, 0xe0, 0xd0, 0xff, 0xff, 0x1a, 0xf0, 0x80, 0xbd, 0xe8,
0x08, 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, 0x00, 0x30, 0xa0, 0xe3, 0x00, 0xe0, 0xd4, 0xe5,
0x00, 0x00, 0x50, 0xe3, 0x00, 0xc0, 0xa0, 0xe1, 0x01, 0x30, 0x83, 0xe2,
0x7e, 0xe0, 0xef, 0xe6, 0x06, 0x00, 0x00, 0x0a, 0x03, 0x00, 0x52, 0xe1,
0x01, 0xe0, 0xcc, 0xe4, 0x0c, 0x00, 0xa0, 0xe1, 0xf5, 0xff, 0xff, 0xca,
0x02, 0x50, 0x55, 0xe0, 0xdc, 0xff, 0xff, 0x1a, 0xf0, 0x80, 0xbd, 0xe8,
0x03, 0x00, 0x52, 0xe1, 0x01, 0xc0, 0x83, 0xe2, 0x02, 0x30, 0x83, 0xe2,
0xf8, 0xff, 0xff, 0xda, 0x0c, 0x00, 0x52, 0xe1, 0x00, 0xc0, 0xd4, 0xe5,
0xf5, 0xff, 0xff, 0xda, 0x03, 0x00, 0x52, 0xe1, 0x00, 0xc0, 0xd4, 0xe5,
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,
0x02, 0x19, 0xa0, 0xe3, 0x82, 0x5c, 0xa0, 0xe3, 0xc6, 0x11, 0x40, 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,
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,
0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1, 0x00, 0xe0, 0xc5, 0xe5,
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,
0x00, 0xc0, 0xd4, 0xe5, 0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1,
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,
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,
0x00, 0x40, 0xa0, 0xe3, 0xc2, 0x41, 0x40, 0xe3, 0x14, 0xd0, 0x4d, 0xe2,
0x00, 0x70, 0xa0, 0xe1, 0x07, 0x50, 0xa0, 0xe1, 0x01, 0x30, 0xd5, 0xe4,
@ -1025,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,
0x8a, 0x00, 0x00, 0x1a, 0xb0, 0x80, 0xcd, 0xe1, 0x0d, 0x90, 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,
0x70, 0xff, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5, 0x01, 0x00, 0x13, 0xe3,
0xaa, 0xff, 0xff, 0xeb, 0x01, 0x10, 0xa0, 0xe3, 0x07, 0x00, 0xa0, 0xe1,
0x6a, 0xff, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5, 0x01, 0x00, 0x13, 0xe3,
0xf6, 0xff, 0xff, 0x1a, 0x05, 0x70, 0xa0, 0xe1, 0x07, 0x50, 0xa0, 0xe1,
0x01, 0x30, 0xd5, 0xe4, 0x01, 0x00, 0x53, 0xe3, 0xe0, 0xff, 0xff, 0x1a,
0x48, 0x38, 0x94, 0xe5, 0x01, 0x2a, 0xa0, 0xe3, 0x0f, 0x30, 0xc3, 0xe3,
@ -1052,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,
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, 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,
0x07, 0x00, 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, 0x01, 0x10, 0x57, 0xe5, 0x05, 0x00, 0x57, 0xe5,
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,
0x04, 0x20, 0x57, 0xe5, 0x08, 0x30, 0x57, 0xe5, 0x02, 0xe0, 0x57, 0xe5,
0x06, 0xc0, 0x57, 0xe5, 0x01, 0x24, 0x82, 0xe1, 0x00, 0x34, 0x83, 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,
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,
0x01, 0x10, 0xa0, 0xe3, 0x09, 0x00, 0xa0, 0xe1, 0x30, 0xff, 0xff, 0xeb,
0x01, 0x10, 0xa0, 0xe3, 0x07, 0x00, 0xa0, 0xe1, 0xf3, 0xfe, 0xff, 0xeb,
0x01, 0x10, 0xa0, 0xe3, 0x09, 0x00, 0xa0, 0xe1, 0x2d, 0xff, 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,
0x05, 0x70, 0xa0, 0xe1, 0x81, 0xff, 0xff, 0xea, 0x14, 0xd0, 0x8d, 0xe2,
0xf0, 0x83, 0xbd, 0xe8, 0x04, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x47, 0x4e, 0x55, 0x00, 0xa5, 0x20, 0xc7, 0xeb,
0xa1, 0x10, 0x58, 0x97, 0xad, 0xa8, 0xd2, 0x63, 0x9e, 0xe3, 0x9c, 0x98,
0x21, 0x5c, 0x23, 0x45, 0x2f, 0x6c, 0x69, 0x62, 0x2f, 0x6c, 0x64, 0x2d,
0x03, 0x00, 0x00, 0x00, 0x47, 0x4e, 0x55, 0x00, 0x1d, 0x30, 0x49, 0x7e,
0xc1, 0xa7, 0xed, 0x9e, 0x86, 0x26, 0xb6, 0x2d, 0x72, 0x23, 0xfe, 0x65,
0x09, 0x25, 0x9d, 0xb7, 0x2f, 0x6c, 0x69, 0x62, 0x2f, 0x6c, 0x64, 0x2d,
0x6c, 0x69, 0x6e, 0x75, 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, 0x01, 0x00, 0x00, 0x00, 0x01, 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,
0x05, 0x00, 0x00, 0x00, 0x1c, 0x85, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
0x0c, 0x85, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xf5, 0xfe, 0xff, 0x6f, 0x38, 0x85, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00, 0x34, 0x85, 0x00, 0x00, 0x06, 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,
0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x08, 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, 0x38, 0x85, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x85, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
fel_write(ctx, 0x00008000, (void *)&payload[0], sizeof(payload));
@ -1108,8 +1128,49 @@ static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
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;
}

1742
chips/v821.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -7,44 +7,62 @@ static int chip_detect(struct xfel_ctx_t * ctx, uint32_t id)
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)
{
uint32_t val;
val = R32(0x030090a0 + 0x18);
val = payload_read32(ctx, 0x030090a0 + 0x18);
val &= ~(0xf << 4);
val |= (1 << 4) | (0x1 << 0);
W32(0x030090a0 + 0x18, val);
W32(0x030090a0 + 0x10, (0xa57 << 1) | (1 << 0));
payload_write32(ctx, 0x030090a0 + 0x18, val);
payload_write32(ctx, 0x030090a0 + 0x10, (0xa57 << 1) | (1 << 0));
return 1;
}
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)
{
uint32_t id[4];
id[0] = payload_arm_read32(ctx, 0x03006200 + 0x0);
id[1] = payload_arm_read32(ctx, 0x03006200 + 0x4);
id[2] = payload_arm_read32(ctx, 0x03006200 + 0x8);
id[3] = payload_arm_read32(ctx, 0x03006200 + 0xc);
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;
}
@ -52,6 +70,8 @@ static int chip_sid(struct xfel_ctx_t * ctx, char * sid)
static int chip_jtag(struct xfel_ctx_t * ctx)
{
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,
0x04, 0xe0, 0x80, 0xe5, 0x00, 0xe0, 0x0f, 0xe1, 0x08, 0xe0, 0x80, 0xe5,
0x10, 0xef, 0x11, 0xee, 0x0c, 0xe0, 0x80, 0xe5, 0x10, 0xef, 0x1c, 0xee,
@ -68,16 +88,16 @@ static int chip_jtag(struct xfel_ctx_t * ctx)
0xb4, 0x20, 0x83, 0xe5, 0xb4, 0x20, 0x93, 0xe5, 0x0f, 0x26, 0xc2, 0xe3,
0x03, 0x26, 0x82, 0xe3, 0xb4, 0x20, 0x83, 0xe5, 0x1e, 0xff, 0x2f, 0xe1,
0x04, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
0x47, 0x4e, 0x55, 0x00, 0x90, 0xef, 0xd5, 0xd4, 0xf9, 0x31, 0x90, 0x65,
0x03, 0xd6, 0xb2, 0x35, 0x09, 0xe0, 0x16, 0x82, 0x15, 0xe2, 0xb6, 0xcc,
0x47, 0x4e, 0x55, 0x00, 0x09, 0xd0, 0xba, 0x36, 0x1c, 0xcc, 0x6b, 0x64,
0xc9, 0x91, 0x95, 0xfd, 0x5a, 0xd8, 0x85, 0x3e, 0xe9, 0x1d, 0x1f, 0x00,
0x2f, 0x6c, 0x69, 0x62, 0x2f, 0x6c, 0x64, 0x2d, 0x6c, 0x69, 0x6e, 0x75,
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,
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 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,
0x04, 0x21, 0x02, 0x00, 0x06, 0x00, 0x00, 0x00, 0xf4, 0x20, 0x02, 0x00,
0xf5, 0xfe, 0xff, 0x6f, 0x20, 0x21, 0x02, 0x00, 0x05, 0x00, 0x00, 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,
0x10, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x1e, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0xfb, 0xff, 0xff, 0x6f,
@ -85,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, 0x20, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x38, 0x21, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00
};
fel_write(ctx, 0x00022000, (void *)&payload[0], sizeof(payload));
@ -1217,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 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,
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, 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,
0x10, 0x1f, 0x01, 0xee, 0x10, 0x10, 0x90, 0xe5, 0x10, 0x1f, 0x0c, 0xee,
0x0c, 0x10, 0x90, 0xe5, 0x10, 0x1f, 0x01, 0xee, 0x08, 0x10, 0x90, 0xe5,
0x01, 0xf0, 0x29, 0xe1, 0x1e, 0xff, 0x2f, 0xe1, 0xf8, 0x7f, 0x03, 0x00,
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,
0x01, 0x45, 0x40, 0xe3, 0x40, 0x00, 0x55, 0xe3, 0x00, 0x30, 0xa0, 0xe3,
0x07, 0x10, 0xa0, 0xe1, 0x05, 0x20, 0xa0, 0x31, 0x40, 0x20, 0xa0, 0x23,
0x30, 0x20, 0x8e, 0xe5, 0x34, 0x20, 0x8e, 0xe5, 0x38, 0x20, 0x8e, 0xe5,
0x00, 0x10, 0xc6, 0xe5, 0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1,
0xfb, 0xff, 0xff, 0xca, 0x08, 0x30, 0x9e, 0xe5, 0x02, 0x31, 0x83, 0xe3,
0x08, 0x30, 0x8e, 0xe5, 0x1c, 0x30, 0x9e, 0xe5, 0x73, 0x30, 0xef, 0xe6,
0x07, 0xc0, 0xa0, 0xe1, 0x05, 0x20, 0xa0, 0x31, 0x40, 0x20, 0xa0, 0x23,
0x30, 0x20, 0x81, 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, 0x08, 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, 0x00, 0x30, 0xa0, 0xe3,
0x00, 0xc0, 0xd4, 0xe5, 0x00, 0x00, 0x50, 0xe3, 0x00, 0x10, 0xa0, 0xe1,
0x01, 0x30, 0x83, 0xe2, 0x7c, 0xc0, 0xef, 0xe6, 0x06, 0x00, 0x00, 0x0a,
0x03, 0x00, 0x52, 0xe1, 0x01, 0xc0, 0xc1, 0xe4, 0x01, 0x00, 0xa0, 0xe1,
0xf5, 0xff, 0xff, 0xca, 0x02, 0x50, 0x55, 0xe0, 0xdf, 0xff, 0xff, 0x1a,
0xf0, 0x80, 0xbd, 0xe8, 0x03, 0x00, 0x52, 0xe1, 0x01, 0x10, 0x83, 0xe2,
0x02, 0x30, 0x83, 0xe2, 0xf8, 0xff, 0xff, 0xda, 0x01, 0x00, 0x52, 0xe1,
0x00, 0x10, 0xd4, 0xe5, 0xf5, 0xff, 0xff, 0xda, 0x03, 0x00, 0x52, 0xe1,
0x00, 0x10, 0xd4, 0xe5, 0x01, 0x10, 0x83, 0xe2, 0x02, 0x30, 0x83, 0xe2,
0xf7, 0xff, 0xff, 0xca, 0x02, 0x50, 0x55, 0xe0, 0xd0, 0xff, 0xff, 0x1a,
0x00, 0xe0, 0xd4, 0xe5, 0x00, 0x00, 0x50, 0xe3, 0x00, 0xc0, 0xa0, 0xe1,
0x01, 0x30, 0x83, 0xe2, 0x7e, 0xe0, 0xef, 0xe6, 0x06, 0x00, 0x00, 0x0a,
0x03, 0x00, 0x52, 0xe1, 0x01, 0xe0, 0xcc, 0xe4, 0x0c, 0x00, 0xa0, 0xe1,
0xf5, 0xff, 0xff, 0xca, 0x02, 0x50, 0x55, 0xe0, 0xdc, 0xff, 0xff, 0x1a,
0xf0, 0x80, 0xbd, 0xe8, 0x03, 0x00, 0x52, 0xe1, 0x01, 0xc0, 0x83, 0xe2,
0x02, 0x30, 0x83, 0xe2, 0xf8, 0xff, 0xff, 0xda, 0x0c, 0x00, 0x52, 0xe1,
0x00, 0xc0, 0xd4, 0xe5, 0xf5, 0xff, 0xff, 0xda, 0x03, 0x00, 0x52, 0xe1,
0x00, 0xc0, 0xd4, 0xe5, 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, 0x00, 0x10, 0xa0, 0xe3, 0x02, 0x5c, 0xa0, 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,
0x06, 0x20, 0xa0, 0x31, 0x40, 0x20, 0xa0, 0x23, 0x30, 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,
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,
0x00, 0x30, 0xa0, 0xe3, 0x00, 0xc0, 0xd4, 0xe5, 0x01, 0x30, 0x83, 0xe2,
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,
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,
0x01, 0x55, 0x40, 0xe3, 0x0b, 0x7a, 0xa0, 0xe3, 0x00, 0x73, 0x40, 0xe3,
0x14, 0xd0, 0x4d, 0xe2, 0x00, 0x60, 0xa0, 0xe1, 0x06, 0x40, 0xa0, 0xe1,
@ -1272,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,
0x08, 0x00, 0x53, 0xe3, 0x8c, 0x00, 0x00, 0x1a, 0xb0, 0x80, 0xcd, 0xe1,
0x0d, 0x90, 0xa0, 0xe1, 0x08, 0x60, 0x8d, 0xe2, 0x02, 0x10, 0xa0, 0xe3,
0x09, 0x00, 0xa0, 0xe1, 0xad, 0xff, 0xff, 0xeb, 0x01, 0x10, 0xa0, 0xe3,
0x06, 0x00, 0xa0, 0xe1, 0x70, 0xff, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5,
0x09, 0x00, 0xa0, 0xe1, 0xaa, 0xff, 0xff, 0xeb, 0x01, 0x10, 0xa0, 0xe3,
0x06, 0x00, 0xa0, 0xe1, 0x6a, 0xff, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5,
0x01, 0x00, 0x13, 0xe3, 0xf6, 0xff, 0xff, 0x1a, 0x04, 0x60, 0xa0, 0xe1,
0x06, 0x40, 0xa0, 0xe1, 0x01, 0x30, 0xd4, 0xe4, 0x01, 0x00, 0x53, 0xe3,
0xe0, 0xff, 0xff, 0x1a, 0x48, 0x20, 0x97, 0xe5, 0x01, 0x3a, 0xa0, 0xe3,
@ -1300,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,
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, 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,
0x07, 0x00, 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, 0x01, 0x10, 0x56, 0xe5, 0x05, 0x00, 0x56, 0xe5,
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,
0x04, 0x20, 0x56, 0xe5, 0x08, 0x30, 0x56, 0xe5, 0x02, 0xe0, 0x56, 0xe5,
0x06, 0xc0, 0x56, 0xe5, 0x01, 0x24, 0x82, 0xe1, 0x00, 0x34, 0x83, 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,
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,
0x01, 0x10, 0xa0, 0xe3, 0x09, 0x00, 0xa0, 0xe1, 0x2e, 0xff, 0xff, 0xeb,
0x01, 0x10, 0xa0, 0xe3, 0x06, 0x00, 0xa0, 0xe1, 0xf1, 0xfe, 0xff, 0xeb,
0x01, 0x10, 0xa0, 0xe3, 0x09, 0x00, 0xa0, 0xe1, 0x2b, 0xff, 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,
0x04, 0x60, 0xa0, 0xe1, 0x7f, 0xff, 0xff, 0xea, 0x14, 0xd0, 0x8d, 0xe2,
0xf0, 0x83, 0xbd, 0xe8, 0x04, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00, 0x47, 0x4e, 0x55, 0x00, 0xbe, 0x5b, 0x1d, 0xa0,
0x00, 0xaf, 0x04, 0x3c, 0x40, 0x15, 0xc5, 0xde, 0x21, 0x29, 0xbc, 0xb6,
0x9f, 0x83, 0xa6, 0x42, 0x2f, 0x6c, 0x69, 0x62, 0x2f, 0x6c, 0x64, 0x2d,
0x03, 0x00, 0x00, 0x00, 0x47, 0x4e, 0x55, 0x00, 0x7e, 0xf1, 0x42, 0x24,
0x25, 0xf1, 0x0c, 0x1b, 0x69, 0xe5, 0x0b, 0x13, 0x65, 0x6b, 0x15, 0x0a,
0xcb, 0x0f, 0xb5, 0xcb, 0x2f, 0x6c, 0x69, 0x62, 0x2f, 0x6c, 0x64, 0x2d,
0x6c, 0x69, 0x6e, 0x75, 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, 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, 0xf5, 0xfe, 0xff, 0x6f,
0x14, 0x25, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x10, 0x25, 0x02, 0x00,
0x06, 0x00, 0x00, 0x00, 0x00, 0x25, 0x02, 0x00, 0x0a, 0x00, 0x00, 0x00,
0x44, 0x25, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x40, 0x25, 0x02, 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,
0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00, 0xfb, 0xff, 0xff, 0x6f, 0x01, 0x00, 0x00, 0x08,
@ -1337,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,
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));
if(swapbuf)
@ -1356,8 +1380,49 @@ static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
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;
}

View File

@ -63,38 +63,56 @@ static int chip_detect(struct xfel_ctx_t * ctx, uint32_t id)
return 0;
}
static int chip_reset(struct xfel_ctx_t * ctx)
static uint32_t payload_read32(struct xfel_ctx_t * ctx, uint32_t addr)
{
W32(0x020500a0 + 0x08, (0x16aa << 16) | (0x1 << 0));
return 1;
}
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),
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), (void *)&val, sizeof(val));
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)
{
payload_write32(ctx, 0x020500a0 + 0x08, (0x16aa << 16) | (0x1 << 0));
return 1;
}
static int chip_sid(struct xfel_ctx_t * ctx, char * sid)
{
uint32_t id[4];
id[0] = payload_arm_read32(ctx, 0x03006200 + 0x0);
id[1] = payload_arm_read32(ctx, 0x03006200 + 0x4);
id[2] = payload_arm_read32(ctx, 0x03006200 + 0x8);
id[3] = payload_arm_read32(ctx, 0x03006200 + 0xc);
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;
}
@ -1457,47 +1475,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,
0x10, 0xef, 0x11, 0xee, 0x0c, 0xe0, 0x80, 0xe5, 0x10, 0xef, 0x1c, 0xee,
0x10, 0xe0, 0x80, 0xe5, 0x10, 0xef, 0x11, 0xee, 0x14, 0xe0, 0x80, 0xe5,
0x29, 0x0a, 0xa0, 0xe3, 0x77, 0x00, 0x00, 0xeb, 0x28, 0x00, 0x9f, 0xe5,
0x29, 0x0a, 0xa0, 0xe3, 0x7d, 0x00, 0x00, 0xeb, 0x28, 0x00, 0x9f, 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,
0x0c, 0x10, 0x90, 0xe5, 0x10, 0x1f, 0x01, 0xee, 0x08, 0x10, 0x90, 0xe5,
0x01, 0xf0, 0x29, 0xe1, 0x1e, 0xff, 0x2f, 0xe1, 0xe0, 0x0f, 0x04, 0x00,
0xf0, 0x40, 0x2d, 0xe9, 0x00, 0x50, 0x51, 0xe2, 0xf0, 0x80, 0xbd, 0x08,
0x05, 0xea, 0xa0, 0xe3, 0x52, 0x6c, 0xa0, 0xe3, 0x02, 0xe4, 0x40, 0xe3,
0x05, 0x1a, 0xa0, 0xe3, 0x52, 0x6c, 0xa0, 0xe3, 0x02, 0x14, 0x40, 0xe3,
0x53, 0x4c, 0xa0, 0xe3, 0x02, 0x64, 0x40, 0xe3, 0x00, 0x70, 0xe0, 0xe3,
0x02, 0x44, 0x40, 0xe3, 0x40, 0x00, 0x55, 0xe3, 0x00, 0x30, 0xa0, 0xe3,
0x07, 0x10, 0xa0, 0xe1, 0x05, 0x20, 0xa0, 0x31, 0x40, 0x20, 0xa0, 0x23,
0x30, 0x20, 0x8e, 0xe5, 0x34, 0x20, 0x8e, 0xe5, 0x38, 0x20, 0x8e, 0xe5,
0x00, 0x10, 0xc6, 0xe5, 0x01, 0x30, 0x83, 0xe2, 0x03, 0x00, 0x52, 0xe1,
0xfb, 0xff, 0xff, 0xca, 0x08, 0x30, 0x9e, 0xe5, 0x02, 0x31, 0x83, 0xe3,
0x08, 0x30, 0x8e, 0xe5, 0x1c, 0x30, 0x9e, 0xe5, 0x73, 0x30, 0xef, 0xe6,
0x07, 0xc0, 0xa0, 0xe1, 0x05, 0x20, 0xa0, 0x31, 0x40, 0x20, 0xa0, 0x23,
0x30, 0x20, 0x81, 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, 0x08, 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, 0x00, 0x30, 0xa0, 0xe3,
0x00, 0xc0, 0xd4, 0xe5, 0x00, 0x00, 0x50, 0xe3, 0x00, 0x10, 0xa0, 0xe1,
0x01, 0x30, 0x83, 0xe2, 0x7c, 0xc0, 0xef, 0xe6, 0x06, 0x00, 0x00, 0x0a,
0x03, 0x00, 0x52, 0xe1, 0x01, 0xc0, 0xc1, 0xe4, 0x01, 0x00, 0xa0, 0xe1,
0xf5, 0xff, 0xff, 0xca, 0x02, 0x50, 0x55, 0xe0, 0xdf, 0xff, 0xff, 0x1a,
0xf0, 0x80, 0xbd, 0xe8, 0x03, 0x00, 0x52, 0xe1, 0x01, 0x10, 0x83, 0xe2,
0x02, 0x30, 0x83, 0xe2, 0xf8, 0xff, 0xff, 0xda, 0x01, 0x00, 0x52, 0xe1,
0x00, 0x10, 0xd4, 0xe5, 0xf5, 0xff, 0xff, 0xda, 0x03, 0x00, 0x52, 0xe1,
0x00, 0x10, 0xd4, 0xe5, 0x01, 0x10, 0x83, 0xe2, 0x02, 0x30, 0x83, 0xe2,
0xf7, 0xff, 0xff, 0xca, 0x02, 0x50, 0x55, 0xe0, 0xd0, 0xff, 0xff, 0x1a,
0x00, 0xe0, 0xd4, 0xe5, 0x00, 0x00, 0x50, 0xe3, 0x00, 0xc0, 0xa0, 0xe1,
0x01, 0x30, 0x83, 0xe2, 0x7e, 0xe0, 0xef, 0xe6, 0x06, 0x00, 0x00, 0x0a,
0x03, 0x00, 0x52, 0xe1, 0x01, 0xe0, 0xcc, 0xe4, 0x0c, 0x00, 0xa0, 0xe1,
0xf5, 0xff, 0xff, 0xca, 0x02, 0x50, 0x55, 0xe0, 0xdc, 0xff, 0xff, 0x1a,
0xf0, 0x80, 0xbd, 0xe8, 0x03, 0x00, 0x52, 0xe1, 0x01, 0xc0, 0x83, 0xe2,
0x02, 0x30, 0x83, 0xe2, 0xf8, 0xff, 0xff, 0xda, 0x0c, 0x00, 0x52, 0xe1,
0x00, 0xc0, 0xd4, 0xe5, 0xf5, 0xff, 0xff, 0xda, 0x03, 0x00, 0x52, 0xe1,
0x00, 0xc0, 0xd4, 0xe5, 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, 0x05, 0x1a, 0xa0, 0xe3, 0x52, 0x5c, 0xa0, 0xe3,
0x02, 0x14, 0x40, 0xe3, 0x53, 0x4c, 0xa0, 0xe3, 0x02, 0x54, 0x40, 0xe3,
0x00, 0x70, 0xe0, 0xe3, 0x02, 0x44, 0x40, 0xe3, 0x40, 0x00, 0x56, 0xe3,
0x06, 0x20, 0xa0, 0x31, 0x40, 0x20, 0xa0, 0x23, 0x30, 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,
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,
0x00, 0x30, 0xa0, 0xe3, 0x00, 0xc0, 0xd4, 0xe5, 0x01, 0x30, 0x83, 0xe2,
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,
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, 0x05, 0x5a, 0xa0, 0xe3,
0x02, 0x54, 0x40, 0xe3, 0x01, 0x7a, 0xa0, 0xe3, 0x00, 0x72, 0x40, 0xe3,
0x14, 0xd0, 0x4d, 0xe2, 0x00, 0x60, 0xa0, 0xe1, 0x06, 0x40, 0xa0, 0xe1,
@ -1508,8 +1528,8 @@ static int chip_spi_init(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t *
0x77, 0x00, 0x00, 0x0a, 0x07, 0x00, 0x53, 0xe3, 0x86, 0x00, 0x00, 0x0a,
0x08, 0x00, 0x53, 0xe3, 0x93, 0x00, 0x00, 0x1a, 0xb0, 0x80, 0xcd, 0xe1,
0x0d, 0x90, 0xa0, 0xe1, 0x08, 0x60, 0x8d, 0xe2, 0x02, 0x10, 0xa0, 0xe3,
0x09, 0x00, 0xa0, 0xe1, 0xad, 0xff, 0xff, 0xeb, 0x01, 0x10, 0xa0, 0xe3,
0x06, 0x00, 0xa0, 0xe1, 0x70, 0xff, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5,
0x09, 0x00, 0xa0, 0xe1, 0xaa, 0xff, 0xff, 0xeb, 0x01, 0x10, 0xa0, 0xe3,
0x06, 0x00, 0xa0, 0xe1, 0x6a, 0xff, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5,
0x01, 0x00, 0x13, 0xe3, 0xf6, 0xff, 0xff, 0x1a, 0x04, 0x60, 0xa0, 0xe1,
0x06, 0x40, 0xa0, 0xe1, 0x01, 0x30, 0xd4, 0xe4, 0x01, 0x00, 0x53, 0xe3,
0xe0, 0xff, 0xff, 0x1a, 0x02, 0x34, 0xa0, 0xe3, 0x01, 0x1a, 0xa0, 0xe3,
@ -1539,35 +1559,35 @@ static int chip_spi_init(struct xfel_ctx_t * ctx, uint32_t * swapbuf, uint32_t *
0xb0, 0x30, 0xc3, 0xe3, 0x80, 0x30, 0x83, 0xe3, 0x08, 0x30, 0x85, 0xe5,
0x91, 0xff, 0xff, 0xea, 0x01, 0x90, 0xd6, 0xe5, 0x02, 0x00, 0x86, 0xe2,
0x09, 0x10, 0xa0, 0xe1, 0x01, 0x60, 0x89, 0xe2, 0x06, 0x60, 0x84, 0xe0,
0x51, 0xff, 0xff, 0xeb, 0x8a, 0xff, 0xff, 0xea, 0x06, 0x10, 0xd6, 0xe5,
0x4e, 0xff, 0xff, 0xeb, 0x8a, 0xff, 0xff, 0xea, 0x06, 0x10, 0xd6, 0xe5,
0x09, 0x60, 0x86, 0xe2, 0x07, 0x00, 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, 0x01, 0x10, 0x56, 0xe5,
0x05, 0x00, 0x56, 0xe5, 0x0e, 0x28, 0x82, 0xe1, 0x0c, 0x38, 0x83, 0xe1,
0x01, 0x1c, 0x82, 0xe1, 0x00, 0x0c, 0x83, 0xe1, 0x40, 0xff, 0xff, 0xeb,
0x01, 0x1c, 0x82, 0xe1, 0x00, 0x0c, 0x83, 0xe1, 0x3d, 0xff, 0xff, 0xeb,
0x79, 0xff, 0xff, 0xea, 0x06, 0x10, 0xd6, 0xe5, 0x09, 0x60, 0x86, 0xe2,
0x07, 0x00, 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, 0x01, 0x10, 0x56, 0xe5, 0x05, 0x00, 0x56, 0xe5,
0x0e, 0x28, 0x82, 0xe1, 0x0c, 0x38, 0x83, 0xe1, 0x01, 0x1c, 0x82, 0xe1,
0x00, 0x0c, 0x83, 0xe1, 0xf5, 0xfe, 0xff, 0xeb, 0x68, 0xff, 0xff, 0xea,
0x00, 0x0c, 0x83, 0xe1, 0xef, 0xfe, 0xff, 0xeb, 0x68, 0xff, 0xff, 0xea,
0x0d, 0x90, 0xa0, 0xe1, 0x08, 0x60, 0x8d, 0xe2, 0x05, 0x30, 0xa0, 0xe3,
0x00, 0x30, 0xcd, 0xe5, 0x01, 0x10, 0xa0, 0xe3, 0x09, 0x00, 0xa0, 0xe1,
0x27, 0xff, 0xff, 0xeb, 0x01, 0x10, 0xa0, 0xe3, 0x06, 0x00, 0xa0, 0xe1,
0xea, 0xfe, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5, 0x01, 0x00, 0x13, 0xe3,
0x24, 0xff, 0xff, 0xeb, 0x01, 0x10, 0xa0, 0xe3, 0x06, 0x00, 0xa0, 0xe1,
0xe4, 0xfe, 0xff, 0xeb, 0x08, 0x30, 0xdd, 0xe5, 0x01, 0x00, 0x13, 0xe3,
0xf6, 0xff, 0xff, 0x1a, 0x04, 0x60, 0xa0, 0xe1, 0x78, 0xff, 0xff, 0xea,
0x14, 0xd0, 0x8d, 0xe2, 0xf0, 0x83, 0xbd, 0xe8, 0x04, 0x00, 0x00, 0x00,
0x14, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x47, 0x4e, 0x55, 0x00,
0x51, 0x5f, 0x35, 0x3c, 0x4a, 0x75, 0x7e, 0xc7, 0x3a, 0x29, 0x61, 0xd7,
0xc7, 0x74, 0x86, 0x5b, 0xb8, 0x72, 0x8f, 0x5a, 0x2f, 0x6c, 0x69, 0x62,
0xf3, 0x44, 0xca, 0x28, 0x76, 0x40, 0x9b, 0x16, 0xb7, 0x29, 0x31, 0x7c,
0x80, 0xaf, 0x9b, 0xfe, 0x09, 0xac, 0xee, 0x10, 0x2f, 0x6c, 0x69, 0x62,
0x2f, 0x6c, 0x64, 0x2d, 0x6c, 0x69, 0x6e, 0x75, 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, 0x01, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf5, 0xfe, 0xff, 0x6f,
0x48, 0x85, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x44, 0x85, 0x02, 0x00,
0x06, 0x00, 0x00, 0x00, 0x34, 0x85, 0x02, 0x00, 0x0a, 0x00, 0x00, 0x00,
0x60, 0x85, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x5c, 0x85, 0x02, 0x00,
0x06, 0x00, 0x00, 0x00, 0x4c, 0x85, 0x02, 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, 0x1e, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00, 0xfb, 0xff, 0xff, 0x6f, 0x01, 0x00, 0x00, 0x08,
@ -1575,7 +1595,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,
0x60, 0x85, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
0x78, 0x85, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
fel_write(ctx, 0x00028000, (void *)&payload[0], sizeof(payload));
if(swapbuf)
@ -1594,8 +1614,149 @@ static int chip_spi_run(struct xfel_ctx_t * ctx, uint8_t * cbuf, uint32_t clen)
return 1;
}
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", 0x0000, 128 },
{ "brom-conf-try", 0x0010, 32 },
{ "thermal-sensor", 0x0014, 64 },
{ "ft-zone", 0x001c, 128 },
{ "reserved1", 0x002c, 96 },
{ "write-protect", 0x0038, 32 },
{ "read-protect", 0x003c, 32 },
{ "lcjs", 0x0040, 32 },
{ "reserved2", 0x0044, 800 },
{ "rotpk", 0x00a8, 256 },
{ "reserved3", 0x00c8, 448 },
};
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;
}
}
}
}
}
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");
return 0;
}

View File

@ -69,19 +69,26 @@ usage:
| H3 | Quad-Core ARM Cortex-A7 @ 1.296GHz | 0x00168000 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| H5 | Quad-Core ARM Cortex-A53 | 0x00171800 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| 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 | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ |
| R329 | Dual-Core Cortex-A53 | 0x00185100 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| R528 | Dual-Core Cortex-A7 | 0x00185900 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| T113 | Dual-Core Cortex-A7 | 0x00185900 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| T507 | Quad-Core ARM Cortex-A53 | 0x00182300 | ✅ | ❌ | ❌ | ❌ | | ❌ | ❌ |
| T507 | Quad-Core ARM Cortex-A53 | 0x00182300 | ✅ | ❌ | ❌ | ❌ | | ❌ | ❌ |
| V3s | Single-core Cortex-A7 | 0x00168100 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| S3 | Single-core Cortex-A7 | 0x00168100 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| V536 | Dual-Core Cortex-A7 | 0x00181600 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| V821 | Andes A272L2 32Bit RISC-V and E907 RISC-V | 0x00188200 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| 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 | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ |
| 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 | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ |
| MR527 | Octa-core Cortex-A55 2.0Ghz + E906 RISC-V + HIFI4 DSP | 0x00189000 | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ |
# Build from source

View File

@ -70,19 +70,26 @@ usage:
| H3 | Quad-Core ARM Cortex-A7 @ 1.296GHz | 0x00168000 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| H5 | Quad-Core ARM Cortex-A53 | 0x00171800 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| 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 | ✅ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ |
| R329 | Dual-Core Cortex-A53 | 0x00185100 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| R528 | Dual-Core Cortex-A7 | 0x00185900 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| T113 | Dual-Core Cortex-A7 | 0x00185900 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| T507 | Quad-Core ARM Cortex-A53 | 0x00182300 | ✅ | ❌ | ❌ | ❌ | | ❌ | ❌ |
| T507 | Quad-Core ARM Cortex-A53 | 0x00182300 | ✅ | ❌ | ❌ | ❌ | | ❌ | ❌ |
| V3s | Single-core Cortex-A7 | 0x00168100 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| S3 | Single-core Cortex-A7 | 0x00168100 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| V536 | Dual-Core Cortex-A7 | 0x00181600 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| V821 | Andes A272L2 32Bit RISC-V and E907 RISC-V | 0x00188200 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| 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 | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ |
| 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 | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ |
| MR527 | Octa-core Cortex-A55 2.0Ghz + E906 RISC-V + HIFI4 DSP | 0x00189000 | ✅ | ✅ | ✅ | ❌ | ✅ | ❌ | ❌ |
# 编译安装

15
fel.c
View File

@ -8,6 +8,7 @@ extern struct chip_t a31;
extern struct chip_t a33_r16;
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 a80;
extern struct chip_t a83t;
@ -21,11 +22,16 @@ extern struct chip_t r128;
extern struct chip_t r328;
extern struct chip_t r329;
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 v536;
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[] = {
&a10,
@ -36,6 +42,7 @@ static struct chip_t * chips[] = {
&a33_r16,
&a40i_r40,
&a50,
&a523_a527_t527,
&a64,
&a80,
&a83t,
@ -49,11 +56,15 @@ static struct chip_t * chips[] = {
&r328,
&r329,
&r528_t113,
&t507,
&r818,
&v3s_s3,
&v536,
&v831,
&v851_v853,
&v821,
&a733,
&t536,
&a537_a333,
};
struct usb_request_t {

1
fel.h
View File

@ -6,6 +6,7 @@ extern "C" {
#endif
#include <x.h>
#include <misc.h>
#include <progress.h>
struct xfel_ctx_t;

132
main.c
View File

@ -5,102 +5,9 @@
#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 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;
}
static unsigned char hex_string(const char * s, int o)
{
return (hex_to_bin(s[o]) << 4) | hex_to_bin(s[o + 1]);
}
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)
{
printf("xfel(v1.3.1) - https://github.com/xboot/xfel\r\n");
printf("xfel(v1.3.3) - https://github.com/xboot/xfel\r\n");
printf("usage:\r\n");
printf(" xfel version - Show chip version\r\n");
printf(" xfel hexdump <address> <length> - Dumps memory region in hex\r\n");
@ -130,8 +37,6 @@ static void usage(void)
int main(int argc, char * argv[])
{
struct xfel_ctx_t ctx = { 0 };
libusb_context *context = NULL;
if(argc < 2)
{
@ -147,32 +52,27 @@ int main(int argc, char * argv[])
}
}
libusb_device **list = NULL;
libusb_device ** list = NULL;
libusb_context * context = NULL;
libusb_init(&context);
int count = libusb_get_device_list(context, &list);
assert(count > 0);
for (size_t i = 0; i < count; ++i) {
libusb_device *device = list[i];
for(int i = 0; i < count; i++)
{
libusb_device * device = list[i];
struct libusb_device_descriptor desc;
int rc = libusb_get_device_descriptor(device, &desc);
if(rc != 0)
{
printf("ERROR: Can't get device list: %d\r\n", rc);
}
if(desc.idVendor == 0x1f3a && desc.idProduct == 0xefe8) {
int rc = libusb_open(device, &ctx.hdl);
if(rc != 0)
{
printf("ERROR: Can't connect to device: %d\r\n", rc);
}
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))
{
printf("ERROR: Can't found any FEL device\r\n");
printf("ERROR: No FEL device found!\r\n");
if(ctx.hdl)
libusb_close(ctx.hdl);
libusb_exit(NULL);
@ -241,7 +141,7 @@ int main(int argc, char * argv[])
if(argc == 2)
{
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);
}
else
@ -318,9 +218,7 @@ int main(int argc, char * argv[])
{
argc -= 2;
argv += 2;
if(fel_chip_ddr(&ctx, (argc == 1) ? argv[0] : ""))
printf("Initial ddr controller succeeded\r\n");
else
if(!fel_chip_ddr(&ctx, (argc == 1) ? argv[0] : ""))
printf("Failed to initial ddr controller\r\n");
}
else if(!strcmp(argv[1], "sign"))

100
misc.c Normal file
View 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
View 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__ */

View File

@ -2,8 +2,8 @@
# Top makefile
#
CROSS ?= ~/Xuantie-900-gcc-linux-5.10.4-musl64-x86_64-V2.4.0/bin/riscv64-unknown-linux-musl-
NAME := sid
CROSS ?= arm-linux-gnueabihf-
NAME := jmp-arm64
#
# System environment variable.
@ -26,7 +26,7 @@ LDFLAGS := -T link.ld -nostdlib
ARFLAGS := -rcs
OCFLAGS := -v -O binary
ODFLAGS :=
MCFLAGS := -march=rv64gvxthead -mabi=lp64d -mcmodel=medany -fno-stack-protector
MCFLAGS := -march=armv7-a -mtune=cortex-a7 -mfpu=vfpv4 -mfloat-abi=hard -marm -mno-thumb-interwork -mno-unaligned-access -fno-stack-protector
LIBDIRS :=
LIBS :=

View File

@ -0,0 +1,27 @@
#ifndef __ARM32_ENDIAN_H__
#define __ARM32_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 /* __ARM32_ENDIAN_H__ */

View 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__ */

View File

@ -0,0 +1,53 @@
#ifndef __ARM32_TYPES_H__
#define __ARM32_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 int ptrdiff_t;
typedef signed int intptr_t;
typedef unsigned int uintptr_t;
typedef unsigned int size_t;
typedef signed int ssize_t;
typedef signed int off_t;
typedef signed long long loff_t;
typedef signed int bool_t;
typedef unsigned int irq_flags_t;
typedef unsigned int virtual_addr_t;
typedef unsigned int virtual_size_t;
typedef unsigned int physical_addr_t;
typedef unsigned int physical_size_t;
typedef struct {
volatile int counter;
} atomic_t;
typedef struct {
volatile int lock;
} spinlock_t;
#ifdef __cplusplus
}
#endif
#endif /* __ARM32_TYPES_H__ */

View 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) }
}

View 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

View 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;
}

View File

@ -2,7 +2,7 @@
# 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
#

View File

@ -2,7 +2,7 @@
# 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
#

View File

@ -2,7 +2,7 @@
# 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
#

10
payloads/d1_f133/read32/.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
#
# Normal rules
#
*~
#
# Generated files
#
/.obj
/output

View 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)

View 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__ */

View 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__ */

View 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__ */

View 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__ */

View 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__ */

View 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__ */

View 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__ */

View File

@ -2,11 +2,11 @@ OUTPUT_FORMAT("elf64-littleriscv", "elf64-littleriscv", "elf64-littleriscv")
OUTPUT_ARCH(riscv)
ENTRY(_start)
STACK_SIZE = 0x400;
STACK_SIZE = 0x010;
MEMORY
{
ram : org = 0x00020000, len = 0x00001000 /* 4 KB */
ram : org = 0x00045000, len = 0x00000200 /* 512B */
}
SECTIONS
@ -16,7 +16,6 @@ SECTIONS
PROVIDE(__image_start = .);
PROVIDE(__text_start = .);
.obj/source/start.o (.text*)
.obj/source/sys-sid.o (.text*)
*(.text*)
*(.iplt)
*(.note.gnu.build-id)

View File

@ -38,17 +38,14 @@ _start:
j reset
reset:
addi sp, sp, -32
sd s0, 8(sp)
sd s1, 16(sp)
sd ra, 24(sp)
mv s0, a0
li a0, 0x00021000
jal sys_read_sid
ld ra, 24(sp)
ld s0, 8(sp)
ld s1, 16(sp)
addi sp, sp, 32
la t0, _adr
lw t0, (t0)
lw t0, (t0)
la t1, _val
sw t0, (t1)
ret
.align 2
_adr:
.word 0x11223344
_val:
.word 0x55667788

View File

@ -1,68 +0,0 @@
#ifndef __D1_REG_CCU_H__
#define __D1_REG_CCU_H__
#define D1_CCU_BASE (0x02001000)
#define CCU_PLL_CPU_CTRL_REG (0x000)
#define CCU_PLL_DDR_CTRL_REG (0x010)
#define CCU_PLL_PERI0_CTRL_REG (0x020)
#define CCU_PLL_PERI1_CTRL_REG (0x028)
#define CCU_PLL_GPU_CTRL_REG (0x030)
#define CCU_PLL_VIDEO0_CTRL_REG (0x040)
#define CCU_PLL_VIDEO1_CTRL_REG (0x048)
#define CCU_PLL_VE_CTRL (0x058)
#define CCU_PLL_DE_CTRL (0x060)
#define CCU_PLL_HSIC_CTRL (0x070)
#define CCU_PLL_AUDIO0_CTRL_REG (0x078)
#define CCU_PLL_AUDIO1_CTRL_REG (0x080)
#define CCU_PLL_DDR_PAT0_CTRL_REG (0x110)
#define CCU_PLL_DDR_PAT1_CTRL_REG (0x114)
#define CCU_PLL_PERI0_PAT0_CTRL_REG (0x120)
#define CCU_PLL_PERI0_PAT1_CTRL_REG (0x124)
#define CCU_PLL_PERI1_PAT0_CTRL_REG (0x128)
#define CCU_PLL_PERI1_PAT1_CTRL_REG (0x12c)
#define CCU_PLL_GPU_PAT0_CTRL_REG (0x130)
#define CCU_PLL_GPU_PAT1_CTRL_REG (0x134)
#define CCU_PLL_VIDEO0_PAT0_CTRL_REG (0x140)
#define CCU_PLL_VIDEO0_PAT1_CTRL_REG (0x144)
#define CCU_PLL_VIDEO1_PAT0_CTRL_REG (0x148)
#define CCU_PLL_VIDEO1_PAT1_CTRL_REG (0x14c)
#define CCU_PLL_VE_PAT0_CTRL_REG (0x158)
#define CCU_PLL_VE_PAT1_CTRL_REG (0x15c)
#define CCU_PLL_DE_PAT0_CTRL_REG (0x160)
#define CCU_PLL_DE_PAT1_CTRL_REG (0x164)
#define CCU_PLL_HSIC_PAT0_CTRL_REG (0x170)
#define CCU_PLL_HSIC_PAT1_CTRL_REG (0x174)
#define CCU_PLL_AUDIO0_PAT0_CTRL_REG (0x178)
#define CCU_PLL_AUDIO0_PAT1_CTRL_REG (0x17c)
#define CCU_PLL_AUDIO1_PAT0_CTRL_REG (0x180)
#define CCU_PLL_AUDIO1_PAT1_CTRL_REG (0x184)
#define CCU_PLL_CPU_BIAS_REG (0x300)
#define CCU_PLL_DDR_BIAS_REG (0x310)
#define CCU_PLL_PERI0_BIAS_REG (0x320)
#define CCU_PLL_PERI1_BIAS_REG (0x328)
#define CCU_PLL_GPU_BIAS_REG (0x330)
#define CCU_PLL_VIDEO0_BIAS_REG (0x340)
#define CCU_PLL_VIDEO1_BIAS_REG (0x348)
#define CCU_PLL_VE_BIAS_REG (0x358)
#define CCU_PLL_DE_BIAS_REG (0x360)
#define CCU_PLL_HSIC_BIAS_REG (0x370)
#define CCU_PLL_AUDIO0_BIAS_REG (0x378)
#define CCU_PLL_AUDIO1_BIAS_REG (0x380)
#define CCU_PLL_CPU_TUN_REG (0x400)
#define CCU_CPU_AXI_CFG_REG (0x500)
#define CCU_CPU_GATING_REG (0x504)
#define CCU_PSI_CLK_REG (0x510)
#define CCU_AHB3_CLK_REG (0x51c)
#define CCU_APB0_CLK_REG (0x520)
#define CCU_APB1_CLK_REG (0x524)
#define CCU_MBUS_CLK_REG (0x540)
#define CCU_DMA_BGR_REG (0x70c)
#define CCU_DRAM_CLK_REG (0x800)
#define CCU_MBUS_MAT_CLK_GATING_REG (0x804)
#define CCU_DRAM_BGR_REG (0x80c)
#define CCU_RISCV_CLK_REG (0xd00)
#define CCU_RISCV_GATING_REG (0xd04)
#define CCU_RISCV_CFG_BGR_REG (0xd0c)
#endif /* __D1_REG_CCU_H__ */

View File

@ -2,7 +2,7 @@
# 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
#

View File

@ -186,6 +186,8 @@ static void sys_spi_transfer(void * txbuf, void * rxbuf, u32_t len)
write32(addr + SPI_MBC, n);
sys_spi_write_txbuf(tx, n);
write32(addr + SPI_TCR, read32(addr + SPI_TCR) | (1 << 31));
while(read32(addr + SPI_TCR) & (1 << 31));
while((read32(addr + SPI_FSR) & 0xff) < n);
for(i = 0; i < n; i++)
{

10
payloads/d1_f133/write32/.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
#
# Normal rules
#
*~
#
# Generated files
#
/.obj
/output

View 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)

View 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__ */

View 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__ */

View 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__ */

View 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__ */

View 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__ */

View 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__ */

View 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__ */

View 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__ */

View 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__ */

View 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__ */

View 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__ */

View 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*) }
}

View 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

View File

@ -159,6 +159,8 @@ static void sys_spi_transfer(void * txbuf, void * rxbuf, u32_t len)
write32(addr + SPI_MBC, n);
sys_spi_write_txbuf(tx, n);
write32(addr + SPI_TCR, read32(addr + SPI_TCR) | (1 << 31));
while(read32(addr + SPI_TCR) & (1 << 31));
while((read32(addr + SPI_FSR) & 0xff) < n);
for(i = 0; i < n; i++)
{

View File

@ -186,6 +186,8 @@ static void sys_spi_transfer(void * txbuf, void * rxbuf, u32_t len)
write32(addr + SPI_MBC, n);
sys_spi_write_txbuf(tx, n);
write32(addr + SPI_TCR, read32(addr + SPI_TCR) | (1 << 31));
while(read32(addr + SPI_TCR) & (1 << 31));
while((read32(addr + SPI_FSR) & 0xff) < n);
for(i = 0; i < n; i++)
{

View File

@ -196,6 +196,8 @@ static void sys_spi_transfer(void * txbuf, void * rxbuf, u32_t len)
write32(addr + SPI_MBC, n);
sys_spi_write_txbuf(tx, n);
write32(addr + SPI_TCR, read32(addr + SPI_TCR) | (1 << 31));
while(read32(addr + SPI_TCR) & (1 << 31));
while((read32(addr + SPI_FSR) & 0xff) < n);
for(i = 0; i < n; i++)
{

10
payloads/r528_t113/read32/.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
#
# Normal rules
#
*~
#
# Generated files
#
/.obj
/output

View File

@ -0,0 +1,120 @@
#
# Top makefile
#
CROSS ?= arm-none-eabi-
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=armv7-a -mtune=cortex-a7 -mfpu=vfpv4 -mfloat-abi=softfp -marm -mno-thumb-interwork -mno-unaligned-access -fno-stack-protector
LIBDIRS :=
LIBS :=
INCDIRS :=
SRCDIRS :=
#
# Add external library
#
INCDIRS += 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)

View 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__ */

View File

@ -0,0 +1,27 @@
#ifndef __ARM32_ENDIAN_H__
#define __ARM32_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 /* __ARM32_ENDIAN_H__ */

View 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__ */

View 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__ */

View 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__ */

View 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__ */

View 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__ */

View File

@ -0,0 +1,53 @@
#ifndef __ARM32_TYPES_H__
#define __ARM32_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 int ptrdiff_t;
typedef signed int intptr_t;
typedef unsigned int uintptr_t;
typedef unsigned int size_t;
typedef signed int ssize_t;
typedef signed int off_t;
typedef signed long long loff_t;
typedef signed int bool_t;
typedef unsigned int irq_flags_t;
typedef unsigned int virtual_addr_t;
typedef unsigned int virtual_size_t;
typedef unsigned int physical_addr_t;
typedef unsigned int physical_size_t;
typedef struct {
volatile int counter;
} atomic_t;
typedef struct {
volatile int lock;
} spinlock_t;
#ifdef __cplusplus
}
#endif
#endif /* __ARM32_TYPES_H__ */

View 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__ */

View File

@ -0,0 +1,121 @@
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 = 0x010;
MEMORY
{
ram : org = 0x00045000, len = 0x00000200 /* 512B */
}
SECTIONS
{
.text :
{
PROVIDE(__image_start = .);
PROVIDE(__text_start = .);
.obj/source/start.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) }
}

View File

@ -0,0 +1,49 @@
/*
* 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
reset:
ldr r0, _adr
adr r1, _val
ldr r2, [r0]
str r2, [r1]
bx lr
.align 2
_adr:
.word 0x11223344
_val:
.word 0x55667788

View File

@ -186,6 +186,8 @@ static void sys_spi_transfer(void * txbuf, void * rxbuf, u32_t len)
write32(addr + SPI_MBC, n);
sys_spi_write_txbuf(tx, n);
write32(addr + SPI_TCR, read32(addr + SPI_TCR) | (1 << 31));
while(read32(addr + SPI_TCR) & (1 << 31));
while((read32(addr + SPI_FSR) & 0xff) < n);
for(i = 0; i < n; i++)
{

10
payloads/r528_t113/write32/.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
#
# Normal rules
#
*~
#
# Generated files
#
/.obj
/output

View File

@ -0,0 +1,120 @@
#
# Top makefile
#
CROSS ?= arm-none-eabi-
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=armv7-a -mtune=cortex-a7 -mfpu=vfpv4 -mfloat-abi=softfp -marm -mno-thumb-interwork -mno-unaligned-access -fno-stack-protector
LIBDIRS :=
LIBS :=
INCDIRS :=
SRCDIRS :=
#
# Add external library
#
INCDIRS += 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)

View 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__ */

View File

@ -0,0 +1,27 @@
#ifndef __ARM32_ENDIAN_H__
#define __ARM32_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 /* __ARM32_ENDIAN_H__ */

View 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__ */

View 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__ */

Some files were not shown because too many files have changed in this diff Show More