mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-09 00:51:29 +00:00
Add support for flash device parameters printing to bct_dump.
This adds human readable output for SPI and SDMMC device parameters stored in a BCT file. This includes clock divisors, boot flash type and various flash type specific parameters. BUG=None TEST=bct_dump /build/tegra2_seaboard/u-boot/image.bin Change-Id: I9f233abf53627ddb00159e105cfa3ff01d38ce5c This CL depends on: http://codereview.chromium.org/6579041/ Review URL: http://codereview.chromium.org/6576041
This commit is contained in:
128
bct_dump.c
128
bct_dump.c
@@ -35,27 +35,65 @@ typedef struct {
|
||||
} value_data;
|
||||
|
||||
static value_data const values[] = {
|
||||
{nvbct_lib_id_boot_data_version, "Version................: 0x%08x\n"},
|
||||
{nvbct_lib_id_block_size_log2, "Block size (log2)......: %d\n"},
|
||||
{nvbct_lib_id_page_size_log2, "Page size (log2).......: %d\n"},
|
||||
{nvbct_lib_id_partition_size, "Parition size..........: 0x%08x\n"},
|
||||
{nvbct_lib_id_bootloader_used, "Bootloader used........: %d\n"},
|
||||
{nvbct_lib_id_bootloaders_max, "Bootloaders max........: %d\n"},
|
||||
{nvbct_lib_id_bct_size, "BCT size...............: %d\n"},
|
||||
{nvbct_lib_id_hash_size, "Hash size..............: %d\n"},
|
||||
{nvbct_lib_id_crypto_offset, "Crypto offset..........: %d\n"},
|
||||
{nvbct_lib_id_crypto_length, "Crypto length..........: %d\n"},
|
||||
{nvbct_lib_id_max_bct_search_blks, "Max BCT search blocks..: %d\n"},
|
||||
{nvbct_lib_id_boot_data_version,
|
||||
"Version..................: 0x%08x\n"},
|
||||
{nvbct_lib_id_block_size_log2,
|
||||
"Block size (log2)........: %d\n"},
|
||||
{nvbct_lib_id_page_size_log2,
|
||||
"Page size (log2).........: %d\n"},
|
||||
{nvbct_lib_id_partition_size,
|
||||
"Parition size............: 0x%08x\n"},
|
||||
{nvbct_lib_id_bootloader_used,
|
||||
"Bootloader used..........: %d\n"},
|
||||
{nvbct_lib_id_bootloaders_max,
|
||||
"Bootloaders max..........: %d\n"},
|
||||
{nvbct_lib_id_bct_size,
|
||||
"BCT size.................: %d\n"},
|
||||
{nvbct_lib_id_hash_size,
|
||||
"Hash size................: %d\n"},
|
||||
{nvbct_lib_id_crypto_offset,
|
||||
"Crypto offset............: %d\n"},
|
||||
{nvbct_lib_id_crypto_length,
|
||||
"Crypto length............: %d\n"},
|
||||
{nvbct_lib_id_max_bct_search_blks,
|
||||
"Max BCT search blocks....: %d\n"},
|
||||
{nvbct_lib_id_num_param_sets,
|
||||
"Device parameters used...: %d\n"},
|
||||
};
|
||||
|
||||
static value_data const bl_values[] = {
|
||||
{nvbct_lib_id_bl_version, " Version.......: 0x%08x\n"},
|
||||
{nvbct_lib_id_bl_start_blk, " Start block...: %d\n"},
|
||||
{nvbct_lib_id_bl_start_page, " Start page....: %d\n"},
|
||||
{nvbct_lib_id_bl_length, " Length........: %d\n"},
|
||||
{nvbct_lib_id_bl_load_addr, " Load address..: 0x%08x\n"},
|
||||
{nvbct_lib_id_bl_entry_point, " Entry point...: 0x%08x\n"},
|
||||
{nvbct_lib_id_bl_attribute, " Attributes....: 0x%08x\n"},
|
||||
{nvbct_lib_id_bl_version,
|
||||
" Version.......: 0x%08x\n"},
|
||||
{nvbct_lib_id_bl_start_blk,
|
||||
" Start block...: %d\n"},
|
||||
{nvbct_lib_id_bl_start_page,
|
||||
" Start page....: %d\n"},
|
||||
{nvbct_lib_id_bl_length,
|
||||
" Length........: %d\n"},
|
||||
{nvbct_lib_id_bl_load_addr,
|
||||
" Load address..: 0x%08x\n"},
|
||||
{nvbct_lib_id_bl_entry_point,
|
||||
" Entry point...: 0x%08x\n"},
|
||||
{nvbct_lib_id_bl_attribute,
|
||||
" Attributes....: 0x%08x\n"},
|
||||
};
|
||||
|
||||
static value_data const spi_values[] = {
|
||||
{nvbct_lib_id_spiflash_read_command_type_fast,
|
||||
" Command fast...: %d\n"},
|
||||
{nvbct_lib_id_spiflash_clock_source,
|
||||
" Clock source...: %d\n"},
|
||||
{nvbct_lib_id_spiflash_clock_divider,
|
||||
" Clock divider..: %d\n"},
|
||||
};
|
||||
|
||||
static value_data const sdmmc_values[] = {
|
||||
{nvbct_lib_id_sdmmc_clock_divider,
|
||||
" Clock divider..: %d\n"},
|
||||
{nvbct_lib_id_sdmmc_data_width,
|
||||
" Data width.....: %d\n"},
|
||||
{nvbct_lib_id_sdmmc_max_power_class_supported,
|
||||
" Power class....: %d\n"},
|
||||
};
|
||||
|
||||
static void
|
||||
@@ -71,9 +109,13 @@ main(int argc, char *argv[])
|
||||
int e;
|
||||
build_image_context context;
|
||||
u_int32_t bootloaders_used;
|
||||
u_int32_t parameters_used;
|
||||
nvboot_dev_type type;
|
||||
u_int32_t data;
|
||||
int i;
|
||||
int j;
|
||||
value_data const * device_values;
|
||||
int device_count;
|
||||
|
||||
if (argc != 2)
|
||||
usage();
|
||||
@@ -93,11 +135,13 @@ main(int argc, char *argv[])
|
||||
|
||||
read_bct_file(&context);
|
||||
|
||||
/* Display root values */
|
||||
for (i = 0; i < sizeof(values) / sizeof(values[0]); ++i) {
|
||||
e = context.bctlib.get_value(values[i].id, &data, context.bct);
|
||||
printf(values[i].message, e == 0 ? data : -1);
|
||||
}
|
||||
|
||||
/* Display bootloader values */
|
||||
e = context.bctlib.get_value(nvbct_lib_id_bootloader_used,
|
||||
&bootloaders_used,
|
||||
context.bct);
|
||||
@@ -114,6 +158,54 @@ main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
/* Display device values */
|
||||
e = context.bctlib.get_value(nvbct_lib_id_num_param_sets,
|
||||
¶meters_used,
|
||||
context.bct);
|
||||
|
||||
for (i = 0; (e == 0) && (i < parameters_used); ++i) {
|
||||
printf("DeviceParameter[%d]\n", i);
|
||||
|
||||
e = context.bctlib.getdev_param(i,
|
||||
nvbct_lib_id_dev_type,
|
||||
&type,
|
||||
context.bct);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case nvboot_dev_type_spi:
|
||||
printf(" Type...........: SPI\n");
|
||||
device_values = spi_values;
|
||||
device_count = (sizeof(spi_values) /
|
||||
sizeof(spi_values[0]));
|
||||
break;
|
||||
|
||||
case nvboot_dev_type_sdmmc:
|
||||
printf(" Type...........: SDMMC\n");
|
||||
device_values = sdmmc_values;
|
||||
device_count = (sizeof(sdmmc_values) /
|
||||
sizeof(sdmmc_values[0]));
|
||||
break;
|
||||
|
||||
default:
|
||||
printf(" Type...........: Unknown (%d)\n",
|
||||
type);
|
||||
device_values = NULL;
|
||||
device_count = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
for (j = 0; j < device_count; ++j) {
|
||||
value_data value = device_values[j];
|
||||
|
||||
e = context.bctlib.getdev_param(i,
|
||||
value.id,
|
||||
&data,
|
||||
context.bct);
|
||||
printf(value.message, e == 0 ? data : -1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Clean up memory. */
|
||||
cleanup_context(&context);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user