app: aboot: Add support for tests framework
Add support to execute LK test framework through fastboot command.
Change-Id: I6fc816567ec27c76807df5740f96a9670fc48ece
diff --git a/app/aboot/aboot.c b/app/aboot/aboot.c
index 07f87e5..afb6c75 100644
--- a/app/aboot/aboot.c
+++ b/app/aboot/aboot.c
@@ -88,6 +88,7 @@
#include "board.h"
#include "scm.h"
#include "mdtp.h"
+#include "fastboot_test.h"
extern bool target_use_signed_kernel(void);
extern void platform_uninit(void);
@@ -168,6 +169,7 @@
static char *target_boot_params = NULL;
static bool boot_reason_alarm;
static bool devinfo_present = true;
+bool boot_into_fastboot = false;
/* Assuming unauthorized kernel image by default */
static int auth_kernel_img = 0;
@@ -1034,7 +1036,11 @@
device.is_unlocked,
device.is_tampered);
- if(target_use_signed_kernel() && (!device.is_unlocked))
+ /* Change the condition a little bit to include the test framework support.
+ * We would never reach this point if device is in fastboot mode, even if we did
+ * that means we are in test mode, so execute kernel authentication part for the
+ * tests */
+ if((target_use_signed_kernel() && (!device.is_unlocked)) || boot_into_fastboot)
{
offset = imagesize_actual;
if (check_aboot_addr_range_overlap((uint32_t)image_addr + offset, page_size))
@@ -1051,6 +1057,9 @@
}
verify_signed_bootimg((uint32_t)image_addr, imagesize_actual);
+ /* The purpose of our test is done here */
+ if (boot_into_fastboot && auth_kernel_img)
+ return 0;
} else {
second_actual = ROUND_TO_PAGE(hdr->second_size, page_mask);
#ifdef TZ_SAVE_KERNEL_HASH
@@ -3174,6 +3183,9 @@
{"oem enable-charger-screen", cmd_oem_enable_charger_screen},
{"oem disable-charger-screen", cmd_oem_disable_charger_screen},
{"oem select-display-panel", cmd_oem_select_display_panel},
+#if UNITTEST_FW_SUPPORT
+ {"oem run-tests", cmd_oem_runtests},
+#endif
#endif
};
@@ -3215,7 +3227,6 @@
void aboot_init(const struct app_descriptor *app)
{
unsigned reboot_mode = 0;
- bool boot_into_fastboot = false;
/* Setup page size information for nv storage */
if (target_is_emmc_boot())
diff --git a/app/aboot/fastboot_test.c b/app/aboot/fastboot_test.c
new file mode 100644
index 0000000..f32435c
--- /dev/null
+++ b/app/aboot/fastboot_test.c
@@ -0,0 +1,92 @@
+/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+
+#include <stdlib.h>
+#include <debug.h>
+#include "devinfo.h"
+#include "fastboot.h"
+#include "fastboot_test.h"
+#include <app/tests.h>
+#if USE_RPMB_FOR_DEVINFO
+#include <rpmb.h>
+#endif
+/* main function that calls into the tests */
+
+extern void ramdump_table_map();
+extern void kauth_test();
+
+void cmd_oem_runtests()
+{
+ dprintf(INFO, "Running LK tests ... \n");
+#if LPAE
+ ramdump_table_map();
+#endif
+
+#if USE_RPMB_FOR_DEVINFO
+ dprintf(INFO, "Running RPMB test case, please make sure RPMB key is provisioned ...\n");
+ struct device_info *write_info = memalign(PAGE_SIZE, 4096);
+ struct device_info *read_info = memalign(PAGE_SIZE, 4096);
+ if((read_device_info_rpmb((void*) read_info, PAGE_SIZE)) < 0)
+ dprintf(INFO, "RPMB READ TEST : [ FAIL ]\n");
+
+ write_info->is_unlocked = !read_info->is_unlocked;
+
+ if((write_device_info_rpmb((void*) write_info, PAGE_SIZE)) < 0)
+ dprintf(INFO, "RPMB WRITE TEST : [ FAIL ]\n");
+
+ if((read_device_info_rpmb((void*) read_info, PAGE_SIZE)) < 0)
+ dprintf(INFO, "RPMB READ TEST : [ FAIL ]\n");
+
+ if (read_info->is_unlocked == write_info->is_unlocked)
+ dprintf(INFO, "RPMB READ/WRITE TEST: [ PASS ]\n");
+ else
+ dprintf(INFO, "RPMB READ/WRITE TEST: [ FAIL ]\n");
+
+ free(read_info);
+ free(write_info);
+#endif
+
+#if VERIFIED_BOOT
+ if (!boot_linux_from_mmc())
+ dprintf(INFO, "Verifid Boot authentication test: [ PASS ]\n");
+ else
+ dprintf(INFO, "Verifid Boot authentication test: [ FAIL ]\n");
+
+ kauth_test();
+#endif
+
+ if (!thread_tests())
+ dprintf(INFO, "Thread Test: [ PASS ]\n");
+ else
+ dprintf(INFO, "Thread Test: [ FAIL ]\n");
+
+ printf_tests();
+
+ fastboot_okay("");
+}
diff --git a/app/aboot/fastboot_test.h b/app/aboot/fastboot_test.h
new file mode 100644
index 0000000..005bfa7
--- /dev/null
+++ b/app/aboot/fastboot_test.h
@@ -0,0 +1,36 @@
+/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of The Linux Foundation nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+
+#ifndef __FASTBOOT_TEST_H__
+#define __FASTBOOT_TEST_H__
+#include <sys/types.h>
+extern void ramdump_table_map();
+void cmd_oem_runtests();
+extern int boot_linux_from_mmc();
+#endif
diff --git a/app/aboot/rules.mk b/app/aboot/rules.mk
index 24bca43..09a5152 100644
--- a/app/aboot/rules.mk
+++ b/app/aboot/rules.mk
@@ -11,6 +11,11 @@
$(LOCAL_DIR)/fastboot.o \
$(LOCAL_DIR)/recovery.o
+ifeq ($(ENABLE_UNITTEST_FW), 1)
+OBJS += \
+ $(LOCAL_DIR)/fastboot_test.o
+endif
+
ifeq ($(ENABLE_MDTP_SUPPORT),1)
OBJS += \
$(LOCAL_DIR)/mdtp.o \
diff --git a/app/mmutest/mmu_test.c b/app/mmutest/mmu_test.c
index 849a9e6..27ed628 100644
--- a/app/mmutest/mmu_test.c
+++ b/app/mmutest/mmu_test.c
@@ -29,6 +29,7 @@
#include <sys/types.h>
#include <debug.h>
#include <arch/arm/mmu.h>
+#include <arch/ops.h>
#include <mmu.h>
#include <string.h>
#include <smem.h>
diff --git a/app/mmutest/rules.mk b/app/mmutest/rules.mk
index 78918a1..5094f65 100644
--- a/app/mmutest/rules.mk
+++ b/app/mmutest/rules.mk
@@ -1,6 +1,6 @@
LOCAL_DIR := $(GET_LOCAL_DIR)
-INCLUDES += -I$(LK_TOP_DIR)/platform/msm_shared/include
+INCLUDES += -I$(LOCAL_DIR)/include -I$(LK_TOP_DIR)/platform/msm_shared/include
OBJS += \
$(LOCAL_DIR)/mmu_test.o
diff --git a/app/rules.mk b/app/rules.mk
index e564fe0..0c06ce6 100644
--- a/app/rules.mk
+++ b/app/rules.mk
@@ -3,6 +3,11 @@
MODULES += \
lib/openssl
+ifeq ($(ENABLE_UNITTEST_FW), 1)
+MODULES += \
+ app/tests
+endif
+
OBJS += \
$(LOCAL_DIR)/app.o
diff --git a/app/tests/adc_tests.c b/app/tests/adc_tests.c
deleted file mode 100644
index 5f2d511..0000000
--- a/app/tests/adc_tests.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * * Neither the name of The Linux Foundation, Inc. nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <pm8x41_adc.h>
-#include <debug.h>
-
-void adc_test()
-{
- uint32_t vadc_chan1;
- uint32_t vadc_chan2;
- uint16_t iusb = 3250000;
- uint16_t ibat = 2500000;
- uint16_t batt_id_chan = 49;
- uint16_t vbat_sns_chan = 6;
-
- /*
- * TEST: Read the voltage on batt_id & vbat_sns channels
- */
- vadc_chan1 = pm8x41_adc_channel_read(batt_id_chan);
- dprintf(INFO, "The channel [%ud] voltage is :%ud\n",batt_id_chan, vadc_chan1);
-
- vadc_chan2 = pm8x41_adc_channel_read(vbat_sns_chan);
- dprintf(INFO, "The channel [%ud] voltage is :%ud\n",vbat_sns_chan, vadc_chan2);
-
- /*
- * TEST: Set the IUSB & IBAT max values
- */
-
- if (!pm8x41_iusb_max_config(iusb))
- dprintf(INFO, "Iusb max current is set\n");
-
- if (!pm8x41_ibat_max_config(ibat))
- dprintf(INFO, "Ibat max current is set\n");
-
-}
diff --git a/app/tests/led_tests.c b/app/tests/led_tests.c
deleted file mode 100644
index 11ef9f2..0000000
--- a/app/tests/led_tests.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2011, The Linux Foundation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following
- * disclaimer in the documentation and/or other materials provided
- * with the distribution.
- * * Neither the name of The Linux Foundation nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
- * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
- * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include<dev/pm8921_leds.h>
-#include<dev/pm8921.h>
-
-void led_tests()
-{
-uint32_t duty_us, period_us;
-
- /* 50% Duty cycle */
- duty_us = 500000;
- period_us = 1000000;
-
- /* Configure PM8921_ID_LED_0 from PWM2*/
- pm8921_config_led_current(PM8921_ID_LED_0, 2, PWM2, 1);
-
- /* PWM2 for PM8921_ID_LED_0 is LPG 5
- * Configure and enable lpg5
- */
- pm_set_pwm_config(5, duty_us, period_us, &pmic);
- pm_pwm_channel_enable(5, &pmic);
-
- /* Configure and enable lpg0 for panel backlight*/
- pm_set_pwm_config(0, duty_us, period_us, &pmic);
- pm_pwm_channel_enable(0, &pmic);
-
- mdelay(10000);
-
- /* Configure PM8921_ID_LED_1 also from PWM2*/
- pm8921_config_led_current(PM8921_ID_LED_1, 2, PWM2, 1);
- mdelay(10000);
-
- /* Disable PM8921_ID_LED_0 */
- pm8921_config_led_current(PM8921_ID_LED_0, 2, 2, 0);
-
- /* Turn on GPIO 24 through LPG 0
- * Will be reconfigured during display_init
- */
- panel_backlight_on_pwm();
-
- mdelay(10000);
-
- /* Disable PM8921_ID_LED_1 */
- pm8921_config_led_current(PM8921_ID_LED_1, 2, 2, 0);
-}
diff --git a/app/tests/rules.mk b/app/tests/rules.mk
index f8151ac..ec79a7f 100644
--- a/app/tests/rules.mk
+++ b/app/tests/rules.mk
@@ -5,7 +5,9 @@
OBJS += \
$(LOCAL_DIR)/tests.o \
$(LOCAL_DIR)/thread_tests.o \
- $(LOCAL_DIR)/printf_tests.o \
- $(LOCAL_DIR)/i2c_tests.o \
- $(LOCAL_DIR)/adc_tests.o \
+ $(LOCAL_DIR)/printf_tests.o
+
+ifeq ($(VERIFIED_BOOT),1)
+OBJS += \
$(LOCAL_DIR)/kauth_test.o
+endif
diff --git a/project/msm8996.mk b/project/msm8996.mk
index f0e618a..aefc7c3 100644
--- a/project/msm8996.mk
+++ b/project/msm8996.mk
@@ -89,3 +89,9 @@
DEFINES += PLATFORM_USE_QMP_MISC=1
#Use PON register for reboot reason
DEFINES += USE_PON_REBOOT_REG=1
+# Enable unit test FW
+ENABLE_UNITTEST_FW=1
+ifeq ($(ENABLE_UNITTEST_FW),1)
+DEFINES += UNITTEST_FW_SUPPORT=1
+endif
+