util/mma: changing BOOT_STUB to COREBOOT region and few more things

(1) Added following new function.

cbfs_locate_file_in_region - to locate (and mmap) a file in a flash
region
  This function is used to look for MMA blobs in "COREBOOT" cbfs region

(2) mma_setup_test.sh would write to "COREBOOT" region.

(3) changes in mma_automated_test.sh. Few MMA tests need system to
be COLD rebooted before test can start. mma_automated_test.sh would
do COLD reboot after each test, and so i would sync the filesystem
before doing COLD reboot.

BRANCH=none
BUG=chrome-os-partner:43731
TEST=Build and Boot kunimitsu (FAB4). Able to locate MMA files in CBFS
Not tested on Glados.

Change-Id: I8338a46d8591d16183e51917782f052fa78c4167
Signed-off-by: Patrick Georgi <pgeorgi@chromium.org>
Original-Commit-Id: 1e418dfffd8a7fe590f9db771d2f0b01a44afbb4
Original-Change-Id: I402f84f5c46720710704dfd32b9319c73c412e47
Original-Signed-off-by: Pratik Prajapati <pratikkumar.v.prajapati@intel.com>
Original-Reviewed-on: https://chromium-review.googlesource.com/331682
Original-Commit-Ready: Pratikkumar V Prajapati <pratikkumar.v.prajapati@intel.com>
Original-Tested-by: Pratikkumar V Prajapati <pratikkumar.v.prajapati@intel.com>
Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Original-Reviewed-by: Pratikkumar V Prajapati <pratikkumar.v.prajapati@intel.com>
Reviewed-on: https://review.coreboot.org/14125
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
Pratik Prajapati 2016-02-22 16:50:31 -08:00 committed by Patrick Georgi
parent 0175fb1b4f
commit de62e0f079
3 changed files with 50 additions and 9 deletions

View File

@ -22,10 +22,12 @@
#include "mma.h" #include "mma.h"
#include <soc/romstage.h> #include <soc/romstage.h>
#include <string.h> #include <string.h>
#include <fmap.h>
#define MMA_TEST_METADATA_FILENAME "mma_test_metadata.bin" #define MMA_TEST_METADATA_FILENAME "mma_test_metadata.bin"
#define MMA_TEST_NAME_TAG "MMA_TEST_NAME" #define MMA_TEST_NAME_TAG "MMA_TEST_NAME"
#define MMA_TEST_PARAM_TAG "MMA_TEST_PARAM" #define MMA_TEST_PARAM_TAG "MMA_TEST_PARAM"
#define MMA_CBFS_REGION "COREBOOT"
#define TEST_NAME_MAX_SIZE 30 #define TEST_NAME_MAX_SIZE 30
#define TEST_PARAM_MAX_SIZE 100 #define TEST_PARAM_MAX_SIZE 100
#define FSP_MMA_RESULTS_GUID { 0x8f4e928, 0xf5f, 0x46d4, \ #define FSP_MMA_RESULTS_GUID { 0x8f4e928, 0xf5f, 0x46d4, \
@ -112,6 +114,30 @@ static int label_value(const char *haystack, size_t haystack_sz,
return 0; return 0;
} }
static void *cbfs_locate_file_in_region(const char *region_name, const char *file_name,
uint32_t file_type, uint32_t *file_size)
{
struct region_device rdev;
struct cbfsf fh;
if (file_size != NULL)
*file_size = 0;
if (fmap_locate_area_as_rdev(region_name, &rdev) == 0) {
if (cbfs_locate(&fh, &rdev, file_name, &file_type) == 0) {
if (file_size != NULL)
*file_size = region_device_sz(&fh.data);
return rdev_mmap_full(&fh.data);
} else
printk(BIOS_DEBUG, "%s file not found in %s region\n",
file_name, region_name);
} else
printk(BIOS_DEBUG,"%s region not found while looking for %s\n", region_name,
file_name);
return NULL;
}
void setup_mma(MEMORY_INIT_UPD *memory_params) void setup_mma(MEMORY_INIT_UPD *memory_params)
{ {
void *mma_test_metadata, *mma_test_content, *mma_test_param; void *mma_test_metadata, *mma_test_content, *mma_test_param;
@ -127,8 +153,9 @@ void setup_mma(MEMORY_INIT_UPD *memory_params)
memory_params->MmaTestConfigPtr = 0; memory_params->MmaTestConfigPtr = 0;
memory_params->MmaTestConfigSize = 0; memory_params->MmaTestConfigSize = 0;
mma_test_metadata = cbfs_boot_map_with_leak(MMA_TEST_METADATA_FILENAME, mma_test_metadata = cbfs_locate_file_in_region(MMA_CBFS_REGION,
CBFS_TYPE_MMA , &mma_test_metadata_file_len); MMA_TEST_METADATA_FILENAME, CBFS_TYPE_MMA,
&mma_test_metadata_file_len);
if (!mma_test_metadata) { if (!mma_test_metadata) {
printk(BIOS_DEBUG, "MMA setup failed: Failed to read %s\n", printk(BIOS_DEBUG, "MMA setup failed: Failed to read %s\n",
@ -154,16 +181,18 @@ void setup_mma(MEMORY_INIT_UPD *memory_params)
printk(BIOS_DEBUG, "Got MMA_TEST_NAME=%s MMA_TEST_PARAM=%s\n", printk(BIOS_DEBUG, "Got MMA_TEST_NAME=%s MMA_TEST_PARAM=%s\n",
test_filename, test_param_filename); test_filename, test_param_filename);
mma_test_content = cbfs_boot_map_with_leak(test_filename, mma_test_content = cbfs_locate_file_in_region(MMA_CBFS_REGION,
CBFS_TYPE_EFI , &mma_test_content_file_len); test_filename, CBFS_TYPE_EFI,
&mma_test_content_file_len);
if (!mma_test_content) { if (!mma_test_content) {
printk(BIOS_DEBUG, "MMA setup failed: Failed to read %s.\n", printk(BIOS_DEBUG, "MMA setup failed: Failed to read %s.\n",
test_filename); test_filename);
return; return;
} }
mma_test_param = cbfs_boot_map_with_leak(test_param_filename, mma_test_param = cbfs_locate_file_in_region(MMA_CBFS_REGION,
CBFS_TYPE_MMA , &mma_test_param_file_len); test_param_filename, CBFS_TYPE_MMA,
&mma_test_param_file_len);
if (!mma_test_param) { if (!mma_test_param) {
printk(BIOS_DEBUG, "MMA setup failed: Failed to read %s.\n", printk(BIOS_DEBUG, "MMA setup failed: Failed to read %s.\n",
test_param_filename); test_param_filename);

View File

@ -64,6 +64,10 @@ get_mma_autotest_params() {
} }
main() { main() {
# sleep 30 sec, before we start. This would give some time if we want
# to stop automation.
sleep 30s
mkdir -p "${MMA_LOCAL_DATA_STORAGE}"
# Exit if there are no tests # Exit if there are no tests
[ -e "${MMA_AUTOMATED_TEST_CONFIG}" ] || exit 0 [ -e "${MMA_AUTOMATED_TEST_CONFIG}" ] || exit 0
@ -87,7 +91,15 @@ main() {
get_mma_autotest_params get_mma_autotest_params
${MMA_SETUP_TEST_TOOL} set ${MMA_TEST_NAME} ${MMA_TEST_PARAM} ${MMA_SETUP_TEST_TOOL} set ${MMA_TEST_NAME} ${MMA_TEST_PARAM}
reboot # sync the filesystem, hoping this would minimize
# the chances of fs corruption
sync
sleep 2s
sync
sleep 2s
sync
sleep 2s
ectool reboot_ec
} }
main "$@" main "$@"

View File

@ -90,7 +90,7 @@ show_usage() {
write_flash() { write_flash() {
printf "Writing back flash contents "${flashrom_temp_image}"\n" printf "Writing back flash contents "${flashrom_temp_image}"\n"
flashrom -p host -w "${flashrom_temp_image}" -i BOOT_STUB --fast-verify || \ flashrom -p host -w "${flashrom_temp_image}" --fast-verify || \
{ {
printf "failed to read flash\n" ; printf "failed to read flash\n" ;
exit -1; exit -1;
@ -180,7 +180,7 @@ main() {
remove_file_if_exists "${flashrom_temp_image}" remove_file_if_exists "${flashrom_temp_image}"
printf "Reading flash contents to "${flashrom_temp_image}"\n" printf "Reading flash contents to "${flashrom_temp_image}"\n"
flashrom -p host -r "${flashrom_temp_image}" -i BOOT_STUB || \ flashrom -p host -r "${flashrom_temp_image}" || \
{ {
printf "failed to read flash\n" ; printf "failed to read flash\n" ;
exit -1; exit -1;