mirror of https://github.com/hak5/openwrt.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 <tharvey@gateworks.com>
parent
f8c7e935ef
commit
a4b86b292a
|
@ -8,12 +8,13 @@
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=kobs-ng
|
PKG_NAME:=kobs-ng
|
||||||
PKG_VERSION:=3.0.35-4.0.0
|
PKG_VERSION:=5.4
|
||||||
PKG_RELEASE:=2
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
PKG_SOURCE:=imx-kobs-$(PKG_VERSION).tar.gz
|
||||||
PKG_SOURCE_URL:=http://repository.timesys.com/buildsources/k/kobs-ng/kobs-ng-$(PKG_VERSION)/
|
PKG_SOURCE_URL:=http://www.freescale.com/lgfiles/NMG/MAD/YOCTO/
|
||||||
PKG_MD5SUM:=26104c577f59a6b81782a5bd16aadd82
|
PKG_MD5SUM:=77467d834f858c2ec216841583e5f437
|
||||||
|
PKG_BUILD_DIR:=$(BUILD_DIR)/imx-kobs-$(PKG_VERSION)
|
||||||
|
|
||||||
PKG_LICENSE:=GPLv2
|
PKG_LICENSE:=GPLv2
|
||||||
PKG_LICENSE_FILES:=COPYING
|
PKG_LICENSE_FILES:=COPYING
|
||||||
|
|
|
@ -10,8 +10,11 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
--- a/src/mtd.h
|
--- a/src/mtd.h
|
||||||
+++ b/src/mtd.h
|
+++ b/src/mtd.h
|
||||||
@@ -27,6 +27,7 @@
|
@@ -25,8 +25,10 @@
|
||||||
|
#ifndef MTD_H
|
||||||
|
#define MTD_H
|
||||||
|
|
||||||
|
+#define _GNU_SOURCE
|
||||||
#include <mtd/mtd-user.h>
|
#include <mtd/mtd-user.h>
|
||||||
#include <endian.h>
|
#include <endian.h>
|
||||||
+#include <fcntl.h>
|
+#include <fcntl.h>
|
|
@ -1,76 +0,0 @@
|
||||||
From: Paul B. Henson <henson@acm.org>
|
|
||||||
|
|
||||||
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 <henson@acm.org>
|
|
||||||
---
|
|
||||||
|
|
||||||
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?
|
|
|
@ -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
|
--- a/src/main.c
|
||||||
+++ b/src/main.c
|
+++ b/src/main.c
|
||||||
@@ -94,6 +94,7 @@ void usage(void)
|
@@ -94,6 +94,7 @@ void usage(void)
|
||||||
|
@ -10,7 +13,7 @@
|
||||||
" --data_hold_time=<value> ............. NCB field (default 60)\n"
|
" --data_hold_time=<value> ............. NCB field (default 60)\n"
|
||||||
--- a/src/mtd.c
|
--- a/src/mtd.c
|
||||||
+++ b/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;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,9 +23,9 @@
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
/* verify it's a nand */
|
/* verify it's a nand */
|
||||||
if (miu->type != MTD_NANDFLASH) {
|
if (miu->type != MTD_NANDFLASH
|
||||||
fprintf(stderr, "mtd: device %s not NAND\n", mp->name);
|
&& miu->type != MTD_MLCNANDFLASH) {
|
||||||
@@ -2914,7 +2919,7 @@ static const struct {
|
@@ -3385,7 +3390,7 @@ static const struct {
|
||||||
} mtd_int_args[] = {
|
} mtd_int_args[] = {
|
||||||
ARG_IGNORE(chip_count),
|
ARG_IGNORE(chip_count),
|
||||||
ARG_IGNORE(chip_0_offset),
|
ARG_IGNORE(chip_0_offset),
|
||||||
|
@ -31,7 +34,7 @@
|
||||||
ARG_IGNORE(chip_1_offset),
|
ARG_IGNORE(chip_1_offset),
|
||||||
ARG_IGNORE(chip_1_size),
|
ARG_IGNORE(chip_1_size),
|
||||||
ARG(search_exponent),
|
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);
|
// Pd(chip_count);
|
||||||
Ps(chip_0_device_path);
|
Ps(chip_0_device_path);
|
||||||
// Pd(chip_0_offset);
|
// Pd(chip_0_offset);
|
||||||
|
|
|
@ -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 <errno.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
+#include <sys/utsname.h>
|
||||||
|
|
||||||
|
#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) {
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
|
@ -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 <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
Loading…
Reference in New Issue