aboutsummaryrefslogtreecommitdiffstats
path: root/tools
Commit message (Collapse)AuthorAgeFilesLines
* firmware-utils: tplink-safeloader: support displaying fw infoRafał Miłecki2021-04-141-4/+127
| | | | | | | | | | Add "-i" option for reading & displaying firmware info. First it lists in-firmware partitions ("fwup-ptn"). Then it checks for human understandable partitions and prints data found in each of them. This new feature is meant for development & debug purposes. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* firmware-utils: mkmylofw: fix blocks paddingRafał Miłecki2021-04-131-1/+1
| | | | | | | | | | | | | | | The old code didn't make sense as it was using "len" variable which was guaranteed to be always 0. Loop right above broken code is: while (len > 0) { } With this recent ALIGN macro fix this resulted in subtracting block size from 0 and calling write_out_padding() with a negative length. To calculate amount of bytes needed for padding & alignment it should be enough to use % 4. Fixes: a2f66229450d ("firmware-utils: fix few random warnings") Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* firmware-utils: zyimage: drop POSIX SOURCE definesRafał Miłecki2021-04-131-2/+0
| | | | | | | | | | This fixes: src/zyimage.c:10:0: warning: "_POSIX_SOURCE" redefined src/zyimage.c:11:0: warning: "_POSIX_C_SOURCE" redefined This change has been tested on Linux with -Wextra and on Mac OS. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* tplink-safeloader: fix C7v5 factory flashing from vendor fw > v1.1.xPetr Štetiar2021-04-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently it's not possible to flash factory images on devices shipped with vendor firmware versions 1.1.0 Build 20201120 rel. 50406 (published 2020-12-22): (curFw_ver, newFw_ver) == (1.1, 1.0) [NM_Error](nm_checkSoftVer) 00848: Firmwave not supports, check failed. [NM_Error](nm_checkUpdateContent) 01084: software version dismatched [NM_Error](nm_buildUpgradeStruct) 01188: checkUpdateContent failed. They've even following note in release notes: Note: You will be unable to downgrade to the previous firmware version after updating this firmware. This version check in vendor firmware is implemented in /usr/bin/nvrammanager binary likely as following C code[1]: sscanf(buf, "%d.%d.%*s",&upd_fw_major, &upd_fw_minor); ... if (((int)upd_fw_major < (int)cur_fw_major) || ((ret = 1, cur_fw_major == upd_fw_major && (upd_fw_minor < (int)cur_fw_minor)))) { ret = 0; printf("[NM_Error](%s) %05d: Firmwave not supports, check failed.\r\n\r\n","nm_checkSoftVer" ,0x350); } ... return ret; So in order to fix this and make it future proof it should be enough to ship our factory firmware images with major version 7 (lucky number). Tested on latest firmware version 1.1.2 Build 20210125 rel.37999: Firmwave supports, check OK. (curFw_ver, newFw_ver) == (1.1, 7.0) check firmware ok! Flashing back to vendor firmware c7v5_us-up-ver1-1-2-P1[20210125-rel37999]_2021-01-25_10.33.55.bin works as well: U-Boot 1.1.4-gbec22107-dirty (Nov 18 2020 - 18:19:12) ... Firmware downloaded... filesize = 0xeeae77 fileaddr = 0x80060000. Firmware Recovery file length : 15642231 Firmware process id 2. handle_fw_cloud 146 Image verify OK! Firmware file Verify ok! product-info:product_name:Archer C7 product_ver:5.0.0 special_id:55530000 [Error]sysmgr_cfg_checkSupportList(): 1023 @ specialId 45550000 NOT Match. Firmware supports, check OK. Firmware Recovery check ok! 1. https://gist.github.com/ynezz/2e0583647d863386a66c3d231541b6d1 Signed-off-by: Petr Štetiar <ynezz@true.cz>
* firmware-utils: add -Wall to most toolsRafał Miłecki2021-04-091-43/+43
| | | | | | This helps spotting possible problems Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* firmware-utils: fix -Wpointer-sign warningsRafał Miłecki2021-04-0918-54/+81
| | | | Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* firmware-utils: fix -Wmaybe-uninitialized warningsRafał Miłecki2021-04-096-4/+18
| | | | Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* firmware-utils: fix few random warningsRafał Miłecki2021-04-097-7/+3
| | | | | | | | | 1. -Wunused-label 2. -Wparentheses 3. -Wmisleading-indentation 4. -Wformat-overflow Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* firmware-utils: fix unused variable warningsRafał Miłecki2021-04-0920-60/+18
| | | | | | | | This fixes warnings from the: 1. -Wunused-variable 2. -Wunused-but-set-variable Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* firmware-utils: fix all -Wformat warningsRafał Miłecki2021-04-092-3/+3
| | | | | | | 1. Use %hhu for uint8_t 2. Use %z for size_t Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* firmware-utils: bcm4908img: convert into a packageRafał Miłecki2021-04-082-998/+0
| | | | | | | | | | bcm4908img is a tool managing BCM4908 platform images. It's used for creating them as well as checking, modifying and extracting data from. It's required by both: host (for building firmware images) and target (for sysupgrade purposes). Make it a host/target package. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* firmware-utils: bcm4908img: fix uninitialized var usageRafał Miłecki2021-04-081-3/+7
| | | | Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* firmware-utils: bcm4908img: extract bootfs without paddingRafał Miłecki2021-04-071-6/+27
| | | | | | | | JFFS2 bootfs partition in a BCM4908 image usually includes some padding. For flashing it individually (writing to designed MTD partition) we want just JFFS2 data. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* firmware-utils: bcm4908img: fix extracting cferomRafał Miłecki2021-04-071-1/+1
| | | | | | Fix offset to extract proper data when image contains vendor header. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* firmware-utils: bcm4908img: support extracting bootfs & rootfsRafał Miłecki2021-04-071-0/+35
| | | | | | | It's required for upgrading firmware using single partitions instead of just blindly writing whole image. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* firmware-utils: bcm4908img: replace size with offsetRafał Miłecki2021-04-071-20/+35
| | | | | | | It's much easier to operate on BCM4908 image data with absolute offset of each section stored. It doesn't require summing sizes over and over. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* firmware-utils: bcm4908img: add bootfs supportRafał Miłecki2021-04-051-3/+337
| | | | | | | | | | | | This adds support for accessing bootfs JFFS2 partition in the BCM4908 image. Support includes: 1. Listing files 2. Renaming file (requires unchanged name length) Above commands are useful for flashing BCM4908 images which by defualt come with cferom.000 file and require renaming it. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* firmware-utils: bcm4908img: support extracting image dataRafał Miłecki2021-04-051-0/+87
| | | | | | It's useful for upgrading cferom, firmware, etc. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* firmware-utils: bcm4908img: find cferom sizeRafał Miłecki2021-04-051-0/+31
| | | | | | | It's important for modifying / extracting firmware content. cferom is optional image content at the file beginning. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* firmware-utils: bcm4908img: use "info" command displaying file infoRafał Miłecki2021-04-051-11/+20
| | | | | | | BCM4908 image format contains some info that may be useful for info / debugging purposes. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* firmware-utils: bcm4908img: support reading from stdinRafał Miłecki2021-04-051-8/+38
| | | | | | | 1. Don't allow pipe stdin as we need to fseek() 2. Don't alow TTY as it doesn't make sense for binary input Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* firmware-utils: bcm4908img: detect Netgear vendor firmwareRafał Miłecki2021-04-051-25/+33
| | | | | | | | Netgear uses CHK header which needs to be skipped when validating BCM4908 image. Detect it directly in the bcm4908img tool. Dealing with binary structs and endianess is way simpler in C. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* firmware-utils: bcm4908img: extract parsing codeRafał Miłecki2021-04-051-37/+67
| | | | | | | | Move code parsing existing firmware file to separated function. This cleans up existing code and allows reusing parsing code for other commands. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* firmware-utils: bcm4908kernel: name struct fieldsRafał Miłecki2021-03-241-8/+8
| | | | | | Less magic names / values. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* firmware-utils: bcm4908img: name fields & valuesRafał Miłecki2021-03-241-8/+22
| | | | | | Less magic numbers Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
* tools/sparse: update to version 0.6.3Tony Ambardar2021-03-191-2/+2
| | | | | | | | | | | Update to the latest stable release. This fixes a segfault and build failure seen compiling the 5.10 kernel for x86/64. With this update, builds complete and sparse generates the usual large volume of warnings as on 5.4 kernels. Reported-by: Javier Marcet <javier@marcet.info> Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
* tools: otrx: allow own magicHauke Mehrtens2021-03-151-2/+13
| | | | | | | | | This allows to specify an own magic instead of using the default magic value TRX_MAGIC. If no own magic is specified the default one will be used. Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com> Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
* firmware-utils/ptgen: remove unused variable assignmentDaniel Golle2021-03-141-1/+0
| | | | | | | | | | | | | | | | Discovered by coverty: CID 1473630: Code maintainability issues (UNUSED_VALUE) Assigning value from "type_to_guid_and_name(type, &name)" to "part_guid" here, but that stored value is overwritten before it can be used. Remove the now redundant assignment of part_guid which is also set conditionally later on. Fixes: 4a078bd135 ("firmware-utils/ptgen: fix partition guid and name") Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* tools/libelf: remove unneeded host libraryTony Ambardar2021-03-133-258/+1
| | | | | | | | | | | | | | | | | | | | This old ELF library dating to 2009 used to be necessary on MacOS but is not required for building the kernel or tools since [1]. On Linux systems, libelf is already an OpenWRT build-system prerequisite [2]. Presence of the older library can mask or conflict with the system libelf and lead to build errors, as seen compiling Linux kernels since v5.8 or host tools such as dwarves (e.g. pahole). Remove the unnecessary tools/libelf library and avoid the related issues. [1] 5f8e587240 ("build: force disable stack validation during kernel build on non-linux systems") [2] https://openwrt.org/docs/guide-developer/build-system/install-buildsystem#prerequisites Tested-by: Rosen Penev <rosenp@gmail.com> (Linux) Tested-by: Georgi Valkov <gvalkov@abv.bg> (MacOS) Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
* tools: mkimage: add patches for 64-bit MediaTek BootROMDaniel Golle2021-03-112-0/+360
| | | | | | | Add patches for mkimage to allow using it instead of the binary-only 'bromimage' tool to generate bl2 for MT7622. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* firmware-utils/ptgen: change GPT to LBA addressingOskari Lemmela2021-03-031-13/+20
| | | | | | | | | Do not align partitions with sectors. Only kb align for GPT is supported. Use 254 heads and 63 sectors for PMBR. Signed-off-by: Oskari Lemmela <oskari@lemmela.net>
* firmware-utils/ptgen: add support for hybrid MBROskari Lemmela2021-03-031-11/+28
| | | | | | | | | | | Adding -H option copies partition to MBR after pmbr entry. Max 3 partitions can be copied to MBR. Hybrid MBR is needed only in special cases. For example mt7622 SD card boot needs MBR entry with boot flag enabled. Signed-off-by: Oskari Lemmela <oskari@lemmela.net>
* firmware-utils/ptgen: fix partition guid and nameOskari Lemmela2021-03-031-2/+3
| | | | | | | guid and name function should be called before storing partition info. Signed-off-by: Oskari Lemmela <oskari@lemmela.net>
* firmware-utils/ptgen: fix compile warningsOskari Lemmela2021-03-031-2/+2
| | | | | | remove extra arguments from printf message Signed-off-by: Oskari Lemmela <oskari@lemmela.net>
* tools/xxd: fix source URLDaniel Golle2021-03-011-1/+1
| | | | Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* tools: xxd: use more convenient source tarballDaniel Golle2021-03-011-20/+6
| | | | | | | Don't download all of vim just to build xxd. Use a tight tarball containing only xxd sources instead. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* tools: add xxd (from vim)Daniel Golle2021-02-282-1/+34
| | | | | | | | | | U-Boot requires xxd to create the default environment from an external file as done in uboot-mediatek. Build xxd (only, not the rest of vim) as part of tools to make sure it is present on the buildhost. Reported-by: David Bauer <mail@david-bauer.net> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* firmware-utils/ptgen: set GPT partition attributes and nameDaniel Golle2021-02-281-10/+71
| | | | | | | | | | | Allow setting GPT partition names as used by TF-A bl2 to identify the FIP volume to load from eMMC and SD-card. While at it, also allow setting 'required' attribute as it should be used for volumes which are essential for the system to boot. Also properly handle setting the LEGACY_BOOT flag on the partition selected as 'active', as this is how it is specified in the spec. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
* tools: add cpioDavid Bauer2021-02-283-1/+35
| | | | | | | mediatek-mt7622 as well as mediatek-mt7623 require CPIO to create their initramfs images. So build CPIO as part of the host toolchain. Signed-off-by: David Bauer <mail@david-bauer.net>
* download: add mirror alias for DebianDavid Bauer2021-02-262-2/+2
| | | | | | | Add an alias for Debian packages and download them from the Debian mirror redirector. Signed-off-by: David Bauer <mail@david-bauer.net>
* ramips: mt7621: add TP-Link EAP235-Wall supportSander Vanheule2021-02-191-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The TP-Link EAP235-Wall is a wall-mounted, PoE-powered AC1200 access point with four gigabit ethernet ports. When connecting to the device's serial port, it is strongly advised to use an isolated UART adapter. This prevents linking different power domains created by the PoE power supply, which may damage your devices. The device's U-Boot supports saving modified environments with `saveenv`. However, there is no u-boot-env partition, and saving modifications will cause the partition table to be overwritten. This is not an issue for running OpenWrt, but will prevent the vendor FW from functioning properly. Device specifications: * SoC: MT7621DAT * RAM: 128MiB * Flash: 16MiB SPI-NOR * Wireless 2.4GHz (MT7603EN): b/g/n, 2x2 * Wireless 5GHz (MT7613BEN): a/n/ac, 2x2 * Ethernet: 4× GbE * Back side: ETH0, PoE PD port * Bottom side: ETH1, ETH2, ETH3 * Single white device LED * LED button, reset button (available for failsafe) * PoE pass-through on port ETH3 (enabled with GPIO) Datasheet of the flash chip specifies a maximum frequency of 33MHz, but that didn't work. 20MHz gives no errors with reading (flash dump) or writing (sysupgrade). Device mac addresses: Stock firmware uses the same MAC address for ethernet (on device label) and 2.4GHz wireless. The 5GHz wireless address is incremented by one. This address is stored in the 'info' ('default-mac') partition at an offset of 8 bytes. From OEM ifconfig: eth a4:2b:b0:...:88 ra0 a4:2b:b0:...:88 rai0 a4:2b:b0:...:89 Flashing instructions: * Enable SSH in the web interface, and SSH into the target device * run `cliclientd stopcs`, this should return "success" * upload the factory image via the web interface Debricking: U-boot can be interrupted during boot, serial console is 57600 baud, 8n1 This allows installing a sysupgrade image, or fixing the device in another way. * Access serial header from the side of the board, close to ETH3, pin-out is (1:TX, 2:RX, 3:GND, 4:3.3V), with pin 1 closest to ETH3. * Interrupt bootloader by holding '4' during boot, which drops the bootloader into its shell * Change default 'serverip' and 'ipaddr' variables (optional) * Download initramfs with `tftpboot`, and boot image with `bootm` # tftpboot 84000000 openwrt-initramfs.bin # bootm Revert to stock: Using the tplink-safeloader utility from the firmware-utils package, TP-Link's firmware image can be converted to an OpenWrt-compatible sysupgrade image: $ ./staging_dir/host/bin/tplink-safeloader -B EAP235-WALL-V1 \ -z EAP235-WALLv1_XXX_up_signed.bin -o eap235-sysupgrade.bin This can then be flashed using the OpenWrt sysupgrade interface. The image will appear to be incompatible and must be force flashed, without keeping the current configuration. Known issues: - DFS support is incomplete (known issue with MT7613) - MT7613 radio may stop responding when idling, reboot required. This was an issue with the ddc75ff704 version of mt76, but appears to have improved/disappeared with bc3963764d. Error notice example: [ 7099.554067] mt7615e 0000:02:00.0: Message 73 (seq 1) timeout Hardware was kindly provided for porting by Stijn Segers. Tested-by: Stijn Segers <foss@volatilesystems.org> Signed-off-by: Sander Vanheule <sander@svanheule.net>
* tools/fakeroot: fix build regression on macOSFelix Fietkau2021-02-151-0/+42
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* fakeroot: fix to work with glibc 2.33Ilya Lipnitskiy2021-02-151-0/+145
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following commit removed _STAT_VER definitions from glibc: https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=8ed005daf0ab03e142500324a34087ce179ae78e That subsequently broke fakeroot: https://bugs.archlinux.org/task/69572 https://bugzilla.redhat.com/show_bug.cgi?id=1889862#c13 https://forum.openwrt.org/t/unable-to-build-toolchain-fakeroot-fails-perhaps-others-after-it/87966 Make the patch based on Jan Pazdziora's suggestion from here: https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/SMQ3RYXEYTVZH6PLQMKNB3NM4XLPMNZO/ Add wrappers for newly exported symbols in glibc. Apply patch from Debian to fix warnings in fts_read and fts_children: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=676428 https://sources.debian.org/patches/fakeroot/1.25.3-1.1/eglibc-fts-without-LFS/ Fix __xmknod{,at} dev pointer argument. Switch default to assume * and not the absence of *. On glibc 2.33+, there is no definition for these functions in header files, so the compile test doesn't work. But, we can default to using the pointer (as is the case with newer glibc), and use the header file on older platforms to fail the test and use no pointer. Tested on my x86_64 Arch Linux machine, fakeroot unit tests pass. Also tested by building various .ipks and examining the tar contents, to ensure that the owner uid/gid was 0/0. Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
* tools/patchelf: bump to use latest masterIlya Lipnitskiy2021-02-151-4/+5
| | | | | | | | | | | | | | | | | | | Recent ABI_VERSION commits make use of patchelf. It was discovered that with patchelf 0.10(and even 0.12) various big endian targets fail to link against libubox SO that was processed through patchelf. Using latest master patchelf fixes those link errors. Potential commits affecting big-endian processing https://github.com/NixOS/patchelf/commit/884eccc4f061a3dbdbe63a4c73f1cc9bbf77fa7d https://github.com/NixOS/patchelf/commit/d148bae6c1291b93d660a156a1756670069cd8cc Recent builds with failures: http://buildbot.openwrt.org/master/images/builders/lantiq%2Fxrx200/builds/682 http://buildbot.openwrt.org/master/images/builders/ath79%2Fmikrotik/builds/449 Cc: Hauke Mehrtens <hauke@hauke-m.de> Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
* tools: mkimage: Update U-Boot to version 2021.01Hauke Mehrtens2021-02-086-60/+13
| | | | | | | | | | | | * The fit image is now created with 0666 permission in upstream U-Boot remove our patch switch creates it with 0744 * The generated/autoconf.h file is created now as an empty file, it is not needed to remove this include any more. * Upstream lib/rsa/rsa-sign.c now includes stdlib.h instead of malloc.h * ALIGN_MASK was moved to imagetool.h, own patch should not be needed any more. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
* treewide: unify OpenWrt hosted source via @OPENWRTPaul Spooren2021-02-052-2/+2
| | | | | | | | | | | Multiple sources are hosted on OpenWrts source server only. The source URLs to point to the server vary based on different epochs in OpenWrts history. Replace all by @OPENWRT which is an "empty" mirror, therefore using the fallback servers sources.cdn.openwrt.org and sources.openwrt.org. Signed-off-by: Paul Spooren <mail@aparcar.org>
* tplink-safeloader: add support for TP-Link Archer A7 v5 (RU)Alexey Kunitskiy2021-02-051-1/+2
| | | | | | | | | | | | | | | | | | | Although provided in separate zip archives, the firmwares for EU and RU version are byte-identical. This adds the missing ID compared to the support-list in the vendor firmware. Note (since I checked it anyway): Partitions and support list are unchanged for all three existing firmware versions: * 20200721-rel40773 * 20201029-rel43238 * 20201120-rel50399 Signed-off-by: Alexey Kunitskiy <alexey.kv@gmail.com> [rewrite commit message] Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
* tools/zstd: compile with cmakeRosen Penev2021-01-302-3/+9
| | | | | | | | It's faster and more reliable. Removed ccache cmake build dependency as it's now implicit. Signed-off-by: Rosen Penev <rosenp@gmail.com>
* tools/zstd: update to 1.4.8Rosen Penev2021-01-302-65/+3
| | | | | | | Switch to the normal tarball instead of the codeload generated one. The latter has the potential to change hashes based on changes in the repo. Signed-off-by: Rosen Penev <rosenp@gmail.com>
* firmware-utils: bcm4908asus: tool inserting Asus tail into BCM4908 imageRafał Miłecki2021-01-222-0/+445
| | | | | | | | | | | Asus looks for an extra data at the end of BCM4908 image, right before the BCM4908 tail. It needs to be properly filled to make Asus accept firmware image. This tool constructs such a tail, writes it and updates CRC32 in BCM4908 tail accordingly. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>