Skip to contentSkip to conversation

Clarify standalone application support

PATCH In review Paul Barker 3 participants 12 messages May 5, 2022 – Oct 26, 2022

lore
Share & tools
lore
#0 lore raw

cover Clarify standalone application support

While looking into the support for u-boot standalone applications I noticed that there was some mis-alignment between the license exception and the files which needed to be included to get a functioning application. I also noticed that the set of SPI access functions defined in the jump table was missing a key function and did not match the set of prototypes defined in the exports header. These patches should rectify the issues I found.

Paul Barker (3):
Licenses: Clarify exceptions for standalone apps
examples: hello_world: Drop inclusion of common header
exports: Fix export of SPI access functions

 Licenses/Exceptions               | 12 ++++++++----
 examples/standalone/hello_world.c |  1 -
 include/_exports.h                |  4 ++++
 include/exports.h                 | 15 ++++++++++++++-
 4 files changed, 26 insertions(+), 6 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/3 Licenses: Clarify exceptions for standalone apps

On 2010-01-27, an email [1] was sent to the mailing list by Wolfgang Denk which clarified the intended licensing exceptions for standalone applications. As the "export.h" header and the "stubs.c" source files are required to implement a standalone application, the intention was that these files be covered by the licensing exception. This is made clear in the following quotes from that email:

"exports.h" should be added to the "allowed" file list; there should be no need to include "common.h". Eventually this needs fixing. Patches are welcome.

"examples/standalone/stubs.c" should be added to the "allowed" file list (the ppc_*jmp.S files are LGPLed).

There should be no doubts - the intention is clear, the current state may need improvement. Help (read: patches) welcome.

[1]: https://lists.denx.de/pipermail/u-boot/2010-January/067174.html

---
 Licenses/Exceptions | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
Licenses/Exceptions +8 -4
index c9b3cd981f51..4f241f4aff29 100644
@@ -7,9 +7,13 @@ use U-Boot services by means of the jump table provided by U-Boot
 exactly for this purpose - this is merely considered normal use of
 U-Boot, and does *not* fall under the heading of "derived work".
 
-  The header files "include/image.h" and "arch/*/include/asm/u-boot.h"
-define interfaces to U-Boot.  Including these (unmodified) header
-files in another file is considered normal use of U-Boot, and does
-*not* fall under the heading of "derived work".
+The following files define interfaces to U-Boot:
+  * include/image.h
+  * include/export.h
+  * arch/*/include/asm/u-boot.h
+  * examples/standalone/stubs.c
+
+Including these (unmodified) files in another file is considered normal
+use of U-Boot, and does *not* fall under the heading of "derived work".
 -- Wolfgang Denk
 
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH 1/3] Licenses: Clarify exceptions for standalone apps

Quoted 36 lines · Paul Barker

On 2010-01-27, an email [1] was sent to the mailing list by Wolfgang Denk which clarified the intended licensing exceptions for standalone applications. As the "export.h" header and the "stubs.c" source files are required to implement a standalone application, the intention was that these files be covered by the licensing exception. This is made clear in the following quotes from that email:

"exports.h" should be added to the "allowed" file list; there should be no need to include "common.h". Eventually this needs fixing. Patches are welcome.

"examples/standalone/stubs.c" should be added to the "allowed" file list (the ppc_*jmp.S files are LGPLed).

There should be no doubts - the intention is clear, the current state may need improvement. Help (read: patches) welcome.

[1]: https://lists.denx.de/pipermail/u-boot/2010-January/067174.html

---
 Licenses/Exceptions | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
Licenses/Exceptions +0 -3
index c9b3cd981f51..4f241f4aff29 100644
@@ -7,9 +7,13 @@ use U-Boot services by means of the jump table provided by U-Boot
 exactly for this purpose - this is merely considered normal use of
 U-Boot, and does *not* fall under the heading of "derived work".
 
-  The header files "include/image.h" and "arch/*/include/asm/u-boot.h"
-define interfaces to U-Boot.  Including these (unmodified) header
-files in another file is considered normal use of U-Boot, and does

Licenses/Exceptions use U-Boot services by means of the jump table provided by U-Boot · line 18

Quoted 10 lines
Licenses/Exceptions +8 -1
-*not* fall under the heading of "derived work".
+The following files define interfaces to U-Boot:
+  * include/image.h
+  * include/export.h
+  * arch/*/include/asm/u-boot.h
+  * examples/standalone/stubs.c
+
+Including these (unmodified) files in another file is considered normal
+use of U-Boot, and does *not* fall under the heading of "derived work".
 -- Wolfgang Denk

Wolfgang?

Signature · 1 line
Tom
Acked-by on v1 1/3
#3 lore raw

Re: [PATCH 1/3] Licenses: Clarify exceptions for standalone apps

In reply to Paul Barker

Dear Paul Barker,

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

On 2010-01-27, an email [1] was sent to the mailing list by Wolfgang Denk which clarified the intended licensing exceptions for standalone applications. As the "export.h" header and the "stubs.c" source files are required to implement a standalone application, the intention was that these files be covered by the licensing exception. This is made clear in the following quotes from that email:

"exports.h" should be added to the "allowed" file list; there should be no need to include "common.h". Eventually this needs fixing. Patches are welcome.

"examples/standalone/stubs.c" should be added to the "allowed" file list (the ppc_*jmp.S files are LGPLed).

Quoted 7 lines

There should be no doubts - the intention is clear, the current state may need improvement. Help (read: patches) welcome.

[1]: https://lists.denx.de/pipermail/u-boot/2010-January/067174.html

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich,  Office: Kirchenstr. 5, 82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]
It usually takes more than three weeks to prepare  a  good  impromptu
speech.                                                  - Mark Twain
#4 lore raw

Re: [PATCH 1/3] Licenses: Clarify exceptions for standalone apps

In reply to Paul Barker
Quoted 14 lines · Paul Barker

On 2010-01-27, an email [1] was sent to the mailing list by Wolfgang Denk which clarified the intended licensing exceptions for standalone applications. As the "export.h" header and the "stubs.c" source files are required to implement a standalone application, the intention was that these files be covered by the licensing exception. This is made clear in the following quotes from that email:

"exports.h" should be added to the "allowed" file list; there should be no need to include "common.h". Eventually this needs fixing. Patches are welcome.

"examples/standalone/stubs.c" should be added to the "allowed" file list (the ppc_*jmp.S files are LGPLed).

Quoted 8 lines

There should be no doubts - the intention is clear, the current state may need improvement. Help (read: patches) welcome.

[1]: https://lists.denx.de/pipermail/u-boot/2010-January/067174.html

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#5 lore raw

PATCH 2/3 examples: hello_world: Drop inclusion of common header

In reply to Paul Barker

The "common.h" header is not covered by the licensing exception for standalone applications. Let's drop inclusion of this header from the hello_world example to prove that a standalone app can be built without it.

---
 examples/standalone/hello_world.c | 1 -
 1 file changed, 1 deletion(-)
examples/standalone/hello_world.c +0 -1
index 263cd9ca079d..27ec3793155d 100644
@@ -4,7 +4,6 @@
  * Wolfgang Denk, DENX Software Engineering, [email protected].
  */
 
-#include <common.h>
 #include <exports.h>
 
 int hello_world(int argc, char *const argv[])
Signature · 1 line
2.25.1
Reviewed-by on v1 2/3
#6 lore raw

Re: [PATCH 2/3] examples: hello_world: Drop inclusion of common header

Quoted 6 lines · Paul Barker

The "common.h" header is not covered by the licensing exception for standalone applications. Let's drop inclusion of this header from the hello_world example to prove that a standalone app can be built without it.

Signature · 1 line
Tom
#7 lore raw

Re: [PATCH 2/3] examples: hello_world: Drop inclusion of common header

In reply to Paul Barker

Dear Paul,

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

The "common.h" header is not covered by the licensing exception for standalone applications. Let's drop inclusion of this header from the hello_world example to prove that a standalone app can be built without it.

---
 examples/standalone/hello_world.c | 1 -
 1 file changed, 1 deletion(-)

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich,  Office: Kirchenstr. 5, 82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]
An expert is a person who avoids the small errors while  sweeping  on
to the grand fallacy.
#8 lore raw

Re: [PATCH 2/3] examples: hello_world: Drop inclusion of common header

In reply to Paul Barker
Quoted 7 lines · Paul Barker

The "common.h" header is not covered by the licensing exception for standalone applications. Let's drop inclusion of this header from the hello_world example to prove that a standalone app can be built without it.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#9 lore raw

PATCH 3/3 exports: Fix export of SPI access functions

In reply to Paul Barker

* With CONFIG_DM_SPI defined, spi_get_bus_and_cs needs to be used instead of spi_setup_slave to configure a SPI bus. As spi_setup_slave is already present in the export list it is reasonable to also export spi_get_bus_and_cs.

* For the functions listed in the jump table to be callable they must also be defined in the "exports.h" header. Define the various exported SPI functions so that they can be used.

---
 include/_exports.h |  4 ++++
 include/exports.h  | 15 ++++++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)
include/_exports.h +4 -0
index f6df8b610734..3457a92c95ad 100644
@@ -60,11 +60,15 @@
 	EXPORT_FUNC(dummy, void, spi_claim_bus, void)
 	EXPORT_FUNC(dummy, void, spi_release_bus, void)
 	EXPORT_FUNC(dummy, void, spi_xfer, void)
+	EXPORT_FUNC(dummy, void, spi_get_bus_and_cs, void)
 #else
 	EXPORT_FUNC(spi_claim_bus, int, spi_claim_bus, struct spi_slave *)
 	EXPORT_FUNC(spi_release_bus, void, spi_release_bus, struct spi_slave *)
 	EXPORT_FUNC(spi_xfer, int, spi_xfer, struct spi_slave *,
 		    unsigned int, const void *, void *, unsigned long)
+	EXPORT_FUNC(spi_get_bus_and_cs, int, spi_get_bus_and_cs, int, int, int,
+			int, const char *, const char *, struct udevice **,
+			struct spi_slave **)
 #endif
 	EXPORT_FUNC(ustrtoul, unsigned long, ustrtoul,
 		    const char *, char **, unsigned int)
include/exports.h +14 -1
index 6f8c9cf4517e..93110d63a235 100644
@@ -53,6 +53,19 @@ unsigned long long ustrtoull(const char *cp, char **endp, unsigned int base);
 int i2c_write (uchar, uint, int , uchar* , int);
 int i2c_read (uchar, uint, int , uchar* , int);
 #endif
+#ifdef CONFIG_CMD_SPI
+#ifndef CONFIG_DM_SPI
+struct spi_slave * spi_setup_slave(unsigned int, unsigned int,
+        unsigned int, unsigned int);
+void spi_free_slave(struct spi_slave *);
+#endif
+int spi_claim_bus(struct spi_slave *);
+void spi_release_bus(struct spi_slave *);
+int spi_xfer(struct spi_slave *, unsigned int, const void *, void *,
+        unsigned long);
+int spi_get_bus_and_cs(int, int, int, int, const char *, const char *,
+        struct udevice **, struct spi_slave **);
+#endif
 #ifdef CONFIG_PHY_AQUANTIA
 struct mii_dev *mdio_get_current_dev(void);
 struct phy_device *phy_find_by_mask(struct mii_dev *bus, unsigned phy_mask);
@@ -71,7 +84,7 @@ struct jt_funcs {
 };
 
 
-#define XF_VERSION	9
+#define XF_VERSION	10
 
 #if defined(CONFIG_X86)
 extern gd_t *global_data;
Signature · 1 line
2.25.1
Reviewed-by on v1 3/3
#10 lore raw

Re: [PATCH 3/3] exports: Fix export of SPI access functions

Quoted 10 lines · Paul Barker

* With CONFIG_DM_SPI defined, spi_get_bus_and_cs needs to be used instead of spi_setup_slave to configure a SPI bus. As spi_setup_slave is already present in the export list it is reasonable to also export spi_get_bus_and_cs.

* For the functions listed in the jump table to be callable they must also be defined in the "exports.h" header. Define the various exported SPI functions so that they can be used.

Signature · 1 line
Tom
#11 lore raw

Re: [PATCH 3/3] exports: Fix export of SPI access functions

In reply to Paul Barker

Dear Paul,

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

* With CONFIG_DM_SPI defined, spi_get_bus_and_cs needs to be used instead of spi_setup_slave to configure a SPI bus. As spi_setup_slave is already present in the export list it is reasonable to also export spi_get_bus_and_cs.

* For the functions listed in the jump table to be callable they must also be defined in the "exports.h" header. Define the various exported SPI functions so that they can be used.

Quoted 5 lines
---
 include/_exports.h |  4 ++++
 include/exports.h  | 15 ++++++++++++++-
 2 files changed, 18 insertions(+), 1 deletion(-)

Sorry, but I disagree here. The SPI functions should have never been part of the export interface. As far as I can see now, they have been added by commit bedd8403f7

export SPI functions to standalone apps

While we're here, fix the broken #ifdef handling in _exports.h.

in 2009. Actually I must even have seen them, as I complained about incorrect comment style :-(

But no, SPI support should not be inclluded. I2C was there because it was needed for reading the environment from an EEPROM, but then the interface was frozen ano no more new interfices / drivers should be allowed.

Viele Grüße,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich,  Office: Kirchenstr. 5, 82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]
If you can't explain it to a six year old, you  don't  understand  it
yourself.                                           - Albert Einstein