mirror of
https://github.com/xboot/xfel.git
synced 2024-11-30 13:13:37 +08:00
[f1c100s]add jtag payload for f1c100s
This commit is contained in:
parent
b403b7f9ee
commit
1f6a8dad1e
@ -19,7 +19,30 @@ static int chip_sid(struct xfel_ctx_t * ctx, uint32_t * sid)
|
||||
|
||||
static int chip_jtag(struct xfel_ctx_t * ctx)
|
||||
{
|
||||
return 0;
|
||||
static const uint8_t payload[] = {
|
||||
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, 0x1a, 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, 0x2e, 0x10, 0xa0, 0xe3,
|
||||
0x04, 0x10, 0xc0, 0xe5, 0x46, 0x10, 0xa0, 0xe3, 0x05, 0x10, 0xc0, 0xe5,
|
||||
0x45, 0x10, 0xa0, 0xe3, 0x06, 0x10, 0xc0, 0xe5, 0x4c, 0x10, 0xa0, 0xe3,
|
||||
0x07, 0x10, 0xc0, 0xe5, 0x40, 0x00, 0xa0, 0xe3, 0x00, 0xd0, 0x90, 0xe5,
|
||||
0x04, 0xe0, 0x90, 0xe5, 0x10, 0x10, 0x90, 0xe5, 0x10, 0x1f, 0x01, 0xee,
|
||||
0x0c, 0x10, 0x90, 0xe5, 0x10, 0x1f, 0x01, 0xee, 0x08, 0x10, 0x90, 0xe5,
|
||||
0x01, 0xf0, 0x29, 0xe1, 0x1e, 0xff, 0x2f, 0xe1, 0x40, 0x30, 0x9f, 0xe5,
|
||||
0xb4, 0x28, 0x93, 0xe5, 0x0f, 0x20, 0xc2, 0xe3, 0x03, 0x20, 0x82, 0xe3,
|
||||
0xb4, 0x28, 0x83, 0xe5, 0xb4, 0x28, 0x93, 0xe5, 0xf0, 0x20, 0xc2, 0xe3,
|
||||
0x30, 0x20, 0x82, 0xe3, 0xb4, 0x28, 0x83, 0xe5, 0xb4, 0x28, 0x93, 0xe5,
|
||||
0x0f, 0x2a, 0xc2, 0xe3, 0x03, 0x2a, 0x82, 0xe3, 0xb4, 0x28, 0x83, 0xe5,
|
||||
0xb4, 0x28, 0x93, 0xe5, 0x0f, 0x26, 0xc2, 0xe3, 0x03, 0x26, 0x82, 0xe3,
|
||||
0xb4, 0x28, 0x83, 0xe5, 0x1e, 0xff, 0x2f, 0xe1, 0x00, 0x00, 0xc2, 0x01
|
||||
};
|
||||
fel_write(ctx, 0x00008800, (void *)&payload[0], sizeof(payload));
|
||||
fel_exec(ctx, 0x00008800);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int chip_ddr(struct xfel_ctx_t * ctx, const char * type)
|
||||
|
10
payloads/f1c100s/f1c100s-jtag/.gitignore
vendored
Normal file
10
payloads/f1c100s/f1c100s-jtag/.gitignore
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
#
|
||||
# Normal rules
|
||||
#
|
||||
*~
|
||||
|
||||
#
|
||||
# Generated files
|
||||
#
|
||||
/.obj
|
||||
/output
|
123
payloads/f1c100s/f1c100s-jtag/Makefile
Normal file
123
payloads/f1c100s/f1c100s-jtag/Makefile
Normal file
@ -0,0 +1,123 @@
|
||||
#
|
||||
# Top makefile
|
||||
#
|
||||
|
||||
CROSS ?= arm-none-eabi-
|
||||
NAME := f1c100s-jtag
|
||||
|
||||
#
|
||||
# System environment variable.
|
||||
#
|
||||
#
|
||||
# System environment variable.
|
||||
#
|
||||
ifeq ($(OS), Windows_NT)
|
||||
HOSTOS := windows
|
||||
else
|
||||
ifneq (,$(findstring Linux, $(shell uname -a)))
|
||||
HOSTOS := linux
|
||||
endif
|
||||
endif
|
||||
|
||||
#
|
||||
# Load default variables.
|
||||
#
|
||||
ASFLAGS := -g -ggdb -Wall -O3
|
||||
CFLAGS := -g -ggdb -Wall -O3
|
||||
CXXFLAGS := -g -ggdb -Wall -O3
|
||||
LDFLAGS := -T link.ld -nostdlib
|
||||
ARFLAGS := -rcs
|
||||
OCFLAGS := -v -O binary
|
||||
ODFLAGS :=
|
||||
MCFLAGS := -march=armv5te -mtune=arm926ej-s -mfloat-abi=soft -marm -mno-thumb-interwork -mno-unaligned-access
|
||||
|
||||
LIBDIRS :=
|
||||
LIBS :=
|
||||
INCDIRS :=
|
||||
SRCDIRS :=
|
||||
|
||||
#
|
||||
# Add external library
|
||||
#
|
||||
INCDIRS += include \
|
||||
include/external
|
||||
SRCDIRS += source \
|
||||
source/external
|
||||
|
||||
#
|
||||
# You shouldn't need to change anything below this point.
|
||||
#
|
||||
AS := $(CROSS)gcc -x assembler-with-cpp
|
||||
CC := $(CROSS)gcc
|
||||
CXX := $(CROSS)g++
|
||||
LD := $(CROSS)ld
|
||||
AR := $(CROSS)ar
|
||||
OC := $(CROSS)objcopy
|
||||
OD := $(CROSS)objdump
|
||||
MKDIR := mkdir -p
|
||||
CP := cp -af
|
||||
RM := rm -fr
|
||||
CD := cd
|
||||
FIND := find
|
||||
|
||||
#
|
||||
# X variables
|
||||
#
|
||||
X_ASFLAGS := $(MCFLAGS) $(ASFLAGS)
|
||||
X_CFLAGS := $(MCFLAGS) $(CFLAGS)
|
||||
X_CXXFLAGS := $(MCFLAGS) $(CXXFLAGS)
|
||||
X_LDFLAGS := $(LDFLAGS)
|
||||
X_OCFLAGS := $(OCFLAGS)
|
||||
X_LIBDIRS := $(LIBDIRS)
|
||||
X_LIBS := $(LIBS) -lgcc
|
||||
|
||||
X_OUT := output
|
||||
X_NAME := $(patsubst %, $(X_OUT)/%, $(NAME))
|
||||
X_INCDIRS := $(patsubst %, -I %, $(INCDIRS))
|
||||
X_SRCDIRS := $(patsubst %, %, $(SRCDIRS))
|
||||
X_OBJDIRS := $(patsubst %, .obj/%, $(X_SRCDIRS))
|
||||
|
||||
X_SFILES := $(foreach dir, $(X_SRCDIRS), $(wildcard $(dir)/*.S))
|
||||
X_CFILES := $(foreach dir, $(X_SRCDIRS), $(wildcard $(dir)/*.c))
|
||||
X_CPPFILES := $(foreach dir, $(X_SRCDIRS), $(wildcard $(dir)/*.cpp))
|
||||
|
||||
X_SDEPS := $(patsubst %, .obj/%, $(X_SFILES:.S=.o.d))
|
||||
X_CDEPS := $(patsubst %, .obj/%, $(X_CFILES:.c=.o.d))
|
||||
X_CPPDEPS := $(patsubst %, .obj/%, $(X_CPPFILES:.cpp=.o.d))
|
||||
X_DEPS := $(X_SDEPS) $(X_CDEPS) $(X_CPPDEPS)
|
||||
|
||||
X_SOBJS := $(patsubst %, .obj/%, $(X_SFILES:.S=.o))
|
||||
X_COBJS := $(patsubst %, .obj/%, $(X_CFILES:.c=.o))
|
||||
X_CPPOBJS := $(patsubst %, .obj/%, $(X_CPPFILES:.cpp=.o))
|
||||
X_OBJS := $(X_SOBJS) $(X_COBJS) $(X_CPPOBJS)
|
||||
|
||||
VPATH := $(X_OBJDIRS)
|
||||
|
||||
.PHONY: all clean
|
||||
all : $(X_NAME)
|
||||
|
||||
$(X_NAME) : $(X_OBJS)
|
||||
@echo [LD] Linking $@.elf
|
||||
@$(CC) $(X_LDFLAGS) $(X_LIBDIRS) -Wl,--cref,-Map=$@.map $^ -o $@.elf $(X_LIBS)
|
||||
@echo [OC] Objcopying $@.bin
|
||||
@$(OC) $(X_OCFLAGS) $@.elf $@.bin
|
||||
|
||||
$(X_SOBJS) : .obj/%.o : %.S
|
||||
@echo [AS] $<
|
||||
@$(AS) $(X_ASFLAGS) -MD -MP -MF $@.d $(X_INCDIRS) -c $< -o $@
|
||||
|
||||
$(X_COBJS) : .obj/%.o : %.c
|
||||
@echo [CC] $<
|
||||
@$(CC) $(X_CFLAGS) -MD -MP -MF $@.d $(X_INCDIRS) -c $< -o $@
|
||||
|
||||
$(X_CPPOBJS) : .obj/%.o : %.cpp
|
||||
@echo [CXX] $<
|
||||
@$(CXX) $(X_CXXFLAGS) -MD -MP -MF $@.d $(X_INCDIRS) -c $< -o $@
|
||||
|
||||
clean:
|
||||
@$(RM) .obj $(X_OUT)
|
||||
|
||||
#
|
||||
# Include the dependency files, should be place the last of makefile
|
||||
#
|
||||
sinclude $(shell $(MKDIR) $(X_OBJDIRS) $(X_OUT)) $(X_DEPS)
|
83
payloads/f1c100s/f1c100s-jtag/include/byteorder.h
Normal file
83
payloads/f1c100s/f1c100s-jtag/include/byteorder.h
Normal file
@ -0,0 +1,83 @@
|
||||
#ifndef __BYTEORDER_H__
|
||||
#define __BYTEORDER_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <types.h>
|
||||
|
||||
static inline u16_t __swab16(u16_t x)
|
||||
{
|
||||
return ( (x<<8) | (x>>8) );
|
||||
}
|
||||
|
||||
static inline u32_t __swab32(u32_t x)
|
||||
{
|
||||
return ( (x<<24) | (x>>24) | \
|
||||
((x & (u32_t)0x0000ff00UL)<<8) | \
|
||||
((x & (u32_t)0x00ff0000UL)>>8) );
|
||||
}
|
||||
|
||||
static inline u64_t __swab64(u64_t x)
|
||||
{
|
||||
return ( (x<<56) | (x>>56) | \
|
||||
((x & (u64_t)0x000000000000ff00ULL)<<40) | \
|
||||
((x & (u64_t)0x0000000000ff0000ULL)<<24) | \
|
||||
((x & (u64_t)0x00000000ff000000ULL)<< 8) | \
|
||||
((x & (u64_t)0x000000ff00000000ULL)>> 8) | \
|
||||
((x & (u64_t)0x0000ff0000000000ULL)>>24) | \
|
||||
((x & (u64_t)0x00ff000000000000ULL)>>40) );
|
||||
}
|
||||
|
||||
/*
|
||||
* swap bytes bizarrely.
|
||||
* swahw32 - swap 16-bit half-words in a 32-bit word
|
||||
*/
|
||||
static inline u32_t __swahw32(u32_t x)
|
||||
{
|
||||
return ( ((x & (u32_t)0x0000ffffUL)<<16) | ((x & (u32_t)0xffff0000UL)>>16) );
|
||||
}
|
||||
|
||||
/*
|
||||
* swap bytes bizarrely.
|
||||
* swahb32 - swap 8-bit halves of each 16-bit half-word in a 32-bit word
|
||||
*/
|
||||
static inline u32_t __swahb32(u32_t x)
|
||||
{
|
||||
return ( ((x & (u32_t)0x00ff00ffUL)<<8) | ((x & (u32_t)0xff00ff00UL)>>8) );
|
||||
}
|
||||
|
||||
#if (BYTE_ORDER == BIG_ENDIAN)
|
||||
#define cpu_to_le64(x) (__swab64((u64_t)(x)))
|
||||
#define le64_to_cpu(x) (__swab64((u64_t)(x)))
|
||||
#define cpu_to_le32(x) (__swab32((u32_t)(x)))
|
||||
#define le32_to_cpu(x) (__swab32((u32_t)(x)))
|
||||
#define cpu_to_le16(x) (__swab16((u16_t)(x)))
|
||||
#define le16_to_cpu(x) (__swab16((u16_t)(x)))
|
||||
#define cpu_to_be64(x) ((u64_t)(x))
|
||||
#define be64_to_cpu(x) ((u64_t)(x))
|
||||
#define cpu_to_be32(x) ((u32_t)(x))
|
||||
#define be32_to_cpu(x) ((u32_t)(x))
|
||||
#define cpu_to_be16(x) ((u16_t)(x))
|
||||
#define be16_to_cpu(x) ((u16_t)(x))
|
||||
#else
|
||||
#define cpu_to_le64(x) ((u64_t)(x))
|
||||
#define le64_to_cpu(x) ((u64_t)(x))
|
||||
#define cpu_to_le32(x) ((u32_t)(x))
|
||||
#define le32_to_cpu(x) ((u32_t)(x))
|
||||
#define cpu_to_le16(x) ((u16_t)(x))
|
||||
#define le16_to_cpu(x) ((u16_t)(x))
|
||||
#define cpu_to_be64(x) (__swab64((u64_t)(x)))
|
||||
#define be64_to_cpu(x) (__swab64((u64_t)(x)))
|
||||
#define cpu_to_be32(x) (__swab32((u32_t)(x)))
|
||||
#define be32_to_cpu(x) (__swab32((u32_t)(x)))
|
||||
#define cpu_to_be16(x) (__swab16((u16_t)(x)))
|
||||
#define be16_to_cpu(x) (__swab16((u16_t)(x)))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BYTEORDER_H__ */
|
27
payloads/f1c100s/f1c100s-jtag/include/endian.h
Normal file
27
payloads/f1c100s/f1c100s-jtag/include/endian.h
Normal 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__ */
|
55
payloads/f1c100s/f1c100s-jtag/include/f1c100s/reg-ccu.h
Normal file
55
payloads/f1c100s/f1c100s-jtag/include/f1c100s/reg-ccu.h
Normal file
@ -0,0 +1,55 @@
|
||||
#ifndef __F1C100S_REG_CCU_H__
|
||||
#define __F1C100S_REG_CCU_H__
|
||||
|
||||
#define F1C100S_CCU_BASE (0x01c20000)
|
||||
|
||||
#define CCU_PLL_CPU_CTRL (0x000)
|
||||
#define CCU_PLL_AUDIO_CTRL (0x008)
|
||||
#define CCU_PLL_VIDEO_CTRL (0x010)
|
||||
#define CCU_PLL_VE_CTRL (0x018)
|
||||
#define CCU_PLL_DDR_CTRL (0x020)
|
||||
#define CCU_PLL_PERIPH_CTRL (0x028)
|
||||
#define CCU_CPU_CFG (0x050)
|
||||
#define CCU_AHB_APB_CFG (0x054)
|
||||
|
||||
#define CCU_BUS_CLK_GATE0 (0x060)
|
||||
#define CCU_BUS_CLK_GATE1 (0x064)
|
||||
#define CCU_BUS_CLK_GATE2 (0x068)
|
||||
|
||||
#define CCU_SDMMC0_CLK (0x088)
|
||||
#define CCU_SDMMC1_CLK (0x08c)
|
||||
#define CCU_DAUDIO_CLK (0x0b0)
|
||||
#define CCU_SPDIF_CLK (0x0b4)
|
||||
#define CCU_I2S_CLK (0x0b8)
|
||||
#define CCU_USBPHY_CFG (0x0cc)
|
||||
#define CCU_DRAM_CLK_GATE (0x100)
|
||||
#define CCU_DEBE_CLK (0x104)
|
||||
#define CCU_DEFE_CLK (0x10c)
|
||||
#define CCU_LCD_CLK (0x118)
|
||||
#define CCU_DEINTERLACE_CLK (0x11c)
|
||||
#define CCU_TVE_CLK (0x120)
|
||||
#define CCU_TVD_CLK (0x124)
|
||||
#define CCU_CSI_CLK (0x134)
|
||||
#define CCU_VE_CLK (0x13c)
|
||||
#define CCU_ADDA_CLK (0x140)
|
||||
#define CCU_AVS_CLK (0x144)
|
||||
|
||||
#define CCU_PLL_STABLE_TIME0 (0x200)
|
||||
#define CCU_PLL_STABLE_TIME1 (0x204)
|
||||
#define CCU_PLL_CPU_BIAS (0x220)
|
||||
#define CCU_PLL_AUDIO_BIAS (0x224)
|
||||
#define CCU_PLL_VIDEO_BIAS (0x228)
|
||||
#define CCU_PLL_VE_BIAS (0x22c)
|
||||
#define CCU_PLL_DDR0_BIAS (0x230)
|
||||
#define CCU_PLL_PERIPH_BIAS (0x234)
|
||||
#define CCU_PLL_CPU_TUN (0x250)
|
||||
#define CCU_PLL_DDR_TUN (0x260)
|
||||
#define CCU_PLL_AUDIO_PAT (0x284)
|
||||
#define CCU_PLL_VIDEO_PAT (0x288)
|
||||
#define CCU_PLL_DDR0_PAT (0x290)
|
||||
|
||||
#define CCU_BUS_SOFT_RST0 (0x2c0)
|
||||
#define CCU_BUS_SOFT_RST1 (0x2c4)
|
||||
#define CCU_BUS_SOFT_RST3 (0x2d0)
|
||||
|
||||
#endif /* __F1C100S_REG_CCU_H__ */
|
39
payloads/f1c100s/f1c100s-jtag/include/f1c100s/reg-dram.h
Normal file
39
payloads/f1c100s/f1c100s-jtag/include/f1c100s/reg-dram.h
Normal file
@ -0,0 +1,39 @@
|
||||
#ifndef __F1C100S_REG_DRAM_H__
|
||||
#define __F1C100S_REG_DRAM_H__
|
||||
|
||||
#define F1C100S_DRAM_BASE (0x01c01000)
|
||||
|
||||
#define DRAM_SCONR (0x00)
|
||||
#define DRAM_STMG0R (0x04)
|
||||
#define DRAM_STMG1R (0x08)
|
||||
#define DRAM_SCTLR (0x0c)
|
||||
#define DRAM_SREFR (0x10)
|
||||
#define DRAM_SEXTMR (0x14)
|
||||
#define DRAM_DDLYR (0x24)
|
||||
#define DRAM_DADRR (0x28)
|
||||
#define DRAM_DVALR (0x2c)
|
||||
#define DRAM_DRPTR0 (0x30)
|
||||
#define DRAM_DRPTR1 (0x34)
|
||||
#define DRAM_DRPTR2 (0x38)
|
||||
#define DRAM_DRPTR3 (0x3c)
|
||||
#define DRAM_SEFR (0x40)
|
||||
#define DRAM_MAE (0x44)
|
||||
#define DRAM_ASPR (0x48)
|
||||
#define DRAM_SDLY0 (0x4C)
|
||||
#define DRAM_SDLY1 (0x50)
|
||||
#define DRAM_SDLY2 (0x54)
|
||||
#define DRAM_MCR0 (0x100)
|
||||
#define DRAM_MCR1 (0x104)
|
||||
#define DRAM_MCR2 (0x108)
|
||||
#define DRAM_MCR3 (0x10c)
|
||||
#define DRAM_MCR4 (0x110)
|
||||
#define DRAM_MCR5 (0x114)
|
||||
#define DRAM_MCR6 (0x118)
|
||||
#define DRAM_MCR7 (0x11c)
|
||||
#define DRAM_MCR8 (0x120)
|
||||
#define DRAM_MCR9 (0x124)
|
||||
#define DRAM_MCR10 (0x128)
|
||||
#define DRAM_MCR11 (0x12c)
|
||||
#define DRAM_BWCR (0x140)
|
||||
|
||||
#endif /* __F1C100S_REG_DRAM_H__ */
|
54
payloads/f1c100s/f1c100s-jtag/include/io.h
Normal file
54
payloads/f1c100s/f1c100s-jtag/include/io.h
Normal file
@ -0,0 +1,54 @@
|
||||
#ifndef __IO_H__
|
||||
#define __IO_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <types.h>
|
||||
|
||||
static inline u8_t read8(virtual_addr_t addr)
|
||||
{
|
||||
return( *((volatile u8_t *)(addr)) );
|
||||
}
|
||||
|
||||
static inline u16_t read16(virtual_addr_t addr)
|
||||
{
|
||||
return( *((volatile u16_t *)(addr)) );
|
||||
}
|
||||
|
||||
static inline u32_t read32(virtual_addr_t addr)
|
||||
{
|
||||
return( *((volatile u32_t *)(addr)) );
|
||||
}
|
||||
|
||||
static inline u64_t read64(virtual_addr_t addr)
|
||||
{
|
||||
return( *((volatile u64_t *)(addr)) );
|
||||
}
|
||||
|
||||
static inline void write8(virtual_addr_t addr, u8_t value)
|
||||
{
|
||||
*((volatile u8_t *)(addr)) = value;
|
||||
}
|
||||
|
||||
static inline void write16(virtual_addr_t addr, u16_t value)
|
||||
{
|
||||
*((volatile u16_t *)(addr)) = value;
|
||||
}
|
||||
|
||||
static inline void write32(virtual_addr_t addr, u32_t value)
|
||||
{
|
||||
*((volatile u32_t *)(addr)) = value;
|
||||
}
|
||||
|
||||
static inline void write64(virtual_addr_t addr, u64_t value)
|
||||
{
|
||||
*((volatile u64_t *)(addr)) = value;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __IO_H__ */
|
34
payloads/f1c100s/f1c100s-jtag/include/stdarg.h
Normal file
34
payloads/f1c100s/f1c100s-jtag/include/stdarg.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef __STDARG_H__
|
||||
#define __STDARG_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef __builtin_va_list va_list;
|
||||
|
||||
/*
|
||||
* prepare to access variable args
|
||||
*/
|
||||
#define va_start(v, l) __builtin_va_start(v, l)
|
||||
|
||||
/*
|
||||
* the caller will get the value of current argument
|
||||
*/
|
||||
#define va_arg(v, l) __builtin_va_arg(v, l)
|
||||
|
||||
/*
|
||||
* end for variable args
|
||||
*/
|
||||
#define va_end(v) __builtin_va_end(v)
|
||||
|
||||
/*
|
||||
* copy variable args
|
||||
*/
|
||||
#define va_copy(d, s) __builtin_va_copy(d, s)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STDARG_H__ */
|
49
payloads/f1c100s/f1c100s-jtag/include/stddef.h
Normal file
49
payloads/f1c100s/f1c100s-jtag/include/stddef.h
Normal file
@ -0,0 +1,49 @@
|
||||
#ifndef __STDDEF_H__
|
||||
#define __STDDEF_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
#define NULL (0)
|
||||
#else
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
|
||||
#if (defined(__GNUC__) && (__GNUC__ >= 4))
|
||||
#define offsetof(type, member) __builtin_offsetof(type, member)
|
||||
#else
|
||||
#define offsetof(type, field) ((size_t)(&((type *)0)->field))
|
||||
#endif
|
||||
#define container_of(ptr, type, member) ({const typeof(((type *)0)->member) *__mptr = (ptr); (type *)((char *)__mptr - offsetof(type,member));})
|
||||
|
||||
#if (defined(__GNUC__) && (__GNUC__ >= 3))
|
||||
#define likely(expr) (__builtin_expect(!!(expr), 1))
|
||||
#define unlikely(expr) (__builtin_expect(!!(expr), 0))
|
||||
#else
|
||||
#define likely(expr) (!!(expr))
|
||||
#define unlikely(expr) (!!(expr))
|
||||
#endif
|
||||
|
||||
#define min(a, b) ({typeof(a) _amin = (a); typeof(b) _bmin = (b); (void)(&_amin == &_bmin); _amin < _bmin ? _amin : _bmin;})
|
||||
#define max(a, b) ({typeof(a) _amax = (a); typeof(b) _bmax = (b); (void)(&_amax == &_bmax); _amax > _bmax ? _amax : _bmax;})
|
||||
#define clamp(v, a, b) min(max(a, v), b)
|
||||
|
||||
#define ifloor(x) ((x) > 0 ? (int)(x) : (int)((x) - 0.9999999999))
|
||||
#define iround(x) ((x) > 0 ? (int)((x) + 0.5) : (int)((x) - 0.5))
|
||||
#define iceil(x) ((x) > 0 ? (int)((x) + 0.9999999999) : (int)(x))
|
||||
#define idiv255(x) ((((int)(x) + 1) * 257) >> 16)
|
||||
|
||||
#define X(...) ("" #__VA_ARGS__ "")
|
||||
|
||||
enum {
|
||||
FALSE = 0,
|
||||
TRUE = 1,
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STDDEF_H__ */
|
31
payloads/f1c100s/f1c100s-jtag/include/stdint.h
Normal file
31
payloads/f1c100s/f1c100s-jtag/include/stdint.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef __STDINT_H__
|
||||
#define __STDINT_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <types.h>
|
||||
|
||||
typedef s8_t int8_t;
|
||||
typedef u8_t uint8_t;
|
||||
|
||||
typedef s16_t int16_t;
|
||||
typedef u16_t uint16_t;
|
||||
|
||||
typedef s32_t int32_t;
|
||||
typedef u32_t uint32_t;
|
||||
|
||||
typedef s64_t int64_t;
|
||||
typedef u64_t uint64_t;
|
||||
|
||||
#define UINT8_MAX (0xff)
|
||||
#define UINT16_MAX (0xffff)
|
||||
#define UINT32_MAX (0xffffffff)
|
||||
#define UINT64_MAX (0xffffffffffffffffULL)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STDINT_H__ */
|
17
payloads/f1c100s/f1c100s-jtag/include/string.h
Normal file
17
payloads/f1c100s/f1c100s-jtag/include/string.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef __STRING_H__
|
||||
#define __STRING_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <types.h>
|
||||
|
||||
void * memset(void * s, int c, size_t n);
|
||||
void * memcpy(void * dest, const void * src, size_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STRING_H__ */
|
53
payloads/f1c100s/f1c100s-jtag/include/types.h
Normal file
53
payloads/f1c100s/f1c100s-jtag/include/types.h
Normal 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__ */
|
21
payloads/f1c100s/f1c100s-jtag/include/xboot.h
Normal file
21
payloads/f1c100s/f1c100s-jtag/include/xboot.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef __XBOOT_H__
|
||||
#define __XBOOT_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <types.h>
|
||||
#include <io.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <endian.h>
|
||||
#include <byteorder.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __XBOOT_H__ */
|
122
payloads/f1c100s/f1c100s-jtag/link.ld
Normal file
122
payloads/f1c100s/f1c100s-jtag/link.ld
Normal file
@ -0,0 +1,122 @@
|
||||
OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
|
||||
OUTPUT_ARCH(arm)
|
||||
ENTRY(_start)
|
||||
|
||||
STACK_UND_SIZE = 0x010;
|
||||
STACK_ABT_SIZE = 0x010;
|
||||
STACK_IRQ_SIZE = 0x010;
|
||||
STACK_FIQ_SIZE = 0x010;
|
||||
STACK_SRV_SIZE = 0x400;
|
||||
|
||||
MEMORY
|
||||
{
|
||||
ram : org = 0x00008800, len = 0x00001000 /* 4 KB */
|
||||
}
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
PROVIDE(__image_start = .);
|
||||
PROVIDE(__text_start = .);
|
||||
.obj/source/start.o (.text)
|
||||
.obj/source/sys-jtag.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) }
|
||||
}
|
72
payloads/f1c100s/f1c100s-jtag/source/start.S
Normal file
72
payloads/f1c100s/f1c100s-jtag/source/start.S
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* 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:
|
||||
b reset
|
||||
|
||||
reset:
|
||||
ldr r0, =0x00000040
|
||||
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, c1, c0, 0
|
||||
str lr, [r0, #16]
|
||||
|
||||
bl sys_jtag_init
|
||||
|
||||
mov r0, #0x4
|
||||
mov r1, #'e'
|
||||
strb r1, [r0, #0]
|
||||
mov r1, #'G'
|
||||
strb r1, [r0, #1]
|
||||
mov r1, #'O'
|
||||
strb r1, [r0, #2]
|
||||
mov r1, #'N'
|
||||
strb r1, [r0, #3]
|
||||
mov r1, #'.'
|
||||
strb r1, [r0, #4]
|
||||
mov r1, #'F'
|
||||
strb r1, [r0, #5]
|
||||
mov r1, #'E'
|
||||
strb r1, [r0, #6]
|
||||
mov r1, #'L'
|
||||
strb r1, [r0, #7]
|
||||
ldr r0, =0x00000040
|
||||
ldr sp, [r0, #0]
|
||||
ldr lr, [r0, #4]
|
||||
ldr r1, [r0, #16]
|
||||
mcr p15, 0, r1, c1, c0, 0
|
||||
ldr r1, [r0, #12]
|
||||
mcr p15, 0, r1, c1, c0, 0
|
||||
ldr r1, [r0, #8]
|
||||
msr cpsr, r1
|
||||
bx lr
|
57
payloads/f1c100s/f1c100s-jtag/source/sys-jtag.c
Normal file
57
payloads/f1c100s/f1c100s-jtag/source/sys-jtag.c
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* sys-jtag.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_jtag_init(void)
|
||||
{
|
||||
virtual_addr_t addr;
|
||||
u32_t val;
|
||||
|
||||
/* Config GPIOF0, GPIOF1, GPIOF3 and GPIOF5 to JTAG mode */
|
||||
addr = 0x01c208b4 + 0x00;
|
||||
val = read32(addr);
|
||||
val &= ~(0xf << ((0 & 0x7) << 2));
|
||||
val |= ((0x3 & 0x7) << ((0 & 0x7) << 2));
|
||||
write32(addr, val);
|
||||
|
||||
val = read32(addr);
|
||||
val &= ~(0xf << ((1 & 0x7) << 2));
|
||||
val |= ((0x3 & 0x7) << ((1 & 0x7) << 2));
|
||||
write32(addr, val);
|
||||
|
||||
val = read32(addr);
|
||||
val &= ~(0xf << ((3 & 0x7) << 2));
|
||||
val |= ((0x3 & 0x7) << ((3 & 0x7) << 2));
|
||||
write32(addr, val);
|
||||
|
||||
val = read32(addr);
|
||||
val &= ~(0xf << ((5 & 0x7) << 2));
|
||||
val |= ((0x3 & 0x7) << ((5 & 0x7) << 2));
|
||||
write32(addr, val);
|
||||
}
|
Loading…
Reference in New Issue
Block a user