projects/Amlogic: new device: Khadas VIM

This commit is contained in:
kszaq 2018-02-14 21:53:01 +01:00
parent 760c839f1f
commit 8f4f5eaed4
7 changed files with 485 additions and 0 deletions

View File

@ -0,0 +1,40 @@
#------------------------------------------------------------------------------------------------------
#
# boot.ini
#
# WARNING DO NOT MODIFY THIS FILE! ALL CHANGES WILL BE LOST WITH THE NEXT UPDATE!
# Set your own settings in config.ini
#
#------------------------------------------------------------------------------------------------------
KHADAS-UBOOT-CONFIG
setenv bootrootfs "BOOT_IMAGE=kernel.img boot=LABEL=LIBREELEC disk=LABEL=STORAGE"
setenv condev "ttyS0,115200"
setenv hdmimode "1080p60hz"
setenv hdmioutput "1"
setenv vpu "1"
setenv libreelec "quiet"
setenv hdmi_cec "1"
setenv uenv_addr 0x13000000
fatload mmc 0:1 ${loadaddr} kernel.img
fatload mmc 0:1 ${dtb_mem_addr} dtb.img
if fatload mmc 0:1 ${uenv_addr} config.ini; then env import -t ${uenv_addr} $filesize; fi
setenv khadas "no_console_suspend logo=osd1,loaded,0x3f800000,${hdmimode} vout=${hdmimode},enable hdmimode=${hdmimode} cvbsmode=nocvbs consoleblank=0"
if test "${hdmi_cec}" = "1"; then setenv cec "hdmitx=cec17"; fi
setenv bootargs "console=${condev} ${bootrootfs} ${khadas} ${cec} ${libreelec}"
# Device tree modifications
bootm start
bootm loados
bootm fdt
if test "${vpu}" = "0"; then fdt rm /mesonstream; fdt rm /vdec; fdt rm /ppmgr; fi
if test "${hdmioutput}" = "0"; then fdt rm /mesonfb; fi
# Remove aml partition layout from device tree (required for eMMC boot)
fdt rm /partitions
bootm prep
# Boot the board
bootm go

View File

@ -0,0 +1,57 @@
#------------------------------------------------------------------------------------------------------
#
# config.ini
#
#------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------------
#
# Console Setup
# on serial port:
# condev='ttyS0,115200'
#
#------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------------
#
# Video
# Setup the video output
# hdmimode='480i60hz'
# hdmimode='480p60hz'
# hdmimode='576i50hz'
# hdmimode='576p50hz'
# hdmimode='720p60hz'
# hdmimode='720p50hz'
# hdmimode='1080i60hz'
# hdmimode='1080p60hz'
# hdmimode='1080i50hz'
# hdmimode='1080p50hz'
# hdmimode='1080p30hz'
# hdmimode='1080p25hz'
# hdmimode='1080p24hz'
# hdmimode='2160p60hz'
# hdmimode='2160p50hz'
# hdmimode='2160p30hz'
# hdmimode='2160p25hz'
# hdmimode='2160p24hz'
#
#------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------------
#
# LibreELEC variables
#
# Setup the LibreELEC options
# valid values are: textmode debugging progress nofsck nosplash noram overlay quiet ssh
#
# libreelec='quiet'
#
#------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------------
#
# Enable|Disable HDMI CEC Control
# hdmi_cec='0'
# hdmi_cec='1'
#
#------------------------------------------------------------------------------------------------------

View File

@ -0,0 +1,33 @@
#!/bin/bash
################################################################################
# This file is part of LibreELEC - https://libreelec.tv
# Copyright (C) 2017-present Team LibreELEC
#
# LibreELEC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# LibreELEC 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 the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LibreELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################
if [ -f "$RELEASE_DIR/3rdparty/bootloader/u-boot.bin" ]; then
echo "Writing u-boot to $(basename $DISK)"
dd if="$RELEASE_DIR/3rdparty/bootloader/u-boot.bin" of="$DISK" conv=fsync,notrunc bs=1 count=444 >"$SAVE_ERROR" 2>&1 || show_error
dd if="$RELEASE_DIR/3rdparty/bootloader/u-boot.bin" of="$DISK" conv=fsync,notrunc bs=512 skip=1 seek=1 >"$SAVE_ERROR" 2>&1 || show_error
fi
if [ -f "$RELEASE_DIR/3rdparty/bootloader/boot.ini" ]; then
mcopy $RELEASE_DIR/3rdparty/bootloader/boot.ini ::
fi
if [ -f "$RELEASE_DIR/3rdparty/bootloader/config.ini" ]; then
mcopy $RELEASE_DIR/3rdparty/bootloader/config.ini ::
fi

View File

@ -0,0 +1,27 @@
#!/bin/sh
################################################################################
# This file is part of LibreELEC - https://libreelec.tv
# Copyright (C) 2017-present Team LibreELEC
#
# LibreELEC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# LibreELEC 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 the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LibreELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################
. config/options $1
mkdir -p $RELEASE_DIR/3rdparty/bootloader
cp -a $(get_build_dir linux)/arch/$TARGET_KERNEL_ARCH/boot/dtb.img $RELEASE_DIR/3rdparty/bootloader
cp -a $(get_build_dir $BOOTLOADER)/fip/u-boot.bin.sd.bin $RELEASE_DIR/3rdparty/bootloader/u-boot.bin
cp -a $PROJECT_DIR/$PROJECT/devices/$DEVICE/bootloader/boot.ini $RELEASE_DIR/3rdparty/bootloader
cp -a $PROJECT_DIR/$PROJECT/devices/$DEVICE/bootloader/config.ini $RELEASE_DIR/3rdparty/bootloader

View File

@ -0,0 +1,25 @@
# u-boot version to use (default)
UBOOT_VERSION="vendor"
# Configuration for u-boot
UBOOT_CONFIG="kvim_defconfig"
# Target Configfile for u-boot
UBOOT_CONFIGFILE="boot.ini"
# Kernel extra targets to build
KERNEL_UBOOT_EXTRA_TARGET="gxl_p212_2g_kvim.dtb"
# Additional kernel dependencies
KERNEL_EXTRA_DEPENDS_TARGET="device-trees-amlogic"
# additional drivers to install:
# for a list of additinoal drivers see packages/linux-drivers
# Space separated list is supported,
# e.g. ADDITIONAL_DRIVERS="DRIVER1 DRIVER2"
ADDITIONAL_DRIVERS="$ADDITIONAL_DRIVERS ap6xxx-aml"
# additional Firmware to use (dvb-firmware, misc-firmware, wlan-firmware)
# Space separated list is supported,
# e.g. FIRMWARE="dvb-firmware misc-firmware wlan-firmware"
FIRMWARE="$FIRMWARE brcmfmac_sdio-firmware-all-aml"

View File

@ -0,0 +1,60 @@
################################################################################
# This file is part of LibreELEC - https://libreelec.tv
# Copyright (C) 2009-2016 Stephan Raue (stephan@openelec.tv)
# Copyright (C) 2017-present Team LibreELEC
#
# LibreELEC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# LibreELEC 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 the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LibreELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################
PKG_NAME="u-boot"
PKG_VERSION="ffc14fc"
PKG_ARCH="arm aarch64"
PKG_SITE="https://www.denx.de/wiki/U-Boot"
PKG_URL="https://github.com/khadas/u-boot/archive/$PKG_VERSION.tar.gz"
PKG_SOURCE_DIR="u-boot-$PKG_VERSION*"
PKG_DEPENDS_TARGET="toolchain dtc:host gcc-linaro-aarch64-elf:host gcc-linaro-arm-eabi:host"
PKG_LICENSE="GPL"
PKG_SECTION="tools"
PKG_SHORTDESC="u-boot: Universal Bootloader project"
PKG_LONGDESC="Das U-Boot is a cross-platform bootloader for embedded systems, used as the default boot loader by several board vendors. It is intended to be easy to port and to debug, and runs on many supported architectures, including PPC, ARM, MIPS, x86, m68k, NIOS, and Microblaze."
PKG_IS_KERNEL_PKG="yes"
PKG_NEED_UNPACK="$PROJECT_DIR/$PROJECT/bootloader"
[ -n "$DEVICE" ] && PKG_NEED_UNPACK+=" $PROJECT_DIR/$PROJECT/devices/$DEVICE/bootloader"
post_unpack() {
sed -i "s|arm-none-eabi-|arm-eabi-|g" $PKG_BUILD/Makefile $PKG_BUILD/arch/arm/cpu/armv8/gxl/firmware/scp_task/Makefile
}
make_target() {
export PATH=$TOOLCHAIN/lib/gcc-linaro-aarch64-elf/bin/:$TOOLCHAIN/lib/gcc-linaro-arm-eabi/bin/:$PATH
CROSS_COMPILE=aarch64-elf- ARCH=arm CFLAGS="" LDFLAGS="" make mrproper
CROSS_COMPILE=aarch64-elf- ARCH=arm CFLAGS="" LDFLAGS="" make $UBOOT_CONFIG
CROSS_COMPILE=aarch64-elf- ARCH=arm CFLAGS="" LDFLAGS="" make HOSTCC="$HOST_CC" HOSTSTRIP="true"
}
makeinstall_target() {
mkdir -p $INSTALL/usr/share/bootloader
# Only install u-boot.img et al when building a board specific image
find_file_path bootloader/install && . ${FOUND_PATH}
# Always install the update script
find_file_path bootloader/update.sh && cp -av ${FOUND_PATH} $INSTALL/usr/share/bootloader
cp $PKG_BUILD/fip/u-boot.bin.sd.bin $INSTALL/usr/share/bootloader/u-boot
find_file_path bootloader/boot.ini && cp -av ${FOUND_PATH} $INSTALL/usr/share/bootloader
find_file_path bootloader/config.ini && cp -av ${FOUND_PATH} $INSTALL/usr/share/bootloader
}

View File

@ -0,0 +1,243 @@
From cf157959c122b63b17b0b3284535cbfdad6ea936 Mon Sep 17 00:00:00 2001
From: kszaq <kszaquitto@gmail.com>
Date: Sat, 17 Feb 2018 20:30:08 +0100
Subject: [PATCH] khadas_vim: amend boot procedure for LibreELEC
* make eMMC use MBR instead of AML partition structure
* port eMMC/SD renumbering from Hardkernel to allow booting from either SD or eMMC
* remove NAND driver (not in use)
* remove fastboot, bcb, store interface (not in use and conflicts with eMMC MBR)
* remove preboot steps that are not requried for faster booting
---
board/khadas/configs/kvim.h | 39 ++++-----------------
board/khadas/kvim/kvim.c | 83 +++++++++++++++++----------------------------
drivers/mmc/aml_sd_emmc.c | 1 -
3 files changed, 38 insertions(+), 85 deletions(-)
diff --git a/board/khadas/configs/kvim.h b/board/khadas/configs/kvim.h
index 0189f32..e95fc98 100644
--- a/board/khadas/configs/kvim.h
+++ b/board/khadas/configs/kvim.h
@@ -47,7 +47,7 @@
//#define CONFIG_INSTABOOT
/* configs for dtb in boot.img */
-//#define DTB_BIND_KERNEL
+#define DTB_BIND_KERNEL
/* SMP Definitinos */
#define CPU_RELEASE_ADDR secondary_boot_func
@@ -61,12 +61,6 @@
/* support ext4*/
#define CONFIG_CMD_EXT4 1
-/* Bootloader Control Block function
- That is used for recovery and the bootloader to talk to each other
- */
-#define CONFIG_BOOTLOADER_CONTROL_BLOCK
-
-
/* Serial config */
#define CONFIG_CONS_INDEX 2
#define CONFIG_BAUDRATE 115200
@@ -109,8 +103,6 @@
"init_display=" \
"osd open;" \
"osd clear;" \
- "imgread pic logo bootup ${loadaddr};" \
- "bmp display ${bootup_offset}; bmp scale" \
"\0"\
"bootdisk=ramdisk\0" \
"bootargs=" \
@@ -140,13 +132,11 @@
* - ramdisk: Ubuntu or Linux distro
*/
#define CONFIG_PREBOOT \
- "run init_display;" \
- "run combine_key;" \
- "run upgrade_key;"
+ "run init_display;"
-#define CONFIG_BOOTCOMMAND "cfgload;ext4load mmc 1:5 1080000 Image;ext4load mmc 1:5 10000000 uInitrd;ext4load mmc 1:5 20000000 kvim.dtb;booti 1080000 10000000 20000000"
+#define CONFIG_BOOTCOMMAND "cfgload"
-//#define CONFIG_ENV_IS_NOWHERE 1
+#define CONFIG_ENV_IS_NOWHERE 1
#define CONFIG_ENV_SIZE (64*1024)
#define CONFIG_FIT 1
#define CONFIG_OF_LIBFDT 1
@@ -184,7 +174,7 @@
#define CONFIG_DDR_FUNC_PRINT_WINDOW 0 //0:disable, 1:enable. print ddr training window
/* storage: emmc/nand/sd */
-#define CONFIG_STORE_COMPATIBLE 1
+//#define CONFIG_STORE_COMPATIBLE 1
/*
* storage
* |---------|---------|
@@ -199,7 +189,7 @@
/* support for mtd */
//#define CONFIG_AML_MTD 1
/* support for nftl */
-#define CONFIG_AML_NAND 1
+// #define CONFIG_AML_NAND 1
#if defined(CONFIG_AML_NAND) && defined(CONFIG_AML_MTD)
#error CONFIG_AML_NAND/CONFIG_AML_MTD can not support at the sametime;
@@ -290,22 +280,6 @@
#define CONFIG_USB_XHCI_AMLOGIC_GXL 1
#endif //#if defined(CONFIG_CMD_USB)
-//UBOOT fastboot config
-#define CONFIG_CMD_FASTBOOT 1
-#define CONFIG_FASTBOOT_FLASH_MMC_DEV 1
-#define CONFIG_FASTBOOT_FLASH 1
-#define CONFIG_USB_GADGET 1
-#define CONFIG_USBDOWNLOAD_GADGET 1
-#define CONFIG_SYS_CACHELINE_SIZE 64
-#define CONFIG_FASTBOOT_MAX_DOWN_SIZE 0x8000000
-#define CONFIG_DEVICE_PRODUCT "p212"
-
-//UBOOT Facotry usb/sdcard burning config
-#define CONFIG_AML_V2_FACTORY_BURN 1 //support facotry usb burning
-#define CONFIG_AML_FACTORY_BURN_LOCAL_UPGRADE 1 //support factory sdcard burning
-#define CONFIG_POWER_KEY_NOT_SUPPORTED_FOR_BURN 1 //There isn't power-key for factory sdcard burning
-#define CONFIG_SD_BURNING_SUPPORT_UI 1 //Displaying upgrading progress bar when sdcard/udisk burning
-
#define CONFIG_AML_SECURITY_KEY 1
#ifndef DTB_BIND_KERNEL
#define CONFIG_UNIFY_KEY_MANAGE 1
@@ -352,7 +326,6 @@
/*file system*/
#define CONFIG_DOS_PARTITION 1
-#define CONFIG_AML_PARTITION 1
#define CONFIG_MMC 1
#define CONFIG_FS_FAT 1
#define CONFIG_FS_EXT4 1
diff --git a/board/khadas/kvim/kvim.c b/board/khadas/kvim/kvim.c
index b1fdb96..41a056a 100644
--- a/board/khadas/kvim/kvim.c
+++ b/board/khadas/kvim/kvim.c
@@ -71,6 +71,23 @@ int dram_init(void)
void secondary_boot_func(void)
{
}
+
+/*
+ * Discover the boot device within MicroSD or eMMC
+ * and return 1 for eMMC, otherwise 0.
+ */
+#define BOOT_DEVICE_RESERVED 0
+#define BOOT_DEVICE_EMMC 1
+#define BOOT_DEVICE_NAND 2
+#define BOOT_DEVICE_SPI 3
+#define BOOT_DEVICE_SD 4
+#define BOOT_DEVICE_USB 5
+
+int get_boot_device(void)
+{
+ return readl(AO_SEC_GP_CFG0) & 0xf;
+}
+
void internalPhyConfig(struct phy_device *phydev)
{
/*Enable Analog and DSP register Bank access by*/
@@ -263,8 +280,21 @@ int board_mmc_init(bd_t *bis)
#else
//board_mmc_register(SDIO_PORT_B);
#endif
- board_mmc_register(SDIO_PORT_B);
- board_mmc_register(SDIO_PORT_C);
+ switch (get_boot_device())
+ {
+ case BOOT_DEVICE_EMMC:
+ board_mmc_register(SDIO_PORT_C); // "mmc0"
+ board_mmc_register(SDIO_PORT_B);
+ break;
+ case BOOT_DEVICE_SD:
+ board_mmc_register(SDIO_PORT_B); // "mmc0"
+ board_mmc_register(SDIO_PORT_C);
+ break;
+ default:
+ printf("No available mmc device! Check boot device!\n");
+ do_reset(NULL, 0, 0, NULL);
+ break;
+ }
// board_mmc_register(SDIO_PORT_B1);
#if defined(CONFIG_ENV_IS_NOWHERE) && defined(CONFIG_AML_SD_EMMC)
/* try emmc here. */
@@ -413,58 +443,9 @@ U_BOOT_CMD(hdmi_init, CONFIG_SYS_MAXARGS, 0, do_hdmi_init,
#endif
#ifdef CONFIG_BOARD_LATE_INIT
int board_late_init(void){
- /* ENV need update in following cases:
- * - Bootloader upgrade
- * - New ROM upgrade(the built-in bootloader might be changed)
- */
- run_command("get_rebootmode;" \
- "echo reboot_mode=${reboot_mode};" \
- "if test ${reboot_mode} = factory_reset; then " \
- "defenv_reserv aml_dt;" \
- "setenv upgrade_step 2;" \
- "save;" \
- "fi;", 0);
- run_command("if itest ${upgrade_step} == 1; then " \
- "defenv_reserv;" \
- "setenv upgrade_step 2;" \
- "saveenv;" \
- "fi;", 0);
-
/* HDMI setup */
run_command("hdmitx hpd", 0);
run_command("vout output $outputmode", 0);
- /* Load DTB */
-#ifndef DTB_BIND_KERNEL
- int ret;
- ret = run_command("store dtb read $dtb_mem_addr", 1);
- if (ret) {
- printf("%s(): [store dtb read $dtb_mem_addr] fail\n", __func__);
- #ifdef CONFIG_DTB_MEM_ADDR
- char cmd[64];
- printf("load dtb to %x\n", CONFIG_DTB_MEM_ADDR);
- sprintf(cmd, "store dtb read %x", CONFIG_DTB_MEM_ADDR);
- ret = run_command(cmd, 1);
- if (ret) {
- printf("%s(): %s fail\n", __func__, cmd);
- }
- #endif
- }
-#elif defined(CONFIG_DTB_MEM_ADDR)
- {
- char cmd[128];
- int ret;
- if (!getenv("dtb_mem_addr")) {
- sprintf(cmd, "setenv dtb_mem_addr 0x%x", CONFIG_DTB_MEM_ADDR);
- run_command(cmd, 0);
- }
- sprintf(cmd, "imgread dtb boot ${dtb_mem_addr}");
- ret = run_command(cmd, 0);
- if (ret) {
- printf("%s(): cmd[%s] fail, ret=%d\n", __func__, cmd, ret);
- }
- }
-#endif// #ifndef DTB_BIND_KERNEL
-
/* Khadas VIM check */
run_command("saradc open 1;" \
"if saradc get_in_range 0x1a0 0x220; then " \
diff --git a/drivers/mmc/aml_sd_emmc.c b/drivers/mmc/aml_sd_emmc.c
index 4d3a84f..f8aa8f7 100644
--- a/drivers/mmc/aml_sd_emmc.c
+++ b/drivers/mmc/aml_sd_emmc.c
@@ -787,7 +787,6 @@ void sd_emmc_register(struct aml_card_sd_info * aml_priv)
#endif
cfg->f_min = 400000;
cfg->f_max = 40000000;
- cfg->part_type = PART_TYPE_AML;
cfg->b_max = 256;
mmc_create(cfg,aml_priv);
}
--
2.7.4