summaryrefslogtreecommitdiffstats
path: root/recipes-bsp
diff options
context:
space:
mode:
authorFabio Berton <fabio.berton@ossystems.com.br>2016-07-19 09:18:19 -0300
committerOtavio Salvador <otavio@ossystems.com.br>2016-07-22 10:50:40 -0300
commitf5708ec4e8a87d9733613ba773078ffe7de89d09 (patch)
tree672c15c2fc29d9f821503aa6f8a2f880bd984c68 /recipes-bsp
parent32e1e617273611f16f69b91122ccf55b92f07cb4 (diff)
downloadmeta-fsl-arm-f5708ec4e8a87d9733613ba773078ffe7de89d09.tar.gz
imx-kobs: Allow kobs-ng to flash the SPL on the 4.x kernel
Add function to check if kernel support raw_mode and fix function that calculates the geometry based on known info from the mtd partitionmtd geometry. These patches were copied from: https://github.com/Gateworks/openwrt/commit/379e87df4fb67198fe900ffe2a394e69fbd47801 Signed-off-by: Fabio Berton <fabio.berton@ossystems.com.br> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Diffstat (limited to 'recipes-bsp')
-rw-r--r--recipes-bsp/imx-kobs/imx-kobs/fix-cal_nfc_geometry.patch31
-rw-r--r--recipes-bsp/imx-kobs/imx-kobs/raw-mode.patch48
-rw-r--r--recipes-bsp/imx-kobs/imx-kobs_5.4.bb2
3 files changed, 81 insertions, 0 deletions
diff --git a/recipes-bsp/imx-kobs/imx-kobs/fix-cal_nfc_geometry.patch b/recipes-bsp/imx-kobs/imx-kobs/fix-cal_nfc_geometry.patch
new file mode 100644
index 0000000..dddb49a
--- /dev/null
+++ b/recipes-bsp/imx-kobs/imx-kobs/fix-cal_nfc_geometry.patch
@@ -0,0 +1,31 @@
1The Freescale downstream vendor kernel has a patch that exports the bch
2flash geometry via a debugfs file. This is not available in mainline linux
3kernels so the fallback method calculates the geometry based on known info
4from the mtd partition. A bug exists in this funcion where it fails to
5assume that block0 ECC is the same as the other blocks by default.
6
7Upstream-Status: Pending
8
9--- a/src/mtd.c
10+++ b/src/mtd.c
11@@ -610,7 +610,7 @@ static int cal_nfc_geometry(struct mtd_d
12 /* The two are fixed, please change them when the driver changes. */
13 geo->metadata_size_in_bytes = 10;
14 geo->gf_len = 13;
15- geo->ecc_chunkn_size_in_bytes = 512;
16+ geo->ecc_chunkn_size_in_bytes = geo->ecc_chunk0_size_in_bytes = 512;
17
18 if (mtd->oobsize > geo->ecc_chunkn_size_in_bytes) {
19 geo->gf_len = 14;
20@@ -700,8 +700,9 @@ int parse_nfc_geometry(struct mtd_data *
21 unsigned int value;
22
23 if (!plat_config_data->m_u32UseNfcGeo) {
24+ /* fsl kernel patch provides bch_geometry via debugfs */
25 if (!(node = fopen(dbg_geometry_node_path, "r"))) {
26- fprintf(stderr, "Cannot open BCH geometry node: \"%s\"",
27+ fprintf(stderr, "Cannot open BCH geometry node: \"%s\"\n",
28 dbg_geometry_node_path);
29 return cal_nfc_geometry(md);
30 }
31
diff --git a/recipes-bsp/imx-kobs/imx-kobs/raw-mode.patch b/recipes-bsp/imx-kobs/imx-kobs/raw-mode.patch
new file mode 100644
index 0000000..76c2440
--- /dev/null
+++ b/recipes-bsp/imx-kobs/imx-kobs/raw-mode.patch
@@ -0,0 +1,48 @@
1The downstream Freescale vendor kernel has a patch that allows determining
2if raw NAND flash mode is provided via a debugfs file. This is not present
3in upstream kernels, but the raw access support was added in the 3.19
4kernel, so we will check the kernel version if we can't find the file.
5
6Upstream-Status: Pending
7
8--- a/src/mtd.c
9+++ b/src/mtd.c
10@@ -34,6 +34,7 @@
11 #include <errno.h>
12 #include <sys/types.h>
13 #include <sys/ioctl.h>
14+#include <sys/utsname.h>
15
16 #include "mtd.h"
17 #include "rand.h"
18@@ -808,15 +809,27 @@ struct mtd_data *mtd_open(const struct m
19 md->cfg = *cfg;
20
21 /* check if use new raw access mode */
22+ /* by looking for debugfs from fsl patch */
23+ md->raw_mode_flag = 0;
24 fp = fopen("/sys/kernel/debug/gpmi-nand/raw_mode", "r");
25 if (!fp) {
26- md->raw_mode_flag = 0;
27- vp(md, "mtd: use legacy raw access mode\n");
28+ /* fallback to kernel version: raw access added in 3.19 */
29+ struct utsname uts;
30+ if (!uname(&uts)) {
31+ int major = 0, minor = 0;
32+ sscanf(uts.release, "%d.%d", &major, &minor);
33+ vp(md, "mtd: Linux %d.%d\n", major, minor);
34+ if ((major << 8 | minor) > (3 << 8 | 18))
35+ md->raw_mode_flag = 1;
36+ }
37 } else {
38 fclose(fp);
39 md->raw_mode_flag = 1;
40- vp(md, "mtd: use new bch layout raw access mode\n");
41 }
42+ if (md->raw_mode_flag)
43+ vp(md, "mtd: use new bch layout raw access mode\n");
44+ else
45+ vp(md, "mtd: use legacy raw access mode\n");
46
47 if (plat_config_data->m_u32UseMultiBootArea) {
48
diff --git a/recipes-bsp/imx-kobs/imx-kobs_5.4.bb b/recipes-bsp/imx-kobs/imx-kobs_5.4.bb
index 1d33d40..de396a1 100644
--- a/recipes-bsp/imx-kobs/imx-kobs_5.4.bb
+++ b/recipes-bsp/imx-kobs/imx-kobs_5.4.bb
@@ -7,6 +7,8 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=393a5ca445f6965873eca0259a17f833"
7 7
8SRC_URI = "${FSL_MIRROR}/imx-kobs-${PV}.tar.gz \ 8SRC_URI = "${FSL_MIRROR}/imx-kobs-${PV}.tar.gz \
9 file://fix-compile.patch \ 9 file://fix-compile.patch \
10 file://raw-mode.patch \
11 file://fix-cal_nfc_geometry.patch \
10" 12"
11 13
12SRC_URI[md5sum] = "77467d834f858c2ec216841583e5f437" 14SRC_URI[md5sum] = "77467d834f858c2ec216841583e5f437"