mirror of
git://projects.qi-hardware.com/xburst-tools.git
synced 2024-11-29 16:03:43 +02:00
qi-add-gta02-indentity-part-parsing.patch
Now everything else is in place, we are able to mount the GTA02 "identity" partition and extract the USB Ethernet MAC Address from it, and add it to the kernel commandline. This causes the Ethernet gadget to use the same MAC address each boot, simplifying DHCP server situation. The MAC address in the identity partition is globally unique from the factory. Signed-off-by: Andy Green <andy@openmoko.com>
This commit is contained in:
parent
bb67ea1a84
commit
dd0c85f427
@ -31,6 +31,7 @@
|
|||||||
#include <pcf50633.h>
|
#include <pcf50633.h>
|
||||||
#include <glamo-init.h>
|
#include <glamo-init.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <ext2.h>
|
||||||
|
|
||||||
#define GTA02_DEBUG_UART 2
|
#define GTA02_DEBUG_UART 2
|
||||||
#define PCF50633_I2C_ADS 0x73
|
#define PCF50633_I2C_ADS 0x73
|
||||||
@ -38,6 +39,9 @@
|
|||||||
|
|
||||||
static int battery_condition_reasonable = 0;
|
static int battery_condition_reasonable = 0;
|
||||||
|
|
||||||
|
extern unsigned long partition_offset_blocks;
|
||||||
|
extern unsigned long partition_length_blocks;
|
||||||
|
|
||||||
struct nand_dynparts {
|
struct nand_dynparts {
|
||||||
const char *name; /* name of this partition for Linux */
|
const char *name; /* name of this partition for Linux */
|
||||||
u32 good_length; /* bytes needed from good sectors in this partition */
|
u32 good_length; /* bytes needed from good sectors in this partition */
|
||||||
@ -480,18 +484,30 @@ void post_serial_init_gta02(void)
|
|||||||
puts("BATTERY CONDITION LOW\n");
|
puts("BATTERY CONDITION LOW\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const struct board_api board_api_gta02;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* create and append dynparts Linux kernel commandline
|
* create and append device-specific Linux kernel commandline
|
||||||
|
*
|
||||||
|
* This takes care of legacy dyanmic partition sizing and USB Ethernet
|
||||||
|
* MAC address identity information.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char * append_device_specific_cmdline_gta02(char * cmdline)
|
char * append_device_specific_cmdline_gta02(char * cmdline)
|
||||||
{
|
{
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
int len;
|
||||||
u32 block512 = 0;
|
u32 block512 = 0;
|
||||||
u32 start_block512 = 0;
|
u32 start_block512 = 0;
|
||||||
char term = ',';
|
char term = ',';
|
||||||
const u32 GTA02_NAND_READBLOCK_SIZE = 2048;
|
const u32 GTA02_NAND_READBLOCK_SIZE = 2048;
|
||||||
extern int s3c2442_nand_is_bad_block(unsigned long block_index_512);
|
extern int s3c2442_nand_is_bad_block(unsigned long block_index_512);
|
||||||
|
static char mac[64];
|
||||||
|
struct kernel_source const * real_kernel = this_kernel;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* dynparts computation
|
||||||
|
*/
|
||||||
|
|
||||||
cmdline += strlen(strcpy(cmdline,
|
cmdline += strlen(strcpy(cmdline,
|
||||||
" mtdparts=physmap-flash:-(nor);neo1973-nand:"));
|
" mtdparts=physmap-flash:-(nor);neo1973-nand:"));
|
||||||
@ -533,6 +549,47 @@ char * append_device_specific_cmdline_gta02(char * cmdline)
|
|||||||
|
|
||||||
*cmdline = '\0';
|
*cmdline = '\0';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Identity
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* position ourselves at true start of GTA02 identity partition */
|
||||||
|
partition_offset_blocks = nand_dynparts[4].good_length;
|
||||||
|
partition_length_blocks = 0x40000 / 512;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* lie that we are in NAND context... GTA02 specific
|
||||||
|
* all filesystem access is completed before we are called
|
||||||
|
*/
|
||||||
|
this_kernel = &board_api_gta02.kernel_source[3];
|
||||||
|
|
||||||
|
if (!ext2fs_mount()) {
|
||||||
|
puts("Unable to mount ext2 filesystem\n");
|
||||||
|
goto bail;
|
||||||
|
}
|
||||||
|
|
||||||
|
len = ext2fs_open("usb");
|
||||||
|
if (len < 0) {
|
||||||
|
puts(" Open failed\n");
|
||||||
|
goto bail;
|
||||||
|
}
|
||||||
|
|
||||||
|
n = ext2fs_read(mac, sizeof(mac));
|
||||||
|
if (n < 0) {
|
||||||
|
puts(" Read failed\n");
|
||||||
|
goto bail;
|
||||||
|
}
|
||||||
|
|
||||||
|
mac[len] = '\0';
|
||||||
|
|
||||||
|
cmdline += strlen(strcpy(cmdline, " g_ether.host_addr="));
|
||||||
|
cmdline += strlen(strcpy(cmdline, &mac[2]));
|
||||||
|
*cmdline += ' ' ;
|
||||||
|
bail:
|
||||||
|
this_kernel = real_kernel;
|
||||||
|
|
||||||
|
*cmdline = '\0';
|
||||||
|
|
||||||
return cmdline;
|
return cmdline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ int ext2fs_devread(int sector, int filesystem_block_log2, int byte_offset, int b
|
|||||||
|
|
||||||
sector = sector << filesystem_block_log2;
|
sector = sector << filesystem_block_log2;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check partition boundaries
|
* Check partition boundaries
|
||||||
*/
|
*/
|
||||||
@ -93,8 +94,7 @@ int ext2fs_devread(int sector, int filesystem_block_log2, int byte_offset, int b
|
|||||||
u8 p[SECTOR_SIZE];
|
u8 p[SECTOR_SIZE];
|
||||||
|
|
||||||
block_len = SECTOR_SIZE;
|
block_len = SECTOR_SIZE;
|
||||||
this_kernel->block_read(p,
|
this_kernel->block_read(p,partition_offset_blocks + sector, 1);
|
||||||
partition_offset_blocks + sector, 1);
|
|
||||||
memcpy(buf, p, byte_len);
|
memcpy(buf, p, byte_len);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user