From patchwork Mon May 4 16:52:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vasili Galka X-Patchwork-Id: 467733 X-Patchwork-Delegate: trini@ti.com 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 C1074140295 for ; Tue, 5 May 2015 02:53:18 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=lxUNnXV8; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E5BBB4B854; Mon, 4 May 2015 18:53:16 +0200 (CEST) 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 nLjBehlGHwtj; Mon, 4 May 2015 18:53:16 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5C1274B836; Mon, 4 May 2015 18:53:16 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 524B44B836 for ; Mon, 4 May 2015 18:53:12 +0200 (CEST) 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 vhuIXImiSd3n for ; Mon, 4 May 2015 18:53:12 +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-wg0-f45.google.com (mail-wg0-f45.google.com [74.125.82.45]) by theia.denx.de (Postfix) with ESMTPS id 0C6BE4B73C for ; Mon, 4 May 2015 18:53:08 +0200 (CEST) Received: by wgen6 with SMTP id n6so156519282wge.3 for ; Mon, 04 May 2015 09:53:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=9zxVAn7NRXtH9Lzq7KdQc8Da2ssb8SNOPNpKGu7f3NY=; b=lxUNnXV82IQdF791W8bMG0KF24KGNIfT9xClwnVDxmxxKfTTs/0CYeTA8E5iebDcVi P+kmbrsJ1ZiB34KRbSHXQ1tVpYpB6iO1G+dFbiPey69BI4O6nLeFg1XubKA+RWICrzuY I6ZrqcGTbWzZ8a9EFRcTBeNu7DmgjeT/fao5O+9hAq6HF/4yA28raqWyXF7Wh4M+QOgW wzd+3xBvPZSIRiWrcEdn7c0XlxYGzSlJt+DPR4YnfKKkZRh9l7ljnjGvgipWysmGNA9q bOPmmcIRYfoZugHj+92jeyuNtRIpq6y5bTVE3btMLGWWv28U1b2UdyX3Z1QqhJG8cYRG WJTg== X-Received: by 10.180.99.42 with SMTP id en10mr21265116wib.83.1430758387816; Mon, 04 May 2015 09:53:07 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.9.73 with HTTP; Mon, 4 May 2015 09:52:27 -0700 (PDT) In-Reply-To: References: From: Vasili Galka Date: Mon, 4 May 2015 19:52:27 +0300 Message-ID: To: Simon Glass X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Cc: Tom Rini , "u-boot@lists.denx.de" Subject: Re: [U-Boot] AM335x configurations - console output at early stages lost X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 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" Hi Simon, On Mon, May 4, 2015 at 7:45 PM, Simon Glass wrote: > Hi Vasili, > > On 4 May 2015 at 10:21, Vasili Galka wrote: > > > > Hi Simon, > > > > On Thu, Apr 30, 2015 at 3:38 AM, Simon Glass wrote: > >> > >> Hi Vasili, > >> > >> On 29 April 2015 at 10:57, Vasili Galka wrote: > >> > Hi Tom, > >> > > >> > I’m working on rebasing an old U-Boot branch for our company’s AM335x > >> > based board upon the current U-Boot release (v2015.04). Our branch was > >> > initially based on the v2013.10 release (the ti/am335x/ board was > >> > taken as reference). > >> > > >> > After making all the code compile, I discovered there was a change in > >> > the U-Boot initialization sequence, introduced by commit > >> > a6b541b09022acb6f7c2754100ae26bd44eed1d9, that prevents our code from > >> > working: > >> > > >> > Prior to the above mentioned commit, the console serial port was > >> > initialized at a very early stage in the armv7/am335x/board.c:s_init() > >> > function (calling preloader_console_init()). Roughly saying, it was > >> > the first thing done by the SPL code. This made quite much sense, as > >> > it enabled all the code afterwards to output status/debugging info to > >> > the console. > >> > Moving the preloader_console_init() call to spl_board_init() caused it > >> > to be run at a very "late" stage (as part of the board_init_r() > >> > function). AFAIU, now all the code that runs till then has no ability > >> > for any console output. > >> > For example, in our particular case, the DDR configuration code (in > >> > sdram_init()) reads the DDR type from an I2C EEPROM. Obviously, if > >> > something goes wrong in this process, we would like to report it to > >> > the console. > >> > > >> > I understand there was a good reason for the mentioned commit (the > >> > GD), however, as you see, we have also lost some important > >> > functionality with it. I would appreciate your advice on how to solve > >> > it. > >> > >> It would certainly be very useful and it would be great if we could > >> printf() from as soon as we have a stack (and perhaps printch() even > >> earlier). I think it can be done, but I have not put in the time to > >> figure it out. > >> > >> You could take a look at CONFIG_DEBUG_UART which at least allows > >> primitive UART access before gd is set up. I wonder if we could do > >> something like change printf() /purchatr() to use this when gd is > >> NULL? > >> > >> Regards, > >> Simon > > > > > > Thanks for the suggestion! I'm attempting to make it work. > > Was the "Debug UART" code (added in > 21d004368fc8a4da07147c58dfe9a4e16d4ab761) ever tested on AM335x? It does > not seem to work for me, I'm currently debugging in attempt to understand > the cause. > > From memory I think I did test it locally but did not send patches to > enable it. > > You will need to enable DEBUG_UART_NS16550, and supply suitable values > for DEBUG_UART_BASE and DEBUG_UART_CLOCK. > > But the debug UART code (in ns16550.c) is really simple so it should > not be possible to debug it. > > I think it would be good to have the DEBUG_UART_... options in the > board's defconfig file, even though CONFIG_DEBUG_UART itself is > disabled. Then people can enable it easily when they want to use the > debug UART. > > Regards, > Simon > Yes, of course, please see below the changes I applied. I expected to see a character written on to the UART, but I see nothing. So I attempt to compare the new serial code to the old one (from 2013) that definitely works. Best, Vasili --- /* * Default to using SPI for environment, etc. diff --git a/arch/arm/cpu/armv7/am33xx/board.c b/arch/arm/cpu/armv7/am33xx/board.c index 67bef23..79026d4 100644 --- a/arch/arm/cpu/armv7/am33xx/board.c +++ b/arch/arm/cpu/armv7/am33xx/board.c @@ -35,6 +35,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -297,6 +298,11 @@ void s_init(void) set_uart_mux_conf(); setup_clocks_for_console(); uart_soft_reset(); +#ifdef CONFIG_DEBUG_UART + debug_uart_init(); + printch('A'); + for(;;); +#endif #if defined(CONFIG_NOR_BOOT) || defined(CONFIG_QSPI_BOOT) /* TODO: This does not work, gd is not available yet */ gd->baudrate = CONFIG_BAUDRATE; diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c index 03beab5..7674433 100644 --- a/drivers/serial/ns16550.c +++ b/drivers/serial/ns16550.c @@ -54,7 +54,7 @@ DECLARE_GLOBAL_DATA_PTR; #define CONFIG_SYS_NS16550_IER 0x00 #endif /* CONFIG_SYS_NS16550_IER */ -#ifdef CONFIG_DM_SERIAL +#if defined(CONFIG_DM_SERIAL) || defined(CONFIG_DEBUG_UART_NS16550) static inline void serial_out_shift(unsigned char *addr, int shift, int value) { @@ -85,6 +85,9 @@ static inline int serial_in_shift(unsigned char *addr, int shift) return readb(addr); #endif } +#endif + +#if defined(CONFIG_DM_SERIAL) static void ns16550_writeb(NS16550_t port, int offset, int value) { diff --git a/include/configs/vm_am335x.h b/include/configs/vm_am335x.h index 9725c3f..3a1abc9 100644 --- a/include/configs/vm_am335x.h +++ b/include/configs/vm_am335x.h @@ -69,6 +69,11 @@ #define CONFIG_SYS_NS16550_COM1 0x44e09000 /* Baseboard has UART0 */ #define CONFIG_BAUDRATE 115200 +/* Enable "debug UART" to be the same (this is used at very beginning before gd is set-up) */ +#define CONFIG_DEBUG_UART +#define CONFIG_DEBUG_UART_NS16550 +#define CONFIG_DEBUG_UART_BASE CONFIG_SYS_NS16550_COM1 +#define CONFIG_DEBUG_UART_CLOCK CONFIG_SYS_NS16550_CLK