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
@ -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?
|
@ -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