summaryrefslogtreecommitdiffstats
path: root/board/ait/cam_enc_4xx/cam_enc_4xx.c
diff options
context:
space:
mode:
Diffstat (limited to 'board/ait/cam_enc_4xx/cam_enc_4xx.c')
-rw-r--r--board/ait/cam_enc_4xx/cam_enc_4xx.c103
1 files changed, 63 insertions, 40 deletions
diff --git a/board/ait/cam_enc_4xx/cam_enc_4xx.c b/board/ait/cam_enc_4xx/cam_enc_4xx.c
index 5586576017..32b28f9270 100644
--- a/board/ait/cam_enc_4xx/cam_enc_4xx.c
+++ b/board/ait/cam_enc_4xx/cam_enc_4xx.c
@@ -21,6 +21,7 @@
#include <common.h>
#include <errno.h>
+#include <hush.h>
#include <linux/mtd/nand.h>
#include <nand.h>
#include <miiphy.h>
@@ -503,7 +504,7 @@ struct fit_images_info {
size_t size;
};
-static struct fit_images_info images[10];
+static struct fit_images_info imgs[10];
struct menu_display {
char title[50];
@@ -554,7 +555,7 @@ static char *menu_handle(struct menu_display *display)
{
struct menu *m;
int i;
- char *choice = NULL;
+ void *choice = NULL;
char key[2];
int ret;
char *s;
@@ -606,7 +607,7 @@ static char *menu_handle(struct menu_display *display)
sprintf(key, "%d", 1);
menu_default_set(m, key);
- if (menu_get_choice(m, (void **)&choice) != 1)
+ if (menu_get_choice(m, &choice) != 1)
debug("Problem picking a choice!\n");
menu_destroy(m);
@@ -653,7 +654,7 @@ static int ait_writeublheader(void)
sprintf(s, "%lx", i);
ret = setenv("header_addr", s);
if (ret == 0)
- ret = run_command2("run img_writeheader", 0);
+ ret = run_command("run img_writeheader", 0);
if (ret != 0)
break;
}
@@ -688,16 +689,16 @@ static int ait_menu_install_images(void)
* img_writeramdisk: write ramdisk to ubi volume
*/
- while (images[count].type != IH_TYPE_INVALID) {
+ while (imgs[count].type != IH_TYPE_INVALID) {
printf("Installing %s\n",
- genimg_get_type_name(images[count].type));
- sprintf(s, "%p", images[count].data);
+ genimg_get_type_name(imgs[count].type));
+ sprintf(s, "%p", imgs[count].data);
setenv("img_addr_r", s);
- sprintf(s, "%lx", (unsigned long)images[count].size);
+ sprintf(s, "%lx", (unsigned long)imgs[count].size);
setenv("filesize", s);
- switch (images[count].subtype) {
+ switch (imgs[count].subtype) {
case FIT_SUBTYPE_DF_ENV_IMAGE:
- ret = run_command2("run img_writedfenv", 0);
+ ret = run_command("run img_writedfenv", 0);
break;
case FIT_SUBTYPE_RAMDISK_IMAGE:
t = getenv("img_volume");
@@ -713,16 +714,16 @@ static int ait_menu_install_images(void)
if (ret != 0)
break;
- ret = run_command2("run img_writeramdisk", 0);
+ ret = run_command("run img_writeramdisk", 0);
break;
case FIT_SUBTYPE_SPL_IMAGE:
- ret = run_command2("run img_writespl", 0);
+ ret = run_command("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);
+ ret = run_command("run img_writeuboot", 0);
break;
default:
/* not supported type */
@@ -731,8 +732,19 @@ static int ait_menu_install_images(void)
count++;
}
/* now save dvn_* and img_volume env vars to new values */
- if (ret == 0)
- ret = run_command2("run savenewvers", 0);
+ if (ret == 0) {
+ t = getenv("x_dvn_boot_vers");
+ if (t)
+ setenv("dvn_boot_vers", t);
+
+ t = getenv("x_dvn_app_vers");
+ if (t)
+ setenv("dvn_boot_vers", t);
+
+ setenv("x_dvn_boot_vers", NULL);
+ setenv("x_dvn_app_vers", NULL);
+ ret = run_command("run savenewvers", 0);
+ }
return ret;
}
@@ -749,6 +761,8 @@ static int ait_menu_evaluate_load(char *choice)
break;
case '2':
/* cancel, back to main */
+ setenv("x_dvn_boot_vers", NULL);
+ setenv("x_dvn_app_vers", NULL);
break;
}
@@ -865,7 +879,7 @@ static int ait_menu_check_image(void)
int found_uboot = -1;
int found_ramdisk = -1;
- memset(images, 0, sizeof(images));
+ memset(imgs, 0, sizeof(imgs));
s = getenv("fit_addr_r");
fit_addr = s ? (unsigned long)simple_strtol(s, NULL, 16) : \
CONFIG_BOARD_IMG_ADDR_R;
@@ -911,7 +925,7 @@ static int ait_menu_check_image(void)
fit_image_print(addr, noffset, "");
fit_image_get_type(addr, noffset,
- &images[count].type);
+ &imgs[count].type);
/* Mandatory properties */
ret = fit_get_desc(addr, noffset, &desc);
printf("Description: ");
@@ -925,33 +939,33 @@ static int ait_menu_check_image(void)
if (ret) {
printf("unavailable\n");
} else {
- images[count].subtype = ait_subtype_nr(subtype);
+ imgs[count].subtype = ait_subtype_nr(subtype);
printf("%s %d\n", subtype,
- images[count].subtype);
+ imgs[count].subtype);
}
- sprintf(images[count].desc, "%s", desc);
+ sprintf(imgs[count].desc, "%s", desc);
ret = fit_image_get_data(addr, noffset,
- &images[count].data,
- &images[count].size);
+ &imgs[count].data,
+ &imgs[count].size);
printf("Data Size: ");
if (ret)
printf("unavailable\n");
else
- genimg_print_size(images[count].size);
- printf("Data @ %p\n", images[count].data);
+ genimg_print_size(imgs[count].size);
+ printf("Data @ %p\n", imgs[count].data);
count++;
}
}
for (i = 0; i < count; i++) {
- if (images[i].subtype == FIT_SUBTYPE_UBOOT_IMAGE)
+ if (imgs[i].subtype == FIT_SUBTYPE_UBOOT_IMAGE)
found_uboot = i;
- if (images[i].type == IH_TYPE_RAMDISK) {
+ if (imgs[i].type == IH_TYPE_RAMDISK) {
found_ramdisk = i;
- images[i].subtype = FIT_SUBTYPE_RAMDISK_IMAGE;
+ imgs[i].subtype = FIT_SUBTYPE_RAMDISK_IMAGE;
}
}
@@ -959,31 +973,31 @@ static int ait_menu_check_image(void)
if (found_uboot >= 0) {
s = getenv("dvn_boot_vers");
if (s) {
- ret = strcmp(s, images[found_uboot].desc);
+ ret = strcmp(s, imgs[found_uboot].desc);
if (ret != 0) {
- setenv("dvn_boot_vers",
- images[found_uboot].desc);
+ setenv("x_dvn_boot_vers",
+ imgs[found_uboot].desc);
} else {
found_uboot = -1;
printf("no new uboot version\n");
}
} else {
- setenv("dvn_boot_vers", images[found_uboot].desc);
+ setenv("dvn_boot_vers", imgs[found_uboot].desc);
}
}
if (found_ramdisk >= 0) {
s = getenv("dvn_app_vers");
if (s) {
- ret = strcmp(s, images[found_ramdisk].desc);
+ ret = strcmp(s, imgs[found_ramdisk].desc);
if (ret != 0) {
- setenv("dvn_app_vers",
- images[found_ramdisk].desc);
+ setenv("x_dvn_app_vers",
+ imgs[found_ramdisk].desc);
} else {
found_ramdisk = -1;
printf("no new ramdisk version\n");
}
} else {
- setenv("dvn_app_vers", images[found_ramdisk].desc);
+ setenv("dvn_app_vers", imgs[found_ramdisk].desc);
}
}
if ((found_uboot == -1) && (found_ramdisk == -1))
@@ -1005,7 +1019,7 @@ static int ait_menu_evaluate_update(char *choice)
break;
case '2':
/* load image */
- ret = run_command2("run load_img", 0);
+ ret = run_command("run load_img", 0);
printf("ret: %d\n", ret);
if (ret)
return MENU_UPDATE;
@@ -1073,9 +1087,9 @@ int menu_show(int bootdelay)
{
int ret;
- run_command2("run saveparms", 0);
+ run_command("run saveparms", 0);
ret = ait_menu_show(&ait_main, bootdelay);
- run_command2("run restoreparms", 0);
+ run_command("run restoreparms", 0);
if (ret == MENU_EXIT_BOOTCMD)
return 0;
@@ -1085,8 +1099,17 @@ int menu_show(int bootdelay)
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"));
+ char *s1, *s2;
+
+ s1 = getenv("x_dvn_boot_vers");
+ if (!s1)
+ s1 = getenv("dvn_boot_vers");
+
+ s2 = getenv("x_dvn_app_vers");
+ if (!s2)
+ s2 = getenv("dvn_app_vers");
+
+ printf("State: dvn_boot_vers: %s dvn_app_vers: %s\n", s1, s2);
return;
}
#endif
OpenPOWER on IntegriCloud