Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Odroidxu4 v2017.05 #44

Open
wants to merge 6 commits into
base: odroidxu4-v2017.05
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions board/samsung/common/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,9 @@ void set_board_info(void)

#if defined(CONFIG_TARGET_ODROID_XU4) || defined(CONFIG_TARGET_ODROID_XU3)
/* save board_name for select dtb */
if (!strncmp("xu3-lite" , bdtype, 8))
setenv("board_name", "xu3l");
else if (!strncmp("xu3", bdtype, 3))
setenv("board_name", "xu3");
else
setenv("board_name", "xu4");
setenv("board_name", "xu4");
if (!strncmp("xu3", bdtype, 3))
setenv("board_name", bdtype);

/* save board_id_value (adc value) */
{
Expand Down
153 changes: 31 additions & 122 deletions cmd/cfgload.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,139 +9,48 @@
#include <command.h>
#include <errno.h>
#include <malloc.h>
#include <linux/ctype.h> /* isalpha, isdigit */
#include <linux/sizes.h>

#ifdef CONFIG_SYS_HUSH_PARSER
#include <cli_hush.h>
#endif

#if defined(CONFIG_TARGET_ODROID_XU4)
#define BOOTINI_MAGIC "ODROIDXU-UBOOT-CONFIG"
#else
#error 'BOOTINI_MAGIC' is missing!!!
#endif

#define SZ_BOOTINI SZ_64K

/* Nothing to proceed with zero size string or comment.
*
* FIXME: Do we really need to strip the line start with '#' or ';',
* since any U-boot command does not start with punctuation character.
*/
static int valid_command(const char* p)
{
char *q;

for (q = (char*)p; *q; q++) {
if (isblank(*q)) continue;
if (isalnum(*q)) return 1;
if (ispunct(*q))
return (*q != '#') && (*q != ';');
}

return !(p == q);
}

/* Read boot.ini from FAT partition
*/
static char* read_cfgload(void)
{
char msg[128] = { 0, };
unsigned long filesize;
char *p;

p = (char *)simple_strtoul(getenv("loadaddr"), NULL, 16);
if (NULL == p) {
p = (char *)CONFIG_SYS_LOAD_ADDR;
sprintf(msg, "%x", CONFIG_SYS_LOAD_ADDR);
setenv("loadaddr", msg);
}

setenv("filesize", "0");
sprintf(msg, "cfgload addr = 0x%08X, Loading boot.ini from ",
simple_strtoul(getenv("loadaddr"), NULL, 16));

setenv("msgload", msg);
run_command("if fatload mmc 0:1 ${loadaddr} boot.ini;" \
" then echo ${msgload} FAT;" \
" else if ext4load mmc 0:1 ${loadaddr} /boot.ini;" \
" then echo ${msgload} ext4 0:1 /boot.ini;" \
" else if ext4load mmc 0:1 ${loadaddr} /boot/boot.ini;" \
" then echo ${msgload} ext4 0:1 /boot/boot.ini;" \
" else if ext4load mmc 0:2 ${loadaddr} /boot/boot.ini;" \
" then echo ${msgload} ext4 0:2 /boot.ini;" \
" else if ext4load mmc 0:2 ${loadaddr} /boot.ini;" \
" then echo ${msgload} ext4 0:2 /boot/boot.ini;" \
" fi;fi;fi;fi;fi;", 0);

filesize = getenv_ulong("filesize", 16, 0);
if (0 == filesize) {
printf("cfgload: no boot.ini or empty file\n");
return NULL;
}

if (filesize > SZ_BOOTINI) {
printf("boot.ini: 'boot.ini' exceeds %d, size=%ld\n",
SZ_BOOTINI, filesize);
return NULL;
}

/* Terminate the read buffer with '\0' to be treated as string */
*(char *)(p + filesize) = '\0';

/* Scan MAGIC string, readed boot.ini must start with exact magic string.
* Otherwise, we will not proceed at all.
*/
while (*p) {
char *s = strsep(&p, "\n");
if (!valid_command(s))
continue;

/* MAGIC string is discovered, return the buffer address of next to
* proceed the commands.
*/
if (!strncmp(s, BOOTINI_MAGIC, sizeof(BOOTINI_MAGIC)))
return memcpy(malloc(filesize), p, filesize);
}

printf("cfgload: MAGIC NAME, %s, is not found!!\n", BOOTINI_MAGIC);

return NULL;
}

static int do_load_cfgload(cmd_tbl_t *cmdtp, int flag, int argc,
char *const argv[])
{
char *p;
char *cmd;

p = read_cfgload();
if (NULL == p)
return 0;

printf("cfgload: applying boot.ini...\n");

while (p) {
cmd = strsep(&p, "\n");
if (!valid_command(cmd))
continue;

printf("cfgload: %s\n", cmd);
int i, n, devno = 0;
char* scripts[] = {
"/boot.ini",
"/boot/boot.ini",
"/boot.scr",
};

ulong addr;
char cmd[1024];

if (argc < 2) {
addr = CONFIG_SYS_LOAD_ADDR;
debug ("* cfgload: default load address = 0x%08lx\n", addr);
} else {
addr = simple_strtoul(argv[1], NULL, 16);
debug ("* cfgload: cmdline image address = 0x%08lx\n", addr);
}

#ifndef CONFIG_SYS_HUSH_PARSER
run_command(cmd, 0);
#else
parse_string_outer(cmd, FLAG_PARSE_SEMICOLON
| FLAG_EXIT_FROM_LOOP);
#endif
setenv("devtype", "mmc");
setenv("devnum", simple_itoa(devno));
setenv("devno", simple_itoa(devno));

for (i = 1; i <= 2; i++) {
setenv("partition", simple_itoa(i));
for (n = 0; n < ARRAY_SIZE(scripts); n++) {
snprintf(cmd, sizeof(cmd),
"load mmc %d:%d 0x%08lx %s; source 0x%08lx",
devno, i, addr, scripts[n], addr);
run_command(cmd, 0);
}
}

return 0;
return 1;
}

U_BOOT_CMD(
cfgload, 1, 0, do_load_cfgload,
cfgload, 2, 0, do_load_cfgload,
"read 'boot.ini' from FAT partiton",
"\n"
" - read boot.ini from the first partiton treated as FAT partiton"
Expand Down
33 changes: 33 additions & 0 deletions cmd/source.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,25 @@
#include <mpc8xx.h>
#endif

#if defined(CONFIG_TARGET_ODROID_XU3) || defined(CONFIG_TARGET_ODROID_XU4)
#include <linux/ctype.h>

static
int check_odroid_script(ulong addr, char *product)
{
int i;
char *buf;
char magic[32];
int size = snprintf(magic, sizeof(magic), "%s-uboot-config", product);

buf = map_sysmem(addr, 0);
if (strncasecmp(magic, buf, size))
return -EINVAL;

return size;
}
#endif

int
source (ulong addr, const char *fit_uname)
{
Expand All @@ -42,6 +61,9 @@ source (ulong addr, const char *fit_uname)
const void *fit_data;
size_t fit_len;
#endif
#if defined(CONFIG_TARGET_ODROID_XU3) || defined(CONFIG_TARGET_ODROID_XU4)
int size;
#endif

verify = getenv_yesno ("verify");

Expand Down Expand Up @@ -133,8 +155,19 @@ source (ulong addr, const char *fit_uname)
break;
#endif
default:
#if defined(CONFIG_TARGET_ODROID_XU3) || defined(CONFIG_TARGET_ODROID_XU4)
size = check_odroid_script(addr, "ODROIDXU");
if (size > 0) {
data = (u32*)(addr + size);
len = simple_strtoul(getenv("filesize"), NULL, 16) - size;
} else {
puts ("Wrong image format for \"source\" command\n");
return 1;
}
#else
puts ("Wrong image format for \"source\" command\n");
return 1;
#endif
}

debug ("** Script length: %ld\n", len);
Expand Down
1 change: 1 addition & 0 deletions configs/odroid-xu3_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ CONFIG_G_DNL_VENDOR_NUM=0x04e8
CONFIG_G_DNL_PRODUCT_NUM=0x6601
CONFIG_VIDEO_BRIDGE=y
CONFIG_ERRNO_STR=y
CONFIG_OF_LIBFDT_OVERLAY=y
2 changes: 1 addition & 1 deletion configs/odroid-xu4_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ CONFIG_MD5=y
# CONFIG_LZ4 is not set
CONFIG_ERRNO_STR=y
CONFIG_OF_LIBFDT=y
# CONFIG_OF_LIBFDT_OVERLAY is not set
CONFIG_OF_LIBFDT_OVERLAY=y
# CONFIG_SPL_OF_LIBFDT is not set
# CONFIG_FDT_FIXUP_PARTITIONS is not set

Expand Down
1 change: 1 addition & 0 deletions include/configs/odroid_xu3.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,5 @@
"dfu_alt_system="CONFIG_DFU_ALT_SYSTEM \
"dfu_alt_info=Autoset by THOR/DFU command run.\0"

#define CONFIG_CMD_INI
#endif /* __CONFIG_H */
2 changes: 2 additions & 0 deletions include/configs/odroid_xu4.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,6 @@
"hdmi_phy_res=720p60hz edid=0, hpd=1 disable_vu7=false " \
"touch_invert_x=false touch_invert_y=false"


#define CONFIG_CMD_INI
#endif /* __CONFIG_H */
3 changes: 1 addition & 2 deletions scripts/check-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,13 @@ cat `find ${srctree} -name "Kconfig*"` |sed -n \
-e 's/^menuconfig \([A-Za-z0-9_]*\).*$/CONFIG_\1/p' |sort |uniq > ${ok}
comm -23 ${suspects} ${ok} >${new_adhoc}
if [ -s ${new_adhoc} ]; then
echo >&2 "Error: You must add new CONFIG options using Kconfig"
echo >&2 "Warning: You must add new CONFIG options using Kconfig"
echo >&2 "The following new ad-hoc CONFIG options were detected:"
cat >&2 ${new_adhoc}
echo >&2
echo >&2 "Please add these via Kconfig instead. Find a suitable Kconfig"
echo >&2 "file and add a 'config' or 'menuconfig' option."
# Don't delete the temporary files in case they are useful
exit 1
else
rm ${suspects} ${ok} ${new_adhoc}
fi
Binary file modified sd_fuse/u-boot.bin.hardkernel
Binary file not shown.