Re: [U-Boot] [PATCH v8 4/4] common: Generic firmware loader for file system
On Thu, 2018-02-22 at 10:02 +0100, Lothar Waßmann wrote: > Hi, > > On Mon, 5 Feb 2018 15:06:49 +0800 tien.fong.c...@intel.com wrote: > > > > From: Tien Fong Chee> > > > This is file system generic loader which can be used to load > > the file image from the storage into target such as memory. > > The consumer driver would then use this loader to program whatever, > > ie. the FPGA device. > > > > Signed-off-by: Tien Fong Chee > > Reviewed-by: Lothar Waßmann > > --- > > common/Kconfig | 9 ++ > > common/Makefile| 1 + > > common/fs_loader.c | 320 > > + > > doc/README.firmware_loader | 76 +++ > > include/fs_loader.h| 28 > > 5 files changed, 434 insertions(+) > > create mode 100644 common/fs_loader.c > > create mode 100644 doc/README.firmware_loader > > create mode 100644 include/fs_loader.h > > > [...] > > > > +#if defined(CONFIG_SPL_MMC_SUPPORT) && defined(CONFIG_SPL_BUILD) > > +__weak int init_mmc(void) > > +{ > > + /* Just for the case MMC is not yet initialized */ > > + struct mmc *mmc = NULL; > > + int err; > > + > > +#ifdef CONFIG_SPL > > + spl_mmc_find_device(, spl_boot_device()); > > +#else > > + debug("#define CONFIG_SPL is required or overrriding > > %s\n", > > > s/overrr/overr/ > I would remove it and adding the depend on CONFIG_SPL in Kconfig for compile-time error checking. > > > Lothar Waßmann ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH v8 4/4] common: Generic firmware loader for file system
On Thu, 2018-02-22 at 10:50 -0500, Tom Rini wrote: > On Thu, Feb 22, 2018 at 03:28:12PM +0100, Marek Vasut wrote: > > > > On 02/22/2018 09:18 AM, Chee, Tien Fong wrote: > > > > > > On Thu, 2018-02-15 at 15:58 +0100, Marek Vasut wrote: > > > > > > > > On 02/05/2018 08:06 AM, tien.fong.c...@intel.com wrote: > > > > > > > > > > > > > > > From: Tien Fong Chee> > > > > > > > > > This is file system generic loader which can be used to load > > > > > the file image from the storage into target such as memory. > > > > > The consumer driver would then use this loader to program > > > > > whatever, > > > > > ie. the FPGA device. > > > > > > > > > > Signed-off-by: Tien Fong Chee > > > > > Reviewed-by: Lothar Waßmann > > > > [...] > > > > > > > > > > > > > > > > > > > +#include > > > > > +#include > > > > > +#include > > > > > +#include > > > > > +#include > > > > > +#include > > > > > +#include > > > > > +#include > > > > > +#ifdef CONFIG_SPL > > > > Are the ifdefs needed ? > > > > > > > Because spl.h contains some codes have its dependency with SPL. > > > So, Tom > > > adviced to make this part of code depend on CONFIG_SPL. > > > However, only __weak int init_mmc() depend on the codes from > > > spl.h, so > > > user can override their own init_mmc() if SPL is not used. > > You probably dont need those ifdefs around headers. > In this case, we do. You can only include on architectures > which have SPL support. > > I wouldn't object to a separate patch series that adds a dummy > asm-generic/spl.h and we go that route, if it also cleans up more of > the > code in general. But I think that's separate from this > series. Thanks! > Planning to add the depend on CONFIG_SPL in Kconfig instead of ifdefs . ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH v8 4/4] common: Generic firmware loader for file system
On Thu, 2018-02-22 at 15:28 +0100, Marek Vasut wrote: > On 02/22/2018 09:18 AM, Chee, Tien Fong wrote: > > > > On Thu, 2018-02-15 at 15:58 +0100, Marek Vasut wrote: > > > > > > On 02/05/2018 08:06 AM, tien.fong.c...@intel.com wrote: > > > > > > > > > > > > From: Tien Fong Chee> > > > > > > > This is file system generic loader which can be used to load > > > > the file image from the storage into target such as memory. > > > > The consumer driver would then use this loader to program > > > > whatever, > > > > ie. the FPGA device. > > > > > > > > Signed-off-by: Tien Fong Chee > > > > Reviewed-by: Lothar Waßmann > > > [...] > > > > > > > > > > > > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#ifdef CONFIG_SPL > > > Are the ifdefs needed ? > > > > > Because spl.h contains some codes have its dependency with SPL. So, > > Tom > > adviced to make this part of code depend on CONFIG_SPL. > > However, only __weak int init_mmc() depend on the codes from spl.h, > > so > > user can override their own init_mmc() if SPL is not used. > You probably dont need those ifdefs around headers. > > > > > > > > > > > > > > +#include > > > > +#endif > > > > +#include > > > > +#ifdef CONFIG_CMD_UBIFS > > > > +#include > > > > +#include > > > > +#endif > > > > +#include > > > > + > > > > +struct firmware_priv { > > > > + const char *name; /* Filename */ > > > > + u32 offset; /* Offset of reading a file > > > > */ > > > > +}; > > > > + > > > > +static struct device_location default_locations[] = { > > > > + { > > > > + .name = "mmc", > > > > + .devpart = "0:1", > > > > + }, > > > > + { > > > > + .name = "usb", > > > > + .devpart = "0:1", > > > > + }, > > > > + { > > > > + .name = "sata", > > > > + .devpart = "0:1", > > > > + }, > > > How can this load from UBI if it's not listed here ? > Well ? > I can add ".name = ubi" and ".devpart = UBI" . > [...] > > > > > > > > > > > > > > +#ifdef CONFIG_SATA > > > > +static int init_storage_sata(void) > > > > +{ > > > > + return sata_probe(0); > > > Shouldn't the sata device number be pulled from devpart in > > > default_locations table ? > > > > > This may need to add the logic for splitting the device number and > > partition into integer from the string. Let me think how to do it, > > may > > be i can leverage existing code. > strtok(), strtol() or something ? > yes, plan to use that. > [...] > > > > > > > > > > > > > > +#ifdef CONFIG_SPL > > > > + spl_mmc_find_device(, spl_boot_device()); > > > > +#else > > > > + debug("#define CONFIG_SPL is required or overrriding > > > > %s\n", > > > > + __func__); > > > This can be a compile-time error, maybe ? > > > > > No compile error. When you open the file, "%s\n" is actually same > > line > > with debug(". . > So what ? This missing macro can be detected at runtime, heck this > code > can even depend on CONFIG_SPL in Kconfig. > Oh...I got you, i thought you means syntax error. So, i would remove it and adding the depend on CONFIG_SPL in Kconfig. > > > > > > > > > > > > > > > > > + return -ENOENT; > > > > +#endif > > > > + > > > > + err = mmc_init(mmc); > > > > + if (err) { > > > > + debug("spl: mmc init failed with error: %d\n", > > > > err); > > > > + return err; > > > > + } > > > > + > > > > + return err; > > > > +} > > > > +#else > > > > +__weak int init_mmc(void) > > > > +{ > > > > + /* Expect somewhere already initialize MMC */ > > > > + return 0; > > > > +} > > > > +#endif > > > [...] > ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH v8 4/4] common: Generic firmware loader for file system
On Thu, Feb 22, 2018 at 03:28:12PM +0100, Marek Vasut wrote: > On 02/22/2018 09:18 AM, Chee, Tien Fong wrote: > > On Thu, 2018-02-15 at 15:58 +0100, Marek Vasut wrote: > >> On 02/05/2018 08:06 AM, tien.fong.c...@intel.com wrote: > >>> > >>> From: Tien Fong Chee> >>> > >>> This is file system generic loader which can be used to load > >>> the file image from the storage into target such as memory. > >>> The consumer driver would then use this loader to program whatever, > >>> ie. the FPGA device. > >>> > >>> Signed-off-by: Tien Fong Chee > >>> Reviewed-by: Lothar Waßmann > >> [...] > >> > >>> > >>> +#include > >>> +#include > >>> +#include > >>> +#include > >>> +#include > >>> +#include > >>> +#include > >>> +#include > >>> +#ifdef CONFIG_SPL > >> Are the ifdefs needed ? > >> > > Because spl.h contains some codes have its dependency with SPL. So, Tom > > adviced to make this part of code depend on CONFIG_SPL. > > However, only __weak int init_mmc() depend on the codes from spl.h, so > > user can override their own init_mmc() if SPL is not used. > > You probably dont need those ifdefs around headers. In this case, we do. You can only include on architectures which have SPL support. I wouldn't object to a separate patch series that adds a dummy asm-generic/spl.h and we go that route, if it also cleans up more of the code in general. But I think that's separate from this series. Thanks! -- Tom signature.asc Description: PGP signature ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH v8 4/4] common: Generic firmware loader for file system
On 02/22/2018 09:18 AM, Chee, Tien Fong wrote: > On Thu, 2018-02-15 at 15:58 +0100, Marek Vasut wrote: >> On 02/05/2018 08:06 AM, tien.fong.c...@intel.com wrote: >>> >>> From: Tien Fong Chee>>> >>> This is file system generic loader which can be used to load >>> the file image from the storage into target such as memory. >>> The consumer driver would then use this loader to program whatever, >>> ie. the FPGA device. >>> >>> Signed-off-by: Tien Fong Chee >>> Reviewed-by: Lothar Waßmann >> [...] >> >>> >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#include >>> +#ifdef CONFIG_SPL >> Are the ifdefs needed ? >> > Because spl.h contains some codes have its dependency with SPL. So, Tom > adviced to make this part of code depend on CONFIG_SPL. > However, only __weak int init_mmc() depend on the codes from spl.h, so > user can override their own init_mmc() if SPL is not used. You probably dont need those ifdefs around headers. >>> +#include >>> +#endif >>> +#include >>> +#ifdef CONFIG_CMD_UBIFS >>> +#include >>> +#include >>> +#endif >>> +#include >>> + >>> +struct firmware_priv { >>> + const char *name; /* Filename */ >>> + u32 offset; /* Offset of reading a file */ >>> +}; >>> + >>> +static struct device_location default_locations[] = { >>> + { >>> + .name = "mmc", >>> + .devpart = "0:1", >>> + }, >>> + { >>> + .name = "usb", >>> + .devpart = "0:1", >>> + }, >>> + { >>> + .name = "sata", >>> + .devpart = "0:1", >>> + }, >> How can this load from UBI if it's not listed here ? Well ? [...] >>> +#ifdef CONFIG_SATA >>> +static int init_storage_sata(void) >>> +{ >>> + return sata_probe(0); >> Shouldn't the sata device number be pulled from devpart in >> default_locations table ? >> > This may need to add the logic for splitting the device number and > partition into integer from the string. Let me think how to do it, may > be i can leverage existing code. strtok(), strtol() or something ? [...] >>> +#ifdef CONFIG_SPL >>> + spl_mmc_find_device(, spl_boot_device()); >>> +#else >>> + debug("#define CONFIG_SPL is required or overrriding >>> %s\n", >>> + __func__); >> This can be a compile-time error, maybe ? >> > No compile error. When you open the file, "%s\n" is actually same line > with debug(". . So what ? This missing macro can be detected at runtime, heck this code can even depend on CONFIG_SPL in Kconfig. >>> >>> + return -ENOENT; >>> +#endif >>> + >>> + err = mmc_init(mmc); >>> + if (err) { >>> + debug("spl: mmc init failed with error: %d\n", >>> err); >>> + return err; >>> + } >>> + >>> + return err; >>> +} >>> +#else >>> +__weak int init_mmc(void) >>> +{ >>> + /* Expect somewhere already initialize MMC */ >>> + return 0; >>> +} >>> +#endif >> [...] -- Best regards, Marek Vasut ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH v8 4/4] common: Generic firmware loader for file system
Hi, On Mon, 5 Feb 2018 15:06:49 +0800 tien.fong.c...@intel.com wrote: > From: Tien Fong Chee> > This is file system generic loader which can be used to load > the file image from the storage into target such as memory. > The consumer driver would then use this loader to program whatever, > ie. the FPGA device. > > Signed-off-by: Tien Fong Chee > Reviewed-by: Lothar Waßmann > --- > common/Kconfig | 9 ++ > common/Makefile| 1 + > common/fs_loader.c | 320 > + > doc/README.firmware_loader | 76 +++ > include/fs_loader.h| 28 > 5 files changed, 434 insertions(+) > create mode 100644 common/fs_loader.c > create mode 100644 doc/README.firmware_loader > create mode 100644 include/fs_loader.h > [...] > +#if defined(CONFIG_SPL_MMC_SUPPORT) && defined(CONFIG_SPL_BUILD) > +__weak int init_mmc(void) > +{ > + /* Just for the case MMC is not yet initialized */ > + struct mmc *mmc = NULL; > + int err; > + > +#ifdef CONFIG_SPL > + spl_mmc_find_device(, spl_boot_device()); > +#else > + debug("#define CONFIG_SPL is required or overrriding %s\n", > s/overrr/overr/ Lothar Waßmann ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH v8 4/4] common: Generic firmware loader for file system
On Thu, 2018-02-15 at 15:58 +0100, Marek Vasut wrote: > On 02/05/2018 08:06 AM, tien.fong.c...@intel.com wrote: > > > > From: Tien Fong Chee> > > > This is file system generic loader which can be used to load > > the file image from the storage into target such as memory. > > The consumer driver would then use this loader to program whatever, > > ie. the FPGA device. > > > > Signed-off-by: Tien Fong Chee > > Reviewed-by: Lothar Waßmann > [...] > > > > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#ifdef CONFIG_SPL > Are the ifdefs needed ? > Because spl.h contains some codes have its dependency with SPL. So, Tom adviced to make this part of code depend on CONFIG_SPL. However, only __weak int init_mmc() depend on the codes from spl.h, so user can override their own init_mmc() if SPL is not used. > > > > +#include > > +#endif > > +#include > > +#ifdef CONFIG_CMD_UBIFS > > +#include > > +#include > > +#endif > > +#include > > + > > +struct firmware_priv { > > + const char *name; /* Filename */ > > + u32 offset; /* Offset of reading a file */ > > +}; > > + > > +static struct device_location default_locations[] = { > > + { > > + .name = "mmc", > > + .devpart = "0:1", > > + }, > > + { > > + .name = "usb", > > + .devpart = "0:1", > > + }, > > + { > > + .name = "sata", > > + .devpart = "0:1", > > + }, > How can this load from UBI if it's not listed here ? > > > > > +}; > > + > > +/* USB build is not supported yet in SPL */ > > +#ifndef CONFIG_SPL_BUILD > > +#ifdef CONFIG_USB_STORAGE > > +static int init_usb(void) > > +{ > > + int err; > > + > > + err = usb_init(); > > + if (err) > > + return err; > > + > > +#ifndef CONFIG_DM_USB > > + err = usb_stor_scan(1); > mode = 0 I think, we don't need this verbose output. > Okay so i will change to usb_stor_scan(0) . > > > > + if (err) > > + return err; > > +#endif > > + > > + return err; > > +} > > +#else > > +static int init_usb(void) > > +{ > > + debug("Error: Cannot load flash image: no USB support\n"); > > + return -ENOSYS; > > +} > > +#endif > > +#endif > > + > > +#ifdef CONFIG_SATA > > +static int init_storage_sata(void) > > +{ > > + return sata_probe(0); > Shouldn't the sata device number be pulled from devpart in > default_locations table ? > This may need to add the logic for splitting the device number and partition into integer from the string. Let me think how to do it, may be i can leverage existing code. > > > > +} > > +#else > > +static int init_storage_sata(void) > > +{ > > + debug("Error: Cannot load image: no SATA support\n"); > > + return -ENOSYS; > > +} > > +#endif > > + > > +#ifdef CONFIG_CMD_UBIFS > > +static int mount_ubifs(struct device_location *location) > > +{ > > + int ret; > > + char cmd[32]; > > + > > + if (ret = ubi_part(location->mtdpart, NULL)) { > > + debug("Cannot find mtd partition %s\n", location- > > >mtdpart); > > + return ret; > > + } > > + > > + return cmd_ubifs_mount(location->ubivol); > > +} > > + > > +static int umount_ubifs(void) > > +{ > > + return cmd_ubifs_umount(); > > +} > > +#else > > +static int mount_ubifs(struct device_location *location) > > +{ > > + debug("Error: Cannot load image: no UBIFS support\n"); > > + return -ENOSYS; > > +} > > +#endif > > + > > +#if defined(CONFIG_SPL_MMC_SUPPORT) && defined(CONFIG_SPL_BUILD) > > +__weak int init_mmc(void) > > +{ > > + /* Just for the case MMC is not yet initialized */ > > + struct mmc *mmc = NULL; > > + int err; > > + > > +#ifdef CONFIG_SPL > > + spl_mmc_find_device(, spl_boot_device()); > > +#else > > + debug("#define CONFIG_SPL is required or overrriding > > %s\n", > > + __func__); > This can be a compile-time error, maybe ? > No compile error. When you open the file, "%s\n" is actually same line with debug(". . > > > > + return -ENOENT; > > +#endif > > + > > + err = mmc_init(mmc); > > + if (err) { > > + debug("spl: mmc init failed with error: %d\n", > > err); > > + return err; > > + } > > + > > + return err; > > +} > > +#else > > +__weak int init_mmc(void) > > +{ > > + /* Expect somewhere already initialize MMC */ > > + return 0; > > +} > > +#endif > [...] > ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
Re: [U-Boot] [PATCH v8 4/4] common: Generic firmware loader for file system
On 02/05/2018 08:06 AM, tien.fong.c...@intel.com wrote: > From: Tien Fong Chee> > This is file system generic loader which can be used to load > the file image from the storage into target such as memory. > The consumer driver would then use this loader to program whatever, > ie. the FPGA device. > > Signed-off-by: Tien Fong Chee > Reviewed-by: Lothar Waßmann [...] > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#ifdef CONFIG_SPL Are the ifdefs needed ? > +#include > +#endif > +#include > +#ifdef CONFIG_CMD_UBIFS > +#include > +#include > +#endif > +#include > + > +struct firmware_priv { > + const char *name; /* Filename */ > + u32 offset; /* Offset of reading a file */ > +}; > + > +static struct device_location default_locations[] = { > + { > + .name = "mmc", > + .devpart = "0:1", > + }, > + { > + .name = "usb", > + .devpart = "0:1", > + }, > + { > + .name = "sata", > + .devpart = "0:1", > + }, How can this load from UBI if it's not listed here ? > +}; > + > +/* USB build is not supported yet in SPL */ > +#ifndef CONFIG_SPL_BUILD > +#ifdef CONFIG_USB_STORAGE > +static int init_usb(void) > +{ > + int err; > + > + err = usb_init(); > + if (err) > + return err; > + > +#ifndef CONFIG_DM_USB > + err = usb_stor_scan(1); mode = 0 I think, we don't need this verbose output. > + if (err) > + return err; > +#endif > + > + return err; > +} > +#else > +static int init_usb(void) > +{ > + debug("Error: Cannot load flash image: no USB support\n"); > + return -ENOSYS; > +} > +#endif > +#endif > + > +#ifdef CONFIG_SATA > +static int init_storage_sata(void) > +{ > + return sata_probe(0); Shouldn't the sata device number be pulled from devpart in default_locations table ? > +} > +#else > +static int init_storage_sata(void) > +{ > + debug("Error: Cannot load image: no SATA support\n"); > + return -ENOSYS; > +} > +#endif > + > +#ifdef CONFIG_CMD_UBIFS > +static int mount_ubifs(struct device_location *location) > +{ > + int ret; > + char cmd[32]; > + > + if (ret = ubi_part(location->mtdpart, NULL)) { > + debug("Cannot find mtd partition %s\n", location->mtdpart); > + return ret; > + } > + > + return cmd_ubifs_mount(location->ubivol); > +} > + > +static int umount_ubifs(void) > +{ > + return cmd_ubifs_umount(); > +} > +#else > +static int mount_ubifs(struct device_location *location) > +{ > + debug("Error: Cannot load image: no UBIFS support\n"); > + return -ENOSYS; > +} > +#endif > + > +#if defined(CONFIG_SPL_MMC_SUPPORT) && defined(CONFIG_SPL_BUILD) > +__weak int init_mmc(void) > +{ > + /* Just for the case MMC is not yet initialized */ > + struct mmc *mmc = NULL; > + int err; > + > +#ifdef CONFIG_SPL > + spl_mmc_find_device(, spl_boot_device()); > +#else > + debug("#define CONFIG_SPL is required or overrriding %s\n", > + __func__); This can be a compile-time error, maybe ? > + return -ENOENT; > +#endif > + > + err = mmc_init(mmc); > + if (err) { > + debug("spl: mmc init failed with error: %d\n", err); > + return err; > + } > + > + return err; > +} > +#else > +__weak int init_mmc(void) > +{ > + /* Expect somewhere already initialize MMC */ > + return 0; > +} > +#endif [...] -- Best regards, Marek Vasut ___ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot