aboutsummaryrefslogtreecommitdiff
path: root/drivers/dfu
AgeCommit message (Collapse)AuthorFilesLines
2019-10-31dfu: add callback for flush and initiated operationPatrick Delaunay1-0/+19
Add weak callback to allow board specific behavior - flush - initiated This patch prepare usage of DFU back end for communication with STM32CubeProgrammer on stm32mp1 platform with stm32prog command. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
2019-10-31dfu: add DFU virtual backendPatrick Delaunay4-1/+61
Add a virtual DFU backend to allow board specific read and write (for OTP update for example). Acked-by: Lukasz Majewski <lukma@denx.de> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
2019-10-31dfu: add partition support for MTD backendPatrick Delaunay1-1/+80
Add the support of MTD partition for the MTD backend. The expected dfu_alt_info for one alternate on the mtd device : <name> part <part_id> <name> partubi <part_id> "partubi" also erase up to the end of the partition after write operation. For example: dfu_alt_info = "spl part 1;u-boot part 2; UBI partubi 3" U-Boot> dfu 0 mtd nand0 Acked-by: Lukasz Majewski <lukma@denx.de> Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
2019-10-31dfu: add backend for MTD devicePatrick Delaunay4-1/+243
Add DFU backend for MTD device: allow to read and write on all MTD device (NAND, SPI-NOR, SPI-NAND,...) For example : > set dfu_alt_info "nand_raw raw 0x0 0x100000" > dfu 0 mtd nand0 This MTD backend provides the same level than dfu nand backend for NAND and dfu sf backend for SPI-NOR; So it can replace booth of them but it also add support of spi-nand. > set dfu_alt_info "nand_raw raw 0x0 0x100000" > dfu 0 mtd spi-nand0 The backend code is based on the "mtd" command introduced by commit 5db66b3aee6f ("cmd: mtd: add 'mtd' command") Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
2019-10-31dfu: allow read with no data without error for EOF indicationPatrick Delaunay1-0/+2
This patch allows the DFU backend to indicate that that it can't provide no more data to fill the DFU buffer, by setting b_left =0 without error, even if the size of received data is lower of the expected total size indicated by get_medium_size. For USB DFU stack point of view, it is acceptable: the read length < requested size in DFU_UPLOAD and the transaction is stopped. That avoid infinite loop issue in dfu_read_buffer_fill because the size for the DFU read is limited by get_medium_size = r_left and the DFU stack expects that read is allowed up to this size. This issue never occurs for current flash device (where chunk are always completely read, and b_left will be never 0) but it is useful for virtual partition when the backend only know the max size of this alternate, the real size of the data are only known in the read treatment. PS: for file access on mmc, EOF is never reached as dfu_get_medium_size_mmc returns the exact size of the file. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
2019-10-31dfu: allow to manage DFU on several devicesPatrick Delaunay1-1/+59
Add support of DFU for several interface/device with one command. The format for "dfu_alt_info" in this case is : - <interface> <dev>'='alternate list (';' separated) - each interface is separated by '&' The previous behavior is always supported. One example for NOR (bootloaders) + NAND (rootfs in UBI): U-Boot> env set dfu_alt_info \ "sf 0:0:10000000:0=spl part 0 1;u-boot part 0 2; \ u-boot-env part 0 3&nand 0=UBI partubi 0,3" U-Boot> dfu 0 list DFU alt settings list: dev: SF alt: 0 name: spl layout: RAW_ADDR dev: SF alt: 1 name: ssbl layout: RAW_ADDR dev: SF alt: 2 name: u-boot-env layout: RAW_ADDR dev: NAND alt: 3 name: UBI layout: RAW_ADDR U-Boot> dfu 0 $> dfu-util -l Found DFU: [0483:5720] ver=9999, devnum=96, cfg=1,\ intf=0, alt=3, name="UBI", serial="002700333338511934383330" Found DFU: [0483:5720] ver=9999, devnum=96, cfg=1,\ intf=0, alt=2, name="u-boot-env", serial="002700333338511934383330" Found DFU: [0483:5720] ver=9999, devnum=96, cfg=1,\ intf=0, alt=1, name="u-boot", serial="002700333338511934383330" Found DFU: [0483:5720] ver=9999, devnum=96, cfg=1,\ intf=0, alt=0, name="spl", serial="002700333338511934383330" Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
2019-10-31dfu: prepare the support of multiple interfacePatrick Delaunay1-12/+39
Split the function dfu_config_entities with 2 new functions - dfu_alt_init - dfu_alt_add Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
2019-10-31dfu: sf: add partition support for nor backendPatrick Delaunay2-0/+60
Copy the partition support from NAND backend to SF, support part and partubi option. In case of ubi partition, erase the rest of the partition as it is mandatory for UBI. The added code is under compilation flag CONFIG_DFU_SF_PART activated by default. for example: U-Boot> env set dfu_alt_info "spl part 0 1;\ u-boot part 0 2;u-boot-env part 0 3;UBI partubi 0 4" U-Boot> dfu 0 sf 0:0:10000000:0 Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
2019-10-31dfu: cosmetic: cleanup sf to avoid checkpatch errorPatrick Delaunay2-5/+6
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Acked-by: Lukasz Majewski <lukma@denx.de>
2019-10-31dfu: mmc: add support for in-partition offsetMarek Szyprowski1-2/+11
Add possibility to define a part of partition as a separate DFU entity. This allows to have more than one items on the given partition. The real use case for this option is TM2 board. It can use u-boot stored as Linux kernel on the defined partition (as RAW data) and load the real kernel from the same partition, but stored under the certain offset. Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Acked-by: Lukasz Majewski <lukma@denx.de>
2019-10-31dfu: dfu_nand: reduce verbosityRalph Siemsen1-1/+1
In combination with multiple partitions in NAND, this printf() ends up being more noise than helpful. Change it to debug() instead. Signed-off-by: Ralph Siemsen <ralph.siemsen@linaro.org> Acked-by: Lukasz Majewski <lukma@denx.de>
2019-08-11env: Move env_get() to env.hSimon Glass1-0/+1
Move env_get() over to the new header file. Acked-by: Joe Hershberger <joe.hershberger@ni.com> Signed-off-by: Simon Glass <sjg@chromium.org>
2019-01-30dfu: mmc: call fs functions instead of run_commandSimon Goldschmidt1-36/+31
This unbreaks dfu mmc_file_op which is currently broken since using the load cmd on a buffer from heap is not allowed - added with commit aa3c609e2be5 ("fs: prevent overwriting reserved memory") Fixes: commit aa3c609e2be5 ("fs: prevent overwriting reserved memory") Reported-by: Stephen Warren <swarren@wwwdotorg.org> Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com> Tested-by: Stephen Warren <swarren@nvidia.com> Acked-by: Lukasz Majewski <lukma@denx.de>
2019-01-26dfu: Make DFU support more SPL friendlyAndrew F. Davis1-6/+6
Do this by using $(SPL_) in Makefiles and CONFIG_IS_ENABLED in C code. This ensures the files and features are only built into the right build for which they are enabled. Using the macros to simplify this patch was made possible by the config symbol rename done in the last patch. Signed-off-by: Andrew F. Davis <afd@ti.com> Reviewed-by: Tom Rini <trini@konsulko.com> Acked-by: Lukasz Majewski <lukma@denx.de>
2018-11-13dfu: nand: Add missing dependency on CMD_MTDPARTSBoris Brezillon1-0/+1
dfu_fill_entity_nand() uses find_dev_and_part() and mtdparts_init() which are provided by cmd/mtdparts.c. Add the dependency to avoid build failures when CMD_MTDPARTS is not selected. Reported-by: Jagan Teki <jagan@amarulasolutions.com> Fixes: 6828e602b722d ("dfu: Migrate to Kconfig") Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Reviewed-by: Lukasz Majewski <lukma@denx.de> Reviewed-by: Jagan Teki <jagan@openedev.com>
2018-08-08dfu: Provide more verbose error messageSam Protsenko1-0/+1
It might be useful for user to see some human-readable root cause message in addition to "configuration failed" message, so that the issue can be fixed quickly. Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
2018-08-08dfu: Fix memory leak in dfu_init_env_entities()Sam Protsenko1-3/+4
In case of error in dfu_init_env_entities(), env_bkp will leak. Fix it by providing single return path. Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
2018-08-08dfu: Fix data abort in dfu_free_entities()Sam Protsenko1-1/+1
Commit 5d8fae79163e ("dfu: avoid memory leak") brings a regression which described below. This patch is effectively reverting that commit, adding corresponding comment to avoid such regressions in future. In case of error in dfu_config_entities(), it frees "dfu" array, which leads to "data abort" in dfu_free_entities(), which tries to free the same array (and even tries to access it from linked list first). The issue occurs e.g. when partition table on device does not match $dfu_alt_info layout: => dfu 0 mmc 1 Couldn't find part #2 on mmc device #1 DFU entities configuration failed! data abort To fix this issue, do not free "dfu" array in dfu_config_entities(). It will be freed later in dfu_free_entities(). Tested on BeagleBone Black (where this regression was originally found). Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
2018-05-07SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini7-15/+7
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
2018-02-21dfu: tftp: Fix arm64 build warningsMarek Vasut1-2/+2
Fix two build warnings when building for arm64: drivers/dfu/dfu_tftp.c: In function ‘dfu_tftp_write’: drivers/dfu/dfu_tftp.c:59:37: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] ret = dfu_write_from_mem_addr(dfu, (void *)addr, len); ^ and drivers/dfu/dfu_tftp.c: In function ‘dfu_tftp_write’: drivers/dfu/dfu_tftp.c:41:8: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 4 has type ‘__kernel_size_t {aka long unsigned int}’ [-Wformat=] debug("%s: image name: %s strlen: %u\n", __func__, sb, strlen(sb)); ^ Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Lukasz Majewski <lukma@denx.de>
2018-02-21dfu: Rename _FUNCTION_DFU to DFU_OVER_Marek Vasut1-4/+4
Do the following to make the symbol names less confusing. sed -i "s/\([TU][^_]\+\)_FUNCTION_DFU/DFU_OVER_\1/g" \ `git grep _FUNCTION_DFU | cut -d ":" -f 1 | sort -u` Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Lukasz Majewski <lukma@denx.de>
2018-02-21dfu: Fix up the Kconfig messMarek Vasut2-2/+12
Clean up the screaming mess of configuration options that DFU is. It was impossible to configure DFU such that TFTP is enabled and USB is not, this patch fixes that and assures that DFU TFTP and DFU USB can be enabled separatelly and that the correct pieces of code are compiled in. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Lukasz Majewski <lukma@denx.de>
2018-01-26dfu: select HASHMaxime Ripard1-0/+1
The DFU code relies on the HASH config option. Make sure it is always there by selecting it. Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> Reviewed-by: Jagan Teki <jagan@openedev.com>
2017-10-04treewide: replace with error() with pr_err()Masahiro Yamada4-22/+22
U-Boot widely uses error() as a bit noisier variant of printf(). This macro causes name conflict with the following line in include/linux/compiler-gcc.h: # define __compiletime_error(message) __attribute__((error(message))) This prevents us from using __compiletime_error(), and makes it difficult to fully sync BUILD_BUG macros with Linux. (Notice Linux's BUILD_BUG_ON_MSG is implemented by using compiletime_assert().) Let's convert error() into now treewide-available pr_err(). Done with the help of Coccinelle, excluing tools/ directory. The semantic patch I used is as follows: // <smpl> @@@@ -error +pr_err (...) // </smpl> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Simon Glass <sjg@chromium.org> [trini: Re-run Coccinelle] Signed-off-by: Tom Rini <trini@konsulko.com>
2017-08-16env: Rename getenv/_f() to env_get()Simon Glass2-4/+4
We are now using an env_ prefix for environment functions. Rename these two functions for consistency. Also add function comments in common.h. Quite a few places use getenv() in a condition context, provoking a warning from checkpatch. These are fixed up in this patch also. Suggested-by: Wolfgang Denk <wd@denx.de> Signed-off-by: Simon Glass <sjg@chromium.org>
2017-07-28dfu: add common function to initiate transactionPatrick Delaunay1-38/+34
- factorize code between read and write transaction - always use dfu_transaction_cleanup() to initialize the internal variable: easy maintenance - replace direct access by dfu_get_buf() and dfu_get_buf_size() Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
2017-07-28dfu: factorize transaction cleanupPatrick Delaunay1-17/+11
rename cleanup function, as now called by read Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
2017-07-28dfu: remove limitation on partition sizePatrick Delaunay5-9/+9
Change long (32 bits on arm) to u64 (same type than offset) for size and read offset r_left So partition and device used for DFU can be greater than 4GB Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
2017-07-28dfu: allow dfu read on partition greater than 2GBPatrick Delaunay5-15/+21
solve issue on get_medium_size() function the detection of error is a simple test < 0 but for ARM platform, long is 32bits and 2GB = 0x80000000 is seen as error. I solve the issue by changing the prototype fo the function to separate size and result. This patch prepare the next patch with size change to u64. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
2017-07-11dfu: dfu_nand: use get_nand_dev_by_index()Grygorii Strashko1-7/+5
As part of preparation for nand DM conversion the new API has been introduced to remove direct access to nand_info array. So, use it here instead of accessing to nand_info array directly. Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
2017-06-03dfu: dfu_sf: Fix read offsetPhil Edworthy1-1/+2
The offset was applied to write, but not read, now its applied to both. Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
2017-05-12common: dfu: ignore reset for spl-dfuB, Ravi1-0/+4
The SPL-DFU feature enable to load and execute u-boot from RAM over usb from PC using dfu-util. Hence dfu-reset should not be issued when dfu-util -R switch is issued. Signed-off-by: Ravi Babu <ravibabu@ti.com>
2016-11-03dfu: align array in dfu_get_dev_type with enum dfu_device_typePatrick Delaunay1-1/+1
Signed-off-by: Patrick Delaunay <patrick.delaunay73@gmail.com>
2016-09-27dfu: Migrate to KconfigTom Rini1-0/+28
Introduce a hidden USB_FUNCTION_DFU Kconfig option and select it for CMD_DFU (as we must have the DFU command enabled to do anything DFU). Make all of the entries in drivers/dfu/Kconfig depend on CMD_DFU and add options for all of the back end choices that DFU can make use of. Cc: Lukasz Majewski <l.majewski@samsung.com> Signed-off-by: Tom Rini <trini@konsulko.com> Acked-by: Lukasz Majewski <l.majewski@samsung.com>
2016-09-01nand: Fix some more NULL name testsScott Wood1-2/+2
Now that nand_info[] is an array of pointers we need to test the pointer itself rather than using name as a proxy for NULLness. Fixes: b616d9b0a708eb9 ("nand: Embed mtd_info in struct nand_chip") Signed-off-by: Scott Wood <oss@buserror.net> Cc: Lukasz Majewski <l.majewski@samsung.com> Cc: Tony Lindgren <tony@atomide.com> Acked-by: Tony Lindgren <tony@atomide.com>
2016-07-11dm: dfu: mmc: Support CONFIG_BLK in DFU for MMCSimon Glass1-6/+5
Update the method of accessing the block device so that it works with CONFIG_BLK enabled. Signed-off-by: Simon Glass <sjg@chromium.org>
2016-06-09dfu, nand, ubi: fix erasing after write finishHeiko Schocher1-1/+11
writting to ubi nand partitions need after write ends an erase of the remaining sectors. This fail, if dfu write size was not a multiple of erasesize, example log: Failure erase: -1 Fix this error. Signed-off-by: Heiko Schocher <hs@denx.de>
2016-06-03nand: Embed mtd_info in struct nand_chipScott Wood1-4/+4
nand_info[] is now an array of pointers, with the actual mtd_info instance embedded in struct nand_chip. This is in preparation for syncing the NAND code with Linux 4.6, which makes the same change to struct nand_chip. It's in a separate commit due to the large amount of changes required to accommodate the change to nand_info[]. Signed-off-by: Scott Wood <oss@buserror.net>
2016-06-03mtd: nand: Remove nand_info_t typedefScott Wood1-10/+10
This typedef serves no purpose other than causing confusion with struct nand_chip. Signed-off-by: Scott Wood <oss@buserror.net>
2016-05-17dm: mmc: Use the new select_hwpart() APISimon Glass1-4/+9
Avoid calling directly into the MMC code - use the new API call instead. Signed-off-by: Simon Glass <sjg@chromium.org>
2016-05-06Merge branch 'master' of git://git.denx.de/u-boot-usbTom Rini1-1/+3
2016-05-06dfu: avoid memory leakPeng Fan1-1/+3
When dfu_fill_entity fail, need to free dfu to avoid memory leak. Reported by Coverity: " Resource leak (RESOURCE_LEAK) leaked_storage: Variable dfu going out of scope leaks the storage it points to. " Signed-off-by: Peng Fan <van.freenix@gmail.com> Cc: "Łukasz Majewski" <l.majewski@samsung.com> Cc: Marek Vasut <marex@denx.de>
2016-05-05Fix various typos, scattered over the code.Robert P. J. Day1-3/+3
Spelling corrections for (among other things): * environment * override * variable * ftd (should be "fdt", for flattened device tree) * embedded * FTDI * emulation * controller
2016-04-25dfu: ram: fix number base of RAM entity parametersStephen Warren1-2/+2
U-Boot typically interprets unprefixed numbers as base 16, and DFU RAM entity parsing has historically done so. Reverse the change to default to base 10, so that values in previously working command-lines aren't mis-parsed, causing RAM corruption, crashes, hangs, etc. Fixes: 6aeb877afef0 ("drivers: dfu: ram: fix a crash with dfu ram with invalid dfu_alt_info env") Cc: Mugunthan V N <mugunthanvnm@ti.com> Cc: Tom Rini <trini@konsulko.com> Signed-off-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Mugunthan V N <mugunthanvnm@ti.com> Tested-by: Mugunthan V N <mugunthanvnm@ti.com> [Test HW: AM335x BBB]
2016-04-25drivers: dfu: ram: fix a crash with dfu ram with invalid dfu_alt_info envMugunthan V N1-7/+14
U-Boot crashes when an invalid dfu_alt_info is set and tried using dfu command. Fixing this as it is handled in dfu-mmc. => dfu 0 ram 0 data abort pc : [<9ff893d6>] lr : [<9ff6edb9>] reloc pc : [<808323d6>] lr : [<80817db9>] sp : 9ef36cf0 ip : 00000158 fp : 9ffbc0b8 r10: 9ffbc0b8 r9 : 9ef36ed8 r8 : 00000000 r7 : 00000000 r6 : 9ffbc0c8 r5 : 9ef36cfc r4 : 9ef392c8 r3 : 00000004 r2 : 00000000 r1 : 9ff9a985 r0 : ffffffff Flags: Nzcv IRQs off FIQs on Mode SVC_32 Resetting CPU ... resetting ... Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2016-03-14dm: part: Rename some partition functionsSimon Glass1-1/+1
Rename three partition functions so that they start with part_. This makes it clear what they relate to. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Stephen Warren <swarren@nvidia.com>
2016-03-14dm: Drop the block_dev_desc_t typedefSimon Glass1-1/+1
Use 'struct' instead of a typdef. Also since 'struct block_dev_desc' is long and causes 80-column violations, rename it to struct blk_desc. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Stephen Warren <swarren@nvidia.com>
2016-01-13mmc: store hwpart in the block deviceStephen Warren1-21/+5
This will allow us to have multiple block device structs each referring to the same eMMC device, yet different HW partitions. For now, there is still a single block device per eMMC device. As before, this block device always accesses whichever HW partition was most recently selected. Clients wishing to make use of multiple block devices referring to different HW partitions can simply take a copy of this block device once it points at the correct HW partition, and use each one as they wish. This feature will be used by the next patch. In the future, perhaps get_device() could be enhanced to return a dynamically allocated block device struct, to avoid the client needing to copy it in order to maintain multiple block devices. However, this would require all users to be updated to free those block device structs at some point, which is rather a large change. Most callers of mmc_switch_part() wish to permanently switch the default MMC block device's HW partition. Enhance mmc_switch_part() so that it does this. This removes the need for callers to do this. However, common/env_mmc.c needs to save and restore the current HW partition. Make it do this more explicitly. Replace use of mmc_switch_part() with mmc_select_hwpart() in order to remove duplicate code that skips the call if that HW partition is already selected. Signed-off-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2016-01-13block: pass block dev not num to read/write/erase()Stephen Warren1-2/+2
This will allow the implementation to make use of data in the block_dev structure beyond the base device number. This will be useful so that eMMC block devices can encompass the HW partition ID rather than treating this out-of-band. Equally, the existence of the priv field is crying out for this patch to exist. Signed-off-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Tom Rini <trini@konsulko.com>
2015-11-03dfu: dfu_sf: Pass duplicate devstr to parse_devVignesh R1-1/+3
parse_dev() alters the string pointed by devstr parameter. Due to this subsequent parsing of sf entities will fail, as string pointed by devstr is no longer valid sf dev arguments. Fix this by passing pointer to the copy of the string to parse_dev instead of pointer to the actual devstr. Signed-off-by: Vignesh R <vigneshr@ti.com> Reviewed-by: Tom Rini <trini@konsulko.com>