public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Nikita Kiryanov <nikita@compulab.co.il>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 5/5] cm-t35: add support for loading splash image from NAND
Date: Tue, 25 Dec 2012 10:56:57 +0200	[thread overview]
Message-ID: <50D96A59.2030305@compulab.co.il> (raw)
In-Reply-To: <50D81891.1030503@myspectrum.nl>

Hi Jeroen,

On 12/24/2012 10:55 AM, Jeroen Hofstee wrote:
> Hi Nikita,
>
> On 12/23/2012 08:03 AM, Nikita Kiryanov wrote:
>> Add support for loading splash image from NAND
>>
>> Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
>> Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
>> ---
>>   board/cm_t35/cm_t35.c    |   61
>> ++++++++++++++++++++++++++++++++++++++++++++++
>>   include/configs/cm_t35.h |    4 +++
>>   2 files changed, 65 insertions(+)
>>
>> diff --git a/board/cm_t35/cm_t35.c b/board/cm_t35/cm_t35.c
>> index 8f3d735..8dbdb44 100644
>> --- a/board/cm_t35/cm_t35.c
>> +++ b/board/cm_t35/cm_t35.c
>> @@ -33,7 +33,9 @@
>>   #include <net.h>
>>   #include <i2c.h>
>>   #include <usb.h>
>> +#include <nand.h>
>>   #include <twl4030.h>
>> +#include <bmp_layout.h>
>>   #include <linux/compiler.h>
>>   #include <asm/io.h>
>> @@ -75,6 +77,65 @@ static u32 gpmc_nand_config[GPMC_MAX_REG] = {
>>       0,
>>   };
>> +#ifdef CONFIG_LCD
>> +#ifdef CONFIG_CMD_NAND
>> +static int splash_load_from_nand(u32 bmp_load_addr)
>> +{
>> +    struct bmp_header *bmp_hdr;
>> +    int res, splash_screen_nand_offset = 0x100000;
>> +    size_t bmp_size, bmp_header_size = sizeof(struct bmp_header);
>> +
>> +    if (bmp_load_addr + bmp_header_size >= gd->start_addr_sp)
>> +        goto splash_address_too_high;
>> +
>> +    res = nand_read_skip_bad(&nand_info[nand_curr_device],
>> +            splash_screen_nand_offset, &bmp_header_size,
>> +            (u_char *)bmp_load_addr);
>> +    if (res < 0)
>> +        return res;
>> +
>> +    bmp_hdr = (struct bmp_header *)bmp_load_addr;
>> +    bmp_size = le32_to_cpu(bmp_hdr->file_size);
>> +
>> +    if (bmp_load_addr + bmp_size >= gd->start_addr_sp)
>> +        goto splash_address_too_high;
>> +
>> +    return nand_read_skip_bad(&nand_info[nand_curr_device],
>> +            splash_screen_nand_offset, &bmp_size,
>> +            (u_char *)bmp_load_addr);
>> +
>> +splash_address_too_high:
>> +    printf("Error: splashimage address too high. Data overwrites
>> U-Boot "
>> +        "and/or placed beyond DRAM boundaries.\n");
>> +
>> +    return -1;
>> +}
>> +#else
>> +static inline int splash_load_from_nand(void)
>> +{
>> +    return -1;
>> +}
>> +#endif /* CONFIG_CMD_NAND */
>> +
>> +int board_splash_screen_prepare(void)
>> +{
>> +    char *env_splashimage_value;
>> +    u32 bmp_load_addr;
>> +
>> +    env_splashimage_value = getenv("splashimage");
>> +    if (env_splashimage_value == NULL)
>> +        return -1;
>> +
>> +    bmp_load_addr = simple_strtoul(env_splashimage_value, 0, 16);
>> +    if (bmp_load_addr == 0) {
>> +        printf("Error: bad splashimage address specified\n");
>> +        return -1;
>> +    }
>> +
>> +    return splash_load_from_nand(bmp_load_addr);
>> +}
>> +#endif /* CONFIG_LCD */
>> +
> fyi, I noticed that my board compiled with gcc 4.7.3 from ELDK 5.3 will
> trap
> if the bitmap is not aligned. Aligned is a bit tricky though since the
> bitmap
> has the signature, e.g. "BM" prepended and is thereafter 32 bit aligned
> (or at least combined fields of 32 bits). In my case displaying the
> bitmap now only works when loaded to an aligned address - 2. Since
> you accept the value from the user, which has no ability to restore it once
> set "incorrectly", you might want to check the load address (well obviously
> only if it is a problem in your case as well).

Thanks for verifying this issue. I did encounter it during testing, but
I assumed it to be a compiler problem because it worked when compiling
with a different version.

Loading to aligned address - 2 works for me as well when compiling with
the problematic compiler, but this is strange to me. Isn't the "packed"
attribute that is applied to bmp_header_t supposed to prevent these
types of problems by effectively forcing the compiler to assume byte
alignment?

Albert, can you shed some light on this?

>
> Regards,
> Jeroen
>


-- 
Regards,
Nikita.

  reply	other threads:[~2012-12-25  8:56 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-23  7:03 [U-Boot] [PATCH 0/5] Add splash screen for CM-T35 Nikita Kiryanov
2012-12-23  7:03 ` [U-Boot] [PATCH 1/5] omap3: add useful dss defines Nikita Kiryanov
2013-01-20 21:42   ` Jeroen Hofstee
2013-01-21  7:53     ` Nikita Kiryanov
2013-01-21 18:38       ` Jeroen Hofstee
2013-01-23  8:23         ` Nikita Kiryanov
2012-12-23  7:03 ` [U-Boot] [PATCH 2/5] lcd: add option for board specific splash screen preparation Nikita Kiryanov
2013-01-20 20:34   ` Jeroen Hofstee
2013-01-21  7:51     ` Nikita Kiryanov
2013-01-21 19:14       ` Jeroen Hofstee
2013-01-23  8:31         ` Nikita Kiryanov
2013-01-23 22:13           ` Jeroen Hofstee
2013-01-24  8:35             ` Igor Grinberg
2013-01-24 22:34               ` Jeroen Hofstee
2013-01-25  6:45                 ` Igor Grinberg
2013-01-26 13:33                   ` Jeroen Hofstee
2012-12-23  7:03 ` [U-Boot] [PATCH 3/5] cm-t35: add support for dvi displays Nikita Kiryanov
2013-01-20 20:59   ` Jeroen Hofstee
2013-01-21  8:12     ` Nikita Kiryanov
2013-01-23 21:39       ` Jeroen Hofstee
2013-01-24  9:02         ` Igor Grinberg
2012-12-23  7:03 ` [U-Boot] [PATCH 4/5] cm-t35: add support for user defined lcd parameters Nikita Kiryanov
2013-01-20 21:08   ` Jeroen Hofstee
2013-01-21  8:25     ` Nikita Kiryanov
2013-01-23 22:36       ` Jeroen Hofstee
2013-01-24  9:12         ` Igor Grinberg
2012-12-23  7:03 ` [U-Boot] [PATCH 5/5] cm-t35: add support for loading splash image from NAND Nikita Kiryanov
2012-12-24  8:55   ` Jeroen Hofstee
2012-12-25  8:56     ` Nikita Kiryanov [this message]
2012-12-26 14:27       ` Jeroen Hofstee
2012-12-30 14:39         ` Nikita Kiryanov
2013-01-22  7:37           ` Albert ARIBAUD
2013-01-23 10:47             ` Nikita Kiryanov
2013-01-23 11:07               ` Nikita Kiryanov
2013-03-26 14:51   ` [U-Boot] [U-Boot, " Tom Rini
2013-01-20 12:25 ` [U-Boot] [PATCH 0/5] Add splash screen for CM-T35 Nikita Kiryanov
2013-01-20 20:31   ` Jeroen Hofstee
2013-01-21 14:10   ` Tom Rini

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=50D96A59.2030305@compulab.co.il \
    --to=nikita@compulab.co.il \
    --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