Merge git://git.denx.de/u-boot-rockchip

This commit is contained in:
Tom Rini 2015-12-16 14:50:03 -05:00
commit 35065cdd94
25 changed files with 483 additions and 279 deletions

View File

@ -17,21 +17,6 @@ config ROCKCHIP_RK3036
and video codec support. Peripherals include Gigabit Ethernet,
USB2 host and OTG, SDIO, I2S, UART, SPI, I2C and PWMs.
config ROCKCHIP_SPL_HDR
string "Header of rockchip's spl loader"
help
Rockchip's bootrom requires the spl loader to start with a 4-bytes
header. The content of this header depends on the chip type.
config ROCKCHIP_MAX_SPL_SIZE
hex "Max size of rockchip's spl loader"
help
Different chip may have different sram size. And if we want to jump
back to the bootrom after spl, we may need to reserve some sram space
for the bootrom.
The max spl loader size should be sram size minus reserved
size(if needed)
config SYS_MALLOC_F
default y

View File

@ -3,21 +3,19 @@ if ROCKCHIP_RK3036
config TARGET_EVB_RK3036
bool "EVB_RK3036"
config TARGET_KYLIN_RK3036
bool "KYLIN_RK3036"
config SYS_SOC
default "rockchip"
config SYS_MALLOC_F_LEN
default 0x400
config ROCKCHIP_SPL_HDR
default "RK30"
config ROCKCHIP_MAX_SPL_SIZE
default 0x1000
config ROCKCHIP_COMMON
bool "Support rk common fuction"
source "board/evb_rk3036/evb_rk3036/Kconfig"
source "board/kylin/kylin_rk3036/Kconfig"
endif

View File

@ -701,15 +701,19 @@ finish:
static void sdram_all_config(struct rk3036_sdram_priv *priv)
{
u32 os_reg = 0;
u32 cs1_row = 0;
struct rk3036_ddr_config config = priv->ddr_config;
if (config.rank > 1)
cs1_row = config.cs1_row - 13;
os_reg = config.ddr_type << DDR_TYPE_SHIFT |
0 << DDR_CHN_CNT_SHIFT |
(config.rank - 1) << DDR_RANK_CNT_SHIFT |
(config.col - 1) << DDR_COL_SHIFT |
(config.bank == 3 ? 0 : 1) << DDR_BANK_SHIFT |
(config.cs0_row - 13) << DDR_CS0_ROW_SHIFT |
(config.cs1_row - 13) << DDR_CS1_ROW_SHIFT |
cs1_row << DDR_CS1_ROW_SHIFT |
1 << DDR_BW_SHIFT | config.bw << DDR_DIE_BW_SHIFT;
writel(os_reg, &priv->grf->os_reg[1]);
}

View File

@ -16,12 +16,6 @@ config TARGET_CHROMEBOOK_JERRY
WiFi. It includes a Chrome OS EC (Cortex-M3) to provide access to
the keyboard and battery functions.
config ROCKCHIP_SPL_HDR
default "RK32"
config ROCKCHIP_MAX_SPL_SIZE
default 0x8000
config SYS_SOC
default "rockchip"

View File

@ -0,0 +1,15 @@
if TARGET_KYLIN_RK3036
config SYS_BOARD
default "kylin_rk3036"
config SYS_VENDOR
default "kylin"
config SYS_CONFIG_NAME
default "kylin_rk3036"
config BOARD_SPECIFIC_OPTIONS # dummy
def_bool y
endif

View File

View File

@ -0,0 +1,7 @@
#
# (C) Copyright 2015 Google, Inc
#
# SPDX-License-Identifier: GPL-2.0+
#
obj-y += kylin_rk3036.o

View File

@ -0,0 +1,49 @@
/*
* (C) Copyright 2015 Rockchip Electronics Co., Ltd
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <dm.h>
#include <asm/io.h>
#include <asm/arch/uart.h>
#include <asm/arch/sdram_rk3036.h>
DECLARE_GLOBAL_DATA_PTR;
void get_ddr_config(struct rk3036_ddr_config *config)
{
/* K4B4G1646Q config */
config->ddr_type = 3;
config->rank = 1;
config->cs0_row = 15;
config->cs1_row = 15;
/* 8bank */
config->bank = 3;
config->col = 10;
/* 16bit bw */
config->bw = 1;
}
int board_init(void)
{
return 0;
}
int dram_init(void)
{
gd->ram_size = sdram_size();
return 0;
}
#ifndef CONFIG_SYS_DCACHE_OFF
void enable_caches(void)
{
/* Enable D-cache. I-cache is already enabled in start.S */
dcache_enable();
}
#endif

View File

@ -452,7 +452,7 @@ ulong spl_relocate_stack_gd(void)
#ifdef CONFIG_SPL_SYS_MALLOC_SIMPLE
if (CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN) {
if (!(gd->flags & GD_FLG_SPL_INIT))
panic("spl_init must be called before heap reloc");
panic_str("spl_init must be called before heap reloc");
ptr -= CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN;
gd->malloc_base = ptr;

View File

@ -42,5 +42,6 @@ CONFIG_DEBUG_UART_CLOCK=24000000
CONFIG_DEBUG_UART_SHIFT=2
CONFIG_SYS_NS16550=y
CONFIG_USE_PRIVATE_LIBGCC=y
CONFIG_USE_TINY_PRINTF=y
CONFIG_CMD_DHRYSTONE=y
CONFIG_ERRNO_STR=y

View File

@ -0,0 +1,26 @@
CONFIG_ARM=y
CONFIG_ARCH_ROCKCHIP=y
CONFIG_ROCKCHIP_RK3036=y
CONFIG_TARGET_KYLIN_RK3036=y
CONFIG_DEFAULT_DEVICE_TREE="rk3036-sdk"
CONFIG_SPL_STACK_R=y
CONFIG_SPL_STACK_R_ADDR=0x80000
# CONFIG_CMD_IMLS is not set
# CONFIG_CMD_SETEXPR is not set
CONFIG_CMD_PMIC=y
CONFIG_CMD_REGULATOR=y
CONFIG_CLK=y
CONFIG_REGMAP=y
CONFIG_SYSCON=y
CONFIG_RESET=y
CONFIG_LED=y
CONFIG_SYS_I2C_ROCKCHIP=y
CONFIG_PINCTRL=y
CONFIG_ROCKCHIP_DWMMC=y
CONFIG_ROCKCHIP_3036_PINCTRL=y
CONFIG_ROCKCHIP_GPIO=y
CONFIG_RAM=y
CONFIG_DM_MMC=y
CONFIG_USE_PRIVATE_LIBGCC=y
CONFIG_CMD_DHRYSTONE=y
CONFIG_ERRNO_STR=y

View File

@ -71,7 +71,7 @@ Connect your board's OTG port to your computer.
To create a suitable image and write it to the board:
./firefly-rk3288/tools/mkimage -T rkimage -d \
./firefly-rk3288/tools/mkimage -n rk3288 -T rkimage -d \
./firefly-rk3288/spl/u-boot-spl-dtb.bin out && \
cat out | openssl rc4 -K 7c4e0304550509072d2c7b38170d1711 | rkflashtool l
@ -94,7 +94,7 @@ Booting from an SD card
To write an image that boots from an SD card (assumed to be /dev/sdc):
./firefly-rk3288/tools/mkimage -T rksd -d \
./firefly-rk3288/tools/mkimage -n rk3288 -T rksd -d \
firefly-rk3288/spl/u-boot-spl-dtb.bin out && \
sudo dd if=out of=/dev/sdc seek=64 && \
sudo dd if=firefly-rk3288/u-boot-dtb.img of=/dev/sdc seek=256
@ -123,7 +123,7 @@ something like:
=>
For evb_rk3036 board:
./evb-rk3036/tools/mkimage -T rksd -d evb-rk3036/spl/u-boot-spl.bin out && \
./evb-rk3036/tools/mkimage -n rk3036 -T rksd -d evb-rk3036/spl/u-boot-spl.bin out && \
cat evb-rk3036/u-boot-dtb.bin >> out && \
sudo dd if=out of=/dev/sdc seek=64
@ -135,7 +135,7 @@ Booting from SPI
To write an image that boots from SPI flash (e.g. for the Haier Chromebook):
./chromebook_jerry/tools/mkimage -T rkspi -d chromebook_jerry/spl/u-boot-spl-dtb.bin out
./chromebook_jerry/tools/mkimage -n rk3036 -T rkspi -d chromebook_jerry/spl/u-boot-spl-dtb.bin out
dd if=spl.bin of=out.bin bs=128K conv=sync
cat chromebook_jerry/u-boot-dtb.img out.bin
dd if=out.bin of=out.bin.pad bs=4M conv=sync

View File

@ -1469,7 +1469,9 @@ static int mmc_startup(struct mmc *mmc)
mmc->block_dev.blksz = mmc->read_bl_len;
mmc->block_dev.log2blksz = LOG2(mmc->block_dev.blksz);
mmc->block_dev.lba = lldiv(mmc->capacity, mmc->read_bl_len);
#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
#if !defined(CONFIG_SPL_BUILD) || \
(defined(CONFIG_SPL_LIBCOMMON_SUPPORT) && \
!defined(CONFIG_USE_TINY_PRINTF))
sprintf(mmc->block_dev.vendor, "Man %06x Snr %04x%04x",
mmc->cid[0] >> 24, (mmc->cid[2] & 0xffff),
(mmc->cid[3] >> 16) & 0xffff);

View File

@ -0,0 +1,12 @@
/*
* (C) Copyright 2015 Rockchip Electronics Co., Ltd
*
* SPDX-License-Identifier: GPL-2.0+
*/
#ifndef __CONFIG_H
#define __CONFIG_H
#include <configs/rk3036_common.h>
#endif

View File

@ -85,13 +85,13 @@ obj-$(CONFIG_LIB_RAND) += rand.o
ifdef CONFIG_SPL_BUILD
# SPL U-Boot may use full-printf, tiny-printf or none at all
ifdef CONFIG_USE_TINY_PRINTF
obj-$(CONFIG_SPL_SERIAL_SUPPORT) += tiny-printf.o
obj-$(CONFIG_SPL_SERIAL_SUPPORT) += tiny-printf.o panic.o strto.o
else
obj-$(CONFIG_SPL_SERIAL_SUPPORT) += vsprintf.o
obj-$(CONFIG_SPL_SERIAL_SUPPORT) += vsprintf.o panic.o strto.o
endif
else
# Main U-Boot always uses the full printf support
obj-y += vsprintf.o
obj-y += vsprintf.o panic.o strto.o
endif
subdir-ccflags-$(CONFIG_CC_OPTIMIZE_LIBS_FOR_SPEED) += -O2

45
lib/panic.c Normal file
View File

@ -0,0 +1,45 @@
/*
* linux/lib/vsprintf.c
*
* Copyright (C) 1991, 1992 Linus Torvalds
*/
/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */
/*
* Wirzenius wrote this portably, Torvalds fucked it up :-)
*/
#include <common.h>
#if !defined(CONFIG_PANIC_HANG)
#include <command.h>
#endif
static void panic_finish(void) __attribute__ ((noreturn));
static void panic_finish(void)
{
putc('\n');
#if defined(CONFIG_PANIC_HANG)
hang();
#else
udelay(100000); /* allow messages to go out */
do_reset(NULL, 0, 0, NULL);
#endif
while (1)
;
}
void panic_str(const char *str)
{
puts(str);
panic_finish();
}
void panic(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
vprintf(fmt, args);
va_end(args);
panic_finish();
}

174
lib/strto.c Normal file
View File

@ -0,0 +1,174 @@
/*
* linux/lib/vsprintf.c
*
* Copyright (C) 1991, 1992 Linus Torvalds
*/
/* vsprintf.c -- Lars Wirzenius & Linus Torvalds. */
/*
* Wirzenius wrote this portably, Torvalds fucked it up :-)
*/
#include <common.h>
#include <errno.h>
#include <linux/ctype.h>
unsigned long simple_strtoul(const char *cp, char **endp,
unsigned int base)
{
unsigned long result = 0;
unsigned long value;
if (*cp == '0') {
cp++;
if ((*cp == 'x') && isxdigit(cp[1])) {
base = 16;
cp++;
}
if (!base)
base = 8;
}
if (!base)
base = 10;
while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp-'0' : (islower(*cp)
? toupper(*cp) : *cp)-'A'+10) < base) {
result = result*base + value;
cp++;
}
if (endp)
*endp = (char *)cp;
return result;
}
int strict_strtoul(const char *cp, unsigned int base, unsigned long *res)
{
char *tail;
unsigned long val;
size_t len;
*res = 0;
len = strlen(cp);
if (len == 0)
return -EINVAL;
val = simple_strtoul(cp, &tail, base);
if (tail == cp)
return -EINVAL;
if ((*tail == '\0') ||
((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) {
*res = val;
return 0;
}
return -EINVAL;
}
long simple_strtol(const char *cp, char **endp, unsigned int base)
{
if (*cp == '-')
return -simple_strtoul(cp + 1, endp, base);
return simple_strtoul(cp, endp, base);
}
unsigned long ustrtoul(const char *cp, char **endp, unsigned int base)
{
unsigned long result = simple_strtoul(cp, endp, base);
switch (**endp) {
case 'G':
result *= 1024;
/* fall through */
case 'M':
result *= 1024;
/* fall through */
case 'K':
case 'k':
result *= 1024;
if ((*endp)[1] == 'i') {
if ((*endp)[2] == 'B')
(*endp) += 3;
else
(*endp) += 2;
}
}
return result;
}
unsigned long long ustrtoull(const char *cp, char **endp, unsigned int base)
{
unsigned long long result = simple_strtoull(cp, endp, base);
switch (**endp) {
case 'G':
result *= 1024;
/* fall through */
case 'M':
result *= 1024;
/* fall through */
case 'K':
case 'k':
result *= 1024;
if ((*endp)[1] == 'i') {
if ((*endp)[2] == 'B')
(*endp) += 3;
else
(*endp) += 2;
}
}
return result;
}
unsigned long long simple_strtoull(const char *cp, char **endp,
unsigned int base)
{
unsigned long long result = 0, value;
if (*cp == '0') {
cp++;
if ((*cp == 'x') && isxdigit(cp[1])) {
base = 16;
cp++;
}
if (!base)
base = 8;
}
if (!base)
base = 10;
while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp - '0'
: (islower(*cp) ? toupper(*cp) : *cp) - 'A' + 10) < base) {
result = result * base + value;
cp++;
}
if (endp)
*endp = (char *) cp;
return result;
}
long trailing_strtoln(const char *str, const char *end)
{
const char *p;
if (!end)
end = str + strlen(str);
for (p = end - 1; p > str; p--) {
if (!isdigit(*p))
return simple_strtoul(p + 1, NULL, 10);
}
return -1;
}
long trailing_strtol(const char *str)
{
return trailing_strtoln(str, NULL);
}

View File

@ -40,17 +40,14 @@ static void div_out(unsigned int *num, unsigned int div)
out_dgt(dgt);
}
int printf(const char *fmt, ...)
int vprintf(const char *fmt, va_list va)
{
va_list va;
char ch;
char *p;
unsigned int num;
char buf[12];
unsigned int div;
va_start(va, fmt);
while ((ch = *(fmt++))) {
if (ch != '%') {
putc(ch);
@ -117,6 +114,17 @@ int printf(const char *fmt, ...)
}
abort:
va_end(va);
return 0;
}
int printf(const char *fmt, ...)
{
va_list va;
int ret;
va_start(va, fmt);
ret = vprintf(fmt, va);
va_end(va);
return ret;
}

View File

@ -15,176 +15,12 @@
#include <linux/types.h>
#include <linux/string.h>
#include <linux/ctype.h>
#include <errno.h>
#include <common.h>
#if !defined(CONFIG_PANIC_HANG)
#include <command.h>
#endif
#include <div64.h>
#define noinline __attribute__((noinline))
unsigned long simple_strtoul(const char *cp, char **endp,
unsigned int base)
{
unsigned long result = 0;
unsigned long value;
if (*cp == '0') {
cp++;
if ((*cp == 'x') && isxdigit(cp[1])) {
base = 16;
cp++;
}
if (!base)
base = 8;
}
if (!base)
base = 10;
while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp-'0' : (islower(*cp)
? toupper(*cp) : *cp)-'A'+10) < base) {
result = result*base + value;
cp++;
}
if (endp)
*endp = (char *)cp;
return result;
}
int strict_strtoul(const char *cp, unsigned int base, unsigned long *res)
{
char *tail;
unsigned long val;
size_t len;
*res = 0;
len = strlen(cp);
if (len == 0)
return -EINVAL;
val = simple_strtoul(cp, &tail, base);
if (tail == cp)
return -EINVAL;
if ((*tail == '\0') ||
((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) {
*res = val;
return 0;
}
return -EINVAL;
}
long simple_strtol(const char *cp, char **endp, unsigned int base)
{
if (*cp == '-')
return -simple_strtoul(cp + 1, endp, base);
return simple_strtoul(cp, endp, base);
}
unsigned long ustrtoul(const char *cp, char **endp, unsigned int base)
{
unsigned long result = simple_strtoul(cp, endp, base);
switch (**endp) {
case 'G':
result *= 1024;
/* fall through */
case 'M':
result *= 1024;
/* fall through */
case 'K':
case 'k':
result *= 1024;
if ((*endp)[1] == 'i') {
if ((*endp)[2] == 'B')
(*endp) += 3;
else
(*endp) += 2;
}
}
return result;
}
unsigned long long ustrtoull(const char *cp, char **endp, unsigned int base)
{
unsigned long long result = simple_strtoull(cp, endp, base);
switch (**endp) {
case 'G':
result *= 1024;
/* fall through */
case 'M':
result *= 1024;
/* fall through */
case 'K':
case 'k':
result *= 1024;
if ((*endp)[1] == 'i') {
if ((*endp)[2] == 'B')
(*endp) += 3;
else
(*endp) += 2;
}
}
return result;
}
unsigned long long simple_strtoull(const char *cp, char **endp,
unsigned int base)
{
unsigned long long result = 0, value;
if (*cp == '0') {
cp++;
if ((*cp == 'x') && isxdigit(cp[1])) {
base = 16;
cp++;
}
if (!base)
base = 8;
}
if (!base)
base = 10;
while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp - '0'
: (islower(*cp) ? toupper(*cp) : *cp) - 'A' + 10) < base) {
result = result * base + value;
cp++;
}
if (endp)
*endp = (char *) cp;
return result;
}
long trailing_strtoln(const char *str, const char *end)
{
const char *p;
if (!end)
end = str + strlen(str);
for (p = end - 1; p > str; p--) {
if (!isdigit(*p))
return simple_strtoul(p + 1, NULL, 10);
}
return -1;
}
long trailing_strtol(const char *str)
{
return trailing_strtoln(str, NULL);
}
/* we use this so that we can do without the ctype library */
#define is_digit(c) ((c) >= '0' && (c) <= '9')
@ -897,35 +733,6 @@ int vprintf(const char *fmt, va_list args)
return i;
}
static void panic_finish(void) __attribute__ ((noreturn));
static void panic_finish(void)
{
putc('\n');
#if defined(CONFIG_PANIC_HANG)
hang();
#else
udelay(100000); /* allow messages to go out */
do_reset(NULL, 0, 0, NULL);
#endif
while (1)
;
}
void panic_str(const char *str)
{
puts(str);
panic_finish();
}
void panic(const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
vprintf(fmt, args);
va_end(args);
panic_finish();
}
void __assert_fail(const char *assertion, const char *file, unsigned line,
const char *function)

View File

@ -64,7 +64,7 @@ RSA_OBJS-$(CONFIG_FIT_SIGNATURE) := $(addprefix lib/rsa/, \
rsa-sign.o rsa-verify.o rsa-checksum.o \
rsa-mod-exp.o)
ROCKCHIP_OBS = $(if $(CONFIG_ARCH_ROCKCHIP),lib/rc4.o rkcommon.o rkimage.o rksd.o,)
ROCKCHIP_OBS = lib/rc4.o rkcommon.o rkimage.o rksd.o
# common objs for dumpimage and mkimage
dumpimage-mkimage-objs := aisimage.o \
@ -109,12 +109,6 @@ fit_check_sign-objs := $(dumpimage-mkimage-objs) fit_check_sign.o
# TODO(sjg@chromium.org): Is this correct on Mac OS?
ifneq ($(CONFIG_ARCH_ROCKCHIP),)
HOST_EXTRACFLAGS += \
-DCONFIG_ROCKCHIP_MAX_SPL_SIZE=$(CONFIG_ROCKCHIP_MAX_SPL_SIZE) \
-DCONFIG_ROCKCHIP_SPL_HDR="\"$(CONFIG_ROCKCHIP_SPL_HDR)\""
endif
ifneq ($(CONFIG_MX23)$(CONFIG_MX28),)
# Add CONFIG_MXS into host CFLAGS, so we can check whether or not register
# the mxsimage support within tools/mxsimage.c .

View File

@ -40,16 +40,84 @@ struct header0_info {
uint8_t reserved2[2];
};
/**
* struct spl_info - spl info for each chip
*
* @imagename: Image name(passed by "mkimage -n")
* @spl_hdr: Boot ROM requires a 4-bytes spl header
* @spl_size: Spl size(include extra 4-bytes spl header)
*/
struct spl_info {
const char *imagename;
const char *spl_hdr;
const uint32_t spl_size;
};
static struct spl_info spl_infos[] = {
{ "rk3036", "RK30", 0x1000 },
{ "rk3288", "RK32", 0x8000 },
};
static unsigned char rc4_key[16] = {
124, 78, 3, 4, 85, 5, 9, 7,
45, 44, 123, 56, 23, 13, 23, 17
};
int rkcommon_set_header(void *buf, uint file_size)
static struct spl_info *rkcommon_get_spl_info(char *imagename)
{
int i;
for (i = 0; i < ARRAY_SIZE(spl_infos); i++)
if (!strncmp(imagename, spl_infos[i].imagename, 6))
return spl_infos + i;
return NULL;
}
int rkcommon_check_params(struct image_tool_params *params)
{
int i;
if (rkcommon_get_spl_info(params->imagename) != NULL)
return 0;
fprintf(stderr, "ERROR: imagename (%s) is not supported!\n",
strlen(params->imagename) > 0 ? params->imagename : "NULL");
fprintf(stderr, "Available imagename:");
for (i = 0; i < ARRAY_SIZE(spl_infos); i++)
fprintf(stderr, "\t%s", spl_infos[i].imagename);
fprintf(stderr, "\n");
return -1;
}
const char *rkcommon_get_spl_hdr(struct image_tool_params *params)
{
struct spl_info *info = rkcommon_get_spl_info(params->imagename);
/*
* info would not be NULL, because of we checked params before.
*/
return info->spl_hdr;
}
int rkcommon_get_spl_size(struct image_tool_params *params)
{
struct spl_info *info = rkcommon_get_spl_info(params->imagename);
/*
* info would not be NULL, because of we checked params before.
*/
return info->spl_size;
}
int rkcommon_set_header(void *buf, uint file_size,
struct image_tool_params *params)
{
struct header0_info *hdr;
if (file_size > CONFIG_ROCKCHIP_MAX_SPL_SIZE)
if (file_size > rkcommon_get_spl_size(params))
return -ENOSPC;
memset(buf, '\0', RK_INIT_OFFSET * RK_BLK_SIZE);

View File

@ -12,8 +12,37 @@ enum {
RK_BLK_SIZE = 512,
RK_INIT_OFFSET = 4,
RK_MAX_BOOT_SIZE = 512 << 10,
RK_SPL_HDR_START = RK_INIT_OFFSET * RK_BLK_SIZE,
RK_SPL_HDR_SIZE = 4,
RK_SPL_START = RK_SPL_HDR_START + RK_SPL_HDR_SIZE,
RK_IMAGE_HEADER_LEN = RK_SPL_START,
};
/**
* rkcommon_check_params() - check params
*
* @return 0 if OK, -1 if ERROR.
*/
int rkcommon_check_params(struct image_tool_params *params);
/**
* rkcommon_get_spl_hdr() - get 4-bytes spl hdr for a Rockchip boot image
*
* Rockchip's bootrom requires the spl loader to start with a 4-bytes
* header. The content of this header depends on the chip type.
*/
const char *rkcommon_get_spl_hdr(struct image_tool_params *params);
/**
* rkcommon_get_spl_size() - get spl size for a Rockchip boot image
*
* Different chip may have different sram size. And if we want to jump
* back to the bootrom after spl, we may need to reserve some sram space
* for the bootrom.
* The spl loader size should be sram size minus reserved size(if needed)
*/
int rkcommon_get_spl_size(struct image_tool_params *params);
/**
* rkcommon_set_header() - set up the header for a Rockchip boot image
*
@ -23,6 +52,7 @@ enum {
* @file_size: Size of the file we want the boot ROM to load, in bytes
* @return 0 if OK, -ENOSPC if too large
*/
int rkcommon_set_header(void *buf, uint file_size);
int rkcommon_set_header(void *buf, uint file_size,
struct image_tool_params *params);
#endif

View File

@ -9,6 +9,7 @@
#include "imagetool.h"
#include <image.h>
#include "rkcommon.h"
static uint32_t header;
@ -30,7 +31,8 @@ static void rkimage_print_header(const void *buf)
static void rkimage_set_header(void *buf, struct stat *sbuf, int ifd,
struct image_tool_params *params)
{
memcpy(buf, CONFIG_ROCKCHIP_SPL_HDR, 4);
memcpy(buf + RK_SPL_HDR_START, rkcommon_get_spl_hdr(params),
RK_SPL_HDR_SIZE);
}
static int rkimage_extract_subimage(void *buf, struct image_tool_params *params)

View File

@ -13,18 +13,7 @@
#include "mkimage.h"
#include "rkcommon.h"
enum {
RKSD_SPL_HDR_START = RK_INIT_OFFSET * RK_BLK_SIZE,
RKSD_SPL_START = RKSD_SPL_HDR_START + 4,
RKSD_HEADER_LEN = RKSD_SPL_START,
};
static char dummy_hdr[RKSD_HEADER_LEN];
static int rksd_check_params(struct image_tool_params *params)
{
return 0;
}
static char dummy_hdr[RK_IMAGE_HEADER_LEN];
static int rksd_verify_header(unsigned char *buf, int size,
struct image_tool_params *params)
@ -42,15 +31,16 @@ static void rksd_set_header(void *buf, struct stat *sbuf, int ifd,
unsigned int size;
int ret;
size = params->file_size - RKSD_SPL_HDR_START;
ret = rkcommon_set_header(buf, size);
size = params->file_size - RK_SPL_HDR_START;
ret = rkcommon_set_header(buf, size, params);
if (ret) {
/* TODO(sjg@chromium.org): This method should return an error */
printf("Warning: SPL image is too large (size %#x) and will not boot\n",
size);
}
memcpy(buf + RKSD_SPL_HDR_START, CONFIG_ROCKCHIP_SPL_HDR, 4);
memcpy(buf + RK_SPL_HDR_START, rkcommon_get_spl_hdr(params),
RK_SPL_HDR_SIZE);
}
static int rksd_extract_subimage(void *buf, struct image_tool_params *params)
@ -72,7 +62,7 @@ static int rksd_vrec_header(struct image_tool_params *params,
{
int pad_size;
pad_size = RKSD_SPL_HDR_START + CONFIG_ROCKCHIP_MAX_SPL_SIZE;
pad_size = RK_SPL_HDR_START + rkcommon_get_spl_size(params);
debug("pad_size %x\n", pad_size);
return pad_size - params->file_size;
@ -84,9 +74,9 @@ static int rksd_vrec_header(struct image_tool_params *params,
U_BOOT_IMAGE_TYPE(
rksd,
"Rockchip SD Boot Image support",
RKSD_HEADER_LEN,
RK_IMAGE_HEADER_LEN,
dummy_hdr,
rksd_check_params,
rkcommon_check_params,
rksd_verify_header,
rksd_print_header,
rksd_set_header,

View File

@ -14,18 +14,10 @@
#include "rkcommon.h"
enum {
RKSPI_SPL_HDR_START = RK_INIT_OFFSET * RK_BLK_SIZE,
RKSPI_SPL_START = RKSPI_SPL_HDR_START + 4,
RKSPI_HEADER_LEN = RKSPI_SPL_START,
RKSPI_SECT_LEN = RK_BLK_SIZE * 4,
};
static char dummy_hdr[RKSPI_HEADER_LEN];
static int rkspi_check_params(struct image_tool_params *params)
{
return 0;
}
static char dummy_hdr[RK_IMAGE_HEADER_LEN];
static int rkspi_verify_header(unsigned char *buf, int size,
struct image_tool_params *params)
@ -45,7 +37,7 @@ static void rkspi_set_header(void *buf, struct stat *sbuf, int ifd,
int ret;
size = params->orig_file_size;
ret = rkcommon_set_header(buf, size);
ret = rkcommon_set_header(buf, size, params);
debug("size %x\n", size);
if (ret) {
/* TODO(sjg@chromium.org): This method should return an error */
@ -53,7 +45,8 @@ static void rkspi_set_header(void *buf, struct stat *sbuf, int ifd,
size);
}
memcpy(buf + RKSPI_SPL_HDR_START, CONFIG_ROCKCHIP_SPL_HDR, 4);
memcpy(buf + RK_SPL_HDR_START, rkcommon_get_spl_hdr(params),
RK_SPL_HDR_SIZE);
/*
* Spread the image out so we only use the first 2KB of each 4KB
@ -89,12 +82,12 @@ static int rkspi_vrec_header(struct image_tool_params *params,
{
int pad_size;
pad_size = (CONFIG_ROCKCHIP_MAX_SPL_SIZE + 0x7ff) / 0x800 * 0x800;
pad_size = (rkcommon_get_spl_size(params) + 0x7ff) / 0x800 * 0x800;
params->orig_file_size = pad_size;
/* We will double the image size due to the SPI format */
pad_size *= 2;
pad_size += RKSPI_SPL_HDR_START;
pad_size += RK_SPL_HDR_START;
debug("pad_size %x\n", pad_size);
return pad_size - params->file_size;
@ -106,9 +99,9 @@ static int rkspi_vrec_header(struct image_tool_params *params,
U_BOOT_IMAGE_TYPE(
rkspi,
"Rockchip SPI Boot Image support",
RKSPI_HEADER_LEN,
RK_IMAGE_HEADER_LEN,
dummy_hdr,
rkspi_check_params,
rkcommon_check_params,
rkspi_verify_header,
rkspi_print_header,
rkspi_set_header,