Skip to content

Commit

Permalink
Fire_HD10_9th_Gen-7.3.2.4-20220825
Browse files Browse the repository at this point in the history
  • Loading branch information
carlitros900 committed Feb 24, 2023
1 parent 3a169ee commit 983eb70
Show file tree
Hide file tree
Showing 172 changed files with 7,065 additions and 1,510 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Fire_HD10_9th_Gen-7.3.2.3-20220418
# Fire_HD10_9th_Gen-7.3.2.4-20220825
21 changes: 9 additions & 12 deletions build_kernel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ WORKSPACE_DIR="$(mktemp -d)"

TOOLCHAIN_DIR="${WORKSPACE_DIR}/toolchain"
PLATFORM_EXTRACT_DIR="${WORKSPACE_DIR}/src"
WORKSPACE_OUT_DIR="${WORKSPACE_DIR}/out"
WORKSPACE_OUT_DIR="${PLATFORM_EXTRACT_DIR}/out/target/product/maverick/obj/KERNEL_OBJ"

for d in "${TOOLCHAIN_DIR}" "${PLATFORM_EXTRACT_DIR}" "$WORKSPACE_OUT_DIR"
do
Expand All @@ -45,7 +45,6 @@ done
# Remove workspace directory upon completion.
trap "rm -rf $WORKSPACE_DIR" EXIT

PARALLEL_EXECUTION="-j8"

function usage {
echo "Usage: ${BASH_SOURCE[0]} path_to_platform_tar output_folder" 1>&2
Expand Down Expand Up @@ -76,6 +75,7 @@ function display_config {
echo "TARGET ARCHITECTURE: ${TARGET_ARCH}"
echo "TOOLCHAIN REPO: ${TOOLCHAIN_REPO}"
echo "TOOLCHAIN PREFIX: ${TOOLCHAIN_PREFIX}"
echo "PARALLEL_EXECUTION: ${PARALLEL_EXECUTION}"
echo "-------------------------------------------------------------------------"
echo "Sleeping 3 seconds before continuing."
sleep 3
Expand Down Expand Up @@ -105,7 +105,8 @@ function setup_output_dir {

function download_toolchain {
echo "Cloning toolchain ${TOOLCHAIN_REPO} to ${TOOLCHAIN_DIR}"
git clone "${TOOLCHAIN_REPO}" "${TOOLCHAIN_DIR}"
#git clone "${TOOLCHAIN_REPO}" "${TOOLCHAIN_DIR}"
git clone --single-branch -b "${TOOLCHAIN_BRANCH}" "${TOOLCHAIN_REPO}" "${TOOLCHAIN_DIR}"
if [[ $? -ne 0 ]]
then
echo "ERROR: Could not clone toolchain from ${TOOLCHAIN_REPO}."
Expand All @@ -122,14 +123,10 @@ function exec_build_kernel {
CCOMPILE="${TOOLCHAIN_DIR}/bin/${TOOLCHAIN_PREFIX}"
CC="${CLANG_COMPILER_PATH}/bin/clang"

if [[ -n "${KERNEL_SUBPATH}" ]]
then
MAKE_ARGS="-C ${KERNEL_SUBPATH}"
fi

MAKE_ARGS="${MAKE_ARGS} O=${WORKSPACE_OUT_DIR} ARCH=${TARGET_ARCH} CROSS_COMPILE=${CCOMPILE}"
MAKE_ARGS="${MAKE_ARGS} CLANG_TRIPLE=aarch64-linux-gnu- CC=${CC}"
echo "Base make args: ${MAKE_ARGS}"
MAKE_ARGS="-C ${KERNEL_SUBPATH} O=${WORKSPACE_OUT_DIR} ARCH=${TARGET_ARCH}"
MAKE_ARGS1="-C ${KERNEL_SUBPATH} O=${WORKSPACE_OUT_DIR} ARCH=${TARGET_ARCH} CROSS_COMPILE=${CCOMPILE} CLANG_TRIPLE=aarch64-linux-gnu- CC=${CC}"
echo "MAKE_ARGS: ${MAKE_ARGS}"
echo "MAKE_ARGS1: ${MAKE_ARGS1}"

# Move into the build base folder.
pushd "${PLATFORM_EXTRACT_DIR}"
Expand All @@ -146,7 +143,7 @@ function exec_build_kernel {

# Step 3: full make
echo "Running full make"
make ${MAKE_ARGS}
make ${PARALLEL_EXECUTION} ${MAKE_ARGS1}

if [[ $? != 0 ]]; then
echo "ERROR: Failed to build kernel" >&2
Expand Down
3 changes: 3 additions & 0 deletions build_kernel_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ KERNEL_SUBPATH="kernel/mediatek/mt8183/4.4"
DEFCONFIG_NAME="maverick_defconfig"
TARGET_ARCH="arm64"
TOOLCHAIN_REPO="https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9"
TOOLCHAIN_BRANCH="llvm-r383902b"
TOOLCHAIN_NAME="aarch64-linux-android-4.9"
TOOLCHAIN_PREFIX="aarch64-linux-android-"
PARALLEL_EXECUTION="-j24"

# Expected image files are seperated with ":"
KERNEL_IMAGES="arch/arm64/boot/Image:arch/arm64/boot/Image.gz:arch/arm64/boot/Image.gz-dtb"

################################################################################
# NOTE: You must fill in the following with the path to a copy of Clang compiler
# of version r383902b
################################################################################
CLANG_COMPILER_PATH=""
109 changes: 109 additions & 0 deletions src/device/amazon/kernel/driver/Documentation/amazon_logger.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
Amazon Logger driver

1. Overview:

This driver is metrics logging driver for Amazon device. Metrics are
the "events" log recorded by device software. It includes user space metrics logging
and kernel space metrics logging. This driver supports kernel space's logging only.
It is based on Linux trace ring_buffer to takes following benefits:
-let ring_buffer to manage the buffer.
-ring_buffer allows multiple producers writing at same time on different cpus.

_________________
| |
| logd |
|_______________|
_______________|________________
| |
-----------------------------------------------------------------------
| |
| |
_______|______ ________|_____
| ring_buffer | | ring_buffer |
|______________| |_____________|
| /dev/metrics | | /dev/vitals |
|______________| |_____________|


2. Interfaces for kernel:

Following three kernel API are exported for other kernel components:

1)int log_to_metrics(enum android_log_priority priority,
const char *domain, char *logmsg);

2)int log_counter_to_vitals(enum android_log_priority priority,
const char *domain, const char *program,
const char *source, const char *key,
long counter_value, const char *unit,
const char *metadata, vitals_type type);

3)int log_timer_to_vitals(enum android_log_priority priority,
const char *domain, const char *program,
const char *source, const char *key,
long timer_value, const char *unit, vitals_type type);

General arguments description:
program: Vital record category name
source: Vital name
discrete_value, dv: a discrete value, typically used as key
counter_value, cv: counter value
timer_value, tv: timer value
unit: unit for the vital
type: type of vitals, currently 3 types are supported:
a. VITALS_NORMAL: regular vitals with no special processing
b. VITALS_FGTRACKING: vitals for which foreground tracking is required.
These vitals will be tracked in 2 separate buckets: total occurrence
and occurrence in foreground.
c. VITALS_TIME_BUCKET: vitals for state transition which needs to be broken
down to different time buckets. This simplifies client side processing
as only info required is new_state, transition time (in time since boot),
and initial state (client should report during boot/initialization), and client
side does not need to keep timers to track time spent in buckets.
Return value:
0 on success, error code for failure.

Example code:

#include<linux/metricslog.h>
#include<linux/string.h>

#define METRICS_STR_LEN 128
int amazon_log_example(void)
{
char metrics_log[METRICS_STR_LEN];
int ret = -1;
struct timespec now;

memset(metrics_log, 0, METRICS_STR_LEN);
snprintf(metrics_log, METRICS_STR_LEN, "TEST:METRIC:VALUE_A=%d;CT;1,VALUE_B=%d;CT;1:NR",
1, 0);
ret = log_to_metrics(ANDROID_LOG_INFO, "metric_test", metrics_log);
if (ret)
pr_err("fails in log_to_metrics %d", ret);

now = current_kernel_time();
memset(metrics_log, 0, METRICS_STR_LEN);

snprintf(metrics_log, METRICS_STR_LEN, "Kerenl:TEST:VALUE_A=%d;CT;1,VALUE_B=%d;CT;1:NR",
ret = log_timer_to_vitals(ANDROID_LOG_INFO, "Kernel timer", "TEST",
"time_in_test", "Test", now.tv_sec, "s", VITALS_TIME_BUCKET);
if (ret)
pr_err("fails in log_timer_to_vitals %d", ret);

ret = log_counter_to_vitals(ANDROID_LOG_INFO, "Kernel vitals", "TEST",
"VITALS", "test_value", (u32)1, "count", "s", VITALS_NORMAL);
if (ret)
pr_err("fails in log_counter_to_vitals %d", ret);

return ret;
}

3. Interfaces for userspace:

Two device nodes /dev/metrics and /dev/vitals will be created. Both of them support
open(),poll()/select() and read() system calls. Currently they are read-only mode,
therefore they do not support write(). For read(), it supports blocking and nonblocking mode.
In blocking mode, the read() will be blocked until a new log is available.
In nonblocking(O_NONBLOCK) mode, the read() will return immediately if no data is available.
For each read(), only one log entry is consumed and returned to user land.
45 changes: 45 additions & 0 deletions src/device/amazon/kernel/driver/Documentation/idme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
idme driver

1. Overview:

idme driver is used to show the information of idme in /proc directory and
also provide interfaces to access specific item in idme, such as board type,
bootmode, dev flags.

2. Interfaces for kernel:

Following kernel APIs are exported for other kernel components:

const char *idme_get_item(char *idme_item);
-This function is used to get the specific idme item value,
such as: board_id, boot_mode, dev_flags etc.
-Return the value on success, NULL on failure.

unsigned int idme_get_board_type(void);
-This function is used to get the board type in board_id,
-Return the board type on success, 0 on failure.

unsigned int idme_get_board_rev(void);
-This function is used to get the board revision in board_id,
-Return the board revision on success, 0 on failure.

unsigned int idme_get_bootmode(void);
-This function is used to get boot mode in idme,
-Return the boot_mode on success, 0 on failure.

u64 idme_get_dev_flags_value(void);
-This function is used to get dev_flags in idme
-Return the dev_flags value on success, 0 on failure.

bool board_has_wan(void);
-This function is used to check whether this board supported WAN.
-Return true if having WAN, else return false.

3. Interfaces for userspace:
Directory /proc/idme will be added. It will show the value of idme items. For example:

/proc/idme # ls
DKB bootcount dev_flags mac_addr product_name region t_unlock_code usr_flags
KB bootmode device_type_id mac_sec productid sensorcal tp_cg_color wifi_mfg
alscal bt_mac_addr fos_flags manufacturing productid2 serial unlock_code
board_id bt_mfg front_cam_otp postmode rear_cam_otp t_unlock_cert unlock_version
50 changes: 50 additions & 0 deletions src/device/amazon/kernel/driver/Documentation/sign_of_life.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
sign_of_life driver

1. Overview:

sign_of_life driver provides the "life cycle reason" of Amazon device to
userland application via /proc/life_cycle_reason. "life of reason" means why
device got powered off or rebooted or booted. For example, device may
get shutdown by thermal service due to an overheated CPU. During next booting,
the sign_of_life driver will find out the thermal shutdown reason and provides
the reason to the /proc interface. Then userland application will read
the /proc/life_cycle_reason and reports this abnormal event to device health
servers.

2. Interfaces for kernel:

Following four kernel APIs are exported for other kernel components:

int life_cycle_set_boot_reason(life_cycle_reason_t boot_reason);
-This function will set the boot reason which causing device booting,
such as: kernel panics, normal reboot, power key turn on device etc.
-Return 0 on success, -1 on failure.

int life_cycle_set_shutdown_reason(life_cycle_reason_t shutdown_reason);
-This function will set the shutdown reason which causing device shutdown.
such as: normal software shutdown, sudden power loss off and long press
powerkey off etc.
-Return 0 on success, -1 on failure.


int life_cycle_set_thermal_shutdown_reason(life_cycle_reason_t thermal_shutdown_reason);
-This function will set the Thermal Shutdown reason which causing device
shutdown, such as: overheated cpus, overheated wifi, overheated PCB, overheated
PMIC etc.
-Return 0 on success, -1 on failure.


int life_cycle_set_special_mode(life_cycle_reason_t life_cycle_special_mode);
-This function will set the special mode which causing device life cycle change,
such as: OTA mode, factory reset mode, low battery mode etc.
-Return 0 on success, -1 on failure.

3. Interfaces for userspace:
A /proc/life_of_reason will be added. It will provides driver version, life cycle
reason and life cycle type(normal or abnormal). For example, if device was rebooted
due to a kernel panic, the output from /proc interface will be as following:

cat /proc/life_cycle_reason
lc_version:2.0
lc_reason:Warm Boot By Kernel Panic
lc_type:LCR_abnormal
67 changes: 67 additions & 0 deletions src/device/amazon/kernel/driver/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
menu "Amzn"

config AMZN
bool "Amazon Common Drivers"
default N
---help---
Enable support for various drivers needed on the Amazon Fire OS platform

if AMZN

config AMZN_SIGN_OF_LIFE
bool "Amazon Sign of Life"
help
enable the life cycle metrics to log device boot and shutdown information

config AMZN_SIGN_OF_LIFE_RTC
bool "Amazon Sign of Life platform implementation"
help
enable the life cycle metrics to log device boot and shutdown information on specific Platform

config AMZN_POWEROFF_LOG
bool "Long press key power off log"
default N
help
enable Long press key power off log

config AMZN_METRICS_LOG
bool "Amazon Metrics logger driver"
select RING_BUFFER
default n
---help---
Enable Amazon Metrics/Vitals logger driver

config AMZN_METRICS_LOG_TEST
tristate "Amazon Metrics logger driver test module"
depends on AMZN_METRICS_LOG
default n
---help---
Enable Amazon Metrics/Vitals logger test module

config AMZN_INPUT_KEYCOMBO
tristate "Amazon key combo"
depends on INPUT
select INPUT_KEYCOMBO
help
Say Y here if you want to panic kernel / power off when some keys are pressed;

To compile this driver as a module, choose M here: the
module will be called amzn_keycombo.

config AMZN_IDME
bool "IDME support"
depends on PROC_FS
help
Select Y here to enable IDME support to read the data
via userspace (i.e. /proc/idme/* entries)

config AMZN_DRV_TEST
tristate "Amazon common BSP driver test module"
depends on AMZN_METRICS_LOG && AMZN_SIGN_OF_LIFE && AMZN_IDME
default n
---help---
Enable Amazon Common BSP test module

endif # if AMZN

endmenu
26 changes: 26 additions & 0 deletions src/device/amazon/kernel/driver/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Copyright (C) 2020 Amazon Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See http://www.gnu.org/licenses/gpl-2.0.html for more details.
#

mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
cur_dir := $(patsubst %/,%,$(dir $(mkfile_path)))

$(shell mkdir -p $(CURDIR)/include/linux)
$(shell cp $(cur_dir)/include/amzn_*.h $(CURDIR)/include/linux/)

obj-$(CONFIG_AMZN_SIGN_OF_LIFE) += amzn_sign_of_life.o
obj-$(CONFIG_AMZN_SIGN_OF_LIFE_RTC) += amzn_sign_of_life_rtc_impl.o
obj-$(CONFIG_AMZN_METRICS_LOG) += amzn_logger.o
obj-$(CONFIG_AMZN_METRICS_LOG_TEST) += amzn_logger_test.o
obj-$(CONFIG_AMZN_INPUT_KEYCOMBO) += amzn_keycombo.o
obj-$(CONFIG_AMZN_IDME) += amzn_idme.o
obj-$(CONFIG_AMZN_DRV_TEST) += amzn_drv_test.o
Loading

0 comments on commit 983eb70

Please sign in to comment.