[U-Boot] common/cmd_disk.c doesn't actually define any "commands"

Albert ARIBAUD albert.u.boot at aribaud.net
Mon Feb 4 17:01:20 CET 2013


Hi Mats,

On Mon, 4 Feb 2013 15:42:17 +0000, Mats Kärrman
<Mats.Karrman at tritech.se> wrote:

> Hi Albert,
> 
> Albert ARIBAUD wrote:
> > Maybe, but the problem you state is not about cmd_disk (or I am
> > missing the point). USB commands are in USB related files, e.g.
> > do_usbboot() is in cmd_usb.c, so that's where a conditional should be
> > put if you want to compile the command out, rather than in cmd_disk,
> > which does not add to the U-Boot commands table at all.
> 
> The cmd_usb file contains all the other USB commands through "do_usb"
> and "usbboot" through "do_usbboot" that is just a forward to "common_diskboot".
> Maybe the major miss-feature here is that you get usbboot and a bunch
> of extra code, just because you want to be able to read USB memories.
> This could of course be fixed by revising the ifdefs in cmd_usb etc.
> instead but in that case I support Robert in his remark about the file naming ;)

Actually there is no way to fulfill your need to make the usbboot
command conditionally compiled by modifying cmd_disk, because cmd_disk
simply does not define any command -- so you will have to put the
conditionals in cmd_usb.c no matter what.

Now you may want to also conditionally compile cmd_disk.c only of USB,
SCSI or IDE require it, but this you can and should do in the Makefile;
remember cmd_disk.c is only useful to provide common_diskboot(), so
either you completely compile it, or you don't compile it at all.

(now this could be different if we use gcc's -fdata-sections,
-ffunction-sections along with ld's --gc-sections, as then we could
argue that even if compiled, cmd_disk.c would be linked out if
unreferenced.)

As for the name, Robert's issue stems from his assumption that a file
with cmd_ necessarily declares a listable U-Boot command. I assume that
files with cmd_ contain command-related code not necessarily including
a listable command -- for instance here, a command execution function
which is mapped to a (set of three) listable command(s) elsewhere.

> BR // Mats

Amicalement,
-- 
Albert.


More information about the U-Boot mailing list