ccardimx28js removal: delete recipes not used by other platforms

https://jira.digi.com/browse/DEL-4771

Signed-off-by: Javier Viguera <javier.viguera@digi.com>
This commit is contained in:
Javier Viguera 2017-06-29 10:46:47 +02:00
parent d2df029153
commit 6a2699967c
49 changed files with 0 additions and 8470 deletions

View File

@ -1,29 +0,0 @@
From: Javier Viguera <javier.viguera@digi.com>
Date: Fri, 11 Oct 2013 18:56:04 +0200
Subject: [PATCH] makefile.am
Yocto build system does not use the makefile.in directly. Instead it
uses autotools to regenerate it using the source makefile.am.
But the makefile.in distributed in the package has some rules changed
that are not generated from the makefile.am, so adapt the makefile.am to
generate an equivalent makefile.in.
Signed-off-by: Javier Viguera <javier.viguera@digi.com>
---
include/Makefile.am | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/Makefile.am b/include/Makefile.am
index 17d4d2c..dc3a466 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -1,5 +1,8 @@
noinst_HEADERS=version.h
+all-local:
+ echo "const char *git_sha = \""`git rev-parse HEAD`"\";" > ../include/autoversion.h
+
version.h: stamp-vh
@:

View File

@ -1,84 +0,0 @@
From: "Paul B. Henson" <henson@acm.org>
Date: Fri, 11 Oct 2013 17:23:44 +0200
Subject: [PATCH] fix-mtd-defines
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>
Signed-off-by: Javier Viguera <javier.viguera@digi.com>
---
src/mtd.c | 9 +++++++++
src/mtd.h | 8 ++++++++
2 files changed, 17 insertions(+)
diff --git a/src/mtd.c b/src/mtd.c
index 2974814..f9e60a3 100644
--- 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, int ecc)
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, int ecc)
}
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, int ecc)
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, int ecc)
mp->oobinfochanged = 1;
} else
mp->oobinfochanged = 2;
+#endif
}
mp->ecc = ecc;
diff --git a/src/mtd.h b/src/mtd.h
index 99d7887..bf6e53d 100644
--- 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?

View File

@ -1,170 +0,0 @@
From: Hector Palacios <hector.palacios@digi.com>
Date: Fri, 18 Oct 2013 10:10:37 +0200
Subject: cleanup ROM version detection code and add cpx2 support
The original code flow was difficult to understand.
Now there is a main if-elseif to check for 'Hardware' or 'Revision'
strings from cpuinfo.
On the 'Hardware' section we first check if it is a CPX2, or else we
will parse the MX-- number to get the CPU model.
On the 'Revision' section we base on the revision number to get the
CPU model or, if unset (like when Linux is booted directly), we'll
rely on the previous hw_system_rev calculated before.
Signed-off-by: Hector Palacios <hector.palacios@digi.com>
Reviewed-by: Robert Hodaszi <robert.hodaszi@digi.com>
---
src/plat_boot_config.c | 119 ++++++++++++++++++++++++++-----------------------
1 file changed, 63 insertions(+), 56 deletions(-)
diff --git a/src/plat_boot_config.c b/src/plat_boot_config.c
index 76e65c8..e3bf242 100644
--- a/src/plat_boot_config.c
+++ b/src/plat_boot_config.c
@@ -109,10 +109,11 @@ int discover_boot_rom_version(void)
{
FILE *cpuinfo;
char line_buffer[100];
- static char *banner = "Revision";
+ static char *banner_rev = "Revision";
static char *banner_hw = "Hardware";
+ static char *banner_digi_x2 = "Hardware\t: Digi ConnectPort X2";
char *rev;
- int system_rev, hw_system_rev = 0;
+ int system_rev = 0, hw_system_rev = 0;
cpuinfo = fopen("/proc/cpuinfo", "r");
if (!cpuinfo) {
@@ -125,15 +126,20 @@ int discover_boot_rom_version(void)
if (!fgets(line_buffer, sizeof(line_buffer), cpuinfo))
break;
- /* Check if it's revision line */
- if (strncmp(line_buffer, banner, strlen(banner))) {
- /*
- * Why use the `Hardware` to parse the system type ?
- * [1] If boot linux kernel directly from SD card not by uboot,
- * the `Revision` will be zero.
- * [2] The code does not change the old logic.
- */
- if (!strncmp(line_buffer, banner_hw, strlen(banner))) {
+ /* Check if it's hardware line... */
+ /*
+ * Why use the `Hardware` to parse the system type ?
+ * [1] If boot linux kernel directly from SD card not by uboot,
+ * the `Revision` will be zero.
+ * [2] The code does not change the old logic.
+ */
+ if (!strncmp(line_buffer, banner_hw, strlen(banner_hw))) {
+ if (!strncmp(line_buffer, banner_digi_x2,
+ strlen(banner_digi_x2))) {
+ /* The cpx2 is an i.MX28 */
+ hw_system_rev = MX28;
+ }
+ else {
rev = strstr(line_buffer, "MX");
if (rev) {
char tmp[3] = {};
@@ -143,56 +149,57 @@ int discover_boot_rom_version(void)
hw_system_rev = strtoul(tmp, NULL, 16);
}
}
- continue;
}
+ /* ... or Revision line */
+ else if (!strncmp(line_buffer, banner_rev, strlen(banner_rev))) {
+ rev = index(line_buffer, ':');
+ if (rev != NULL) {
+ rev++;
+ system_rev = strtoul(rev, NULL, 16);
+ system_rev = mxc_cpu(system_rev);
+ if (!system_rev)
+ system_rev = hw_system_rev;
+
+ switch (system_rev) {
+ case MX23:
+ plat_config_data = &mx23_boot_config;
+ break;
+
+ case MX28:
+ plat_config_data = &mx28_boot_config;
+ break;
+
+ case MX53:
+ if (mxc_cpu_is_rev(system_rev, CHIP_REV_2_0) < 0)
+ plat_config_data = &mx53to1_boot_config;
+ else
+ plat_config_data = &mx53to2_boot_config;
+ break;
+
+ case MX50:
+ plat_config_data = &mx50_boot_config;
+ break;
+
+ case MX6:
+ case MX6Q:
+ case MX6DL:
+ plat_config_data = &mx6q_boot_config;
+ break;
+
+ default:
+ fprintf(stderr, "Couldn't find Boot ROM version\n");
+ break;
+ }
- rev = index(line_buffer, ':');
- if (rev != NULL) {
- rev++;
- system_rev = strtoul(rev, NULL, 16);
- system_rev = mxc_cpu(system_rev);
- if (!system_rev)
- system_rev = hw_system_rev;
-
- switch (system_rev) {
- case MX23:
- plat_config_data = &mx23_boot_config;
- break;
-
- case MX28:
- plat_config_data = &mx28_boot_config;
- break;
-
- case MX53:
- if (mxc_cpu_is_rev(system_rev, CHIP_REV_2_0) < 0)
- plat_config_data = &mx53to1_boot_config;
- else
- plat_config_data = &mx53to2_boot_config;
- break;
-
- case MX50:
- plat_config_data = &mx50_boot_config;
- break;
-
- case MX6:
- case MX6Q:
- case MX6DL:
- plat_config_data = &mx6q_boot_config;
- break;
-
- default:
- fprintf(stderr, "Couldn't find Boot ROM version\n");
- break;
- }
-
- fclose(cpuinfo);
- if (plat_config_data) {
- plat_config_data->m_u32Arm_type = system_rev;
- return 0;
+ break; /* quit for loop */
}
- return -1;
}
}
+
fclose(cpuinfo);
+ if (plat_config_data) {
+ plat_config_data->m_u32Arm_type = system_rev;
+ return 0;
+ }
return -1;
}

View File

@ -1,128 +0,0 @@
From: Hector Palacios <hector.palacios@digi.com>
Date: Fri, 18 Oct 2013 10:11:29 +0200
Subject: discover boot ROM version from FDT if available
New kernels don't get CPU information from U-Boot ATAGS and
so the /proc/cpuinfo file does not have the Hardware/Revision
lines filled in.
This patch gets the CPU model from the device tree information
at /proc/device-tree/compatible.
For backwards compatibility, if the CPU model cannot be retrieved
from this file, we try to get it from /proc/cpuinfo.
Signed-off-by: Hector Palacios <hector.palacios@digi.com>
Reviewed-by: Robert Hodaszi <robert.hodaszi@digi.com>
---
src/plat_boot_config.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 94 insertions(+), 1 deletion(-)
diff --git a/src/plat_boot_config.c b/src/plat_boot_config.c
index e3bf242..af7e03a 100644
--- a/src/plat_boot_config.c
+++ b/src/plat_boot_config.c
@@ -105,7 +105,91 @@ static platform_config mx6q_boot_config = {
.rom_mtd_commit_structures = v4_rom_mtd_commit_structures,
};
-int discover_boot_rom_version(void)
+#define MAX_STRLEN 256
+int get_rom_version_from_fdt(void)
+{
+ FILE *fd;
+ char line_buffer[MAX_STRLEN];
+ char *p;
+ static char *compatible = "fsl,imx";
+ char *rev;
+ int system_rev;
+
+ fd = fopen("/proc/device-tree/compatible", "r");
+ if (!fd)
+ return -1;
+
+ p = &line_buffer[0];
+ if (fgets(p, MAX_STRLEN, fd)) {
+ /*
+ * The compatible string can contain more than one string.
+ * Each string value is separated from the next one by a
+ * NULL char. We must check all values one by one until
+ * we find two consecutive NULL chars.
+ */
+ while (p[0] != 0) {
+ if (!strncmp(p, compatible, strlen(compatible))) {
+ rev = p + strlen(compatible);
+ /*
+ * check if it's an imx6 CPU series, or
+ * a parsable number.
+ */
+ if (!strncmp(rev, "6q", 2))
+ system_rev = MX6Q;
+ else if (!strncmp(rev, "6d", 2))
+ system_rev = MX6DL;
+ else if (!strncmp(rev, "6s", 2))
+ system_rev = MX6;
+ else
+ system_rev = strtoul(rev, NULL, 16);
+
+ switch (system_rev) {
+ case MX23:
+ plat_config_data = &mx23_boot_config;
+ break;
+
+ case MX28:
+ plat_config_data = &mx28_boot_config;
+ break;
+
+ case MX53:
+ /*
+ * TODO: check CPU revision
+ * Consider it is a TO2 for the
+ * moment
+ */
+ plat_config_data = &mx53to2_boot_config;
+ break;
+
+ case MX50:
+ plat_config_data = &mx50_boot_config;
+ break;
+
+ case MX6:
+ case MX6Q:
+ case MX6DL:
+ plat_config_data = &mx6q_boot_config;
+ break;
+
+ default:
+ break;
+ }
+
+ if (plat_config_data) {
+ plat_config_data->m_u32Arm_type = system_rev;
+ return 0;
+ }
+ }
+ /* Move string pointer to next possible value */
+ p += strlen(p) + 1;
+ }
+ }
+
+ fclose(fd);
+ return -1;
+}
+
+int get_rom_version_from_cpuinfo(void)
{
FILE *cpuinfo;
char line_buffer[100];
@@ -203,3 +287,12 @@ int discover_boot_rom_version(void)
}
return -1;
}
+
+int discover_boot_rom_version(void)
+{
+ /* First, try to get ROM version from FDT */
+ if (get_rom_version_from_fdt())
+ return (get_rom_version_from_cpuinfo());
+
+ return 0;
+}

View File

@ -1,195 +0,0 @@
From: Hector Palacios <hector.palacios@digi.com>
Date: Tue, 15 Oct 2013 18:58:11 +0200
Subject: dump v1 boot structures
The kobs-ng that we received from Freescale did not support reading the
boot structures on the mx28. It could write them, but the function that
reads them was never updated to handle the updated structures used by
the mx28. This change adds basic support for reading these structures,
enough so that the dump command works.
(forward ported from kobs-ng-10.12.01 to kobs-ng-3.0.35_4.1.0)
Signed-off-by: Hector Palacios <hector.palacios@digi.com>
Reviewed-by: Robert Hodaszi <robert.hodaszi@digi.com>
---
src/main.c | 5 ++-
src/mtd.c | 129 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
src/mtd.h | 1 +
3 files changed, 131 insertions(+), 4 deletions(-)
diff --git a/src/main.c b/src/main.c
index 82b6f9e..70517b0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -152,7 +152,10 @@ int dump_main(int argc, char **argv)
if (flags & F_VERBOSE)
mtd_dump(md);
- r = mtd_load_all_boot_structures(md);
+ if (ROM_Version_1 == plat_config_data->m_u32RomVer)
+ r = mtd_load_v1_boot_structures(md);
+ else
+ r = mtd_load_all_boot_structures(md);
if (r != 0) {
fprintf(stderr, "Unable to load boot structures\n");
exit(5);
diff --git a/src/mtd.c b/src/mtd.c
index f9e60a3..9ea92ad 100644
--- a/src/mtd.c
+++ b/src/mtd.c
@@ -975,6 +975,130 @@ void dump(const void *data, int size)
printf("\n");
}
+/*
+ * This function is a hack written by Digi because the original code from
+ * Freescale did not supporting reading the bootlet structures at all.
+ * This function reads the search areas for a given BCB. It will read the first
+ * search area and use it if the read succeeds. If the read fails, then it will
+ * try again with the second search area.
+ *
+ * md A pointer to the current struct mtd_data.
+ * bcb_name A pointer to a human-readable string that indicates what kind of
+ * BCB we're reading. This string will only be used in log messages.
+ * ofs1 If there is one chips, the index of the search area to read
+ * ofs2
+ * ofs_mchip If there are multiple chips, the index of the search area to read
+ * on both chips.
+ * end The number of consecutive search areas to be read.
+ * size The size of the BCB data to be read.
+ * ecc Indicates whether or not to use hardware ECC.
+ */
+int mtd_read_bcb(struct mtd_data *md, char *bcb_name,
+ loff_t ofs1, loff_t ofs2, loff_t ofs_mchip,
+ loff_t end, size_t size, int ecc)
+{
+ int chip;
+ loff_t end_index, search_area_indices[2], o;
+ int r;
+ int i;
+ int j;
+ unsigned stride_size_in_bytes;
+ unsigned search_area_size_in_strides;
+ unsigned search_area_size_in_bytes;
+
+ /* Compute some important facts about geometry */
+ if (plat_config_data->m_u32RomVer == ROM_Version_2) {
+ stride_size_in_bytes = mtd_erasesize(md);
+ search_area_size_in_strides = 4;
+ search_area_size_in_bytes = search_area_size_in_strides * stride_size_in_bytes;
+ } else {
+ stride_size_in_bytes = PAGES_PER_STRIDE * mtd_writesize(md);
+ search_area_size_in_strides = 1 << md->cfg.search_exponent;
+ search_area_size_in_bytes = search_area_size_in_strides * stride_size_in_bytes;
+ }
+
+ /*
+ * Check whether there are multiple chips and set up the two search area
+ * indices accordingly.
+ */
+ if (multichip(md))
+ search_area_indices[0] = search_area_indices[1] = ofs_mchip;
+ else {
+ search_area_indices[0] = ofs1;
+ search_area_indices[1] = ofs2;
+ }
+
+ /* Loop over search areas for this BCB. */
+ for (i = 0; i < 2; i++) {
+ /*
+ * Compute the search area index that marks the end of the
+ * writing on this chip.
+ */
+ end_index = search_area_indices[i] + end;
+
+ /* Figure out which chip we're writing */
+ chip = multichip(md) ? i : 0;
+
+ /* Loop over consecutive search areas to write. */
+ for (; search_area_indices[i] < end_index; search_area_indices[i]++) {
+ /*
+ * Compute the byte offset of the beginning of this
+ * search area
+ */
+ o = search_area_indices[i] * search_area_size_in_bytes;
+
+ /* Loop over strides in this search area. */
+ for (j = 0; j < search_area_size_in_strides; j++, o += stride_size_in_bytes) {
+ /*
+ * If we're crossing into a new block, erase it
+ * first.
+ */
+
+ /* Write the page */
+ vp(md, "mtd: Reading %s%d @%d:0x%llx(%x)\n",
+ bcb_name, j, chip, o, size);
+
+ r = mtd_read_page(md, chip, o, ecc);
+ if (r != size) {
+ fprintf(stderr, "\n%s r = 0x%8.8X, size = 0x%8.8X\n", __func__, r, size);
+ fprintf(stderr, "mtd: Failed to read %s @%d: 0x%llx (%d)\n",
+ bcb_name, chip, o, r);
+ } else
+ break;
+ }
+ }
+ }
+
+ return !(r == size);
+}
+
+/*
+ * This function is a hack by Digi, written because the original code from
+ * Freescale did not support reading the v1 boot structures at all. Do not
+ * use the results from this function for anything other than browsing the
+ * boot structures.
+ */
+int mtd_load_v1_boot_structures(struct mtd_data *md)
+{
+ int err = 0;
+
+ /* read the FCB search area */
+ err = mtd_read_bcb(md, "FCB", 0, 0, 0, 1,
+ mtd_writesize(md) + mtd_oobsize(md), false);
+ memcpy(&md->fcb, md->buf, sizeof(md->fcb));
+
+ /* read the DBBT search area */
+ err |= mtd_read_bcb(md, "DBBT", 1, 1, 1, 1, mtd_writesize(md), true);
+ memcpy(&md->dbbt28, md->buf, sizeof(md->dbbt28));
+
+ if ((err != 0) ||
+ (md->dbbt28.m_u32FingerPrint != DBBT_FINGERPRINT2)) {
+ err = -1;
+ }
+
+ return err;
+}
+
void *mtd_load_boot_structure(struct mtd_data *md, int chip, loff_t *ofsp, loff_t end,
uint32_t magic1, uint32_t magic2, uint32_t magic3, int use_ecc,
int magic_offset)
@@ -1083,9 +1207,8 @@ int mtd_load_all_boot_structures(struct mtd_data *md)
md->curr_ncb = NULL;
md->ncb_version = ncb_get_version(buf, &md->curr_ncb);
- if (md->flags & F_VERBOSE)
- printf("mtd: found NCB%d candidate version %d @%d:0x%llx\n",
- i, md->ncb_version, chip, ofs);
+ vp(md, "mtd: found NCB%d candidate version %d @%d:0x%llx\n",
+ i, md->ncb_version, chip, ofs);
if (md->ncb_version >= 0)
break;
diff --git a/src/mtd.h b/src/mtd.h
index bf6e53d..18e4d70 100644
--- a/src/mtd.h
+++ b/src/mtd.h
@@ -276,6 +276,7 @@ void *mtd_load_boot_structure(struct mtd_data *md, int chip, loff_t *ofsp, loff_
uint32_t magic1, uint32_t magic2, uint32_t magic3, int use_ecc,
int magic_offset);
int mtd_load_all_boot_structures(struct mtd_data *md);
+int mtd_load_v1_boot_structures(struct mtd_data *md);
int mtd_dump_structure(struct mtd_data *md);
int v0_rom_mtd_init(struct mtd_data *md, FILE *fp);

View File

@ -1,454 +0,0 @@
From: Hector Palacios <hector.palacios@digi.com>
Date: Wed, 16 Oct 2013 10:30:14 +0200
Subject: added option to verify data written to flash
This patch adds a -c (check) option to the update command.
This option will read back the data written to the flash and
compare to the original contents in RAM, to verify the write
operation was successful.
Signed-off-by: Hector Palacios <hector.palacios@digi.com>
Reviewed-by: Robert Hodaszi <robert.hodaszi@digi.com>
---
src/main.c | 22 ++++++--
src/mtd.c | 138 +++++++++++++++++++++++++++++++++++++++----------
src/mtd.h | 10 ++--
src/plat_boot_config.h | 2 +-
4 files changed, 136 insertions(+), 36 deletions(-)
diff --git a/src/main.c b/src/main.c
index 70517b0..8774045 100644
--- a/src/main.c
+++ b/src/main.c
@@ -82,10 +82,12 @@ void usage(void)
" -x .................................... Add 1k-padding in the head\n"
" -n .................................... Dry run (don't commit to flash)\n"
" -w .................................... Commit to flash\n"
+ " -c .................................... Check committed data in flash\n"
"\n"
" update [-v] [KEY] [KOBS] [-0|1] <file> .. Update a single bootstream\n"
" -v .................................... Verbose mode\n"
" -0|1 .................................. Update specified bootstream #\n"
+ " -c .................................... Check committed data in flash\n"
"\n"
" extract [-v] [KEY] [KOBS] [-0|1] <file> . Extract a bootstream from flash\n"
" -v .................................... Verbose mode\n"
@@ -390,7 +392,8 @@ int extract_main(int argc, char **argv)
return 0;
}
-static int perform_bootstream_update(struct mtd_data *md, FILE *infp, int image_mask)
+static int perform_bootstream_update(struct mtd_data *md, FILE *infp,
+ int image_mask, int check)
{
int i, r;
unsigned int size, start, avail, end, update;
@@ -435,7 +438,8 @@ static int perform_bootstream_update(struct mtd_data *md, FILE *infp, int image_
update |= UPDATE_BS(i);
}
- r = plat_config_data->rom_mtd_commit_structures(md, infp, UPDATE_LDLB | update);
+ r = plat_config_data->rom_mtd_commit_structures(md, infp,
+ UPDATE_LDLB | update, check);
if (r < 0) {
fprintf(stderr, "FAILED to commit structures\n");
return -1;
@@ -457,6 +461,7 @@ int update_main(int argc, char **argv)
char ascii[20 * 2 + 1];
int device_key;
uint8_t *keyp;
+ int check;
memset(key, 0, sizeof(key));
device_key = 0;
@@ -473,6 +478,7 @@ int update_main(int argc, char **argv)
image_mask = 0; /* no image */
flags = 0;
j = 0;
+ check = 0;
for (i = 1; i < argc; i++) {
if (argv[i][0] != '-') {
@@ -500,6 +506,9 @@ int update_main(int argc, char **argv)
exit(5);
}
break;
+ case 'c':
+ check = 1;
+ break;
case 'v':
flags |= F_VERBOSE;
break;
@@ -545,7 +554,7 @@ int update_main(int argc, char **argv)
if (flags & F_VERBOSE)
mtd_dump(md);
- r = perform_bootstream_update(md, infp, image_mask);
+ r = perform_bootstream_update(md, infp, image_mask, check);
if (r != 0) {
fprintf(stderr, "Unable to perform bootstream update\n");
usage();
@@ -597,6 +606,7 @@ int init_main(int argc, char **argv)
FILE *infp;
loff_t ofs;
int dryrun;
+ int check;
int padding = 0;
struct mtd_config cfg;
uint8_t key[16];
@@ -619,6 +629,7 @@ int init_main(int argc, char **argv)
image = 0; /* first image */
flags = 0;
dryrun = 0;
+ check = 0;
j = 0;
for (i = 1; i < argc; i++) {
@@ -640,6 +651,9 @@ int init_main(int argc, char **argv)
case 'w':
dryrun = 0;
break;
+ case 'c':
+ check = 1;
+ break;
case 'n':
dryrun = 1;
break;
@@ -738,7 +752,7 @@ int init_main(int argc, char **argv)
mtd_dump_structure(md);
if (!dryrun) {
- r = plat_config_data->rom_mtd_commit_structures(md, infp, UPDATE_ALL);
+ r = plat_config_data->rom_mtd_commit_structures(md, infp, UPDATE_ALL, check);
if (r < 0) {
fprintf(stderr, "FAILED to commit structures\n");
exit(5);
diff --git a/src/mtd.c b/src/mtd.c
index 9ea92ad..77ba307 100644
--- a/src/mtd.c
+++ b/src/mtd.c
@@ -2344,7 +2344,7 @@ int v4_rom_mtd_init(struct mtd_data *md, FILE *fp)
int mtd_commit_bcb(struct mtd_data *md, char *bcb_name,
loff_t ofs1, loff_t ofs2, loff_t ofs_mchip,
- loff_t end, size_t size, int ecc)
+ loff_t end, size_t size, int ecc, int verify)
{
int chip;
loff_t end_index, search_area_indices[2], o;
@@ -2355,6 +2355,13 @@ int mtd_commit_bcb(struct mtd_data *md, char *bcb_name,
unsigned search_area_size_in_strides;
unsigned search_area_size_in_bytes;
unsigned count;
+ char *readbuf = NULL;
+
+ if (verify) {
+ readbuf = malloc(mtd_writesize(md));
+ if (NULL == readbuf)
+ return -1;
+ }
vp(md, "-------------- Start to write the [ %s ] -----\n", bcb_name);
//----------------------------------------------------------------------
@@ -2457,6 +2464,20 @@ int mtd_commit_bcb(struct mtd_data *md, char *bcb_name,
err ++;
}
+ if (verify) {
+ //------------------------------------------------------
+ // Verify the written data
+ //------------------------------------------------------
+ r = pread(md->part[chip].fd, readbuf, mtd_writesize(md), o);
+ if (r != mtd_writesize(md)) {
+ fprintf(stderr, "mtd: Failed to read @0x%llx (%d)\n", o, r);
+ goto err_free;
+ }
+ if (memcmp(md->buf, readbuf, mtd_writesize(md))) {
+ fprintf(stderr, "mtd: Verification error @0x%llx\n", o);
+ goto err_free;
+ }
+ }
}
}
@@ -2466,16 +2487,31 @@ int mtd_commit_bcb(struct mtd_data *md, char *bcb_name,
if (md->flags & F_VERBOSE)
printf("%s(%s): status %d\n\n", __func__, bcb_name, err);
- return err;
+err_free:
+ if (verify)
+ free(readbuf);
+ if (err) {
+ fprintf(stderr, "mtd: %d errors\n", err);
+ return -1;
+ }
+ else
+ return 0;
}
-int write_boot_stream(struct mtd_data *md, FILE *fp)
+int write_boot_stream(struct mtd_data *md, FILE *fp, int verify)
{
int startpage, start, size;
loff_t ofs, end;
- int i, r, chunk;
+ int i, r = 0, chunk;
int chip = 0;
struct fcb_block *fcb = &md->fcb.FCB_Block;
+ char *readbuf = NULL;
+
+ if (verify) {
+ readbuf = malloc(mtd_writesize(md));
+ if (NULL == readbuf)
+ return -1;
+ }
vp(md, "---------- Start to write the [ %s ]----\n", (char*)md->private);
for (i = 0; i < 2; i++) {
@@ -2530,7 +2566,7 @@ int write_boot_stream(struct mtd_data *md, FILE *fp)
r = fread(md->buf, 1, chunk, fp);
if (r < 0) {
fprintf(stderr, "mtd: Failed %d (fread %d)\n", r, chunk);
- return -1;
+ goto err_free;
}
if (r < chunk) {
memset(md->buf + r, 0, chunk - r);
@@ -2539,10 +2575,30 @@ int write_boot_stream(struct mtd_data *md, FILE *fp)
/* write page */
r = mtd_write_page(md, chip, ofs, 1);
- if (r != mtd_writesize(md))
+ if (r != mtd_writesize(md)) {
fprintf(stderr, "mtd: Failed to write BS @0x%llx (%d)\n",
ofs, r);
+ r = -1;
+ goto err_free;
+ }
+ if (verify) {
+ //------------------------------------------------------
+ // Verify the written data
+ //------------------------------------------------------
+ r = pread(md->part[chip].fd, readbuf,
+ mtd_writesize(md), ofs);
+ if (r != mtd_writesize(md)) {
+ fprintf(stderr, "mtd: Failed to read BS @0x%llx (%d)\n", ofs, r);
+ r = -1;
+ goto err_free;
+ }
+ if (memcmp(md->buf, readbuf, mtd_writesize(md))) {
+ fprintf(stderr, "mtd: Verification error @0x%llx\n", ofs);
+ r = -1;
+ goto err_free;
+ }
+ }
ofs += mtd_writesize(md);
size -= chunk;
}
@@ -2555,19 +2611,26 @@ int write_boot_stream(struct mtd_data *md, FILE *fp)
*/
memset(md->buf, 0, mtd_writesize(md));
r = mtd_write_page(md, chip, ofs, 1);
- if (r != mtd_writesize(md))
+ if (r != mtd_writesize(md)) {
fprintf(stderr, "Failed to write safe page\n");
+ r = -1;
+ goto err_free;
+ }
vp(md, "mtd: We write one page for save guard. *\n");
-
if (ofs >= end) {
fprintf(stderr, "mtd: Failed to write BS#%d\n", i);
- return -1;
+ r = -1;
+ goto err_free;
}
}
- return 0;
+
+err_free:
+ if (verify)
+ free(readbuf);
+ return r;
}
-int v0_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
+int v0_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags, int verify)
{
int startpage, start, size;
unsigned int search_area_sz, stride;
@@ -2666,7 +2729,9 @@ int v0_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
if (r < 0)
return r;
- mtd_commit_bcb(md, "NCB", 0, 1, 0, 1, size, false);
+ r = mtd_commit_bcb(md, "NCB", 0, 1, 0, 1, size, false, verify);
+ if (r < 0)
+ return r;
}
if (flags & UPDATE_LDLB) {
@@ -2675,7 +2740,10 @@ int v0_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
memset(md->buf, 0, mtd_writesize(md));
memcpy(md->buf, md->curr_ldlb, sizeof(*md->curr_ldlb));
- mtd_commit_bcb(md, "LDLB", 2, 3, 1, 1, mtd_writesize(md), true);
+ r = mtd_commit_bcb(md, "LDLB", 2, 3, 1, 1, mtd_writesize(md), true,
+ verify);
+ if (r < 0)
+ return r;
}
if (flags & UPDATE_DBBT) {
@@ -2684,7 +2752,11 @@ int v0_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
memset(md->buf, 0, mtd_writesize(md));
memcpy(md->buf, md->curr_dbbt, sizeof(*md->curr_dbbt));
- mtd_commit_bcb(md, "DBBT", 4, 5, 2, 1, mtd_writesize(md), true);
+ r = mtd_commit_bcb(md, "DBBT", 4, 5, 2, 1, mtd_writesize(md), true,
+ verify);
+ if (r < 0)
+ return r;
+
for (i = 0; i < 2; i++) {
for (j = 0; j < 2; j++) {
if (md->flags & F_MULTICHIP) {
@@ -2766,7 +2838,7 @@ static void write_dbbt(struct mtd_data *md, int dbbt_num)
}
}
-int v1_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
+int v1_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags, int verify)
{
int size ,r;
@@ -2779,8 +2851,11 @@ int v1_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
size = mtd_writesize(md) + mtd_oobsize(md);
r = fcb_encrypt(&md->fcb, md->buf, size, 1);
if (r < 0)
- return r;
- mtd_commit_bcb(md, "FCB", 0, 0, 0, 1, size, false);
+ return -1;
+
+ r = mtd_commit_bcb(md, "FCB", 0, 0, 0, 1, size, false, verify);
+ if (r < 0)
+ return -1;
//----------------------------------------------------------------------
// Write the DBBT search area.
@@ -2788,14 +2863,17 @@ int v1_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
memset(md->buf, 0, mtd_writesize(md));
memcpy(md->buf, &(md->dbbt28), sizeof(md->dbbt28));
dbbt_checksum(md, &md->dbbt28);
- mtd_commit_bcb(md, "DBBT", 1, 1, 1, 1, mtd_writesize(md), true);
+ r = mtd_commit_bcb(md, "DBBT", 1, 1, 1, 1, mtd_writesize(md), true,
+ verify);
+ if (r < 0)
+ return -1;
write_dbbt(md, 1); /* only write the DBBT for nand0 */
/* write the boot image. */
- return write_boot_stream(md, fp);
+ return write_boot_stream(md, fp, verify);
}
-int v2_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
+int v2_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags, int verify)
{
int startpage, start, size;
unsigned int search_area_size_in_bytes, stride_size_in_bytes;
@@ -2832,7 +2910,9 @@ int v2_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
memset(md->buf, 0, mtd_writesize(md));
memcpy(md->buf, &(md->fcb), sizeof(md->fcb));
- mtd_commit_bcb(md, "FCB", 0, 0, 0, 1, mtd_writesize(md), true);
+ r = mtd_commit_bcb(md, "FCB", 0, 0, 0, 1, mtd_writesize(md), true, verify);
+ if (r < 0)
+ return -1;
//----------------------------------------------------------------------
// Write the DBBT search area.
@@ -2841,7 +2921,9 @@ int v2_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
memset(md->buf, 0, mtd_writesize(md));
memcpy(md->buf, &(md->dbbt28), sizeof(md->dbbt28));
- mtd_commit_bcb(md, "DBBT", 1, 1, 1, 1, mtd_writesize(md), true);
+ r = mtd_commit_bcb(md, "DBBT", 1, 1, 1, 1, mtd_writesize(md), true, verify);
+ if (r < 0)
+ return -1;
//----------------------------------------------------------------------
// Write the DBBT table area.
@@ -2985,7 +3067,7 @@ int v2_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
return 0;
}
-int v4_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
+int v4_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags, int verify)
{
int size, i, r, chip = 0;
loff_t ofs;
@@ -2997,12 +3079,16 @@ int v4_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
r = fcb_encrypt(&md->fcb, md->buf, size, 1);
if (r < 0)
return r;
- mtd_commit_bcb(md, "FCB", 0, 0, 0, 1, size, false);
+ r = mtd_commit_bcb(md, "FCB", 0, 0, 0, 1, size, false, verify);
+ if (r < 0)
+ return r;
/* [2] Write the DBBT search area. */
memset(md->buf, 0, mtd_writesize(md));
memcpy(md->buf, &(md->dbbt50), sizeof(md->dbbt50));
- mtd_commit_bcb(md, "DBBT", 1, 1, 1, 1, mtd_writesize(md), true);
+ r = mtd_commit_bcb(md, "DBBT", 1, 1, 1, 1, mtd_writesize(md), true, verify);
+ if (r < 0)
+ return -1;
/* Write the DBBT table area. */
memset(md->buf, 0, mtd_writesize(md));
@@ -3023,7 +3109,7 @@ int v4_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags)
}
/* [3] Write the two boot streams. */
- return write_boot_stream(md, fp);
+ return write_boot_stream(md, fp, verify);
}
#undef ARG
diff --git a/src/mtd.h b/src/mtd.h
index 18e4d70..699e505 100644
--- a/src/mtd.h
+++ b/src/mtd.h
@@ -295,11 +295,11 @@ int mtd_markbad(struct mtd_data *md, int chip, loff_t ofs);
#define UPDATE_BS(x) (0x08 << ((x) & 1))
#define UPDATE_ALL (UPDATE_NCB | UPDATE_LDLB | UPDATE_DBBT | UPDATE_BS0 | UPDATE_BS1)
-int v0_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags);
-int v1_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags);
-int v2_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags);
-int v3_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags);
-int v4_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags);
+int v0_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags, int verify);
+int v1_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags, int verify);
+int v2_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags, int verify);
+int v3_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags, int verify);
+int v4_rom_mtd_commit_structures(struct mtd_data *md, FILE *fp, int flags, int verify);
int mtd_set_ecc_mode(struct mtd_data *md, int ecc);
diff --git a/src/plat_boot_config.h b/src/plat_boot_config.h
index 8242ede..a3c03a7 100644
--- a/src/plat_boot_config.h
+++ b/src/plat_boot_config.h
@@ -55,7 +55,7 @@ typedef struct _platform_config_t {
uint32_t m_u32Arm_type;
uint32_t m_u32DBBT_FingerPrint;
int (* rom_mtd_init)(struct mtd_data *md, FILE *fp);
- int (* rom_mtd_commit_structures)(struct mtd_data *md, FILE *fp, int flags);
+ int (* rom_mtd_commit_structures)(struct mtd_data *md, FILE *fp, int flags, int verify);
} platform_config;
extern platform_config *plat_config_data;

View File

@ -1,24 +0,0 @@
From: Javier Viguera <javier.viguera@digi.com>
Date: Thu, 14 Nov 2013 16:46:01 +0100
Subject: [PATCH] disable use of nfc_geometry
Not supported in kernel v3.10
Signed-off-by: Javier Viguera <javier.viguera@digi.com>
---
src/plat_boot_config.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/plat_boot_config.c b/src/plat_boot_config.c
index af7e03a47f1b..463045f0bc75 100644
--- a/src/plat_boot_config.c
+++ b/src/plat_boot_config.c
@@ -46,7 +46,7 @@ static platform_config mx28_boot_config = {
.m_u32EnDISBBM = 0,
.m_u32EnSoftEcc = 1,
.m_u32EnBootStreamVerify = 1,
- .m_u32UseNfcGeo = 1,
+ .m_u32UseNfcGeo = 0,
.m_u32UseMultiBootArea = 0,
.m_u32UseSinglePageStride = 1,
.m_u32DBBT_FingerPrint = DBBT_FINGERPRINT2,

View File

@ -1,23 +0,0 @@
From 62d43285dd08709c86b91ba0ae23c974e96c2905 Mon Sep 17 00:00:00 2001
From: Hector Palacios <hector.palacios@digi.com>
Date: Thu, 15 Oct 2015 12:31:24 +0200
Subject: [PATCH] mtd: configure 16-bit ECC for 4K page NAND with 224-byte OOB
Signed-off-by: Hector Palacios <hector.palacios@digi.com>
---
src/mtd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/mtd.c b/src/mtd.c
index 77ba3070de7a..4d04f4c2921d 100644
--- a/src/mtd.c
+++ b/src/mtd.c
@@ -2124,7 +2124,7 @@ int v1_rom_mtd_init(struct mtd_data *md, FILE *fp)
if (mtd_writesize(md) == 2048) {
geo->ecc_strength = ROM_BCH_Ecc_8bit << 1;
} else if (mtd_writesize(md) == 4096) {
- if (mtd_oobsize(md) == 218)
+ if (mtd_oobsize(md) == 218 || mtd_oobsize(md) == 224)
geo->ecc_strength = ROM_BCH_Ecc_16bit << 1;
else if ((mtd_oobsize(md) == 128))
geo->ecc_strength = ROM_BCH_Ecc_8bit << 1;

View File

@ -1,25 +0,0 @@
# Copyright 2013 Digi International. All rights reserved.
SUMMARY = "Freescale's mxs nand update utility"
SECTION = "base"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=393a5ca445f6965873eca0259a17f833"
inherit autotools
SRC_URI = " \
${DIGI_PKG_SRC}/${PN}-${PV}.tar.gz \
file://0001-makefile.am.patch \
file://0002-fix-mtd-defines.patch \
file://0003-cleanup-ROM-version-detection-code-and-add-cpx2-supp.patch \
file://0004-discover-boot-ROM-version-from-FDT-if-available.patch \
file://0005-dump-v1-boot-structures.patch \
file://0006-added-option-to-verify-data-written-to-flash.patch \
file://0007-disable-use-of-nfc_geometry.patch \
file://0008-mtd-configure-16-bit-ECC-for-4K-page-NAND-with-224-b.patch \
"
SRC_URI[md5sum] = "2a0e55b5063605b2664fd67c95a6c686"
SRC_URI[sha256sum] = "92d2f23add8c5d3102c77f241cae26ca55871ccc613a7af833bebbbac7afb8ea"
COMPATIBLE_MACHINE = "mxs"

View File

@ -1,39 +0,0 @@
# Copyright (C) 2013,2017 Digi International.
SUMMARY = "Digi's utilities library"
SECTION = "libs"
LICENSE = "GPL-2.0"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6"
SRC_URI = " \
file://cmdopt.c \
file://cmdopt.h \
file://crc32.c \
file://crc32.h \
file://digi-platforms.h \
file://log.c \
file://log.h \
file://mem.c \
file://mem.h \
file://misc_helper.h \
file://platform.c \
"
S = "${WORKDIR}"
do_compile() {
${CC} -O2 -Wall ${LDFLAGS} -c -o log.o log.c
${CC} -O2 -Wall ${LDFLAGS} -c -o cmdopt.o cmdopt.c
${CC} -O2 -Wall ${LDFLAGS} -c -o mem.o mem.c
${CC} -O2 -Wall ${LDFLAGS} -c -o crc32.o crc32.c
${CC} -O2 -Wall ${LDFLAGS} -c -o platform.o platform.c
${AR} -rcs libdigi.a log.o cmdopt.o mem.o crc32.o platform.o
}
do_install() {
mkdir -p ${D}${includedir}/libdigi ${D}${libdir}
install -m 0644 libdigi.a ${D}${libdir}
install -m 0644 cmdopt.h crc32.h digi-platforms.h log.h mem.h misc_helper.h ${D}${includedir}/libdigi
}
RDEPENDS_${PN}-dev = ""

View File

@ -1,366 +0,0 @@
/***********************************************************************
*
* Copyright 2001,2002 by FS-Forth Systeme GmbH.
* All rights reserved.
*
* $Id: cmdopt.c,v 1.4 2007-01-23 15:13:27 mpietrek Exp $
* @Author: Markus Pietrek
* @Descr: Provides some helper functions to access the command line
* options. The results are stored in global variables.
* This file is not thread safe.
*
********************************************************************** */
/*********************************************************************** *
* @History:
* 2002/10/21 : Purified for splint. Changed to new variable
* naming convention.
*
*********************************************************************** */
#include <assert.h>
#include <ctype.h> // toupper
#include <getopt.h> // getopt
#include <stdio.h>
#include <stdlib.h> // atoi
#include <string.h> // strlen
#include "cmdopt.h"
#include "log.h"
#include "misc_helper.h"
#define BUFFER_SIZE 1024
#define MAX_ENTRIES 32
/*@observer@*/
void (*fnCmdOptExtendedUsage) (char bCmdLine) = NULL;
const char* szCmdOptVersion = "$Revision: 1.4 $"; // if not
// overwritten take
// at least the
// revision of cmdopt
static CmdOptEntry cmdOptEntries[ MAX_ENTRIES ]; // to avoid malloc we
// use a static buffer
/*@noreturn@*/
static void usageAndExit( int argc,
char* argv[],
const CmdOptEntry entries[],
const char* szDescr,
char cWrongNumber );
static void updateVar( const CmdOptEntry entries[],
int nOptIndex,
const char* szStr );
/***********************************************************************
* @Function: cmdOptParse
* @Return: only if command line could be parsed otherwise ends
* the application. Result is only set if COT_MORE is specified
* and points to the first unprocessed entry
* @Descr: reads the command line and sets the variables. Displays a usage
* if values are wrong.
***********************************************************************/
int cmdOptParse( int argc,
char* argv[],
const CmdOptEntry entries[],
const char* szDescr )
{
char szOptLine[ BUFFER_SIZE ];
struct option axLongOptions[ MAX_ENTRIES ];
int nOptIndex = 0;
int nSize = 0;
int nSizeLong = 0;
signed char cOptChar;
int nOptIndexStatic = 0;
int nOptLongIndex = 0;
char cPrintVersion = 0;
char cPrintHelp = 0;
CmdOptEntry coePrintVersion =
{COT_BOOL, -1, &cPrintVersion, "version", "print version and exit" };
CmdOptEntry coePrintHelp =
{COT_BOOL, 'h', &cPrintHelp, "help", "print help" };
CmdOptEntry coeLogLevel =
{COT_INT, 'l', &logLevel, "log-level", "log level for messages" };
CLEAR( axLongOptions );
// add global default command line arguments
cmdOptEntries[ nOptIndexStatic++ ] = coePrintVersion;
cmdOptEntries[ nOptIndexStatic++ ] = coePrintHelp;
cmdOptEntries[ nOptIndexStatic++ ] = coeLogLevel;
// copy default command line entries
// will break when all entries are copied to global area
// or too much arguments
while( 1 )
{
if( nOptIndexStatic == MAX_ENTRIES )
{
logMsg( LOG_ERR, "cmdOptParse: too many command line options" );
exit( EXIT_FAILURE );
}
cmdOptEntries[ nOptIndexStatic ] = entries[ nOptIndex ];
if( entries[ nOptIndex ].type == COT_NONE )
// no more entries
break;
nOptIndexStatic++;
nOptIndex++;
}
// create parameter list for getopt
nOptIndex = 0;
szOptLine[ nOptIndex ] = 0;
while( cmdOptEntries[ nSize ].type != COT_NONE )
{
if( ( cmdOptEntries[ nSize ].type != COT_MORE ) &&
( cmdOptEntries[ nSize ].type != COT_MORE_OPT ) ) {
axLongOptions[ nSizeLong ].name = cmdOptEntries[ nSize ].szLabelStr;
axLongOptions[ nSizeLong ].has_arg =
((cmdOptEntries[ nSize ].type != COT_BOOL ) ? required_argument : no_argument);
axLongOptions[ nSizeLong ].flag = NULL;
axLongOptions[ nSizeLong ].val = -2 - nSize;
nSizeLong++;
}
if( NULL != cmdOptEntries[ nSize ].pbPresent )
*cmdOptEntries[ nSize ].pbPresent = 0;
if( !cmdOptEntries[ nSize ].cOptChar )
{
// parameter is not mandatory
nSize++;
continue;
}
if( nOptIndex >= BUFFER_SIZE - 2 )
{
logMsg( LOG_ERR,
"cmdOptParse: too long command line" );
exit( EXIT_FAILURE );
}
if( -1 != cmdOptEntries[ nSize ].cOptChar ) {
szOptLine[ nOptIndex++ ] = cmdOptEntries[ nSize ].cOptChar;
if( cmdOptEntries[ nSize ].type != COT_BOOL )
szOptLine[ nOptIndex++ ] = ':';
}
szOptLine[ nOptIndex ] = 0;
nSize++;
}
// parse optional command line options
while( ( cOptChar = getopt_long( argc, argv, szOptLine, axLongOptions, &nOptLongIndex ) ) != -1 )
{
char cFound = 0;
if( cOptChar < 0 ) {
cFound = 1;
updateVar( cmdOptEntries, -2 - cOptChar, optarg );
} else {
for( nOptIndex = 0; nOptIndex < nSize; nOptIndex++ )
{
if( cmdOptEntries[ nOptIndex ].cOptChar == cOptChar )
{
// optional arguments only
cFound = 1;
updateVar( cmdOptEntries, nOptIndex, optarg );
}
}
}
if( !cFound )
usageAndExit( argc, argv, cmdOptEntries, szDescr, 0 );
}
if( cPrintVersion )
{
fprintf( stdout, "%s %s\n",
argv[ 0 ],
szCmdOptVersion );
exit( EXIT_SUCCESS );
}
if( cPrintHelp )
usageAndExit( argc, argv, cmdOptEntries, szDescr, 0 );
// parse mandatory command line options
nOptIndex = 0;
for( nOptIndex = 0; nOptIndex < nSize; nOptIndex++ )
if( !cmdOptEntries[ nOptIndex ].cOptChar )
{
if( cmdOptEntries[ nOptIndex ].type == COT_MORE_OPT )
// don't parse the following arguments as they
// can't be covered by this lib yet
return optind;
if( !( argc - optind ) )
usageAndExit( argc, argv, cmdOptEntries, szDescr, 1 );
if( cmdOptEntries[ nOptIndex ].type == COT_MORE )
// don't parse the following arguments as they
// can't be covered by this lib yet
return optind;
updateVar( cmdOptEntries, nOptIndex, argv[ optind++ ] );
}
if( argc - optind )
// COT_MORE is aborted before
usageAndExit( argc, argv, cmdOptEntries, szDescr, 1 );
return 0;
}
void cmdOptUsageAndExit(
int argc,
char* argv[],
const CmdOptEntry entries[],
const char* szDescr )
{
usageAndExit( argc, argv, entries, szDescr, 0 );
}
/***********************************************************************
* @Function: usageAndExit
* @Return: never
* @Descr: displays usage and exits with EXIT_FAILURE. If wrongNumber is 1,
* a message "too many arguments is displayed".
***********************************************************************/
static void usageAndExit( /*@unused@*/ int argc,
char* argv[],
const CmdOptEntry entries[],
const char* szDescr,
char cWrongNumber )
{
int nOptIndex = 0;
size_t maxStrLen = 0;
fprintf( stdout, "Usage: %s ", argv[ 0 ] );
// print command line arguments
while( entries[ nOptIndex ].type != COT_NONE )
{
if( entries[ nOptIndex ].szLabelStr != NULL )
{
// determine max len of labelStr for formatted output
size_t strLen = strlen( entries[ nOptIndex ].szLabelStr );
if( strLen > maxStrLen )
maxStrLen = strLen;
}
switch( entries[ nOptIndex ].type )
{
case COT_BOOL:
case COT_INT:
case COT_STRING:
fprintf( stdout, "[--%s] ", entries[ nOptIndex ].szLabelStr );
break;
case COT_MORE:
case COT_MORE_OPT:
fprintf( stdout,
"%s ",
entries[ nOptIndex ].szLabelStr );
break;
case COT_NONE:
// will never happen but satisfies compiler
break;
}
nOptIndex++;
}
if( NULL != fnCmdOptExtendedUsage )
fnCmdOptExtendedUsage( 1 );
fprintf( stdout, "\n" );
// explain command line options
nOptIndex = 0;
while( entries[ nOptIndex ].type != COT_NONE )
{
fprintf( stdout, " " );
fprintf( stdout, " %-*s",
(int) maxStrLen,
entries[ nOptIndex ].szLabelStr );
if( entries[ nOptIndex ].cOptChar > 0)
fprintf( stdout, " [-%c]", entries[ nOptIndex ].cOptChar );
else
fprintf( stdout, " " );
/*@+matchanyintegral*/ // maxStrLen is size_t. We shall
// unrestrict for this case the
// behaviour of splint because the
// compiler should do some
// checking, too
/*@-matchanyintegral*/
if( entries[ nOptIndex ].szHelpStr != NULL )
fprintf( stdout, " : %s", entries[ nOptIndex ].szHelpStr );
fprintf( stdout, "\n" );
nOptIndex++;
}
if( NULL != fnCmdOptExtendedUsage )
fnCmdOptExtendedUsage( 0 );
fprintf( stdout, "\n%s\n", szDescr );
// explain failure
if( cWrongNumber )
fprintf( stderr, "\n*** Wrong # arguments ***\n" );
exit( EXIT_FAILURE );
}
/***********************************************************************
* @Function: updateVar
* @Return: nothing
* @Descr: sets the variable in entries[ index ] to the value in str
* and does conversion if necessary
***********************************************************************/
static void updateVar( const CmdOptEntry entries[],
int nOptIndex,
const char* szStr )
{
switch( entries[ nOptIndex ].type )
{
case COT_BOOL:
*((char*) entries[ nOptIndex ].vValuePtr) = 1;
break;
case COT_INT:
if( (int) strlen( szStr ) > 2 &&
((szStr[ 0 ] == '0' && (toupper( szStr[ 1 ] ) == 'X' ))))
{
sscanf( &szStr[ 2 ],
"%x",
((int*) entries[ nOptIndex ].vValuePtr ) );
break;
}
*((int*) entries[ nOptIndex ].vValuePtr) = atoi( szStr );
break;
case COT_STRING:
*((const char**) entries[ nOptIndex ].vValuePtr) = szStr;
break;
case COT_MORE:
case COT_MORE_OPT:
case COT_NONE:
// will never happen but satisfies compiler
break;
}
if( NULL != entries[ nOptIndex ].pbPresent )
*entries[ nOptIndex ].pbPresent = 1;
}

View File

@ -1,54 +0,0 @@
/*
* libdigi/cmdopt.h
*
* Copyright (C) 2001,2002 by Digi International Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*
* Description: Helper functions to access command line options.
* The results are stored in global variables.
*
*/
#ifndef DG_CMDOPT_H
#define DG_CMDOPT_H
typedef enum {
COT_BOOL, // if present,bool is set 1, otherwise unchanged
COT_INT, // sets *valuePtr to the int value
// with conversions (if 0x
// prefix is present)
COT_STRING, // sets *valuePtr to the string
COT_MORE, // to end the array. Any additional arguments
// are allowed
COT_MORE_OPT, // to end the array. Any optional arguments
// are allowed
COT_NONE // to end the array. Any additional arguments
// are considered as failures
} CmdOptTypes;
typedef struct {
CmdOptTypes type; // type of option to be read
signed char cOptChar; // character to identify that option, if 0, then
// no option is used but parameter is required
void *vValuePtr; // ptr to the variable where value is stored
const char *szLabelStr; // label displayed in command line
const char *szHelpStr; // displays this help string for the variable
char *pbPresent; // will be set to if this option is present
} CmdOptEntry;
/* can be set to display additional usage */
extern void (*fnCmdOptExtendedUsage) (char bCmdLine);
extern const char *szCmdOptVersion; // overwrite it before calling cmdOptParse to
// define version of application
int cmdOptParse(int argc, char *argv[], const CmdOptEntry entries[], const char *szDescr);
void cmdOptUsageAndExit(int argc,
char *argv[], const CmdOptEntry entries[], const char *szDescr);
#endif /* DG_CMDOPT_H */

View File

@ -1,86 +0,0 @@
/*
* crc32.c
*
* Copyright (C) 2006 by Digi International Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*
* Description: Flash Test Util
*
*/
#include "crc32.h"
static const crc32_t crc32_table[256] = {
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL, 0x076dc419L,
0x706af48fL, 0xe963a535L, 0x9e6495a3L, 0x0edb8832L, 0x79dcb8a4L,
0xe0d5e91eL, 0x97d2d988L, 0x09b64c2bL, 0x7eb17cbdL, 0xe7b82d07L,
0x90bf1d91L, 0x1db71064L, 0x6ab020f2L, 0xf3b97148L, 0x84be41deL,
0x1adad47dL, 0x6ddde4ebL, 0xf4d4b551L, 0x83d385c7L, 0x136c9856L,
0x646ba8c0L, 0xfd62f97aL, 0x8a65c9ecL, 0x14015c4fL, 0x63066cd9L,
0xfa0f3d63L, 0x8d080df5L, 0x3b6e20c8L, 0x4c69105eL, 0xd56041e4L,
0xa2677172L, 0x3c03e4d1L, 0x4b04d447L, 0xd20d85fdL, 0xa50ab56bL,
0x35b5a8faL, 0x42b2986cL, 0xdbbbc9d6L, 0xacbcf940L, 0x32d86ce3L,
0x45df5c75L, 0xdcd60dcfL, 0xabd13d59L, 0x26d930acL, 0x51de003aL,
0xc8d75180L, 0xbfd06116L, 0x21b4f4b5L, 0x56b3c423L, 0xcfba9599L,
0xb8bda50fL, 0x2802b89eL, 0x5f058808L, 0xc60cd9b2L, 0xb10be924L,
0x2f6f7c87L, 0x58684c11L, 0xc1611dabL, 0xb6662d3dL, 0x76dc4190L,
0x01db7106L, 0x98d220bcL, 0xefd5102aL, 0x71b18589L, 0x06b6b51fL,
0x9fbfe4a5L, 0xe8b8d433L, 0x7807c9a2L, 0x0f00f934L, 0x9609a88eL,
0xe10e9818L, 0x7f6a0dbbL, 0x086d3d2dL, 0x91646c97L, 0xe6635c01L,
0x6b6b51f4L, 0x1c6c6162L, 0x856530d8L, 0xf262004eL, 0x6c0695edL,
0x1b01a57bL, 0x8208f4c1L, 0xf50fc457L, 0x65b0d9c6L, 0x12b7e950L,
0x8bbeb8eaL, 0xfcb9887cL, 0x62dd1ddfL, 0x15da2d49L, 0x8cd37cf3L,
0xfbd44c65L, 0x4db26158L, 0x3ab551ceL, 0xa3bc0074L, 0xd4bb30e2L,
0x4adfa541L, 0x3dd895d7L, 0xa4d1c46dL, 0xd3d6f4fbL, 0x4369e96aL,
0x346ed9fcL, 0xad678846L, 0xda60b8d0L, 0x44042d73L, 0x33031de5L,
0xaa0a4c5fL, 0xdd0d7cc9L, 0x5005713cL, 0x270241aaL, 0xbe0b1010L,
0xc90c2086L, 0x5768b525L, 0x206f85b3L, 0xb966d409L, 0xce61e49fL,
0x5edef90eL, 0x29d9c998L, 0xb0d09822L, 0xc7d7a8b4L, 0x59b33d17L,
0x2eb40d81L, 0xb7bd5c3bL, 0xc0ba6cadL, 0xedb88320L, 0x9abfb3b6L,
0x03b6e20cL, 0x74b1d29aL, 0xead54739L, 0x9dd277afL, 0x04db2615L,
0x73dc1683L, 0xe3630b12L, 0x94643b84L, 0x0d6d6a3eL, 0x7a6a5aa8L,
0xe40ecf0bL, 0x9309ff9dL, 0x0a00ae27L, 0x7d079eb1L, 0xf00f9344L,
0x8708a3d2L, 0x1e01f268L, 0x6906c2feL, 0xf762575dL, 0x806567cbL,
0x196c3671L, 0x6e6b06e7L, 0xfed41b76L, 0x89d32be0L, 0x10da7a5aL,
0x67dd4accL, 0xf9b9df6fL, 0x8ebeeff9L, 0x17b7be43L, 0x60b08ed5L,
0xd6d6a3e8L, 0xa1d1937eL, 0x38d8c2c4L, 0x4fdff252L, 0xd1bb67f1L,
0xa6bc5767L, 0x3fb506ddL, 0x48b2364bL, 0xd80d2bdaL, 0xaf0a1b4cL,
0x36034af6L, 0x41047a60L, 0xdf60efc3L, 0xa867df55L, 0x316e8eefL,
0x4669be79L, 0xcb61b38cL, 0xbc66831aL, 0x256fd2a0L, 0x5268e236L,
0xcc0c7795L, 0xbb0b4703L, 0x220216b9L, 0x5505262fL, 0xc5ba3bbeL,
0xb2bd0b28L, 0x2bb45a92L, 0x5cb36a04L, 0xc2d7ffa7L, 0xb5d0cf31L,
0x2cd99e8bL, 0x5bdeae1dL, 0x9b64c2b0L, 0xec63f226L, 0x756aa39cL,
0x026d930aL, 0x9c0906a9L, 0xeb0e363fL, 0x72076785L, 0x05005713L,
0x95bf4a82L, 0xe2b87a14L, 0x7bb12baeL, 0x0cb61b38L, 0x92d28e9bL,
0xe5d5be0dL, 0x7cdcefb7L, 0x0bdbdf21L, 0x86d3d2d4L, 0xf1d4e242L,
0x68ddb3f8L, 0x1fda836eL, 0x81be16cdL, 0xf6b9265bL, 0x6fb077e1L,
0x18b74777L, 0x88085ae6L, 0xff0f6a70L, 0x66063bcaL, 0x11010b5cL,
0x8f659effL, 0xf862ae69L, 0x616bffd3L, 0x166ccf45L, 0xa00ae278L,
0xd70dd2eeL, 0x4e048354L, 0x3903b3c2L, 0xa7672661L, 0xd06016f7L,
0x4969474dL, 0x3e6e77dbL, 0xaed16a4aL, 0xd9d65adcL, 0x40df0b66L,
0x37d83bf0L, 0xa9bcae53L, 0xdebb9ec5L, 0x47b2cf7fL, 0x30b5ffe9L,
0xbdbdf21cL, 0xcabac28aL, 0x53b39330L, 0x24b4a3a6L, 0xbad03605L,
0xcdd70693L, 0x54de5729L, 0x23d967bfL, 0xb3667a2eL, 0xc4614ab8L,
0x5d681b02L, 0x2a6f2b94L, 0xb40bbe37L, 0xc30c8ea1L, 0x5a05df1bL,
0x2d02ef8dL
};
crc32_t crc32(crc32_t uiCRC, const void *pvBuf, size_t iLen)
{
const unsigned char *pcBuf = (const unsigned char *)pvBuf;
/* uiCRC starts with 0 on first block. If run on a block, undoes the
previous uiCRC ^ 0xffffffff. */
uiCRC ^= 0xffffffff;
while (iLen-- > 0)
uiCRC = crc32_table[(uiCRC ^ *pcBuf++) & 0xff] ^ (uiCRC >> 8);
/* if last block, this is the result. Otherwise this will be undone
on next crc32 call */
return uiCRC ^ 0xffffffff;
}

View File

@ -1,24 +0,0 @@
/*
* libdigi/crc32.h
*
* Copyright (C) 2006 by Digi International Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*
* Description: CRC32 functions
*
*/
#ifndef DG_CRC32_H
#define DG_CRC32_H
#include <stdint.h> /* uint32_t */
#include <stdlib.h> /* size_t */
typedef uint32_t crc32_t;
extern crc32_t crc32(crc32_t uiCRC, const void *pvBuf, size_t iLen);
#endif /* DG_CRC32_H */

View File

@ -1,116 +0,0 @@
/*
* libdigi/digi-platforms.h
*
* Copyright (C) 2011 by Digi International Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*
* Description: Digi platforms
*
*/
#ifndef DIGI_PLATFORMS_H
#define DIGI_PLATFORMS_H
#define PLATFORM_NAME(x) x ## _NAME
#define MACH_TYPE_CC7U 1017
#define MACH_TYPE_CC7U_NAME "cc7u"
#define MACH_TYPE_CWIEM 1033
#define MACH_TYPE_CWIEM_NAME "cwiem"
#define MACH_TYPE_CCW9C 1110
#define MACH_TYPE_CCW9C_NAME "ccw9c"
#define MACH_TYPE_CC9P9360DEV 1114
#define MACH_TYPE_CC9P9360DEV_NAME "cc9p9360dev"
#define MACH_TYPE_CC9P9750DEV 1115
#define MACH_TYPE_CC9P9750DEV_NAME "cc9p9750dev"
#define MACH_TYPE_CC9P9360VAL 1116
#define MACH_TYPE_CC9P9360VAL_NAME "cc9p9360val"
#define MACH_TYPE_CC9P9750VAL 1117
#define MACH_TYPE_CC9P9750VAL_NAME "cc9p9750val"
#define MACH_TYPE_CC9P9360JS 1264
#define MACH_TYPE_CC9P9360JS_NAME "cc9p9360js"
#define MACH_TYPE_CC9P9215 1445
#define MACH_TYPE_CC9P9215_NAME "cc9p9215"
#define MACH_TYPE_CC9P9210 1446
#define MACH_TYPE_CC9P9210_NAME "cc9p9210"
#define MACH_TYPE_CC9P9215JS 1447
#define MACH_TYPE_CC9P9215JS_NAME "cc9p9215js"
#define MACH_TYPE_CC9P9210JS 1448
#define MACH_TYPE_CC9P9210JS_NAME "cc9p9210js"
#define MACH_TYPE_CC7UCAMRY 1493
#define MACH_TYPE_CC7UCAMRY_NAME "cc7ucamry"
#define MACH_TYPE_CC9M2443JS 1663
#define MACH_TYPE_CC9M2443JS_NAME "cc9m2443js"
#define MACH_TYPE_CME9210 1712
#define MACH_TYPE_CME9210_NAME "cme9210"
#define MACH_TYPE_CCW9P9215JS 1811
#define MACH_TYPE_CCW9P9215JS_NAME "ccw9p9215js"
#define MACH_TYPE_CC9M2443 1815
#define MACH_TYPE_CC9M2443_NAME "cc9m2443"
#define MACH_TYPE_CME9210JS 1854
#define MACH_TYPE_CME9210JS_NAME "cme9210js"
#define MACH_TYPE_CC9P9360 1855
#define MACH_TYPE_CC9P9360_NAME "cc9p9360"
#define MACH_TYPE_CCW9P9215 2137
#define MACH_TYPE_CCW9P9215_NAME "ccw9p9215"
#define MACH_TYPE_CCW9M2443 2145
#define MACH_TYPE_CCW9M2443_NAME "ccw9m2443"
#define MACH_TYPE_CCW9M2443JS 2146
#define MACH_TYPE_CCW9M2443JS_NAME "ccw9m2443js"
#define MACH_TYPE_CC9P9215_3G 2397
#define MACH_TYPE_CC9P9215_3G_NAME "cc9p9215_3g"
#define MACH_TYPE_CC9P9215_3GJS 2398
#define MACH_TYPE_CC9P9215_3GJS_NAME "cc9p9215_3gjs"
#define MACH_TYPE_CCMX51 2516
#define MACH_TYPE_CCMX51_NAME "ccmx51"
#define MACH_TYPE_CCMX51JS 2517
#define MACH_TYPE_CCMX51JS_NAME "ccmx51js"
#define MACH_TYPE_CCWMX51 2518
#define MACH_TYPE_CCWMX51_NAME "ccwmx51"
#define MACH_TYPE_CCWMX51JS 2519
#define MACH_TYPE_CCWMX51JS_NAME "ccwmx51js"
#define MACH_TYPE_CWME9210 3320
#define MACH_TYPE_CWME9210_NAME "cwme9210"
#define MACH_TYPE_CWME9210JS 3321
#define MACH_TYPE_CWME9210JS_NAME "cwme9210js"
#define MACH_TYPE_CCMX53 3346
#define MACH_TYPE_CCMX53_NAME "ccmx53"
#define MACH_TYPE_CCMX53JS 3347
#define MACH_TYPE_CCMX53JS_NAME "ccmx53js"
#define MACH_TYPE_CCWMX53 3348
#define MACH_TYPE_CCWMX53_NAME "ccwmx53"
#define MACH_TYPE_CCWMX53JS 3349
#define MACH_TYPE_CCWMX53JS_NAME "ccwmx53js"
#define MACH_TYPE_CPX2 3419
#define MACH_TYPE_CPX2_NAME "cpx2"
#define MACH_TYPE_WR21 3737
#define MACH_TYPE_WR21_NAME "wr21"
#define MACH_TYPE_CCARDWMX28 3893
#define MACH_TYPE_CCARDWMX28_NAME "ccardwmx28"
#define MACH_TYPE_CCARDMX28 3894
#define MACH_TYPE_CCARDMX28_NAME "ccardmx28"
#define MACH_TYPE_CCARDWMX28JS 3917
#define MACH_TYPE_CCARDWMX28JS_NAME "ccardwmx28js"
#define MACH_TYPE_CCARDMX28JS 3918
#define MACH_TYPE_CCARDMX28JS_NAME "ccardmx28js"
#define MACH_TYPE_CCIMX53 9980
#define MACH_TYPE_CCIMX53_NAME "ccimx53"
#define MACH_TYPE_CCIMX53JS 9981
#define MACH_TYPE_CCIMX53JS_NAME "ccimx53js"
#define MACH_TYPE_CCIMX51 9982
#define MACH_TYPE_CCIMX51_NAME "ccimx51"
#define MACH_TYPE_CCIMX51JS 9983
#define MACH_TYPE_CCIMX51JS_NAME "ccimx51js"
#define MACH_TYPE_CCARDIMX28 9984
#define MACH_TYPE_CCARDIMX28_NAME "ccardimx28"
#define MACH_TYPE_CCARDIMX28JS 9985
#define MACH_TYPE_CCARDIMX28JS_NAME "ccardimx28js"
int get_platform_id(void);
char is_nand_oob_atomic(void);
#endif /* DIGI_PLATFORMS_H */

View File

@ -1,129 +0,0 @@
/*
* log.c
*
* Copyright (C) 2001,2002 by Digi International Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*
* Description: implements logging interface
*
*/
#include <stdio.h> // fprintf
#include <stdlib.h> // EXIT_FAILURE
#include <errno.h> // errno
#include <netdb.h> // h_errno
#include <string.h> // strerror
#include <stdarg.h> // vprintf
#include "log.h"
/* Globaly visible */
LogLevel logLevel = LOG_STATUS;
/***********************************************************************
* @Function: log
* @Return: nothing
* @Descr: format and arg1..arg3 are printed on stderr only if level
* is <= logLevel
* format may not contain any newline character.
***********************************************************************/
void logMsg(LogLevel level, const char *szFormat, ...)
{
if (level <= logLevel) {
va_list ap;
/*@-formatconst@ */
va_start(ap, szFormat);
vfprintf(stderr, szFormat, ap);
va_end(ap);
/*@-formatconst@ */
fputs("\n", stderr);
}
}
/***********************************************************************
* @Function: systemLog
* @Return: nothing
* @Descr: dumps the system error that happened just before
***********************************************************************/
void systemLog(const char *szFormat, ...)
{
char *szError = NULL;
va_list ap;
if (errno)
szError = strdup(strerror(errno));
else if (h_errno)
szError = strdup(hstrerror(h_errno));
/*@-formatconst@ */
va_start(ap, szFormat);
vfprintf(stderr, szFormat, ap);
va_end(ap);
/*@-formatconst@ */
if (NULL != szError)
fprintf(stderr, " (%s)", szError);
fputs("\n", stderr);
if (NULL != szError)
free(szError);
}
/***********************************************************************
* @Function: error
* @Return: never
* @Descr: format and arg1..arg3 are printed on stderr only if level
* is <= logLevel
* format may not contain any newline character.
***********************************************************************/
void error(const char *szFormat, ...)
{
va_list ap;
fprintf(stderr, "*** Error: ");
/*@-formatconst@ */
va_start(ap, szFormat);
vfprintf(stderr, szFormat, ap);
va_end(ap);
/*@-formatconst@ */
fputs("\n", stderr);
exit(EXIT_FAILURE);
}
/***********************************************************************
* @Function: systemError
* @Return: never
* @Descr: dumps the system error that happened just before and exits the
* application
***********************************************************************/
void systemError(const char *szFormat, ...)
{
char *szError = NULL;
va_list ap;
if (errno)
szError = strdup(strerror(errno));
else if (h_errno)
szError = strdup(hstrerror(h_errno));
fprintf(stderr, "*** Error: ");
/*@-formatconst@ */
va_start(ap, szFormat);
vfprintf(stderr, szFormat, ap);
va_end(ap);
/*@-formatconst@ */
if (NULL != szError)
fprintf(stderr, " (%s)", szError);
fputs("\n", stderr);
free(szError);
exit(EXIT_FAILURE);
}

View File

@ -1,34 +0,0 @@
/*
* libdigi/log.h
*
* Copyright (C) 2001,2002 by Digi International Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*
* Description: Logging facility for applications
*
*/
#ifndef DG_LOG_H
#define DG_LOG_H
typedef enum {
LOG_ERR = 0,
LOG_STATUS,
LOG_HARDWARE1,
LOG_HARDWARE2,
LOG_PACKET,
LOG_LAST
} LogLevel;
extern LogLevel logLevel;
extern void logMsg(LogLevel level, const char *szFormat, ...);
extern void systemLog(const char *szFormat, ...);
extern void error(const char *szFormat, ...);
extern void systemError(const char *szFormat, ...);
#endif /* DG_LOG_H */

View File

@ -1,90 +0,0 @@
/*
* mem.c
*
* Copyright (C) 2006 by Digi International Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*
* Description: provides MemCmp() and MemDump()
*
*/
#include <stdio.h> /* printf */
#include "mem.h"
/***********************************************************************
* !Function: MemCmp
* !Descr: compares memory
* !Return: offset of failure or -1 if none
***********************************************************************/
loff_t MemCmp(const void *pvS1, const void *pvS2, size_t iSize)
{
const char *pcS2 = (const char *)pvS2;
const char *pcS1 = (const char *)pvS1;
loff_t iOffset = 0;
while (iOffset < iSize) {
if (*pcS2 != *pcS1)
return iOffset;
pcS2++;
pcS1++;
iOffset++;
}
return -1;
}
/***********************************************************************
* !Function: MemDump
* !Descr: Prints memory from pvbase + iOffset to pvBase + iOffset + iLen
***********************************************************************/
void MemDump(const void *pvBase, loff_t iOffset, size_t iLen)
{
const unsigned char *pucBuf = (const unsigned char *)pvBase + iOffset;
const int COLUMN_COUNT = 16;
int i;
for (i = 0; i < iLen; i += COLUMN_COUNT) {
/* print one row */
int j, iRowLen;
if ((i + COLUMN_COUNT) <= iLen)
iRowLen = COLUMN_COUNT;
else
iRowLen = iLen - i;
printf("%08llx ", (long long)iOffset);
/* print hexadecimal representation */
for (j = 0; j < iRowLen; j++) {
printf("%02x ", *(pucBuf + j));
if (((COLUMN_COUNT / 2) - 1) == j)
/* additional separator */
printf(" ");
}
printf(" ");
/* print character representation row */
for (j = 0; j < iRowLen; j++) {
unsigned char c = *(pucBuf + j);
if ((c < 32) || (c > 127))
c = '.';
if (((COLUMN_COUNT / 2) - 1) == j)
/* additional separator */
printf(" ");
printf("%c", c);
}
printf("\r\n");
pucBuf += iRowLen;
iOffset += iRowLen;
}
}

View File

@ -1,23 +0,0 @@
/*
* libdigi/mem.h
*
* Copyright (C) 2006 by Digi International Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*
* Description: provides MemCmp() and MemDump()
*
*/
#ifndef DG_MEM_H
#define DG_MEM_H
#include <stdlib.h> /* size_t */
extern loff_t MemCmp(const void *pvS1, const void *pvS2, size_t iSize);
extern void MemDump(const void *pvBase, loff_t iOffset, size_t iLen);
#endif /* DG_MEM_H */

View File

@ -1,51 +0,0 @@
/*
* libdigi/misc_helper.h
*
* Copyright (C) 2006 by Digi International Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*
* Description: miscellaneous definitions that simplifies developing
* May require 'string.h' or 'log.h'
*
*/
#ifndef DG_MISC_HELPER_H
#define DG_MISC_HELPER_H
#include <stdio.h> /* snprintf */
#include <string.h> /* memset */
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(*(x)))
#define CLEAR(x) memset( &x, 0, sizeof( x ) )
/* round up to kB */
#define TO_KiB(x) (((x) + 1023) / 1024)
/* to bytes */
#define KiB(x) ((x) * 1024)
#define MiB(x) (KiB(x) * 1024)
#define MAX(a, b) ((a) < (b) ? (b) : (a))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FREE(x) \
do { \
free((void *)x); \
x = NULL; \
} while (0)
#define CLOSE(x) \
do { \
if (close(x)) \
systemError("close"); \
x = -1; \
} while (0)
#define SPRINTF(acStr, args...) \
snprintf(acStr, sizeof(acStr), args)
#endif /* DG_MISC_HELPER_H */

View File

@ -1,110 +0,0 @@
/*
* Copyright (C) 2011 by Digi International Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version2 as published by
* the Free Software Foundation.
*/
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "digi-platforms.h"
#include "log.h"
/*
* Gets the platform ID from the file /proc/cpuinfo
* (the kernel needs to write the machine ID in this file).
* Returns the machine ID or -1 on error
*/
int get_platform_id(void)
{
char buffer[80];
FILE *fp;
long id = -1;
fp = popen("cat /proc/cpuinfo | grep \"Machine ID\" | cut -f 2 -d :", "r");
if (fp == NULL)
systemError("cannot access /proc/cpuinfo");
if (fgets(buffer, sizeof(buffer) - 1, fp)) {
errno = 0; /* to distinguish success/failure after call */
id = strtol(buffer, NULL, 10);
if (errno != 0)
id = -1; /* don't care about the error code */
}
fclose(fp);
return id;
}
/*
* get_platform_name_from_fdt
*
* Read the device tree and return platform name or NULL
*/
static char *get_platform_name_from_fdt(void)
{
static const char *fdt = "/proc/device-tree/digi,machine,name";
static char buffer[64]; /* static buffer so it can be used in the caller function */
char *plat_name = NULL;
FILE *fp;
fp = fopen(fdt, "r");
if (fp == NULL)
goto out;
plat_name = fgets(buffer, sizeof(buffer), fp);
fclose(fp);
out:
return plat_name;
}
/*
* Checks whether platform requires an atomic access to NAND OOB
*/
char is_nand_oob_atomic(void)
{
int platform_id;
platform_id = get_platform_id();
if (platform_id != -1) {
/* The following platforms require atomic access to NAND OOB */
if (MACH_TYPE_CPX2 == platform_id ||
MACH_TYPE_WR21 == platform_id ||
MACH_TYPE_CCMX51 == platform_id ||
MACH_TYPE_CCMX51JS == platform_id ||
MACH_TYPE_CCWMX51 == platform_id ||
MACH_TYPE_CCWMX51JS == platform_id ||
MACH_TYPE_CCIMX51 == platform_id ||
MACH_TYPE_CCIMX51JS == platform_id ||
MACH_TYPE_CCMX53 == platform_id ||
MACH_TYPE_CCMX53JS == platform_id ||
MACH_TYPE_CCWMX53 == platform_id ||
MACH_TYPE_CCWMX53JS == platform_id ||
MACH_TYPE_CCIMX53 == platform_id ||
MACH_TYPE_CCIMX53JS == platform_id ||
MACH_TYPE_CCARDMX28 == platform_id ||
MACH_TYPE_CCARDMX28JS == platform_id ||
MACH_TYPE_CCARDWMX28 == platform_id ||
MACH_TYPE_CCARDWMX28JS == platform_id ||
MACH_TYPE_CCARDIMX28 == platform_id ||
MACH_TYPE_CCARDIMX28JS == platform_id)
return 1;
} else {
/*
* Workaround to detect is_nand_oob_atomic in ccardimx28 using
* linux 3.x
* TODO: generalize this.
*/
char *platform_name = get_platform_name_from_fdt();
if (platform_name && !strcmp(platform_name, "ccardimx28"))
return 1;
}
return 0;
}

View File

@ -1,46 +0,0 @@
# Copyright (C) 2013 Digi International.
SUMMARY = "Digi's NVRAM tool"
SECTION = "base"
LICENSE = "GPL-2.0"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6"
require recipes-bsp/u-boot/u-boot-dey-rev_${PV}.inc
DEPENDS = "libdigi"
SRC_URI += " \
file://main.c \
file://nvram_priv_linux.c \
"
S = "${WORKDIR}"
CMD_GIT_SHA1 = "$(cd ${THISDIR} && git rev-parse --short=7 HEAD)"
LIB_GIT_SHA1 = "$(cd ${WORKDIR}/git && git rev-parse --short=7 HEAD)"
EXTRA_CFLAGS = "-Wall -DLINUX -DCMD_GIT_SHA1=\"${CMD_GIT_SHA1}\" -DLIB_GIT_SHA1=\"${LIB_GIT_SHA1}\" -Ilib/include -I${STAGING_INCDIR}/libdigi"
do_configure() {
rm -f lib && ln -s ${UBOOT_NVRAM_LIBPATH}
}
do_compile() {
# 'libnvram.a' static library
${CC} ${CFLAGS} ${EXTRA_CFLAGS} -c -o nvram.o lib/src/nvram.c
${CC} ${CFLAGS} ${EXTRA_CFLAGS} -c -o nvram_cmdline.o lib/src/nvram_cmdline.c
${CC} ${CFLAGS} ${EXTRA_CFLAGS} -c -o nvram_priv_linux.o nvram_priv_linux.c
${AR} -rcs libnvram.a nvram.o nvram_cmdline.o nvram_priv_linux.o
# 'nvram' command-line tool
${CC} ${CFLAGS} ${EXTRA_CFLAGS} -c -o main.o main.c
${CC} ${LDFLAGS} -o nvram main.o libnvram.a -ldigi
}
do_install() {
mkdir -p ${D}${base_sbindir} ${D}${includedir} ${D}${libdir}
install -m 0644 libnvram.a ${D}${libdir}/
install -m 0644 lib/include/nvram.h lib/include/nvram_types.h ${D}${includedir}/
install -m 0755 nvram ${D}${base_sbindir}/
}
PACKAGE_ARCH = "${MACHINE_ARCH}"

View File

@ -1,266 +0,0 @@
/*
* nvram/src/main.c
*
* Copyright (C) 2006-2013 by Digi International Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version2 as published by
* the Free Software Foundation.
*/
/*
* !Author: Markus Pietrek
* !Descr: main() and user code for nvram.
*/
#include <errno.h> /* errno */
#include <fcntl.h> /* open */
#include <stdarg.h> /* vprintf */
#include <stdio.h> /* snprintf */
#include <stdlib.h> /* EXIT_SUCCESS */
#include <string.h> /* strdup */
#include <sys/stat.h>
/* from libdigi */
#include <cmdopt.h>
#include <log.h>
#include <misc_helper.h>
#include "nvram.h" /* Nv* */
#define CA(cmd) \
do { \
if( !cmd ) \
ExitError( #cmd ); \
} while( 0 )
#define VERSION "1.15" "-g"CMD_GIT_SHA1
/* Hack to change priv_linux mode */
void NvPrivLinuxSetMode(char bManufMode);
/* local functions */
static void ExitError(const char *szFormat, ...);
static void OnExit(void);
static void ExtendedUsage(char bCmdLine);
static void OSLoadFromFile(nv_os_type_e eOS, const char *szFile);
static void OSSaveToFile(nv_os_type_e eOS, const char *szFile);
static char l_bOptDetailed = 0;
static char quiet = 0;
static char l_bManufMode = 0;
int main(int argc, char *argv[])
{
char acVersion[128];
uint32_t uiLibVerMajor;
uint32_t uiLibVerMinor;
int iExtendedArgs;
const char *xPrintAll[] = { "printall" };
const char *szOSOutFile = NULL;
const char *szOSInFile = NULL;
const char *szOS = NULL;
char bSave = 0;
nv_os_type_e eOS = NVOS_NONE;
int ret;
CmdOptEntry aCmdEntries[] = {
/*@@-nullassign@@ */// only COT_NONE may have a NULL for vValuePtr
{COT_BOOL, 'e', &l_bOptDetailed, "error_detailed",
"detailed error messages"},
{COT_BOOL, 'b', &g_markBadBlocks, "bad-block-marking",
"On repeated error, mark block as bad."},
{COT_STRING, 'g', &szOSOutFile, "get_os_cfg",
"copies the os configuration block to file"},
{COT_STRING, 's', &szOSInFile, "set_os_cfg",
"copies the os configuration block from file"},
{COT_STRING, 'o', &szOS, "os",
"select's the OS to get configuration from"},
{COT_BOOL, 'q', &quiet, "quiet",
"display no error messages"},
{COT_BOOL, 'm', &l_bManufMode, "manuf-mode",
"manufacturing mode (no auto-repair, permit reset)"},
{COT_MORE_OPT, 0, NULL, "", ""},
{COT_NONE, 0, NULL, NULL, NULL},
/*@@+nullassign@@ */
};
NvGetLibVersion(&uiLibVerMajor, &uiLibVerMinor);
snprintf(acVersion,
sizeof(acVersion) - 1,
"Version: " VERSION ", NVRAM Library %u.%u-g" LIB_GIT_SHA1 ", compiled on "
__DATE__ "," __TIME__, uiLibVerMajor, uiLibVerMinor);
acVersion[sizeof(acVersion) - 1] = 0U;
szCmdOptVersion = acVersion;
fnCmdOptExtendedUsage = ExtendedUsage;
iExtendedArgs = cmdOptParse(argc, argv, aCmdEntries,
"NVRAM Tool for updating nvram settings");
logMsg(LOG_HARDWARE1,
"Sizes: Critical: %i\n"
" Module ID: %i\n"
" IP: %i\n"
" IP Device: %i\n"
" Partition Table: %i\n"
" Partition Entry: %i\n"
" OS Cfg Table: %i\n"
" OS Cfg: %i\n",
sizeof(nv_critical_t),
sizeof(nv_param_module_id_t),
sizeof(nv_param_ip_t),
sizeof(nv_param_ip_device_t),
sizeof(nv_param_part_table_t),
sizeof(nv_param_part_t),
sizeof(nv_param_os_cfg_table_t),
sizeof(nv_param_os_cfg_t));
/* so we can close everything even on error() or on return of main */
atexit(OnExit);
NvPrivLinuxSetMode(l_bManufMode);
/* In manufacturing mode, do not let library auto-repair the NVRAM */
ret = NvInit(l_bManufMode ? NVR_MANUAL : NVR_AUTO);
if (!ret) {
/* If NVRAM was not initialized, only continue if
* we are requesting a reset.
*/
if (argc == iExtendedArgs) {
ExitError("NvInit");
} else {
if (strcmp("reset", argv[iExtendedArgs]))
ExitError("NvInit");
}
}
if (NULL != szOS) {
if (!NvToOS(&eOS, szOS))
error("OS not known: %s\n", szOS);
}
if (NULL != szOSInFile) {
bSave = 1;
OSLoadFromFile(eOS, szOSInFile);
}
if (NULL != szOSOutFile)
/* it's load from NVRAM view */
OSSaveToFile(eOS, szOSOutFile);
if (argc == iExtendedArgs) {
if ((NULL == szOSInFile) && (NULL == szOSOutFile))
/* on -o, the user likes to read/write something */
CA(NvCmdLine(ARRAY_SIZE(xPrintAll), xPrintAll));
} else {
CA(NvCmdLine(argc - iExtendedArgs, (const char **)&argv[iExtendedArgs]));
if (!strcmp("set", argv[iExtendedArgs]) ||
!strcmp("reset", argv[iExtendedArgs]) ||
!strcmp("init", argv[iExtendedArgs]))
bSave = 1;
}
if (bSave)
CA(NvSave());
return EXIT_SUCCESS;
}
/* ********** local functions ********** */
static void ExtendedUsage(char bCmdLine)
{
if (bCmdLine == 1)
CA(NvPrintHelp());
}
static void ExitError(const char *szFormat, ...)
{
const char *szError = NULL;
const char *szWhat = NULL;
const char *szFunc = NULL;
const char *szFile = NULL;
int iLine;
va_list ap;
if (!quiet || l_bOptDetailed) {
fprintf(stderr, "*** Error: ");
if (l_bOptDetailed) {
/*@-formatconst@ */
va_start(ap, szFormat);
vfprintf(stderr, szFormat, ap);
va_end(ap);
fprintf(stderr, ": ");
/*@+formatconst@ */
}
if (NVE_GOOD != NvErrorMsg(&szError, &szWhat, &szFunc, &szFile, &iLine)) {
if (l_bOptDetailed)
fprintf(stderr, " %s: (%s) @ %s:%i (%s)",
szError, szWhat, szFile, iLine, szFunc);
else
fprintf(stderr, " %s: (%s)", szError, szWhat);
}
fprintf(stderr, "\n");
}
exit(EXIT_FAILURE);
}
static void OSLoadFromFile(nv_os_type_e eOS, const char *szFile)
{
int iFd;
nv_param_os_cfg_t xCfg;
void *pvTmp;
CA(NvOSCfgFind(&xCfg, eOS));
pvTmp = malloc(xCfg.uiSize);
if (NULL == pvTmp)
systemError("malloc: %i", xCfg.uiSize);
iFd = open(szFile, O_RDONLY);
if (-1 == iFd)
systemError("%s", szFile);
if (-1 == read(iFd, pvTmp, xCfg.uiSize))
systemError("read");
CLOSE(iFd);
CA(NvOSCfgSet(eOS, pvTmp, xCfg.uiSize));
FREE(pvTmp);
printf("Loaded from %s\n", szFile);
}
static void OSSaveToFile(nv_os_type_e eOS, const char *szFile)
{
int iFd;
nv_param_os_cfg_t xCfg;
void *pvTmp;
size_t iSize;
CA(NvOSCfgFind(&xCfg, eOS));
pvTmp = malloc(xCfg.uiSize);
if (NULL == pvTmp)
systemError("malloc: %i", xCfg.uiSize);
CA(NvOSCfgGet(eOS, pvTmp, xCfg.uiSize, &iSize));
iFd = open(szFile, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (-1 == iFd)
systemError("%s", szFile);
if (xCfg.uiSize != write(iFd, pvTmp, xCfg.uiSize))
systemError("write");
CLOSE(iFd);
FREE(pvTmp);
printf("Stored to %s\n", szFile);
}
/*! \brief closes all descriptors on any exit */
static void OnExit(void)
{
NvFinish();
}

View File

@ -1,302 +0,0 @@
/*
* nvram/src/nvram_priv_linux.c
*
* Copyright (C) 2006-2013 by Digi International Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version2 as published by
* the Free Software Foundation.
*/
/*
* !Author: Markus Pietrek
* !Descr: Defines the private functions needed by the nvram core to
* access I2C, Flash and a console for linux userspace.
*/
#define _XOPEN_SOURCE 500 /* for pread/pwrite */
#include <errno.h> /* ENOTSUP */
#include <fcntl.h> /* open */
#include <mtd/mtd-user.h> /* MEMERASE */
#include <stdarg.h> /* vprintf */
#include <sys/ioctl.h> /* ioctl */
#include <sys/stat.h> /* stat */
/* from libdigi */
#include <log.h> /* systemError */
#include <misc_helper.h> /* CLEAR */
#include "nvram_priv.h"
#define NVRAM_PARTITION 1
char g_markBadBlocks = 0;
/* ********** local variables ********** */
static char l_acMtd[32];
static int l_iFdMtd = -1;
static mtd_info_t l_xMtdInfo;
static unsigned char bbMaxRetries = 3;
extern void MemDump(const void *pvBase, loff_t iOffset, size_t iLen);
static char l_bManufMode = 0;
/* ********** global functions ********** */
void NvPrivLinuxSetMode(char bManufMode)
{
/* Hack so linux nvram can change behavior of priv_linux */
/* without ubootenv also changing. */
l_bManufMode = bManufMode;
}
int NvPrivOSInit(void)
{
struct stat xStat;
CLEAR(xStat);
/* detect NVRAM partition */
SPRINTF(l_acMtd, "/dev/mtd/%i", NVRAM_PARTITION);
/* determine whether we are /dev/mtd/ or /dev/mtd */
if (-1 == stat(l_acMtd, &xStat)) {
SPRINTF(l_acMtd, "/dev/mtd%i", NVRAM_PARTITION);
/* not dev fs */
if (-1 == stat(l_acMtd, &xStat))
return NV_SET_ERROR(NVE_NO_DEV, strerror(errno));
}
return 1;
}
int NvPrivOSFinish(void)
{
return 1;
}
int NvPrivOSPostInit(void)
{
return 1;
}
int NvPrivOSCriticalPostReset(struct nv_critical *pParams)
{
/* nothing to do */
return 1;
}
int NvPrivOSCriticalPartReset(struct nv_critical *pCrit, nv_os_type_e eForOS)
{
if (l_bManufMode) {
/*
* In manufacturing mode, don't return an error, assuming
* that caller knows what they're doing.
*/
return 1;
} else {
/*
* Retain previous behavior of returning an error, which
* will cause us to exit before calling NvSave(); this is
* done to prevent 'nvram reset' from linux from erasing the
* OSCfgTable, since we won't properly restore the ubootenv
* section.
*/
RETURN_NOT_IMPLEMENTED();
}
}
int NvPrivOSFlashOpen(char bForWrite)
{
l_iFdMtd = open(l_acMtd, bForWrite ? (O_RDWR | O_SYNC) : O_RDONLY);
if (-1 == l_iFdMtd)
return NV_SET_ERROR(NVE_NO_DEV, strerror(errno));
CLEAR(l_xMtdInfo);
/* read partition info */
if (ioctl(l_iFdMtd, MEMGETINFO, &l_xMtdInfo)) {
CLOSE(l_iFdMtd);
return NV_SET_ERROR(NVE_NO_DEV, strerror(errno));
}
return 1;
}
int NvPrivOSFlashClose(void)
{
CLOSE(l_iFdMtd);
return 1;
}
/* A block is marked as bad as a consequence of consecutive read/write errors,
* for example unrecoverable CRC errors, or if the data verification after a
* write finds data mismatch after a number of retries. */
static int NvPrivMarkBadBlock(int fd, loff_t iOffset)
{
logMsg(LOG_STATUS, "Marking offset %d as bad\n", (int)iOffset);
return (ioctl(fd, MEMSETBADBLOCK, &iOffset));
}
int NvPrivOSFlashRead(void *pvBuf, loff_t iOffs, size_t iLength)
{
int iRead;
int i, iRet;
for (i = 0; i < bbMaxRetries; i++) {
iRead = pread(l_iFdMtd, pvBuf, iLength, iOffs);
if (iRead != iLength) {
if (g_markBadBlocks) {
systemLog("Retrying failed read:Got %i "
"Bytes instead of %i.\n", iRead, iLength);
continue;
} else {
systemLog("read failed. Got %i Bytes "
"instead of %i\n", iRead, iLength);
return NV_SET_ERROR(NVE_IO, strerror(errno));
}
}
break;
}
if (g_markBadBlocks && (i >= bbMaxRetries)) {
/* Read error, for example unrecoverable ECC */
iRet = NvPrivMarkBadBlock(l_iFdMtd, iOffs);
return NV_SET_ERROR(NVE_IO, strerror(iRet));
}
return 1;
}
int NvPrivOSFlashErase(loff_t iOffs)
{
erase_info_t xErase;
CLEAR(xErase);
xErase.length = l_xMtdInfo.erasesize;
xErase.start = iOffs;
if (ioctl(l_iFdMtd, MEMERASE, &xErase))
return NV_SET_ERROR(NVE_IO, strerror(errno));
return 1;
}
int NvPrivOSFlashWrite( /*@in@ */ const void *pvBuf, loff_t iOffs, size_t iLength)
{
int iWritten, iRead;
int i, iRet;
unsigned char *pvRdBuf;
/* we are not called for bad sectors */
for (i = 0; i < bbMaxRetries; i++) {
iWritten = pwrite(l_iFdMtd, pvBuf, iLength, iOffs);
if (iWritten != iLength) {
if (g_markBadBlocks) {
systemLog("Retrying failed write:"
"Wrote %i Bytes"
" instead of %i.\n", iWritten, iLength);
continue;
} else {
logMsg(LOG_ERR, "write failed."
" Wrote %i Bytes" " instead of %i\n", iWritten, iLength);
return NV_SET_ERROR(NVE_IO, strerror(errno));
}
}
if (g_markBadBlocks) {
pvRdBuf = (unsigned char *)malloc(iLength);
if (NULL == pvRdBuf) {
systemLog("Malloc failed.\n");
return NV_SET_ERROR(NVE_IO, strerror(errno));
}
for (i = 0; i < bbMaxRetries; i++) {
iRead = pread(l_iFdMtd, pvRdBuf, iLength, iOffs);
if (iRead != iLength) {
systemLog("Retrying failed read:"
"%i < > %i.\n", iRead, iLength);
continue;
}
if (memcmp(pvRdBuf, pvBuf, iLength) != 0) {
logMsg(LOG_ERR,
"\nData mismatch at offset 0x%08x\n", iOffs);
logMsg(LOG_ERR, "Source is");
MemDump(pvBuf, iOffs & ~0xf, MIN(iLength, 0x20));
logMsg(LOG_ERR, "Flash is");
MemDump(pvRdBuf, iOffs & ~0xf, MIN(iRead, 0x20));
continue;
}
break;
}
FREE(pvRdBuf);
}
break;
}
if (g_markBadBlocks && (i >= bbMaxRetries)) {
iRet = NvPrivMarkBadBlock(l_iFdMtd, iOffs);
return NV_SET_ERROR(NVE_IO, strerror(iRet));
}
return 1;
}
int NvPrivOSFlashProtect(loff_t iOffs, size_t iLength, char bProtect)
{
erase_info_t xErase;
CLEAR(xErase);
xErase.length = l_xMtdInfo.erasesize;
xErase.start = iOffs;
if (ioctl(l_iFdMtd, (bProtect ? MEMLOCK : MEMUNLOCK), &xErase)) {
if (ENOTSUP != errno)
/* e.g. NAND */
return NV_SET_ERROR(NVE_IO, strerror(errno));
}
return 1;
}
int NvPrivOSFlashInfo(loff_t iOffs,
/*@out@*/ struct nv_priv_flash_status *pStatus)
{
int iRes;
CLEAR(*pStatus);
/* linux hasn't an interface yet to determine erase size at iOffs.
Anyway, we place NVRAM immediately after U-Boot, so we have unique
erase sizes */
pStatus->iEraseSize = l_xMtdInfo.erasesize;
pStatus->type = l_xMtdInfo.type;
/* determine whether block at iOffs is bad */
iRes = ioctl(l_iFdMtd, MEMGETBADBLOCK, &iOffs);
if (iRes > 0)
pStatus->bBad = 1;
else if ((iRes < 0) && (ENOTSUP != errno))
return NV_SET_ERROR(NVE_IO, strerror(errno));
/* else if not supported (NOR), is is assumed good */
return 1;
}
void NvPrivOSPrintf(const char *szFormat, ...)
{
va_list ap;
va_start(ap, szFormat);
vprintf(szFormat, ap);
va_end(ap);
}
void NvPrivOSPrintfError(const char *szFormat, ...)
{
va_list ap;
va_start(ap, szFormat);
vfprintf(stderr, szFormat, ap);
va_end(ap);
}

View File

@ -1,5 +0,0 @@
PV = "2013.01"
require recipes-bsp/nvram/nvram.inc
COMPATIBLE_MACHINE = "(ccardimx28)"

View File

@ -1,16 +0,0 @@
#
# U-Boot bootscript for SD images created by Yocto.
#
# Layout:
# * U-Boot (raw copied)
# * Boot partion (FAT) with kernel images and DTB
# * Rootfs partion (EXT4)
#
# +--------------+----------------------+-------------------------+
# | U-BOOT (RAW) | BOOT_PARTITION (FAT) | ROOTFS_PARTITION (EXT4) |
# +--------------+----------------------+-------------------------+
#
setenv fdtimg uimage-imx28-ccardimx28js.dtb
setenv kimg uimage-ccardimx28js.bin
setenv mmc_rpart /dev/mmcblk0p3
dboot linux mmc 0:2

View File

@ -1,11 +0,0 @@
# Copyright (C) 2013 Digi International
SRCBRANCH = "v2013.01/dub-2.0/maint"
SRCREV = "${AUTOREV}"
# Select internal or Github U-Boot repo
UBOOT_GIT_URI ?= "${@base_conditional('DIGI_INTERNAL_GIT', '1' , '${DIGI_GIT}u-boot-denx.git', '${DIGI_GITHUB_GIT}/u-boot.git', d)}"
SRC_URI = "${UBOOT_GIT_URI};branch=${SRCBRANCH}"
UBOOT_NVRAM_LIBPATH = "git/board/digi/common/cmd_nvram/lib"

View File

@ -1,26 +0,0 @@
# Copyright (C) 2012 Digi International
DESCRIPTION = "Bootloader for Digi platforms"
require recipes-bsp/u-boot/u-boot.inc
include u-boot-dey-rev_${PV}.inc
PROVIDES += "u-boot"
LICENSE = "GPLv2+"
LIC_FILES_CHKSUM = "file://COPYING;md5=1707d6db1d42237583f50183a5651ecb"
SRC_URI += "file://boot.txt"
S = "${WORKDIR}/git"
DEPENDS += "elftosb-native u-boot-mkimage-native"
do_compile_prepend() {
${S}/tools/setlocalversion --save-scmversion ${S}
}
do_deploy_append() {
mkimage -T script -n bootscript -C none -d ${WORKDIR}/boot.txt ${DEPLOYDIR}/boot.scr
}
COMPATIBLE_MACHINE = "(ccardimx28)"

View File

@ -1,34 +0,0 @@
# Copyright (C) 2013 Digi International.
SUMMARY = "Digi's ubootenv tool"
SECTION = "base"
LICENSE = "GPL-2.0"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6"
DEPENDS = "libdigi nvram"
SRC_URI = " \
file://env_funcs.c \
file://env_funcs.h \
file://environment.h \
file://main_env.c \
"
S = "${WORKDIR}"
GIT_SHA1 = "$(cd ${THISDIR} && git rev-parse --short=7 HEAD)"
EXTRA_CFLAGS = "-Wall -DLINUX -DGIT_SHA1=\"${GIT_SHA1}\" -I${STAGING_INCDIR}/libdigi"
do_compile() {
${CC} ${CFLAGS} ${EXTRA_CFLAGS} -c -o main_env.o main_env.c
${CC} ${CFLAGS} ${EXTRA_CFLAGS} -c -o env_funcs.o env_funcs.c
${CC} ${LDFLAGS} -o ubootenv main_env.o env_funcs.o -lnvram -ldigi
}
do_install() {
mkdir -p ${D}${base_sbindir}
install -m 0755 ubootenv ${D}${base_sbindir}/
}
PACKAGE_ARCH = "${MACHINE_ARCH}"

View File

@ -1,183 +0,0 @@
/*
* env_funcs.c
*
* Copyright (C) 2006-2013 by Digi International Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*
* Description: Function prototypes for all the flavors of the NVRAM tool
*
*/
#include <stdio.h>
#include <string.h>
#include "env_funcs.h"
/*
* Function: get_var_value
* Return: NULL on failure/ pointer where var value starts on succes
* Description: Checks if the variable name is contained on the string and
* returns a pointer where the variable value starts.
*/
char *get_var_value(const char *from, const char *var_name, char sep)
{
char *separator;
char *start;
if (((separator = strchr(from, sep)) != NULL) &&
((start = strstr(from, var_name)) != NULL)) {
if (start < separator)
return (++separator);
}
return NULL;
}
/*
* Function: get_var_name
* Return: 1 on success, 0 otherwise
* Description: Retrieves the var name from a var string
*/
int get_var_name(const char *from, char *var_name, char sep)
{
char *separator;
if ((separator = strchr(from, sep)) != NULL) {
while (from < separator)
*var_name++ = *from++;
*var_name = 0;
return 1;
}
return 0;
}
/*
* Function: get_next_env_string
* Return: the string to the next environment variable in UBOOT or
* NULL on failure
* Description: returns the addr of the next string in a data structure
* <string>\0<string>\0\0
* It does an offset calculation to check for overflow.
*/
char *get_next_env_string(char *from, char *till)
{
if (*from == 0)
return NULL;
while (from < till && *from)
from++;
if (from == till && *from)
return NULL; // Indicate string to long
return (++from);
}
/*
* Function: get_var_addr
* Return: the pointer to the address string or NULL if not found.
* Description: Returns the addr of the variable in a data structure
* <string>\0<string>\0\0
* It does an offset calculation to check for overflow.
*/
char *get_var_addr(char *from, char *till, char *var_name)
{
char *data = from;
char *var_addr;
char var_name_temp[ENV_MAX_VAR_NAME_LEN + 1];
sprintf(var_name_temp, "%s%s", var_name, "=");
do {
if (*data && data < till) {
if ((var_addr = strstr(data, var_name_temp)) != NULL
&& (var_addr == data))
return var_addr < till ? var_addr : NULL;
}
} while ((data = get_next_env_string(data, till)) != NULL);
return NULL;
}
/*
* Function: get_end_mark
* Description:
*/
char *get_end_mark(char *from, char *till)
{
while (from < till) {
while (*from)
from++;
if (from >= till)
return NULL;
if (*(++from) == 0)
return from;
}
return NULL;
}
/*
* Function: remove_var
* Return: 1 on success, 0 otherwise
* Description: Remove environment variables
*/
int remove_var(char *from, char *till, char *var_name)
{
char *var_addr;
char *env_end;
char *var_end;
/* Check if variable already exists */
if ((var_addr = get_var_addr(from, till, var_name)) != NULL) {
if ((env_end = get_end_mark(var_addr, till)) != NULL) {
if ((var_end = get_next_env_string(var_addr, till)) != NULL) {
while (var_end <= env_end)
*var_addr++ = *var_end++;
while (var_addr <= env_end)
*var_addr++ = 0; /* Just to have a clean environment :-) */
return 1;
}
}
}
return 0;
}
/*
* Function: add_var
* Return: 1 on success, 0 otherwise
* Description: Add a new environment variable
*/
int add_var(char *from, char *till, char *var_str)
{
char *var_addr;
char var_name[ENV_MAX_VAR_NAME_LEN];
if (get_var_name(var_str, var_name, '=')) {
/* Check if variable already exists */
if ((var_addr = get_var_addr(from, till, var_name)) != NULL) {
/* @TODO: remove more?? could be that it were there more than once?? */
if (!remove_var(var_addr, till, var_name))
return 0;
}
/* Append the variable to the end */
if ((var_addr = get_end_mark(from, till)) != NULL) {
/* Check if environment is empty. If yes, start from the beginning */
if (var_addr == (from + 1))
var_addr--;
while (var_addr < till && *var_str)
*var_addr++ = *var_str++;
*var_addr++ = 0;
*var_addr = 0;
return 1;
} else {
fprintf(stderr, "Unable to find environment end\n");
}
}
return 0;
}

View File

@ -1,29 +0,0 @@
/*
* env_funcs.h
*
* Copyright (C) 2006-2013 by Digi International Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*
* Description: Data types and prototypes for parsing the NVRAM environment
*
*/
#ifndef ENV_FUNCS_H
#define ENV_FUNCS_H
#define ENV_MAX_VAR_NAME_LEN 50
#define ENV_MAX_VAR_VAL_LEN 256
char *get_var_value(const char *from, const char *var_name, char sep);
char *get_next_env_string(char *from, char *till);
char *get_var_addr(char *from, char *till, char *var_name);
char *get_end_mark(char *from, char *till);
int get_var_name(const char *from, char *var_name, char sep);
int add_var(char *from, char *till, char *var_str);
int remove_var(char *from, char *till, char *var_name);
#endif

View File

@ -1,26 +0,0 @@
/*
* environment.h
*
* Copyright (C) 2006-2013 by Digi International Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*
* Description: Data types and definitions for environment in NVRAM
*
*/
#ifndef __ENV_TOOL_H_
#define __ENV_TOOL_H_
#define VAR_SEP '\0'
#define VAR_ASIGN '='
typedef struct {
unsigned long crc;
char data[];
} env_t;
#endif

View File

@ -1,561 +0,0 @@
/*
* main_env.c
*
* Copyright (C) 2006-2013 by Digi International Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published by
* the Free Software Foundation.
*
* Description: main() and user code to manage u-boot and linux environment
*
*/
#define VERSION "1.8" "-g"GIT_SHA1
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <mtd/mtd-user.h> /* MEMERASE */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h> /* ioctl */
#include <unistd.h>
#include <libdigi/crc32.h>
#include <nvram.h> /* Nv* */
#include "env_funcs.h"
#include "environment.h"
#define APP_UBOOTENV "ubootenv"
#define APP_PRODINFOENV "prodinfoenv"
static char *fileadd = NULL;
static char *printlist = NULL;
static char *setstring = NULL;
static char *eraselist = NULL;
static char *cmdname = NULL;
static int dump = 0, clean = 0;
static nv_os_type_e envType;
static const char *envTypes[] = {
[NVOS_NONE] = "None",
[NVOS_UBOOT] = "U-Boot",
[NVOS_PROD_INFO] = "Product Info",
};
static const size_t envDefaultSizes[] = {
[NVOS_NONE] = 0,
[NVOS_UBOOT] = 8192, /* Default value is CONFIG_ENV_SIZE, normally set by U-Boot */
[NVOS_PROD_INFO] = PROD_INFO_DATA_SIZE, /* Defined in nvram.h but shouldn't be except uboot needs it */
};
static const char* excludeVars[][2] = {
{"ethaddr", "ethaddr1" },
{"wlanaddr", "ethaddr2" },
{"eth1addr", "ethaddr3" },
{"ipaddr", "ip1" },
{"ipaddr_wlan", "ip2" },
{"ipaddr1", "ip3" },
{"netmask", "netmask1" },
{"netmask_wlan","netmask2" },
{"netmask1", "netmask3" },
{"serverip", "server" },
{"gatewayip", "gateway" },
{"dnsip", "dns1" },
{"dnsip2", "dns2" },
{"dhcp", "dhcp1" },
{"dhcp_wlan", "dhcp2" },
{"dhcp1", "dhcp3" },
};
static const char *env_os_type_to_string(void)
{
return envTypes[envType];
}
static int env_onetime_writable(void)
{
if (NVOS_PROD_INFO == envType)
return 1;
return 0;
}
static int env_is_empty(env_t * env, unsigned int envlen)
{
char *from = (char *)&env->data;
char *till = (char *)&env->data + envlen;
char *end;
end = get_end_mark(from, till);
/* Check if environment is empty. If yes, start from the beginning */
if (end == (from + 1))
return 1;
return 0;
}
static int env_have_to_use_nvram(const char *varname)
{
int j;
if (envType == NVOS_UBOOT) {
for (j = 0; j < ARRAY_SIZE(excludeVars); j++) {
if (strcmp(varname, excludeVars[j][0]) == 0)
return j;
}
}
return -1;
}
static void show_usage(void)
{
fprintf(stdout, "Usage: %s [options]\n"
"%s %s Copyright Digi International Inc.\n\n"
"Prints or updates the %s environment\n"
"\n"
" -d, --dump Prints the values of all the environment\n"
" -p, --print 'var_name_list' Prints the value of the list of variables\n"
" The list has to be simple quoted ('')\n"
" -s, --set 'var_name=var_value' Sets var_value in the variable var_name\n"
" The string has to be simple quoted ('') to allow\n"
" spaces\n"
" -e --erase 'var_name_list' Removes the list of variables (simple quoted)\n"
" -c --clean Removes all variables\n"
" -a --fileadd file_name Adds variables from file_name. To init the full\n"
" environment from file use -c -a simultaneously\n"
" -h --help Displays usage information\n\n",
cmdname, cmdname, VERSION, env_os_type_to_string());
if (env_onetime_writable()) {
fprintf(stdout, " WARNING: Variables can only be set the first time\n"
" and become read-only afterwards.\n");
}
}
static void show_usage_and_exit(int exit_code)
{
show_usage();
exit(exit_code);
}
static void process_options(int argc, char *argv[])
{
int opt_index, opt, optcount = 0;
static const char *short_options = "?hdcp:s:e:a:";
static const struct option long_options[] = {
{"dump", no_argument, NULL, 'd'},
{"help", no_argument, NULL, 'h'},
{"erase", required_argument, NULL, 'e'},
{"clean", no_argument, NULL, 'c'},
{"fileadd", required_argument, NULL, 'a'},
{"print", required_argument, NULL, 'p'},
{"set", required_argument, NULL, 's'},
{0, 0, 0, 0},
};
for (opt_index = 0;;) {
opt = getopt_long(argc, argv, short_options, long_options, &opt_index);
if (opt == EOF)
break;
switch (opt) {
case 'd':
dump = 1;
break;
case 'p':
printlist = optarg;
break;
case 's':
setstring = optarg;
break;
case 'a':
fileadd = optarg;
break;
case 'e':
eraselist = optarg;
break;
case 'c':
clean = 1;
break;
case 'h':
case '?':
show_usage_and_exit(EXIT_SUCCESS);
break;
}
optcount++;
}
if (optcount == 0)
show_usage_and_exit(EXIT_FAILURE);
/* Check options */
if (dump && (printlist != NULL)) {
fprintf(stderr, "--dump and --print can't be used simultaneously\n");
show_usage_and_exit(EXIT_FAILURE);
}
if (clean && (eraselist != NULL)) {
fprintf(stderr, "--clean and --erase can't be used simultaneously\n");
show_usage_and_exit(EXIT_FAILURE);
}
}
static int env_add_var(const char *varstring, env_t * env, unsigned int envlen)
{
char *nvramCmd[3] = { "set", "network", NULL };
char tmpstr[50];
char *varval;
int j;
if (varstring == NULL)
return -EINVAL;
if (!get_var_name(varstring, tmpstr, VAR_ASIGN))
return -EINVAL;
/* Check if is a special variable */
if ((j = env_have_to_use_nvram(tmpstr)) != -1) {
if ((varval = get_var_value(varstring, excludeVars[j][0], VAR_ASIGN)) != NULL) {
/* Define command to be used by nvram */
sprintf(tmpstr, "%s=%s", excludeVars[j][1], varval);
nvramCmd[2] = tmpstr;
if (!NvCmdLine(3, (const char **)nvramCmd)) {
return -EINVAL;
}
}
} else {
if (!add_var(env->data, env->data + envlen, (char *)varstring)) {
return -EINVAL;
}
}
return 0;
}
static int env_add_vars_from_file(char *filename, env_t * env, unsigned int envlen)
{
FILE *fp;
char line[ENV_MAX_VAR_NAME_LEN + ENV_MAX_VAR_VAL_LEN + 3];
int ret = EXIT_SUCCESS;
if ((fp = fopen(filename, "r")) == NULL)
return -errno;
while (!feof(fp)) {
if (fgets(line, sizeof(line), fp)) {
/* TODO should we remove comments starting with # ?? */
/* Remove '\n' */
if (line[strlen(line) - 1] == '\n')
line[strlen(line) - 1] = 0;
if (env_add_var((const char *)line, env, envlen)) {
fprintf(stderr, "Unable to add environment variable %s\n",
line);
ret = -EINVAL;
goto out;
}
}
}
out:
if (fp)
fclose(fp);
return ret;
}
static void env_remove_varlist(const char *varlist, env_t * env, unsigned int envlen)
{
char *var;
var = strtok((char *)varlist, " ");
while (var != NULL) {
if (!remove_var(env->data, env->data + envlen, var))
fprintf(stderr, "Unable to remove environment variable %s\n", var);
var = strtok(NULL, " ");
}
}
static int env_validate(env_t * env, int datalen, int verbose)
{
unsigned long new_crc;
/* Check stored crc with data */
new_crc = crc32(0, (const unsigned char *)env->data, datalen);
if ((unsigned int)env->crc != new_crc) {
if ( verbose ) {
fprintf(stderr, "CRC failure: got 0x%08x expected 0x%08x\n",
(unsigned int)env->crc, (unsigned int)new_crc);
}
return 1;
}
return 0;
}
static void env_printenv_nvram_vars(char *varname)
{
struct nv_critical *crit;
nv_param_ip_t *ip_params;
int index;
int oneloop = 0;
if (NvCriticalGet(&crit)) {
ip_params = &crit->s.p.xIP;
for (index = 3; index < ARRAY_SIZE(excludeVars); index++) {
if (varname != NULL) {
if ((index = env_have_to_use_nvram(varname)) == -1)
break;
oneloop = 1;
}
switch (index) {
case 3:
fprintf(stdout, "ipaddr=%s\n",
NvToStringIP(ip_params->axDevice[0].uiIP));
break;
case 4:
fprintf(stdout, "ipaddr_wlan=%s\n",
NvToStringIP(ip_params->axDevice[1].uiIP));
break;
case 5:
fprintf(stdout, "ipaddr1=%s\n",
NvToStringIP(crit->s.p.eth1dev.uiIP));
break;
case 6:
fprintf(stdout, "netmask=%s\n",
NvToStringIP(ip_params->axDevice[0].uiNetMask));
break;
case 7:
fprintf(stdout, "netmask_wlan=%s\n",
NvToStringIP(ip_params->axDevice[1].uiNetMask));
break;
case 8:
fprintf(stdout, "netmask1=%s\n",
NvToStringIP(crit->s.p.eth1dev.uiNetMask));
break;
case 9:
fprintf(stdout, "serverip=%s\n",
NvToStringIP(ip_params->uiIPServer));
break;
case 10:
fprintf(stdout, "gatewayip=%s\n",
NvToStringIP(ip_params->uiIPGateway));
break;
case 11:
fprintf(stdout, "dnsip=%s\n",
NvToStringIP(ip_params->auiIPDNS[0]));
break;
case 12:
fprintf(stdout, "dnsip2=%s\n",
NvToStringIP(ip_params->auiIPDNS[1]));
break;
case 13:
fprintf(stdout, "dhcp=%s\n",
(ip_params->axDevice[0].flags.bDHCP ? "on" : "off"));
break;
case 14:
fprintf(stdout, "dhcp_wlan=%s\n",
(ip_params->axDevice[1].flags.bDHCP ? "on" : "off"));
break;
case 15:
fprintf(stdout, "dhcp1=%s\n",
(crit->s.p.eth1dev.flags.bDHCP ? "on" : "off"));
break;
}
if (oneloop)
break;
}
}
}
static void env_printenv(int dump, char *varlist, env_t * env, unsigned int envlen)
{
char *var;
char *data = env->data;
char *varinenv;
if (dump) {
/* print the full environment */
while (data != NULL && *data) {
fprintf(stdout, "%s\n", data);
data = get_next_env_string(data, env->data + envlen);
}
if (envType == NVOS_UBOOT)
env_printenv_nvram_vars(NULL);
return;
} else {
var = strtok((char *)varlist, " ");
while (var != NULL) {
if (envType == NVOS_UBOOT)
env_printenv_nvram_vars(var);
if ((varinenv =
get_var_addr(env->data, env->data + envlen, var)) != NULL) {
fprintf(stdout, "%s\n", varinenv);
}
var = strtok(NULL, " ");
}
}
}
int main(int argc, char *argv[])
{
unsigned int envlen = 0;
env_t *env = NULL;
nv_param_os_cfg_t xCfg;
size_t iSize;
int save_env = 0;
int ret = EXIT_SUCCESS;
int found;
char *cmdstart;
cmdname = argv[0];
cmdname = *argv;
if ((cmdstart = strrchr(cmdname, '/')) != NULL) {
cmdname = cmdstart + 1;
}
if (strcmp(cmdname, APP_UBOOTENV) == 0)
envType = NVOS_UBOOT;
else if (strcmp(cmdname, APP_PRODINFOENV) == 0)
envType = NVOS_PROD_INFO;
else {
fprintf(stderr, "This application can be invoked as:\n"
"%s\n%s\n\n", APP_UBOOTENV, APP_PRODINFOENV);
return EXIT_FAILURE;
}
/* read and process command line */
process_options(argc, argv);
if (!NvInit(NVR_AUTO)) {
fprintf(stderr, "Unable to initialize nvram\n");
return EXIT_FAILURE;
}
found = NvOSCfgFind(&xCfg, envType);
if (!found && clean) {
/* Add missing section to nvram if --clean specified */
if (envDefaultSizes[envType] != 0 ) {
if (!NvOSCfgAdd(envType, envDefaultSizes[envType])) {
fprintf(stderr, "Unable to add missing %s environment to flash\n",
env_os_type_to_string());
return EXIT_FAILURE;
}
/* Try again to find our section */
found = NvOSCfgFind(&xCfg, envType);
}
}
if (!found) {
fprintf(stderr, "Unable to detect %s environment in flash\n",
env_os_type_to_string());
return EXIT_FAILURE;
}
env = malloc(xCfg.uiSize);
if (NULL == env) {
perror("malloc");
return EXIT_FAILURE;
}
memset(env, 0, xCfg.uiSize);
/* Adjust envlen for just for data, crc32 value not included */
envlen = xCfg.uiSize - sizeof(unsigned long);
if (!NvOSCfgGet(envType, (void *)env, xCfg.uiSize, &iSize)) {
/* This can't fail; we either found it, created it, or exited. */
/* But just to be safe... */
fprintf(stderr, "Unable to get %s environment from flash\n",
env_os_type_to_string());
ret = EXIT_FAILURE;
goto free_and_ret;
}
/* Check if env is one-time writable, is valid, and was already written */
if (env_onetime_writable() && !env_validate(env, envlen, 0) &&
!env_is_empty(env, envlen)) {
if ( clean || fileadd || eraselist || setstring ) {
fprintf(stderr, "Environment is one-time writable only\n");
ret = EXIT_FAILURE;
goto free_and_ret;
}
}
if (clean) {
memset(env, 0, xCfg.uiSize);
save_env = 1;
} else {
if (env_validate(env, envlen, 1)) {
fprintf(stderr, "Invalid %s environment found\n",
env_os_type_to_string());
ret = EXIT_FAILURE;
goto free_and_ret;
}
}
if (fileadd != NULL) {
if (env_add_vars_from_file(fileadd, env, envlen) < 0) {
fprintf(stderr, "Unable to add %s environment from file %s\n",
env_os_type_to_string(), fileadd);
ret = EXIT_FAILURE;
goto free_and_ret;
}
save_env = 1;
}
if (eraselist != NULL) {
env_remove_varlist(eraselist, env, envlen);
save_env = 1;
}
if (setstring != NULL) {
if (env_add_var(setstring, env, envlen)) {
fprintf(stderr, "Unable to add environment variable %s\n", setstring);
ret = EXIT_FAILURE;
goto free_and_ret;
}
save_env = 1;
}
if (dump) {
env_printenv(1, NULL, env, envlen);
} else if (printlist != NULL) {
env_printenv(0, printlist, env, envlen);
}
if (save_env) {
/* Compute new crc32 value just in case we are going to update the value in flash */
env->crc = crc32(0, (const unsigned char *)env->data, envlen);
if (!NvOSCfgSet(envType, env, xCfg.uiSize)) {
fprintf(stderr, "Unable to set %s environment to store in flash\n",
env_os_type_to_string());
ret = EXIT_FAILURE;
}
if (!NvSave()) {
fprintf(stderr, "Unable to save %s environment in flash\n",
env_os_type_to_string());
ret = EXIT_FAILURE;
}
}
free_and_ret:
free(env);
return ret;
}

View File

@ -1,26 +0,0 @@
# Copyright (C) 2013,2017 Digi International.
SUMMARY = "Digi's update test utility"
SECTION = "base"
LICENSE = "GPL-2.0"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6"
DEPENDS += "libdigi"
RDEPENDS_${PN}_append_mxs = " kobs-ng"
SRC_URI = "file://update_flash.c \
file://jffs2-user.h \
"
GIT_SHA1 = "$(cd ${THISDIR} && git rev-parse --short HEAD)"
S = "${WORKDIR}"
do_compile() {
${CC} -O2 -Wall ${LDFLAGS} -DGIT_SHA1=\"${GIT_SHA1}\" update_flash.c -o update_flash -ldigi
}
do_install() {
install -d ${D}${bindir}
install -m 0755 update_flash ${D}${bindir}
}

View File

@ -1,33 +0,0 @@
/*
* JFFS2 definitions for use in user space only
*/
#ifndef __JFFS2_USER_H__
#define __JFFS2_USER_H__
/* This file is blessed for inclusion by userspace */
#include <linux/jffs2.h>
#include <endian.h>
#include <byteswap.h>
#undef cpu_to_je16
#undef cpu_to_je32
#undef cpu_to_jemode
#undef je16_to_cpu
#undef je32_to_cpu
#undef jemode_to_cpu
extern int target_endian;
#define t16(x) ({ uint16_t __b = (x); (target_endian==__BYTE_ORDER)?__b:bswap_16(__b); })
#define t32(x) ({ uint32_t __b = (x); (target_endian==__BYTE_ORDER)?__b:bswap_32(__b); })
#define cpu_to_je16(x) ((jint16_t){t16(x)})
#define cpu_to_je32(x) ((jint32_t){t32(x)})
#define cpu_to_jemode(x) ((jmode_t){t32(x)})
#define je16_to_cpu(x) (t16((x).v16))
#define je32_to_cpu(x) (t32((x).v32))
#define jemode_to_cpu(x) (t32((x).m))
#endif /* __JFFS2_USER_H__ */

View File

@ -1,50 +0,0 @@
# Copyright (C) 2013 Digi International.
SUMMARY = "Atheros's wireless driver"
LICENSE = "ISC"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/ISC;md5=f3b90e78ea0cffb20bf5cca7947a896d"
inherit module
SRCREV_external = ""
SRCREV_internal = "50dafb5890180cf33fdb42919c3e6f591d0cd2ea"
SRCREV = "${@base_conditional('DIGI_INTERNAL_GIT', '1' , '${SRCREV_internal}', '${SRCREV_external}', d)}"
SRC_URI_external = "${DIGI_GITHUB_GIT}/atheros.git;protocol=git;nobranch=1"
SRC_URI_internal = "${DIGI_GIT}linux-modules/atheros.git;protocol=git;nobranch=1"
SRC_URI = "${@base_conditional('DIGI_INTERNAL_GIT', '1' , '${SRC_URI_internal}', '${SRC_URI_external}', d)}"
SRC_URI += " \
file://atheros-pre-up \
file://Makefile \
file://0001-atheros-convert-NLA_PUT-macros.patch \
file://0002-atheros-update-renamed-struct-members.patch \
"
S = "${WORKDIR}/git"
EXTRA_OEMAKE += "DEL_PLATFORM=${MACHINE} KLIB_BUILD=${STAGING_KERNEL_DIR}"
do_configure_prepend() {
cp ${WORKDIR}/Makefile ${S}/
}
do_install_append() {
install -d ${D}${sysconfdir}/network/if-pre-up.d
install -m 0755 ${WORKDIR}/atheros-pre-up ${D}${sysconfdir}/network/if-pre-up.d/atheros
install -d ${D}${sysconfdir}/modprobe.d
cat >> ${D}${sysconfdir}/modprobe.d/atheros.conf <<-_EOF_
install ath6kl_sdio true
options ath6kl_sdio ath6kl_p2p=1 softmac_enable=1
_EOF_
}
FILES_${PN} += " \
${sysconfdir}/modprobe.d/ \
${sysconfdir}/network/ \
"
# 'modprobe' from kmod package is needed to load atheros driver. The one
# from busybox does not support '--ignore-install' option.
RDEPENDS_${PN} = "kmod"
COMPATIBLE_MACHINE = "(ccardimx28)"

View File

@ -1,235 +0,0 @@
From: Javier Viguera <javier.viguera@digi.com>
Date: Fri, 13 Sep 2013 11:12:04 +0200
Subject: [PATCH] atheros: update renamed struct members
struct genl_info: s/snd_pid/snd_portid
struct netlink_notify: s/pid/portid
struct netlink_skb_parms: s/pid/portid
Signed-off-by: Javier Viguera <javier.viguera@digi.com>
---
compat-wireless/net/wireless/nl80211.c | 50 ++++++++++++++++----------------
1 file changed, 25 insertions(+), 25 deletions(-)
diff --git a/compat-wireless/net/wireless/nl80211.c b/compat-wireless/net/wireless/nl80211.c
index c219a2ca027f..2cba63866a90 100644
--- a/compat-wireless/net/wireless/nl80211.c
+++ b/compat-wireless/net/wireless/nl80211.c
@@ -1122,7 +1122,7 @@ static int nl80211_dump_wiphy(struct sk_buff *skb, struct netlink_callback *cb)
continue;
if (++idx <= start)
continue;
- if (nl80211_send_wiphy(skb, NETLINK_CB(cb->skb).pid,
+ if (nl80211_send_wiphy(skb, NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq, NLM_F_MULTI,
dev) < 0) {
idx--;
@@ -1145,7 +1145,7 @@ static int nl80211_get_wiphy(struct sk_buff *skb, struct genl_info *info)
if (!msg)
return -ENOMEM;
- if (nl80211_send_wiphy(msg, info->snd_pid, info->snd_seq, 0, dev) < 0) {
+ if (nl80211_send_wiphy(msg, info->snd_portid, info->snd_seq, 0, dev) < 0) {
nlmsg_free(msg);
return -ENOBUFS;
}
@@ -1590,7 +1590,7 @@ static int nl80211_dump_interface(struct sk_buff *skb, struct netlink_callback *
if_idx++;
continue;
}
- if (nl80211_send_iface(skb, NETLINK_CB(cb->skb).pid,
+ if (nl80211_send_iface(skb, NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq, NLM_F_MULTI,
rdev, wdev->netdev) < 0) {
mutex_unlock(&rdev->devlist_mtx);
@@ -1621,7 +1621,7 @@ static int nl80211_get_interface(struct sk_buff *skb, struct genl_info *info)
if (!msg)
return -ENOMEM;
- if (nl80211_send_iface(msg, info->snd_pid, info->snd_seq, 0,
+ if (nl80211_send_iface(msg, info->snd_portid, info->snd_seq, 0,
dev, netdev) < 0) {
nlmsg_free(msg);
return -ENOBUFS;
@@ -1922,7 +1922,7 @@ static int nl80211_get_key(struct sk_buff *skb, struct genl_info *info)
if (!msg)
return -ENOMEM;
- hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0,
+ hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
NL80211_CMD_NEW_KEY);
if (IS_ERR(hdr))
return PTR_ERR(hdr);
@@ -2628,7 +2628,7 @@ static int nl80211_dump_station(struct sk_buff *skb,
goto out_err;
if (nl80211_send_station(skb,
- NETLINK_CB(cb->skb).pid,
+ NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq, NLM_F_MULTI,
netdev, mac_addr,
&sinfo) < 0)
@@ -2674,7 +2674,7 @@ static int nl80211_get_station(struct sk_buff *skb, struct genl_info *info)
if (!msg)
return -ENOMEM;
- if (nl80211_send_station(msg, info->snd_pid, info->snd_seq, 0,
+ if (nl80211_send_station(msg, info->snd_portid, info->snd_seq, 0,
dev, mac_addr, &sinfo) < 0) {
nlmsg_free(msg);
return -ENOBUFS;
@@ -3062,7 +3062,7 @@ static int nl80211_dump_mpath(struct sk_buff *skb,
if (err)
goto out_err;
- if (nl80211_send_mpath(skb, NETLINK_CB(cb->skb).pid,
+ if (nl80211_send_mpath(skb, NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq, NLM_F_MULTI,
netdev, dst, next_hop,
&pinfo) < 0)
@@ -3111,7 +3111,7 @@ static int nl80211_get_mpath(struct sk_buff *skb, struct genl_info *info)
if (!msg)
return -ENOMEM;
- if (nl80211_send_mpath(msg, info->snd_pid, info->snd_seq, 0,
+ if (nl80211_send_mpath(msg, info->snd_portid, info->snd_seq, 0,
dev, dst, next_hop, &pinfo) < 0) {
nlmsg_free(msg);
return -ENOBUFS;
@@ -3337,7 +3337,7 @@ static int nl80211_get_mesh_config(struct sk_buff *skb,
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg)
return -ENOMEM;
- hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0,
+ hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
NL80211_CMD_GET_MESH_CONFIG);
if (!hdr)
goto out;
@@ -3612,7 +3612,7 @@ static int nl80211_get_reg(struct sk_buff *skb, struct genl_info *info)
goto out;
}
- hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0,
+ hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
NL80211_CMD_GET_REG);
if (!hdr)
goto put_failure;
@@ -4216,7 +4216,7 @@ static int nl80211_send_bss(struct sk_buff *msg, struct netlink_callback *cb,
ASSERT_WDEV_LOCK(wdev);
- hdr = nl80211hdr_put(msg, NETLINK_CB(cb->skb).pid, seq, flags,
+ hdr = nl80211hdr_put(msg, NETLINK_CB(cb->skb).portid, seq, flags,
NL80211_CMD_NEW_SCAN_RESULTS);
if (!hdr)
return -1;
@@ -4451,7 +4451,7 @@ static int nl80211_dump_survey(struct sk_buff *skb,
}
if (nl80211_send_survey(skb,
- NETLINK_CB(cb->skb).pid,
+ NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq, NLM_F_MULTI,
netdev,
&survey) < 0)
@@ -5010,7 +5010,7 @@ static int nl80211_testmode_dump(struct sk_buff *skb,
}
while (1) {
- void *hdr = nl80211hdr_put(skb, NETLINK_CB(cb->skb).pid,
+ void *hdr = nl80211hdr_put(skb, NETLINK_CB(cb->skb).portid,
cb->nlh->nlmsg_seq, NLM_F_MULTI,
NL80211_CMD_TESTMODE);
struct nlattr *tmdata;
@@ -5090,7 +5090,7 @@ struct sk_buff *cfg80211_testmode_alloc_reply_skb(struct wiphy *wiphy,
return NULL;
return __cfg80211_testmode_alloc_skb(rdev, approxlen,
- rdev->testmode_info->snd_pid,
+ rdev->testmode_info->snd_portid,
rdev->testmode_info->snd_seq,
GFP_KERNEL);
}
@@ -5427,7 +5427,7 @@ static int nl80211_remain_on_channel(struct sk_buff *skb,
if (!msg)
return -ENOMEM;
- hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0,
+ hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
NL80211_CMD_REMAIN_ON_CHANNEL);
if (IS_ERR(hdr)) {
@@ -5638,7 +5638,7 @@ static int nl80211_register_mgmt(struct sk_buff *skb, struct genl_info *info)
if (!rdev->ops->mgmt_tx)
return -EOPNOTSUPP;
- return cfg80211_mlme_register_mgmt(dev->ieee80211_ptr, info->snd_pid,
+ return cfg80211_mlme_register_mgmt(dev->ieee80211_ptr, info->snd_portid,
frame_type,
nla_data(info->attrs[NL80211_ATTR_FRAME_MATCH]),
nla_len(info->attrs[NL80211_ATTR_FRAME_MATCH]));
@@ -5708,7 +5708,7 @@ static int nl80211_tx_mgmt(struct sk_buff *skb, struct genl_info *info)
if (!msg)
return -ENOMEM;
- hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0,
+ hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
NL80211_CMD_FRAME);
if (IS_ERR(hdr)) {
@@ -5820,7 +5820,7 @@ static int nl80211_get_power_save(struct sk_buff *skb, struct genl_info *info)
if (!msg)
return -ENOMEM;
- hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0,
+ hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
NL80211_CMD_GET_POWER_SAVE);
if (!hdr) {
err = -ENOBUFS;
@@ -5998,7 +5998,7 @@ static int nl80211_get_wowlan(struct sk_buff *skb, struct genl_info *info)
if (!msg)
return -ENOMEM;
- hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0,
+ hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
NL80211_CMD_GET_WOWLAN);
if (!hdr)
goto nla_put_failure;
@@ -6281,7 +6281,7 @@ static int nl80211_register_unexpected_frame(struct sk_buff *skb,
if (wdev->ap_unexpected_nlpid)
return -EBUSY;
- wdev->ap_unexpected_nlpid = info->snd_pid;
+ wdev->ap_unexpected_nlpid = info->snd_portid;
return 0;
}
@@ -6311,7 +6311,7 @@ static int nl80211_probe_client(struct sk_buff *skb,
if (!msg)
return -ENOMEM;
- hdr = nl80211hdr_put(msg, info->snd_pid, info->snd_seq, 0,
+ hdr = nl80211hdr_put(msg, info->snd_portid, info->snd_seq, 0,
NL80211_CMD_PROBE_CLIENT);
if (IS_ERR(hdr)) {
@@ -6349,7 +6349,7 @@ static int nl80211_register_beacons(struct sk_buff *skb, struct genl_info *info)
if (rdev->ap_beacons_nlpid)
return -EBUSY;
- rdev->ap_beacons_nlpid = info->snd_pid;
+ rdev->ap_beacons_nlpid = info->snd_portid;
return 0;
}
@@ -8357,8 +8357,8 @@ static int nl80211_netlink_notify(struct notifier_block * nb,
list_for_each_entry_rcu(rdev, &cfg80211_rdev_list, list) {
list_for_each_entry_rcu(wdev, &rdev->netdev_list, list)
- cfg80211_mlme_unregister_socket(wdev, notify->pid);
- if (rdev->ap_beacons_nlpid == notify->pid)
+ cfg80211_mlme_unregister_socket(wdev, notify->portid);
+ if (rdev->ap_beacons_nlpid == notify->portid)
rdev->ap_beacons_nlpid = 0;
}

View File

@ -1,42 +0,0 @@
ATH_DRV_BASEDIR := compat-wireless
ifneq ($(KERNELRELEASE),)
ATH_DEFINES += \
-DCOMPAT_BASE_TREE="\"$(shell cat $(src)/$(ATH_DRV_BASEDIR)/compat_base_tree)\"" \
-DCOMPAT_BASE_TREE_VERSION="\"$(shell cat $(src)/$(ATH_DRV_BASEDIR)/compat_base_tree_version)\"" \
-DCOMPAT_PROJECT="\"Compat-wireless\"" \
-DCOMPAT_VERSION="\"$(shell cat $(src)/$(ATH_DRV_BASEDIR)/compat_version)\""
NOSTDINC_FLAGS := -I$(M)/$(ATH_DRV_BASEDIR)/include/ \
-include $(M)/$(ATH_DRV_BASEDIR)/include/linux/compat-2.6.h \
$(ATH_DEFINES)
include $(src)/$(ATH_DRV_BASEDIR)/config.mk
SHELL_EXPORT := PATH=$(src)/$(ATH_DRV_BASEDIR)/scripts:$${PATH} \
COMPAT_CONFIG=$(src)/$(ATH_DRV_BASEDIR)/config.mk \
CONFIG_CHECK=.$(COMPAT_CONFIG)_md5sum.txt \
COMPAT_AUTOCONF=$(src)/$(ATH_DRV_BASEDIR)/include/linux/compat_autoconf.h
dummy := $(shell $(SHELL_EXPORT) bash -c "cd $(src)/$(ATH_DRV_BASEDIR) && ./scripts/check_config.sh || true")
obj-y := $(ATH_DRV_BASEDIR)/compat/
obj-y += $(ATH_DRV_BASEDIR)/net/wireless/
obj-y += $(ATH_DRV_BASEDIR)/drivers/net/wireless/ath/ath6kl/
else #ifneq ($(KERNELRELEASE),)
SRC := $(shell pwd)
all:
$(MAKE) -C $(KERNEL_SRC) M=$(SRC)
modules_install:
$(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules_install
# Fix installation directory of the modules.
find $(INSTALL_MOD_PATH)/lib/modules/$(KERNEL_VERSION)/extra/$(ATH_DRV_BASEDIR) -type f -name '*.ko' | \
xargs -I modfile mv -f modfile $(INSTALL_MOD_PATH)/lib/modules/$(KERNEL_VERSION)/extra/
rm -rf $(INSTALL_MOD_PATH)/lib/modules/*/extra/$(ATH_DRV_BASEDIR)
endif #ifneq ($(KERNELRELEASE),)

View File

@ -1,139 +0,0 @@
#!/bin/sh
#===============================================================================
#
# 10-atheros_pre-up
#
# Copyright (C) 2012 by Digi International Inc.
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as published by
# the Free Software Foundation.
#
#
# !Description: Load Atheros' wireless driver
#
#===============================================================================
set -e
[ "${IFACE}" != "wlan0" ] && exit 0
FIRMWARE_DIR="/lib/firmware/ath6k/AR6003/hw2.1.1"
ATH6KL_DBG_NONE=0x0
ATH6KL_DBG_CREDIT=0x00000001
ATH6KL_DBG_WLAN_TX=0x00000004
ATH6KL_DBG_WLAN_RX=0x00000008
ATH6KL_DBG_BMI=0x00000010
ATH6KL_DBG_HTC=0x00000020
ATH6KL_DBG_HIF=0x00000040
ATH6KL_DBG_IRQ=0x00000080
ATH6KL_DBG_WMI=0x00000400
ATH6KL_DBG_TRC=0x00000800
ATH6KL_DBG_SCATTER=0x00001000
ATH6KL_DBG_WLAN_CFG=0x00002000
ATH6KL_DBG_RAW_BYTES=0x00004000
ATH6KL_DBG_AGGR=0x00008000
ATH6KL_DBG_SDIO=0x00010000
ATH6KL_DBG_SDIO_DUMP=0x00020000
ATH6KL_DBG_BOOT=0x00040000
ATH6KL_DBG_WMI_DUMP=0x00080000
ATH6KL_DBG_SUSPEND=0x00100000
ATH6KL_DBG_USB=0x00200000
ATH6KL_DBG_RECOVERY=0x00400000
ATH6KL_DBG_ANY=0xffffffff
ATH6KL_DEBUG_MASK="${ATH6KL_DBG_NONE}"
#
# Get the wlan MAC address from kernel command line. Use a default
# value if the address has not been set.
#
if [ -f "/proc/device-tree/wireless/mac-address" ]; then
MAC_ADDR="$(hexdump -ve '1/1 "%02X" ":"' /proc/device-tree/wireless/mac-address | sed 's/:$//g')"
else
MAC_ADDR="$(sed -ne 's,^.*ethaddr2=\([^[:blank:]]\+\)[:blank:]*.*,\1,g;T;p' /proc/cmdline)"
fi
if [ -z "${MAC_ADDR}" -o "${MAC_ADDR}" = "00:00:00:00:00:00" ]; then
MAC_ADDR="00:04:F3:4C:B1:D3"
fi
# We need to write the WLAN MAC address to softmac in the ath6k firmware
# directory. However, we don't want to rewrite the file if it already exists
# and the address is the same because we don't want to wear out NAND flash.
#
# So create the file on the RAM DRIVE first and compare the two. Only update
# the copy on NAND if the address has changed.
#
mac1="$(echo ${MAC_ADDR} | cut -d':' -f1)"
mac2="$(echo ${MAC_ADDR} | cut -d':' -f2)"
mac3="$(echo ${MAC_ADDR} | cut -d':' -f3)"
mac4="$(echo ${MAC_ADDR} | cut -d':' -f4)"
mac5="$(echo ${MAC_ADDR} | cut -d':' -f5)"
mac6="$(echo ${MAC_ADDR} | cut -d':' -f6)"
TMP_MACFILE="$(mktemp -t softmac.XXXXXX)"
printf "\x${mac1}\x${mac2}\x${mac3}\x${mac4}\x${mac5}\x${mac6}" > ${TMP_MACFILE}
if ! cmp -s ${TMP_MACFILE} ${FIRMWARE_DIR}/softmac; then
cp ${TMP_MACFILE} ${FIRMWARE_DIR}/softmac
fi
rm -f ${TMP_MACFILE}
# Figure out which wireless region we are in. The US has rules for
# what channels can be used and at what power level. We use a different set of
# rules for the other regions in the world that we sell into. The mod_cert field
# in OTP will be set to 0x0 for the US. Once we know the region, make sure the
# appropriate calibration file is loaded.
#
MACHINE="$(cat /proc/device-tree/digi,machine,name 2>/dev/null || \
cat /sys/kernel/machine/name)"
MOD_VARIANT="$(cat /proc/device-tree/digi,hwid,variant 2>/dev/null || \
cat /sys/kernel/${MACHINE}/mod_variant)"
REGION_CODE="$(cat /proc/device-tree/digi,hwid,cert 2>/dev/null || \
cat /sys/kernel/${MACHINE}/mod_cert)"
# 'ccimx6sbc' variants 0x05, 0x07 and 0x0a do not have bluetooth
# and use a different calibration file
US_CODE="0x0"
case "${MACHINE}:${MOD_VARIANT}:${REGION_CODE}" in
ccimx6sbc:0x05:${US_CODE}|ccimx6sbc:0x07:${US_CODE}|ccimx6sbc:0x0a:${US_CODE})
BDATA_SOURCE="Digi_6203_2_ANT-US.bin"
logger -t atheros "Setting US wireless region (no bluetooth)";;
ccimx6sbc:0x05:*|ccimx6sbc:0x07:*|ccimx6sbc:0x0a:*)
BDATA_SOURCE="Digi_6203_2_ANT-World.bin"
logger -t atheros "Setting non-US (world) wireless region (no bluetooth)";;
*:*:${US_CODE})
BDATA_SOURCE="Digi_6203-6233-US.bin"
logger -t atheros "Setting US wireless region";;
*:*:*)
BDATA_SOURCE="Digi_6203-6233-World.bin"
logger -t atheros "Setting non-US (world) wireless region";;
esac
# We don't want to rewrite NAND every time we boot so only
# change the link if it is wrong.
BDATA_LINK="${FIRMWARE_DIR}/bdata.bin"
if [ ! -e "${BDATA_LINK}" ] || ! cmp -s "${BDATA_LINK}" "${FIRMWARE_DIR}/${BDATA_SOURCE}"; then
ln -sf "${BDATA_SOURCE}" "${BDATA_LINK}"
fi
# Load 'cfg80211' and let it settle down (needed by 'ath6kl_sdio')
modprobe -q cfg80211 && sleep 0.2
# ath6kl_sdio.ko
if ! grep -qs ath6kl_sdio /proc/modules; then
RETRIES="5"
while [ "${RETRIES}" -gt "0" ]; do
modprobe --ignore-install -q ath6kl_sdio debug_mask="${ATH6KL_DEBUG_MASK}" || true
[ -d "/sys/class/net/wlan0" ] && break
RETRIES="$((RETRIES - 1))"
rmmod ath6kl_sdio > /dev/null
echo "Retrying to load wireless"
sleep 2
done
[ "${RETRIES}" -eq "0" ] && echo "Loading ath6kl_sdio module: [FAILED]"
fi
# Delay required for the interface 'wlan0' to settle down before trying to configure it.
sleep 0.5

View File

@ -1,212 +0,0 @@
# CONFIG_SWAP is not set
CONFIG_SYSVIPC=y
CONFIG_NO_HZ=y
CONFIG_HIGH_RES_TIMERS=y
CONFIG_IKCONFIG=y
CONFIG_IKCONFIG_PROC=y
# CONFIG_UTS_NS is not set
# CONFIG_IPC_NS is not set
# CONFIG_PID_NS is not set
# CONFIG_NET_NS is not set
CONFIG_RELAY=y
CONFIG_BLK_DEV_INITRD=y
CONFIG_PERF_EVENTS=y
# CONFIG_COMPAT_BRK is not set
CONFIG_MODULES=y
CONFIG_MODULE_FORCE_LOAD=y
CONFIG_MODULE_UNLOAD=y
CONFIG_MODVERSIONS=y
CONFIG_BLK_DEV_INTEGRITY=y
# CONFIG_IOSCHED_DEADLINE is not set
# CONFIG_IOSCHED_CFQ is not set
# CONFIG_ARCH_MULTI_V7 is not set
CONFIG_ARCH_MXS=y
# CONFIG_ARM_THUMB is not set
CONFIG_PREEMPT_VOLUNTARY=y
CONFIG_AEABI=y
CONFIG_CPU_FREQ=y
CONFIG_CPU_FREQ_GOV_POWERSAVE=y
CONFIG_CPU_FREQ_GOV_USERSPACE=y
CONFIG_CPU_FREQ_GOV_ONDEMAND=y
CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
CONFIG_FPE_NWFPE=y
CONFIG_NET=y
CONFIG_PACKET=y
CONFIG_UNIX=y
CONFIG_INET=y
CONFIG_IP_PNP=y
CONFIG_IP_PNP_DHCP=y
CONFIG_SYN_COOKIES=y
# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
# CONFIG_INET_XFRM_MODE_TUNNEL is not set
# CONFIG_INET_XFRM_MODE_BEET is not set
# CONFIG_INET_LRO is not set
# CONFIG_INET_DIAG is not set
# CONFIG_IPV6 is not set
CONFIG_BRIDGE=y
CONFIG_NET_SCHED=y
CONFIG_CAN=y
# CONFIG_CAN_GW is not set
CONFIG_CAN_FLEXCAN=y
CONFIG_BT=y
CONFIG_BT_RFCOMM=y
CONFIG_BT_RFCOMM_TTY=y
CONFIG_BT_BNEP=y
CONFIG_BT_BNEP_MC_FILTER=y
CONFIG_BT_BNEP_PROTO_FILTER=y
CONFIG_BT_HIDP=y
CONFIG_BT_HCIUART=y
CONFIG_BT_HCIUART_ATH3K=y
CONFIG_WIRELESS_EXT=y
CONFIG_RFKILL=y
CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
# CONFIG_FIRMWARE_IN_KERNEL is not set
# CONFIG_FW_LOADER_USER_HELPER is not set
CONFIG_MTD=y
CONFIG_MTD_CMDLINE_PARTS=y
CONFIG_MTD_BLOCK=y
CONFIG_MTD_SST25L=y
CONFIG_MTD_NAND=y
CONFIG_MTD_NAND_GPMI_NAND=y
CONFIG_MTD_UBI=y
CONFIG_PROC_DEVICETREE=y
CONFIG_BLK_DEV_LOOP=y
CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_RAM_SIZE=16384
CONFIG_SRAM=y
CONFIG_EEPROM_AT24=y
CONFIG_SCSI=y
CONFIG_BLK_DEV_SD=y
# CONFIG_SCSI_LOWLEVEL is not set
CONFIG_NETDEVICES=y
# CONFIG_NET_CADENCE is not set
# CONFIG_NET_VENDOR_BROADCOM is not set
# CONFIG_NET_VENDOR_CIRRUS is not set
# CONFIG_NET_VENDOR_FARADAY is not set
# CONFIG_NET_VENDOR_INTEL is not set
# CONFIG_NET_VENDOR_MARVELL is not set
# CONFIG_NET_VENDOR_MICREL is not set
# CONFIG_NET_VENDOR_MICROCHIP is not set
# CONFIG_NET_VENDOR_NATSEMI is not set
# CONFIG_NET_VENDOR_SEEQ is not set
# CONFIG_NET_VENDOR_SMSC is not set
# CONFIG_NET_VENDOR_STMICRO is not set
# CONFIG_NET_VENDOR_WIZNET is not set
CONFIG_SMSC_PHY=y
CONFIG_ICPLUS_PHY=y
CONFIG_REALTEK_PHY=y
CONFIG_MICREL_PHY=y
CONFIG_USB_USBNET=y
CONFIG_USB_NET_SMSC95XX=y
# CONFIG_WLAN is not set
# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
CONFIG_INPUT_EVDEV=y
# CONFIG_KEYBOARD_ATKBD is not set
CONFIG_KEYBOARD_MXS_PSWITCH=y
# CONFIG_INPUT_MOUSE is not set
# CONFIG_SERIO is not set
CONFIG_VT_HW_CONSOLE_BINDING=y
CONFIG_DEVPTS_MULTIPLE_INSTANCES=y
# CONFIG_LEGACY_PTYS is not set
# CONFIG_DEVKMEM is not set
CONFIG_SERIAL_AMBA_PL011=y
CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
CONFIG_SERIAL_MXS_AUART=y
# CONFIG_HW_RANDOM is not set
CONFIG_I2C=y
# CONFIG_I2C_COMPAT is not set
CONFIG_I2C_CHARDEV=y
CONFIG_I2C_MXS=y
CONFIG_SPI=y
CONFIG_SPI_GPIO=y
CONFIG_SPI_MXS=y
CONFIG_SPI_SPIDEV=y
CONFIG_GPIO_SYSFS=y
CONFIG_W1=y
CONFIG_W1_MASTER_DS2482=y
CONFIG_W1_SLAVE_DS2431=y
# CONFIG_HWMON is not set
CONFIG_WATCHDOG=y
CONFIG_STMP3XXX_RTC_WATCHDOG=y
CONFIG_REGULATOR=y
CONFIG_REGULATOR_FIXED_VOLTAGE=y
CONFIG_FB=y
CONFIG_FB_MXS=y
CONFIG_BACKLIGHT_LCD_SUPPORT=y
CONFIG_LCD_CLASS_DEVICE=y
CONFIG_BACKLIGHT_CLASS_DEVICE=y
CONFIG_BACKLIGHT_PWM=y
CONFIG_FRAMEBUFFER_CONSOLE=y
CONFIG_FONTS=y
CONFIG_LOGO=y
CONFIG_FB_LOGO_CENTERED=y
CONFIG_SOUND=y
CONFIG_SND=y
CONFIG_SND_MIXER_OSS=y
CONFIG_SND_PCM_OSS=y
CONFIG_SND_DYNAMIC_MINORS=y
# CONFIG_SND_DRIVERS is not set
# CONFIG_SND_ARM is not set
# CONFIG_SND_SPI is not set
# CONFIG_SND_USB is not set
CONFIG_SND_SOC=y
CONFIG_SND_MXS_SOC=y
CONFIG_SND_SOC_MXS_SGTL5000=y
CONFIG_USB=y
CONFIG_USB_EHCI_HCD=y
CONFIG_USB_STORAGE=y
CONFIG_USB_CHIPIDEA=y
CONFIG_USB_CHIPIDEA_UDC=y
CONFIG_USB_CHIPIDEA_HOST=y
CONFIG_USB_PHY=y
CONFIG_USB_MXS_PHY=y
CONFIG_USB_GADGET=y
CONFIG_USB_ETH=m
CONFIG_USB_MASS_STORAGE=m
CONFIG_USB_G_SERIAL=m
CONFIG_MMC=y
CONFIG_MMC_UNSAFE_RESUME=y
CONFIG_MMC_MXS=y
CONFIG_RTC_CLASS=y
CONFIG_RTC_DRV_STMP=y
CONFIG_DMADEVICES=y
CONFIG_MXS_DMA=y
CONFIG_STAGING=y
CONFIG_MXS_LRADC=y
CONFIG_IIO_SYSFS_TRIGGER=y
CONFIG_COMMON_CLK_DEBUG=y
CONFIG_IIO=y
CONFIG_PWM=y
CONFIG_PWM_MXS=y
CONFIG_EXT2_FS=y
CONFIG_EXT2_FS_XATTR=y
CONFIG_EXT3_FS=y
CONFIG_EXT4_FS=y
# CONFIG_DNOTIFY is not set
CONFIG_VFAT_FS=y
CONFIG_TMPFS=y
CONFIG_TMPFS_POSIX_ACL=y
CONFIG_JFFS2_FS=y
CONFIG_JFFS2_COMPRESSION_OPTIONS=y
CONFIG_JFFS2_LZO=y
CONFIG_JFFS2_RUBIN=y
CONFIG_UBIFS_FS=y
CONFIG_UBIFS_FS_ADVANCED_COMPR=y
CONFIG_NFS_FS=y
CONFIG_NFS_V3_ACL=y
CONFIG_NFS_V4=y
CONFIG_ROOT_NFS=y
CONFIG_NLS_CODEPAGE_437=y
CONFIG_NLS_CODEPAGE_850=y
CONFIG_NLS_ISO8859_1=y
CONFIG_NLS_ISO8859_15=y
CONFIG_PRINTK_TIME=y
CONFIG_FRAME_WARN=2048
CONFIG_UNUSED_SYMBOLS=y
CONFIG_DEBUG_KERNEL=y
# CONFIG_FTRACE is not set
# CONFIG_ARM_UNWIND is not set
# CONFIG_CRYPTO_MANAGER_DISABLE_TESTS is not set
# CONFIG_CRYPTO_ANSI_CPRNG is not set
# CONFIG_CRYPTO_HW is not set

View File

@ -1,61 +0,0 @@
# Copyright (C) 2012 Digi International
require recipes-kernel/linux/linux-dey.inc
require recipes-kernel/linux/linux-dtb.inc
SRCBRANCH = "v3.10/dey-1.4/maint"
SRCREV = "${AUTOREV}"
config_dts() {
for DTB in ${KERNEL_DEVICETREE}; do
if [ "${1}" = "enable" ]; then
sed -i -e "/${2}/{s,^///include,/include,g}" ${S}/arch/arm/boot/dts/${DTB%b}s
elif [ "${1}" = "disable" ]; then
sed -i -e "/${2}/{s,^/include,///include,g}" ${S}/arch/arm/boot/dts/${DTB%b}s
fi
done
}
do_update_dts() {
if [ -n "${HAVE_WIFI}" ]; then
config_dts enable '_ssp2_mmc_wifi.dtsi'
else
config_dts disable '_ssp2_mmc_wifi.dtsi'
fi
if [ -n "${HAVE_SECOND_ETH}" ]; then
config_dts enable '_ethernet1.dtsi'
else
config_dts disable '_ethernet1.dtsi'
fi
if [ -n "${HAVE_BT}" ]; then
config_dts enable '_auart0_bluetooth.dtsi'
else
config_dts disable '_auart0_bluetooth.dtsi'
fi
if [ -n "${HAVE_1WIRE}" ]; then
config_dts enable '_onewire_i2c1.dtsi'
config_dts disable '_auart2_4wires.dtsi'
else
config_dts disable '_onewire_i2c1.dtsi'
fi
if [ -n "${HAVE_GUI}" ]; then
# Enable LCD
config_dts enable '_display_'
config_dts disable '_auart1_'
# Enable touch
config_dts enable '_lradc_touchscreen'
config_dts disable '_ssp1_'
config_dts disable '_auart1_4wires'
config_dts disable '_ethernet0_leds'
else
# spidev conflicts with touchscreen, thus enable it only
# when touch is disabled
if [ -n "${HAVE_EXAMPLE}" ]; then
config_dts enable 'ssp1_spi_gpio.dtsi'
config_dts enable 'ssp1_spi_gpio_spidev.dtsi'
fi
fi
}
addtask update_dts before do_install after do_sizecheck
COMPATIBLE_MACHINE = "(ccardimx28)"

View File

@ -1,74 +0,0 @@
From: Javier Viguera <javier.viguera@digi.com>
Date: Thu, 31 Jan 2013 11:23:37 +0100
Subject: [PATCH] enable-libnl3
Signed-off-by: Javier Viguera <javier.viguera@digi.com>
---
Makefile | 7 ++++++-
nl80211_utils.c | 4 ++--
nl80211_utils.h | 2 +-
3 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index 115ad33..6c21413 100644
--- a/Makefile
+++ b/Makefile
@@ -56,17 +56,22 @@ LIBS= -ldbus-1 -lpthread -lrt -lbluetooth
NL1FOUND := $(shell $(PKG_CONFIG) --atleast-version=1 libnl-1 && echo Y)
NL2FOUND := $(shell $(PKG_CONFIG) --atleast-version=2 libnl-2.0 && echo Y)
+NL3FOUND := $(shell $(PKG_CONFIG) --atleast-version=3 libnl-3.0 && echo Y)
ifeq ($(NL1FOUND),Y)
+CFLAGS += -DCONFIG_LIBNL1
NLLIBNAME = libnl-1
endif
ifeq ($(NL2FOUND),Y)
-CFLAGS += -DCONFIG_LIBNL20
LIBS += -lnl-genl
NLLIBNAME = libnl-2.0
endif
+ifeq ($(NL3FOUND),Y)
+NLLIBNAME = libnl-3.0
+endif
+
#ifeq ($(NLLIBNAME),)
#$(error Cannot find development files for any supported version of libnl)
#endif
diff --git a/nl80211_utils.c b/nl80211_utils.c
index 4689044..2957f2e 100644
--- a/nl80211_utils.c
+++ b/nl80211_utils.c
@@ -9,7 +9,7 @@
#include <net/if.h>
#include "nl80211_utils.h"
-#ifndef CONFIG_LIBNL20
+#ifdef CONFIG_LIBNL1
/* libnl 2.0 compatibility code */
static inline int __genl_ctrl_alloc_cache(struct nl_sock *h, struct nl_cache **cache)
@@ -24,7 +24,7 @@ static inline int __genl_ctrl_alloc_cache(struct nl_sock *h, struct nl_cache **c
#define nl_socket_alloc nl_handle_alloc
#define nl_socket_free nl_handle_destroy
-#endif /* CONFIG_LIBNL20 */
+#endif /* CONFIG_LIBNL1 */
int iw_debug = 0;
diff --git a/nl80211_utils.h b/nl80211_utils.h
index 6a0dbd7..6bbeb2c 100644
--- a/nl80211_utils.h
+++ b/nl80211_utils.h
@@ -11,7 +11,7 @@
#include <netlink/genl/family.h>
#include <netlink/genl/ctrl.h>
-#ifndef CONFIG_LIBNL20
+#ifdef CONFIG_LIBNL1
#define nl_sock nl_handle
#endif

View File

@ -1,85 +0,0 @@
From: Javier Viguera <javier.viguera@digi.com>
Date: Tue, 16 Apr 2013 18:46:31 +0200
Subject: [PATCH] cross-compile
Signed-off-by: Javier Viguera <javier.viguera@digi.com>
---
Makefile | 43 +++++++++++++++++++++++++++----------------
1 file changed, 27 insertions(+), 16 deletions(-)
diff --git a/Makefile b/Makefile
index 6c21413..91659dd 100644
--- a/Makefile
+++ b/Makefile
@@ -25,13 +25,13 @@ SBINDIR ?= $(PREFIX)/sbin
MANDIR ?= $(PREFIX)/share/man
PKG_CONFIG ?= pkg-config
-ifdef V210
-CC= $(ATH_CROSS_COMPILE_TYPE)gcc
-LD= $(ATH_CROSS_COMPILE_TYPE)ld
-else
-CC= $(ATH_CROSSS_COMPILE_TYPE)gcc
-LD= $(ATH_CROSSS_COMPILE_TYPE)ld
-endif
+# ifdef V210
+# CC= $(ATH_CROSS_COMPILE_TYPE)gcc
+# LD= $(ATH_CROSS_COMPILE_TYPE)ld
+# else
+# CC= $(ATH_CROSSS_COMPILE_TYPE)gcc
+# LD= $(ATH_CROSSS_COMPILE_TYPE)ld
+# endif
SOURCES=abtfilt_main.c \
abtfilt_wlan.c \
abtfilt_core.c \
@@ -40,19 +40,19 @@ SOURCES=abtfilt_main.c \
nl80211_utils.c\
btfilter_core.c
-INCLUDES= -Iinclude \
+override INCLUDES += -Iinclude \
-Ios/linux/include \
- -Icommon/include \
- -I$(V210_DIR)/usr/include/dbus-1.0/ \
- -I$(V210_DIR)/usr/lib/dbus-1.0/include \
- -I$(V210_DIR)/usr/local/include/dbus-1.0 \
- -I$(V210_DIR)/usr/local/lib/dbus-1.0/include \
- -I$(V210_DIR)/usr/include/bluetooth \
- -I$(V210_DIR)/usr/local/include/bluetooth \
+ -Icommon/include
+# -I$(V210_DIR)/usr/include/dbus-1.0/ \
+# -I$(V210_DIR)/usr/lib/dbus-1.0/include \
+# -I$(V210_DIR)/usr/local/include/dbus-1.0 \
+# -I$(V210_DIR)/usr/local/lib/dbus-1.0/include \
+# -I$(V210_DIR)/usr/include/bluetooth \
+# -I$(V210_DIR)/usr/local/include/bluetooth \
CFLAGS= -Wall -g -DABF_DEBUG
#LIBS= -ldbus-1 -lpthread -lbtfilt -lrt -lbluetooth
-LIBS= -ldbus-1 -lpthread -lrt -lbluetooth
+# LIBS= -ldbus-1 -lpthread -lrt -lbluetooth
NL1FOUND := $(shell $(PKG_CONFIG) --atleast-version=1 libnl-1 && echo Y)
NL2FOUND := $(shell $(PKG_CONFIG) --atleast-version=2 libnl-2.0 && echo Y)
@@ -79,6 +79,13 @@ endif
LIBS += $(shell $(PKG_CONFIG) --libs $(NLLIBNAME))
CFLAGS += $(shell $(PKG_CONFIG) --cflags $(NLLIBNAME))
+# dbus
+LIBS += $(shell $(PKG_CONFIG) --libs --static dbus-1)
+CFLAGS += $(shell $(PKG_CONFIG) --cflags dbus-1)
+
+# BlueZ
+LIBS += $(shell $(PKG_CONFIG) --libs bluez)
+CFLAGS += $(shell $(PKG_CONFIG) --cflags bluez)
ifdef BOARD_HAS_ATH_WLAN_AR6004
CFLAGS += -DMULTI_WLAN_CHAN_SUPPORT
@@ -124,3 +131,7 @@ all: $(OBJECTS)
clean:
rm -f $(FILTERAPP) $(OBJECTS)
+
+install:
+ mkdir -p $(DESTDIR)$(SBINDIR)
+ install -m 0755 $(FILTERAPP) $(DESTDIR)$(SBINDIR)

View File

@ -1,127 +0,0 @@
From 641f02fe3638d291a0ef53c076bda7e68e2f7d28 Mon Sep 17 00:00:00 2001
From: Alex Gonzalez <alex.gonzalez@digi.com>
Date: Tue, 26 Aug 2014 16:57:14 +0200
Subject: [PATCH] abtfilt_wan: Rewrite the netlink listener.
Not sure how old this code is but it is not working properly any more.
Not only it incorrectly detects the netlink messages as corrupted, but it
also assumes an RTM_DELLINK will be issued for the link down event which
is not correct.
I have updated the code trying to touch as little things as possible.
Signed-off-by: Alex Gonzalez <alex.gonzalez@digi.com>
---
abtfilt_wlan.c | 87 +++++++++++++++++++++++++++++++++++++---------------------
1 file changed, 56 insertions(+), 31 deletions(-)
diff --git a/abtfilt_wlan.c b/abtfilt_wlan.c
index b1966cef7ef2..64dffde37f19 100644
--- a/abtfilt_wlan.c
+++ b/abtfilt_wlan.c
@@ -232,6 +232,59 @@ Abf_WlanDispatchIO(ATHBT_FILTER_INFO *pInfo, unsigned long int req,
return A_OK;
}
+static void
+print_link(struct ifinfomsg *ifi, int len, int up)
+{
+ struct rtattr *attrib;
+
+ for(attrib = IFLA_RTA(ifi); RTA_OK(attrib, len);
+ attrib = RTA_NEXT(attrib, len)) {
+ switch(attrib->rta_type) {
+ case IFLA_IFNAME:
+ A_DEBUG("[%d:%s] Link %s\n", ifi->ifi_index,
+ (char *)RTA_DATA(attrib), up ? "UP" : "DOWN");
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+static void
+parse_message(ATH_BT_FILTER_INSTANCE *pInstance, int len, char *buf)
+{
+ struct nlmsghdr *msg_ptr;
+ struct ifinfomsg *ifi;
+ int len1;
+
+ for(msg_ptr = (struct nlmsghdr *)buf; NLMSG_OK(msg_ptr, len);
+ msg_ptr = NLMSG_NEXT(msg_ptr, len)) {
+ /* Finish reading */
+ if(msg_ptr->nlmsg_type == NLMSG_DONE)
+ break;
+
+ /* Message is some kind of error */
+ if(msg_ptr->nlmsg_type == NLMSG_ERROR) {
+ A_ERR("Message is an error.\n");
+ break;
+ }
+
+ if(msg_ptr->nlmsg_type == RTM_NEWLINK) {
+ ifi = NLMSG_DATA(msg_ptr);
+ len1 = msg_ptr->nlmsg_len - NLMSG_LENGTH(sizeof(*ifi));
+ if(ifi->ifi_flags & IFF_RUNNING){
+ print_link(ifi, len1, 1);
+ NewLinkEvent(pInstance, msg_ptr, len1);
+ }
+ else {
+ print_link(ifi, len1, 0);
+ DelLinkEvent(pInstance, msg_ptr, len1);
+ }
+ break;
+ }
+ }
+}
+
/* Internal functions */
static void *
WlanEventThread(void *arg)
@@ -322,41 +375,13 @@ WlanEventThread(void *arg)
} while (left == -1 && errno == EINTR);
if (left < 0) {
- A_ERR("[%s] recvfrom(netlink)\n", __FUNCTION__);
+ A_ERR("[%s] recvfrom(netlink) error %d\n", __FUNCTION__,
+ left);
continue;
// break;
}
- h = (struct nlmsghdr *) buf;
- while (left >= (int)sizeof(*h)) {
- int len, plen;
-
- len = h->nlmsg_len;
- plen = len - sizeof(*h);
- if (len > left || plen < 0) {
- A_ERR("[%s] malformed netlink message\n", __FUNCTION__);
- continue;
- }
-
- //A_DEBUG("RTM Message Type: %s\n",
- // ((h->nlmsg_type == RTM_NEWLINK) ?
- // "RTM_NEWLINK" : ((h->nlmsg_type == RTM_DELLINK) ?
- // "RTM_DELLINK" : "RTM_OTHER")));
- switch (h->nlmsg_type) {
- case RTM_NEWLINK:
- NewLinkEvent(pInstance, h, plen);
- break;
- case RTM_DELLINK:
- DelLinkEvent(pInstance, h, plen);
- break;
- default:
- break;
- }
-
- len = NLMSG_ALIGN(len);
- left -= len;
- h = (struct nlmsghdr *) ((char *) h + len);
- }
+ parse_message(pInstance, left, buf);
}
}

View File

@ -1,29 +0,0 @@
From d631ddd830cfacf610a562b52fc953b14dff7962 Mon Sep 17 00:00:00 2001
From: Isaac Hermida <isaac.hermida@digi.com>
Date: Fri, 6 Nov 2015 17:46:33 +0100
Subject: [PATCH] add -fgnu89-inline flag for gcc5
The problem is the change of the default C standard from gnu89 to gnu11
which changes the semantics of 'inline'. The issue is described in the
Porting guide at https://gcc.gnu.org/gcc-5/porting_to.html.
---
Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 91659ddb788c..1e2e1d6b0584 100644
--- a/Makefile
+++ b/Makefile
@@ -50,7 +50,7 @@ override INCLUDES += -Iinclude \
# -I$(V210_DIR)/usr/include/bluetooth \
# -I$(V210_DIR)/usr/local/include/bluetooth \
-CFLAGS= -Wall -g -DABF_DEBUG
+CFLAGS= -Wall -g -DABF_DEBUG -fgnu89-inline
#LIBS= -ldbus-1 -lpthread -lbtfilt -lrt -lbluetooth
# LIBS= -ldbus-1 -lpthread -lrt -lbluetooth
--
1.9.1

View File

@ -1,33 +0,0 @@
#!/bin/sh
#===============================================================================
#
# btfilter
#
# Copyright (C) 2015 by Digi International Inc.
# All rights reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 as published by
# the Free Software Foundation.
#
#
# !Description: Configure Bluetooth
#
#===============================================================================
set -e
if [ "${1}" != "start" ]; then
exit 0
fi
SCRIPTNAME="$(basename "${0}")"
# Check if this hardware does support Bluetooth
if [ -d "/proc/device-tree/bluetooth" ]; then
echo "Starting btfilter service."
if ! abtfilt -b -x -s -w wlan0 1>/dev/null; then
echo "${SCRIPTNAME}: FAILED (abtfilt)"
exit
fi
fi

View File

@ -1,34 +0,0 @@
# Copyright (C) 2013 Digi International.
SUMMARY = "Atheros BT/wlan coexistance daemon"
SECTION = "network"
LICENSE = "ISC"
LIC_FILES_CHKSUM = "file://Makefile;beginline=1;endline=14;md5=8f6614b37751445a5f6a9bdc69be26b3"
inherit bluetooth
inherit update-rc.d
DEPENDS = "${BLUEZ} dbus libnl"
SRC_URI = " \
${DIGI_PKG_SRC}/${PN}-${PV}.tar.bz2 \
file://0001-enable-libnl3.patch \
file://0002-cross-compile.patch \
file://0003-abtfilt_wan-Rewrite-the-netlink-listener.patch \
file://0004-add-fgnu89-flag-for-gcc5.patch \
file://btfilter-init \
"
SRC_URI[md5sum] = "06a26d3a368c33b508d660ea84d476ee"
SRC_URI[sha256sum] = "b1af73003b622189b66d51911d429d6d205ac9227ec8278c8572ca0c68c7d5f3"
EXTRA_OEMAKE = "INCLUDES=-I${STAGING_INCDIR}/bluetooth"
do_install() {
install -d ${D}${bindir} ${D}${sysconfdir}/init.d/
install -m 0755 abtfilt ${D}${bindir}
install -m 0755 ${WORKDIR}/btfilter-init ${D}${sysconfdir}/init.d/btfilter
}
INITSCRIPT_NAME = "btfilter"
INITSCRIPT_PARAMS = "start 11 5 ."