From 186f9c130faa3e228b0db7f45de359748f78b1c3 Mon Sep 17 00:00:00 2001 From: Gerhard Sittig Date: Wed, 5 Jun 2013 14:51:05 +0200 Subject: ac14xx: fix a potential NULL deref in diagnostics getenv() immediately after setenv() may perfectly legally return NULL, so make sure to not deference an invalid pointer when creating diagnostic output Signed-off-by: Gerhard Sittig diff --git a/board/ifm/ac14xx/ac14xx.c b/board/ifm/ac14xx/ac14xx.c index 7442591..f200b45 100644 --- a/board/ifm/ac14xx/ac14xx.c +++ b/board/ifm/ac14xx/ac14xx.c @@ -209,6 +209,7 @@ static int read_eeprom(void) int mac_read_from_eeprom(void) { const u8 *mac; + const char *mac_txt; if (read_eeprom()) { printf("I2C EEPROM read failed.\n"); @@ -230,8 +231,11 @@ int mac_read_from_eeprom(void) if (mac && is_valid_ether_addr(mac)) { eth_setenv_enetaddr("ethaddr", mac); - printf("DIAG: %s() MAC value [%s]\n", - __func__, getenv("ethaddr")); + mac_txt = getenv("ethaddr"); + if (mac_txt) + printf("DIAG: MAC value [%s]\n", mac_txt); + else + printf("DIAG: failed to setup MAC env\n"); } return 0; -- cgit v0.10.2 From b5992e77effcf15cbd50753fd85033a3f9887825 Mon Sep 17 00:00:00 2001 From: Gerhard Sittig Date: Wed, 5 Jun 2013 14:51:06 +0200 Subject: ac14xx: cleanup comments in the board support fix typos, minor rephrasing, remove obsolete notes and TODO items Signed-off-by: Gerhard Sittig diff --git a/board/ifm/ac14xx/ac14xx.c b/board/ifm/ac14xx/ac14xx.c index f200b45..d45b7b2 100644 --- a/board/ifm/ac14xx/ac14xx.c +++ b/board/ifm/ac14xx/ac14xx.c @@ -37,7 +37,7 @@ static void gpio_configure(void) /* * out_be32(&gpioregs->gpdir, 0xC2293020); - * workaround for a hardware affect: configure direction in pieces, + * workaround for a hardware effect: configure direction in pieces, * setting all outputs at once drops the reset line too low and * makes us lose the MII connection (breaks ethernet for us) */ @@ -330,8 +330,7 @@ int misc_init_r(void) gpio_configure(); /* - * check the GPIO keyboard, - * enforced start of the recovery when + * enforce the start of the recovery system when * - the appropriate keys were pressed * - a previous installation was aborted or has failed * - "some" external software told us to @@ -339,13 +338,8 @@ int misc_init_r(void) want_recovery = 0; keys = gpio_querykbd(); printf("GPIO keyboard status [0x%08X]\n", keys); - /* XXX insist in the _exact_ combination? */ if ((keys & GPIOKEY_BITS_RECOVERY) == GPIOKEY_BITS_RECOVERY) { printf("GPIO keyboard requested RECOVERY\n"); - /* XXX TODO - * refine the logic to detect the first keypress, and - * wait to recheck IF it was the recovery combination? - */ want_recovery = 1; } s = getenv("install_in_progress"); diff --git a/include/configs/ac14xx.h b/include/configs/ac14xx.h index 7cb10fb..5dbcba2 100644 --- a/include/configs/ac14xx.h +++ b/include/configs/ac14xx.h @@ -72,7 +72,7 @@ #define CONFIG_SYS_MAX_RAM_SIZE 0x20000000 /* - * DDR Controller Configuration XXX TODO + * DDR Controller Configuration * * SYS_CFG: * [31:31] MDDRC Soft Reset: Diabled @@ -265,7 +265,6 @@ /* * CS related parameters - * TODO document these */ /* CS0 Flash */ #define CONFIG_SYS_CS0_CFG 0x00031110 @@ -506,7 +505,7 @@ #define CONFIG_BOOTDELAY 2 /* -1 disables auto-boot */ -/* XXX TODO need to specify the builtin environment */ +/* the builtin environment and standard greeting */ #define CONFIG_PREBOOT "echo;" \ "echo Type \\\"run flash_nfs\\\" to mount root filesystem over NFS;" \ "echo" -- cgit v0.10.2 From 527a1c71fbe264be9b37c3c2a9d992ea1ee91390 Mon Sep 17 00:00:00 2001 From: Gerhard Sittig Date: Wed, 5 Jun 2013 14:51:07 +0200 Subject: ac14xx: minor improvement in diagnostics - minor rewording of diagnostics output - make diagnostics optional and off by default Signed-off-by: Gerhard Sittig diff --git a/board/ifm/ac14xx/ac14xx.c b/board/ifm/ac14xx/ac14xx.c index d45b7b2..c8e88cc 100644 --- a/board/ifm/ac14xx/ac14xx.c +++ b/board/ifm/ac14xx/ac14xx.c @@ -23,6 +23,10 @@ #include #endif +static int eeprom_diag; +static int mac_diag; +static int gpio_diag; + DECLARE_GLOBAL_DATA_PTR; static void gpio_configure(void) @@ -126,8 +130,6 @@ static u32 gpio_querykbd(void) /* excerpt from the recovery's hw_info.h */ -static int eeprom_diag = 1; - struct __attribute__ ((__packed__)) eeprom_layout { char magic[3]; /** 'ifm' */ u8 len[2]; /** content length without magic/len fields */ @@ -231,11 +233,13 @@ int mac_read_from_eeprom(void) if (mac && is_valid_ether_addr(mac)) { eth_setenv_enetaddr("ethaddr", mac); - mac_txt = getenv("ethaddr"); - if (mac_txt) - printf("DIAG: MAC value [%s]\n", mac_txt); - else - printf("DIAG: failed to setup MAC env\n"); + if (mac_diag) { + mac_txt = getenv("ethaddr"); + if (mac_txt) + printf("DIAG: MAC value [%s]\n", mac_txt); + else + printf("DIAG: failed to setup MAC env\n"); + } } return 0; @@ -337,29 +341,31 @@ int misc_init_r(void) */ want_recovery = 0; keys = gpio_querykbd(); - printf("GPIO keyboard status [0x%08X]\n", keys); + if (gpio_diag) + printf("GPIO keyboard status [0x%02X]\n", keys); if ((keys & GPIOKEY_BITS_RECOVERY) == GPIOKEY_BITS_RECOVERY) { - printf("GPIO keyboard requested RECOVERY\n"); + printf("detected recovery request (keyboard)\n"); want_recovery = 1; } s = getenv("install_in_progress"); if ((s != NULL) && (*s != '\0')) { - printf("previous installation aborted, running RECOVERY\n"); + printf("previous installation has not completed\n"); want_recovery = 1; } s = getenv("install_failed"); if ((s != NULL) && (*s != '\0')) { - printf("previous installation FAILED, running RECOVERY\n"); + printf("previous installation has failed\n"); want_recovery = 1; } s = getenv("want_recovery"); if ((s != NULL) && (*s != '\0')) { - printf("running RECOVERY according to the request\n"); + printf("detected recovery request (environment)\n"); want_recovery = 1; } - - if (want_recovery) + if (want_recovery) { + printf("enforced start of the recovery system\n"); setenv("bootcmd", "run recovery"); + } /* * boot the recovery system without waiting; boot the -- cgit v0.10.2 From 14d4c5f39ed24df2fba6e60d1e1c89f66d419345 Mon Sep 17 00:00:00 2001 From: Gerhard Sittig Date: Wed, 5 Jun 2013 14:51:08 +0200 Subject: ac14xx: re-order the recovery condition checks re-order the conditions which make the recovery system startup: combine those conditions which were explicitly initiated (key press, software request) and those which post-process error conditions (installer issues) Signed-off-by: Gerhard Sittig diff --git a/board/ifm/ac14xx/ac14xx.c b/board/ifm/ac14xx/ac14xx.c index c8e88cc..dc2aff0 100644 --- a/board/ifm/ac14xx/ac14xx.c +++ b/board/ifm/ac14xx/ac14xx.c @@ -336,8 +336,8 @@ int misc_init_r(void) /* * enforce the start of the recovery system when * - the appropriate keys were pressed - * - a previous installation was aborted or has failed * - "some" external software told us to + * - a previous installation was aborted or has failed */ want_recovery = 0; keys = gpio_querykbd(); @@ -347,6 +347,11 @@ int misc_init_r(void) printf("detected recovery request (keyboard)\n"); want_recovery = 1; } + s = getenv("want_recovery"); + if ((s != NULL) && (*s != '\0')) { + printf("detected recovery request (environment)\n"); + want_recovery = 1; + } s = getenv("install_in_progress"); if ((s != NULL) && (*s != '\0')) { printf("previous installation has not completed\n"); @@ -357,11 +362,6 @@ int misc_init_r(void) printf("previous installation has failed\n"); want_recovery = 1; } - s = getenv("want_recovery"); - if ((s != NULL) && (*s != '\0')) { - printf("detected recovery request (environment)\n"); - want_recovery = 1; - } if (want_recovery) { printf("enforced start of the recovery system\n"); setenv("bootcmd", "run recovery"); -- cgit v0.10.2 From 81b0fb04101da1bf1e399bbf56c86d0ad3a2fe3d Mon Sep 17 00:00:00 2001 From: Gerhard Sittig Date: Wed, 5 Jun 2013 14:51:09 +0200 Subject: ac14xx: remove obsolete board config items - use the default baudrate table for serial communication - remove hostname/boofile/rootpath defines which were not referenced elsewhere Signed-off-by: Gerhard Sittig diff --git a/include/configs/ac14xx.h b/include/configs/ac14xx.h index 5dbcba2..e06e9ea 100644 --- a/include/configs/ac14xx.h +++ b/include/configs/ac14xx.h @@ -330,8 +330,6 @@ #endif #define CONFIG_BAUDRATE 115200 /* ... at 115200 bps */ -#define CONFIG_SYS_BAUDRATE_TABLE \ - {300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 115200} #define CONSOLE_FIFO_TX_SIZE FIFOC_PSC3_TX_SIZE #define CONSOLE_FIFO_TX_ADDR FIFOC_PSC3_TX_ADDR @@ -496,10 +494,6 @@ #define CONFIG_ENV_OVERWRITE #define CONFIG_TIMESTAMP -#define CONFIG_HOSTNAME ac14xx -#define CONFIG_BOOTFILE "ac14xx/uImage" -#define CONFIG_ROOTPATH "/opt/eldk/ppc_6xx" - /* default load addr for tftp and bootm */ #define CONFIG_LOADADDR 400000 -- cgit v0.10.2 From 4779025c1ed685247c338763f2e1e0a17d201c51 Mon Sep 17 00:00:00 2001 From: Gerhard Sittig Date: Wed, 5 Jun 2013 14:51:10 +0200 Subject: ac14xx: use the official product name everywhere remove remaining "k6" code names, switch to the official 'ac14xx' name Signed-off-by: Gerhard Sittig diff --git a/include/configs/ac14xx.h b/include/configs/ac14xx.h index e06e9ea..fcb56f4 100644 --- a/include/configs/ac14xx.h +++ b/include/configs/ac14xx.h @@ -507,13 +507,13 @@ #define CONFIG_EXTRA_ENV_SETTINGS_DEVEL \ "muster_nr=00\0" \ "fromram=run ramargs addip addtty; " \ - "tftp ${fdt_addr_r} k6m2/ac14xx.dtb-${muster_nr}; " \ - "tftp ${kernel_addr_r} k6m2/uImage-${muster_nr}; " \ - "tftp ${ramdisk_addr_r} k6m2/uFS-${muster_nr}; " \ + "tftp ${fdt_addr_r} ac14xx/ac14xx.dtb-${muster_nr}; " \ + "tftp ${kernel_addr_r} ac14xx/uImage-${muster_nr}; " \ + "tftp ${ramdisk_addr_r} ac14xx/uFS-${muster_nr}; " \ "bootm ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}\0" \ "fromnfs=run nfsargs addip addtty; " \ - "tftp ${fdt_addr_r} k6m2/ac14xx.dtb-${muster_nr}; " \ - "tftp ${kernel_addr_r} k6m2/uImage-${muster_nr}; " \ + "tftp ${fdt_addr_r} ac14xx/ac14xx.dtb-${muster_nr}; " \ + "tftp ${kernel_addr_r} ac14xx/uImage-${muster_nr}; " \ "bootm ${kernel_addr_r} - ${fdt_addr_r}\0" \ "fromflash=run nfsargs addip addtty; " \ "bootm fc020000 - fc000000\0" \ -- cgit v0.10.2 From 6c5001d5429bed52c25cbfc1ed6e244beced3ed5 Mon Sep 17 00:00:00 2001 From: Gerhard Sittig Date: Wed, 5 Jun 2013 14:51:11 +0200 Subject: ac14xx: rephrase network boot config for development - remove the builtin 'rootpath' spec (according to U-Boot project policy) and require user provided environments to contain these - rephrase the evaluation of the 'muster_nr' approach which allows to quickly switch among several network boot setups (make the setting transparent when empty, resulting in default DULG behaviour) - reduce the ARP timeout for faster network boot Signed-off-by: Gerhard Sittig diff --git a/include/configs/ac14xx.h b/include/configs/ac14xx.h index fcb56f4..381bcdd 100644 --- a/include/configs/ac14xx.h +++ b/include/configs/ac14xx.h @@ -505,15 +505,15 @@ "echo" #define CONFIG_EXTRA_ENV_SETTINGS_DEVEL \ - "muster_nr=00\0" \ + "muster_nr=-00\0" \ "fromram=run ramargs addip addtty; " \ - "tftp ${fdt_addr_r} ac14xx/ac14xx.dtb-${muster_nr}; " \ - "tftp ${kernel_addr_r} ac14xx/uImage-${muster_nr}; " \ - "tftp ${ramdisk_addr_r} ac14xx/uFS-${muster_nr}; " \ + "tftp ${fdt_addr_r} ac14xx/ac14xx.dtb${muster_nr}; " \ + "tftp ${kernel_addr_r} ac14xx/uImage${muster_nr}; " \ + "tftp ${ramdisk_addr_r} ac14xx/uFS${muster_nr}; " \ "bootm ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}\0" \ "fromnfs=run nfsargs addip addtty; " \ - "tftp ${fdt_addr_r} ac14xx/ac14xx.dtb-${muster_nr}; " \ - "tftp ${kernel_addr_r} ac14xx/uImage-${muster_nr}; " \ + "tftp ${fdt_addr_r} ac14xx/ac14xx.dtb${muster_nr}; " \ + "tftp ${kernel_addr_r} ac14xx/uImage${muster_nr}; " \ "bootm ${kernel_addr_r} - ${fdt_addr_r}\0" \ "fromflash=run nfsargs addip addtty; " \ "bootm fc020000 - fc000000\0" \ @@ -541,12 +541,11 @@ "u-boot=ac14xx/u-boot.bin\0" \ "bootfile=ac14xx/uImage\0" \ "fdtfile=ac14xx/ac14xx.dtb\0" \ - "rootpath=/opt/eldk/ppc_6xx\n" \ "netdev=eth0\0" \ "consdev=ttyPSC0\0" \ "hostname=ac14xx\0" \ "nfsargs=setenv bootargs root=/dev/nfs rw " \ - "nfsroot=${serverip}:${rootpath}-${muster_nr}\0" \ + "nfsroot=${serverip}:${rootpath}${muster_nr}\0" \ "ramargs=setenv bootargs root=/dev/ram rw\0" \ "addip=setenv bootargs ${bootargs} " \ "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}" \ @@ -576,6 +575,8 @@ #define CONFIG_BOOTCOMMAND "run production" +#define CONFIG_ARP_TIMEOUT 200UL + #define CONFIG_FIT 1 #define CONFIG_OF_LIBFDT 1 #define CONFIG_OF_BOARD_SETUP 1 -- cgit v0.10.2