openwrt/target/linux
Michał Kępień a60721f2ed mikrotik: switch to Yafut for building MikroTik NOR images
The Yafut tool now has limited capabilities for working on filesystem
images stored in regular files.  This enables preparing Yaffs2 images
for devices with NOR flash using upstream Yaffs2 filesystem code instead
of the custom kernel2minor tool.

Since minimizing the size of the resulting filesystem image size is
important and upstream Yaffs2 code requires two allocator reserve blocks
to be available when writing a file to the filesystem, a trick is
employed while preparing an OpenWRT image: the blank filesystem image
that Yafut operates on initially contains two extra erase blocks that
are chopped off after the kernel file is written.  This is safe to do
because Yaffs2 has a true log structure and therefore only ever writes
sequentially (and the size of the kernel file is known beforehand).
While the two extra erase blocks are necessary for writes, Yaffs2 code
seems to be perfectly capable of reading back files from a "truncated"
filesystem that does not contain these extra erase blocks.

In terms of image size, this new approach is only marginally worse than
the current kernel2minor-based one: specifically, upstream Yaffs2 code
needs to write three object headers (each of which takes up an entire
data chunk) when the kernel file is written to the filesystem:

  - an object header for the kernel file when it is created,

  - an object header for the root directory when the kernel file is
    created,

  - an updated object header for the kernel file when the latter is
    fully written (so that its new size can be recorded).

kernel2minor only writes two of these headers, which is the absolute
minimum required for reading the file back.  This means that the
Yafut-based approach causes firmware images to be at most one erase
block (64 kB) larger than those created using kernel2minor, but only in
the very unfortunate scenario where the size of the kernel file is
really close to a multiple of the erase block size.

The rest of the calculations performed when the empty filesystem image
is first prepared stems from the Yaffs2 layout used by MikroTik NOR
devices: each 65,536-byte erase block contains 63 chunks, each of which
consists of 1024 bytes of data followed by 16-byte Yaffs tags without
ECC data; each such group of 63 chunks is then followed by 16 bytes of
padding, which translates to "-C 1040 -B 64k -E" in the Yafut
invocation.  Yaffs2 checkpoints and summaries are disabled (using
Yafut's -P and -S switches, respectively) as they are merely performance
optimizations that require extra storage space.  The -L and -M switches
are used to force little-endian or big-endian byte order (respectively)
in the resulting filesystem image, no matter what byte order the build
host uses.  The tr invocation is used to ensure that the filesystem
image is initialized with 0xFF bytes (which are an indicator of unused
space for Yaffs2 code).

Signed-off-by: Michał Kępień <openwrt@kempniu.pl>
Link: https://github.com/openwrt/openwrt/pull/13453
Signed-off-by: Robert Marko <robimarko@gmail.com>
2024-06-05 17:03:24 +02:00
..
airoha airoha: drop kernel 6.1 support 2024-06-05 09:34:06 +02:00
apm821xx apm821xx: restore 6.1 config+patches 2024-04-05 09:26:26 +02:00
archs38 archs38: remove 5.15 support 2024-03-29 09:58:45 +01:00
armsr armsr: Remove kernel 6.1 configuration 2024-05-30 22:44:57 +02:00
at91 at91: 5.15: remove old config and patch files 2024-04-28 17:50:37 +02:00
ath79 mikrotik: switch to Yafut for building MikroTik NOR images 2024-06-05 17:03:24 +02:00
bcm27xx kernel: Split kmod-video-dma into two kmods 2024-06-02 17:38:23 +02:00
bcm47xx bcm47xx: 6.6: refresh patches 2024-06-03 17:57:54 +02:00
bcm53xx kernel: bump 6.1 to 6.1.89 2024-04-30 20:18:15 +02:00
bcm4908 bcm4908: set kernel 6.6 as a testing version 2024-04-27 12:14:00 +02:00
bmips bmips: Build U-Boot into the XG6846 target 2024-05-01 21:32:23 +02:00
d1 d1: drop 6.1 support 2024-05-29 17:56:28 +02:00
gemini gemini: In-flight ethernet patches 2024-05-19 22:06:11 +02:00
generic generic: 6.6: net: sfp-bus: fix SFP mode detect from bitrate 2024-05-30 12:06:26 +01:00
imx imx: kernel: add imx8mp PCI support 2024-03-24 21:19:10 +01:00
ipq40xx mikrotik: switch to Yafut for building MikroTik NOR images 2024-06-05 17:03:24 +02:00
ipq806x ipq806x: mr42/mr52: fix PCIe ports 2024-05-16 19:28:16 +02:00
ixp4xx ixp4xx: Add back support for D-Link DSM G600 A 2024-05-25 09:17:19 +02:00
kirkwood kirkwood: add D-Link DNS-320L support 2024-06-01 01:29:09 +02:00
lantiq lantiq: disable building of ZyXEL P-2812HNU F1 2024-05-28 08:06:10 +02:00
layerscape layerscape: add 6.6 testing kernel 2024-05-25 20:18:23 +02:00
loongarch64 loongarch64: new target 2024-05-04 14:14:16 +08:00
malta malta: Remove kernel 6.1 configuration 2024-05-28 22:10:53 +02:00
mediatek mediatek: filogic: avoid sub-shell invovation in netdev rename loop 2024-05-31 13:26:54 +01:00
mpc85xx mpc85xx: refresh patches 2024-06-02 22:43:46 +02:00
mvebu mvebu: disable polling delay for passive trip point for puzzle thermal 2024-06-01 16:40:10 +01:00
mxs mxs: drop 6.1 support 2024-04-25 14:33:22 +02:00
octeon octeon: convert to new LED color/function format where possible 2024-02-07 14:48:41 +01:00
octeontx kernel: bump 5.15 to 5.15.155 2024-04-16 23:11:25 +02:00
omap omap: drop kernel 5.15 2024-02-13 19:05:48 +01:00
pistachio pistachio: 6.1: refresh kernel patches 2024-04-22 11:27:05 +02:00
qoriq qoriq: add kernel 6.1 support 2024-04-18 00:30:03 +03:00
qualcommax qualcommax: use ath11k_patch_mac for ZBT-Z800AX 2024-06-03 13:15:48 +02:00
ramips mikrotik: switch to Yafut for building MikroTik NOR images 2024-06-05 17:03:24 +02:00
realtek realtek: Trap LLDP packets to the CPU 2024-05-10 16:03:51 +02:00
rockchip rockchip: switch to kernel 6.6 2024-05-09 10:43:37 +02:00
sifiveu sifiveu: drop 6.1 support 2024-04-30 11:02:48 +02:00
starfive generic: 6.1: backport AXP PMIC support 2024-03-26 21:56:57 +01:00
sunxi sunxi: add support for Lichee Pi Zero Dock (V3s) board 2024-05-04 00:41:02 +02:00
tegra tegra: Activate CONFIG_SND_DRIVERS 2024-06-02 17:56:28 +02:00
uml uml: restore 6.1 config + patches 2024-03-23 21:38:00 +01:00
x86 x86: Activate CONFIG_FB_DEVICE 2024-05-31 11:25:48 +02:00
zynq zynq: 5.15: remove files 2024-05-01 10:26:41 +02:00
Makefile linux: add dtb makefile target to targets list 2024-02-08 23:04:55 +01:00