[U-Boot] [PATCH 00/10] updates for common keymile code

This is mainly an cleanup for the keymile boards. The second step of simplifying the default and debug environment for all boards is the main change in this set.
Addititionaly some dead code, unsused defines were removed and the ivm code was reorganized to an own ivmc.c file. The km82xx specific code war moved from common.c to km_82xx.c. CRAMFS and CRAMFS_CMDLINE was enabled for all boards.
All keymile boards compile cleanly and checkpatch reports no errors or warnings.
Holger Brunck (9): km/common: rework and simplify default environment km/common: simplify debug environment km/common: remove obsolete defines and header km/common: force set ethaddr after reading IVM km/common: remove saveenv from do_checkboardidhwkey km/common: move ivm functions from to ivm.c km/common: remove fdt_(gs)et_node_and_value powerpc/km82xx: remove 82xx specific functions from common.c km/common: enable cramfs and cramfs cmdline
Thomas Herzmann (1): km/common: add test sw starting variable
board/keymile/common/common.c | 456 +--------------------------- board/keymile/common/common.h | 2 +- board/keymile/common/ivm.c | 342 +++++++++++++++++++++ board/keymile/common/keymile_hdlc_enet.h | 129 -------- board/keymile/km82xx/Makefile | 2 +- board/keymile/km82xx/km82xx.c | 60 ++++ board/keymile/km83xx/Makefile | 2 +- board/keymile/km_arm/Makefile | 2 +- board/keymile/scripts/README | 42 ++- board/keymile/scripts/debug-arm-env.txt | 2 - board/keymile/scripts/debug-common-env.txt | 9 - board/keymile/scripts/debug-ppc-env.txt | 2 - board/keymile/scripts/develop-arm.txt | 2 + board/keymile/scripts/develop-common.txt | 6 + board/keymile/scripts/develop-ppc_82xx.txt | 2 + board/keymile/scripts/develop-ppc_8xx.txt | 2 + board/keymile/scripts/ramfs-arm.txt | 2 + board/keymile/scripts/ramfs-common.txt | 12 + board/keymile/scripts/ramfs-ppc_82xx.txt | 2 + board/keymile/scripts/ramfs-ppc_8xx.txt | 2 + include/configs/km/keymile-common.h | 131 +++------ include/configs/km/km-powerpc.h | 12 +- include/configs/km/km82xx-common.h | 9 +- include/configs/km/km8321-common.h | 3 +- include/configs/km/km83xx-common.h | 7 +- include/configs/km/km_arm.h | 16 +- 26 files changed, 529 insertions(+), 729 deletions(-) create mode 100644 board/keymile/common/ivm.c delete mode 100644 board/keymile/common/keymile_hdlc_enet.h delete mode 100644 board/keymile/scripts/debug-arm-env.txt delete mode 100644 board/keymile/scripts/debug-common-env.txt delete mode 100644 board/keymile/scripts/debug-ppc-env.txt create mode 100644 board/keymile/scripts/develop-arm.txt create mode 100644 board/keymile/scripts/develop-common.txt create mode 100644 board/keymile/scripts/develop-ppc_82xx.txt create mode 100644 board/keymile/scripts/develop-ppc_8xx.txt create mode 100644 board/keymile/scripts/ramfs-arm.txt create mode 100644 board/keymile/scripts/ramfs-common.txt create mode 100644 board/keymile/scripts/ramfs-ppc_82xx.txt create mode 100644 board/keymile/scripts/ramfs-ppc_8xx.txt

This is the second step to simplify and decrease the default environment for the keymile boards. The release usecase formaly used to set the production environment was removed and the default configuration is now the production environment. So the formar environment variable "release" which has done a lot of things in the past, simply erase the current environment and do a reset which forces u-boot to setup the default environment again.
Signed-off-by: Holger Brunck holger.brunck@keymile.com Signed-off-by: Valentin Longchamp valentin.longchamp@keymile.com cc: Heiko Schocher hs@denx.de cc: Wolfgang Denk wd@denx.de --- include/configs/km/keymile-common.h | 105 ++++++++--------------------------- include/configs/km/km-powerpc.h | 10 ++-- include/configs/km/km_arm.h | 12 ++-- 3 files changed, 34 insertions(+), 93 deletions(-)
diff --git a/include/configs/km/keymile-common.h b/include/configs/km/keymile-common.h index 70c9dad..8839ccb 100644 --- a/include/configs/km/keymile-common.h +++ b/include/configs/km/keymile-common.h @@ -131,8 +131,7 @@ /* common powerpc specific env settings */ #ifndef CONFIG_KM_DEF_ENV_BOOTPARAMS #define CONFIG_KM_DEF_ENV_BOOTPARAMS \ - "bootparams=empty\0" \ - "initial_boot_bank=0\0" + "actual_bank=0\0" #endif
#ifndef CONFIG_KM_DEF_NETDEV @@ -151,57 +150,15 @@ #define str(s) #s
/* - * bootrunner - * - run all commands in 'subbootcmds' - * - on error, stop running the remaing commands - */ -#define CONFIG_KM_DEF_ENV_BOOTRUNNER \ - "bootrunner=" \ - "break=0; " \ - "for subbootcmd in ${subbootcmds}; do " \ - "if test ${break} -eq 0; then; " \ - "print ${subbootcmd}; " \ - "run ${subbootcmd} || break=1; " \ - "fi; " \ - "done\0" \ - "" - -/* * boottargets - * - set 'subbootcmds' for the bootrunner + * - set 'subbootcmds' * - set 'bootcmd' and 'altbootcmd' * available targets: * - 'release': for a standalone system kernel/rootfs from flash - * - * - 'commonargs': bootargs common to all targets */ #define CONFIG_KM_DEF_ENV_BOOTTARGETS \ - "commonargs=" \ - "addip " \ - "addtty " \ - "addmem " \ - "addinit " \ - "addvar " \ - "addmtdparts " \ - "addbootcount " \ - "\0" \ - "release=" \ - "setenv actual_bank ${initial_boot_bank} && " \ - "setenv subbootcmds "" \ - "checkboardid " \ - "ubiattach ubicopy " \ - "cramfsloadfdt cramfsloadkernel " \ - "flashargs ${commonargs} " \ - "addpanic boot " \ - "" && " \ - "setenv bootcmd '" \ - "run actual bootrunner; reset" \ - "' && " \ - "setenv altbootcmd '" \ - "run backup bootrunner; reset" \ - "' && " \ - "saveenv && saveenv && " \ - "reset\0" \ + "subbootcmds=ubiattach ubicopy cramfsloadfdt cramfsloadkernel " \ + "flashargs add_default addpanic boot\0" \ "debug_env=" \ "tftp 200000 " CONFIG_KM_ARCH_DBG_FILE " && " \ "env import -t 200000 ${filesize} && " \ @@ -212,37 +169,26 @@ * bootargs * - modify 'bootargs' * - * - 'addip': add ip configuration - * - 'addmem': limit kernel memory mem= + * - 'add_default': default bootargs common for all arm/ppc boards * - 'addpanic': add kernel panic options - * - 'addtty': add console=... - * - 'addvar': add phram device for /var * - 'flashargs': defaults arguments for flash base boot * - * processor specific settings - * - 'addbootcount': add boot counter - * - 'addmtdparts': add mtd partition information */ #define CONFIG_KM_DEF_ENV_BOOTARGS \ - "addinit=" \ - "setenv bootargs ${bootargs} init=${init}\0" \ - "addip=" \ + "add_default=" \ "setenv bootargs ${bootargs} " \ "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}" \ - ":${hostname}:${netdev}:off\0" \ - "addmem=" \ - "setenv bootargs ${bootargs} mem=${pnvramaddr}\0" \ + ":${hostname}:${netdev}:off3" \ + " console=" CONFIG_KM_CONSOLE_TTY ",${baudrate}" \ + " mem=${pnvramaddr} init=${init}" \ + " phram.phram=phvar,${varaddr}," xstr(CONFIG_KM_PHRAM) \ + " ubi.mtd=" CONFIG_KM_UBI_LINUX_MTD_NAME " " \ + CONFIG_KM_DEF_BOOT_ARGS_CPU \ + "\0" \ "addpanic=" \ "setenv bootargs ${bootargs} panic=1 panic_on_oops=1\0" \ - "addtty=" \ - "setenv bootargs ${bootargs}" \ - " console=" CONFIG_KM_CONSOLE_TTY ",${baudrate}\0" \ - "addvar=" \ - "setenv bootargs ${bootargs} phram.phram=phvar," \ - "${varaddr}," xstr(CONFIG_KM_PHRAM) "\0" \ "flashargs=" \ "setenv bootargs " \ - "ubi.mtd=" CONFIG_KM_UBI_LINUX_MTD_NAME " " \ "root=mtdblock:rootfs${boot_bank} " \ "rootfstype=squashfs ro\0" \ "" @@ -261,9 +207,7 @@ */ #define CONFIG_KM_DEF_ENV_FLASH_BOOT \ "cramfsaddr=" xstr(CONFIG_KM_CRAMFS_ADDR) "\0" \ - "cramfsloadkernel=" \ - "cramfsload ${kernel_addr_r} uImage && " \ - "setenv actual_kernel_addr ${kernel_addr_r}\0" \ + "cramfsloadkernel=cramfsload ${load_addr_r} uImage\0" \ "ubiattach=ubi part " CONFIG_KM_UBI_PARTITION_NAME "\0" \ "ubicopy=ubi read "xstr(CONFIG_KM_CRAMFS_ADDR) \ " bootfs${boot_bank}\0" \ @@ -276,14 +220,8 @@ * - 'default': setup default environment */ #define CONFIG_KM_DEF_ENV_CONSTANTS \ - "actual=setenv boot_bank ${actual_bank}\0" \ - "backup=setenv boot_bank ${backup_bank}\0" \ - "actual_bank=${initial_boot_bank}\0" \ "backup_bank=0\0" \ - "default=" \ - "setenv default 'run newenv; reset' && " \ - "run release && saveenv; reset\0" \ - "checkboardid=km_checkbidhwk\0" \ + "release=run newenv; reset\0" \ "pnvramsize=" xstr(CONFIG_KM_PNVRAM) "\0" \ ""
@@ -292,24 +230,27 @@ CONFIG_KM_DEF_ENV_BOOTPARAMS \ CONFIG_KM_DEF_NETDEV \ CONFIG_KM_DEF_ENV_CPU \ - CONFIG_KM_DEF_ENV_BOOTRUNNER \ CONFIG_KM_DEF_ENV_BOOTTARGETS \ CONFIG_KM_DEF_ENV_BOOTARGS \ CONFIG_KM_DEF_ENV_FLASH_BOOT \ CONFIG_KM_DEF_ENV_CONSTANTS \ "altbootcmd=run bootcmd\0" \ - "bootcmd=run default\0" \ + "bootcmd=km_checkbidhwk && " \ + " setenv bootcmd 'setenv boot_bank ${actual_bank}; " \ + "run ${subbootcmds}; reset' && " \ + "setenv altbootcmd 'setenv boot_bank ${backup_bank}; " \ + "run ${subbootcmds}; reset' && " \ + "saveenv && saveenv && boot\0" \ "bootlimit=2\0" \ "init=/sbin/init-overlay.sh\0" \ - "kernel_addr_r="xstr(CONFIG_KM_KERNEL_ADDR) "\0" \ - "load=tftpboot ${u-boot_addr_r} ${u-boot}\0" \ + "load_addr_r="xstr(CONFIG_KM_KERNEL_ADDR) "\0" \ + "load=tftpboot ${load_addr_r} ${u-boot}\0" \ "mtdids=" MTDIDS_DEFAULT "\0" \ "mtdparts=" MTDPARTS_DEFAULT "\0" \ "stderr=serial\0" \ "stdin=serial\0" \ "stdout=serial\0" \ "u-boot="xstr(CONFIG_HOSTNAME) "/u-boot.bin\0" \ - "u-boot_addr_r="xstr(CONFIG_KM_KERNEL_ADDR) "\0" \ "" #endif /* CONFIG_KM_DEF_ENV */
diff --git a/include/configs/km/km-powerpc.h b/include/configs/km/km-powerpc.h index d6db8d7..de94d5f 100644 --- a/include/configs/km/km-powerpc.h +++ b/include/configs/km/km-powerpc.h @@ -66,14 +66,14 @@ #define CONFIG_KM_KERNEL_ADDR 0x400000 /* 3968Kbytes */ #define CONFIG_KM_FDT_ADDR 0x7E0000 /* 128Kbytes */
+/* architecture specific default bootargs */ +#define CONFIG_KM_DEF_BOOT_ARGS_CPU "" + #define CONFIG_KM_DEF_ENV_CPU \ - "addbootcount=true\0" \ - "addmtdparts=true\0" \ - "boot=bootm ${actual_kernel_addr} - ${actual_fdt_addr}\0" \ + "boot=bootm ${load_addr_r} - ${fdt_addr_r}\0" \ "cramfsloadfdt=" \ "cramfsload ${fdt_addr_r} " \ - "fdt_0x${IVM_BoardId}_0x${IVM_HWKey}.dtb && " \ - "setenv actual_fdt_addr ${fdt_addr_r}\0" \ + "fdt_0x${IVM_BoardId}_0x${IVM_HWKey}.dtb\0" \ "fdt_addr_r=" xstr(CONFIG_KM_FDT_ADDR) "\0" \ "update=" \ "protect off " xstr(BOOTFLASH_START) " +${filesize} && "\ diff --git a/include/configs/km/km_arm.h b/include/configs/km/km_arm.h index 20ee6ea..13bbcd1 100644 --- a/include/configs/km/km_arm.h +++ b/include/configs/km/km_arm.h @@ -63,12 +63,12 @@ #define CONFIG_KM_CRAMFS_ADDR 0x2400000 #define CONFIG_KM_KERNEL_ADDR 0x2000000 /* 4096KBytes */
+/* architecture specific default bootargs */ +#define CONFIG_KM_DEF_BOOT_ARGS_CPU \ + "bootcountaddr=${bootcountaddr} ${mtdparts}" + #define CONFIG_KM_DEF_ENV_CPU \ - "addbootcount=" \ - "setenv bootargs ${bootargs} " \ - "bootcountaddr=${bootcountaddr}\0" \ - "addmtdparts=setenv bootargs ${bootargs} ${mtdparts}\0" \ - "boot=bootm ${actual_kernel_addr} - -\0" \ + "boot=bootm ${load_addr_r} - -\0" \ "cramfsloadfdt=true\0" \ CONFIG_KM_DEF_ENV_UPDATE \ "" @@ -245,7 +245,7 @@ int get_scl(void); #define CONFIG_KM_DEF_ENV_UPDATE \ "update=" \ "spi on;sf probe 0;sf erase 0 50000;" \ - "sf write ${u-boot_addr_r} 0 ${filesize};" \ + "sf write ${load_addr_r} 0 ${filesize};" \ "spi off\0"
/*

This is the second step to simplify and decrease the default environment for the keymile boards. The release usecase formaly used to set the production environment was removed and the default configuration is now the production environment. So the formar environment variable "release" which has done a lot of things in the past, simply erase the current environment and do a reset which forces u-boot to setup the default environment again.
Signed-off-by: Holger Brunck holger.brunck@keymile.com Signed-off-by: Valentin Longchamp valentin.longchamp@keymile.com cc: Heiko Schocher hs@denx.de cc: Wolfgang Denk wd@denx.de
--- Changes for v2: - fix bug in u-boot update function in powerpc.h s/u-boot_addr_r/load_addr_r/
include/configs/km/keymile-common.h | 105 ++++++++--------------------------- include/configs/km/km-powerpc.h | 12 ++-- include/configs/km/km_arm.h | 12 ++-- 3 files changed, 35 insertions(+), 94 deletions(-)
diff --git a/include/configs/km/keymile-common.h b/include/configs/km/keymile-common.h index 70c9dad..8839ccb 100644 --- a/include/configs/km/keymile-common.h +++ b/include/configs/km/keymile-common.h @@ -131,8 +131,7 @@ /* common powerpc specific env settings */ #ifndef CONFIG_KM_DEF_ENV_BOOTPARAMS #define CONFIG_KM_DEF_ENV_BOOTPARAMS \ - "bootparams=empty\0" \ - "initial_boot_bank=0\0" + "actual_bank=0\0" #endif
#ifndef CONFIG_KM_DEF_NETDEV @@ -151,57 +150,15 @@ #define str(s) #s
/* - * bootrunner - * - run all commands in 'subbootcmds' - * - on error, stop running the remaing commands - */ -#define CONFIG_KM_DEF_ENV_BOOTRUNNER \ - "bootrunner=" \ - "break=0; " \ - "for subbootcmd in ${subbootcmds}; do " \ - "if test ${break} -eq 0; then; " \ - "print ${subbootcmd}; " \ - "run ${subbootcmd} || break=1; " \ - "fi; " \ - "done\0" \ - "" - -/* * boottargets - * - set 'subbootcmds' for the bootrunner + * - set 'subbootcmds' * - set 'bootcmd' and 'altbootcmd' * available targets: * - 'release': for a standalone system kernel/rootfs from flash - * - * - 'commonargs': bootargs common to all targets */ #define CONFIG_KM_DEF_ENV_BOOTTARGETS \ - "commonargs=" \ - "addip " \ - "addtty " \ - "addmem " \ - "addinit " \ - "addvar " \ - "addmtdparts " \ - "addbootcount " \ - "\0" \ - "release=" \ - "setenv actual_bank ${initial_boot_bank} && " \ - "setenv subbootcmds "" \ - "checkboardid " \ - "ubiattach ubicopy " \ - "cramfsloadfdt cramfsloadkernel " \ - "flashargs ${commonargs} " \ - "addpanic boot " \ - "" && " \ - "setenv bootcmd '" \ - "run actual bootrunner; reset" \ - "' && " \ - "setenv altbootcmd '" \ - "run backup bootrunner; reset" \ - "' && " \ - "saveenv && saveenv && " \ - "reset\0" \ + "subbootcmds=ubiattach ubicopy cramfsloadfdt cramfsloadkernel " \ + "flashargs add_default addpanic boot\0" \ "debug_env=" \ "tftp 200000 " CONFIG_KM_ARCH_DBG_FILE " && " \ "env import -t 200000 ${filesize} && " \ @@ -212,37 +169,26 @@ * bootargs * - modify 'bootargs' * - * - 'addip': add ip configuration - * - 'addmem': limit kernel memory mem= + * - 'add_default': default bootargs common for all arm/ppc boards * - 'addpanic': add kernel panic options - * - 'addtty': add console=... - * - 'addvar': add phram device for /var * - 'flashargs': defaults arguments for flash base boot * - * processor specific settings - * - 'addbootcount': add boot counter - * - 'addmtdparts': add mtd partition information */ #define CONFIG_KM_DEF_ENV_BOOTARGS \ - "addinit=" \ - "setenv bootargs ${bootargs} init=${init}\0" \ - "addip=" \ + "add_default=" \ "setenv bootargs ${bootargs} " \ "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}" \ - ":${hostname}:${netdev}:off\0" \ - "addmem=" \ - "setenv bootargs ${bootargs} mem=${pnvramaddr}\0" \ + ":${hostname}:${netdev}:off3" \ + " console=" CONFIG_KM_CONSOLE_TTY ",${baudrate}" \ + " mem=${pnvramaddr} init=${init}" \ + " phram.phram=phvar,${varaddr}," xstr(CONFIG_KM_PHRAM) \ + " ubi.mtd=" CONFIG_KM_UBI_LINUX_MTD_NAME " " \ + CONFIG_KM_DEF_BOOT_ARGS_CPU \ + "\0" \ "addpanic=" \ "setenv bootargs ${bootargs} panic=1 panic_on_oops=1\0" \ - "addtty=" \ - "setenv bootargs ${bootargs}" \ - " console=" CONFIG_KM_CONSOLE_TTY ",${baudrate}\0" \ - "addvar=" \ - "setenv bootargs ${bootargs} phram.phram=phvar," \ - "${varaddr}," xstr(CONFIG_KM_PHRAM) "\0" \ "flashargs=" \ "setenv bootargs " \ - "ubi.mtd=" CONFIG_KM_UBI_LINUX_MTD_NAME " " \ "root=mtdblock:rootfs${boot_bank} " \ "rootfstype=squashfs ro\0" \ "" @@ -261,9 +207,7 @@ */ #define CONFIG_KM_DEF_ENV_FLASH_BOOT \ "cramfsaddr=" xstr(CONFIG_KM_CRAMFS_ADDR) "\0" \ - "cramfsloadkernel=" \ - "cramfsload ${kernel_addr_r} uImage && " \ - "setenv actual_kernel_addr ${kernel_addr_r}\0" \ + "cramfsloadkernel=cramfsload ${load_addr_r} uImage\0" \ "ubiattach=ubi part " CONFIG_KM_UBI_PARTITION_NAME "\0" \ "ubicopy=ubi read "xstr(CONFIG_KM_CRAMFS_ADDR) \ " bootfs${boot_bank}\0" \ @@ -276,14 +220,8 @@ * - 'default': setup default environment */ #define CONFIG_KM_DEF_ENV_CONSTANTS \ - "actual=setenv boot_bank ${actual_bank}\0" \ - "backup=setenv boot_bank ${backup_bank}\0" \ - "actual_bank=${initial_boot_bank}\0" \ "backup_bank=0\0" \ - "default=" \ - "setenv default 'run newenv; reset' && " \ - "run release && saveenv; reset\0" \ - "checkboardid=km_checkbidhwk\0" \ + "release=run newenv; reset\0" \ "pnvramsize=" xstr(CONFIG_KM_PNVRAM) "\0" \ ""
@@ -292,24 +230,27 @@ CONFIG_KM_DEF_ENV_BOOTPARAMS \ CONFIG_KM_DEF_NETDEV \ CONFIG_KM_DEF_ENV_CPU \ - CONFIG_KM_DEF_ENV_BOOTRUNNER \ CONFIG_KM_DEF_ENV_BOOTTARGETS \ CONFIG_KM_DEF_ENV_BOOTARGS \ CONFIG_KM_DEF_ENV_FLASH_BOOT \ CONFIG_KM_DEF_ENV_CONSTANTS \ "altbootcmd=run bootcmd\0" \ - "bootcmd=run default\0" \ + "bootcmd=km_checkbidhwk && " \ + " setenv bootcmd 'setenv boot_bank ${actual_bank}; " \ + "run ${subbootcmds}; reset' && " \ + "setenv altbootcmd 'setenv boot_bank ${backup_bank}; " \ + "run ${subbootcmds}; reset' && " \ + "saveenv && saveenv && boot\0" \ "bootlimit=2\0" \ "init=/sbin/init-overlay.sh\0" \ - "kernel_addr_r="xstr(CONFIG_KM_KERNEL_ADDR) "\0" \ - "load=tftpboot ${u-boot_addr_r} ${u-boot}\0" \ + "load_addr_r="xstr(CONFIG_KM_KERNEL_ADDR) "\0" \ + "load=tftpboot ${load_addr_r} ${u-boot}\0" \ "mtdids=" MTDIDS_DEFAULT "\0" \ "mtdparts=" MTDPARTS_DEFAULT "\0" \ "stderr=serial\0" \ "stdin=serial\0" \ "stdout=serial\0" \ "u-boot="xstr(CONFIG_HOSTNAME) "/u-boot.bin\0" \ - "u-boot_addr_r="xstr(CONFIG_KM_KERNEL_ADDR) "\0" \ "" #endif /* CONFIG_KM_DEF_ENV */
diff --git a/include/configs/km/km-powerpc.h b/include/configs/km/km-powerpc.h index d6db8d7..7aaa8d2 100644 --- a/include/configs/km/km-powerpc.h +++ b/include/configs/km/km-powerpc.h @@ -66,19 +66,19 @@ #define CONFIG_KM_KERNEL_ADDR 0x400000 /* 3968Kbytes */ #define CONFIG_KM_FDT_ADDR 0x7E0000 /* 128Kbytes */
+/* architecture specific default bootargs */ +#define CONFIG_KM_DEF_BOOT_ARGS_CPU "" + #define CONFIG_KM_DEF_ENV_CPU \ - "addbootcount=true\0" \ - "addmtdparts=true\0" \ - "boot=bootm ${actual_kernel_addr} - ${actual_fdt_addr}\0" \ + "boot=bootm ${load_addr_r} - ${fdt_addr_r}\0" \ "cramfsloadfdt=" \ "cramfsload ${fdt_addr_r} " \ - "fdt_0x${IVM_BoardId}_0x${IVM_HWKey}.dtb && " \ - "setenv actual_fdt_addr ${fdt_addr_r}\0" \ + "fdt_0x${IVM_BoardId}_0x${IVM_HWKey}.dtb\0" \ "fdt_addr_r=" xstr(CONFIG_KM_FDT_ADDR) "\0" \ "update=" \ "protect off " xstr(BOOTFLASH_START) " +${filesize} && "\ "erase " xstr(BOOTFLASH_START) " +${filesize} && " \ - "cp.b ${u-boot_addr_r} " xstr(BOOTFLASH_START) \ + "cp.b ${load_addr_r} " xstr(BOOTFLASH_START) \ " ${filesize} && " \ "protect on " xstr(BOOTFLASH_START) " +${filesize}\0" \ "" diff --git a/include/configs/km/km_arm.h b/include/configs/km/km_arm.h index f1eea26..7eb5cd4 100644 --- a/include/configs/km/km_arm.h +++ b/include/configs/km/km_arm.h @@ -67,12 +67,12 @@ #define CONFIG_KM_CRAMFS_ADDR 0x2400000 #define CONFIG_KM_KERNEL_ADDR 0x2000000 /* 4096KBytes */
+/* architecture specific default bootargs */ +#define CONFIG_KM_DEF_BOOT_ARGS_CPU \ + "bootcountaddr=${bootcountaddr} ${mtdparts}" + #define CONFIG_KM_DEF_ENV_CPU \ - "addbootcount=" \ - "setenv bootargs ${bootargs} " \ - "bootcountaddr=${bootcountaddr}\0" \ - "addmtdparts=setenv bootargs ${bootargs} ${mtdparts}\0" \ - "boot=bootm ${actual_kernel_addr} - -\0" \ + "boot=bootm ${load_addr_r} - -\0" \ "cramfsloadfdt=true\0" \ CONFIG_KM_DEF_ENV_UPDATE \ "" @@ -229,7 +229,7 @@ int get_scl(void); #define CONFIG_KM_DEF_ENV_UPDATE \ "update=" \ "spi on;sf probe 0;sf erase 0 50000;" \ - "sf write ${u-boot_addr_r} 0 ${filesize};" \ + "sf write ${load_addr_r} 0 ${filesize};" \ "spi off\0"
/*

Dear Holger Brunck,
In message 1309850836-21989-1-git-send-email-holger.brunck@keymile.com you wrote:
This is the second step to simplify and decrease the default environment for the keymile boards. The release usecase formaly used to set the production environment was removed and the default configuration is now the production environment. So the formar environment variable "release" which has done a lot of things in the past, simply erase the current environment and do a reset which forces u-boot to setup the default environment again.
Signed-off-by: Holger Brunck holger.brunck@keymile.com Signed-off-by: Valentin Longchamp valentin.longchamp@keymile.com cc: Heiko Schocher hs@denx.de cc: Wolfgang Denk wd@denx.de
Changes for v2:
- fix bug in u-boot update function in powerpc.h s/u-boot_addr_r/load_addr_r/
include/configs/km/keymile-common.h | 105 ++++++++--------------------------- include/configs/km/km-powerpc.h | 12 ++-- include/configs/km/km_arm.h | 12 ++-- 3 files changed, 35 insertions(+), 94 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

From: Thomas Herzmann thomas.herzmann@keymile.com
The test SW is started when the test_bank variable is set.
Signed-off-by: Thomas Herzmann thomas.herzmann@keymile.com Signed-off-by: Valentin Longchamp valentin.longchamp@keymile.com cc: Heiko Schocher hs@denx.de cc: Wolfgang Denk wd@denx.de Signed-off-by: Holger Brunck holger.brunck@keymile.com --- include/configs/km/keymile-common.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/include/configs/km/keymile-common.h b/include/configs/km/keymile-common.h index 8839ccb..c40a541 100644 --- a/include/configs/km/keymile-common.h +++ b/include/configs/km/keymile-common.h @@ -223,6 +223,8 @@ "backup_bank=0\0" \ "release=run newenv; reset\0" \ "pnvramsize=" xstr(CONFIG_KM_PNVRAM) "\0" \ + "testbootcmd=setenv boot_bank ${test_bank}; " \ + "run ${subbootcmds}; reset\0" \ ""
#ifndef CONFIG_KM_DEF_ENV

Dear Holger Brunck,
In message 1307348541-2466-3-git-send-email-holger.brunck@keymile.com you wrote:
From: Thomas Herzmann thomas.herzmann@keymile.com
The test SW is started when the test_bank variable is set.
Signed-off-by: Thomas Herzmann thomas.herzmann@keymile.com Signed-off-by: Valentin Longchamp valentin.longchamp@keymile.com cc: Heiko Schocher hs@denx.de cc: Wolfgang Denk wd@denx.de Signed-off-by: Holger Brunck holger.brunck@keymile.com
include/configs/km/keymile-common.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

The debug environment which is stored in textfiles in the scripts directory was reworked. Two usecase are now present which can be executed simply from the default environment: run develop: this configures the environment to setup the rootfs via nfs run ramfs: this configures the environment to setup the rootfs in ram
Each architecture now has a "arch" variable which is used to load the architecture specific debug scripts and to set the rootpath for NFS.
Signed-off-by: Holger Brunck holger.brunck@keymile.com Signed-off-by: Valentin Longchamp valentin.longchamp@keymile.com cc: Heiko Schocher hs@denx.de cc: Wolfgang Denk wd@denx.de --- board/keymile/scripts/README | 42 ++++++++++++++++----------- board/keymile/scripts/debug-arm-env.txt | 2 - board/keymile/scripts/debug-common-env.txt | 9 ------ board/keymile/scripts/debug-ppc-env.txt | 2 - board/keymile/scripts/develop-arm.txt | 2 + board/keymile/scripts/develop-common.txt | 6 ++++ board/keymile/scripts/develop-ppc_82xx.txt | 2 + board/keymile/scripts/develop-ppc_8xx.txt | 2 + board/keymile/scripts/ramfs-arm.txt | 2 + board/keymile/scripts/ramfs-common.txt | 12 ++++++++ board/keymile/scripts/ramfs-ppc_82xx.txt | 2 + board/keymile/scripts/ramfs-ppc_8xx.txt | 2 + include/configs/km/keymile-common.h | 10 ++++-- include/configs/km/km-powerpc.h | 2 - include/configs/km/km82xx-common.h | 2 +- include/configs/km/km8321-common.h | 3 +- include/configs/km/km83xx-common.h | 7 ++-- include/configs/km/km_arm.h | 4 +-- 18 files changed, 68 insertions(+), 45 deletions(-) delete mode 100644 board/keymile/scripts/debug-arm-env.txt delete mode 100644 board/keymile/scripts/debug-common-env.txt delete mode 100644 board/keymile/scripts/debug-ppc-env.txt create mode 100644 board/keymile/scripts/develop-arm.txt create mode 100644 board/keymile/scripts/develop-common.txt create mode 100644 board/keymile/scripts/develop-ppc_82xx.txt create mode 100644 board/keymile/scripts/develop-ppc_8xx.txt create mode 100644 board/keymile/scripts/ramfs-arm.txt create mode 100644 board/keymile/scripts/ramfs-common.txt create mode 100644 board/keymile/scripts/ramfs-ppc_82xx.txt create mode 100644 board/keymile/scripts/ramfs-ppc_8xx.txt
diff --git a/board/keymile/scripts/README b/board/keymile/scripts/README index 86c2b5a..7fbcf74 100644 --- a/board/keymile/scripts/README +++ b/board/keymile/scripts/README @@ -1,23 +1,31 @@ -debug-common-env.txt +These scripts are needed for our development usecases. Copy this directory +into your tftp root directory to be able to use this scripts. +cp -r <u-boot-repo>/board/keymile/scripts <your_tftp_root>/ + +To load and configure these usecase, two environment variables in the u-boot +default environment must be parsed: +run develop : setup environment to configure for rootfs via nfs +run ramfs : setup environment to configure for rootfs in ram + +Last change: 20.05.2011 + +develop-common.txt +============================ +This file defines variables for working with rootfs via nfs for powerpc and +arm. + +develop-<arch>.txt ============================ -This file defines environment variables which are valid for powerpc boards -and for arm boards. +This file defines architecture specific variables for working with rootfs via +nfs arm.
-addramfs: add phram device for the rootfilesysten in ram -develop: for development, laod kernel via tftp and mount rootfs via NFS -nfsargs: default arguments for nfs boot -ramfs: load rootfilesystem in RAM kernel -rootfsfile: loacation of the rootfs file for ramfs -setramfspram: compute PRAM size for ramfs target -setrootfsaddr: compute rootfilesystem address for phram -tftpkernel: load a kernel with tftp into ram -tftpramfs: load rootfs with tftp into ram
-debug-ppc-env.txt +ramfs-common.txt ============================ -fdt_file: location of the dtb file on the tftp server -tftpfdt: load dtb file and set fdt address +This file defines variables for working with rootfs inside the ram for powerpc +and arm.
-debug-arm-env.txt +ramfs-<arch>.txt ============================ -tftpfdt: for arm only a dummy variable, because we have no fdt on arm +This file defines architecture specific variables for working with rootfs inside +ram. diff --git a/board/keymile/scripts/debug-arm-env.txt b/board/keymile/scripts/debug-arm-env.txt deleted file mode 100644 index 84498af..0000000 --- a/board/keymile/scripts/debug-arm-env.txt +++ /dev/null @@ -1,2 +0,0 @@ -debug_env_common=tftpboot 0x200000 scripts/debug-common-env.txt && env import -t 0x200000 ${filesize} -tftpfdt=true diff --git a/board/keymile/scripts/debug-common-env.txt b/board/keymile/scripts/debug-common-env.txt deleted file mode 100644 index 1fd4b0c..0000000 --- a/board/keymile/scripts/debug-common-env.txt +++ /dev/null @@ -1,9 +0,0 @@ -addramfs=setenv bootargs "${bootargs} phram.phram=rootfs${boot_bank},${rootfsaddr},${rootfssize}" -develop=setenv subbootcmds "tftpfdt tftpkernel nfsargs ${commonargs} boot " && setenv bootcmd 'run bootrunner' && setenv altbootcmd 'run bootcmd' && km_setboardid && saveenv && reset -nfsargs=setenv bootargs ubi.mtd=ubi0 root=/dev/nfs rw nfsroot=${serverip}:${rootpath} -ramfs=setenv actual_bank -1 && setenv subbootcmds "tftpfdt tftpkernel setrootfsaddr tftpramfs flashargs ${commonargs} addpanic addramfs boot " && setenv bootcmd 'run bootrunner' && setenv altbootcmd 'run bootcmd' && run setboardid && run setramfspram && run setpnvramaddr && saveenv && reset -rootfsfile=${hostname}/rootfsImage -setramfspram=setexpr value 0 + ${reservedpram} && setexpr value 0x${value} + ${rootfssize} && setexpr value 0x${value} + ${varsize} && setexpr value 0x${value} + ${pnvramsize} && setexpr value 0x${value} / 0x400 && setenv pram 0x${value} -tftpkernel=tftpboot ${kernel_addr_r} ${hostname}/uImage && setenv actual_kernel_addr ${kernel_addr_r} -tftpramfs=tftpboot ${rootfsaddr} ${hostname}/rootfsImage && setenv loadaddr -setrootfsaddr=setexpr value ${pnvramsize} - ${rootfssize} && setenv rootfsaddr 0x${value} diff --git a/board/keymile/scripts/debug-ppc-env.txt b/board/keymile/scripts/debug-ppc-env.txt deleted file mode 100644 index 3c06ff1..0000000 --- a/board/keymile/scripts/debug-ppc-env.txt +++ /dev/null @@ -1,2 +0,0 @@ -debug_env_common=tftpboot 0x200000 scripts/debug-common-env.txt && env import -t 0x200000 ${filesize} -tftpfdt=tftpboot ${fdt_addr_r} ${hostname}/${hostname}.dtb && setenv actual_fdt_addr ${fdt_addr_r} diff --git a/board/keymile/scripts/develop-arm.txt b/board/keymile/scripts/develop-arm.txt new file mode 100644 index 0000000..922afea --- /dev/null +++ b/board/keymile/scripts/develop-arm.txt @@ -0,0 +1,2 @@ +setup_debug_env=tftpboot 0x200000 scripts/develop-common.txt && env import -t 0x200000 ${filesize} && run configure +tftpfdt=true diff --git a/board/keymile/scripts/develop-common.txt b/board/keymile/scripts/develop-common.txt new file mode 100644 index 0000000..3ccd039 --- /dev/null +++ b/board/keymile/scripts/develop-common.txt @@ -0,0 +1,6 @@ +altbootcmd=run ${subbootcmds} +bootcmd=run ${subbootcmds} +configure=km_setboardid && saveenv && reset +subbootcmds=tftpfdt tftpkernel nfsargs add_default boot +nfsargs=setenv bootargs root=/dev/nfs rw nfsroot=${serverip}:/opt/eldk/${arch} +tftpkernel=tftpboot ${load_addr_r} ${hostname}/uImage diff --git a/board/keymile/scripts/develop-ppc_82xx.txt b/board/keymile/scripts/develop-ppc_82xx.txt new file mode 100644 index 0000000..909f6a3 --- /dev/null +++ b/board/keymile/scripts/develop-ppc_82xx.txt @@ -0,0 +1,2 @@ +setup_debug_env=tftpboot 0x200000 scripts/develop-common.txt && env import -t 0x200000 ${filesize} && run configure +tftpfdt=tftpboot ${fdt_addr_r} ${hostname}/${hostname}.dtb diff --git a/board/keymile/scripts/develop-ppc_8xx.txt b/board/keymile/scripts/develop-ppc_8xx.txt new file mode 100644 index 0000000..909f6a3 --- /dev/null +++ b/board/keymile/scripts/develop-ppc_8xx.txt @@ -0,0 +1,2 @@ +setup_debug_env=tftpboot 0x200000 scripts/develop-common.txt && env import -t 0x200000 ${filesize} && run configure +tftpfdt=tftpboot ${fdt_addr_r} ${hostname}/${hostname}.dtb diff --git a/board/keymile/scripts/ramfs-arm.txt b/board/keymile/scripts/ramfs-arm.txt new file mode 100644 index 0000000..79974f1 --- /dev/null +++ b/board/keymile/scripts/ramfs-arm.txt @@ -0,0 +1,2 @@ +setup_debug_env=tftpboot 0x200000 scripts/ramfs-common.txt && env import -t 0x200000 ${filesize} && run configure +tftpfdt=true diff --git a/board/keymile/scripts/ramfs-common.txt b/board/keymile/scripts/ramfs-common.txt new file mode 100644 index 0000000..9315500 --- /dev/null +++ b/board/keymile/scripts/ramfs-common.txt @@ -0,0 +1,12 @@ +addramfs=setenv bootargs "${bootargs} mem=${rootfsaddr} phram.phram=rootfs${boot_bank},${rootfsaddr},${rootfssize}" +actual_bank=-1 +altbootcmd=run ${subbootcmds} +bootcmd=run ${subbootcmds} +subbootcmds=tftpfdt tftpkernel setrootfsaddr tftpramfs flashargs add_default addpanic addramfs boot +nfsargs=setenv bootargs root=/dev/nfs rw nfsroot=${serverip}:${rootpath} +configure=km_setboardid && run setramfspram && saveenv && reset +setramfspram=setexpr value 0 + ${rootfssize} && setexpr value 0x${value} / 0x400 && setexpr value 0x${value} + ${pram} && setenv pram 0x${value} +rootfsfile=${hostname}/rootfsImage +setrootfsaddr=setexpr value ${pnvramaddr} - ${rootfssize} && setenv rootfsaddr 0x${value} +tftpkernel=tftpboot ${load_addr_r} ${hostname}/uImage +tftpramfs=tftpboot ${rootfsaddr} ${hostname}/rootfsImage diff --git a/board/keymile/scripts/ramfs-ppc_82xx.txt b/board/keymile/scripts/ramfs-ppc_82xx.txt new file mode 100644 index 0000000..970927a --- /dev/null +++ b/board/keymile/scripts/ramfs-ppc_82xx.txt @@ -0,0 +1,2 @@ +setup_debug_env=tftpboot 0x200000 scripts/ramfs-common.txt && env import -t 0x200000 ${filesize} && run configure +tftpfdt=tftpboot ${fdt_addr_r} ${hostname}/${hostname}.dtb diff --git a/board/keymile/scripts/ramfs-ppc_8xx.txt b/board/keymile/scripts/ramfs-ppc_8xx.txt new file mode 100644 index 0000000..970927a --- /dev/null +++ b/board/keymile/scripts/ramfs-ppc_8xx.txt @@ -0,0 +1,2 @@ +setup_debug_env=tftpboot 0x200000 scripts/ramfs-common.txt && env import -t 0x200000 ${filesize} && run configure +tftpfdt=tftpboot ${fdt_addr_r} ${hostname}/${hostname}.dtb diff --git a/include/configs/km/keymile-common.h b/include/configs/km/keymile-common.h index c40a541..c0df6d8 100644 --- a/include/configs/km/keymile-common.h +++ b/include/configs/km/keymile-common.h @@ -159,10 +159,14 @@ #define CONFIG_KM_DEF_ENV_BOOTTARGETS \ "subbootcmds=ubiattach ubicopy cramfsloadfdt cramfsloadkernel " \ "flashargs add_default addpanic boot\0" \ - "debug_env=" \ - "tftp 200000 " CONFIG_KM_ARCH_DBG_FILE " && " \ + "develop=" \ + "tftp 200000 scripts/develop-${arch}.txt && " \ "env import -t 200000 ${filesize} && " \ - "run debug_env_common\0" \ + "run setup_debug_env\0" \ + "ramfs=" \ + "tftp 200000 scripts/ramfs-${arch}.txt && " \ + "env import -t 200000 ${filesize} && " \ + "run setup_debug_env\0" \ ""
/* diff --git a/include/configs/km/km-powerpc.h b/include/configs/km/km-powerpc.h index de94d5f..20e83d9 100644 --- a/include/configs/km/km-powerpc.h +++ b/include/configs/km/km-powerpc.h @@ -83,6 +83,4 @@ "protect on " xstr(BOOTFLASH_START) " +${filesize}\0" \ ""
-#define CONFIG_KM_ARCH_DBG_FILE "scripts/debug-ppc-env.txt" - #endif /* __CONFIG_KEYMILE_POWERPC_H */ diff --git a/include/configs/km/km82xx-common.h b/include/configs/km/km82xx-common.h index 446c1d0..b89631c 100644 --- a/include/configs/km/km82xx-common.h +++ b/include/configs/km/km82xx-common.h @@ -87,7 +87,7 @@ "newenv=" \ "prot off 0xFE0C0000 +0x40000 && " \ "era 0xFE0C0000 +0x40000\0" \ - "rootpath=/opt/eldk/ppc_82xx\0" \ + "arch=ppc_82xx\0" \ ""
#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE diff --git a/include/configs/km/km8321-common.h b/include/configs/km/km8321-common.h index 6fab45e..902ae26 100644 --- a/include/configs/km/km8321-common.h +++ b/include/configs/km/km8321-common.h @@ -33,8 +33,7 @@ #define CONFIG_MPC832x /* MPC832x CPU specific */ #define CONFIG_KM8321 /* Keymile PBEC8321 board specific */
-#define CONFIG_KM_DEF_ROOTPATH \ - "rootpath=/opt/eldk/ppc_8xx\0" +#define CONFIG_KM_DEF_ARCH "arch=ppc_8xx\0"
/* include common defines/options for all 83xx Keymile boards */ #include "km83xx-common.h" diff --git a/include/configs/km/km83xx-common.h b/include/configs/km/km83xx-common.h index 85b6ed2..2b1a84a 100644 --- a/include/configs/km/km83xx-common.h +++ b/include/configs/km/km83xx-common.h @@ -302,14 +302,13 @@ #define CONFIG_KM_DEF_ENV "km-common=empty\0" #endif
-#ifndef CONFIG_KM_DEF_ROOTPATH -#define CONFIG_KM_DEF_ROOTPATH \ - "rootpath=/opt/eldk/ppc_82xx\0" +#ifndef CONFIG_KM_DEF_ARCH +#define CONFIG_KM_DEF_ARCH "arch=ppc_82xx\0" #endif
#define CONFIG_EXTRA_ENV_SETTINGS \ CONFIG_KM_DEF_ENV \ - CONFIG_KM_DEF_ROOTPATH \ + CONFIG_KM_DEF_ARCH \ "dtt_bus=pca9547:70:a\0" \ "EEprom_ivm=pca9547:70:9\0" \ "newenv=" \ diff --git a/include/configs/km/km_arm.h b/include/configs/km/km_arm.h index 13bbcd1..21a1b73 100644 --- a/include/configs/km/km_arm.h +++ b/include/configs/km/km_arm.h @@ -73,8 +73,6 @@ CONFIG_KM_DEF_ENV_UPDATE \ ""
-#define CONFIG_KM_ARCH_DBG_FILE "scripts/debug-arm-env.txt" - #define CONFIG_MD5 /* get_random_hex on krikwood needs MD5 support */ #define CONFIG_SKIP_LOWLEVEL_INIT /* disable board lowlevel_init */ #define CONFIG_KIRKWOOD_EGIGA_INIT /* Enable GbePort0/1 for kernel */ @@ -259,7 +257,7 @@ int get_scl(void); " ${addr} " xstr(CONFIG_ENV_OFFSET) " 4 && " \ "eeprom write " xstr(CONFIG_SYS_DEF_EEPROM_ADDR) \ " ${addr} " xstr(CONFIG_ENV_OFFSET_REDUND) " 4\0" \ - "rootpath=/opt/eldk/arm\0" \ + "arch=arm\0" \ "EEprom_ivm=" KM_IVM_BUS "\0" \ ""

The debug environment which is stored in textfiles in the scripts directory was reworked. Two usecase are now present which can be executed simply from the default environment: run develop: this configures the environment to setup the rootfs via nfs run ramfs: this configures the environment to setup the rootfs in ram
Each architecture now has a "arch" variable which is used to load the architecture specific debug scripts and to set the rootpath for NFS.
Signed-off-by: Holger Brunck holger.brunck@keymile.com Signed-off-by: Valentin Longchamp valentin.longchamp@keymile.com cc: Heiko Schocher hs@denx.de cc: Wolfgang Denk wd@denx.de
--- Changes for v2: - rebased to current HEAD
board/keymile/scripts/README | 42 ++++++++++++++++----------- board/keymile/scripts/debug-arm-env.txt | 2 - board/keymile/scripts/debug-common-env.txt | 9 ------ board/keymile/scripts/debug-ppc-env.txt | 2 - board/keymile/scripts/develop-arm.txt | 2 + board/keymile/scripts/develop-common.txt | 6 ++++ board/keymile/scripts/develop-ppc_82xx.txt | 2 + board/keymile/scripts/develop-ppc_8xx.txt | 2 + board/keymile/scripts/ramfs-arm.txt | 2 + board/keymile/scripts/ramfs-common.txt | 12 ++++++++ board/keymile/scripts/ramfs-ppc_82xx.txt | 2 + board/keymile/scripts/ramfs-ppc_8xx.txt | 2 + include/configs/km/keymile-common.h | 10 ++++-- include/configs/km/km-powerpc.h | 2 - include/configs/km/km82xx-common.h | 2 +- include/configs/km/km8321-common.h | 3 +- include/configs/km/km83xx-common.h | 7 ++-- include/configs/km/km_arm.h | 4 +-- 18 files changed, 68 insertions(+), 45 deletions(-) delete mode 100644 board/keymile/scripts/debug-arm-env.txt delete mode 100644 board/keymile/scripts/debug-common-env.txt delete mode 100644 board/keymile/scripts/debug-ppc-env.txt create mode 100644 board/keymile/scripts/develop-arm.txt create mode 100644 board/keymile/scripts/develop-common.txt create mode 100644 board/keymile/scripts/develop-ppc_82xx.txt create mode 100644 board/keymile/scripts/develop-ppc_8xx.txt create mode 100644 board/keymile/scripts/ramfs-arm.txt create mode 100644 board/keymile/scripts/ramfs-common.txt create mode 100644 board/keymile/scripts/ramfs-ppc_82xx.txt create mode 100644 board/keymile/scripts/ramfs-ppc_8xx.txt
diff --git a/board/keymile/scripts/README b/board/keymile/scripts/README index 86c2b5a..7fbcf74 100644 --- a/board/keymile/scripts/README +++ b/board/keymile/scripts/README @@ -1,23 +1,31 @@ -debug-common-env.txt +These scripts are needed for our development usecases. Copy this directory +into your tftp root directory to be able to use this scripts. +cp -r <u-boot-repo>/board/keymile/scripts <your_tftp_root>/ + +To load and configure these usecase, two environment variables in the u-boot +default environment must be parsed: +run develop : setup environment to configure for rootfs via nfs +run ramfs : setup environment to configure for rootfs in ram + +Last change: 20.05.2011 + +develop-common.txt +============================ +This file defines variables for working with rootfs via nfs for powerpc and +arm. + +develop-<arch>.txt ============================ -This file defines environment variables which are valid for powerpc boards -and for arm boards. +This file defines architecture specific variables for working with rootfs via +nfs arm.
-addramfs: add phram device for the rootfilesysten in ram -develop: for development, laod kernel via tftp and mount rootfs via NFS -nfsargs: default arguments for nfs boot -ramfs: load rootfilesystem in RAM kernel -rootfsfile: loacation of the rootfs file for ramfs -setramfspram: compute PRAM size for ramfs target -setrootfsaddr: compute rootfilesystem address for phram -tftpkernel: load a kernel with tftp into ram -tftpramfs: load rootfs with tftp into ram
-debug-ppc-env.txt +ramfs-common.txt ============================ -fdt_file: location of the dtb file on the tftp server -tftpfdt: load dtb file and set fdt address +This file defines variables for working with rootfs inside the ram for powerpc +and arm.
-debug-arm-env.txt +ramfs-<arch>.txt ============================ -tftpfdt: for arm only a dummy variable, because we have no fdt on arm +This file defines architecture specific variables for working with rootfs inside +ram. diff --git a/board/keymile/scripts/debug-arm-env.txt b/board/keymile/scripts/debug-arm-env.txt deleted file mode 100644 index 84498af..0000000 --- a/board/keymile/scripts/debug-arm-env.txt +++ /dev/null @@ -1,2 +0,0 @@ -debug_env_common=tftpboot 0x200000 scripts/debug-common-env.txt && env import -t 0x200000 ${filesize} -tftpfdt=true diff --git a/board/keymile/scripts/debug-common-env.txt b/board/keymile/scripts/debug-common-env.txt deleted file mode 100644 index 1fd4b0c..0000000 --- a/board/keymile/scripts/debug-common-env.txt +++ /dev/null @@ -1,9 +0,0 @@ -addramfs=setenv bootargs "${bootargs} phram.phram=rootfs${boot_bank},${rootfsaddr},${rootfssize}" -develop=setenv subbootcmds "tftpfdt tftpkernel nfsargs ${commonargs} boot " && setenv bootcmd 'run bootrunner' && setenv altbootcmd 'run bootcmd' && km_setboardid && saveenv && reset -nfsargs=setenv bootargs ubi.mtd=ubi0 root=/dev/nfs rw nfsroot=${serverip}:${rootpath} -ramfs=setenv actual_bank -1 && setenv subbootcmds "tftpfdt tftpkernel setrootfsaddr tftpramfs flashargs ${commonargs} addpanic addramfs boot " && setenv bootcmd 'run bootrunner' && setenv altbootcmd 'run bootcmd' && run setboardid && run setramfspram && run setpnvramaddr && saveenv && reset -rootfsfile=${hostname}/rootfsImage -setramfspram=setexpr value 0 + ${reservedpram} && setexpr value 0x${value} + ${rootfssize} && setexpr value 0x${value} + ${varsize} && setexpr value 0x${value} + ${pnvramsize} && setexpr value 0x${value} / 0x400 && setenv pram 0x${value} -tftpkernel=tftpboot ${kernel_addr_r} ${hostname}/uImage && setenv actual_kernel_addr ${kernel_addr_r} -tftpramfs=tftpboot ${rootfsaddr} ${hostname}/rootfsImage && setenv loadaddr -setrootfsaddr=setexpr value ${pnvramsize} - ${rootfssize} && setenv rootfsaddr 0x${value} diff --git a/board/keymile/scripts/debug-ppc-env.txt b/board/keymile/scripts/debug-ppc-env.txt deleted file mode 100644 index 3c06ff1..0000000 --- a/board/keymile/scripts/debug-ppc-env.txt +++ /dev/null @@ -1,2 +0,0 @@ -debug_env_common=tftpboot 0x200000 scripts/debug-common-env.txt && env import -t 0x200000 ${filesize} -tftpfdt=tftpboot ${fdt_addr_r} ${hostname}/${hostname}.dtb && setenv actual_fdt_addr ${fdt_addr_r} diff --git a/board/keymile/scripts/develop-arm.txt b/board/keymile/scripts/develop-arm.txt new file mode 100644 index 0000000..922afea --- /dev/null +++ b/board/keymile/scripts/develop-arm.txt @@ -0,0 +1,2 @@ +setup_debug_env=tftpboot 0x200000 scripts/develop-common.txt && env import -t 0x200000 ${filesize} && run configure +tftpfdt=true diff --git a/board/keymile/scripts/develop-common.txt b/board/keymile/scripts/develop-common.txt new file mode 100644 index 0000000..3ccd039 --- /dev/null +++ b/board/keymile/scripts/develop-common.txt @@ -0,0 +1,6 @@ +altbootcmd=run ${subbootcmds} +bootcmd=run ${subbootcmds} +configure=km_setboardid && saveenv && reset +subbootcmds=tftpfdt tftpkernel nfsargs add_default boot +nfsargs=setenv bootargs root=/dev/nfs rw nfsroot=${serverip}:/opt/eldk/${arch} +tftpkernel=tftpboot ${load_addr_r} ${hostname}/uImage diff --git a/board/keymile/scripts/develop-ppc_82xx.txt b/board/keymile/scripts/develop-ppc_82xx.txt new file mode 100644 index 0000000..909f6a3 --- /dev/null +++ b/board/keymile/scripts/develop-ppc_82xx.txt @@ -0,0 +1,2 @@ +setup_debug_env=tftpboot 0x200000 scripts/develop-common.txt && env import -t 0x200000 ${filesize} && run configure +tftpfdt=tftpboot ${fdt_addr_r} ${hostname}/${hostname}.dtb diff --git a/board/keymile/scripts/develop-ppc_8xx.txt b/board/keymile/scripts/develop-ppc_8xx.txt new file mode 100644 index 0000000..909f6a3 --- /dev/null +++ b/board/keymile/scripts/develop-ppc_8xx.txt @@ -0,0 +1,2 @@ +setup_debug_env=tftpboot 0x200000 scripts/develop-common.txt && env import -t 0x200000 ${filesize} && run configure +tftpfdt=tftpboot ${fdt_addr_r} ${hostname}/${hostname}.dtb diff --git a/board/keymile/scripts/ramfs-arm.txt b/board/keymile/scripts/ramfs-arm.txt new file mode 100644 index 0000000..79974f1 --- /dev/null +++ b/board/keymile/scripts/ramfs-arm.txt @@ -0,0 +1,2 @@ +setup_debug_env=tftpboot 0x200000 scripts/ramfs-common.txt && env import -t 0x200000 ${filesize} && run configure +tftpfdt=true diff --git a/board/keymile/scripts/ramfs-common.txt b/board/keymile/scripts/ramfs-common.txt new file mode 100644 index 0000000..9315500 --- /dev/null +++ b/board/keymile/scripts/ramfs-common.txt @@ -0,0 +1,12 @@ +addramfs=setenv bootargs "${bootargs} mem=${rootfsaddr} phram.phram=rootfs${boot_bank},${rootfsaddr},${rootfssize}" +actual_bank=-1 +altbootcmd=run ${subbootcmds} +bootcmd=run ${subbootcmds} +subbootcmds=tftpfdt tftpkernel setrootfsaddr tftpramfs flashargs add_default addpanic addramfs boot +nfsargs=setenv bootargs root=/dev/nfs rw nfsroot=${serverip}:${rootpath} +configure=km_setboardid && run setramfspram && saveenv && reset +setramfspram=setexpr value 0 + ${rootfssize} && setexpr value 0x${value} / 0x400 && setexpr value 0x${value} + ${pram} && setenv pram 0x${value} +rootfsfile=${hostname}/rootfsImage +setrootfsaddr=setexpr value ${pnvramaddr} - ${rootfssize} && setenv rootfsaddr 0x${value} +tftpkernel=tftpboot ${load_addr_r} ${hostname}/uImage +tftpramfs=tftpboot ${rootfsaddr} ${hostname}/rootfsImage diff --git a/board/keymile/scripts/ramfs-ppc_82xx.txt b/board/keymile/scripts/ramfs-ppc_82xx.txt new file mode 100644 index 0000000..970927a --- /dev/null +++ b/board/keymile/scripts/ramfs-ppc_82xx.txt @@ -0,0 +1,2 @@ +setup_debug_env=tftpboot 0x200000 scripts/ramfs-common.txt && env import -t 0x200000 ${filesize} && run configure +tftpfdt=tftpboot ${fdt_addr_r} ${hostname}/${hostname}.dtb diff --git a/board/keymile/scripts/ramfs-ppc_8xx.txt b/board/keymile/scripts/ramfs-ppc_8xx.txt new file mode 100644 index 0000000..970927a --- /dev/null +++ b/board/keymile/scripts/ramfs-ppc_8xx.txt @@ -0,0 +1,2 @@ +setup_debug_env=tftpboot 0x200000 scripts/ramfs-common.txt && env import -t 0x200000 ${filesize} && run configure +tftpfdt=tftpboot ${fdt_addr_r} ${hostname}/${hostname}.dtb diff --git a/include/configs/km/keymile-common.h b/include/configs/km/keymile-common.h index c40a541..c0df6d8 100644 --- a/include/configs/km/keymile-common.h +++ b/include/configs/km/keymile-common.h @@ -159,10 +159,14 @@ #define CONFIG_KM_DEF_ENV_BOOTTARGETS \ "subbootcmds=ubiattach ubicopy cramfsloadfdt cramfsloadkernel " \ "flashargs add_default addpanic boot\0" \ - "debug_env=" \ - "tftp 200000 " CONFIG_KM_ARCH_DBG_FILE " && " \ + "develop=" \ + "tftp 200000 scripts/develop-${arch}.txt && " \ "env import -t 200000 ${filesize} && " \ - "run debug_env_common\0" \ + "run setup_debug_env\0" \ + "ramfs=" \ + "tftp 200000 scripts/ramfs-${arch}.txt && " \ + "env import -t 200000 ${filesize} && " \ + "run setup_debug_env\0" \ ""
/* diff --git a/include/configs/km/km-powerpc.h b/include/configs/km/km-powerpc.h index 7aaa8d2..4cec57c 100644 --- a/include/configs/km/km-powerpc.h +++ b/include/configs/km/km-powerpc.h @@ -83,6 +83,4 @@ "protect on " xstr(BOOTFLASH_START) " +${filesize}\0" \ ""
-#define CONFIG_KM_ARCH_DBG_FILE "scripts/debug-ppc-env.txt" - #endif /* __CONFIG_KEYMILE_POWERPC_H */ diff --git a/include/configs/km/km82xx-common.h b/include/configs/km/km82xx-common.h index 446c1d0..b89631c 100644 --- a/include/configs/km/km82xx-common.h +++ b/include/configs/km/km82xx-common.h @@ -87,7 +87,7 @@ "newenv=" \ "prot off 0xFE0C0000 +0x40000 && " \ "era 0xFE0C0000 +0x40000\0" \ - "rootpath=/opt/eldk/ppc_82xx\0" \ + "arch=ppc_82xx\0" \ ""
#define CONFIG_SYS_MONITOR_BASE CONFIG_SYS_TEXT_BASE diff --git a/include/configs/km/km8321-common.h b/include/configs/km/km8321-common.h index 6fab45e..902ae26 100644 --- a/include/configs/km/km8321-common.h +++ b/include/configs/km/km8321-common.h @@ -33,8 +33,7 @@ #define CONFIG_MPC832x /* MPC832x CPU specific */ #define CONFIG_KM8321 /* Keymile PBEC8321 board specific */
-#define CONFIG_KM_DEF_ROOTPATH \ - "rootpath=/opt/eldk/ppc_8xx\0" +#define CONFIG_KM_DEF_ARCH "arch=ppc_8xx\0"
/* include common defines/options for all 83xx Keymile boards */ #include "km83xx-common.h" diff --git a/include/configs/km/km83xx-common.h b/include/configs/km/km83xx-common.h index 85b6ed2..2b1a84a 100644 --- a/include/configs/km/km83xx-common.h +++ b/include/configs/km/km83xx-common.h @@ -302,14 +302,13 @@ #define CONFIG_KM_DEF_ENV "km-common=empty\0" #endif
-#ifndef CONFIG_KM_DEF_ROOTPATH -#define CONFIG_KM_DEF_ROOTPATH \ - "rootpath=/opt/eldk/ppc_82xx\0" +#ifndef CONFIG_KM_DEF_ARCH +#define CONFIG_KM_DEF_ARCH "arch=ppc_82xx\0" #endif
#define CONFIG_EXTRA_ENV_SETTINGS \ CONFIG_KM_DEF_ENV \ - CONFIG_KM_DEF_ROOTPATH \ + CONFIG_KM_DEF_ARCH \ "dtt_bus=pca9547:70:a\0" \ "EEprom_ivm=pca9547:70:9\0" \ "newenv=" \ diff --git a/include/configs/km/km_arm.h b/include/configs/km/km_arm.h index 7eb5cd4..23717f4 100644 --- a/include/configs/km/km_arm.h +++ b/include/configs/km/km_arm.h @@ -77,8 +77,6 @@ CONFIG_KM_DEF_ENV_UPDATE \ ""
-#define CONFIG_KM_ARCH_DBG_FILE "scripts/debug-arm-env.txt" - #define CONFIG_SKIP_LOWLEVEL_INIT /* disable board lowlevel_init */ #define CONFIG_MISC_INIT_R
@@ -243,7 +241,7 @@ int get_scl(void); " ${addr} " xstr(CONFIG_ENV_OFFSET) " 4 && " \ "eeprom write " xstr(CONFIG_SYS_DEF_EEPROM_ADDR) \ " ${addr} " xstr(CONFIG_ENV_OFFSET_REDUND) " 4\0" \ - "rootpath=/opt/eldk/arm\0" \ + "arch=arm\0" \ "EEprom_ivm=" KM_IVM_BUS "\0" \ ""

Dear Holger Brunck,
In message 1309852372-23481-1-git-send-email-holger.brunck@keymile.com you wrote:
The debug environment which is stored in textfiles in the scripts directory was reworked. Two usecase are now present which can be executed simply from the default environment: run develop: this configures the environment to setup the rootfs via nfs run ramfs: this configures the environment to setup the rootfs in ram
Each architecture now has a "arch" variable which is used to load the architecture specific debug scripts and to set the rootpath for NFS.
Signed-off-by: Holger Brunck holger.brunck@keymile.com Signed-off-by: Valentin Longchamp valentin.longchamp@keymile.com cc: Heiko Schocher hs@denx.de cc: Wolfgang Denk wd@denx.de
Changes for v2:
- rebased to current HEAD
board/keymile/scripts/README | 42 ++++++++++++++++----------- board/keymile/scripts/debug-arm-env.txt | 2 - board/keymile/scripts/debug-common-env.txt | 9 ------ board/keymile/scripts/debug-ppc-env.txt | 2 - board/keymile/scripts/develop-arm.txt | 2 + board/keymile/scripts/develop-common.txt | 6 ++++ board/keymile/scripts/develop-ppc_82xx.txt | 2 + board/keymile/scripts/develop-ppc_8xx.txt | 2 + board/keymile/scripts/ramfs-arm.txt | 2 + board/keymile/scripts/ramfs-common.txt | 12 ++++++++ board/keymile/scripts/ramfs-ppc_82xx.txt | 2 + board/keymile/scripts/ramfs-ppc_8xx.txt | 2 + include/configs/km/keymile-common.h | 10 ++++-- include/configs/km/km-powerpc.h | 2 - include/configs/km/km82xx-common.h | 2 +- include/configs/km/km8321-common.h | 3 +- include/configs/km/km83xx-common.h | 7 ++-- include/configs/km/km_arm.h | 4 +-- 18 files changed, 68 insertions(+), 45 deletions(-) delete mode 100644 board/keymile/scripts/debug-arm-env.txt delete mode 100644 board/keymile/scripts/debug-common-env.txt delete mode 100644 board/keymile/scripts/debug-ppc-env.txt create mode 100644 board/keymile/scripts/develop-arm.txt create mode 100644 board/keymile/scripts/develop-common.txt create mode 100644 board/keymile/scripts/develop-ppc_82xx.txt create mode 100644 board/keymile/scripts/develop-ppc_8xx.txt create mode 100644 board/keymile/scripts/ramfs-arm.txt create mode 100644 board/keymile/scripts/ramfs-common.txt create mode 100644 board/keymile/scripts/ramfs-ppc_82xx.txt create mode 100644 board/keymile/scripts/ramfs-ppc_8xx.txt
Applied, thanks.
Best regards,
Wolfgang Denk

These defines and the header keymile_hdlc_enet.h are obsolete due to the removed hdlc code.
Signed-off-by: Holger Brunck holger.brunck@keymile.com Signed-off-by: Valentin Longchamp valentin.longchamp@keymile.com cc: Heiko Schocher hs@denx.de cc: Wolfgang Denk wd@denx.de --- board/keymile/common/keymile_hdlc_enet.h | 129 ------------------------------ include/configs/km/keymile-common.h | 10 --- 2 files changed, 0 insertions(+), 139 deletions(-) delete mode 100644 board/keymile/common/keymile_hdlc_enet.h
diff --git a/board/keymile/common/keymile_hdlc_enet.h b/board/keymile/common/keymile_hdlc_enet.h deleted file mode 100644 index db1560f..0000000 --- a/board/keymile/common/keymile_hdlc_enet.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * (C) Copyright 2008 - * Gary Jennejohn, DENX Software Engineering GmbH, garyj@denx.de. - * - * See file CREDITS for list of people who contributed to this - * project. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, - * MA 02111-1307 USA - */ - -#ifndef _KEYMILE_HDLC_ENET_H_ -#define _KEYMILE_HDLC_ENET_H_ - -/* Unfortuantely, we have do this to get the flag defines in the cbd_t */ -#ifdef CONFIG_KM8XX -#include <commproc.h> -#endif -#ifdef CONFIG_MGCOGE -#include <mpc8260.h> -#include <asm/cpm_8260.h> -#endif - -/* - * Defines for the ICN protocol used for communication over HDLC - * on the backplane between MGSUVDs and MGCOGEs. - */ - -/* - * MAC which is reserved for communication (0x00 - 0xff in the last byte, - * which is the slot number) - */ - -/* - * A DLL frame looks like this: - * 8 bit | 8 bit | 8 bit | 8 bit | n * 8 bit| 16 bit| 8 bit - * opening| destination| source | application| data | FCS | closing - * flag | address | address| | | | flag - * (HW) (APP) (APP) (APP) (APP) (HW) (HW) - */ - -/* - * The opening flag, the FCS and the closing flag are set by the hardware so - * they are not reflected in this struct. - */ -struct icn_hdr { - unsigned char dest_addr; - unsigned char src_addr; - unsigned char application; -} __attribute__((packed)); - -#define ICNHDR_LEN (sizeof(struct icn_hdr)) -#define CRC_LEN (sizeof(short)) -/* bytes to remove from packet before sending it upstream */ -#define REMOVE (ICNHDR_LEN + CRC_LEN) - -struct icn_frame { - struct icn_hdr hdr; - unsigned char data[0]; /* a place holder */ -} __attribute__((packed)); - -/* Address field */ -#define HDLC_UUA 0x00 /* Unicast Unit Address */ -#define HDLC_UUA_MASK 0x3f /* the last 6 bits contain the slot number */ -#define SET_HDLC_UUA(x) ((HDLC_UUA | ((x) & HDLC_UUA_MASK))) -#define HDLC_UACUA 0x7f /* Unicast Active Control Unit Address */ -#define HDLC_BCAST 0xff /* broadcast */ - -/* Application field */ -#define MGS_UUSP 0x00 -#define MGS_UREP 0x01 -#define MGS_IUP 0x02 -#define MGS_UTA 0x03 -#define MGS_MDS 0x04 -#define MGS_ITIME 0x05 -/* added by DENX */ -#define MGS_NETCONS 0x06 /* netconsole */ -#define MGS_TFTP 0x07 - -/* Useful defines for buffer sizes, etc. */ -#define HDLC_PKTBUFSRX 32 -#define MAX_FRAME_LENGTH 1500 /* ethernet frame size */ - /* 14 + 28 */ -#define INET_HDR_SIZE (ETHER_HDR_SIZE + IP_HDR_SIZE) -#define INET_HDR_ALIGN (((INET_HDR_SIZE + PKTALIGN - 1) / PKTALIGN) * PKTALIGN) -/* INET_HDR_SIZE is stripped off */ -#define PKT_MAXBLR_SIZE (MAX_FRAME_LENGTH + INET_HDR_ALIGN) - -/* - * It is too slow to read always the port numbers and IP addresses from the - * string variables. - * cachedNumbers is meant to cache it. - * THIS IS ONLY A SPEED IMPROVEMENT! - */ -enum { - IP_ADDR = 0, /* getenv_IPaddr("serverip"); */ - IP_SERVER, /* getenv_IPaddr("ipaddr"); */ - TFTP_SRC_PORT, /* simple_strtol(getenv("tftpsrcp"), NULL, 10); */ - TFTP_DST_PORT, /* simple_strtol(getenv("tftpdstp"), NULL, 10); */ - NETCONS_PORT, /* simple_strtol(getenv("ncip"), NULL, 10); */ - CACHEDNUMBERS -}; - -#define WELL_KNOWN_PORT 69 /* Well known TFTP port # */ - -/* define this to create a test commend (htest) */ -#undef TEST_IT -#ifdef TEST_IT -/* have to save a copy of the eth_device for the test command's use */ -struct eth_device *seth; -#endif -/* define this for outputting of received packets */ -#undef TEST_RX -/* define this for outputting of packets being sent */ -#undef TEST_TX - -#endif /* _KEYMILE_HDLC_ENET_H_ */ diff --git a/include/configs/km/keymile-common.h b/include/configs/km/keymile-common.h index c0df6d8..89a652f 100644 --- a/include/configs/km/keymile-common.h +++ b/include/configs/km/keymile-common.h @@ -83,16 +83,6 @@ #define CONFIG_SYS_LOADS_BAUD_CHANGE #define CONFIG_SYS_BOARD_DRAM_INIT /* Used board specific dram_init */
-/* - * How to get access to the slot ID. Put this here to make it easy - * to modify in a centralized location. This is used in the HDLC - * driver to set the MAC. -*/ -#define CONFIG_CHECK_ETHERNET_PRESENT -#define CONFIG_SYS_SLOT_ID_BASE CONFIG_SYS_KMBEC_FPGA_BASE -#define CONFIG_SYS_SLOT_ID_OFF (0x07) /* register offset */ -#define CONFIG_SYS_SLOT_ID_MASK (0x3f) /* mask for slot ID bits */ - #define CONFIG_I2C_MULTI_BUS #define CONFIG_SYS_MAX_I2C_BUS 1 #define CONFIG_SYS_I2C_INIT_BOARD

Dear Holger Brunck,
In message 1307348541-2466-5-git-send-email-holger.brunck@keymile.com you wrote:
These defines and the header keymile_hdlc_enet.h are obsolete due to the removed hdlc code.
Signed-off-by: Holger Brunck holger.brunck@keymile.com Signed-off-by: Valentin Longchamp valentin.longchamp@keymile.com cc: Heiko Schocher hs@denx.de cc: Wolfgang Denk wd@denx.de
board/keymile/common/keymile_hdlc_enet.h | 129 ------------------------------ include/configs/km/keymile-common.h | 10 --- 2 files changed, 0 insertions(+), 139 deletions(-) delete mode 100644 board/keymile/common/keymile_hdlc_enet.h
Applied, thanks.
Best regards,
Wolfgang Denk

The ethaddr is stored inside the inventory eeprom. During boottime this value was read out and the ethaddr variable was set. Previously this was only done if it ethaddr == NULL but this is wrong for our ARM boards. Because ethaddr is at this stage never NULL for ARM due to the random calculation of a MAC address in mvgbe.c.
Signed-off-by: Holger Brunck holger.brunck@keymile.com Signed-off-by: Valentin Longchamp valentin.longchamp@keymile.com cc: Heiko Schocher hs@denx.de cc: Wolfgang Denk wd@denx.de --- board/keymile/common/common.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c index 9be4c72..fef6253 100644 --- a/board/keymile/common/common.c +++ b/board/keymile/common/common.c @@ -278,8 +278,7 @@ static int ivm_analyze_block2(unsigned char *buf, int len) sprintf((char *)valbuf, "%pM", buf); } #endif - if (getenv("ethaddr") == NULL) - setenv((char *)"ethaddr", (char *)valbuf); + setenv((char *)"ethaddr", (char *)valbuf);
/* IVM_MacCount */ count = (buf[10] << 24) +

Dear Holger Brunck,
In message 1307348541-2466-6-git-send-email-holger.brunck@keymile.com you wrote:
The ethaddr is stored inside the inventory eeprom. During boottime this value was read out and the ethaddr variable was set. Previously this was only done if it ethaddr == NULL but this is wrong for our ARM boards. Because ethaddr is at this stage never NULL for ARM due to the random calculation of a MAC address in mvgbe.c.
Signed-off-by: Holger Brunck holger.brunck@keymile.com Signed-off-by: Valentin Longchamp valentin.longchamp@keymile.com cc: Heiko Schocher hs@denx.de cc: Wolfgang Denk wd@denx.de
board/keymile/common/common.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

This is unneeded here because we save the environment when the board boots the first time. At this time we have set the values already.
Signed-off-by: Holger Brunck holger.brunck@keymile.com Signed-off-by: Valentin Longchamp valentin.longchamp@keymile.com cc: Heiko Schocher hs@denx.de cc: Wolfgang Denk wd@denx.de --- board/keymile/common/common.c | 7 +------ 1 files changed, 1 insertions(+), 6 deletions(-)
diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c index fef6253..d8fcd39 100644 --- a/board/keymile/common/common.c +++ b/board/keymile/common/common.c @@ -831,11 +831,7 @@ int do_checkboardidhwk(cmd_tbl_t *cmdtp, int flag, int argc, * Compare the values of the found entry in the * list with the valid values which are stored * in the inventory eeprom. If they are equal - * store the values in environment variables - * and save the environment. - * This can only happen once for the lifetime - * of a board, because once saved the function - * will never reach the while loop. + * set the values in environment variables. */ if ((bid == ivmbid) && (hwkey == ivmhwkey)) { char buf[10]; @@ -847,7 +843,6 @@ int do_checkboardidhwk(cmd_tbl_t *cmdtp, int flag, int argc, setenv("boardid", buf); sprintf(buf, "%lx", hwkey); setenv("hwkey", buf); - saveenv(); } } /* end while( ! found ) */ }

Dear Holger Brunck,
In message 1307348541-2466-7-git-send-email-holger.brunck@keymile.com you wrote:
This is unneeded here because we save the environment when the board boots the first time. At this time we have set the values already.
Signed-off-by: Holger Brunck holger.brunck@keymile.com Signed-off-by: Valentin Longchamp valentin.longchamp@keymile.com cc: Heiko Schocher hs@denx.de cc: Wolfgang Denk wd@denx.de
board/keymile/common/common.c | 7 +------ 1 files changed, 1 insertions(+), 6 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

The file common.c grows in the past. So move the IVM specific code into an ivm.c file.
Signed-off-by: Holger Brunck holger.brunck@keymile.com Signed-off-by: Valentin Longchamp valentin.longchamp@keymile.com cc: Heiko Schocher hs@denx.de cc: Wolfgang Denk wd@denx.de --- board/keymile/common/common.c | 324 +-------------------------------------- board/keymile/common/common.h | 1 + board/keymile/common/ivm.c | 342 +++++++++++++++++++++++++++++++++++++++++ board/keymile/km82xx/Makefile | 2 +- board/keymile/km83xx/Makefile | 2 +- board/keymile/km_arm/Makefile | 2 +- 6 files changed, 352 insertions(+), 321 deletions(-) create mode 100644 board/keymile/common/ivm.c
diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c index d8fcd39..010e969 100644 --- a/board/keymile/common/common.c +++ b/board/keymile/common/common.c @@ -2,6 +2,9 @@ * (C) Copyright 2008 * Heiko Schocher, DENX Software Engineering, hs@denx.de. * + * (C) Copyright 2011 + * Holger Brunck, Keymile GmbH Hannover, holger.brunck@keymile.com + * * See file CREDITS for list of people who contributed to this * project. * @@ -38,44 +41,13 @@ #include <libfdt.h> #endif
-#include "../common/common.h" +#include "common.h" #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) #include <i2c.h>
static void i2c_write_start_seq(void); -static int i2c_make_abort(void); DECLARE_GLOBAL_DATA_PTR;
-int ivm_calc_crc(unsigned char *buf, int len) -{ - const unsigned short crc_tab[16] = { - 0x0000, 0xCC01, 0xD801, 0x1400, - 0xF001, 0x3C00, 0x2800, 0xE401, - 0xA001, 0x6C00, 0x7800, 0xB401, - 0x5000, 0x9C01, 0x8801, 0x4400}; - - unsigned short crc = 0; /* final result */ - unsigned short r1 = 0; /* temp */ - unsigned char byte = 0; /* input buffer */ - int i; - - /* calculate CRC from array data */ - for (i = 0; i < len; i++) { - byte = buf[i]; - - /* lower 4 bits */ - r1 = crc_tab[crc & 0xF]; - crc = ((crc) >> 4) & 0x0FFF; - crc = crc ^ r1 ^ crc_tab[byte & 0xF]; - - /* upper 4 bits */ - r1 = crc_tab[crc & 0xF]; - crc = (crc >> 4) & 0x0FFF; - crc = crc ^ r1 ^ crc_tab[(byte >> 4) & 0xF]; - } - return crc; -} - /* * Set Keymile specific environment variables * Currently only some memory layout variables are calculated here @@ -111,290 +83,6 @@ int set_km_env(void) return 0; }
-static int ivm_set_value(char *name, char *value) -{ - char tempbuf[256]; - - if (value != NULL) { - sprintf(tempbuf, "%s=%s", name, value); - return set_local_var(tempbuf, 0); - } else { - unset_local_var(name); - } - return 0; -} - -static int ivm_get_value(unsigned char *buf, int len, char *name, int off, - int check) -{ - unsigned short val; - unsigned char valbuf[30]; - - if ((buf[off + 0] != buf[off + 2]) && - (buf[off + 2] != buf[off + 4])) { - printf("%s Error corrupted %s\n", __func__, name); - val = -1; - } else { - val = buf[off + 0] + (buf[off + 1] << 8); - if ((val == 0) && (check == 1)) - val = -1; - } - sprintf((char *)valbuf, "%x", val); - ivm_set_value(name, (char *)valbuf); - return val; -} - -#define INV_BLOCKSIZE 0x100 -#define INV_DATAADDRESS 0x21 -#define INVENTORYDATASIZE (INV_BLOCKSIZE - INV_DATAADDRESS - 3) - -#define IVM_POS_SHORT_TEXT 0 -#define IVM_POS_MANU_ID 1 -#define IVM_POS_MANU_SERIAL 2 -#define IVM_POS_PART_NUMBER 3 -#define IVM_POS_BUILD_STATE 4 -#define IVM_POS_SUPPLIER_PART_NUMBER 5 -#define IVM_POS_DELIVERY_DATE 6 -#define IVM_POS_SUPPLIER_BUILD_STATE 7 -#define IVM_POS_CUSTOMER_ID 8 -#define IVM_POS_CUSTOMER_PROD_ID 9 -#define IVM_POS_HISTORY 10 -#define IVM_POS_SYMBOL_ONLY 11 - -static char convert_char(char c) -{ - return (c < ' ' || c > '~') ? '.' : c; -} - -static int ivm_findinventorystring(int type, - unsigned char* const string, - unsigned long maxlen, - unsigned char *buf) -{ - int xcode = 0; - unsigned long cr = 0; - unsigned long addr = INV_DATAADDRESS; - unsigned long size = 0; - unsigned long nr = type; - int stop = 0; /* stop on semicolon */ - - memset(string, '\0', maxlen); - switch (type) { - case IVM_POS_SYMBOL_ONLY: - nr = 0; - stop= 1; - break; - default: - nr = type; - stop = 0; - } - - /* Look for the requested number of CR. */ - while ((cr != nr) && (addr < INVENTORYDATASIZE)) { - if ((buf[addr] == '\r')) { - cr++; - } - addr++; - } - - /* - * the expected number of CR was found until the end of the IVM - * content --> fill string - */ - if (addr < INVENTORYDATASIZE) { - /* Copy the IVM string in the corresponding string */ - for (; (buf[addr] != '\r') && - ((buf[addr] != ';') || (!stop)) && - (size < (maxlen - 1) && - (addr < INVENTORYDATASIZE)); addr++) - { - size += sprintf((char *)string + size, "%c", - convert_char (buf[addr])); - } - - /* - * copy phase is done: check if everything is ok. If not, - * the inventory data is most probably corrupted: tell - * the world there is a problem! - */ - if (addr == INVENTORYDATASIZE) { - xcode = -1; - printf("Error end of string not found\n"); - } else if ((size >= (maxlen - 1)) && - (buf[addr] != '\r')) { - xcode = -1; - printf("string too long till next CR\n"); - } - } else { - /* - * some CR are missing... - * the inventory data is most probably corrupted - */ - xcode = -1; - printf("not enough cr found\n"); - } - return xcode; -} - -#define GET_STRING(name, which, len) \ - if (ivm_findinventorystring(which, valbuf, len, buf) == 0) { \ - ivm_set_value(name, (char *)valbuf); \ - } - -static int ivm_check_crc(unsigned char *buf, int block) -{ - unsigned long crc; - unsigned long crceeprom; - - crc = ivm_calc_crc(buf, CONFIG_SYS_IVM_EEPROM_PAGE_LEN - 2); - crceeprom = (buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN - 1] + \ - buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN - 2] * 256); - if (crc != crceeprom) { - if (block == 0) - printf("Error CRC Block: %d EEprom: calculated: \ - %lx EEprom: %lx\n", block, crc, crceeprom); - return -1; - } - return 0; -} - -static int ivm_analyze_block2(unsigned char *buf, int len) -{ - unsigned char valbuf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN]; - unsigned long count; - - /* IVM_MacAddress */ - sprintf((char *)valbuf, "%pM", buf); - ivm_set_value("IVM_MacAddress", (char *)valbuf); - /* if an offset is defined, add it */ -#if defined(CONFIG_PIGGY_MAC_ADRESS_OFFSET) - if (CONFIG_PIGGY_MAC_ADRESS_OFFSET > 0) { - unsigned long val = (buf[4] << 16) + (buf[5] << 8) + buf[6]; - - val += CONFIG_PIGGY_MAC_ADRESS_OFFSET; - buf[4] = (val >> 16) & 0xff; - buf[5] = (val >> 8) & 0xff; - buf[6] = val & 0xff; - sprintf((char *)valbuf, "%pM", buf); - } -#endif - setenv((char *)"ethaddr", (char *)valbuf); - - /* IVM_MacCount */ - count = (buf[10] << 24) + - (buf[11] << 16) + - (buf[12] << 8) + - buf[13]; - if (count == 0xffffffff) - count = 1; - sprintf((char *)valbuf, "%lx", count); - ivm_set_value("IVM_MacCount", (char *)valbuf); - return 0; -} - -int ivm_analyze_eeprom(unsigned char *buf, int len) -{ - unsigned short val; - unsigned char valbuf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN]; - unsigned char *tmp; - - if (ivm_check_crc(buf, 0) != 0) - return -1; - - ivm_get_value(buf, CONFIG_SYS_IVM_EEPROM_PAGE_LEN, - "IVM_BoardId", 0, 1); - val = ivm_get_value(buf, CONFIG_SYS_IVM_EEPROM_PAGE_LEN, - "IVM_HWKey", 6, 1); - if (val != 0xffff) { - sprintf((char *)valbuf, "%x", ((val / 100) % 10)); - ivm_set_value("IVM_HWVariant", (char *)valbuf); - sprintf((char *)valbuf, "%x", (val % 100)); - ivm_set_value("IVM_HWVersion", (char *)valbuf); - } - ivm_get_value(buf, CONFIG_SYS_IVM_EEPROM_PAGE_LEN, - "IVM_Functions", 12, 0); - - GET_STRING("IVM_Symbol", IVM_POS_SYMBOL_ONLY, 8) - GET_STRING("IVM_DeviceName", IVM_POS_SHORT_TEXT, 64) - tmp = (unsigned char *) getenv("IVM_DeviceName"); - if (tmp) { - int len = strlen((char *)tmp); - int i = 0; - - while (i < len) { - if (tmp[i] == ';') { - ivm_set_value("IVM_ShortText", - (char *)&tmp[i + 1]); - break; - } - i++; - } - if (i >= len) - ivm_set_value("IVM_ShortText", NULL); - } else { - ivm_set_value("IVM_ShortText", NULL); - } - GET_STRING("IVM_ManufacturerID", IVM_POS_MANU_ID, 32) - GET_STRING("IVM_ManufacturerSerialNumber", IVM_POS_MANU_SERIAL, 20) - GET_STRING("IVM_ManufacturerPartNumber", IVM_POS_PART_NUMBER, 32) - GET_STRING("IVM_ManufacturerBuildState", IVM_POS_BUILD_STATE, 32) - GET_STRING("IVM_SupplierPartNumber", IVM_POS_SUPPLIER_PART_NUMBER, 32) - GET_STRING("IVM_DelieveryDate", IVM_POS_DELIVERY_DATE, 32) - GET_STRING("IVM_SupplierBuildState", IVM_POS_SUPPLIER_BUILD_STATE, 32) - GET_STRING("IVM_CustomerID", IVM_POS_CUSTOMER_ID, 32) - GET_STRING("IVM_CustomerProductID", IVM_POS_CUSTOMER_PROD_ID, 32) - - if (ivm_check_crc(&buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN * 2], 2) != 0) - return 0; - ivm_analyze_block2(&buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN * 2], - CONFIG_SYS_IVM_EEPROM_PAGE_LEN); - - return 0; -} - -int ivm_read_eeprom(void) -{ -#if defined(CONFIG_I2C_MUX) - I2C_MUX_DEVICE *dev = NULL; -#endif - uchar i2c_buffer[CONFIG_SYS_IVM_EEPROM_MAX_LEN]; - uchar *buf; - unsigned dev_addr = CONFIG_SYS_IVM_EEPROM_ADR; - int ret; - -#if defined(CONFIG_I2C_MUX) - /* First init the Bus, select the Bus */ -#if defined(CONFIG_SYS_I2C_IVM_BUS) - dev = i2c_mux_ident_muxstring((uchar *)CONFIG_SYS_I2C_IVM_BUS); -#else - buf = (unsigned char *) getenv("EEprom_ivm"); - if (buf != NULL) - dev = i2c_mux_ident_muxstring(buf); -#endif - if (dev == NULL) { - printf("Error couldnt add Bus for IVM\n"); - return -1; - } - i2c_set_bus_num(dev->busid); -#endif - - buf = (unsigned char *) getenv("EEprom_ivm_addr"); - if (buf != NULL) - dev_addr = simple_strtoul((char *)buf, NULL, 16); - - /* add deblocking here */ - i2c_make_abort(); - - ret = i2c_read(dev_addr, 0, 1, i2c_buffer, - CONFIG_SYS_IVM_EEPROM_MAX_LEN); - if (ret != 0) { - printf ("Error reading EEprom\n"); - return -2; - } - - return ivm_analyze_eeprom(i2c_buffer, CONFIG_SYS_IVM_EEPROM_MAX_LEN); -} - #if defined(CONFIG_SYS_I2C_INIT_BOARD) #define DELAY_ABORT_SEQ 62 /* @200kHz 9 clocks = 44us, 62us is ok */ #define DELAY_HALF_PERIOD (500 / (CONFIG_SYS_I2C_SPEED / 1000)) @@ -480,7 +168,7 @@ static void i2c_write_start_seq(void) * This I2C Deblocking mechanism was developed by Keymile in association * with Anatech and Atmel in 1998. */ -static int i2c_make_abort(void) +int i2c_make_abort(void) {
#if defined(CONFIG_HARD_I2C) && !defined(MACH_TYPE_KM_KIRKWOOD) @@ -548,7 +236,7 @@ static void i2c_write_start_seq(void) out_8(&dev->cr, (I2C_CR_MEN)); }
-static int i2c_make_abort(void) +int i2c_make_abort(void) { struct fsl_i2c *dev; dev = (struct fsl_i2c *) (CONFIG_SYS_IMMR + CONFIG_SYS_I2C_OFFSET); diff --git a/board/keymile/common/common.h b/board/keymile/common/common.h index cee24d4..edf6e3a 100644 --- a/board/keymile/common/common.h +++ b/board/keymile/common/common.h @@ -138,4 +138,5 @@ int fdt_get_node_and_value(void *blob, void **var);
int i2c_soft_read_pin(void); +int i2c_make_abort(void); #endif /* __KEYMILE_COMMON_H */ diff --git a/board/keymile/common/ivm.c b/board/keymile/common/ivm.c new file mode 100644 index 0000000..d0cb0d2 --- /dev/null +++ b/board/keymile/common/ivm.c @@ -0,0 +1,342 @@ +/* + * (C) Copyright 2011 + * Holger Brunck, Keymile GmbH Hannover, holger.brunck@keymile.com + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <common.h> +#include <hush.h> +#include <i2c.h> +#include "common.h" + +int ivm_calc_crc(unsigned char *buf, int len) +{ + const unsigned short crc_tab[16] = { + 0x0000, 0xCC01, 0xD801, 0x1400, + 0xF001, 0x3C00, 0x2800, 0xE401, + 0xA001, 0x6C00, 0x7800, 0xB401, + 0x5000, 0x9C01, 0x8801, 0x4400}; + + unsigned short crc = 0; /* final result */ + unsigned short r1 = 0; /* temp */ + unsigned char byte = 0; /* input buffer */ + int i; + + /* calculate CRC from array data */ + for (i = 0; i < len; i++) { + byte = buf[i]; + + /* lower 4 bits */ + r1 = crc_tab[crc & 0xF]; + crc = ((crc) >> 4) & 0x0FFF; + crc = crc ^ r1 ^ crc_tab[byte & 0xF]; + + /* upper 4 bits */ + r1 = crc_tab[crc & 0xF]; + crc = (crc >> 4) & 0x0FFF; + crc = crc ^ r1 ^ crc_tab[(byte >> 4) & 0xF]; + } + return crc; +} + +static int ivm_set_value(char *name, char *value) +{ + char tempbuf[256]; + + if (value != NULL) { + sprintf(tempbuf, "%s=%s", name, value); + return set_local_var(tempbuf, 0); + } else { + unset_local_var(name); + } + return 0; +} + +static int ivm_get_value(unsigned char *buf, int len, char *name, int off, + int check) +{ + unsigned short val; + unsigned char valbuf[30]; + + if ((buf[off + 0] != buf[off + 2]) && + (buf[off + 2] != buf[off + 4])) { + printf("%s Error corrupted %s\n", __func__, name); + val = -1; + } else { + val = buf[off + 0] + (buf[off + 1] << 8); + if ((val == 0) && (check == 1)) + val = -1; + } + sprintf((char *)valbuf, "%x", val); + ivm_set_value(name, (char *)valbuf); + return val; +} + +#define INV_BLOCKSIZE 0x100 +#define INV_DATAADDRESS 0x21 +#define INVENTORYDATASIZE (INV_BLOCKSIZE - INV_DATAADDRESS - 3) + +#define IVM_POS_SHORT_TEXT 0 +#define IVM_POS_MANU_ID 1 +#define IVM_POS_MANU_SERIAL 2 +#define IVM_POS_PART_NUMBER 3 +#define IVM_POS_BUILD_STATE 4 +#define IVM_POS_SUPPLIER_PART_NUMBER 5 +#define IVM_POS_DELIVERY_DATE 6 +#define IVM_POS_SUPPLIER_BUILD_STATE 7 +#define IVM_POS_CUSTOMER_ID 8 +#define IVM_POS_CUSTOMER_PROD_ID 9 +#define IVM_POS_HISTORY 10 +#define IVM_POS_SYMBOL_ONLY 11 + +static char convert_char(char c) +{ + return (c < ' ' || c > '~') ? '.' : c; +} + +static int ivm_findinventorystring(int type, + unsigned char *const string, + unsigned long maxlen, + unsigned char *buf) +{ + int xcode = 0; + unsigned long cr = 0; + unsigned long addr = INV_DATAADDRESS; + unsigned long size = 0; + unsigned long nr = type; + int stop = 0; /* stop on semicolon */ + + memset(string, '\0', maxlen); + switch (type) { + case IVM_POS_SYMBOL_ONLY: + nr = 0; + stop = 1; + break; + default: + nr = type; + stop = 0; + } + + /* Look for the requested number of CR. */ + while ((cr != nr) && (addr < INVENTORYDATASIZE)) { + if ((buf[addr] == '\r')) + cr++; + addr++; + } + + /* + * the expected number of CR was found until the end of the IVM + * content --> fill string + */ + if (addr < INVENTORYDATASIZE) { + /* Copy the IVM string in the corresponding string */ + for (; (buf[addr] != '\r') && + ((buf[addr] != ';') || (!stop)) && + (size < (maxlen - 1) && + (addr < INVENTORYDATASIZE)); addr++) { + size += sprintf((char *)string + size, "%c", + convert_char (buf[addr])); + } + + /* + * copy phase is done: check if everything is ok. If not, + * the inventory data is most probably corrupted: tell + * the world there is a problem! + */ + if (addr == INVENTORYDATASIZE) { + xcode = -1; + printf("Error end of string not found\n"); + } else if ((size >= (maxlen - 1)) && + (buf[addr] != '\r')) { + xcode = -1; + printf("string too long till next CR\n"); + } + } else { + /* + * some CR are missing... + * the inventory data is most probably corrupted + */ + xcode = -1; + printf("not enough cr found\n"); + } + return xcode; +} + +#define GET_STRING(name, which, len) \ + if (ivm_findinventorystring(which, valbuf, len, buf) == 0) { \ + ivm_set_value(name, (char *)valbuf); \ + } + +static int ivm_check_crc(unsigned char *buf, int block) +{ + unsigned long crc; + unsigned long crceeprom; + + crc = ivm_calc_crc(buf, CONFIG_SYS_IVM_EEPROM_PAGE_LEN - 2); + crceeprom = (buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN - 1] + \ + buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN - 2] * 256); + if (crc != crceeprom) { + if (block == 0) + printf("Error CRC Block: %d EEprom: calculated: \ + %lx EEprom: %lx\n", block, crc, crceeprom); + return -1; + } + return 0; +} + +static int ivm_analyze_block2(unsigned char *buf, int len) +{ + unsigned char valbuf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN]; + unsigned long count; + + /* IVM_MacAddress */ + sprintf((char *)valbuf, "%pM", buf); + ivm_set_value("IVM_MacAddress", (char *)valbuf); + /* if an offset is defined, add it */ +#if defined(CONFIG_PIGGY_MAC_ADRESS_OFFSET) + if (CONFIG_PIGGY_MAC_ADRESS_OFFSET > 0) { + unsigned long val = (buf[4] << 16) + (buf[5] << 8) + buf[6]; + + val += CONFIG_PIGGY_MAC_ADRESS_OFFSET; + buf[4] = (val >> 16) & 0xff; + buf[5] = (val >> 8) & 0xff; + buf[6] = val & 0xff; + sprintf((char *)valbuf, "%pM", buf); + } +#endif + setenv((char *)"ethaddr", (char *)valbuf); + + /* IVM_MacCount */ + count = (buf[10] << 24) + + (buf[11] << 16) + + (buf[12] << 8) + + buf[13]; + if (count == 0xffffffff) + count = 1; + sprintf((char *)valbuf, "%lx", count); + ivm_set_value("IVM_MacCount", (char *)valbuf); + return 0; +} + +int ivm_analyze_eeprom(unsigned char *buf, int len) +{ + unsigned short val; + unsigned char valbuf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN]; + unsigned char *tmp; + + if (ivm_check_crc(buf, 0) != 0) + return -1; + + ivm_get_value(buf, CONFIG_SYS_IVM_EEPROM_PAGE_LEN, + "IVM_BoardId", 0, 1); + val = ivm_get_value(buf, CONFIG_SYS_IVM_EEPROM_PAGE_LEN, + "IVM_HWKey", 6, 1); + if (val != 0xffff) { + sprintf((char *)valbuf, "%x", ((val / 100) % 10)); + ivm_set_value("IVM_HWVariant", (char *)valbuf); + sprintf((char *)valbuf, "%x", (val % 100)); + ivm_set_value("IVM_HWVersion", (char *)valbuf); + } + ivm_get_value(buf, CONFIG_SYS_IVM_EEPROM_PAGE_LEN, + "IVM_Functions", 12, 0); + + GET_STRING("IVM_Symbol", IVM_POS_SYMBOL_ONLY, 8) + GET_STRING("IVM_DeviceName", IVM_POS_SHORT_TEXT, 64) + tmp = (unsigned char *) getenv("IVM_DeviceName"); + if (tmp) { + int len = strlen((char *)tmp); + int i = 0; + + while (i < len) { + if (tmp[i] == ';') { + ivm_set_value("IVM_ShortText", + (char *)&tmp[i + 1]); + break; + } + i++; + } + if (i >= len) + ivm_set_value("IVM_ShortText", NULL); + } else { + ivm_set_value("IVM_ShortText", NULL); + } + GET_STRING("IVM_ManufacturerID", IVM_POS_MANU_ID, 32) + GET_STRING("IVM_ManufacturerSerialNumber", IVM_POS_MANU_SERIAL, 20) + GET_STRING("IVM_ManufacturerPartNumber", IVM_POS_PART_NUMBER, 32) + GET_STRING("IVM_ManufacturerBuildState", IVM_POS_BUILD_STATE, 32) + GET_STRING("IVM_SupplierPartNumber", IVM_POS_SUPPLIER_PART_NUMBER, 32) + GET_STRING("IVM_DelieveryDate", IVM_POS_DELIVERY_DATE, 32) + GET_STRING("IVM_SupplierBuildState", IVM_POS_SUPPLIER_BUILD_STATE, 32) + GET_STRING("IVM_CustomerID", IVM_POS_CUSTOMER_ID, 32) + GET_STRING("IVM_CustomerProductID", IVM_POS_CUSTOMER_PROD_ID, 32) + + if (ivm_check_crc(&buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN * 2], 2) != 0) + return 0; + ivm_analyze_block2(&buf[CONFIG_SYS_IVM_EEPROM_PAGE_LEN * 2], + CONFIG_SYS_IVM_EEPROM_PAGE_LEN); + + return 0; +} + +int ivm_read_eeprom(void) +{ +#if defined(CONFIG_I2C_MUX) + I2C_MUX_DEVICE *dev = NULL; +#endif + uchar i2c_buffer[CONFIG_SYS_IVM_EEPROM_MAX_LEN]; + uchar *buf; + unsigned long dev_addr = CONFIG_SYS_IVM_EEPROM_ADR; + int ret; + +#if defined(CONFIG_I2C_MUX) + /* First init the Bus, select the Bus */ +#if defined(CONFIG_SYS_I2C_IVM_BUS) + dev = i2c_mux_ident_muxstring((uchar *)CONFIG_SYS_I2C_IVM_BUS); +#else + buf = (unsigned char *) getenv("EEprom_ivm"); + if (buf != NULL) + dev = i2c_mux_ident_muxstring(buf); +#endif + if (dev == NULL) { + printf("Error couldnt add Bus for IVM\n"); + return -1; + } + i2c_set_bus_num(dev->busid); +#endif + + buf = (unsigned char *) getenv("EEprom_ivm_addr"); + if (buf != NULL) { + ret = strict_strtoul((char *)buf, 16, &dev_addr); + if (ret != 0) + return -3; + } + + /* add deblocking here */ + i2c_make_abort(); + + ret = i2c_read(dev_addr, 0, 1, i2c_buffer, + CONFIG_SYS_IVM_EEPROM_MAX_LEN); + if (ret != 0) { + printf("Error reading EEprom\n"); + return -2; + } + + return ivm_analyze_eeprom(i2c_buffer, CONFIG_SYS_IVM_EEPROM_MAX_LEN); +} diff --git a/board/keymile/km82xx/Makefile b/board/keymile/km82xx/Makefile index a2b9da4..b9709d9 100644 --- a/board/keymile/km82xx/Makefile +++ b/board/keymile/km82xx/Makefile @@ -28,7 +28,7 @@ endif
LIB = $(obj)lib$(BOARD).o
-COBJS := $(BOARD).o ../common/common.o +COBJS := $(BOARD).o ../common/common.o ../common/ivm.o
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS)) diff --git a/board/keymile/km83xx/Makefile b/board/keymile/km83xx/Makefile index 2fa84f3..7bf64b4 100644 --- a/board/keymile/km83xx/Makefile +++ b/board/keymile/km83xx/Makefile @@ -28,7 +28,7 @@ endif
LIB = $(obj)lib$(BOARD).o
-COBJS += $(BOARD).o ../common/common.o +COBJS += $(BOARD).o ../common/common.o ../common/ivm.o
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS)) diff --git a/board/keymile/km_arm/Makefile b/board/keymile/km_arm/Makefile index 6bcfb25..4907030 100644 --- a/board/keymile/km_arm/Makefile +++ b/board/keymile/km_arm/Makefile @@ -29,7 +29,7 @@ endif
LIB = $(obj)lib$(BOARD).o
-COBJS := $(BOARD).o ../common/common.o +COBJS := $(BOARD).o ../common/common.o ../common/ivm.o
SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(COBJS))

Dear Holger Brunck,
In message 1307348541-2466-8-git-send-email-holger.brunck@keymile.com you wrote:
The file common.c grows in the past. So move the IVM specific code into an ivm.c file.
Signed-off-by: Holger Brunck holger.brunck@keymile.com Signed-off-by: Valentin Longchamp valentin.longchamp@keymile.com cc: Heiko Schocher hs@denx.de cc: Wolfgang Denk wd@denx.de
board/keymile/common/common.c | 324 +-------------------------------------- board/keymile/common/common.h | 1 + board/keymile/common/ivm.c | 342 +++++++++++++++++++++++++++++++++++++++++ board/keymile/km82xx/Makefile | 2 +- board/keymile/km83xx/Makefile | 2 +- board/keymile/km_arm/Makefile | 2 +- 6 files changed, 352 insertions(+), 321 deletions(-) create mode 100644 board/keymile/common/ivm.c
Applied, thanks.
Best regards,
Wolfgang Denk

This code is unused and therefore dead code.
Signed-off-by: Holger Brunck holger.brunck@keymile.com Signed-off-by: Valentin Longchamp valentin.longchamp@keymile.com cc: Heiko Schocher hs@denx.de cc: Wolfgang Denk wd@denx.de --- board/keymile/common/common.c | 55 ----------------------------------------- 1 files changed, 0 insertions(+), 55 deletions(-)
diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c index 010e969..814968d 100644 --- a/board/keymile/common/common.c +++ b/board/keymile/common/common.c @@ -299,61 +299,6 @@ void i2c_init_board(void) #endif #endif
-#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT) -int fdt_set_node_and_value(void *blob, - char *nodename, - char *regname, - void *var, - int size) -{ - int ret = 0; - int nodeoffset = 0; - - nodeoffset = fdt_path_offset(blob, nodename); - if (nodeoffset >= 0) { - ret = fdt_setprop(blob, nodeoffset, regname, var, - size); - if (ret < 0) - printf("ft_blob_update(): cannot set %s/%s " - "property err:%s\n", nodename, regname, - fdt_strerror(ret)); - } else { - printf("ft_blob_update(): cannot find %s node " - "err:%s\n", nodename, fdt_strerror(nodeoffset)); - } - return ret; -} - -int fdt_get_node_and_value(void *blob, - char *nodename, - char *propname, - void **var) -{ - int len; - int nodeoffset = 0; - - nodeoffset = fdt_path_offset(blob, nodename); - if (nodeoffset >= 0) { - *var = (void *)fdt_getprop(blob, nodeoffset, propname, &len); - if (len == 0) { - /* no value */ - printf("%s no value\n", __func__); - return -1; - } else if (len > 0) { - return len; - } else { - printf("libfdt fdt_getprop(): %s\n", - fdt_strerror(len)); - return -2; - } - } else { - printf("%s: cannot find %s node err:%s\n", __func__, - nodename, fdt_strerror(nodeoffset)); - return -3; - } -} -#endif - #if !defined(MACH_TYPE_KM_KIRKWOOD) int ethernet_present(void) {

Dear Holger Brunck,
In message 1307348541-2466-9-git-send-email-holger.brunck@keymile.com you wrote:
This code is unused and therefore dead code.
Signed-off-by: Holger Brunck holger.brunck@keymile.com Signed-off-by: Valentin Longchamp valentin.longchamp@keymile.com cc: Heiko Schocher hs@denx.de cc: Wolfgang Denk wd@denx.de
board/keymile/common/common.c | 55 ----------------------------------------- 1 files changed, 0 insertions(+), 55 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

Common code should be valid for more than one architecture, therefore the km82xx specific code was removed from common.c.
Signed-off-by: Holger Brunck holger.brunck@keymile.com Signed-off-by: Valentin Longchamp valentin.longchamp@keymile.com cc: Heiko Schocher hs@denx.de cc: Wolfgang Denk wd@denx.de --- board/keymile/common/common.c | 69 +---------------------------------- board/keymile/common/common.h | 1 - board/keymile/km82xx/km82xx.c | 60 +++++++++++++++++++++++++++++++ include/configs/km/km82xx-common.h | 7 ++++ 4 files changed, 69 insertions(+), 68 deletions(-)
diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c index 814968d..841bdee 100644 --- a/board/keymile/common/common.c +++ b/board/keymile/common/common.c @@ -25,9 +25,6 @@ */
#include <common.h> -#if defined(CONFIG_KM82XX) -#include <mpc8260.h> -#endif #include <ioports.h> #include <command.h> #include <malloc.h> @@ -44,6 +41,7 @@ #include "common.h" #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C) #include <i2c.h> +#endif
static void i2c_write_start_seq(void); DECLARE_GLOBAL_DATA_PTR; @@ -83,70 +81,9 @@ int set_km_env(void) return 0; }
-#if defined(CONFIG_SYS_I2C_INIT_BOARD) #define DELAY_ABORT_SEQ 62 /* @200kHz 9 clocks = 44us, 62us is ok */ #define DELAY_HALF_PERIOD (500 / (CONFIG_SYS_I2C_SPEED / 1000))
-#if defined(CONFIG_KM_82XX) -#define SDA_MASK 0x00010000 -#define SCL_MASK 0x00020000 -void set_pin(int state, unsigned long mask) -{ - ioport_t *iop = ioport_addr((immap_t *)CONFIG_SYS_IMMR, 3); - - if (state) - setbits_be32(&iop->pdat, mask); - else - clrbits_be32(&iop->pdat, mask); - - setbits_be32(&iop->pdir, mask); -} - -static int get_pin(unsigned long mask) -{ - ioport_t *iop = ioport_addr((immap_t *)CONFIG_SYS_IMMR, 3); - - clrbits_be32(&iop->pdir, mask); - return 0 != (in_be32(&iop->pdat) & mask); -} - -static void set_sda(int state) -{ - set_pin(state, SDA_MASK); -} - -static void set_scl(int state) -{ - set_pin(state, SCL_MASK); -} - -static int get_sda(void) -{ - return get_pin(SDA_MASK); -} - -static int get_scl(void) -{ - return get_pin(SCL_MASK); -} - -#if defined(CONFIG_HARD_I2C) -static void setports(int gpio) -{ - ioport_t *iop = ioport_addr((immap_t *)CONFIG_SYS_IMMR, 3); - - if (gpio) { - clrbits_be32(&iop->ppar, (SDA_MASK | SCL_MASK)); - clrbits_be32(&iop->podr, (SDA_MASK | SCL_MASK)); - } else { - setbits_be32(&iop->ppar, (SDA_MASK | SCL_MASK)); - clrbits_be32(&iop->pdir, (SDA_MASK | SCL_MASK)); - setbits_be32(&iop->podr, (SDA_MASK | SCL_MASK)); - } -} -#endif -#endif - #if !defined(CONFIG_MPC83xx) static void i2c_write_start_seq(void) { @@ -223,7 +160,7 @@ int i2c_make_abort(void) #endif return ret; } -#endif +#endif /* !MPC83xx */
#if defined(CONFIG_MPC83xx) static void i2c_write_start_seq(void) @@ -296,8 +233,6 @@ void i2c_init_board(void) /* Now run the AbortSequence() */ i2c_make_abort(); } -#endif -#endif
#if !defined(MACH_TYPE_KM_KIRKWOOD) int ethernet_present(void) diff --git a/board/keymile/common/common.h b/board/keymile/common/common.h index edf6e3a..0fb19cf 100644 --- a/board/keymile/common/common.h +++ b/board/keymile/common/common.h @@ -124,7 +124,6 @@ struct bfticu_iomap {
int ethernet_present(void); int ivm_read_eeprom(void); -void set_pin(int state, unsigned long mask);
int set_km_env(void); int fdt_set_node_and_value(void *blob, diff --git a/board/keymile/km82xx/km82xx.c b/board/keymile/km82xx/km82xx.c index d453d25..0e50b0b 100644 --- a/board/keymile/km82xx/km82xx.c +++ b/board/keymile/km82xx/km82xx.c @@ -315,6 +315,8 @@ int last_stage_init(void) }
#ifdef CONFIG_MGCOGE3NE +static void set_pin(int state, unsigned long mask); + /* * For mgcoge3ne boards, the mgcoge3un control is controlled from * a GPIO line on the PPC CPU. If bobcatreset is set the line @@ -363,6 +365,64 @@ int hush_init_var(void) return 0; }
+#define SDA_MASK 0x00010000 +#define SCL_MASK 0x00020000 + +static void set_pin(int state, unsigned long mask) +{ + ioport_t *iop = ioport_addr((immap_t *)CONFIG_SYS_IMMR, 3); + + if (state) + setbits_be32(&iop->pdat, mask); + else + clrbits_be32(&iop->pdat, mask); + + setbits_be32(&iop->pdir, mask); +} + +static int get_pin(unsigned long mask) +{ + ioport_t *iop = ioport_addr((immap_t *)CONFIG_SYS_IMMR, 3); + + clrbits_be32(&iop->pdir, mask); + return 0 != (in_be32(&iop->pdat) & mask); +} + +void set_sda(int state) +{ + set_pin(state, SDA_MASK); +} + +void set_scl(int state) +{ + set_pin(state, SCL_MASK); +} + +int get_sda(void) +{ + return get_pin(SDA_MASK); +} + +int get_scl(void) +{ + return get_pin(SCL_MASK); +} + +#if defined(CONFIG_HARD_I2C) +static void setports(int gpio) +{ + ioport_t *iop = ioport_addr((immap_t *)CONFIG_SYS_IMMR, 3); + + if (gpio) { + clrbits_be32(&iop->ppar, (SDA_MASK | SCL_MASK)); + clrbits_be32(&iop->podr, (SDA_MASK | SCL_MASK)); + } else { + setbits_be32(&iop->ppar, (SDA_MASK | SCL_MASK)); + clrbits_be32(&iop->pdir, (SDA_MASK | SCL_MASK)); + setbits_be32(&iop->podr, (SDA_MASK | SCL_MASK)); + } +} +#endif #if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT) void ft_board_setup(void *blob, bd_t *bd) { diff --git a/include/configs/km/km82xx-common.h b/include/configs/km/km82xx-common.h index b89631c..0360cd3 100644 --- a/include/configs/km/km82xx-common.h +++ b/include/configs/km/km82xx-common.h @@ -139,6 +139,13 @@ } while (0) #define I2C_DELAY udelay(5) /* 1/4 I2C clock duration */
+#ifndef __ASSEMBLY__ +void set_sda(int state); +void set_scl(int state); +int get_sda(void); +int get_scl(void); +#endif + /* I2C SYSMON (LM75, AD7414 is almost compatible) */ #define CONFIG_DTT_LM75 /* ON Semi's LM75 */ #define CONFIG_DTT_SENSORS {0} /* Sensor addresses */

Dear Holger Brunck,
In message 1307348541-2466-10-git-send-email-holger.brunck@keymile.com you wrote:
Common code should be valid for more than one architecture, therefore the km82xx specific code was removed from common.c.
Signed-off-by: Holger Brunck holger.brunck@keymile.com Signed-off-by: Valentin Longchamp valentin.longchamp@keymile.com cc: Heiko Schocher hs@denx.de cc: Wolfgang Denk wd@denx.de
board/keymile/common/common.c | 69 +---------------------------------- board/keymile/common/common.h | 1 - board/keymile/km82xx/km82xx.c | 60 +++++++++++++++++++++++++++++++ include/configs/km/km82xx-common.h | 7 ++++ 4 files changed, 69 insertions(+), 68 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

All the km boards uses CRAMFS images where the kernel is stored. This isn't architecture specific because we use it on ARM and POWERPC.
Signed-off-by: Holger Brunck holger.brunck@keymile.com Signed-off-by: Valentin Longchamp valentin.longchamp@keymile.com cc: Heiko Schocher hs@denx.de cc: Wolfgang Denk wd@denx.de --- include/configs/km/keymile-common.h | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/include/configs/km/keymile-common.h b/include/configs/km/keymile-common.h index 89a652f..6a31d26 100644 --- a/include/configs/km/keymile-common.h +++ b/include/configs/km/keymile-common.h @@ -118,7 +118,9 @@ #define CONFIG_MTD_DEVICE #define CONFIG_MTD_CONCAT
-/* common powerpc specific env settings */ +#define CONFIG_CMD_CRAMFS +#define CONFIG_CRAMFS_CMDLINE + #ifndef CONFIG_KM_DEF_ENV_BOOTPARAMS #define CONFIG_KM_DEF_ENV_BOOTPARAMS \ "actual_bank=0\0"

Dear Holger Brunck,
In message 1307348541-2466-11-git-send-email-holger.brunck@keymile.com you wrote:
All the km boards uses CRAMFS images where the kernel is stored. This isn't architecture specific because we use it on ARM and POWERPC.
Signed-off-by: Holger Brunck holger.brunck@keymile.com Signed-off-by: Valentin Longchamp valentin.longchamp@keymile.com cc: Heiko Schocher hs@denx.de cc: Wolfgang Denk wd@denx.de
include/configs/km/keymile-common.h | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
participants (2)
-
Holger Brunck
-
Wolfgang Denk