Commit Graph

37 Commits (7eeb254cc49c4e9f837c980826ec112b9404f341)

Author SHA1 Message Date
Felix Fietkau 7eeb254cc4 treewide: replace nbd@openwrt.org with nbd@nbd.name
Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 years ago
Rafał Miłecki b9afc86b5c mtd: imagetag: fix compilation with changed mtd_fixtrx call
Function mtd_fixtrx was changed during trx improvements.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
8 years ago
Rafał Miłecki df8ca9a5c4 mtd: add -c option for specifying amount of data to be used for checksum
So far fixtrx was calculating checksum over amount of data matching
partition erase size. It was mostly a workaround of checksum problem
after changing anything in initial TRX content (e.g. formatting JFFS2).
Its main purpose was to make bootloader accept modified TRX. This didn't
provide much protection of flash data against corruption.

This new option lets caller request calculating checksum over a bigger
amount of data. It may be used e.g. to include whole kernel data for
checksum and hopefully make bootloader go info failsafe mode if
something goes wrong.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
8 years ago
Rafał Miłecki 2dd125048d mtd: trx: use separated buffer for TRX header
We plan to adjust usage of the main buffer to allow reading custom
amount of data for CRC32. This means we need another buffer that will be
always block aligned.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
8 years ago
rmilecki 6de401b1f8 mtd: seama: exit with error if Seama header wasn't found
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
8 years ago
rmilecki 06a3241c27 mtd: seama: fix image data handling
1) Put sanity checks in one place
2) Respect provided offset
3) Read only as much data as needed for MD5 calculation

Thanks to the last change this is a great speedup and memory saver. On
devices with NAND flash we were allocating & reading about 128 MiB while
something about 8 MiB is enough.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
8 years ago
rmilecki 30edc32888 mtd: seama: move buf allocation to the MD5 function
This buf is only used in this function now, so lets move it there.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
8 years ago
rmilecki 1d628f0cbe mtd: seama: update MD5 using header in the first block buffer
This will allow separating first block buffer from a buffer used for MD5
calculation.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
8 years ago
rmilecki bcccb03200 mtd: seama: add md5 to header struct
This allows us to drop some extra offset calculations and simplifies
code a bit.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
8 years ago
rmilecki 8632d89fa0 mtd: check for Seama magic early when fixing MD5
This avoid long (and unneeded) process of reading all data in case of
running on MTD not containig Seama entity.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
8 years ago
rmilecki 320641585b mtd: add missing breaks in a switch
On platforms supporting both: TRX and Seama calling "fixtrx" was
resulting in trying to fix Seama as well.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
8 years ago
rmilecki 8a60a41951 mtd: use tabs for indents
This makes code style consistent across the whole file.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
8 years ago
John Crispin 4a4c324cd2 mtd: fix reading of image magic bytes in smaller chunks
The image_check currently fails when it cannot read all magic bytes in a
single chunk. But this can happen when the data are read from a pipe. This
currently breaks the openmesh.sh upgrade script with musl because it uses
dd with a blocksize of 1 to copy the image file to the mtd process.

The read can simply be repeated until enough bytes are read for the magic
byte check. It only stops when either an error was returned or 0 bytes were
read.

Signed-off-by: Sven Eckelmann <sven.eckelmann@open-mesh.com>

SVN-Revision: 48891
8 years ago
Rafał Miłecki 358ae42152 mtd: fix Seama format after replacing EOF with sysupgrade data
Seama header has MD5 similarly to TRX and its CRC32. We need to update
it after replacing anything in Seama entity content to make bootloader
accept it.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>

SVN-Revision: 48688
8 years ago
Rafał Miłecki b5c41ad28c mtd: detect image format when writing
Recently TRX checking code was changed to detect Seama format and don't
abort whole writing operation because of it. This isn't a good long-term
solution. It's a poor idea to teach every format handler recognizing all
possible formats. Instead it should be handled in a generic code which
should run check depending on the detected format.

This will also allow further improvements like fixing formats other than
TRX after replacing JFFS2.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>

SVN-Revision: 48639
8 years ago
Rafał Miłecki b4468a0d61 mtd: allow writing Seama files to "firmware" on Broadcom targets
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>

SVN-Revision: 48534
8 years ago
Rafał Miłecki 60ef46b903 mtd: enable "fixseama" on bcm53xx
There are D-Link bcm53xx devices using Seama format.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>

SVN-Revision: 48521
8 years ago
Luka Perkov ea8ac0999c kirkwood: support Linksys boot counter on EA[34]500
This is done with existing code from the WRT1900AC port.
It makes sure the "auto_recovery" bootloader option is set,
and resets the s_env boot counter after a successful boot.

This gives users without a serial console connection some
measure of safety.

Signed-off-by: Claudio Leite <leitec@staticky.com>

SVN-Revision: 47433
9 years ago
Imre Kaloz 20fac016e4 mvebu: add support for the Linksys boot counter
The u-boot boot counter was never reset after a successful boot,
which sometimes could make some variables become out of sync.
This patch adds support for the boot counter and enables
auto_recovery unconditionally.

Signed-off-by: Jonas Gorski <jogo@openwrt.org>
Signed-off-by: Rob Mosher <nyt-openwrt@countercultured.net>
Signed-off-by: Imre Kaloz <kaloz@openwrt.org>

SVN-Revision: 46690
9 years ago
Felix Fietkau 9e233fb241 mtd: add missing <endian.h> include
trx.c in mtd would not include endian.h, so on systems that do not have
this header implicitly included from the other headers (like musl), both
__BYTE_ORDER and __BIG_ENDIAN would be undefined and thus 0, leading to
it always presuming a big-endian system. this would lead to issues when
running mtd fixtrx on little-endian systems, as it would never recognize
the TRX magic as result of the broken STORE32_LE() macro.

Signed-off-by: Shiz <hi@shiz.me>
Tested-by: Shiz <hi@shiz.me>

SVN-Revision: 45896
9 years ago
John Crispin b48b7a7689 mtd: fix md5sum error checking
In mtd_verify(), the return value of md5sum() has been
interpreted as error if nonzero, while the function
returns number of processed bytes, which caused
mtd_verify() to always fail.

This patch fixes error checking to interpret only
negative values as errors.

Signed-off-by: Zefir Kurtisi <zefir.kurtisi@neratec.com>

SVN-Revision: 44605
9 years ago
Jonas Gorski 92eb27f56d package: mtd: move bcm963xx_tag definition into source code
Remove the need for the header file to be exported - we don't need most
of it anyway; all we care about are the offset of the rootfs length and
header crc fields.

Signed-off-by: Jonas Gorski <jogo@openwrt.org>

SVN-Revision: 44557
9 years ago
John Crispin c3bb3906ee mtd: make the dump commnd honour the -o option
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 43512
10 years ago
John Crispin ff02ea36e0 mtd: make the mtd dump call run properly on nand flash
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 43503
10 years ago
John Crispin da988d582f mtd: add ability to dump a mtd device
this can be used on nand flashes and will skip bad blocks and run ecc on the
read data before dumping it.

Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 43500
10 years ago
John Crispin 9a70c8ef9b mtd: fix 2 compiler warnings
mtd.c:544:7: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 3 has type ‘ssize_t’ [-Wformat]
mtd.c:602:1: warning: label ‘done’ defined but not used [-Wunused-label]

Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 43383
10 years ago
Hauke Mehrtens c977fad4fd bcm53xx: add fixtrx
Without running fixtrx the image will not boot at the second time,
because the CRC the boot loader check is invalid at that time.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>

SVN-Revision: 42639
10 years ago
Felix Fietkau 833c5aab7e mtd: disable trx_check() for ar71xx, fixes a regression introduced in r42403
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 42405
10 years ago
Felix Fietkau 766dff7445 mtd: Fix trx check after partition rename ("linux" to "firmware")
On brcm47xx (Huawei E970), I noticed that sysupgrade now tries to flash trx images which don't fit into the flash, resulting in non-booting system.

I found that mtd does trx size checking only when flashing to a partition called "linux". This patch changes this to be "firmware".

This matches the following patch which changed partition name in bcm47xxpart.c driver to "firmware":

commit 86b4d5ef68ca77ff6724ebb9bddd6b93239c87fc
Author: hauke <hauke@3c298f89-4303-0410-b956-a3cf2f4a3e73>
 Date:   Sun Dec 1 16:32:32 2013 +0000

    brcm47xx: use "firmware" partition name
    ...
    Signed-off-by: Rafał Miłecki <zajec5@gmail.com>

    SVN-Revision: 38973

Signed-off-by: Mathias Adam <m.adam--openwrt@adamis.de>

SVN-Revision: 42403
10 years ago
Felix Fietkau 962575f201 mtd: fix compile error with musl
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 40819
10 years ago
John Crispin 00d7e84af6 mtd: improve mtd detection
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 40301
10 years ago
Felix Fietkau 608f4fe3b0 mtd: add support for bad blocks in NAND flash
NAND flash is very likely to contain bad blocks.

Currently, mtd and therefore sysupgrade fails when it encounters a single bad block, potentially leaving an unbootable system.

This patch allows the mtd utility to skip bad blocks in NAND flash and complete sysupgrade successfully.

Patch by: Matthew Redfearn <matt.redfearn@nxp.com>
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 40021
10 years ago
John Crispin ee41b41a30 mtd: add a "mtd verify" call
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 38871
11 years ago
Felix Fietkau ff17114ba1 ar71xx: Unifi AP Pro sysupgrade patch
The current implementation of mtd will not append the backup
file created by sysupgrade to the correct partition, as mtd will append
the data to first jffs2 partition it finds. As the kernel is also
stored on a jffs2 partition (which resides before the overlay
partition), the data will be appended to this partition.

To fix this problem, a new option

-s <number>             skip the first n bytes when appending data to the jffs2 partiton, defaults to "0"

is added to mtd.

Signed-off-by: Peter Wagner <tripolar@gmx.at>

SVN-Revision: 38807
11 years ago
Gabor Juhos 8b50ecc6ff package/mtd: enable seama fixup code for ar71xx
It will be used for the WD My Net N600.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>

SVN-Revision: 38073
11 years ago
Felix Fietkau b95bdc8ab5 kernel/base-files: clean up old code related to refreshing mtd partitions, it is no longer used anywhere
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 37282
11 years ago
John Crispin 4ebf19b48f packages: clean up the package folder
Signed-off-by: John Crispin <blogic@openwrt.org>

SVN-Revision: 37007
11 years ago