public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] "Embedding" default script with uboot image
@ 2015-09-22 12:20 Zatkovský Dušan
  2015-09-30  8:06 ` Zatkovský Dušan
  0 siblings, 1 reply; 4+ messages in thread
From: Zatkovský Dušan @ 2015-09-22 12:20 UTC (permalink / raw)
  To: u-boot

Hi all,

Excuse my question if it was solved somewhere in forum, but I didn't 
found an answer yet (maybe I can't find the right keywords).

I am building the uboot with yocto for imx6 board. I have started with 
some freescale defaults,
edited environment for my needs, saved environment etc ... Now I want to 
create a custom
"default" boot script, that will do some "heurestics", such as "look if 
usb stick is present, then boot from it, else boot from emmc, etc...".
Currently I am storing that script on first partition on emmc and 
loading it with ext2load.

But it has drawbacks:
- user should delete that file -> brick
- user should broke entire filesystem -> brick

I want this script to be "embedded" somehow with uboot image (which is 
placed outside partition table on device), but I didn't found any doc 
how to do that.
Currently I use CONFIG_EXTRA_ENV_SETTINGS for some basic stuffbut it is 
unmaintainable for bigger scripts.

Any suggestions?

Thank you.
--
Dusan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] "Embedding" default script with uboot image
  2015-09-22 12:20 [U-Boot] "Embedding" default script with uboot image Zatkovský Dušan
@ 2015-09-30  8:06 ` Zatkovský Dušan
  2015-10-02  7:35   ` Przemyslaw Marczak
  0 siblings, 1 reply; 4+ messages in thread
From: Zatkovský Dušan @ 2015-09-30  8:06 UTC (permalink / raw)
  To: u-boot

Really nobody?

--
Dusan

D?a 22. 9. 2015 o 14:20 Zatkovsk? Du?an nap?sal(a):
> Hi all,
>
> Excuse my question if it was solved somewhere in forum, but I didn't 
> found an answer yet (maybe I can't find the right keywords).
>
> I am building the uboot with yocto for imx6 board. I have started with 
> some freescale defaults,
> edited environment for my needs, saved environment etc ... Now I want 
> to create a custom
> "default" boot script, that will do some "heurestics", such as "look 
> if usb stick is present, then boot from it, else boot from emmc, etc...".
> Currently I am storing that script on first partition on emmc and 
> loading it with ext2load.
>
> But it has drawbacks:
> - user should delete that file -> brick
> - user should broke entire filesystem -> brick
>
> I want this script to be "embedded" somehow with uboot image (which is 
> placed outside partition table on device), but I didn't found any doc 
> how to do that.
> Currently I use CONFIG_EXTRA_ENV_SETTINGS for some basic stuffbut it 
> is unmaintainable for bigger scripts.
>
> Any suggestions?
>
> Thank you.
> -- 
> Dusan
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] "Embedding" default script with uboot image
  2015-09-30  8:06 ` Zatkovský Dušan
@ 2015-10-02  7:35   ` Przemyslaw Marczak
  2015-10-02  9:55     ` Zatkovský Dušan
  0 siblings, 1 reply; 4+ messages in thread
From: Przemyslaw Marczak @ 2015-10-02  7:35 UTC (permalink / raw)
  To: u-boot

Hi,

On 09/30/2015 10:06 AM, Zatkovsk? Du?an wrote:
> Really nobody?
>
> --
> Dusan
>
> D?a 22. 9. 2015 o 14:20 Zatkovsk? Du?an nap?sal(a):
>> Hi all,
>>
>> Excuse my question if it was solved somewhere in forum, but I didn't
>> found an answer yet (maybe I can't find the right keywords).
>>
>> I am building the uboot with yocto for imx6 board. I have started with
>> some freescale defaults,
>> edited environment for my needs, saved environment etc ... Now I want
>> to create a custom
>> "default" boot script, that will do some "heurestics", such as "look
>> if usb stick is present, then boot from it, else boot from emmc, etc...".
>> Currently I am storing that script on first partition on emmc and
>> loading it with ext2load.
>>
>> But it has drawbacks:
>> - user should delete that file -> brick
>> - user should broke entire filesystem -> brick
>>
>> I want this script to be "embedded" somehow with uboot image (which is
>> placed outside partition table on device), but I didn't found any doc
>> how to do that.
>> Currently I use CONFIG_EXTRA_ENV_SETTINGS for some basic stuffbut it
>> is unmaintainable for bigger scripts.
>>
>> Any suggestions?
>>
>> Thank you.
>> --
>> Dusan
>>
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot

The ELCE is coming, so probably people are busy.

Please check those few suggestions, which can help you:
- you can "cat" the binaries of U-Boot and your script into one binary
- you can get the address of your script in the code with few lines:

unsigned long *ptr = (unsigned long *)&_end; - start address of your DTB

ptr += fdt_totalsize(ptr) >> 2; - start address of your script

- you can add some header with "magic code" before your script binary

- check the size limit of your u-boot binary, because your script can be 
broken if the output binary exceeds the size, which can be loaded to RAM 
by SPL.

- also check if your bigger binary will not overwrite something on the 
flash layout

- to execute the script at every boot, you can modify same late 
function, like autoboot_command in common/autoboot.c ?

- so at this point, you can check your script's magic code - if added

- run script with:

char cmd[64];

sprintf(cmd, "source %p", ptr);
run_command(cmd, 0);

If you add some logic for checking if the script is valid (e.g. header 
with size and crc ?), then I think you can be sure, that it will work.

Best regards,
-- 
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] "Embedding" default script with uboot image
  2015-10-02  7:35   ` Przemyslaw Marczak
@ 2015-10-02  9:55     ` Zatkovský Dušan
  0 siblings, 0 replies; 4+ messages in thread
From: Zatkovský Dušan @ 2015-10-02  9:55 UTC (permalink / raw)
  To: u-boot

Hi,

thx for answer.

My colleague found a way that he:

- converts txt script to u-boot form (by mkimage)
- converts uboot script to .o object ($(OBJCOPY) -I binary -O 
elf32-littlearm -B arm --rename-section .data=.rodata   boot_script 
boot_script.o)
- then:
     extern unsigned char _binary_boot_script_start;
     setenv_hex("boot_script_addr", (ulong)&_binary_boot_script_start);
     run_command_list("source ${boot_script_addr}", -1, 0);

Seems it works OK. Thx you and also him :D

bye

--
Dusan

D?a 2. 10. 2015 o 9:35 Przemyslaw Marczak nap?sal(a):
> Hi,
>
> On 09/30/2015 10:06 AM, Zatkovsk? Du?an wrote:
>> Really nobody?
>>
>> -- 
>> Dusan
>>
>> D?a 22. 9. 2015 o 14:20 Zatkovsk? Du?an nap?sal(a):
>>> Hi all,
>>>
>>> Excuse my question if it was solved somewhere in forum, but I didn't
>>> found an answer yet (maybe I can't find the right keywords).
>>>
>>> I am building the uboot with yocto for imx6 board. I have started with
>>> some freescale defaults,
>>> edited environment for my needs, saved environment etc ... Now I want
>>> to create a custom
>>> "default" boot script, that will do some "heurestics", such as "look
>>> if usb stick is present, then boot from it, else boot from emmc, 
>>> etc...".
>>> Currently I am storing that script on first partition on emmc and
>>> loading it with ext2load.
>>>
>>> But it has drawbacks:
>>> - user should delete that file -> brick
>>> - user should broke entire filesystem -> brick
>>>
>>> I want this script to be "embedded" somehow with uboot image (which is
>>> placed outside partition table on device), but I didn't found any doc
>>> how to do that.
>>> Currently I use CONFIG_EXTRA_ENV_SETTINGS for some basic stuffbut it
>>> is unmaintainable for bigger scripts.
>>>
>>> Any suggestions?
>>>
>>> Thank you.
>>> -- 
>>> Dusan
>>>
>>
>> _______________________________________________
>> U-Boot mailing list
>> U-Boot at lists.denx.de
>> http://lists.denx.de/mailman/listinfo/u-boot
>
> The ELCE is coming, so probably people are busy.
>
> Please check those few suggestions, which can help you:
> - you can "cat" the binaries of U-Boot and your script into one binary
> - you can get the address of your script in the code with few lines:
>
> unsigned long *ptr = (unsigned long *)&_end; - start address of your DTB
>
> ptr += fdt_totalsize(ptr) >> 2; - start address of your script
>
> - you can add some header with "magic code" before your script binary
>
> - check the size limit of your u-boot binary, because your script can 
> be broken if the output binary exceeds the size, which can be loaded 
> to RAM by SPL.
>
> - also check if your bigger binary will not overwrite something on the 
> flash layout
>
> - to execute the script at every boot, you can modify same late 
> function, like autoboot_command in common/autoboot.c ?
>
> - so at this point, you can check your script's magic code - if added
>
> - run script with:
>
> char cmd[64];
>
> sprintf(cmd, "source %p", ptr);
> run_command(cmd, 0);
>
> If you add some logic for checking if the script is valid (e.g. header 
> with size and crc ?), then I think you can be sure, that it will work.
>
> Best regards,

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-10-02  9:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-22 12:20 [U-Boot] "Embedding" default script with uboot image Zatkovský Dušan
2015-09-30  8:06 ` Zatkovský Dušan
2015-10-02  7:35   ` Przemyslaw Marczak
2015-10-02  9:55     ` Zatkovský Dušan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox