Re: [U-Boot] [PATCH 1/2] arm: use $loadaddr as the standalone entry point

2017-08-18 Thread Tom Rini
On Tue, Aug 15, 2017 at 03:21:15PM +0200, Wolfgang Denk wrote:
> Dear Tom,
> 
> In message <20170815113952.GE20467@bill-the-cat> you wrote:
> > 
> > What CONFIG_STANDALONE_LOAD_ADDR is, is the location that we want
> > hello_world, or other example stand alone applications loaded into
> > memory at.  CONFIG_LOADADDR is the safe default location to load things
> > into memory at in order to run them.  At least on ARM, where there's a
> > good number of different default memory layouts, what arch/arm/config.mk
> > does today is broken for the majority of platforms.
> 
> I agree up to here.
> 
> > We should be
> > providing at least a functional default value here, which we are not
> > today.  This in no way precludes a 'real' standalone application from
> > linking and running at whatever it wants within a platforms memory map.
> 
> This is where things become fishy.
> 
> We should use clean terms.

OK.

> Please keep in mind that even the term "load address" can mean two
> things: many people use this term (incorrectly) for the address where
> they load an image to on RAM, and unfortunately we even provide the
> "loadaddr" environment variable which carries this meaning.

We'll use this for now at least, for consistency.

> Originally, the term refers to the address where the image payload gets
> uncompressed and loaded to when unpacking the image.  For example,
> on Power architecture, a typical setup would look like:
> 
> Output of mkimage -l:
> 
>   Image Name:   Linux-4.4.8
>   Created:  Fri Apr 22 09:06:09 2016
>   Image Type:   PowerPC Linux Kernel Image (gzip compressed)
>   Data Size:2009139 Bytes = 1962.05 kB = 1.92 MB
>   Load Address: 
>   Entry Point:  
> 
> We download the uImage file to - say - 0x40 in RAM (so the
> environment variable "loadaddr" might be 0x40),  but when we run
> "bootm", U-Boot will uncompress and _load_ the Linux kernel to the
> _Load_Address_ stored in the image header, i. e. 0x, and then
> it will transfer control to the _Entry_Point_Address_, also stored
> in the image header, here also 0x.
> 
> So we have:
> 
> download address (address of image in RAM):   0x0040
> load address (start of unpacked kernel image):0x
> entry point (start of executable code):   0x
> 
> 
> The term "load address" has always been meant to mean the address
> where the kernel gets _loaded_to_ by the bootm command.  I know that
> there has always been confusion of these terms, and I must have
> explained this at least a hundred times here before.

This is all true.  But it's also unrelated to what
CONFIG_STANDALONE_LOAD_ADDR is used for.  So...

> I would really appreciate if you helped to avoid mixing terms of
> different meaning.  If you have an idea how to avoid this it would
> be more than welcome - unfortunately the (mis)use of the loadaddr
> environment variable is so widespread that I feat there is no easy
> way out.

I think the first problem is that we need to rename
CONFIG_STANDALONE_LOAD_ADDR to CONFIG_EXAMPLE_STANDALONE_ENTRY_POINT to
be more precise about what it is doing and used for, all around.  And
then, I'm not sure.  I had an idea, but I seem to have found that at
least right this moment, hello_world.bin doesn't function for me and I
would swear I had unit tested be1b8679ce42 but it is not working for me
either.  But I'm going to put this down for the evening at least...

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] arm: use $loadaddr as the standalone entry point

2017-08-15 Thread Wolfgang Denk
Dear Max,

In message <1502799746.3076.16.ca...@gmail.com> you wrote:
> 
> Wolfgang says that a board needs to decide on what image type to
> use for the standalone application and then from that set an

No, I did not say this.  On contrary, this is not up to the "board"
to decide.  This is a decision tobe made by the end user, and U-Boot
shall not put any restrictions on this.  You may want to use a raw
binary image, someone else uses an ELF file or an uImage, and I
prefer to use a FIT image.

> appropriate CONFIG_STANDALONE_LOAD_ADDR in its board configuration.

The LOAD_ADDR you use it is a misleading name for where the image
gets loaded to in memory. Note that the payload can be compressed or
encrypted or what else.  The "load address" in the intended meaning
(as present in the image headers) is where the payload of the images
gets stored in memory (which may include decryption, uncompressing
or else).  And entry point is still something else.

> Without that the standalone binaries are useless anyway and setting
> a default in arch/arm/config.mk only purpose is that the build succeeds.

For the build process, only the "load address" and "entry point
address" in their original meaning should be interesting - but his
is not what CONFIG_STANDALONE_LOAD_ADDR provides.

> My motivation to write the patch in the first place (and Tom seems to
> agree) is that for boards who define nothing at least the plain binary
> is linked to a memory address where one can load something.

I also agree with this.  I just want to use a misleading name for
this default.  If you need an start address for the text segment
you should call it like that - we already have CONFIG_SYS_TEXT_BASE
and CONFIG_SPL_TEXT_BASE, so why not use CONFIG_STANDALONE_TEXT_BASE
here?

> Note that I sent a v2 of the patchset addressing Wolfgang's first
> emails. v2 hopefully dropped the wrong connection of load/link
> address with entry point.

No, it does not, as it still uses CONFIG_LOADADDR (= default
download address of some image type) where you in fact mean the
default start address of the data payload only (and very likely this
is the same as the start of the text segment).

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
A verbal contract isn't worth the paper it's written on.
-- Samuel Goldwyn
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] arm: use $loadaddr as the standalone entry point

2017-08-15 Thread Wolfgang Denk
Dear Tom,

In message <20170815113952.GE20467@bill-the-cat> you wrote:
> 
> What CONFIG_STANDALONE_LOAD_ADDR is, is the location that we want
> hello_world, or other example stand alone applications loaded into
> memory at.  CONFIG_LOADADDR is the safe default location to load things
> into memory at in order to run them.  At least on ARM, where there's a
> good number of different default memory layouts, what arch/arm/config.mk
> does today is broken for the majority of platforms.

I agree up to here.

> We should be
> providing at least a functional default value here, which we are not
> today.  This in no way precludes a 'real' standalone application from
> linking and running at whatever it wants within a platforms memory map.

This is where things become fishy.

We should use clean terms.

Please keep in mind that even the term "load address" can mean two
things: many people use this term (incorrectly) for the address where
they load an image to on RAM, and unfortunately we even provide the
"loadaddr" environment variable which carries this meaning.
Originally, the term refers to the address where the image payload gets
uncompressed and loaded to when unpacking the image.  For example,
on Power architecture, a typical setup would look like:

Output of mkimage -l:

Image Name:   Linux-4.4.8
Created:  Fri Apr 22 09:06:09 2016
Image Type:   PowerPC Linux Kernel Image (gzip compressed)
Data Size:2009139 Bytes = 1962.05 kB = 1.92 MB
Load Address: 
Entry Point:  

We download the uImage file to - say - 0x40 in RAM (so the
environment variable "loadaddr" might be 0x40),  but when we run
"bootm", U-Boot will uncompress and _load_ the Linux kernel to the
_Load_Address_ stored in the image header, i. e. 0x, and then
it will transfer control to the _Entry_Point_Address_, also stored
in the image header, here also 0x.

So we have:

download address (address of image in RAM): 0x0040
load address (start of unpacked kernel image):  0x
entry point (start of executable code): 0x


The term "load address" has always been meant to mean the address
where the kernel gets _loaded_to_ by the bootm command.  I know that
there has always been confusion of these terms, and I must have
explained this at least a hundred times here before.


I would really appreciate if you helped to avoid mixing terms of
different meaning.  If you have an idea how to avoid this it would
be more than welcome - unfortunately the (mis)use of the loadaddr
environment variable is so widespread that I feat there is no easy
way out.



Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
I'd rather be led to hell than managed to heaven.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] arm: use $loadaddr as the standalone entry point

2017-08-15 Thread Max Krummenacher
Hello all

Am Dienstag, den 15.08.2017, 07:39 -0400 schrieb Tom Rini:
> On Tue, Aug 15, 2017 at 09:32:30AM +0200, Wolfgang Denk wrote:
> > 
> > Dear Tom,
> > 
> > In message <20170814211300.GM20467@bill-the-cat> you wrote:
> > > 
> > > 
> > > But we're talking about CONFIG_STANDALONE_LOAD_ADDR not
> > > CONFIG_STANDALONE_ENTRY_POINT.  What we've been doing in
> > > arch/arm/config.mk has been on my to fix list for a long time, because
> > > it's been wrong for so many boards.  Setting this to CONFIG_LOADADDR is
> > > a reasonable default value.
> > 
> > No, it is not.  It is fundamentally broken. If you need a default
> > for the entry point address, then define one.  CONFIG_LOADADDR means
> > where the image gets loaded to, and almost all image formats have a
> > header in front of the payuload, so the entry point is somewhere
> > else.  And even if you load raw binary images, there is no guarantee
> > that the entry point is right at the start of the image,
> > 
> > Mixing things that are defined for different purposes (loading image
> > versus start address of the code) is a really bad idea.
> 
> What CONFIG_STANDALONE_LOAD_ADDR is, is the location that we want
> hello_world, or other example stand alone applications loaded into
> memory at.  CONFIG_LOADADDR is the safe default location to load things
> into memory at in order to run them.  At least on ARM, where there's a
> good number of different default memory layouts, what arch/arm/config.mk
> does today is broken for the majority of platforms.  We should be
> providing at least a functional default value here, which we are not
> today.  This in no way precludes a 'real' standalone application from
> linking and running at whatever it wants within a platforms memory map.

Wolfgang says that a board needs to decide on what image type to
use for the standalone application and then from that set an
appropriate CONFIG_STANDALONE_LOAD_ADDR in its board configuration.
Without that the standalone binaries are useless anyway and setting
a default in arch/arm/config.mk only purpose is that the build succeeds.

My motivation to write the patch in the first place (and Tom seems to
agree) is that for boards who define nothing at least the plain binary
is linked to a memory address where one can load something.

I can live with both views.

Note that I sent a v2 of the patchset addressing Wolfgang's first
emails. v2 hopefully dropped the wrong connection of load/link
address with entry point.

Max

> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] arm: use $loadaddr as the standalone entry point

2017-08-15 Thread Tom Rini
On Tue, Aug 15, 2017 at 09:32:30AM +0200, Wolfgang Denk wrote:
> Dear Tom,
> 
> In message <20170814211300.GM20467@bill-the-cat> you wrote:
> > 
> > But we're talking about CONFIG_STANDALONE_LOAD_ADDR not
> > CONFIG_STANDALONE_ENTRY_POINT.  What we've been doing in
> > arch/arm/config.mk has been on my to fix list for a long time, because
> > it's been wrong for so many boards.  Setting this to CONFIG_LOADADDR is
> > a reasonable default value.
> 
> No, it is not.  It is fundamentally broken. If you need a default
> for the entry point address, then define one.  CONFIG_LOADADDR means
> where the image gets loaded to, and almost all image formats have a
> header in front of the payuload, so the entry point is somewhere
> else.  And even if you load raw binary images, there is no guarantee
> that the entry point is right at the start of the image,
> 
> Mixing things that are defined for different purposes (loading image
> versus start address of the code) is a really bad idea.

What CONFIG_STANDALONE_LOAD_ADDR is, is the location that we want
hello_world, or other example stand alone applications loaded into
memory at.  CONFIG_LOADADDR is the safe default location to load things
into memory at in order to run them.  At least on ARM, where there's a
good number of different default memory layouts, what arch/arm/config.mk
does today is broken for the majority of platforms.  We should be
providing at least a functional default value here, which we are not
today.  This in no way precludes a 'real' standalone application from
linking and running at whatever it wants within a platforms memory map.

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] arm: use $loadaddr as the standalone entry point

2017-08-15 Thread Wolfgang Denk
Dear Tom,

In message <20170814211300.GM20467@bill-the-cat> you wrote:
> 
> But we're talking about CONFIG_STANDALONE_LOAD_ADDR not
> CONFIG_STANDALONE_ENTRY_POINT.  What we've been doing in
> arch/arm/config.mk has been on my to fix list for a long time, because
> it's been wrong for so many boards.  Setting this to CONFIG_LOADADDR is
> a reasonable default value.

No, it is not.  It is fundamentally broken. If you need a default
for the entry point address, then define one.  CONFIG_LOADADDR means
where the image gets loaded to, and almost all image formats have a
header in front of the payuload, so the entry point is somewhere
else.  And even if you load raw binary images, there is no guarantee
that the entry point is right at the start of the image,

Mixing things that are defined for different purposes (loading image
versus start address of the code) is a really bad idea.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
The faster I go, the behinder I get. -- Lewis Carroll
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] arm: use $loadaddr as the standalone entry point

2017-08-14 Thread Tom Rini
On Mon, Aug 14, 2017 at 09:36:35PM +0200, Wolfgang Denk wrote:
> Dear Max,
> 
> In message <1502572898.17070.11.ca...@gmail.com> you wrote:
> > 
> > Ok, will do. The issue is that linking the standalone application
> > to have its text segment at a hardcoded address is less
> > likely to work than using an address provided by the board
> 
> This may (or may not) be the case - but no matter how youlook at it,
> chosing CONFIG_LOADADDR is definitely the wrong approach, as the
> LOAD address has nothing to do with the ENTRY point address, so it
> must in no case ever play a role when linking an image.
> 
> > configuration as a possible load address.
> 
> You are confused in your wording, and I'm afraid in your thinking,
> too.
> 
> load address != entry point.

But we're talking about CONFIG_STANDALONE_LOAD_ADDR not
CONFIG_STANDALONE_ENTRY_POINT.  What we've been doing in
arch/arm/config.mk has been on my to fix list for a long time, because
it's been wrong for so many boards.  Setting this to CONFIG_LOADADDR is
a reasonable default value.

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] arm: use $loadaddr as the standalone entry point

2017-08-14 Thread Wolfgang Denk
Dear Max,

In message <1502572898.17070.11.ca...@gmail.com> you wrote:
> 
> Ok, will do. The issue is that linking the standalone application
> to have its text segment at a hardcoded address is less
> likely to work than using an address provided by the board

This may (or may not) be the case - but no matter how youlook at it,
chosing CONFIG_LOADADDR is definitely the wrong approach, as the
LOAD address has nothing to do with the ENTRY point address, so it
must in no case ever play a role when linking an image.

> configuration as a possible load address.

You are confused in your wording, and I'm afraid in your thinking,
too.

load address != entry point.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
In any group of employed individuals the only naturally  early  riser
is  _always_  the office manager, who will _always_ leave reproachful
little notes ... on the desks of their subordinates.
- Terry Pratchett, _Lords and Ladies_
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] arm: use $loadaddr as the standalone entry point

2017-08-12 Thread Max Krummenacher
Dear Wolfgang

Am Samstag, den 12.08.2017, 20:29 +0200 schrieb Wolfgang Denk:
> Dear Max,
> 
> In message <20170812090346.7887-2-max.krummenac...@toradex.com> you wrote:
> > 
> > Different SoCs have different RAM layouts, so providing
> > $(CONFIG_LOADADDR) instead of the constant 0xc10 for
> > CONFIG_STANDALONE_LOAD_ADDR is probably more appropriate.
> 
> At least the wording of the Subject should be fixed.

Ok, will do. The issue is that linking the standalone application
to have its text segment at a hardcoded address is less
likely to work than using an address provided by the board
configuration as a possible load address.

Will reword the commit message in a v2 series accordingly.

Max

> 
> It is fundamentaaly broken to associate the names "loadaddr" and
> "entry point" with each other.  Both are completely independent
> entities which mean totally different things. It is pure chance if
> the entry point of some loaded image should be at the very beginning
> of this image, but this is almost never the case.
> 
> Best regards,
> 
> Wolfgang Denk
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] arm: use $loadaddr as the standalone entry point

2017-08-12 Thread Wolfgang Denk
Dear Max,

In message <20170812090346.7887-2-max.krummenac...@toradex.com> you wrote:
> Different SoCs have different RAM layouts, so providing
> $(CONFIG_LOADADDR) instead of the constant 0xc10 for
> CONFIG_STANDALONE_LOAD_ADDR is probably more appropriate.

At least the wording of the Subject should be fixed.

It is fundamentaaly broken to associate the names "loadaddr" and
"entry point" with each other.  Both are completely independent
entities which mean totally different things. It is pure chance if
the entry point of some loaded image should be at the very beginning
of this image, but this is almost never the case.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
"The bad reputation UNIX has gotten is totally undeserved, laid on by
people who don't understand, who have not gotten in there  and  tried
anything."  -- Jim Joyce, owner of Jim Joyce's UNIX Bookstore
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/2] arm: use $loadaddr as the standalone entry point

2017-08-12 Thread Max Krummenacher
Different SoCs have different RAM layouts, so providing
$(CONFIG_LOADADDR) instead of the constant 0xc10 for
CONFIG_STANDALONE_LOAD_ADDR is probably more appropriate.

Signed-off-by: Max Krummenacher 
---

 arch/arm/config.mk| 4 
 doc/README.standalone | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/arm/config.mk b/arch/arm/config.mk
index 1a9db4..8f56c7433f 100644
--- a/arch/arm/config.mk
+++ b/arch/arm/config.mk
@@ -9,7 +9,11 @@ ifndef CONFIG_STANDALONE_LOAD_ADDR
 ifneq ($(CONFIG_ARCH_OMAP2PLUS),)
 CONFIG_STANDALONE_LOAD_ADDR = 0x8030
 else
+ifndef CONFIG_LOADADDR
 CONFIG_STANDALONE_LOAD_ADDR = 0xc10
+else
+CONFIG_STANDALONE_LOAD_ADDR = $(CONFIG_LOADADDR)
+endif
 endif
 endif
 
diff --git a/doc/README.standalone b/doc/README.standalone
index 659a12f6cb..17d740c44b 100644
--- a/doc/README.standalone
+++ b/doc/README.standalone
@@ -53,7 +53,7 @@ Design Notes on Exporting U-Boot Functions to Standalone 
Applications:
Load addressStart address
x86 0x0004  0x0004
PowerPC 0x0004  0x00040004
-   ARM 0x0c10  0x0c10
+   ARM CONFIG_LOADADDR CONFIG_LOADADDR
MIPS0x8020  0x8020
Blackfin0x1000  0x1000
NDS32   0x0030  0x0030
-- 
2.13.1

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot