From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8CB0FC433EF for ; Thu, 10 Mar 2022 20:55:05 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A20AF83B48; Thu, 10 Mar 2022 21:53:37 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.b="yqEzL1C8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 161C683B32; Thu, 10 Mar 2022 21:52:13 +0100 (CET) Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on0619.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0d::619]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7035E83B19 for ; Thu, 10 Mar 2022 21:51:44 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sean.anderson@seco.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=I/s3nxVw8l6mNiscQi0wh9/no2pvKjXn43Rpii2cCo3Ox8e4+SMeu4Ec/TIuxEjT8d6PdaSLZ8dGT/sXx0Qt5INMwXnUqLHB6hc0kqbe818r33SrZP7A80RtJM/AVzHJWpu+lXz2yysfyhJqzgXIGxQnn1mhPg0ulJ92kLqYGdFJWQS1Sa+bI7xCPwLMoBQ28Mlxh0ODzwmO1vTbs0yedPZpk9KT+AMuFP86e/Rii5bzJB1pe4qQWzfYaJaLpvBrxpTKB5VAow+e4l9JXuzsPXT2/dloPWsBtA67vU6X3ERFbt6fD09mxlazxAFbR4Sh6Jl/OJYPRnmwmbUHn9++QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ItCtvo5lgmG1MqbV96j5NMbo5zAWBpumbur5aWIAcew=; b=TocUeBVubN1zPfx8pR3JSUU8KJf+T/n4/eYtb6hmsx0Md68QG7DQfYAFPYOM1HSp2R7xAbD6fktC0PhsPz2Aae1dtpuoLdQ0jj8lLeVlWyGnnXLOkkw2B2CC0gCXdbs71j4oOVcIrwLLndZy/R86p9Svco8cO9ygqc5j8RWos6vsERY/kpFYRAl9wmWBY+kjAptlga3jtftDZtiMr2nlXHavhzbPN+nOAP3qKefF9oQPgJIKE+f2kq3PyCCkVOtXBs2Et0wyjxWkK5x575Fq46KGdzQ1j0kswbTqjYrUG6dgKJBb0Mmiex5rmoXl8rLLx0B9k6YpuT9GrYsxot05kw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ItCtvo5lgmG1MqbV96j5NMbo5zAWBpumbur5aWIAcew=; b=yqEzL1C8SUkHOMDth/9wRbZbZuAPvkaYLGDn+4LN4QbSiUTZvZFXrF+vLmFV6K2Wke+2/9kYkwh/LgqG0O2ohc0A0z+hMsjKXrr6Pm+ENeeeX39JXC1k+Yj6ixfS4pHzC69s8oee2BP4EXspH5ZznqptKiScUat4a5aJYXjbDmbU5pHVS2jH9OY++hCHwM6//r3A+fJGa+aBAI7F8Eal/qSeALV+PJ/8oG4fre5UWw3bzEHSM9vpoGLynHzFhNghrbNv4kABSMlZUu8SnruADf7UJCpAwbNq3rckghHEEQTm1Cw8Nm4bXO+EONhF8vytc13tUUTXznujCyVfn4kGxA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by DB6PR0301MB2439.eurprd03.prod.outlook.com (2603:10a6:4:5b::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5038.14; Thu, 10 Mar 2022 20:51:42 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::9860:b15b:f166:5896]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::9860:b15b:f166:5896%3]) with mapi id 15.20.5061.022; Thu, 10 Mar 2022 20:51:41 +0000 From: Sean Anderson To: Tom Rini Cc: Liviu Dudau , u-boot@lists.denx.de, Simon Glass , Linus Walleij , Andre Przywara , Sean Anderson , Mingkai Hu , Priyanka Jain , Rajesh Bhagat Subject: [PATCH v2 18/28] ls1046ardb: Add support for JTAG boot Date: Thu, 10 Mar 2022 15:50:48 -0500 Message-Id: <20220310205059.499269-19-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220310205059.499269-1-sean.anderson@seco.com> References: <20220310205059.499269-1-sean.anderson@seco.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BL1PR13CA0433.namprd13.prod.outlook.com (2603:10b6:208:2c3::18) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e01e6874-04fa-4e11-9ac4-08da02d7c7b6 X-MS-TrafficTypeDiagnostic: DB6PR0301MB2439:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tYp92dPNBfMP+QrEh6BSWp0OZmFD9MidnLUqpJ/TX+mELEPeAWYkZHb1m3JfnFr+xDcLO0K5cvXIo9XhHYZRbrCVlztjCB82uxmRhy09pXk5GvacHIz7QyGiETCZ1Cq3V7in8IJDFmrUPXItO57kLU+POayhn2gTBtGOncIAF32eI42uu8yMcwWsbOp99NcKIqqGkvdcoHrg/gXx6CHClt4jSjrtRzuLtrw4f7DAMkGSxLBcdPHY2O4YLveJvZYLI9fmAzQSjcnV3zfs4yeZVY4LPKtFCxkwrhNRZojxfJ+WllxSBq73aQBkvimEReUh9LYb6PzIBYNwoFMtCtxd5dLl7bOdrSIhITKFomECkCgsrROlkw/V5nyNL5tCGhx5eNIvlKBc1LLBFAuJ5rJUk/y8CBgrxunuZlzeOVo7ka3S2FVnC01skZr92W/3PkJe5TYES/wfcxwsG0Cj7XdCMgauPzyWlZt8bXzv92pZjKBJSFsSikGHS7V9REYJk9lYy+hBGZBu4D9Cd4zqWRvCSgoryxp8NvFoTGG281BzCJwFmIn9+zU8iDRqHDprXkM92irPCvWbV5KwxiMjtSrAKweNIA1BPvGr8YeM2NgeNx8rubAFj/AEkG/8ZlZJ3Q2yrffTPNyv/ffxtagGNl7PcOCPp/yNSY9Gc2af6QPoDuIKH/H5i1kprR4IMDtxcOjOihSG2gExFK8Z/yLP1EaiPT04TTAzoUNvQBlKGX5UVTk6ArpcNlBZmEoah2zVLorwZ5YPSWjiru3fcLnMbbVsbsu6fhwUOyyQPKW7dQskffw= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR03MB4523.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(54906003)(66476007)(316002)(4326008)(66556008)(6916009)(8676002)(66946007)(44832011)(36756003)(86362001)(2906002)(38350700002)(38100700002)(5660300002)(8936002)(6512007)(966005)(52116002)(6486002)(6506007)(508600001)(186003)(26005)(2616005)(1076003)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?vDXeZCL2khlUL3/Njys/l84xVdypqSwUNe0jTyEyJIRkfOm4WqET02ZFYJfo?= =?us-ascii?Q?CQCWIg9NhZtMjx0jThVBC4V9s3LqCRY4HOCmrQrB+H5ioYuwGqVKwUZV4n7O?= =?us-ascii?Q?udV1pAanoFkSShxJd7J5ywmtlrJVcI2iSZzm9IzhQsVFrDbDN8R9f2vV4WJ2?= =?us-ascii?Q?4sD8QDO7g9Ys8F1mvLof1mePvkoopt0qyutXKA+OrcBB3nUTytbXKm6sehRj?= =?us-ascii?Q?TW1a1goan3p9I1HH09ee4jCx9eI4V5Qj4c2koS9kXRDYFZTcR8TjuyvnUGDG?= =?us-ascii?Q?wEFXiC9ITURxf0ZhP36tkSZWiF+UZunhnPLEQgK3aXUfHQohjCB4DFYQwKhQ?= =?us-ascii?Q?W8tyeOUcaCaIkoXP0VCGPTpwszzUyzmDat/CjqStwNFNgsBclJQCO/qAyuJt?= =?us-ascii?Q?o/MEOQUiuxO5N2BzAiQshF0zfA8DhGgwoBN2bk9C5smxuxyu1Bh+7V175OFS?= =?us-ascii?Q?yk6No27o9M++QGKDi+MWXH+gHgR8DJ/DYkLiLLsjf6HLeu0jAa1XLJY9ewuP?= =?us-ascii?Q?O/ALWm9t1QM3nuc/HslzencPUQWt1wM37s1SNIZYFyhidqqlTJaXVHP5GurJ?= =?us-ascii?Q?veVIndFuuyCZlGWuKI33hf1HjQM4TQ6mlr0s18ea+6e099DMDXb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UNrJgLr5hStRZQltUH7BQu4U?= =?us-ascii?Q?NvdwkCnhCHnoV7thVsPKZ54ReX62f9RFJkd1l+GpW/0uBjny7WAeE5AcRNEB?= =?us-ascii?Q?73/0RoGPx4P/UCDbB/NpPJM=3D?= X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: e01e6874-04fa-4e11-9ac4-08da02d7c7b6 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Mar 2022 20:51:41.8985 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: AkSm/6e5TByWHfAeT9TXBNlxSNl1LgIWCaGKCmzH+/knQeGkZphNMeUxwRfR7qZfd49bOzwKvlcKFO8TqLXsjg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0301MB2439 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean This adds support for booting entirely from JTAG while using a hard-coded RCW. With these steps, it is not necessary to program a "good" RCW using CodeWarrior. The method here can be performed with any JTAG adapter supported by OpenOCD, including the on-board CMSIS-DAP (albeit very slowly). These steps require LS1046A support in OpenOCD, which is currently in the process of being upstreamed [1]. [1] https://review.openocd.org/c/openocd/+/6855 Signed-off-by: Sean Anderson --- (no changes since v1) arch/arm/cpu/armv8/fsl-layerscape/spl.c | 2 + board/freescale/ls1046ardb/ls1046ardb.c | 10 ++++ doc/board/nxp/ls1046ardb.rst | 71 +++++++++++++++++++++++++ include/configs/ls1046ardb.h | 2 + 4 files changed, 85 insertions(+) diff --git a/arch/arm/cpu/armv8/fsl-layerscape/spl.c b/arch/arm/cpu/armv8/fsl-layerscape/spl.c index 564cc27c8b..1a7dde30a5 100644 --- a/arch/arm/cpu/armv8/fsl-layerscape/spl.c +++ b/arch/arm/cpu/armv8/fsl-layerscape/spl.c @@ -27,6 +27,8 @@ DECLARE_GLOBAL_DATA_PTR; u32 spl_boot_device(void) { + if (IS_ENABLED(CONFIG_SPL_SEMIHOSTING)) + return BOOT_DEVICE_SMH; #ifdef CONFIG_SPL_MMC return BOOT_DEVICE_MMC1; #endif diff --git a/board/freescale/ls1046ardb/ls1046ardb.c b/board/freescale/ls1046ardb/ls1046ardb.c index d0abfe8869..9af7cf763b 100644 --- a/board/freescale/ls1046ardb/ls1046ardb.c +++ b/board/freescale/ls1046ardb/ls1046ardb.c @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include #include #include @@ -27,6 +29,14 @@ DECLARE_GLOBAL_DATA_PTR; +struct serial_device *default_serial_console(void) +{ +#if IS_ENABLED(CONFIG_SEMIHOSTING_SERIAL) + return &serial_smh_device; +#endif + return &eserial1_device; +} + int board_early_init_f(void) { fsl_lsch2_early_init_f(); diff --git a/doc/board/nxp/ls1046ardb.rst b/doc/board/nxp/ls1046ardb.rst index e4499a13fb..69e5ad1495 100644 --- a/doc/board/nxp/ls1046ardb.rst +++ b/doc/board/nxp/ls1046ardb.rst @@ -110,6 +110,77 @@ SD boot and eMMC boot ``{ SW5[0:8], SW4[0] }`` should be ``0010_0000_0``. eMMC is selected only if there is no SD card in the slot. +JTAG boot +^^^^^^^^^ + +To recover a bricked board, or to perform initial programming, the ls1046 +supports using two hard-coded Reset Configuration Words (RCWs). Unfortunately, +this configuration disables most functionality, including the uarts and ethernet. +However, the SD/MMC and flash controllers are still functional. To get around +the lack of a serial console, we will use ARM semihosting instead. When +enabled, OpenOCD will interpret certain instructions as calls to the host +operating system. This allows U-Boot to use the console, read/write files, or +run arbitrary commands (!). + +When configuring U-Boot, ensure that ``CONFIG_SEMIHOSTING``, +``CONFIG_SPL_SEMIHOSTING``, and ``CONFIG_SEMIHOSTING_SERIAL`` are enabled. +``{ SW5[0:8], SW4[0] }`` should be ``0100_1111_0``. Additionally, ``SW4[7]`` +should be set to ``0``. Connect to the "console" USB connector on the front of +the enclosure. + +Create a new file called ``u-boot.tcl`` (or whatever you choose) with the +following contents:: + + # Load the configuration for the LS1046ARDB + source [find board/nxp_rdb-ls1046a.cfg] + # Initialize the scan chain + init + # Stop the processor + halt + # Enable semihosting + arm semihosting enable + # Load U-Boot SPL + load_image spl/u-boot-spl 0 elf + # Start executing SPL at the beginning of OCRAM + resume 0x10000000 + +Then, launch openocd like:: + + openocd -f u-boot.tcl + +You should see the U-boot SPL banner followed by the banner for U-Boot proper +in the output of openocd. The CMSIS-DAP adapter is slow, so this can take a +long time. If you don't see it, something has gone wrong. After a while, you +should see the prompt. You can load an image using semihosting by running:: + + => load hostfs $loadaddr + +Note that openocd's terminal is "cooked," so commands will only be sent to +U-Boot when you press enter, and all commands will be echoed twice. +Additionally, openocd will block when waiting for input, ignoring gdb, JTAG +events, and Ctrl-Cs. To make openocd process these events, just hit enter. + +Using an external JTAG adapter +"""""""""""""""""""""""""""""" + +The CMSIS-DAP adapter can be rather slow. To speed up booting, use an external +JTAG adapter. The following examples assume you are using a J-Link, though any +adapter supported by OpenOCD will do. Ensure that ``SW4[7]`` is ``1``. Attach +your jtag adapter to J22. Modify ``u-boot.tcl`` and replace the first two lines +with the following:: + + # Load the J-Link configuration (or whatever your adapter is) + source [find interface/jlink.cfg] + # Use JTAG, since the J-Link also supports SWD + transport select jtag + # The reset pin resets the whole CPU + reset_config srst_only + # Load the LS1046A config + source [find target/ls1046a.cfg] + +You can proceed as normal through the rest of the steps above. I got a speedup +of around 100x by using a J-Link. + Debug UART ---------- diff --git a/include/configs/ls1046ardb.h b/include/configs/ls1046ardb.h index 8ed1dceb23..ed549c33b6 100644 --- a/include/configs/ls1046ardb.h +++ b/include/configs/ls1046ardb.h @@ -143,6 +143,8 @@ #endif #endif +#define CONFIG_SPL_FS_LOAD_PAYLOAD_NAME "u-boot.img" + #include #endif /* __LS1046ARDB_H__ */ -- 2.25.1