ADD: [nbhw16] added password check to uboot
SVN commit 21494@trunk
This commit is contained in:
parent
db569ab76c
commit
fc4ddf1cc3
|
|
@ -326,6 +326,35 @@ int board_init(void)
|
|||
#ifdef CONFIG_BOARD_LATE_INIT
|
||||
int board_late_init(void)
|
||||
{
|
||||
#if !defined(CONFIG_SPL_BUILD)
|
||||
int hw_ver, hw_rev;
|
||||
int boot_partition;
|
||||
|
||||
if (read_eeprom() < 0)
|
||||
puts("Could not get board ID.\n");
|
||||
|
||||
/* add active root partition to environment */
|
||||
boot_partition = bd_get_boot_partition();
|
||||
if (boot_partition > 1) {
|
||||
boot_partition = 0;
|
||||
}
|
||||
|
||||
/* mmcblk0p1 => root0, mmcblk0p2 => root1 so +1 */
|
||||
setenv_ulong("root_part", boot_partition + 1);
|
||||
|
||||
/* add hardware versions to environment */
|
||||
if (bd_get_hw_version(&hw_ver, &hw_rev)==0) {
|
||||
char hw_versions[128];
|
||||
char new_env[256];
|
||||
snprintf(hw_versions, sizeof(hw_versions), "CP=%d.%d", hw_ver, hw_rev);
|
||||
snprintf(new_env, sizeof(new_env), "setenv bootargs $bootargs %s", hw_versions);
|
||||
setenv("add_version_bootargs", new_env);
|
||||
}
|
||||
|
||||
check_reset_button();
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
|
||||
int rc;
|
||||
char *name = NULL;
|
||||
|
|
@ -411,48 +440,22 @@ static void set_mac_address(int index, uchar mac[6])
|
|||
*/
|
||||
int board_eth_init(bd_t *bis)
|
||||
{
|
||||
int hw_ver, hw_rev;
|
||||
int rv, n = 0;
|
||||
uint8_t mac_addr0[6] = {02,00,00,00,00,01};
|
||||
uint8_t mac_addr1[6] = {02,00,00,00,00,02};
|
||||
__maybe_unused struct ti_am_eeprom *header;
|
||||
int boot_partition;
|
||||
|
||||
|
||||
#if !defined(CONFIG_SPL_BUILD)
|
||||
#ifdef CONFIG_DRIVER_TI_CPSW
|
||||
|
||||
cpsw_data.mdio_div = 0x3E;
|
||||
|
||||
if (read_eeprom() < 0)
|
||||
puts("Could not get board ID.\n");
|
||||
|
||||
bd_get_mac_address(0, mac_addr0, sizeof(mac_addr0));
|
||||
set_mac_address(0, mac_addr0);
|
||||
|
||||
bd_get_mac_address(1, mac_addr1, sizeof(mac_addr1));
|
||||
set_mac_address(1, mac_addr1);
|
||||
|
||||
/* add active root partition to environment */
|
||||
boot_partition = bd_get_boot_partition();
|
||||
if (boot_partition > 1) {
|
||||
boot_partition = 0;
|
||||
}
|
||||
|
||||
/* mmcblk0p1 => root0, mmcblk0p2 => root1 so +1 */
|
||||
setenv_ulong("root_part", boot_partition + 1);
|
||||
|
||||
/* add hardware versions to environment */
|
||||
if (bd_get_hw_version(&hw_ver, &hw_rev)==0) {
|
||||
char hw_versions[128];
|
||||
char new_env[256];
|
||||
snprintf(hw_versions, sizeof(hw_versions), "CP=%d.%d", hw_ver, hw_rev);
|
||||
snprintf(new_env, sizeof(new_env), "setenv bootargs $bootargs %s", hw_versions);
|
||||
setenv("add_version_bootargs", new_env);
|
||||
}
|
||||
|
||||
check_reset_button();
|
||||
|
||||
writel(RMII_MODE_ENABLE | RMII_CHIPCKL_ENABLE, &cdev->miisel);
|
||||
cpsw_slaves[0].phy_if = PHY_INTERFACE_MODE_RMII;
|
||||
cpsw_slaves[1].phy_if = PHY_INTERFACE_MODE_RMII;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@
|
|||
#include <console.h>
|
||||
#include <version.h>
|
||||
|
||||
#include <fs.h>
|
||||
#include <u-boot/md5.h>
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
/*
|
||||
|
|
@ -20,6 +23,83 @@ DECLARE_GLOBAL_DATA_PTR;
|
|||
*/
|
||||
__weak void show_boot_progress(int val) {}
|
||||
|
||||
|
||||
#ifdef CONFIG_NM_LOGIN
|
||||
|
||||
/****************************************************************************
|
||||
* check if ubootpwd exists in data partition and perform a login,
|
||||
* otherwise continue booting
|
||||
*/
|
||||
int login (void)
|
||||
{
|
||||
#define PASS_LEN 256
|
||||
char stored[16];
|
||||
char buf[PASS_LEN], entered[16];
|
||||
int res, i, tries;
|
||||
loff_t actread;
|
||||
|
||||
puts("\nautoboot has been stopped, press 'e' to enter: ");
|
||||
|
||||
for (i=0; i<=4096; i++) {
|
||||
buf[0] = getc();
|
||||
if (buf[0] == 'e' || buf[0] == '\n') {
|
||||
puts("e");
|
||||
break;
|
||||
}
|
||||
if (i == 4096) return 0;
|
||||
}
|
||||
puts("\n");
|
||||
|
||||
memset(stored, 0x0, sizeof(stored));
|
||||
|
||||
if (fs_set_blk_dev("mmc", "1:3", FS_TYPE_EXT) != 0) {
|
||||
puts("Error, can not set blk devicet");
|
||||
return 1;
|
||||
}
|
||||
|
||||
res = fs_read("/root/boot/bootpass", (ulong)stored, 0, sizeof(stored), &actread);
|
||||
if ((res!=0) || (actread != sizeof(stored))) {
|
||||
/* no file or md5 hash found */
|
||||
puts("Login succeeded\n\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (tries = 1; ; tries++) {
|
||||
puts("\nEnter password: ");
|
||||
|
||||
buf[0] = 0;
|
||||
for (i=0; i<PASS_LEN; i++) {
|
||||
buf[i] = getc();
|
||||
if (buf[i] == '\r' || buf[i] == '\n') {
|
||||
buf[i] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
buf[PASS_LEN-1] = 0;
|
||||
|
||||
if (strlen(buf) > 0) {
|
||||
puts("\n");
|
||||
md5((unsigned char*) buf, strlen(buf), (unsigned char *)entered);
|
||||
if (memcmp(stored, entered, 16) == 0) {
|
||||
break;
|
||||
} else {
|
||||
puts("Login incorrect\n");
|
||||
if (tries == 3) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* succeeded */
|
||||
puts("Login succeeded\n\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif /* CONIFG_NM_LOGIN */
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
static void run_preboot_environment_command(void)
|
||||
{
|
||||
#ifdef CONFIG_PREBOOT
|
||||
|
|
@ -65,6 +145,13 @@ void main_loop(void)
|
|||
|
||||
autoboot_command(s);
|
||||
|
||||
#ifdef CONFIG_NM_LOGIN
|
||||
if (!login()) {
|
||||
puts ("Login failed, resetting...\n");
|
||||
do_reset (NULL, 0, 0, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
cli_loop();
|
||||
panic("No CLI available");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,9 +7,8 @@ CONFIG_FIT=y
|
|||
CONFIG_SYS_EXTRA_OPTIONS="EMMC_BOOT"
|
||||
CONFIG_HUSH_PARSER=y
|
||||
CONFIG_AUTOBOOT_KEYED=y
|
||||
CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n"
|
||||
CONFIG_AUTOBOOT_DELAY_STR="d"
|
||||
CONFIG_AUTOBOOT_STOP_STR=" "
|
||||
CONFIG_AUTOBOOT_PROMPT="Press s to abort autoboot in %d seconds\n"
|
||||
CONFIG_AUTOBOOT_STOP_STR="s"
|
||||
CONFIG_CMD_BOOTZ=y
|
||||
# CONFIG_CMD_IMLS is not set
|
||||
CONFIG_CMD_ASKENV=y
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@
|
|||
# define CONFIG_LZO
|
||||
#endif
|
||||
|
||||
#define CONFIG_NM_LOGIN
|
||||
|
||||
#define CONFIG_SYS_BOOTM_LEN (16 << 20)
|
||||
|
||||
#define MACH_TYPE_TIAM335EVM 3589 /* Until the next sync */
|
||||
|
|
|
|||
Loading…
Reference in New Issue