From: Lukasz Majewski <l.majewski@majess.pl>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/8] dfu: tftp: update: Provide tftp support for the DFU subsystem
Date: Thu, 16 Jul 2015 22:06:07 +0200 [thread overview]
Message-ID: <20150716220607.7ea71d9b@jawa> (raw)
In-Reply-To: <CANr=Z=YZE-9wgZbnCEVrteFbB7hBByChkPZ79zk3P6KavGrT_A@mail.gmail.com>
Hi Joe,
> Hi Lukasz,
>
> On Sun, Jul 12, 2015 at 10:30 AM, Lukasz Majewski
> <l.majewski@majess.pl> wrote:
> > This commit adds initial support for using tftp for downloading and
> > upgrading firmware on the device.
> >
> > Signed-off-by: Lukasz Majewski <l.majewski@majess.pl>
> > ---
> > drivers/dfu/Makefile | 1 +
> > drivers/dfu/dfu_tftp.c | 76
> > ++++++++++++++++++++++++++++++++++++++++++++++++++
> > include/dfu.h | 11 ++++++++ 3 files changed, 88
> > insertions(+) create mode 100644 drivers/dfu/dfu_tftp.c
> >
> > diff --git a/drivers/dfu/Makefile b/drivers/dfu/Makefile
> > index 5cc535e..43249ce 100644
> > --- a/drivers/dfu/Makefile
> > +++ b/drivers/dfu/Makefile
> > @@ -10,3 +10,4 @@ obj-$(CONFIG_DFU_MMC) += dfu_mmc.o
> > obj-$(CONFIG_DFU_NAND) += dfu_nand.o
> > obj-$(CONFIG_DFU_RAM) += dfu_ram.o
> > obj-$(CONFIG_DFU_SF) += dfu_sf.o
> > +obj-$(CONFIG_DFU_TFTP) += dfu_tftp.o
> > diff --git a/drivers/dfu/dfu_tftp.c b/drivers/dfu/dfu_tftp.c
> > new file mode 100644
> > index 0000000..26539f2
> > --- /dev/null
> > +++ b/drivers/dfu/dfu_tftp.c
> > @@ -0,0 +1,76 @@
> > +/*
> > + * (C) Copyright 2015
> > + * Lukasz Majewski <l.majewski@majess.pl>
> > + *
> > + * SPDX-License-Identifier: GPL-2.0+
> > + */
> > +
> > +#include <common.h>
> > +#include <malloc.h>
> > +#include <errno.h>
> > +#include <dfu.h>
> > +
> > +int dfu_tftp_write(char *dfu_entity_name, unsigned int addr,
> > unsigned int len) +{
> > + char *s, *sb, *interface, *devstring;
> > + int alt_setting_num, ret;
> > + struct dfu_entity *dfu;
> > +
> > + debug("%s: name: %s addr: 0x%x len: %d\n", __func__,
> > dfu_entity_name,
> > + addr, len);
> > +
> > + interface = getenv("update_tftp_dfu_interface");
> > + if (interface == NULL) {
> > + error("TFTP DFU: 'interface' not defined\n");
> > + return -EINVAL;
> > + }
> > +
> > + devstring = getenv("update_tftp_dfu_devstring");
> > + if (devstring == NULL) {
> > + error("TFTP DFU: 'devstring' not defined\n");
> > + return -EINVAL;
> > + }
>
> It would be great if these env vars could be moved to command
> parameters.
Those parameters are necessary to perform update (via update_tftp())
during boot time.
Normally - when user call 'dfutftp' command he/she needs to specify
this informaiton. (e.g. 'dfutftp 0 mmc 1').
>
> > +
> > + ret = dfu_init_env_entities(interface, devstring);
> > + if (ret)
> > + goto done;
> > +
> > + /*
> > + * We need to copy name pointed by *dfu_entity_name since
> > this text
> > + * is the integral part of the FDT image.
> > + * Any implicit modification (i.e. done by strsep()) will
> > corrupt
> > + * the FDT image and prevent other images to be stored.
> > + */
> > + s = strdup(dfu_entity_name);
> > + sb = s;
> > + if (!s) {
> > + ret = -ENOMEM;
> > + goto done;
> > + }
> > +
> > + strsep(&s, "@");
> > + debug("%s: image name: %s strlen: %d\n", __func__, sb,
> > strlen(sb)); +
> > + alt_setting_num = dfu_get_alt(sb);
> > + free(sb);
> > + if (alt_setting_num < 0) {
> > + error("Alt setting [%d] to write not found!",
> > + alt_setting_num);
> > + ret = -ENODEV;
> > + goto done;
> > + }
> > +
> > + dfu = dfu_get_entity(alt_setting_num);
> > + if (!dfu) {
> > + error("DFU entity for alt: %d not found!",
> > alt_setting_num);
> > + ret = -ENODEV;
> > + goto done;
> > + }
> > +
> > + ret = dfu_write_from_mem_addr(dfu, (void *)addr, len);
> > +
> > +done:
> > + dfu_free_entities();
> > +
> > + return ret;
> > +}
> > diff --git a/include/dfu.h b/include/dfu.h
> > index 7d31abd..adad863 100644
> > --- a/include/dfu.h
> > +++ b/include/dfu.h
> > @@ -207,5 +207,16 @@ static inline int dfu_fill_entity_sf(struct
> > dfu_entity *dfu, char *devstr, }
> > #endif
> >
> > +#ifdef CONFIG_DFU_TFTP
> > +int dfu_tftp_write(char *dfu_entity_name, unsigned int addr,
> > unsigned int len); +#else
> > +static inline int dfu_tftp_write(char *dfu_entity_name, unsigned
> > int addr,
> > + unsigned int len)
> > +{
> > + puts("TFTP write support for DFU not available!\n");
> > + return -1;
>
> This should be -ENOSYS probably.
Good point - thanks!
>
> > +}
> > +#endif
> > +
> > int dfu_add(struct usb_configuration *c);
> > #endif /* __DFU_ENTITY_H_ */
> > --
> > 2.1.4
> >
> > _______________________________________________
> > U-Boot mailing list
> > U-Boot at lists.denx.de
> > http://lists.denx.de/mailman/listinfo/u-boot
Best regards,
Lukasz Majewski
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150716/e0afce0c/attachment.sig>
next prev parent reply other threads:[~2015-07-16 20:06 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-12 15:30 [U-Boot] [PATCH 0/8] dfu: tftp: update: Support for DFU upgrades via ETH (TFTP) Lukasz Majewski
2015-07-12 15:30 ` [U-Boot] [PATCH 1/8] doc: dfu: tftp: README entry for TFTP extension of DFU Lukasz Majewski
2015-07-15 18:14 ` Joe Hershberger
2015-07-16 19:59 ` Lukasz Majewski
2015-07-17 19:28 ` Joe Hershberger
2015-07-20 18:59 ` Lukasz Majewski
2015-07-20 19:17 ` Joe Hershberger
2015-07-20 20:09 ` Tormod Volden
2015-07-21 21:55 ` Lukasz Majewski
2015-07-12 15:30 ` [U-Boot] [PATCH 2/8] net: tftp: Move tftp.h file from ./net to ./include Lukasz Majewski
2015-07-15 18:17 ` Joe Hershberger
2015-07-16 20:02 ` Lukasz Majewski
2015-07-12 15:30 ` [U-Boot] [PATCH 3/8] tftp: update: Allow some parts of the code to be reused when CONFIG_SYS_NO_FLASH is set Lukasz Majewski
2015-07-15 18:19 ` Joe Hershberger
2015-07-12 15:30 ` [U-Boot] [PATCH 4/8] dfu: tftp: update: Provide tftp support for the DFU subsystem Lukasz Majewski
2015-07-15 18:24 ` Joe Hershberger
2015-07-16 20:06 ` Lukasz Majewski [this message]
2015-07-17 19:35 ` Joe Hershberger
2015-07-20 19:03 ` Lukasz Majewski
2015-07-12 15:30 ` [U-Boot] [PATCH 5/8] dfu: tftp: update: Add dfu_write_from_mem_addr() function Lukasz Majewski
2015-07-15 18:33 ` Joe Hershberger
2015-07-16 20:07 ` Lukasz Majewski
2015-07-12 15:30 ` [U-Boot] [PATCH 6/8] update: tftp: dfu: Extend update_tftp() function to support DFU Lukasz Majewski
2015-07-15 18:35 ` Joe Hershberger
2015-07-16 20:11 ` Lukasz Majewski
2015-07-17 19:38 ` Joe Hershberger
2015-07-20 19:05 ` Lukasz Majewski
2015-07-12 15:30 ` [U-Boot] [PATCH 7/8] dfu: command: Provide support for 'dfutftp' command to handle receiving data via TFTP Lukasz Majewski
2015-07-15 18:39 ` Joe Hershberger
2015-07-16 20:26 ` Lukasz Majewski
2015-07-17 19:40 ` Joe Hershberger
2015-07-20 17:59 ` Lukasz Majewski
2015-07-20 18:11 ` Joe Hershberger
2015-07-12 15:30 ` [U-Boot] [PATCH 8/8] config: bbb: Configs necessary for running update via TFTP on Beagle Bone Black Lukasz Majewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150716220607.7ea71d9b@jawa \
--to=l.majewski@majess.pl \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox