meta-digi/meta-digi-arm/recipes-bsp/kobs-ng/ccardimx28js/0005-version-parse-MX-arch-...

103 lines
3.2 KiB
Diff

From b25a7a52f45a4961763543fc67b8ad30cfb02deb Mon Sep 17 00:00:00 2001
From: Hector Palacios <hector.palacios@digi.com>
Date: Mon, 21 May 2012 11:02:43 +0200
Subject: [PATCH 5/5] version: parse MX arch to select rom version
Parse the 'Hardware' line of /cpu/proc in search for the
string 'MX' and then parse the two numbers after it, which
will contain the architecture number (23,28,53) that
determine the rom version to use.
Notice this patch is only applicable to platforms that contain
the string 'MX25, MX28, MX53' on their platform names.
E.g.
ConnectCard Wi-i.MX28 -> OK
ConnectPort CPX2 -> NOT OK
Signed-off-by: Hector Palacios <hector.palacios@digi.com>
---
src/main.c | 50 +++++++++++++++++++++++---------------------------
1 files changed, 23 insertions(+), 27 deletions(-)
diff --git a/src/main.c b/src/main.c
index bd0bac0..c8d4e7f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -807,11 +807,10 @@ void discover_boot_rom_version(void)
FILE *cpuinfo;
char line_buffer[100];
static char *banner_hw = "Hardware\t:";
- static char *banner = "Hardware\t: Freescale MX";
- static char *banner_digi_x2 = "Hardware\t: Digi ConnectPort X2";
static char *v0_rom_tag = "23";
static char *v1_rom_tag = "28";
static char *v2_rom_tag = "53";
+ char *rev;
//----------------------------------------------------------------------
// Attempt to open /proc/cpuinfo.
@@ -834,38 +833,35 @@ void discover_boot_rom_version(void)
// Attempt to get the current line.
//--------------------------------------------------------------
- if (!fgets(line_buffer, sizeof(line_buffer), cpuinfo)) {
+ if (!fgets(line_buffer, sizeof(line_buffer), cpuinfo))
break;
- }
//--------------------------------------------------------------
// Check if the current line contains the information we need.
//--------------------------------------------------------------
- if (strncmp(line_buffer, banner_hw, strlen(banner_hw))) {
- continue;
- }
-
- if ( !strncmp(line_buffer, banner, strlen(banner)) ) {
- if (!strncmp(line_buffer + strlen(banner), v0_rom_tag, strlen(v0_rom_tag))) {
- rom_version = ROM_Version_0;
- break;
- }
- else
- if (!strncmp(line_buffer + strlen(banner), v1_rom_tag, strlen(v1_rom_tag))) {
- rom_version = ROM_Version_1;
- break;
- }
- else
- if (!strncmp(line_buffer + strlen(banner), v2_rom_tag, strlen(v2_rom_tag))) {
- rom_version = ROM_Version_2;
- break;
+ if (!strncmp(line_buffer, banner_hw, strlen(banner_hw))) {
+ rev = strstr(line_buffer, "MX");
+ if (rev) {
+ char tmp[3] = {};
+
+ rev += 2;
+ memcpy(tmp, rev, 2);
+ if (!strncmp(tmp, v0_rom_tag, strlen(v0_rom_tag))) {
+ rom_version = ROM_Version_0;
+ break;
+ }
+ else
+ if (!strncmp(tmp, v1_rom_tag, strlen(v1_rom_tag))) {
+ rom_version = ROM_Version_1;
+ break;
+ }
+ else
+ if (!strncmp(tmp, v2_rom_tag, strlen(v2_rom_tag))) {
+ rom_version = ROM_Version_2;
+ break;
+ }
}
}
-
- if ( !strncmp(line_buffer, banner_digi_x2, strlen(banner_digi_x2)) ) {
- // The CPX2 has a ROM version 1
- rom_version = ROM_Version_1;
- }
}
//----------------------------------------------------------------------
--
1.7.1