Skip to contentSkip to conversation

Handling images(.jpg, .bmp etc) in u-boot

U-Boot bhargavak 3 participants 12 messages Mar 24, 2013 – Apr 6, 2013

lore
Share & tools
lore

bhargavak

author
#0 lore raw

Hi

I have currently implemented u-boot splash screen, a battery charging animation(as a series images) in u-boot on my board, all of the above by creating a GIMP header (.h) for each of the image.

The problem I'm facing is, the size of the u-boot binary is ever increasing, as the headers for each image is very large even though all of them take up only 1/4 of the screen size(WVGA).

Now, I'm supposed to implement a full screen size splash screen and add a few more images to accommodate extra levels of battery charging.

With this added my u-boot.bin goes upto 4-5MB (and that is bad right ??)

I just came to know that there is a method where we can create a partition and put images(.bmp) into the EMMC flash.
I saw the u-boot's manual where there is a description about a environment variable 'splashimage'.

My concern here is, can someone please elaborate the procedure mentioned there.
I do not have a network connection to my board, I just have a microUSB cable connection my PC and the board.

If there are any other methods to implement the whole thing better, suggestions a welcome.

--
View this message in context: http://u-boot.10912.n7.nabble.com/Handling-images-jpg-bmp-etc-in-u-boot-tp150524.html
Sent from the U-Boot mailing list archive at Nabble.com.

#1 lore raw

Dear bhargavak,

Quoted 4 lines · In message <[email protected]> you wrote:

I have currently implemented u-boot splash screen, a battery charging animation(as a series images) in u-boot on my board, all of the above by creating a GIMP header (.h) for each of the image.

Why are you doing this? Why don't you just load the bmp files within U-Boot?

Quoted 3 lines

The problem I'm facing is, the size of the u-boot binary is ever increasing, as the headers for each image is very large even though all of them take up only 1/4 of the screen size(WVGA).

Why don;t you draw smaller images, then? For battery charging state, a pretty small image (definitely smaller than 1/4 WVGA) should be more than adequate.

Quoted 4 lines

Now, I'm supposed to implement a full screen size splash screen and add a few more images to accommodate extra levels of battery charging.

With this added my u-boot.bin goes upto 4-5MB (and that is bad right ??)

Yes, this is very bad.

Quoted 7 lines

I just came to know that there is a method where we can create a partition and put images(.bmp) into the EMMC flash.
I saw the u-boot's manual where there is a description about a environment variable 'splashimage'.

My concern here is, can someone please elaborate the procedure mentioned there.

What exactly is the problem? JUst read the images from whichever storage medium you may be using, and use the bmp command to displaty them.

For example, this is the whole "code" for a slide show demo I've been using on a number of trade shows:

	bootdelay=6
	show_one=fatload mmc 0:2 40001000 slide-${i}.bmp;bmp d 40001000
	slide_show=while mmc rescan; do for i in 1 2 3 4 5 6 7 8 ; do run show_one ; sleep ${delay} ; done ; done
	bootcmd=run slideshow
Quoted 2 lines

If there are any other methods to implement the whole thing better, suggestions a welcome.

Well, reduce the images you are drowing to the really needed size.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Let us not look back in anger or  forward  in  fear,  but  around  in
awareness.                                            - James Thurber
author
#2 lore raw

Hi Wolfgang Denk

Wolfgang Denk wrote

Quoted 3 lines

What exactly is the problem? JUst read the images from whichever storage medium you may be using, and use the bmp command to displaty them.

Kindly pardon me for my ignorance,

The problem I'm facing is how do I load my images into eMMC flash. The tftp command the manual uses seems pretty staright forward, but it does require a network connection, doesn't it ?
I just have a microUSB connecting my PC and board(a device running android on OMAP44xx),
how do I proceed ?

How do I do what tftp, load to RAM, then use cp.b ? Please help me out..

--
View this message in context: http://u-boot.10912.n7.nabble.com/Handling-images-jpg-bmp-etc-in-u-boot-tp150524p150541.html
Sent from the U-Boot mailing list archive at Nabble.com.

#3 lore raw

Dear bhargavak,

Quoted 2 lines · In message <[email protected]> you wrote:

The problem I'm facing is how do I load my images into eMMC flash.

There is a several ways to do that.

Quoted 2 lines

The tftp command the manual uses seems pretty staright forward, but it does require a network connection, doesn't it ?

Yes, indeed TFTP needs a network connection (which, if supported for your hardware, can also be over USB).

Quoted 3 lines

I just have a microUSB connecting my PC and board(a device running android on OMAP44xx),
how do I proceed ?

If the device is running Android, you definitely also have a network connection, or don't you? Why don't you do the needed formatting of the eMMA< creationof file system and installation f the images under an OS, then?

In U-Boot then you can simply read from that file system.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]
You Don't Have To Be 'Damned' To Work Here, But It Helps!!!
                                             - Terry Pratchett, _Eric_
author
#4 lore raw

I created a partition in my eMMC, used fastboot to flash a "example.bmp".. How do I get the base address of the partition ?

I have the following partitions on my device running android, has a u-boot bootloader

U-Boot 1.1.4.XTRAVERSION-g6c554dbc-dirty (Mar 26 2013 - 14:26:11 Load address: 0x80e80000
DRAM: 512 MB
Flash: 0 kB
Using default environment
In: serial
Out: serial
Err: serial
efi partition table:

ptbl slot:    EMMC:(1).
      256     128K      xloader
      512     3M         bootloader
    6656     512K      splash
    7680     128K      misc
    8704     64M       efs
 139776    16K        crypto
 139808    16M        recovery
 172576    8M          boot
 188960    512M      system
1237536   256M      cache
1761824   128M      apk
2023968   2787M    userdata

How do I get the base address of each partition, I tried the following commands in u-boot but It either gives me an error or doesn't return anything
1. # flinfo
Bank # 1: missing or unknown FLASH type
Bank # 2: missing or unknown FLASH type

2. fsinfo
Device Hangs up

3. # fli
Bank # 1: missing or unknown FLASH type
Bank # 2: missing or unknown FLASH type

Please help me find the base address of each of the partition.

--
View this message in context: http://u-boot.10912.n7.nabble.com/Handling-images-jpg-bmp-etc-in-u-boot-tp150524p151089.html
Sent from the U-Boot mailing list archive at Nabble.com.

#5 lore raw

Hi,

Quoted 29 lines · On Sat, 30 Mar 2013 10:47:08 -0700 (PDT) bhargavak <[email protected]>…

I created a partition in my eMMC, used fastboot to flash a "example.bmp".. How do I get the base address of the partition ?

I have the following partitions on my device running android, has a u-boot bootloader

U-Boot 1.1.4.XTRAVERSION-g6c554dbc-dirty (Mar 26 2013 - 14:26:11 Load address: 0x80e80000
DRAM: 512 MB
Flash: 0 kB
Using default environment
In: serial
Out: serial
Err: serial
efi partition table:

ptbl slot:    EMMC:(1).
      256     128K      xloader
      512     3M         bootloader
    6656     512K      splash
    7680     128K      misc
    8704     64M       efs
 139776    16K        crypto
 139808    16M        recovery
 172576    8M          boot
 188960    512M      system
1237536   256M      cache
1761824   128M      apk
2023968   2787M    userdata
Quoted 1 line

How do I get the base address of each partition,

you seem to have only one efi partition. What do you need the base address for?

Quoted 6 lines

I tried the following
commands in u-boot but It either gives me an error or doesn't return anything
1. # flinfo
Bank # 1: missing or unknown FLASH type
Bank # 2: missing or unknown FLASH type

This command is for NOR-Flash info, so this output is expected.

Quoted 8 lines

2. fsinfo
Device Hangs up

3. # fli
Bank # 1: missing or unknown FLASH type
Bank # 2: missing or unknown FLASH type

Please help me find the base address of each of the partition.

For loading files from a partition you do not need to know its base address. Use appropriate commands, "fatload" comes to mind.

HTH,

Anatolij

author
#6 lore raw

Hi

Thank you for that heads up.
In one of posts above a reference to the following code fragment is made, it uses a fatload command

Quoted 8 lines

For example, this is the whole "code" for a slide show demo I've been using on a number of trade shows:

bootdelay=6
show_one=fatload mmc 0:2 40001000 slide-${i}.bmp;bmp d 40001000 slide_show=while mmc rescan; do for i in 1 2 3 4 5 6 7 8 ; do run
show_one ; sleep ${delay} ; done ; done
bootcmd=run slideshow

Can you please explain the "show_one" and the "slide_show" commands ? And, do I just put this into board config ?

--
View this message in context: http://u-boot.10912.n7.nabble.com/Handling-images-jpg-bmp-etc-in-u-boot-tp150524p151106.html
Sent from the U-Boot mailing list archive at Nabble.com.

#7 lore raw

Hi,

Quoted 9 lines · On Sun, 31 Mar 2013 02:30:00 -0700 (PDT) bhargavak <[email protected]>…

Hi

Thank you for that heads up.
In one of posts above a reference to the following code fragment is made, it uses a fatload command

Quoted 2 lines

For example, this is the whole "code" for a slide show demo I've been using on a number of trade shows:

Quoted 8 lines
Quoted 5 lines

bootdelay=6
show_one=fatload mmc 0:2 40001000 slide-${i}.bmp;bmp d 40001000 slide_show=while mmc rescan; do for i in 1 2 3 4 5 6 7 8 ; do run
show_one ; sleep ${delay} ; done ; done
bootcmd=run slideshow

Can you please explain the "show_one" and the "slide_show" commands ? And, do I just put this into board config ?

"show_one" and "slide_show" are environment variables containing a sequence of U-Boot commands. These can be executed by "run show_one" or "run slide_show".

When "show_one" is executed, U-Boot runs two commands:

fatload mmc 0:2 40001000 slide-${i}.bmp

and

bmp display 40001000

The first command loads a file (i.e. "slide-0.bmp") into SDRAM memory at address 0x40001000. It loads the file from the MMC/SD-Card which is connected to the first available SD-Card controller. The file is loaded from the second partition on the SD-Card which is a FAT partition (therefore fatload command). The "${i}" in the file name is used to be able to load images with different file names when this command is executed in a loop.

The second command reads the image at address 0x40001000 in SDRAM, decodes the image data and copies it into the frame buffer.

"slide_show" command is a loop which test for SD-Card presence ("mmc rescan") and executes another inner loop in which the "show_one" command is running 8 times with index "i" counting from 1 to 8 (so that 8 different images are loaded into SDRAM while each loop iteration). After each load/display operation in the loop the execution of the next loop iteration is delayed by the amount of seconds specified in the "delay" environment variable.

Note that these loops will only work if U-Boot was built with enabled CONFIG_SYS_HUSH_PARSER in the board configuration.

You normally won't put these commands into board config. You have to setup the environment variables on the U-Boot command line using "setenv" command and save them using "saveenv" command.

HTH,

Anatolij

author
#8 lore raw

That's a very nice explanation..
Here's what I will do, please tell me if the whole procedure is right.

I have a SD-card partitioned as follows:
boot: FAT32, holds a MLO and u-boot.bin through which I boot my device (runs on OMAP4470)
rootfs: mostly empty always (ext4 currently), I will format it as FAT32

I copy "slide-0.bmp" into the rootfs partition and define "CONFIG_SYS_HUSH_PARSER".

Then I stop the bootloader before the kernel starts, do "setenv" as follows, and "saveenv"

Quoted 1 line

show_one=fatload mmc 0:2 40001000 slide-${i}.bmp;bmp d 40001000

Then do the following:

Quoted 1 line

run show_one

I should be able to see the image on the screen ?
Is there any other configuration options that I should enable ?

For some reason "saveenv" was not working for me yesterday, when I tried to experiment with the "splashimage" environment variable.
I do not remember the exact error it threw, I could post the error first thing tomorrow from my workplace.
As a workaround can I set above variables in my "OMAP" config header ? My u-boot version is "U-Boot 1.1.4-geb3fa991".

--
View this message in context: http://u-boot.10912.n7.nabble.com/Handling-images-jpg-bmp-etc-in-u-boot-tp150524p151108.html
Sent from the U-Boot mailing list archive at Nabble.com.

#9 lore raw
Quoted 10 lines · On Sun, 31 Mar 2013 04:54:35 -0700 (PDT) bhargavak <[email protected]>…

That's a very nice explanation..
Here's what I will do, please tell me if the whole procedure is right.

I have a SD-card partitioned as follows:
boot: FAT32, holds a MLO and u-boot.bin through which I boot my device (runs on OMAP4470)
rootfs: mostly empty always (ext4 currently), I will format it as FAT32

I copy "slide-0.bmp" into the rootfs partition and define "CONFIG_SYS_HUSH_PARSER".

Note that CONFIG_SYS_HUSH_PARSER is not necessary if you do not use 'for' or 'while' loops (but it won't hurt, an maybe it is already defined in your config file).

Quoted 3 lines

Then I stop the bootloader before the kernel starts, do "setenv" as follows, and "saveenv"

Quoted 1 line

show_one=fatload mmc 0:2 40001000 slide-${i}.bmp;bmp d 40001000

Note that when Wolfgang showed you this example, it was only for reference how it could be done. You shouldn't blindly input commands without understanding what these commands are supposed to do. You also should read the command documentation in the U-Boot manual and apply common sense. For example the load address 40001000 in the above example is valid only for a particular architecture, starting offset of the DRAM memory and available memory size. Using 40001000 address in your case might be wrong.

In your case only 512 MiB DRAM is available, you need to figure out where the DRAM starts. Use "bdinfo" command and look at the DRAM bank start value, i.e.:

U-Boot > bdinfo
...

DRAM bank   = 0x00000000
-> start    = 0x10000000
-> size     = 0x40000000

...

In this example the memory starts at address 0x10000000, so a reasonable load address could be 10001000 (since the area starting from 10000000 might contain interrupt/exception vectors, we skip 0x1000 sized block at start of DRAM).

for setting the environment variable use

setenv show_one 'fatload mmc 0:2 40001000 slide-0.bmp;bmp d 40001000'

but replace 40001000 address with a valid address for your board. On my board from the above example I could use address 10001000.

Quoted 4 lines

Then do the following:

Quoted 1 line

run show_one

I should be able to see the image on the screen ?

Provided you used a valid load address and enabled support for "bmp" command and splash screen, yes.

Quoted 1 line

Is there any other configuration options that I should enable ?

I do not know your board and do not have your U-Boot source, so cannot tell for sure. But you need at least

CONFIG_CMD_BMP
CONFIG_SPLASH_SCREEN
CONFIG_VIDEO
CONFIG_CFB_CONSOLE
CONFIG_VGA_AS_SINGLE_DEVICE
CONFIG_SYS_CONSOLE_IS_IN_ENV

and the config option to enable your video driver.

Quoted 5 lines

For some reason "saveenv" was not working for me yesterday, when I tried to experiment with the "splashimage" environment variable.
I do not remember the exact error it threw, I could post the error first thing tomorrow from my workplace.
As a workaround can I set above variables in my "OMAP" config header ?

Look at the CONFIG_EXTRA_ENV_SETTINGS definition in your config header. It includes additional definitions for embedded environment. You could add your variables in this list, but it is only used if the default environment is used. Your board is not in mainline, so I cannot tell exactly what else might be needed.

Quoted 1 line

My u-boot version is "U-Boot 1.1.4-geb3fa991".

This version is _very_ old, we do not support it.

Thanks,

Anatolij

author
#11 lore raw
In reply to Anatolij Gustschin

Anatolij,

Thanks for the direction you gave..

I'm able to move all the images into one partiton and display each of them on need basis
by branching to the respective offset addresses.

I need to know the following, can you please give me your suggestion:

I have been asked to find out if u-boot supports displaying images without having to store them into any
partition in advance. (Why ? the question here was, what if someone forgets to flash the images ? bizzare ? I don't know.. ;) )

Can we zip a .bmp image and compile it with a u-boot and unzip the archive runtime ?
If this is possible, can it be done without increasing the size of the "u-boot.bin" ?

I tried the "xxd -i" command to get a hex dump of the .zip file into a ".h" file,
but this method increased the size of the "*.h" file generated. (it is almost the same as the .bmp file inside the .zip)

Can you please give me your suggestions.

Regards
Bhargav

Quoted 101 lines · Anatolij Gustschin
Quoted 5 lines · On Sun, 31 Mar 2013 04:54:35 -0700 (PDT) bhargavak <[email protected]>…

That's a very nice explanation..
Here's what I will do, please tell me if the whole procedure is right.

I have a SD-card partitioned as follows:
boot: FAT32, holds a MLO and u-boot.bin through which I boot my device

(runs

Quoted 5 lines

on OMAP4470)
rootfs: mostly empty always (ext4 currently), I will format it as FAT32

I copy "slide-0.bmp" into the rootfs partition and define "CONFIG_SYS_HUSH_PARSER".

Note that CONFIG_SYS_HUSH_PARSER is not necessary if you do not use 'for' or 'while' loops (but it won't hurt, an maybe it is already defined in your config file).

Quoted 1 line

Then I stop the bootloader before the kernel starts, do "setenv" as

follows,

Quoted 2 lines

and "saveenv"

Quoted 1 line

show_one=fatload mmc 0:2 40001000 slide-${i}.bmp;bmp d 40001000

Note that when Wolfgang showed you this example, it was only for reference how it could be done. You shouldn't blindly input commands without understanding what these commands are supposed to do. You also should read the command documentation in the U-Boot manual and apply common sense. For example the load address 40001000 in the above example is valid only for a particular architecture, starting offset of the DRAM memory and available memory size. Using 40001000 address in your case might be wrong.

In your case only 512 MiB DRAM is available, you need to figure out where the DRAM starts. Use "bdinfo" command and look at the DRAM bank start value, i.e.:

U-Boot > bdinfo
...

DRAM bank   = 0x00000000
-> start    = 0x10000000
-> size     = 0x40000000

...

In this example the memory starts at address 0x10000000, so a reasonable load address could be 10001000 (since the area starting from 10000000 might contain interrupt/exception vectors, we skip 0x1000 sized block at start of DRAM).

for setting the environment variable use

setenv show_one 'fatload mmc 0:2 40001000 slide-0.bmp;bmp d 40001000'

but replace 40001000 address with a valid address for your board. On my board from the above example I could use address 10001000.

Quoted 4 lines

Then do the following:

Quoted 1 line

run show_one

I should be able to see the image on the screen ?

Provided you used a valid load address and enabled support for "bmp" command and splash screen, yes.

Quoted 1 line

Is there any other configuration options that I should enable ?

I do not know your board and do not have your U-Boot source, so cannot tell for sure. But you need at least

CONFIG_CMD_BMP
CONFIG_SPLASH_SCREEN
CONFIG_VIDEO
CONFIG_CFB_CONSOLE
CONFIG_VGA_AS_SINGLE_DEVICE
CONFIG_SYS_CONSOLE_IS_IN_ENV

and the config option to enable your video driver.

Quoted 1 line

For some reason "saveenv" was not working for me yesterday, when I tried

to

Quoted 4 lines

experiment with the "splashimage" environment variable.
I do not remember the exact error it threw, I could post the error first thing tomorrow from my workplace.
As a workaround can I set above variables in my "OMAP" config header ?

Look at the CONFIG_EXTRA_ENV_SETTINGS definition in your config header. It includes additional definitions for embedded environment. You could add your variables in this list, but it is only used if the default environment is used. Your board is not in mainline, so I cannot tell exactly what else might be needed.

Quoted 1 line

My u-boot version is "U-Boot 1.1.4-geb3fa991".

This version is _very_ old, we do not support it.

Thanks,

Anatolij