From: Tim Harvey Date: Thu, 1 Sep 2016 14:45:37 +0000 (-0700) Subject: boot: kobs-ng: update kobs-ng for newer kernels X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=a4b86b292a0bce95b9874d6c757a709c5a5269b4;p=openwrt%2Fstaging%2Flynxis.git boot: kobs-ng: update kobs-ng for newer kernels This allows kobs-ng to flash the SPL successfully on the 4.4 kernel used by the Gateworks IMX boards supporting NAND. The previous version of kobs-ng worked with the 3.14 kernel but will brick a board making its SPL unbootable for the 4.4 kernel. See http://trac.gateworks.com/wiki/ventana/bootloader#nandspl for instructions on updating the SPL from Linux. Signed-off-by: Tim Harvey --- diff --git a/package/boot/kobs-ng/Makefile b/package/boot/kobs-ng/Makefile index c43fa19243..a7b675adf8 100644 --- a/package/boot/kobs-ng/Makefile +++ b/package/boot/kobs-ng/Makefile @@ -8,12 +8,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=kobs-ng -PKG_VERSION:=3.0.35-4.0.0 -PKG_RELEASE:=2 +PKG_VERSION:=5.4 +PKG_RELEASE:=1 -PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:=http://repository.timesys.com/buildsources/k/kobs-ng/kobs-ng-$(PKG_VERSION)/ -PKG_MD5SUM:=26104c577f59a6b81782a5bd16aadd82 +PKG_SOURCE:=imx-kobs-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://www.freescale.com/lgfiles/NMG/MAD/YOCTO/ +PKG_MD5SUM:=77467d834f858c2ec216841583e5f437 +PKG_BUILD_DIR:=$(BUILD_DIR)/imx-kobs-$(PKG_VERSION) PKG_LICENSE:=GPLv2 PKG_LICENSE_FILES:=COPYING diff --git a/package/boot/kobs-ng/patches/001-compile.patch b/package/boot/kobs-ng/patches/001-compile.patch new file mode 100644 index 0000000000..67da93a324 --- /dev/null +++ b/package/boot/kobs-ng/patches/001-compile.patch @@ -0,0 +1,23 @@ +--- a/src/mtd.c ++++ b/src/mtd.c +@@ -28,6 +28,7 @@ + #include + #include + #include ++#include + #include + #include + #include +--- a/src/mtd.h ++++ b/src/mtd.h +@@ -25,8 +25,10 @@ + #ifndef MTD_H + #define MTD_H + ++#define _GNU_SOURCE + #include + #include ++#include + + #include "BootControlBlocks.h" + #include "rom_nand_hamming_code_ecc.h" diff --git a/package/boot/kobs-ng/patches/001-fix-mtd-defines.patch b/package/boot/kobs-ng/patches/001-fix-mtd-defines.patch deleted file mode 100644 index 6fdc735e06..0000000000 --- a/package/boot/kobs-ng/patches/001-fix-mtd-defines.patch +++ /dev/null @@ -1,76 +0,0 @@ -From: Paul B. Henson - -Newer kernel headers renamed mtd mode defines and no longer support -MEMSETOOBSEL. Allow code to work with both older and newer kernel -versions. - -Signed-off-by: Paul B. Henson ---- - -http://git.buildroot.net/buildroot/plain/package/kobs-ng/kobs-ng-fix-mtd-defines.patch - ---- a/src/mtd.c -+++ b/src/mtd.c -@@ -852,8 +852,11 @@ void mtd_close(struct mtd_data *md) - mp = &md->part[i]; - - if (mp->fd != -1) { -+/* Newer kernels dropped MEMSETOOBSEL */ -+#ifdef MEMSETOOBSEL - (void)ioctl(mp->fd, MEMSETOOBSEL, - &mp->old_oobinfo); -+#endif - close(mp->fd); - } - -@@ -896,6 +899,8 @@ int mtd_set_ecc_mode(struct mtd_data *md - continue; - } - -+/* Newer kernels dropped MEMSETOOBSEL */ -+#ifdef MEMSETOOBSEL - if (r == -ENOTTY) { - r = ioctl(mp->fd, MEMSETOOBSEL, &mp->old_oobinfo); - if (r != 0) { -@@ -904,6 +909,7 @@ int mtd_set_ecc_mode(struct mtd_data *md - } - mp->oobinfochanged = 0; - } -+#endif - } else { - r = ioctl(mp->fd, MTDFILEMODE, (void *)MTD_MODE_RAW); - if (r != 0 && r != -ENOTTY) { -@@ -911,6 +917,8 @@ int mtd_set_ecc_mode(struct mtd_data *md - continue; - } - -+/* Newer kernels dropped MEMSETOOBSEL */ -+#ifdef MEMSETOOBSEL - if (r == -ENOTTY) { - r = ioctl(mp->fd, MEMSETOOBSEL, &none_oobinfo); - if (r != 0) { -@@ -920,6 +928,7 @@ int mtd_set_ecc_mode(struct mtd_data *md - mp->oobinfochanged = 1; - } else - mp->oobinfochanged = 2; -+#endif - } - - mp->ecc = ecc; ---- a/src/mtd.h -+++ b/src/mtd.h -@@ -31,6 +31,14 @@ - #include "BootControlBlocks.h" - #include "rom_nand_hamming_code_ecc.h" - -+// Newer kernel headers renamed define -+#ifndef MTD_MODE_NORMAL -+#define MTD_MODE_NORMAL MTD_FILE_MODE_NORMAL -+#endif -+#ifndef MTD_MODE_RAW -+#define MTD_MODE_RAW MTD_FILE_MODE_RAW -+#endif -+ - //------------------------------------------------------------------------------ - // Re-definitions of true and false, because the standard ones aren't good - // enough? diff --git a/package/boot/kobs-ng/patches/002-add-init-size-param.patch b/package/boot/kobs-ng/patches/002-add-init-size-param.patch index e0e89b2aec..8ad34e9e71 100644 --- a/package/boot/kobs-ng/patches/002-add-init-size-param.patch +++ b/package/boot/kobs-ng/patches/002-add-init-size-param.patch @@ -1,3 +1,6 @@ +Add --chip_0_size param to override the size of the mtd partition which is +required if the SPL does not occupy the entire partition. For Gateworks +Ventana boards the 'uboot' partition contains both the SPL and uboot. --- a/src/main.c +++ b/src/main.c @@ -94,6 +94,7 @@ void usage(void) @@ -10,7 +13,7 @@ " --data_hold_time= ............. NCB field (default 60)\n" --- a/src/mtd.c +++ b/src/mtd.c -@@ -716,6 +716,11 @@ struct mtd_data *mtd_open(const struct m +@@ -876,6 +876,11 @@ struct mtd_data *mtd_open(const struct m goto out; } @@ -20,9 +23,9 @@ + } + /* verify it's a nand */ - if (miu->type != MTD_NANDFLASH) { - fprintf(stderr, "mtd: device %s not NAND\n", mp->name); -@@ -2914,7 +2919,7 @@ static const struct { + if (miu->type != MTD_NANDFLASH + && miu->type != MTD_MLCNANDFLASH) { +@@ -3385,7 +3390,7 @@ static const struct { } mtd_int_args[] = { ARG_IGNORE(chip_count), ARG_IGNORE(chip_0_offset), @@ -31,7 +34,7 @@ ARG_IGNORE(chip_1_offset), ARG_IGNORE(chip_1_size), ARG(search_exponent), -@@ -3107,7 +3112,7 @@ void mtd_cfg_dump(struct mtd_config *cfg +@@ -3578,7 +3583,7 @@ void mtd_cfg_dump(struct mtd_config *cfg // Pd(chip_count); Ps(chip_0_device_path); // Pd(chip_0_offset); diff --git a/package/boot/kobs-ng/patches/003-missing_include.patch b/package/boot/kobs-ng/patches/003-missing_include.patch deleted file mode 100644 index b91c0509da..0000000000 --- a/package/boot/kobs-ng/patches/003-missing_include.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/src/mtd.c -+++ b/src/mtd.c -@@ -28,6 +28,7 @@ - #include - #include - #include -+#include - #include - #include - #include ---- a/src/mtd.h -+++ b/src/mtd.h -@@ -27,6 +27,7 @@ - - #include - #include -+#include - - #include "BootControlBlocks.h" - #include "rom_nand_hamming_code_ecc.h" diff --git a/package/boot/kobs-ng/patches/003-raw-mode.patch b/package/boot/kobs-ng/patches/003-raw-mode.patch new file mode 100644 index 0000000000..5a3be5f058 --- /dev/null +++ b/package/boot/kobs-ng/patches/003-raw-mode.patch @@ -0,0 +1,45 @@ +The downstream Freescale vendor kernel has a patch that allows determining +if raw NAND flash mode is provided via a debugfs file. This is not present +in upstream kernels, but the raw access support was added in the 3.19 +kernel, so we will check the kernel version if we can't find the file. +--- a/src/mtd.c ++++ b/src/mtd.c +@@ -34,6 +34,7 @@ + #include + #include + #include ++#include + + #include "mtd.h" + #include "rand.h" +@@ -808,15 +809,27 @@ struct mtd_data *mtd_open(const struct m + md->cfg = *cfg; + + /* check if use new raw access mode */ ++ /* by looking for debugfs from fsl patch */ ++ md->raw_mode_flag = 0; + fp = fopen("/sys/kernel/debug/gpmi-nand/raw_mode", "r"); + if (!fp) { +- md->raw_mode_flag = 0; +- vp(md, "mtd: use legacy raw access mode\n"); ++ /* fallback to kernel version: raw access added in 3.19 */ ++ struct utsname uts; ++ if (!uname(&uts)) { ++ int major = 0, minor = 0; ++ sscanf(uts.release, "%d.%d", &major, &minor); ++ vp(md, "mtd: Linux %d.%d\n", major, minor); ++ if ((major << 8 | minor) > (3 << 8 | 18)) ++ md->raw_mode_flag = 1; ++ } + } else { + fclose(fp); + md->raw_mode_flag = 1; +- vp(md, "mtd: use new bch layout raw access mode\n"); + } ++ if (md->raw_mode_flag) ++ vp(md, "mtd: use new bch layout raw access mode\n"); ++ else ++ vp(md, "mtd: use legacy raw access mode\n"); + + if (plat_config_data->m_u32UseMultiBootArea) { + diff --git a/package/boot/kobs-ng/patches/004-fix-cal_nfc_geometry.patch b/package/boot/kobs-ng/patches/004-fix-cal_nfc_geometry.patch new file mode 100644 index 0000000000..ebfd62345c --- /dev/null +++ b/package/boot/kobs-ng/patches/004-fix-cal_nfc_geometry.patch @@ -0,0 +1,27 @@ +The Freescale downstream vendor kernel has a patch that exports the bch +flash geometry via a debugfs file. This is not available in mainline linux +kernels so the fallback method calculates the geometry based on known info +from the mtd partition. A bug exists in this funcion where it fails to +assume that block0 ECC is the same as the other blocks by default. +--- a/src/mtd.c ++++ b/src/mtd.c +@@ -610,7 +610,7 @@ static int cal_nfc_geometry(struct mtd_d + /* The two are fixed, please change them when the driver changes. */ + geo->metadata_size_in_bytes = 10; + geo->gf_len = 13; +- geo->ecc_chunkn_size_in_bytes = 512; ++ geo->ecc_chunkn_size_in_bytes = geo->ecc_chunk0_size_in_bytes = 512; + + if (mtd->oobsize > geo->ecc_chunkn_size_in_bytes) { + geo->gf_len = 14; +@@ -700,8 +700,9 @@ int parse_nfc_geometry(struct mtd_data * + unsigned int value; + + if (!plat_config_data->m_u32UseNfcGeo) { ++ /* fsl kernel patch provides bch_geometry via debugfs */ + if (!(node = fopen(dbg_geometry_node_path, "r"))) { +- fprintf(stderr, "Cannot open BCH geometry node: \"%s\"", ++ fprintf(stderr, "Cannot open BCH geometry node: \"%s\"\n", + dbg_geometry_node_path); + return cal_nfc_geometry(md); + } diff --git a/package/boot/kobs-ng/patches/004-gnu_source.patch b/package/boot/kobs-ng/patches/004-gnu_source.patch deleted file mode 100644 index 3e94c92e1c..0000000000 --- a/package/boot/kobs-ng/patches/004-gnu_source.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/src/plat_boot_config.c -+++ b/src/plat_boot_config.c -@@ -18,6 +18,7 @@ - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -+#define _GNU_SOURCE - #include - #include - #include