From patchwork Wed May 4 11:47:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Holger Brunck X-Patchwork-Id: 94003 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 264ED1007D1 for ; Wed, 4 May 2011 21:48:14 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3B71A280D7; Wed, 4 May 2011 13:48:02 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XKIbUg5jQlds; Wed, 4 May 2011 13:48:02 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1B80F280AA; Wed, 4 May 2011 13:47:47 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B686A28096 for ; Wed, 4 May 2011 13:47:43 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AaeN0PaFyAGs for ; Wed, 4 May 2011 13:47:43 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail.de.keymile.com (mail.de.keymile.com [195.8.104.1]) by theia.denx.de (Postfix) with SMTP id C180C28095 for ; Wed, 4 May 2011 13:47:42 +0200 (CEST) Received: from mailrelay.de.keymile.net ([10.9.1.54]) by eSafe SMTP Relay 1304406525; Wed, 04 May 2011 13:47:42 +0200 Received: from pc005093.de.keymile.net (pc005093.de.keymile.net [172.30.2.67]) by mailrelay.de.keymile.net (8.12.2/8.12.2) with ESMTP id p44Bgd7v009634; Wed, 4 May 2011 13:42:43 +0200 (MEST) From: Holger Brunck To: u-boot@lists.denx.de Date: Wed, 4 May 2011 13:47:30 +0200 Message-Id: <600f7afcb8e770eaaa417db1b119823070b62c48.1304508448.git.holger.brunck@keymile.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: In-Reply-To: References: References: X-ESAFE-STATUS: [srvhellgate.de.keymile.net] Mail clean Cc: Valentin Longchamp , Holger Brunck Subject: [U-Boot] [PATCH v2 3/8] km/common: implement setboardid command X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Read out board id and HW key from the IVM eeprom and set these values as an environment variable. Signed-off-by: Holger Brunck Acked-by: Heiko Schocher cc: Wolfgang Denk cc: Detlev Zundel cc: Valentin Longchamp --- Changes for v2: - split up first large patch serie to three independent smaller patch series - rework the patch with inputs from W.Denk: - adapt commit msg - add error handling board/keymile/common/common.c | 34 ++++++++++++++++++++++++++++++++++ 1 files changed, 34 insertions(+), 0 deletions(-) diff --git a/board/keymile/common/common.c b/board/keymile/common/common.c index 4883fe5..68e6b9f 100644 --- a/board/keymile/common/common.c +++ b/board/keymile/common/common.c @@ -26,6 +26,7 @@ #include #endif #include +#include #include #include #include @@ -685,3 +686,36 @@ int board_eth_init(bd_t *bis) return -1; } + +/* + * do_setboardid command + * read out the board id and the hw key from the intventory EEPROM and set + * this values as environment variables. + */ +static int do_setboardid(cmd_tbl_t *cmdtp, int flag, int argc, + char *const argv[]) +{ + unsigned char buf[32]; + char *p; + + p = get_local_var("IVM_BoardId"); + if (p == NULL) { + printf("can't get the IVM_Boardid\n"); + return 1; + } + sprintf((char *)buf, "%s", p); + setenv("boardid", (char *)buf); + + p = get_local_var("IVM_HWKey"); + if (p == NULL) { + printf("can't get the IVM_HWKey\n"); + return 1; + } + sprintf((char *)buf, "%s", p); + setenv("hwkey", (char *)buf); + + return 0; +} + +U_BOOT_CMD(km_setboardid, 1, 0, do_setboardid, "setboardid", "read out bid and " + "hwkey from IVM and set in environment");