summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeiko Schocher <hs@denx.de>2012-01-16 21:20:09 +0000
committerAlbert ARIBAUD <albert.u.boot@aribaud.net>2012-02-12 10:11:25 +0100
commit6be6db588d81aafd7a9e4c5282c9f8a0b93544db (patch)
tree7be27a2ab8e117f3a15489d9b5f59c4160d4432c
parentfc4fa6a16db3f5c5671b4f3d32359fa416542cd2 (diff)
downloadu-boot-imx-6be6db588d81aafd7a9e4c5282c9f8a0b93544db.zip
u-boot-imx-6be6db588d81aafd7a9e4c5282c9f8a0b93544db.tar.gz
u-boot-imx-6be6db588d81aafd7a9e4c5282c9f8a0b93544db.tar.bz2
arm, davinci: cam_enc_4xx board updates
- CONFIG_SYS_MMC_ENV_DEV, needed if environment on mmc - wait for 1 second timer in board_late_init() only, if timer is running. - add UBI/UBIFS support - add FIT images support - menu support - U-Boot max size now 0xa0000 - SPL now Block 0 page 0 - new MTD partitioning 0x00000000 SPL 0x00020000 UBL-Header 0x00040000 UBL-Header 0x00060000 UBL-Header 0x00080000 UBoot (0xa0000(U-Boot length) + 0x60000(3 spare blocks)) 0x00180000 ENV- Variablen (1) 0x001a0000 ENV- Variablen (2) 0x001c0000 ENV- Variablen (reserved for Bad Block) 0x001e0000 ENV- Variablen (reserved for Bad Block) 0x00200000 UBI-Device UBI Volumes: „default“: contain environment-default values „rootfs1“: UBIFS root-fs (1); contain linux kernel image „rootfs2“: UBIFS root-fs (2); contain linux kernel image „data-ro“: UBIFS data (read only) „data-rw“: UBIFS data (read/write) - new environment variables: - app_reset (this is only passed per cmdline to linux) - dvn_app_vers string from ramdisk description contained in the FIT image - dvn_boot_vers string from ubootimage description contained in the FIT image - saveparms, restoreparms, restoretmpparms, savetmpparms helper for saving network parameter. - ubiargs set ubi kernel cmdlinargs for booting with a ubifs rootfs - ubi_ubi boot with reading kernel image from ubifs, and use a ubifs as rootfs Signed-off-by: Heiko Schocher <hs@denx.de> Cc: Sandeep Paulraj <s-paulraj@ti.com> Cc: Tom Rini <tom.rini@gmail.com> Cc: Albert ARIBAUD <albert.u.boot@aribaud.net> Cc: Mike Frysinger <vapier@gentoo.org> Cc: Wolfgang Denk <wd@denx.de>
-rw-r--r--board/ait/cam_enc_4xx/cam_enc_4xx.c667
-rw-r--r--board/ait/cam_enc_4xx/ublimage.cfg3
-rw-r--r--include/configs/cam_enc_4xx.h131
3 files changed, 771 insertions, 30 deletions
diff --git a/board/ait/cam_enc_4xx/cam_enc_4xx.c b/board/ait/cam_enc_4xx/cam_enc_4xx.c
index f438c15..5586576 100644
--- a/board/ait/cam_enc_4xx/cam_enc_4xx.c
+++ b/board/ait/cam_enc_4xx/cam_enc_4xx.c
@@ -20,6 +20,7 @@
*/
#include <common.h>
+#include <errno.h>
#include <linux/mtd/nand.h>
#include <nand.h>
#include <miiphy.h>
@@ -46,6 +47,12 @@ static unsigned long get_timer_val(void)
return now;
}
+static int timer_running(void)
+{
+ return readl(&timer->tcr) &
+ (DV_TIMER_TCR_ENAMODE_MASK << DV_TIMER_TCR_ENAMODE34_SHIFT);
+}
+
static void stop_timer(void)
{
writel(0x0, &timer->tcr);
@@ -66,8 +73,43 @@ int board_init(void)
}
#ifdef CONFIG_DRIVER_TI_EMAC
+static int cam_enc_4xx_check_network(void)
+{
+ char *s;
+
+ s = getenv("ethaddr");
+ if (!s)
+ return -EINVAL;
+
+ if (!is_valid_ether_addr((const u8 *)s))
+ return -EINVAL;
+
+ s = getenv("ipaddr");
+ if (!s)
+ return -EINVAL;
+
+ s = getenv("netmask");
+ if (!s)
+ return -EINVAL;
+
+ s = getenv("serverip");
+ if (!s)
+ return -EINVAL;
+
+ s = getenv("gatewayip");
+ if (!s)
+ return -EINVAL;
+
+ return 0;
+}
int board_eth_init(bd_t *bis)
{
+ int ret;
+
+ ret = cam_enc_4xx_check_network();
+ if (ret)
+ return ret;
+
davinci_emac_initialize();
return 0;
@@ -254,8 +296,11 @@ static int nand_switch_hw_func(int mode)
nand = mtd->priv;
if (mode == 0) {
- printf("switching to uboot hw functions.\n");
- memcpy(&nand->ecc, &org_ecc, sizeof(struct nand_ecc_ctrl));
+ if (notsaved == 0) {
+ printf("switching to uboot hw functions.\n");
+ memcpy(&nand->ecc, &org_ecc,
+ sizeof(struct nand_ecc_ctrl));
+ }
} else {
/* RBL */
printf("switching to RBL hw functions.\n");
@@ -329,7 +374,8 @@ int board_late_init(void)
struct davinci_gpio *gpio = davinci_gpio_bank45;
/* 24MHz InputClock / 15 prediv -> 1.6 MHz timer running */
- while (get_timer_val() < 0x186a00)
+ while ((get_timer_val() < CONFIG_AIT_TIMER_TIMEOUT) &&
+ timer_running())
;
/* 1 sec reached -> stop timer, clear all LED */
@@ -429,3 +475,618 @@ void arch_memory_failure_handle(void)
;
}
#endif
+#if defined(CONFIG_MENU)
+#include "menu.h"
+
+#define MENU_EXIT -1
+#define MENU_EXIT_BOOTCMD -2
+#define MENU_STAY 0
+#define MENU_MAIN 1
+#define MENU_UPDATE 2
+#define MENU_NETWORK 3
+#define MENU_LOAD 4
+
+static int menu_start;
+
+#define FIT_SUBTYPE_UNKNOWN 0
+#define FIT_SUBTYPE_UBL_HEADER 1
+#define FIT_SUBTYPE_SPL_IMAGE 2
+#define FIT_SUBTYPE_UBOOT_IMAGE 3
+#define FIT_SUBTYPE_DF_ENV_IMAGE 4
+#define FIT_SUBTYPE_RAMDISK_IMAGE 5
+
+struct fit_images_info {
+ u_int8_t type;
+ int subtype;
+ char desc[200];
+ const void *data;
+ size_t size;
+};
+
+static struct fit_images_info images[10];
+
+struct menu_display {
+ char title[50];
+ int timeout; /* in sec */
+ int id; /* MENU_* */
+ char **menulist;
+ int (*menu_evaluate)(char *choice);
+};
+
+char *menu_main[] = {
+ "(1) Boot",
+ "(2) Update Software",
+ "(3) Reset to default setting and boot",
+ "(4) Enter U-Boot console",
+ NULL
+};
+
+char *menu_update[] = {
+ "(1) Network settings",
+ "(2) load image",
+ "(3) back to main",
+ NULL
+};
+
+char *menu_load[] = {
+ "(1) install image",
+ "(2) cancel",
+ NULL
+};
+
+char *menu_network[] = {
+ "(1) ipaddr ",
+ "(2) netmask ",
+ "(3) serverip ",
+ "(4) gatewayip",
+ "(5) tftp image name",
+ "(6) back to update software",
+ NULL
+};
+
+static void ait_menu_print(void *data)
+{
+ printf("%s\n", (char *)data);
+ return;
+}
+
+static char *menu_handle(struct menu_display *display)
+{
+ struct menu *m;
+ int i;
+ char *choice = NULL;
+ char key[2];
+ int ret;
+ char *s;
+ char temp[6][200];
+
+ m = menu_create(display->title, display->timeout, 1, ait_menu_print);
+
+ for (i = 0; display->menulist[i]; i++) {
+ sprintf(key, "%d", i + 1);
+ if (display->id == MENU_NETWORK) {
+ switch (i) {
+ case 0:
+ s = getenv("ipaddr");
+ break;
+ case 1:
+ s = getenv("netmask");
+ break;
+ case 2:
+ s = getenv("serverip");
+ break;
+ case 3:
+ s = getenv("gatewayip");
+ break;
+ case 4:
+ s = getenv("img_file");
+ break;
+ default:
+ s = NULL;
+ break;
+ }
+ if (s) {
+ sprintf(temp[i], "%s: %s",
+ display->menulist[i], s);
+ ret = menu_item_add(m, key, temp[i]);
+ } else {
+ ret = menu_item_add(m, key,
+ display->menulist[i]);
+ }
+ } else {
+ ret = menu_item_add(m, key, display->menulist[i]);
+ }
+
+ if (ret != 1) {
+ printf("failed to add item!");
+ menu_destroy(m);
+ return NULL;
+ }
+ }
+ sprintf(key, "%d", 1);
+ menu_default_set(m, key);
+
+ if (menu_get_choice(m, (void **)&choice) != 1)
+ debug("Problem picking a choice!\n");
+
+ menu_destroy(m);
+
+ return choice;
+}
+
+static int ait_menu_show(struct menu_display *display, int bootdelay)
+{
+ int end = MENU_STAY;
+ char *choice;
+
+ if ((menu_start == 0) && (display->id == MENU_MAIN))
+ display->timeout = bootdelay;
+ else
+ display->timeout = 0;
+
+ while (end == MENU_STAY) {
+ choice = menu_handle(display);
+ if (choice)
+ end = display->menu_evaluate(choice);
+
+ if (end == display->id)
+ end = MENU_STAY;
+ if (display->id == MENU_MAIN) {
+ if (menu_start == 0)
+ end = MENU_EXIT_BOOTCMD;
+ else
+ display->timeout = 0;
+ }
+ }
+ return end;
+}
+
+static int ait_writeublheader(void)
+{
+ char s[20];
+ unsigned long i;
+ int ret;
+
+ for (i = CONFIG_SYS_NAND_BLOCK_SIZE;
+ i < CONFIG_SYS_NAND_U_BOOT_OFFS;
+ i += CONFIG_SYS_NAND_BLOCK_SIZE) {
+ sprintf(s, "%lx", i);
+ ret = setenv("header_addr", s);
+ if (ret == 0)
+ ret = run_command2("run img_writeheader", 0);
+ if (ret != 0)
+ break;
+ }
+ return ret;
+}
+
+static int ait_menu_install_images(void)
+{
+ int ret = 0;
+ int count = 0;
+ char s[100];
+ char *t;
+
+ /*
+ * possible image types:
+ * FIT_SUBTYPE_UNKNOWN
+ * FIT_SUBTYPE_UBL_HEADER
+ * FIT_SUBTYPE_SPL_IMAGE
+ * FIT_SUBTYPE_UBOOT_IMAGE
+ * FIT_SUBTYPE_DF_ENV_IMAGE
+ * FIT_SUBTYPE_RAMDISK_IMAGE
+ *
+ * use Envvariables:
+ * img_addr_r: image start addr
+ * header_addr: addr where to write to UBL header
+ * img_writeheader: write ubl header to nand
+ * img_writespl: write spl to nand
+ * img_writeuboot: write uboot to nand
+ * img_writedfenv: write default environment to ubi volume
+ * img_volume: which ubi volume should be updated with img_writeramdisk
+ * filesize: size of data for updating ubi volume
+ * img_writeramdisk: write ramdisk to ubi volume
+ */
+
+ while (images[count].type != IH_TYPE_INVALID) {
+ printf("Installing %s\n",
+ genimg_get_type_name(images[count].type));
+ sprintf(s, "%p", images[count].data);
+ setenv("img_addr_r", s);
+ sprintf(s, "%lx", (unsigned long)images[count].size);
+ setenv("filesize", s);
+ switch (images[count].subtype) {
+ case FIT_SUBTYPE_DF_ENV_IMAGE:
+ ret = run_command2("run img_writedfenv", 0);
+ break;
+ case FIT_SUBTYPE_RAMDISK_IMAGE:
+ t = getenv("img_volume");
+ if (!t) {
+ ret = setenv("img_volume", "rootfs1");
+ } else {
+ /* switch to other volume */
+ if (strncmp(t, "rootfs1", 7) == 0)
+ ret = setenv("img_volume", "rootfs2");
+ else
+ ret = setenv("img_volume", "rootfs1");
+ }
+ if (ret != 0)
+ break;
+
+ ret = run_command2("run img_writeramdisk", 0);
+ break;
+ case FIT_SUBTYPE_SPL_IMAGE:
+ ret = run_command2("run img_writespl", 0);
+ break;
+ case FIT_SUBTYPE_UBL_HEADER:
+ ret = ait_writeublheader();
+ break;
+ case FIT_SUBTYPE_UBOOT_IMAGE:
+ ret = run_command2("run img_writeuboot", 0);
+ break;
+ default:
+ /* not supported type */
+ break;
+ }
+ count++;
+ }
+ /* now save dvn_* and img_volume env vars to new values */
+ if (ret == 0)
+ ret = run_command2("run savenewvers", 0);
+
+ return ret;
+}
+
+static int ait_menu_evaluate_load(char *choice)
+{
+ if (!choice)
+ return -1;
+
+ switch (choice[1]) {
+ case '1':
+ /* install image */
+ ait_menu_install_images();
+ break;
+ case '2':
+ /* cancel, back to main */
+ break;
+ }
+
+ return MENU_MAIN;
+}
+
+struct menu_display ait_load = {
+ .title = "AIT load image",
+ .timeout = 0,
+ .id = MENU_LOAD,
+ .menulist = menu_load,
+ .menu_evaluate = ait_menu_evaluate_load,
+};
+
+static void ait_menu_read_env(char *name)
+{
+ char output[CONFIG_SYS_CBSIZE];
+ char cbuf[CONFIG_SYS_CBSIZE];
+ int readret;
+ int ret;
+
+ sprintf(output, "%s old: %s value: ", name, getenv(name));
+ memset(cbuf, 0, CONFIG_SYS_CBSIZE);
+ readret = readline_into_buffer(output, cbuf, 0);
+
+ if (readret >= 0) {
+ ret = setenv(name, cbuf);
+ if (ret) {
+ printf("Error setting %s\n", name);
+ return;
+ }
+ }
+ return;
+}
+
+static int ait_menu_evaluate_network(char *choice)
+{
+ if (!choice)
+ return MENU_MAIN;
+
+ switch (choice[1]) {
+ case '1':
+ ait_menu_read_env("ipaddr");
+ break;
+ case '2':
+ ait_menu_read_env("netmask");
+ break;
+ case '3':
+ ait_menu_read_env("serverip");
+ break;
+ case '4':
+ ait_menu_read_env("gatewayip");
+ break;
+ case '5':
+ ait_menu_read_env("img_file");
+ break;
+ case '6':
+ return MENU_UPDATE;
+ break;
+ }
+
+ return MENU_STAY;
+}
+
+struct menu_display ait_network = {
+ .title = "AIT network settings",
+ .timeout = 0,
+ .id = MENU_NETWORK,
+ .menulist = menu_network,
+ .menu_evaluate = ait_menu_evaluate_network,
+};
+
+static int fit_get_subtype(const void *fit, int noffset, char **subtype)
+{
+ int len;
+
+ *subtype = (char *)fdt_getprop(fit, noffset, "subtype", &len);
+ if (*subtype == NULL)
+ return -1;
+
+ return 0;
+}
+
+static int ait_subtype_nr(char *subtype)
+{
+ int ret = FIT_SUBTYPE_UNKNOWN;
+
+ if (!strncmp("ublheader", subtype, strlen("ublheader")))
+ return FIT_SUBTYPE_UBL_HEADER;
+ if (!strncmp("splimage", subtype, strlen("splimage")))
+ return FIT_SUBTYPE_SPL_IMAGE;
+ if (!strncmp("ubootimage", subtype, strlen("ubootimage")))
+ return FIT_SUBTYPE_UBOOT_IMAGE;
+ if (!strncmp("dfenvimage", subtype, strlen("dfenvimage")))
+ return FIT_SUBTYPE_DF_ENV_IMAGE;
+
+ return ret;
+}
+
+static int ait_menu_check_image(void)
+{
+ char *s;
+ unsigned long fit_addr;
+ void *addr;
+ int format;
+ char *desc;
+ char *subtype;
+ int images_noffset;
+ int noffset;
+ int ndepth;
+ int count = 0;
+ int ret;
+ int i;
+ int found_uboot = -1;
+ int found_ramdisk = -1;
+
+ memset(images, 0, sizeof(images));
+ s = getenv("fit_addr_r");
+ fit_addr = s ? (unsigned long)simple_strtol(s, NULL, 16) : \
+ CONFIG_BOARD_IMG_ADDR_R;
+
+ addr = (void *)fit_addr;
+ /* check if it is a FIT image */
+ format = genimg_get_format(addr);
+ if (format != IMAGE_FORMAT_FIT)
+ return -EINVAL;
+
+ if (!fit_check_format(addr))
+ return -EINVAL;
+
+ /* print the FIT description */
+ ret = fit_get_desc(addr, 0, &desc);
+ printf("FIT description: ");
+ if (ret)
+ printf("unavailable\n");
+ else
+ printf("%s\n", desc);
+
+ /* find images */
+ images_noffset = fdt_path_offset(addr, FIT_IMAGES_PATH);
+ if (images_noffset < 0) {
+ printf("Can't find images parent node '%s' (%s)\n",
+ FIT_IMAGES_PATH, fdt_strerror(images_noffset));
+ return -EINVAL;
+ }
+
+ /* Process its subnodes, print out component images details */
+ for (ndepth = 0, count = 0,
+ noffset = fdt_next_node(addr, images_noffset, &ndepth);
+ (noffset >= 0) && (ndepth > 0);
+ noffset = fdt_next_node(addr, noffset, &ndepth)) {
+ if (ndepth == 1) {
+ /*
+ * Direct child node of the images parent node,
+ * i.e. component image node.
+ */
+ printf("Image %u (%s)\n", count,
+ fit_get_name(addr, noffset, NULL));
+
+ fit_image_print(addr, noffset, "");
+
+ fit_image_get_type(addr, noffset,
+ &images[count].type);
+ /* Mandatory properties */
+ ret = fit_get_desc(addr, noffset, &desc);
+ printf("Description: ");
+ if (ret)
+ printf("unavailable\n");
+ else
+ printf("%s\n", desc);
+
+ ret = fit_get_subtype(addr, noffset, &subtype);
+ printf("Subtype: ");
+ if (ret) {
+ printf("unavailable\n");
+ } else {
+ images[count].subtype = ait_subtype_nr(subtype);
+ printf("%s %d\n", subtype,
+ images[count].subtype);
+ }
+
+ sprintf(images[count].desc, "%s", desc);
+
+ ret = fit_image_get_data(addr, noffset,
+ &images[count].data,
+ &images[count].size);
+
+ printf("Data Size: ");
+ if (ret)
+ printf("unavailable\n");
+ else
+ genimg_print_size(images[count].size);
+ printf("Data @ %p\n", images[count].data);
+ count++;
+ }
+ }
+
+ for (i = 0; i < count; i++) {
+ if (images[i].subtype == FIT_SUBTYPE_UBOOT_IMAGE)
+ found_uboot = i;
+ if (images[i].type == IH_TYPE_RAMDISK) {
+ found_ramdisk = i;
+ images[i].subtype = FIT_SUBTYPE_RAMDISK_IMAGE;
+ }
+ }
+
+ /* dvn_* env var update, if the FIT descriptors are different */
+ if (found_uboot >= 0) {
+ s = getenv("dvn_boot_vers");
+ if (s) {
+ ret = strcmp(s, images[found_uboot].desc);
+ if (ret != 0) {
+ setenv("dvn_boot_vers",
+ images[found_uboot].desc);
+ } else {
+ found_uboot = -1;
+ printf("no new uboot version\n");
+ }
+ } else {
+ setenv("dvn_boot_vers", images[found_uboot].desc);
+ }
+ }
+ if (found_ramdisk >= 0) {
+ s = getenv("dvn_app_vers");
+ if (s) {
+ ret = strcmp(s, images[found_ramdisk].desc);
+ if (ret != 0) {
+ setenv("dvn_app_vers",
+ images[found_ramdisk].desc);
+ } else {
+ found_ramdisk = -1;
+ printf("no new ramdisk version\n");
+ }
+ } else {
+ setenv("dvn_app_vers", images[found_ramdisk].desc);
+ }
+ }
+ if ((found_uboot == -1) && (found_ramdisk == -1))
+ return -EINVAL;
+
+ return 0;
+}
+
+static int ait_menu_evaluate_update(char *choice)
+{
+ int ret;
+
+ if (!choice)
+ return MENU_MAIN;
+
+ switch (choice[1]) {
+ case '1':
+ return ait_menu_show(&ait_network, 0);
+ break;
+ case '2':
+ /* load image */
+ ret = run_command2("run load_img", 0);
+ printf("ret: %d\n", ret);
+ if (ret)
+ return MENU_UPDATE;
+
+ ret = ait_menu_check_image();
+ if (ret)
+ return MENU_UPDATE;
+
+ return ait_menu_show(&ait_load, 0);
+ break;
+ case '3':
+ return MENU_MAIN;
+ break;
+
+ }
+
+ return MENU_MAIN;
+}
+
+struct menu_display ait_update = {
+ .title = "AIT Update Software",
+ .timeout = 0,
+ .id = MENU_UPDATE,
+ .menulist = menu_update,
+ .menu_evaluate = ait_menu_evaluate_update,
+};
+
+static int ait_menu_evaluate_main(char *choice)
+{
+ if (!choice)
+ return MENU_STAY;
+
+ menu_start = 1;
+ switch (choice[1]) {
+ case '1':
+ /* run bootcmd */
+ return MENU_EXIT_BOOTCMD;
+ break;
+ case '2':
+ return ait_menu_show(&ait_update, 0);
+ break;
+ case '3':
+ /* reset to default settings */
+ setenv("app_reset", "yes");
+ return MENU_EXIT_BOOTCMD;
+ break;
+ case '4':
+ /* u-boot shell */
+ return MENU_EXIT;
+ break;
+ }
+
+ return MENU_EXIT;
+}
+
+struct menu_display ait_main = {
+ .title = "AIT Main",
+ .timeout = CONFIG_BOOTDELAY,
+ .id = MENU_MAIN,
+ .menulist = menu_main,
+ .menu_evaluate = ait_menu_evaluate_main,
+};
+
+int menu_show(int bootdelay)
+{
+ int ret;
+
+ run_command2("run saveparms", 0);
+ ret = ait_menu_show(&ait_main, bootdelay);
+ run_command2("run restoreparms", 0);
+
+ if (ret == MENU_EXIT_BOOTCMD)
+ return 0;
+
+ return MENU_EXIT;
+}
+
+void menu_display_statusline(struct menu *m)
+{
+ printf("State: dvn_boot_vers: %s dvn_app_vers: %s\n",
+ getenv("dvn_boot_vers"), getenv("dvn_app_vers"));
+ return;
+}
+#endif
diff --git a/board/ait/cam_enc_4xx/ublimage.cfg b/board/ait/cam_enc_4xx/ublimage.cfg
index 95182ca..deef757 100644
--- a/board/ait/cam_enc_4xx/ublimage.cfg
+++ b/board/ait/cam_enc_4xx/ublimage.cfg
@@ -38,8 +38,7 @@ ENTRY 0x00000020
PAGES 6
# Block number where user bootloader is present
-# RBL starts always with block 1
-START_BLOCK 5
+START_BLOCK 0
# Page number where user bootloader is present
# Page 0 is always UBL header
diff --git a/include/configs/cam_enc_4xx.h b/include/configs/cam_enc_4xx.h
index 5d9672f..bd94cf3 100644
--- a/include/configs/cam_enc_4xx.h
+++ b/include/configs/cam_enc_4xx.h
@@ -135,7 +135,9 @@
#define CONFIG_MTD_DEVICE
#define CONFIG_CMD_NAND
#define CONFIG_CMD_UBI
+#define CONFIG_CMD_UBIFS
#define CONFIG_RBTREE
+#define CONFIG_LZO
#endif
#define CONFIG_CRC32_VERIFY
@@ -153,15 +155,24 @@
#define CONFIG_SYS_PROMPT_HUSH_PS2 "> "
#define CONFIG_SYS_LONGHELP
+#define CONFIG_MENU
+#define CONFIG_MENU_SHOW
+#define CONFIG_FIT
+#define CONFIG_CMD_PXE
+#define CONFIG_BOARD_IMG_ADDR_R 0x80000000
+
#ifdef CONFIG_NAND_DAVINCI
-#define CONFIG_ENV_SIZE (256 << 10) /* 256 KiB */
+#define CONFIG_ENV_SIZE (16 << 10)
#define CONFIG_ENV_IS_IN_NAND
-#define CONFIG_ENV_OFFSET 0x0
+#define CONFIG_ENV_OFFSET 0x180000
+#define CONFIG_ENV_OFFSET_REDUND 0x1c0000
+#define CONFIG_ENV_RANGE 0x020000
#undef CONFIG_ENV_IS_IN_FLASH
#endif
#if defined(CONFIG_MMC) && !defined(CONFIG_ENV_IS_IN_NAND)
#define CONFIG_CMD_ENV
+#define CONFIG_SYS_MMC_ENV_DEV 0
#define CONFIG_ENV_SIZE (16 << 10) /* 16 KiB */
#define CONFIG_ENV_OFFSET (51 << 9) /* Sector 51 */
#define CONFIG_ENV_IS_IN_MMC
@@ -169,6 +180,11 @@
#endif
#define CONFIG_BOOTDELAY 3
+/*
+ * 24MHz InputClock / 15 prediv -> 1.6 MHz timer running
+ * Timeout 1 second.
+ */
+#define CONFIG_AIT_TIMER_TIMEOUT 0x186a00
#define CONFIG_CMDLINE_EDITING
#define CONFIG_VERSION_VARIABLE
@@ -187,20 +203,17 @@
#define CONFIG_SYS_LOAD_ADDR 0x80700000 /* kernel address */
#define MTDIDS_DEFAULT "nand0=davinci_nand.0"
-
-#ifdef CONFIG_SYS_NAND_LARGEPAGE
-/* Use same layout for 128K/256K blocks; allow some bad blocks */
-#define PART_BOOT "2m(bootloader)ro,"
-#endif
-
-#define PART_KERNEL "4m(kernel)," /* kernel + initramfs */
-#define PART_REST "-(filesystem)"
-
-#define MTDPARTS_DEFAULT \
- "mtdparts=davinci_nand.0:" PART_BOOT PART_KERNEL PART_REST
-
-#define CONFIG_SYS_NAND_PAGE_SIZE (0x800)
-#define CONFIG_SYS_NAND_BLOCK_SIZE (0x20000)
+#define MTDPARTS_DEFAULT \
+ "mtdparts=" \
+ "davinci_nand.0:" \
+ "128k(spl)," \
+ "384k(UBLheader)," \
+ "1m(u-boot)," \
+ "512k(env)," \
+ "-(ubi)"
+
+#define CONFIG_SYS_NAND_PAGE_SIZE 0x800
+#define CONFIG_SYS_NAND_BLOCK_SIZE 0x20000
/* Defines for SPL */
#define CONFIG_SPL
@@ -241,7 +254,6 @@
* so we can define, how many UBL Headers
* we can write before the real spl code
*/
-#define CONFIG_SYS_NROF_UBL_HEADER 5
#define CONFIG_SYS_NROF_PAGES_NAND_SPL 6
#define CONFIG_SYS_NAND_U_BOOT_DST 0x81080000 /* u-boot TEXT_BASE */
@@ -258,8 +270,8 @@
#define CONFIG_SYS_INIT_SP_ADDR CONFIG_SPL_STACK
-#define CONFIG_SYS_NAND_U_BOOT_OFFS 0xc0000
-#define CONFIG_SYS_NAND_U_BOOT_SIZE 0x60000
+#define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000
+#define CONFIG_SYS_NAND_U_BOOT_SIZE 0xa0000
/*
* U-Boot is a 3rd stage loader and if booting with spl, cpu setup is
@@ -411,14 +423,14 @@
#define CONFIG_EXTRA_ENV_SETTINGS \
"u_boot_addr_r=" xstr(DVN4XX_UBOOT_ADDR_R_RAM) "\0" \
"u-boot=" xstr(CONFIG_HOSTNAME) "/u-boot.ubl\0" \
- "load=tftp ${u_boot_addr_r} ${uboot}\0" \
+ "load=tftp ${u_boot_addr_r} ${u-boot}\0" \
"pagesz=" xstr(CONFIG_SYS_NAND_PAGE_SIZE) "\0" \
- "writeheader=nandrbl rbl;nand erase 80000 ${pagesz};" \
- "nand write ${u_boot_addr_r} 80000 ${pagesz};" \
+ "writeheader=nandrbl rbl;nand erase 20000 ${pagesz};" \
+ "nand write ${u_boot_addr_r} 20000 ${pagesz};" \
"nandrbl uboot\0" \
- "writenand_spl=nandrbl rbl;nand erase a0000 3000;" \
+ "writenand_spl=nandrbl rbl;nand erase 0 3000;" \
"nand write " xstr(DVN4XX_UBOOT_ADDR_R_NAND_SPL) \
- " a0000 3000;nandrbl uboot\0" \
+ " 0 3000;nandrbl uboot\0" \
"writeuboot=nandrbl uboot;" \
"nand erase " xstr(CONFIG_SYS_NAND_U_BOOT_OFFS) " " \
xstr(CONFIG_SYS_NAND_U_BOOT_SIZE) \
@@ -426,8 +438,77 @@
" " xstr(CONFIG_SYS_NAND_U_BOOT_OFFS) " " \
xstr(CONFIG_SYS_NAND_U_BOOT_SIZE) "\0" \
"update=run load writenand_spl writeuboot\0" \
- "bootcmd=run bootcmd\0" \
+ "bootcmd=run net_nfs\0" \
+ "rootpath=/opt/eldk-arm/arm\0" \
+ "mtdids=" MTDIDS_DEFAULT "\0" \
+ "mtdparts=" MTDPARTS_DEFAULT "\0" \
+ "netdev=eth0\0" \
+ "addmtd=setenv bootargs ${bootargs} ${mtdparts}\0" \
+ "addmisc=setenv bootargs ${bootargs} app_reset=${app_reset}\0" \
+ "addcon=setenv bootargs ${bootargs} console=ttyS0," \
+ "${baudrate}n8\0" \
+ "addip=setenv bootargs ${bootargs} " \
+ "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}" \
+ ":${hostname}:${netdev}:off eth=${ethaddr} panic=1\0" \
"rootpath=/opt/eldk-arm/arm\0" \
+ "nfsargs=setenv bootargs root=/dev/nfs rw " \
+ "nfsroot=${serverip}:${rootpath}\0" \
+ "bootfile=" xstr(CONFIG_HOSTNAME) "/uImage \0" \
+ "kernel_addr_r=80600000\0" \
+ "load_kernel=tftp ${kernel_addr_r} ${bootfile}\0" \
+ "ubi_load_kernel=ubi part ubi 2048;ubifsmount ${img_volume};" \
+ "ubifsload ${kernel_addr_r} boot/uImage\0" \
+ "fit_addr_r=" xstr(CONFIG_BOARD_IMG_ADDR_R) "\0" \
+ "img_addr_r=" xstr(CONFIG_BOARD_IMG_ADDR_R) "\0" \
+ "img_file=" xstr(CONFIG_HOSTNAME) "/ait.itb\0" \
+ "header_addr=20000\0" \
+ "img_writeheader=nandrbl rbl;" \
+ "nand erase ${header_addr} ${pagesz};" \
+ "nand write ${img_addr_r} ${header_addr} ${pagesz};" \
+ "nandrbl uboot\0" \
+ "img_writespl=nandrbl rbl;nand erase 0 3000;" \
+ "nand write ${img_addr_r} 0 3000;nandrbl uboot\0" \
+ "img_writeuboot=nandrbl uboot;" \
+ "nand erase " xstr(CONFIG_SYS_NAND_U_BOOT_OFFS) " " \
+ xstr(CONFIG_SYS_NAND_U_BOOT_SIZE) \
+ ";nand write ${img_addr_r} " \
+ xstr(CONFIG_SYS_NAND_U_BOOT_OFFS) " " \
+ xstr(CONFIG_SYS_NAND_U_BOOT_SIZE) "\0" \
+ "img_writedfenv=ubi part ubi 2048;" \
+ "ubi write ${img_addr_r} default ${filesize}\0" \
+ "img_volume=rootfs1\0" \
+ "img_writeramdisk=ubi part ubi 2048;ubifsmount ${img_volume};" \
+ "ubi write ${img_addr_r} ${img_volume} ${filesize}\0" \
+ "load_img=tftp ${fit_addr_r} ${img_file}\0" \
+ "net_nfs=run load_kernel; " \
+ "run nfsargs addip addcon addmtd addmisc;" \
+ "bootm ${kernel_addr_r}\0" \
+ "ubi_ubi=run ubi_load_kernel; " \
+ "run ubiargs addip addcon addmtd addmisc;" \
+ "bootm ${kernel_addr_r}\0" \
+ "ubiargs=setenv bootargs ubi.mtd=4,2048" \
+ " root=ubi0:${img_volume} rw rootfstype=ubifs\0" \
+ "app_reset=no\0" \
+ "dvn_app_vers=void\0" \
+ "dvn_boot_vers=void\0" \
+ "savenewvers=run savetmpparms restoreparms; saveenv;" \
+ "run restoretmpparms\0" \
+ "savetmpparms=setenv y_ipaddr ${ipaddr};" \
+ "setenv y_netmask ${netmask};" \
+ "setenv y_serverip ${serverip};" \
+ "setenv y_gatewayip ${gatewayip}\0" \
+ "saveparms=setenv x_ipaddr ${ipaddr};" \
+ "setenv x_netmask ${netmask};" \
+ "setenv x_serverip ${serverip};" \
+ "setenv x_gatewayip ${gatewayip}\0" \
+ "restoreparms=setenv ipaddr ${x_ipaddr};" \
+ "setenv netmask ${x_netmask};" \
+ "setenv serverip ${x_serverip};" \
+ "setenv gatewayip ${x_gatewayip}\0" \
+ "restoretmpparms=setenv ipaddr ${y_ipaddr};" \
+ "setenv netmask ${y_netmask};" \
+ "setenv serverip ${y_serverip};" \
+ "setenv gatewayip ${y_gatewayip}\0" \
"\0"
/* USB Configuration */