From: Vignesh R <vigneshr@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] SPL: tiny-printf: avoid any BSS usage
Date: Tue, 5 Jul 2016 15:47:12 +0530 [thread overview]
Message-ID: <577B8928.7060300@ti.com> (raw)
In-Reply-To: <1467590206-17955-1-git-send-email-andre.przywara@arm.com>
On Monday 04 July 2016 05:26 AM, Andre Przywara wrote:
> As printf calls may be executed quite early, we should avoid using any
> BSS stored variables, since some boards put BSS in DRAM, which may not
> have been initialised yet.
> Explicitly mark those "static global" variables as belonging to the
> .data section, to keep tiny-printf clear of any BSS usage.
> Please note that this is quite a hack (which may need to be extended to
> other source files) and more sustainable solutions are warmly welcomed.
>
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> ---
There is atleast one place where I encountered same issue:
drivers/i2c/i2c-uclass-compact.c:
static int cur_busnum;
I could verify that the below macro helps in that case as well.
>
> lib/tiny-printf.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c
> index 451f4f7..bc2995b 100644
> --- a/lib/tiny-printf.c
> +++ b/lib/tiny-printf.c
> @@ -13,11 +13,18 @@
> #include <stdarg.h>
> #include <serial.h>
>
> -static char *bf;
> -static char zs;
> +/*
> + * This code in here may execute before the DRAM is initialised, so
> + * we should make sure that it doesn't touch BSS, which some boards
> + * put in DRAM.
> + */
> +#define NO_BSS __attribute__((section(".data")))
> +
> +static char *bf NO_BSS;
> +static char zs NO_BSS;
>
> /* Current position in sprintf() output string */
> -static char *outstr;
> +static char *outstr NO_BSS;
>
> static void out(char c)
> {
>
--
Regards
Vignesh
prev parent reply other threads:[~2016-07-05 10:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-03 23:56 [U-Boot] [PATCH] SPL: tiny-printf: avoid any BSS usage Andre Przywara
2016-07-04 12:30 ` Marek Vasut
2016-07-04 17:05 ` Tom Rini
2016-07-05 10:17 ` Vignesh R [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=577B8928.7060300@ti.com \
--to=vigneshr@ti.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox