summaryrefslogtreecommitdiffstats
path: root/common/fastboot.c
Commit message (Collapse)AuthorAgeFilesLines
* usb: gadget: implement and use system_partitions_get_nullAhmad Fatoum2022-03-281-3/+1
| | | | | | | | | | | | | system_partitions_get() clones the system partitions file list and returns the copy. usb multi gadget code expects disabled gadgets to have a NULL file list, not an empty one, so fastboot and DFU handle this case. Add a new system_partitions_get_null helper that can be used instead. This will be used for USB mass storage gadget as well in a follow-up commit. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220319110246.2850396-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fastboot: use file_list_parse_null()Rouven Czerwinski2021-10-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In case an invalid file list is passed to file_list_parse(), it will return an error, i.e. by passing "/dev/mmc1(emmc) /dev/mmc1.1(root)", the error here being that the entries are not comma separated and file_list_parse will try to parse ' ' as a flag. The fastboot code didn't handle this, leading to the following error: ERROR: file_list: Unknown flag ' ' ERROR: file_list: parse error unable to handle paging request at address 0xfffffff2 pc : [<8fe26a20>] lr : [<8fe0f965>] sp : 8ffeff50 ip : 8ffef714 fp : 00079bda r10: 001b9ff8 r9 : 8fea7eec r8 : 00000001 r7 : 00000000 r6 : 00000001 r5 : 00000000 r4 : 8813eab0 r3 : ffffffea r2 : 00020000 r1 : 00000001 r0 : 8813eab0 Flags: nzCv IRQs off FIQs off Mode SVC_32 WARNING: [<8fe26a20>] (usb_multi_count_functions+0xc/0x2a) from [<8fe0f965>] (usbgadget_register+0x79/0xf4) WARNING: [<8fe0f965>] (usbgadget_register+0x79/0xf4) from [<8fe0fa13>] (usbgadget_autostart_set+0x33/0x4c) WARNING: [<8fe0fa13>] (usbgadget_autostart_set+0x33/0x4c) from [<8fe4d437>] (param_int_set+0x4b/0xb0) WARNING: [<8fe4d437>] (param_int_set+0x4b/0xb0) from [<8fe4d899>] (dev_set_param+0x4d/0x64) WARNING: [<8fe4d899>] (dev_set_param+0x4d/0x64) from [<8fe066f1>] (globalvar_add_bool+0x49/0x54) WARNING: [<8fe066f1>] (globalvar_add_bool+0x49/0x54) from [<8fe0f8dd>] (usbgadget_autostart_init+0x15/0x24) WARNING: [<8fe0f8dd>] (usbgadget_autostart_init+0x15/0x24) from [<8fe01081>] (start_barebox+0x35/0x6c) WARNING: [<8fe01081>] (start_barebox+0x35/0x6c) from [<8fe62ed9>] (barebox_non_pbl_start+0x121/0x164) WARNING: [<8fe62ed9>] (barebox_non_pbl_start+0x121/0x164) from [<8fe00005>] (__bare_init_start+0x1/0xc) WARNING: [<8fe64e3d>] (unwind_backtrace+0x1/0x78) from [<8fe01385>] (panic+0x1d/0x34) WARNING: [<8fe01385>] (panic+0x1d/0x34) from [<8fe62723>] (do_exception+0xf/0x14) WARNING: [<8fe62723>] (do_exception+0xf/0x14) from [<8fe62791>] (do_data_abort+0x21/0x34) WARNING: [<8fe62791>] (do_data_abort+0x21/0x34) from [<8fe624d4>] (do_abort_6+0x48/0x54) Use file_list_parse_null instead of file_list_parse to get a NULL pointer if there is a parse error. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Link: https://lore.barebox.org/20210810052928.101783-2-r.czerwinski@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bbu: add function to directly add handlers into file_listAhmad Fatoum2021-05-121-19/+2
| | | | | | | | | | | bbu_handlers_iterate() is only used for merging handlers into a file_list. This can be useful for other update mechanisms as well. Export a bbu_append_handlers_to_file_list that does this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210503114901.13095-14-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fastboot/dfu: use system partitions as fall backAhmad Fatoum2021-05-121-2/+7
| | | | | | | | | | | | | Use the new system partitions infrastructure to have fastboot and DFU fall back to using the same partitions if the global.usbgadget.dfu_function and global.fastboot_partitions are not set, respectively. No functional change intended for configurations that have SYSTEM_PARTITIONS disabled. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210503114901.13095-13-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fastboot: handle ill-named partitions gracefullyAhmad Fatoum2021-05-121-1/+3
| | | | | | | | | | | | | | Users can configure a partition name of bbu-something that would conflict at fastboot init time with a barebox update "something" handler. Current behavior is to silently ignore all remaining barebox update handlers. It would be better to complain loudly and to skip only the entries actually conflicting. Do so. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210503114901.13095-8-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* image-sparse: change retlen to size_tSteffen Trumtrar2021-01-131-1/+1
| | | | | | | | retlen can potentially overflow. Also, write_full() in fastboot_handle_sparse() expects size_t anyway. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/spdx'Sascha Hauer2020-12-111-2/+1
|\
| * common: replace license statements with SPDX-License-IdentifiersAhmad Fatoum2020-11-271-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | For all files in common/ that already have a license text: - Replace with appropriate SPDX-License-Identifier - Remove empty comment lines around replacement - remove comment completely if only thing remaining is name of file without description Reviewed-by: Roland Hieber <rhi@pengutronix.de> Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | commands: implement and use parse_assignment helperAhmad Fatoum2020-11-271-3/+1
|/ | | | | | | | | | | | We have the split by '=' snippet at multiple locations that parse key=value pairs. Consolidate them to a single location. This makes code a bit easier to read at the cost of an extra 8 bytes (LZO-compressed THUMB2 barebox, static inline version is bigger). No functional change. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* magicvar: Replace BAREBOX_MAGICVAR_NAMED with BAREBOX_MAGICVARSascha Hauer2020-10-021-7/+4
| | | | | | | | BAREBOX_MAGICVAR now generates a unique identifier automatically, so we can convert users of BAREBOX_MAGICVAR_NAMED to the simpler BAREBOX_MAGICVAR macro. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/net' into masterSascha Hauer2020-09-251-3/+54
|\
| * fastboot net: implement fastboot over UDPEdmund Henniges2020-08-191-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements the UDP variant of the fastboot protocol. The only way to start the service for now is to compile with CONFIG_FASTBOOT_NET_ON_BOOT. The service will bind to the network interface that provides the IPv4 gateway. Sending an OKAY packet before performing a restart is necessary since contrary to USB the host will not notice when a UDP server disappears. Signed-off-by: Edmund Henniges <eh@emlix.com> Signed-off-by: Daniel Glöckner <dg@emlix.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fastboot: init list head in commonSascha Hauer2020-08-191-0/+2
| | | | | | | | | | | | | | The list of variables can be initialized in common code, no need to do the in the different implementations. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fastboot: Add fastboot_abort()Sascha Hauer2020-08-191-0/+12
| | | | | | | | | | | | Add fastboot_abort() to allow aborting the current session. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fastboot: Warn when cb_download is called with file still openSascha Hauer2020-08-191-0/+6
| | | | | | | | | | | | | | Warn when we are about to open a new download file without having closed the old one. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * fastboot: rename usbgadget.fastboot_* variables to fastboot.*Daniel Glöckner2020-08-191-3/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | There is nothing USB-specific in the defined usbgadget.fastboot_* variables. Rename them to be usable also for the UDP fastboot transport. The usbgadget.fastboot_function variable is used to define the files and devices accessible with the erase and flash commands. Since "function" is a term from the USB specification and the Fastboot specification uses the term "partition", we rename that variable to "fastboot.partitions". Signed-off-by: Daniel Glöckner <dg@emlix.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fastboot: only unset image, not loadaddrRouven Czerwinski2020-09-151-1/+1
|/ | | | | | | | In case the board needs to setup the load address of the kernel, don't overwrite the variable, instead only override the image. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fastboot: Drop support for downloading to bufferSascha Hauer2020-06-181-70/+27
| | | | | | | | | | The option to download to a buffer instead of a file was introduced because in some workloads it is required to have a contiguous image in memory. With recent changes now ramfs can provide such a buffer via memmap API even when it downloaded the data to a file. This makes the explicit download to buffer option unnecessary, so remove it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fastboot: Use make_temp() to create temporary fileSascha Hauer2020-06-121-2/+3
| | | | | | make_temp() was created for this purpose, so use it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fastboot: Use unique tempfile nameSascha Hauer2020-05-201-9/+12
| | | | | | | | With fastboot over ethernet we now can have two instances of fastboot running in parallel. Make sure that both instances use a different temporary file to store data so that they do not influence each other. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fastboot: don't close fd 0 when downloading to ramDaniel Glöckner2020-05-201-1/+2
| | | | | | | | | When downloading to a buffer, download_fd is never assigned a valid file descriptor. We should therefore avoid calling close on the value found in that variable. Signed-off-by: Daniel Glöckner <dg@emlix.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fastboot: split generic code from USB gadgetEdmund Henniges2020-05-201-0/+957
The fastboot specification describes other protocols beyond USB. Allow these to reuse the generic parts of the existing fastboot code when they are implemented. Most of the changes in common/fastboot.c are due to the renaming of struct f_fastboot *f_fb to struct fastboot *fb. Signed-off-by: Edmund Henniges <eh@emlix.com> Signed-off-by: Daniel Glöckner <dg@emlix.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>