U-Boot can dynamically load independent software modules, called "standalone programs".
Standalone programs have a standard C calling environment, and can use standard services like
printf(),
malloc(),
install_hdlr().
Used for:
- special test software that is used in bring-up but shall not be included with customer release
- software that is needed only occasionally
- code that performs special actions that were not foreseen (software updates)
- code that shall not be made available under GPL
Example:
#include <common.h>
#include <exports.h>
int hello_world (int argc, char *argv[])
{
int i;
app_startup(argv);
printf ("Example expects ABI version %d\n", XF_VERSION);
printf ("Actual U-Boot ABI version %d\n", (int)get_version());
printf ("Hello World\n");
printf ("argc = %d\n", argc);
for (i=0; i<=argc; ++i) {
printf ("argv[%d] = \"%s\"\n",
i,
argv[i] ? argv[i] : "<NULL>");
}
return (0);
}
Run:
=> tftp 40000 /tftpboot/hello_world.bin
...
=> go 40004 Hello World! This is a test.
## Starting application at 0x00040004 ...
Hello World
argc = 7
argv[0] = "40004"
argv[1] = "Hello"
argv[2] = "World!"
argv[3] = "This"
argv[4] = "is"
argv[5] = "a"
argv[6] = "test."
argv[7] = ""
## Application terminated, rc = 0x0