summaryrefslogtreecommitdiffstats
path: root/drivers/dfu/dfu.c
Commit message (Collapse)AuthorAgeFilesLines
* drivers:dfu: dfu_flush(): add raw data flush to complete dfu writePrzemyslaw Marczak2014-05-151-0/+4
| | | | | | | | | | | | | | | | | | Before dfu write and flush operations separation, dfu write data was flushed by host download request with len of zero size. Since above change manually calling dfu write with zero size has non sense (e.g. in THOR). This should be done by flush operation. So now dfu_write_buffer_drain() is called in dfu_flush(). If there is any raw data to flush (like it can be in thor) then it will be physically written to medium. Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com> Cc: Lukasz Majewski <l.majewski@samsung.com> Cc: Heiko Schocher <hs@denx.de> Cc: Marek Vasut <marex@denx.de>
* dfu:fix: Replace wrong return value with proper oneLukasz Majewski2014-04-301-1/+1
| | | | | | | This patch remove always false (since we tested ret = 0) ternary operator with ret value returned. Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
* Merge branch 'u-boot/master' into 'u-boot-arm/master'Albert ARIBAUD2014-04-081-20/+22
|\ | | | | | | | | | | | | | | Conflicts: arch/arm/cpu/arm926ejs/mxs/Makefile include/configs/trats.h include/configs/trats2.h include/mmc.h
| * usb: dfu: introduce dfuMANIFEST stateHeiko Schocher2014-03-231-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | on nand flash using ubi, after the download of the new image into the flash, the "rest" of the nand sectors get erased while flushing the medium. With current u-boot version dfu-util may show: Starting download: [##################################################] finished! state(7) = dfuMANIFEST, status(0) = No error condition is present unable to read DFU status as get_status is not answered while erasing sectors, if erasing needs some time. So do the following changes to prevent this: - introduce dfuManifest state According to dfu specification ( http://www.usb.org/developers/devclass_docs/usbdfu10.pdf ) section 7: "the device enters the dfuMANIFEST-SYNC state and awaits the solicitation of the status report by the host. Upon receipt of the anticipated DFU_GETSTATUS, the device enters the dfuMANIFEST state, where it completes its reprogramming operations." - when stepping into dfuManifest state, sending a PollTimeout DFU_MANIFEST_POLL_TIMEOUT in ms, to the host, so the host (dfu-util) waits the PollTimeout before sending a get_status again. Signed-off-by: Heiko Schocher <hs@denx.de> Cc: Lukasz Majewski <l.majewski@samsung.com> Cc: Kyungmin Park <kyungmin.park@samsung.com> Cc: Marek Vasut <marex@denx.de> Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
| * usb, dfu: extract flush code into seperate functionHeiko Schocher2014-03-231-18/+24
| | | | | | | | | | | | | | | | | | | | | | move the flushing code into an extra function dfu_flush(), so it can be used from other code. Signed-off-by: Heiko Schocher <hs@denx.de> Cc: Lukasz Majewski <l.majewski@samsung.com> Cc: Kyungmin Park <kyungmin.park@samsung.com> Cc: Marek Vasut <marex@denx.de> Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
* | usb: dfu: add static alt num count in dfu_config_entities()Przemyslaw Marczak2014-03-131-1/+5
|/ | | | | | | | | | | | Thanks to this multiple call of function dfu_config_entities() gives continuous dfu alt numbering until call dfu_free_entities(). This allows to store dfu entities in multiple variables. Signed-off-by: Przemyslaw Marczak <p.marczak@samsung.com> Acked-by: Łukasz Majewski <l.majewski@samsung.com> Tested-by: Heiko Schocher <hs@denx.de> Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
* dfu: Export allocated dfu buffer sizeLukasz Majewski2013-12-181-0/+5
| | | | | | | The method for exporting size of allocated buffer is provided. It is afterwards used by USB's dfu function code. Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
* usb: dfu: correct dfu buffer inited valueBo Shen2013-11-081-1/+1
| | | | | | | | | After dfu buffer is initialized, the buffer should be all available, while not 0. Initialize its value to min(dfu_buf_size, dfu->r_left). Signed-off-by: Bo Shen <voice.shen@atmel.com> Tested-by: Lukasz Majewski <l.majewski@samsung.com> Acked-by: Lukasz Majewski <l.majewski@samsung.com>
* usb: dfu: decrease dfu->r_left along with the transferBo Shen2013-11-081-0/+1
| | | | | | The value of dfu->r_left need decrease along with the transfer Signed-off-by: Bo Shen <voice.shen@atmel.com>
* dfu:core: Export dfu_{get|free}_buf functionsLukasz Majewski2013-10-201-2/+2
| | | | | | | | Define the dfu_get_buf() and dfu_free_buf() as global functions. They are necessary for zero copy buffer management, when DFU backend is used for storing data. Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
* dfu:core: Find DFU alt setting number by passing its nameLukasz Majewski2013-10-201-0/+12
| | | | | | | New function - dfu_get_alt() - has been added to dfu core. If present, it returns alt setting's number corresponding to passed name. Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
* usb: new board-specific USB init interfaceMateusz Zalega2013-10-201-1/+1
| | | | | | | | | | | | | | This commit unifies board-specific USB initialization implementations under one symbol (usb_board_init), declaration of which is available in usb.h. New API allows selective initialization of USB controllers whenever needed. Signed-off-by: Mateusz Zalega <m.zalega@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com> Cc: Marek Vasut <marex@denx.de> Cc: Lukasz Majewski <l.majewski@samsung.com>
* dfu: ram supportAfzal Mohammed2013-09-241-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DFU spec mentions it as a method to upgrade firmware (software stored in writable non-volatile memory). It also says other potential uses of DFU is beyond scope of the spec. Here such a beyond the scope use is being attempted - directly pumping binary images from host via USB to RAM. This facility is a developer centric one in that it gives advantage over upgrading non-volatile memory for testing new images every time during development and/or testing. Directly putting image onto RAM would speed up upgrade process. This and convenience was the initial thoughts that led to doing this, speed improvement over MMC was only 1 second though - 6 sec on RAM as opposed to 7 sec on MMC in beagle bone, perhaps enabling cache and/or optimizing DFU framework to avoid multiple copy for ram (if worth) may help, and on other platforms and other boot media like NAND maybe improvement would be higher. And for a platform that doesn't yet have proper DFU suppport for non-volatile media's, DFU to RAM can be used. Another minor advantage would be to increase life of mmc/nand as it would be less used during development/testing. usage: <image name> ram <start address> <size> eg. kernel ram 0x81000000 0x1000000 Downloading images to RAM using DFU is not something new, this is acheived in openmoko also. DFU on RAM can be used for extracting RAM contents to host using dfu upload. Perhaps this can be extended to io for squeezing out register dump through usb, if it is worth. Signed-off-by: Afzal Mohammed <afzal.mohd.ma@gmail.com> Cc: Heiko Schocher <hs@denx.de> Cc: Marek Vasut <marex@denx.de> Cc: Lukasz Majewski <l.majewski@samsung.com> Cc: Pantelis Antoniou <panto@antoniou-consulting.com> Cc: Gerhard Sittig <gsi@denx.de> Acked-by: Marek Vasut <marex@denx.de> Acked-by: Lukasz Majewski <l.majewski@samsung.com> Acked-by: Heiko Schocher <hs@denx.de>
* dfu: Extract common DFU code to handle "dfu_alt_info" environment variableLukasz Majewski2013-09-241-0/+23
| | | | | | | | | | | New dfu_init_env_entities() function has been extracted from cmd_dfu.c and stored at dfu core. This is a dfu centric code, so it shall be processed in the core. Change-Id: I756c5de922fa31399d8804eaadc004ee98844ec2 Signed-off-by: Lukasz Majewski <l.majewski@samsung.com> Tested-by: Heiko Schocher <hs@denx.de>
* dfu:cosmetic: Fix printf text for buffer overflow conditionLukasz Majewski2013-09-241-2/+2
| | | | | | | Correct error message if overflow is detected. Change-Id: I8a915c7353d49822c046fbc36241237b370e6c98 Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
* dfu: Implementation of target reset after communication with dfu-util's -R ↵Lukasz Majewski2013-07-291-0/+11
| | | | | | | | | | | | | | switch This patch extends dfu code to support transmission with -R switch specified at dfu-util. When -R is specified, the extra USB_REQ_DFU_DETACH request is sent after successful data transmission. Then dfu resources are released and reset command is issued. Signed-off-by: Lukasz Majewski <l.majewski@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
* Add GPL-2.0+ SPDX-License-Identifier to source filesWolfgang Denk2013-07-241-13/+1
| | | | | | Signed-off-by: Wolfgang Denk <wd@denx.de> [trini: Fixup common/cmd_io.c] Signed-off-by: Tom Rini <trini@ti.com>
* dfu:ext4:fix Fix DFU upload functionalityŁukasz Majewski2013-07-031-4/+5
| | | | | | | | | | | | | | | For the first eMMC read of data for upload, use the "large" dfu_buf (now configurable) instead of usb request buffer allocated at composite layer (which is 4KiB) [*]. For eMMC the whole file is read, which usually is larger than the buffer [*] provided with usb request. Signed-off-by: Lukasz Majewski <l.majewski@samsung.com> Cc: Tom Rini <trini@ti.com> Cc: Pantelis Antoniou <panto@antoniou-consulting.com> Cc: Marek Vasut <marex@denx.de> Cc: Heiko Schocher <hs@denx.de>
* dfu: make data buffer size configurableHeiko Schocher2013-06-301-8/+41
| | | | | | | | | | | | | | | | Dfu transfer uses a buffer before writing data to the raw storage device. Make the size (in bytes) of this buffer configurable through environment variable "dfu_bufsiz". Defaut value is configurable through CONFIG_SYS_DFU_DATA_BUF_SIZE Signed-off-by: Heiko Schocher <hs@denx.de> Cc: Pantelis Antoniou <panto@antoniou-consulting.com> Cc: Tom Rini <trini@ti.com> Cc: Lukasz Majewski <l.majewski@samsung.com> Cc: Kyungmin Park <kyungmin.park@samsung.com> Cc: Marek Vasut <marex@denx.de> Cc: Wolfgang Denk <wd@denx.de> Acked-by: Tom Rini <trini@ti.com>
* dfu: NAND specific routines for DFU operationPantelis Antoniou2013-04-101-0/+8
| | | | | | | | Support for NAND storage devices to work with the DFU framework. Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com> Signed-off-by: Tom Rini <trini@ti.com> Acked-by: Scott Wood <scottwood@freescale.com>
* dfu: Support larger than memory transfers.Pantelis Antoniou2013-04-101-53/+190
| | | | | | | | | | | | | | | | | | | Previously we didn't support upload/download larger than available memory. This is pretty bad when you have to update your root filesystem for example. This patch removes that limitation (and the crashes when you transfered any file larger than 4MB) by making raw image writes be done in chunks and making file maximum size be configurable. The sequence number is a 16 bit counter; make sure we handle rollover correctly. This fixes the wrong transfers for large (> 256MB) images. Also utilize a variable to handle initialization, so that we don't rely on just the counter sent by the host. Signed-off-by: Pantelis Antoniou <panto@antoniou-consulting.com> Signed-off-by: Tom Rini <trini@ti.com>
* dfu: DFU backend implementationLukasz Majewski2012-09-011-0/+238
New, separate driver at ./drivers/dfu has been added. It allows platform and storage independent operation of DFU. It has been extended to use new MMC level of command abstraction. Signed-off-by: Lukasz Majewski <l.majewski@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Cc: Marek Vasut <marex@denx.de>