diff options
author | Fabio Berton <fabio.berton@ossystems.com.br> | 2016-07-19 09:18:19 -0300 |
---|---|---|
committer | Otavio Salvador <otavio@ossystems.com.br> | 2016-08-05 14:51:53 -0300 |
commit | ca3736511ef17608157169c8f36fd83292ae5c02 (patch) | |
tree | 5568f98206a7165c760fd2cb840fe368f75f34eb /recipes-bsp | |
parent | 23bffd51cc2f5fa31928933ec336f34a0584e54f (diff) | |
download | meta-freescale-ca3736511ef17608157169c8f36fd83292ae5c02.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.patch | 31 | ||||
-rw-r--r-- | recipes-bsp/imx-kobs/imx-kobs/raw-mode.patch | 48 | ||||
-rw-r--r-- | recipes-bsp/imx-kobs/imx-kobs_5.4.bb | 2 |
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 00000000..dddb49a1 --- /dev/null +++ b/recipes-bsp/imx-kobs/imx-kobs/fix-cal_nfc_geometry.patch | |||
@@ -0,0 +1,31 @@ | |||
1 | The Freescale downstream vendor kernel has a patch that exports the bch | ||
2 | flash geometry via a debugfs file. This is not available in mainline linux | ||
3 | kernels so the fallback method calculates the geometry based on known info | ||
4 | from the mtd partition. A bug exists in this funcion where it fails to | ||
5 | assume that block0 ECC is the same as the other blocks by default. | ||
6 | |||
7 | Upstream-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 00000000..76c2440a --- /dev/null +++ b/recipes-bsp/imx-kobs/imx-kobs/raw-mode.patch | |||
@@ -0,0 +1,48 @@ | |||
1 | The downstream Freescale vendor kernel has a patch that allows determining | ||
2 | if raw NAND flash mode is provided via a debugfs file. This is not present | ||
3 | in upstream kernels, but the raw access support was added in the 3.19 | ||
4 | kernel, so we will check the kernel version if we can't find the file. | ||
5 | |||
6 | Upstream-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 1d33d40b..de396a17 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 | ||
8 | SRC_URI = "${FSL_MIRROR}/imx-kobs-${PV}.tar.gz \ | 8 | SRC_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 | ||
12 | SRC_URI[md5sum] = "77467d834f858c2ec216841583e5f437" | 14 | SRC_URI[md5sum] = "77467d834f858c2ec216841583e5f437" |