Radix cross Linux

Radix Linux distribution for embedded systems.

637 Commits   4 Branches   3 Tags
author: Andrey V.Kosteltsev <kx@radix.pro> 2016-10-28 21:07:45 +0000 committer: Andrey V.Kosteltsev <kx@radix.pro> 2016-10-28 21:07:45 +0000 commit: 76d426714ca0d081814a9c573212e6173aeffda5 parent: 6ef6e156e871ff8667ca708d171c878ca04d10b1
Commit Summary:
Amlogic S805 U-Boot uses arc-s8xx-elf32 toolchain for firmware
Diffstat:
21 files changed, 2457 insertions, 1 deletion
diff --git a/boot/u-boot/s805/2011.03-20160716/Makefile b/boot/u-boot/s805/2011.03-20160716/Makefile
new file mode 100644
index 000000000..97602b6b4
--- /dev/null
+++ b/boot/u-boot/s805/2011.03-20160716/Makefile
@@ -0,0 +1,283 @@
+
+COMPONENT_TARGETS  = $(HARDWARE_M201)
+COMPONENT_TARGETS += $(HARDWARE_MXQ)
+
+NEED_ABS_PATH     = true
+
+COMPONENT_IS_3PP  = true
+
+
+include ../../../../build-system/constants.mk
+
+
+SOURCE_REQUIRES   = sources/U-Boot/Amlogic/M201
+
+ifneq ($(filter $(HARDWARE),$(HARDWARE_M201)),)
+REQUIRES          = boot/kernel/s805/3.10.33-20150117
+endif
+ifneq ($(filter $(HARDWARE),$(HARDWARE_MXQ)),)
+REQUIRES          = boot/kernel/s805/3.10.103-20160830
+endif
+
+# ======= __END_OF_REQUIRES__ =======
+
+
+DEFAULT_NFS_ROOT_IP_ADDR = 172.16.0.3
+ifneq ($(filter $(HARDWARE),$(HARDWARE_M201)),)
+DEFAULT_NFS_ROOT_PATH    = "nfsroot-m201"
+DEFAULT_HW_ADDR          = 2a:ab:c0:c4:41:4a
+endif
+ifneq ($(filter $(HARDWARE),$(HARDWARE_MXQ)),)
+DEFAULT_NFS_ROOT_PATH    = "nfsroot-mxq"
+DEFAULT_HW_ADDR          = 2a:ab:c0:58:b1:8d
+endif
+
+
+version         = 2011.03-20160716
+tar_xz_archive  = $(SRC_PACKAGE_PATH)/U-Boot/Amlogic/M201/u-boot-aml-$(version).tar.xz
+SRC_ARCHIVE     = $(tar_xz_archive)
+SRC_DIR         = $(TARGET_BUILD_DIR)/u-boot-aml-$(version)
+src_done        = $(TARGET_BUILD_DIR)/.source_done
+
+u_boot          = $(TARGET_BUILD_DIR)/.u_boot_done
+
+ifneq ($(filter $(HARDWARE),$(HARDWARE_M201)),)
+u_boot_config   = m8b_m201_512M_config
+endif
+ifneq ($(filter $(HARDWARE),$(HARDWARE_MXQ)),)
+u_boot_config   = m8b_m201_1G_config
+endif
+
+boot_script_sd  = $(TARGET_BUILD_DIR)/boot.script.sd
+boot_scr_sd     = $(TARGET_BUILD_DIR)/boot.scr.sd
+
+boot_records         = $(TARGET_BUILD_DIR)/$(HARDWARE).boot-records
+boot_fat32fs         = $(TARGET_BUILD_DIR)/$(HARDWARE).fat32fs
+install_boot_records = $(TARGET_BUILD_DIR)/.boot_records_done
+
+
+PATCHES = PATCHES
+
+
+ifneq ($(filter $(TOOLCHAIN),$(TOOLCHAIN_S805_GLIBC)),)
+ARCH = arm
+endif
+
+USE_TARGET_DEST_DIR_SYSROOT = no
+
+
+####### Targets
+
+PKG_GROUP = boot
+
+
+UBOOT_BIN_PKG_NAME                = u-boot
+UBOOT_BIN_PKG_VERSION             = 2011.03
+UBOOT_BIN_PKG_ARCH                = $(TOOLCHAIN)
+UBOOT_BIN_PKG_DISTRO_NAME         = $(DISTRO_NAME)
+UBOOT_BIN_PKG_DISTRO_VERSION      = $(DISTRO_VERSION)
+UBOOT_BIN_PKG_GROUP               = $(PKG_GROUP)
+###                                |---handy-ruler-------------------------------|
+UBOOT_BIN_PKG_SHORT_DESCRIPTION   = Amlogic S805 meson8b M201 U-Boot
+UBOOT_BIN_PKG_URL                 = $(BUG_URL)
+UBOOT_BIN_PKG_LICENSE             = custom
+UBOOT_BIN_PKG_DESCRIPTION_FILE    = $(TARGET_BUILD_DIR)/$(UBOOT_BIN_PKG_NAME)-pkg-description
+UBOOT_BIN_PKG_DESCRIPTION_FILE_IN = $(UBOOT_BIN_PKG_NAME)-pkg-description.in
+UBOOT_BIN_PKG_INSTALL_SCRIPT      = $(UBOOT_BIN_PKG_NAME)-pkg-install.sh
+
+UBOOT_BIN_PKG      = $(CURDIR)/$(TARGET_BUILD_DIR)/$(UBOOT_BIN_PKG_NAME)-package
+
+build_uboot_pkg    = $(TARGET_BUILD_DIR)/.u_boot_pkg_done
+
+pkg_basename       = $(UBOOT_BIN_PKG_NAME)-$(UBOOT_BIN_PKG_VERSION)-$(UBOOT_BIN_PKG_ARCH)-$(UBOOT_BIN_PKG_DISTRO_NAME)-$(UBOOT_BIN_PKG_DISTRO_VERSION)
+
+pkg_archive        = $(TARGET_BUILD_DIR)/$(PKG_GROUP)/$(pkg_basename).$(pkg_arch_suffix)
+pkg_signature      = $(call sign-name,$(pkg_archive))
+pkg_description    = $(call desc-name,$(pkg_archive))
+products           = $(call pkg-files,$(pkg_archive))
+
+BUILD_TARGETS      = $(u_boot)
+BUILD_TARGETS     += $(boot_script_sd)
+BUILD_TARGETS     += $(boot_scr_sd)
+BUILD_TARGETS     += $(build_uboot_pkg)
+BUILD_TARGETS     += $(install_boot_records)
+
+PRODUCT_TARGETS    = $(products)
+
+ROOTFS_TARGETS     = $(pkg_archive)
+
+
+include ../../../../build-system/core.mk
+
+#
+# ARC toolchain
+#
+AMLOGIC_EM4_TOOLCHAIN_PATH  = /opt/toolchain/arc-S8XX-elf32-newlib/1.1.2
+
+AML_COMLILERS  = ARCCC=$(AMLOGIC_EM4_TOOLCHAIN_PATH)/bin/arc-s8xx-elf32-gcc
+AML_COMLILERS += ARCASM=$(AMLOGIC_EM4_TOOLCHAIN_PATH)/bin/arc-s8xx-elf32-as
+AML_COMLILERS += ARCLD=$(AMLOGIC_EM4_TOOLCHAIN_PATH)/bin/arc-s8xx-elf32-ld
+AML_COMLILERS += ARCOBJCOPY=$(AMLOGIC_EM4_TOOLCHAIN_PATH)/bin/arc-s8xx-elf32-objcopy
+AML_COMLILERS += ARCDUMPELF=$(AMLOGIC_EM4_TOOLCHAIN_PATH)/bin/arc-s8xx-elf32-elfdump
+AML_COMLILERS += ARCOBJDUMP=$(AMLOGIC_EM4_TOOLCHAIN_PATH)/bin/arc-s8xx-elf32-objdump
+AML_COMLILERS += ARCCPP=$(AMLOGIC_EM4_TOOLCHAIN_PATH)/bin/arc-s8xx-elf32-cpp
+
+#
+# ARM toolchain
+#
+AMLOGIC_S805_TOOLCHAIN_PATH = /opt/toolchain/3pp/Amlogic-S805/arm-S805-lite
+AMLOGIC_S805_CROSS_PREFIX   = $(AMLOGIC_S805_TOOLCHAIN_PATH)/bin/arm-none-eabi-
+
+
+logos_path    = $(CURDIR)/logo
+logo_fname    = radix-2CPU-224x96-32bpp.bmp
+
+u_boot_logos  = radix-2CPU-224x96.bmp
+u_boot_logos += radix-2CPU-224x96-16bpp.bmp
+u_boot_logos += radix-2CPU-224x96-24bpp.bmp
+u_boot_logos += radix-2CPU-224x96-32bpp.bmp
+
+hdmi_display_width  = 1920
+hdmi_display_height = 1080
+hdmi_output_mode    = 1080p
+video_output_mode   = hdmi
+
+#
+# alternative settings:
+# --------------------
+# hdmi_display_width  = 1280
+# hdmi_display_height =  720
+# hdmi_output_mode    =  720p
+# video_output_mode   = hdmi
+#
+
+#
+# Extra kernel boot arguments:
+#
+extra  = logo=osd1,loaded,0x7900000,$(hdmi_output_mode),full
+extra += vdaccfg=0xa001
+extra += cvbsmode=576cvbs
+extra += hdmimode=$(hdmi_output_mode)
+extra += hdmitx=cec0xf
+extra += vout=$(video_output_mode)
+extra += m_bpp=32
+extra += mac=$(DEFAULT_HW_ADDR)
+
+
+####### Dependencies
+
+ifneq ($(filter $(HARDWARE),$(HARDWARE_M201)),)
+device_dtb  = meson8b_m201_512M.dtb
+endif
+ifneq ($(filter $(HARDWARE),$(HARDWARE_MXQ)),)
+device_dtb  = meson8b-mxq.dtb
+endif
+
+$(src_done): $(SRC_ARCHIVE) $(PATCHES_DEP)
+	$(UNPACK_SRC_ARCHIVE)
+	$(APPLY_PATCHES)
+	@touch $@
+
+UMAKE := CONFIG_NOSOFTFLOAT=1 $(MAKE) -C $(SRC_DIR) CROSS_COMPILE="$(AMLOGIC_S805_CROSS_PREFIX)" $(AML_COMLILERS)
+
+$(u_boot): $(src_done)
+	$(UMAKE)  $(u_boot_config)
+	$(UMAKE)
+	@touch $@
+
+$(boot_script_sd): $(u_boot)
+	@( echo "mmcinfo"                                           > $(boot_script_sd) && \
+	   echo "fatload mmc 0:1 0x12000000 uImage"                >> $(boot_script_sd) && \
+	   echo "fatload mmc 0:1 0x12800000 $(device_dtb)"         >> $(boot_script_sd) && \
+	   echo "fatload mmc 0:1 0x13000000 $(logo_fname)"         >> $(boot_script_sd) && \
+	   echo "setenv display_width $(hdmi_display_width)"       >> $(boot_script_sd) && \
+	   echo "setenv display_height $(hdmi_display_height)"     >> $(boot_script_sd) && \
+	   echo "setenv hdmimode $(hdmi_output_mode)"              >> $(boot_script_sd) && \
+	   echo "setenv outputmode $(hdmi_output_mode)"            >> $(boot_script_sd) && \
+	   echo "video dev open $(hdmi_output_mode)"               >> $(boot_script_sd) && \
+	   echo "bmp display 0x13000000"                           >> $(boot_script_sd) && \
+	   echo "bmp scale"                                        >> $(boot_script_sd) && \
+	   echo "setenv bootargs 'console=ttyS0,115200n8 ro root=/dev/mmcblk0p2 rootfstype=ext4 no_console_suspend $(extra)'" >> $(boot_script_sd) && \
+	   echo "bootm 0x12000000 - 0x12800000"                    >> $(boot_script_sd) \
+	 )
+
+$(boot_scr_sd): $(boot_script_sd)
+	$(SRC_DIR)/build/tools/mkimage -A $(ARCH) -T script -C none -n "Boot Script" -d $< $@
+
+$(build_uboot_pkg): $(boot_scr_sd)
+	@mkdir -p $(TARGET_DEST_DIR)/bootfs
+	@mkdir -p $(UBOOT_BIN_PKG)/boot
+	# ======= Copy U-Boot images =======
+	@cp -a $(boot_scr_sd)   $(TARGET_DEST_DIR)/bootfs
+	@cp -a $(boot_scr_sd)   $(TARGET_DEST_DIR)/bootfs/boot.scr
+	@for logo in $(u_boot_logos) ; do \
+	   cp -a $(logos_path)/$$logo $(TARGET_DEST_DIR)/bootfs ; \
+	 done
+	@cp -a $(boot_scr_sd)   $(UBOOT_BIN_PKG)/boot
+	@cp -a $(boot_scr_sd)   $(UBOOT_BIN_PKG)/boot/boot.scr
+	@for logo in $(u_boot_logos) ; do \
+	   cp -a $(logos_path)/$$logo $(UBOOT_BIN_PKG)/boot ; \
+	 done
+	@cd $(SRC_DIR) && \
+	  cp -a build/u-boot.bin $(TARGET_DEST_DIR)/bootfs && \
+	  cp -a build/u-boot.bin  $(UBOOT_BIN_PKG)/boot
+	@chmod a-x $(UBOOT_BIN_PKG)/boot/u-boot*.bin
+	@mkdir -p $(UBOOT_BIN_PKG)/usr/doc/u-boot-aml-$(version)
+	@cp -a $(SRC_DIR)/COPYING $(SRC_DIR)/CREDITS $(SRC_DIR)/README \
+	       $(UBOOT_BIN_PKG)/usr/doc/u-boot-aml-$(version)
+	@touch $@
+
+$(boot_records): $(build_uboot_pkg)
+	@$(DD) if=/dev/zero of=$@ bs=512 count=2048 conv=notrunc
+	# ======= Setup u-boot into unallocated space of disk image =======
+	@$(DD) if=$(UBOOT_BIN_PKG)/boot/u-boot.bin of=$@ bs=1 count=442       conv=notrunc
+	@$(DD) if=$(UBOOT_BIN_PKG)/boot/u-boot.bin of=$@ bs=512 skip=1 seek=1 conv=notrunc
+	@touch $@
+
+$(boot_fat32fs): $(build_uboot_pkg)
+	@$(DD) if=/dev/zero of=$@ bs=1M count=511
+	# ======= Create FAT32 boot partition image =======
+	@$(MKDOSFS) -F 32 -n bootfs $@
+	@$(MCOPY) -i $@ $(TARGET_DEST_DIR)/bootfs/u-boot.bin ::/
+	@$(MCOPY) -i $@ $(TARGET_DEST_DIR)/bootfs/boot.scr   ::/
+	@for logo in $(u_boot_logos) ; do \
+	   $(MCOPY) -i $@ $(logos_path)/$$logo               ::/ ; \
+	 done
+	@for dtb in $(device_dtb) ; do \
+	   $(MCOPY) -i $@ $(TARGET_DEST_DIR)/bootfs/$$dtb    ::/ ; \
+	 done
+	@$(MCOPY) -i $@ $(TARGET_DEST_DIR)/bootfs/uImage     ::/
+	@$(DOSFSCK) -a $@
+	@touch $@
+
+$(install_boot_records): $(boot_records) $(boot_fat32fs)
+	@$(BUILDSYSTEM)/install_targets         \
+	   --destination=$(PRODUCTS_DEST_DIR)   \
+	   --toolchain=$(TOOLCHAIN)             \
+	   --hardware=$(HARDWARE)               \
+	   --flavour=$(FLAVOUR)                 \
+	   $^
+	@touch $@
+
+$(UBOOT_BIN_PKG_DESCRIPTION_FILE): $(UBOOT_BIN_PKG_DESCRIPTION_FILE_IN)
+	@cat $< | $(SED) -e "s/@VERSION@/$(UBOOT_BIN_PKG_VERSION)/g" | \
+	          $(SED) -e "s/@HARDWARE_SPEC@/$(HW_SPEC)/g"> $@
+
+$(pkg_signature)   : $(pkg_archive) ;
+$(pkg_description) : $(pkg_archive) ;
+
+$(pkg_archive): $(install_boot_records) $(UBOOT_BIN_PKG_DESCRIPTION_FILE) $(UBOOT_BIN_PKG_INSTALL_SCRIPT)
+	@cp $(UBOOT_BIN_PKG_DESCRIPTION_FILE) $(UBOOT_BIN_PKG)/.DESCRIPTION
+	@cp $(UBOOT_BIN_PKG_INSTALL_SCRIPT) $(UBOOT_BIN_PKG)/.INSTALL
+	@chmod a+x $(UBOOT_BIN_PKG)/.INSTALL
+	@$(BUILD_PKG_REQUIRES) $(UBOOT_BIN_PKG)/.REQUIRES
+	@echo "pkgname=$(UBOOT_BIN_PKG_NAME)"                            >  $(UBOOT_BIN_PKG)/.PKGINFO ; \
+	 echo "pkgver=$(UBOOT_BIN_PKG_VERSION)"                          >> $(UBOOT_BIN_PKG)/.PKGINFO ; \
+	 echo "arch=$(UBOOT_BIN_PKG_ARCH)"                               >> $(UBOOT_BIN_PKG)/.PKGINFO ; \
+	 echo "distroname=$(UBOOT_BIN_PKG_DISTRO_NAME)"                  >> $(UBOOT_BIN_PKG)/.PKGINFO ; \
+	 echo "distrover=$(UBOOT_BIN_PKG_DISTRO_VERSION)"                >> $(UBOOT_BIN_PKG)/.PKGINFO ; \
+	 echo "group=$(UBOOT_BIN_PKG_GROUP)"                             >> $(UBOOT_BIN_PKG)/.PKGINFO ; \
+	 echo "short_description=\"$(UBOOT_BIN_PKG_SHORT_DESCRIPTION)\"" >> $(UBOOT_BIN_PKG)/.PKGINFO ; \
+	 echo "url=$(UBOOT_BIN_PKG_URL)"                                 >> $(UBOOT_BIN_PKG)/.PKGINFO ; \
+	 echo "license=$(UBOOT_BIN_PKG_LICENSE)"                         >> $(UBOOT_BIN_PKG)/.PKGINFO
+	@$(FAKEROOT) sh -c "cd $(UBOOT_BIN_PKG) && chown -R root:root . && $(MAKE_PACKAGE) --linkadd yes .."
diff --git a/boot/u-boot/s805/2011.03-20160716/PATCHES b/boot/u-boot/s805/2011.03-20160716/PATCHES
new file mode 100644
index 000000000..03ffaebf4
--- /dev/null
+++ b/boot/u-boot/s805/2011.03-20160716/PATCHES
@@ -0,0 +1,5 @@
+
+../../../../sources/U-Boot/Amlogic/M201/patches/u-boot-aml-2011.03-20160716-gcc5.patch             -p0
+../../../../sources/U-Boot/Amlogic/M201/patches/u-boot-aml-2011.03-20160716-m8b_m201.patch         -p0
+../../../../sources/U-Boot/Amlogic/M201/patches/u-boot-aml-2011.03-20160716-m8b_m201-mmcboot.patch -p0
+../../../../sources/U-Boot/Amlogic/M201/patches/u-boot-aml-2011.03-20160716-m8b_m201-fbset.patch   -p0
diff --git a/boot/u-boot/s805/2011.03-20160716/logo/radix-2CPU-224x96-16bpp.bmp b/boot/u-boot/s805/2011.03-20160716/logo/radix-2CPU-224x96-16bpp.bmp
new file mode 100644
index 000000000..2e4d72eac
Binary files /dev/null and b/boot/u-boot/s805/2011.03-20160716/logo/radix-2CPU-224x96-16bpp.bmp differ
diff --git a/boot/u-boot/s805/2011.03-20160716/logo/radix-2CPU-224x96-24bpp.bmp b/boot/u-boot/s805/2011.03-20160716/logo/radix-2CPU-224x96-24bpp.bmp
new file mode 100644
index 000000000..1931a0bf0
Binary files /dev/null and b/boot/u-boot/s805/2011.03-20160716/logo/radix-2CPU-224x96-24bpp.bmp differ
diff --git a/boot/u-boot/s805/2011.03-20160716/logo/radix-2CPU-224x96-32bpp.bmp b/boot/u-boot/s805/2011.03-20160716/logo/radix-2CPU-224x96-32bpp.bmp
new file mode 100644
index 000000000..44d1ac04f
Binary files /dev/null and b/boot/u-boot/s805/2011.03-20160716/logo/radix-2CPU-224x96-32bpp.bmp differ
diff --git a/boot/u-boot/s805/2011.03-20160716/logo/radix-2CPU-224x96-argb.xcf b/boot/u-boot/s805/2011.03-20160716/logo/radix-2CPU-224x96-argb.xcf
new file mode 100644
index 000000000..8539b21c1
Binary files /dev/null and b/boot/u-boot/s805/2011.03-20160716/logo/radix-2CPU-224x96-argb.xcf differ
diff --git a/boot/u-boot/s805/2011.03-20160716/logo/radix-2CPU-224x96-xrgb.xcf b/boot/u-boot/s805/2011.03-20160716/logo/radix-2CPU-224x96-xrgb.xcf
new file mode 100644
index 000000000..15f2bf2ff
Binary files /dev/null and b/boot/u-boot/s805/2011.03-20160716/logo/radix-2CPU-224x96-xrgb.xcf differ
diff --git a/boot/u-boot/s805/2011.03-20160716/logo/radix-2CPU-224x96.bmp b/boot/u-boot/s805/2011.03-20160716/logo/radix-2CPU-224x96.bmp
new file mode 100644
index 000000000..223884f40
Binary files /dev/null and b/boot/u-boot/s805/2011.03-20160716/logo/radix-2CPU-224x96.bmp differ
diff --git a/boot/u-boot/s805/2011.03-20160716/u-boot-pkg-description.in b/boot/u-boot/s805/2011.03-20160716/u-boot-pkg-description.in
new file mode 100644
index 000000000..464bcad4c
--- /dev/null
+++ b/boot/u-boot/s805/2011.03-20160716/u-boot-pkg-description.in
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description.  Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in.  You must
+# make exactly 11 lines for the formatting to be correct.  It's also
+# customary to leave one space after the ':'.
+
+      |-----handy-ruler------------------------------------------------------|
+u-boot: U-Boot @VERSION@ for @HARDWARE_SPEC@ board
+u-boot:
+u-boot: Amlogic clone of the U-Boot, a boot loader for Embedded
+u-boot: boards based on PowerPC, ARM, MIPS and several other processors,
+u-boot: which can be installed in a boot ROM and used to initialize and
+u-boot: test the hardware or to download and run application code.
+u-boot:
+u-boot: Original DENX Git Repository: git://git.denx.de/u-boot.git
+u-boot:
+u-boot: Amlogic: http://openlinux.amlogic.com:8000/download/ARM/u-boot
+u-boot:
diff --git a/boot/u-boot/s805/2011.03-20160716/u-boot-pkg-install.sh b/boot/u-boot/s805/2011.03-20160716/u-boot-pkg-install.sh
new file mode 100755
index 000000000..0d7793d93
--- /dev/null
+++ b/boot/u-boot/s805/2011.03-20160716/u-boot-pkg-install.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+
+# arg 1:  the new package version
+pre_install() {
+  /bin/true
+}
+
+# arg 1:  the new package version
+post_install() {
+  /bin/true
+}
+
+# arg 1:  the new package version
+# arg 2:  the old package version
+pre_update() {
+  /bin/true
+}
+
+# arg 1:  the new package version
+# arg 2:  the old package version
+post_update() {
+  post_install
+}
+
+# arg 1:  the old package version
+pre_remove() {
+  /bin/true
+}
+
+# arg 1:  the old package version
+post_remove() {
+  /bin/true
+}
+
+
+operation=$1
+shift
+
+$operation $*
diff --git a/sources/U-Boot/Amlogic/M201/Makefile b/sources/U-Boot/Amlogic/M201/Makefile
index fea191f5c..df66c5cc6 100644
--- a/sources/U-Boot/Amlogic/M201/Makefile
+++ b/sources/U-Boot/Amlogic/M201/Makefile
@@ -8,6 +8,7 @@ include ../../../../build-system/constants.mk
 url         = $(DOWNLOAD_SERVER)/sources/U-Boot/Amlogic/M201
 
 versions    = 2011.03-20150117
+versions   += 2011.03-20160716
 
 tarballs    = $(addsuffix .tar.xz, $(addprefix u-boot-aml-, $(versions)))
 sha1s       = $(addsuffix .sha1sum, $(tarballs))
@@ -16,6 +17,10 @@ patches     = $(CURDIR)/patches/u-boot-aml-2011.03-20150117-gcc5.patch
 patches    += $(CURDIR)/patches/u-boot-aml-2011.03-20150117-m8b_m201.patch
 patches    += $(CURDIR)/patches/u-boot-aml-2011.03-20150117-m8b_m201-fbset.patch
 patches    += $(CURDIR)/patches/u-boot-aml-2011.03-20150117-m8b_m201-mmcboot.patch
+patches    += $(CURDIR)/patches/u-boot-aml-2011.03-20160716-gcc5.patch
+patches    += $(CURDIR)/patches/u-boot-aml-2011.03-20160716-m8b_m201.patch
+patches    += $(CURDIR)/patches/u-boot-aml-2011.03-20160716-m8b_m201-fbset.patch
+patches    += $(CURDIR)/patches/u-boot-aml-2011.03-20160716-m8b_m201-mmcboot.patch
 
 .NOTPARALLEL: $(patches)
 
@@ -54,6 +59,10 @@ $(patches): $(sha1s)
 	 ( cd create-2011.03-20150117-m8b_m201-patch         ; ./create.patch.sh ) ; \
 	 ( cd create-2011.03-20150117-m8b_m201-fbset-patch   ; ./create.patch.sh ) ; \
 	 ( cd create-2011.03-20150117-m8b_m201-mmcboot-patch ; ./create.patch.sh ) ; \
+	 ( cd create-2011.03-20160716-gcc5-patch             ; ./create.patch.sh ) ; \
+	 ( cd create-2011.03-20160716-m8b_m201-patch         ; ./create.patch.sh ) ; \
+	 ( cd create-2011.03-20160716-m8b_m201-fbset-patch   ; ./create.patch.sh ) ; \
+	 ( cd create-2011.03-20160716-m8b_m201-mmcboot-patch ; ./create.patch.sh ) ; \
 	 echo -e "\n"
 
 download_clean:
diff --git a/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-gcc5-patch/create.patch.sh b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-gcc5-patch/create.patch.sh
new file mode 100755
index 000000000..bb0543bf7
--- /dev/null
+++ b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-gcc5-patch/create.patch.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=2011.03-20160716
+
+tar --files-from=file.list -xJvf ../u-boot-aml-$VERSION.tar.xz
+mv u-boot-aml-$VERSION u-boot-aml-$VERSION-orig
+
+cp -rf ./u-boot-aml-$VERSION-new ./u-boot-aml-$VERSION
+
+diff -b --unified -Nr  u-boot-aml-$VERSION-orig  u-boot-aml-$VERSION > u-boot-aml-$VERSION-gcc5.patch
+
+mv u-boot-aml-$VERSION-gcc5.patch ../patches
+
+rm -rf ./u-boot-aml-$VERSION
+rm -rf ./u-boot-aml-$VERSION-orig
diff --git a/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-gcc5-patch/file.list b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-gcc5-patch/file.list
new file mode 100644
index 000000000..bbbe00813
--- /dev/null
+++ b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-gcc5-patch/file.list
@@ -0,0 +1 @@
+u-boot-aml-2011.03-20160716/config.mk
diff --git a/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-gcc5-patch/u-boot-aml-2011.03-20160716-new/config.mk b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-gcc5-patch/u-boot-aml-2011.03-20160716-new/config.mk
new file mode 100644
index 000000000..2a5d7b956
--- /dev/null
+++ b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-gcc5-patch/u-boot-aml-2011.03-20160716-new/config.mk
@@ -0,0 +1,274 @@
+#
+# (C) Copyright 2000-2006
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program 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.
+#
+# 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 the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+#########################################################################
+
+ifneq ($(OBJTREE),$(SRCTREE))
+ifeq ($(CURDIR),$(SRCTREE))
+dir :=
+else
+dir := $(subst $(SRCTREE)/,,$(CURDIR))
+endif
+
+obj := $(if $(dir),$(OBJTREE)/$(dir)/,$(OBJTREE)/)
+src := $(if $(dir),$(SRCTREE)/$(dir)/,$(SRCTREE)/)
+
+$(shell mkdir -p $(obj))
+else
+obj :=
+src :=
+endif
+
+# clean the slate ...
+PLATFORM_RELFLAGS =
+PLATFORM_CPPFLAGS =
+PLATFORM_LDFLAGS =
+
+#########################################################################
+
+HOSTCFLAGS	= -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89 \
+                  $(HOSTCPPFLAGS)
+HOSTSTRIP	= strip
+
+#
+# Mac OS X / Darwin's C preprocessor is Apple specific.  It
+# generates numerous errors and warnings.  We want to bypass it
+# and use GNU C's cpp.	To do this we pass the -traditional-cpp
+# option to the compiler.  Note that the -traditional-cpp flag
+# DOES NOT have the same semantics as GNU C's flag, all it does
+# is invoke the GNU preprocessor in stock ANSI/ISO C fashion.
+#
+# Apple's linker is similar, thanks to the new 2 stage linking
+# multiple symbol definitions are treated as errors, hence the
+# -multiply_defined suppress option to turn off this error.
+#
+
+ifeq ($(HOSTOS),darwin)
+# get major and minor product version (e.g. '10' and '6' for Snow Leopard)
+DARWIN_MAJOR_VERSION	= $(shell sw_vers -productVersion | cut -f 1 -d '.')
+DARWIN_MINOR_VERSION	= $(shell sw_vers -productVersion | cut -f 2 -d '.')
+
+os_x_before	= $(shell if [ $(DARWIN_MAJOR_VERSION) -le $(1) -a \
+	$(DARWIN_MINOR_VERSION) -le $(2) ] ; then echo "$(3)"; else echo "$(4)"; fi ;)
+
+# Snow Leopards build environment has no longer restrictions as described above
+HOSTCC		 = $(call os_x_before, 10, 5, "cc", "gcc")
+HOSTCFLAGS	+= $(call os_x_before, 10, 4, "-traditional-cpp")
+HOSTLDFLAGS	+= $(call os_x_before, 10, 5, "-multiply_defined suppress")
+else
+HOSTCC		= gcc
+endif
+
+ifeq ($(HOSTOS),cygwin)
+HOSTCFLAGS	+= -ansi
+endif
+
+# We build some files with extra pedantic flags to try to minimize things
+# that won't build on some weird host compiler -- though there are lots of
+# exceptions for files that aren't complaint.
+
+HOSTCFLAGS_NOPED = $(filter-out -pedantic,$(HOSTCFLAGS))
+#HOSTCFLAGS	+= -pedantic
+
+#########################################################################
+#
+# Option checker (courtesy linux kernel) to ensure
+# only supported compiler options are used
+#
+cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
+		> /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
+
+#
+# Include the make variables (CC, etc...)
+#
+AS	= $(CROSS_COMPILE)as
+LD	= $(CROSS_COMPILE)ld
+CC	= $(CROSS_COMPILE)gcc
+CPP	= $(CC) -E
+AR	= $(CROSS_COMPILE)ar
+NM	= $(CROSS_COMPILE)nm
+LDR	= $(CROSS_COMPILE)ldr
+STRIP	= $(CROSS_COMPILE)strip
+OBJCOPY = $(CROSS_COMPILE)objcopy
+OBJDUMP = $(CROSS_COMPILE)objdump
+RANLIB	= $(CROSS_COMPILE)RANLIB
+MKDIR	= mkdir
+#########################################################################
+
+# Load generated board configuration
+sinclude $(OBJTREE)/include/autoconf.mk
+sinclude $(OBJTREE)/include/config.mk
+
+# Some architecture config.mk files need to know what CPUDIR is set to,
+# so calculate CPUDIR before including ARCH/SOC/CPU config.mk files.
+# Check if arch/$ARCH/cpu/$CPU exists, otherwise assume arch/$ARCH/cpu contains
+# CPU-specific code.
+CPUDIR=arch/$(ARCH)/cpu/$(CPU)
+
+ifneq ($(SRCTREE)/$(CPUDIR),$(wildcard $(SRCTREE)/$(CPUDIR)))
+CPUDIR=arch/$(ARCH)/cpu
+endif
+sinclude $(TOPDIR)/arch/$(ARCH)/config.mk	# include architecture dependend rules
+sinclude $(TOPDIR)/$(CPUDIR)/config.mk		# include  CPU	specific rules
+
+ifdef	SOC
+sinclude $(TOPDIR)/$(CPUDIR)/$(SOC)/config.mk	# include  SoC	specific rules
+endif
+ifdef	VENDOR
+BOARDDIR = $(VENDOR)/$(BOARD)
+else
+BOARDDIR = $(BOARD)
+endif
+ifdef	BOARD
+sinclude $(TOPDIR)/board/$(BOARDDIR)/config.mk	# include board specific rules
+endif
+
+#########################################################################
+
+ifneq (,$(findstring s,$(MAKEFLAGS)))
+ARFLAGS = cr
+else
+ARFLAGS = crv
+endif
+RELFLAGS= $(PLATFORM_RELFLAGS)
+DBGFLAGS= -g # -DDEBUG
+OPTFLAGS= -Os -std=gnu89 #-fomit-frame-pointer
+ifndef LDSCRIPT
+#LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds.debug
+ifeq ($(CONFIG_NAND_U_BOOT),y)
+LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds
+else
+LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
+endif
+endif
+OBJCFLAGS += --gap-fill=0xff
+
+gccincdir := $(shell $(CC) -print-file-name=include)
+
+CPPFLAGS := $(DBGFLAGS) $(OPTFLAGS) $(RELFLAGS)		\
+	-D__KERNEL__
+ifneq ($(CONFIG_SYS_TEXT_BASE),)
+CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE)
+endif
+
+ifneq ($(RESET_VECTOR_ADDRESS),)
+CPPFLAGS += -DRESET_VECTOR_ADDRESS=$(RESET_VECTOR_ADDRESS)
+endif
+
+ifneq ($(OBJTREE),$(SRCTREE))
+CPPFLAGS += -I$(OBJTREE)/include2 -I$(OBJTREE)/include
+endif
+
+CPPFLAGS += -I$(TOPDIR)/include
+CPPFLAGS += -fno-builtin -ffreestanding -nostdinc	\
+	-isystem $(gccincdir) -pipe $(PLATFORM_CPPFLAGS)
+
+ifdef BUILD_TAG
+CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes \
+	-DBUILD_TAG='"$(BUILD_TAG)"'
+else
+CFLAGS := $(CPPFLAGS) -Wall -Wstrict-prototypes
+endif
+
+CFLAGS += $(call cc-option,-fno-stack-protector)
+
+# $(CPPFLAGS) sets -g, which causes gcc to pass a suitable -g<format>
+# option to the assembler.
+AFLAGS_DEBUG :=
+
+# turn jbsr into jsr for m68k
+ifeq ($(ARCH),m68k)
+ifeq ($(findstring 3.4,$(shell $(CC) --version)),3.4)
+AFLAGS_DEBUG := -Wa,-gstabs,-S
+endif
+endif
+
+AFLAGS := $(AFLAGS_DEBUG) -D__ASSEMBLY__ $(CPPFLAGS)
+
+LDFLAGS += $(PLATFORM_LDFLAGS)
+LDFLAGS_FINAL += -Bstatic
+
+LDFLAGS_u-boot += -T $(obj)u-boot.lds $(LDFLAGS_FINAL)
+ifneq ($(CONFIG_SYS_TEXT_BASE),)
+LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
+endif
+
+# Location of a usable BFD library, where we define "usable" as
+# "built for ${HOST}, supports ${TARGET}".  Sensible values are
+# - When cross-compiling: the root of the cross-environment
+# - Linux/ppc (native): /usr
+# - NetBSD/ppc (native): you lose ... (must extract these from the
+#   binutils build directory, plus the native and U-Boot include
+#   files don't like each other)
+#
+# So far, this is used only by tools/gdb/Makefile.
+
+ifeq ($(HOSTOS),darwin)
+BFD_ROOT_DIR =		/usr/local/tools
+else
+ifeq ($(HOSTARCH),$(ARCH))
+# native
+BFD_ROOT_DIR =		/usr
+else
+#BFD_ROOT_DIR =		/LinuxPPC/CDK		# Linux/i386
+#BFD_ROOT_DIR =		/usr/pkg/cross		# NetBSD/i386
+BFD_ROOT_DIR =		/opt/powerpc
+endif
+endif
+
+#########################################################################
+
+export	HOSTCC HOSTCFLAGS HOSTLDFLAGS PEDCFLAGS HOSTSTRIP CROSS_COMPILE \
+	AS LD CC CPP AR NM STRIP OBJCOPY OBJDUMP MAKE
+export	CONFIG_SYS_TEXT_BASE PLATFORM_CPPFLAGS PLATFORM_RELFLAGS CPPFLAGS CFLAGS AFLAGS
+
+#########################################################################
+
+# Allow boards to use custom optimize flags on a per dir/file basis
+BCURDIR = $(subst $(SRCTREE)/,,$(CURDIR:$(obj)%=%))
+ALL_AFLAGS = $(AFLAGS) $(AFLAGS_$(BCURDIR)/$(@F)) $(AFLAGS_$(BCURDIR))
+ALL_CFLAGS = $(CFLAGS) $(CFLAGS_$(BCURDIR)/$(@F)) $(CFLAGS_$(BCURDIR))
+$(obj)%.s:	%.S
+	$(MKDIR) -p $(@D)
+	$(CPP) $(ALL_AFLAGS) -o $@ $<
+$(obj)%.o:	%.S
+	$(MKDIR) -p $(@D)
+	$(CC)  $(ALL_AFLAGS) -o $@ $< -c
+$(obj)%.o:	%.c
+	$(MKDIR) -p $(@D)
+	$(CC)  $(ALL_CFLAGS) -o $@ $< -c
+$(obj)%.i:	%.c
+	$(MKDIR) -p $(@D)
+	$(CPP) $(ALL_CFLAGS) -o $@ $< -c
+$(obj)%.s:	%.c
+	$(MKDIR) -p $(@D)
+	$(CC)  $(ALL_CFLAGS) -o $@ $< -c -S
+
+#########################################################################
+
+# If the list of objects to link is empty, just create an empty built-in.o
+cmd_link_o_target = $(if $(strip $1),\
+		      $(LD) $(LDFLAGS) -r -o $@ $1,\
+		      rm -f $@; $(AR) rcs $@ )
+
+#########################################################################
diff --git a/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-gcc5-patch/u-boot-aml-2011.03-20160716-new/include/linux/compiler-gcc5.h b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-gcc5-patch/u-boot-aml-2011.03-20160716-new/include/linux/compiler-gcc5.h
new file mode 100644
index 000000000..cdd1cc202
--- /dev/null
+++ b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-gcc5-patch/u-boot-aml-2011.03-20160716-new/include/linux/compiler-gcc5.h
@@ -0,0 +1,66 @@
+#ifndef __LINUX_COMPILER_H
+#error "Please don't include <linux/compiler-gcc5.h> directly, include <linux/compiler.h> instead."
+#endif
+
+#define __used				__attribute__((__used__))
+#define __must_check			__attribute__((warn_unused_result))
+#define __compiler_offsetof(a, b)	__builtin_offsetof(a, b)
+
+/* Mark functions as cold. gcc will assume any path leading to a call
+   to them will be unlikely.  This means a lot of manual unlikely()s
+   are unnecessary now for any paths leading to the usual suspects
+   like BUG(), printk(), panic() etc. [but let's keep them for now for
+   older compilers]
+
+   Early snapshots of gcc 4.3 don't support this and we can't detect this
+   in the preprocessor, but we can live with this because they're unreleased.
+   Maketime probing would be overkill here.
+
+   gcc also has a __attribute__((__hot__)) to move hot functions into
+   a special section, but I don't see any sense in this right now in
+   the kernel context */
+#define __cold			__attribute__((__cold__))
+
+#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
+
+#ifndef __CHECKER__
+# define __compiletime_warning(message) __attribute__((warning(message)))
+# define __compiletime_error(message) __attribute__((error(message)))
+#endif /* __CHECKER__ */
+
+/*
+ * Mark a position in code as unreachable.  This can be used to
+ * suppress control flow warnings after asm blocks that transfer
+ * control elsewhere.
+ *
+ * Early snapshots of gcc 4.5 don't support this and we can't detect
+ * this in the preprocessor, but we can live with this because they're
+ * unreleased.  Really, we need to have autoconf for the kernel.
+ */
+#define unreachable() __builtin_unreachable()
+
+/* Mark a function definition as prohibited from being cloned. */
+#define __noclone	__attribute__((__noclone__))
+
+/*
+ * Tell the optimizer that something else uses this function or variable.
+ */
+#define __visible __attribute__((externally_visible))
+
+/*
+ * GCC 'asm goto' miscompiles certain code sequences:
+ *
+ *   http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58670
+ *
+ * Work it around via a compiler barrier quirk suggested by Jakub Jelinek.
+ * Fixed in GCC 4.8.2 and later versions.
+ *
+ * (asm goto is automatically volatile - the naming reflects this.)
+ */
+#define asm_volatile_goto(x...)	do { asm goto(x); asm (""); } while (0)
+
+#ifdef CONFIG_ARCH_USE_BUILTIN_BSWAP
+#define __HAVE_BUILTIN_BSWAP32__
+#define __HAVE_BUILTIN_BSWAP64__
+#define __HAVE_BUILTIN_BSWAP16__
+#endif /* CONFIG_ARCH_USE_BUILTIN_BSWAP */
diff --git a/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-fbset-patch/create.patch.sh b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-fbset-patch/create.patch.sh
new file mode 100755
index 000000000..b0b2d8506
--- /dev/null
+++ b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-fbset-patch/create.patch.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=2011.03-20160716
+
+tar --files-from=file.list -xJvf ../u-boot-aml-$VERSION.tar.xz
+mv u-boot-aml-$VERSION u-boot-aml-$VERSION-orig
+
+cp -rf ./u-boot-aml-$VERSION-new ./u-boot-aml-$VERSION
+
+diff -b --unified -Nr  u-boot-aml-$VERSION-orig  u-boot-aml-$VERSION > u-boot-aml-$VERSION-m8b_m201-fbset.patch
+
+mv u-boot-aml-$VERSION-m8b_m201-fbset.patch ../patches
+
+rm -rf ./u-boot-aml-$VERSION
+rm -rf ./u-boot-aml-$VERSION-orig
diff --git a/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-fbset-patch/file.list b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-fbset-patch/file.list
new file mode 100644
index 000000000..9b671b7b8
--- /dev/null
+++ b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-fbset-patch/file.list
@@ -0,0 +1,3 @@
+u-boot-aml-2011.03-20160716/board/amlogic/configs/m8b_m201_v1.h
+u-boot-aml-2011.03-20160716/common/cmd_bmp.c
+u-boot-aml-2011.03-20160716/drivers/video/aml_video.c
diff --git a/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-fbset-patch/u-boot-aml-2011.03-20160716-new/board/amlogic/configs/m8b_m201_v1.h b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-fbset-patch/u-boot-aml-2011.03-20160716-new/board/amlogic/configs/m8b_m201_v1.h
new file mode 100644
index 000000000..bebe6a9b2
--- /dev/null
+++ b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-fbset-patch/u-boot-aml-2011.03-20160716-new/board/amlogic/configs/m8b_m201_v1.h
@@ -0,0 +1,480 @@
+#ifndef __CONFIG_M8B_M201_V1_H__
+#define __CONFIG_M8B_M201_V1_H__
+
+#define CONFIG_MACH_MESON8_M201  // generate M8 M201 machid number
+
+#define CONFIG_POWER_SPL
+#ifdef CONFIG_M201_COSTDOWN
+#define CONFIG_PWM_VDDEE_VOLTAGE            1100   //VDDEE voltage when boot, must have
+#else
+#define CONFIG_PWM_VDDEE_VOLTAGE            1100   //VDDEE voltage when boot, must have
+#endif
+#define CONFIG_PWM_VDDEE_SUSPEND_VOLTAGE    1100 //VDDEE voltage when suspend, must have
+#define CONFIG_IR_REMOTE_WAKEUP 1
+#define CONFIG_SECURITYKEY
+//#define TEST_UBOOT_BOOT_SPEND_TIME
+
+// cart type of each port
+#define PORT_A_CARD_TYPE            CARD_TYPE_UNKNOWN
+#define PORT_B_CARD_TYPE            CARD_TYPE_UNKNOWN
+#define PORT_C_CARD_TYPE            CARD_TYPE_MMC // CARD_TYPE_MMC/CARD_TYPE_SD
+
+//UART Sectoion
+#define CONFIG_CONS_INDEX   2
+
+#define CONFIG_NEXT_NAND
+//#define CONFIG_SECURE_NAND  1
+//support "boot,bootd"
+//#define CONFIG_CMD_BOOTD 1
+//#define CONFIG_AML_I2C      1
+
+//Enable HDMI Tx
+#define CONFIG_AML_HDMI_TX  1
+#define CONFIG_VIDEO_AML 1
+//Enable TV Output
+#define CONFIG_VIDEO_AMLTVOUT 1
+//Enable LCD output
+//#define CONFIG_VIDEO_AMLLCD
+//Enable CVBS
+#define CONFIG_ENABLE_CVBS 1
+
+#define LCD_BPP LCD_COLOR32
+
+#define CONFIG_OSD_SCALE_ENABLE 1
+
+#define CONFIG_ACS
+#ifdef CONFIG_ACS
+#define CONFIG_DDR_SIZE_IND_ADDR 0xD9000000	//pass memory size, spl->uboot
+#endif
+
+#ifdef CONFIG_NEXT_NAND
+#define CONFIG_CMD_IMGREAD  1   //read the actual size of boot.img/recovery.img/logo.img use cmd 'imgread'
+#define CONFIG_AML_V2_USBTOOL 1
+#define CONFIG_AUTO_START_SD_BURNING     1//1 then auto detect whether or not jump into sdc_burning when boot from external mmc card 
+#define CONFIG_SHA1
+#define CONFIG_POWER_KEY_NOT_SUPPORTED_FOR_BURN 1//power key and poweroff can't work
+#define CONFIG_SD_BURNING_SUPPORT_UI     1//have bmp display to indicate burning state when sdcard burning
+#endif//#ifdef CONFIG_NEXT_NAND
+
+#define CONFIG_UNIFY_KEY_MANAGE 1       //Support burning key with usb tool
+#define CONFIG_CMD_PWM  1
+
+//Enable storage devices
+#define CONFIG_CMD_NAND  1
+#define CONFIG_CMD_BMP 1
+
+//Enable storage devices
+#define CONFIG_CMD_SF    1
+#if defined(CONFIG_CMD_SF)
+	#define SPI_WRITE_PROTECT  1
+	#define CONFIG_CMD_MEMORY  1
+#endif /*CONFIG_CMD_SF*/
+
+//Amlogic SARADC support
+//#define CONFIG_SARADC 1
+#define CONFIG_EFUSE 1
+//#define CONFIG_MACHID_CHECK 1
+#define CONFIG_CMD_SUSPEND 1
+//#define CONFIG_IR_REMOTE 1
+#define CONFIG_IR_REMOTE 1
+#define CONFIG_L2_OFF	 1
+
+#define CONFIG_CMD_NET   1
+#if defined(CONFIG_CMD_NET)
+	#define CONFIG_AML_ETHERNET 1
+	#define RMII_PHY_INTERFACE    1
+	#define CONFIG_NET_MULTI 1
+	#define CONFIG_CMD_PING 1
+	#define CONFIG_CMD_DHCP 1
+	#define CONFIG_CMD_RARP 1
+	//#define CONFIG_NET_RGMII
+	//#define CONFIG_NET_RMII_CLK_EXTERNAL //use external 50MHz clock source
+	#define CONFIG_AML_ETHERNET    1                   /*to link /driver/net/aml_ethernet.c*/
+	#define CONFIG_HOSTNAME        arm_m8
+	#define CONFIG_ETHADDR         00:15:18:01:81:31   /* Ethernet address */
+	#define CONFIG_IPADDR          10.18.9.97          /* Our ip address */
+	#define CONFIG_GATEWAYIP       10.18.9.1           /* Our getway ip address */
+	#define CONFIG_SERVERIP        10.18.9.113         /* Tftp server ip address */
+	#define CONFIG_NETMASK         255.255.255.0
+#endif /* (CONFIG_CMD_NET) */
+
+
+#define CONFIG_SDIO_B1   1
+#define CONFIG_SDIO_A    1
+#define CONFIG_SDIO_B    1
+#define CONFIG_SDIO_C    1
+#define CONFIG_ENABLE_EXT_DEVICE_RETRY 1
+
+
+#define CONFIG_MMU                    1
+#define CONFIG_PAGE_OFFSET 	0xc0000000
+#define CONFIG_SYS_LONGHELP	1
+
+/* USB
+ * Enable CONFIG_MUSB_HCD for Host functionalities MSC, keyboard
+ * Enable CONFIG_MUSB_UDD for Device functionalities.
+ */
+/* #define CONFIG_MUSB_UDC		1 */
+#define CONFIG_CMD_USB 1
+#if defined(CONFIG_CMD_USB)
+	#define CONFIG_M8_USBPORT_BASE_A	0xC9040000
+	#define CONFIG_M8_USBPORT_BASE_B	0xC90C0000
+	#define CONFIG_USB_STORAGE      1
+	#define CONFIG_USB_DWC_OTG_HCD  1
+	#define CONFIG_USB_DWC_OTG_294	1
+#endif //#if defined(CONFIG_CMD_USB)
+
+#define CONFIG_UCL 1
+#define CONFIG_SELF_COMPRESS 
+//#define CONFIG_PREBOOT "mw da004004 80000510;mw c81000014 4000;mw c1109900 0"
+
+#define CONFIG_CMD_AUTOSCRIPT
+
+#define CONFIG_CMD_REBOOT 1
+#define CONFIG_PREBOOT 
+
+#define  CONFIG_AML_GATE_INIT	1
+
+/* Environment information */
+#define CONFIG_BOOTDELAY	1
+#define CONFIG_BOOTFILE		boot.img
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	"loadaddr=0x12000000\0" \
+	"loadaddr_logo=0x13000000\0" \
+	"testaddr=0x12400000\0" \
+	"console=ttyS0,115200n8\0" \
+	"bootm_low=0x00000000\0" \
+	"bootm_size=0x80000000\0" \
+	"mmcargs=setenv bootargs console=${console} " \
+	"boardname=m8_board\0" \
+	"chipname=8726m8\0" \
+	"get_dt=checkhw\0" \
+	"initrd_high=60000000\0" \
+	"hdmimode=1080p\0" \
+	"cvbsmode=576cvbs\0" \
+	"outputmode=1080p\0" \
+	"vdac_config=0x10\0" \
+	"initargs=root=/dev/system rootfstype=ext4 init=/sbin/init console=ttyS0,115200n8 no_console_suspend \0" \
+	"video_dev=tvout\0" \
+	"display_width=1920\0" \
+	"display_height=1080\0" \
+	"display_bpp=32\0" \
+	"display_color_format_index=32\0" \
+	"display_layer=osd2\0" \
+	"display_color_fg=0xffffffff\0" \
+	"display_color_bg=0\0" \
+	"fb_addr=0x7900000\0" \
+	"fb_width=1920\0"\
+	"fb_height=1080\0"\
+	"partnum=2\0" \
+	"p0start=1000000\0" \
+	"p0size=400000\0" \
+	"p0path=uImage\0" \
+	"p1start=1400000\0" \
+	"p1size=8000000\0" \
+	"p1path=android.rootfs\0" \
+	"bootstart=0\0" \
+	"bootsize=100000\0" \
+	"bootpath=u-boot.bin\0" \
+	"sdcburncfg=aml_sdc_burn.ini\0"\
+	"normalstart=1000000\0" \
+	"normalsize=400000\0" \
+	"upgrade_step=0\0" \
+	"firstboot=1\0" \
+	"store=0\0"\
+	"wipe_data=success\0"\
+	"preloaddtb=imgread dtb boot ${loadaddr}\0" \
+	"preboot="\
+        "if itest ${upgrade_step} == 3; then run prepare; run storeargs; run update; fi; "\
+        "if itest ${upgrade_step} == 1; then  "\
+            "defenv; setenv upgrade_step 2; saveenv;"\
+        "fi; "\
+        "run check_rebootmode;"\
+        "run prepare;"\
+        "run storeargs;"\
+        "run update_ir; " \
+        "run switch_bootmode\0" \
+    \
+    "update_ir="\
+        "if irdetect; then run update; fi\0" \
+    \
+   	"update="\
+        /*first try usb burning, second sdc_burn, third autoscr, last recovery*/\
+        "run usb_burning; "\
+        "if mmcinfo; then "\
+            "if fatexist mmc 0 ${sdcburncfg}; then "\
+                "run sdc_burning; "\
+            "else "\
+                "if fatload mmc 0 ${loadaddr} aml_autoscript; then autoscr ${loadaddr}; fi;"\
+                "run recovery;"\
+            "fi;"\
+        "else "\
+            "run recovery;"\
+        "fi;\0"\
+    \
+   	"storeargs="\
+        "setenv bootargs ${initargs} vdaccfg=${vdac_config} logo=osd1,loaded,${fb_addr},${outputmode},full hdmimode=${hdmimode} cvbsmode=${cvbsmode} androidboot.firstboot=${firstboot} hdmitx=${cecconfig}\0"\
+    \
+	"switch_bootmode="\
+        "if test ${reboot_mode} = factory_reset; then "\
+			"run recovery;"\
+        "else if test ${reboot_mode} = update; then "\
+        	"run update;"\
+        "else if test ${reboot_mode} = usb_burning; then "\
+        	"run usb_burning;"\
+		"else if test ${wipe_data} = failed; then "\
+			"echo wipe_data=${wipe_data}; run recovery;"\
+        "else " \
+        	"  "\
+        "fi;fi;fi;fi\0" \
+    \
+    "prepare="\
+        "logo size ${outputmode}; video open; video clear; video dev open ${outputmode};"\
+        "imgread pic logo bootup ${loadaddr_logo}; "\
+        "bmp display ${bootup_offset}; bmp scale;"\
+        "\0"\
+	\
+	"storeboot="\
+        "echo Booting...; "\
+        "if unifykey get usid; then  "\
+            "setenv bootargs ${bootargs} androidboot.serialno=${usid};"\
+        "fi;"\
+        "imgread kernel boot ${loadaddr};"\
+        "bootm;"\
+        "run recovery\0" \
+    \
+	"recovery="\
+        "echo enter recovery;"\
+        "if mmcinfo; then "\
+            "if fatload mmc 0 ${loadaddr} recovery.img; then bootm;fi;"\
+        "fi; "\
+        "if usb start 0; then "\
+                "if fatload usb 0 ${loadaddr} recovery.img; then bootm; fi;"\
+        "fi;"\
+	      "if imgread kernel recovery ${loadaddr}; then "\
+	        "bootm; "\
+				"else "\
+					"echo no recovery in flash; "\
+				"fi;\0" \
+    \
+    "check_rebootmode="\
+		"get_rebootmode; clear_rebootmode; echo reboot_mode=${reboot_mode};"\
+		"if test ${reboot_mode} = factory_reset; then defenv; fi;\0" \
+    \
+	"usb_burning=update 1000\0" \
+    "sdc_burning=sdc_burn ${sdcburncfg}\0"
+
+
+#define CONFIG_BOOTCOMMAND   "run storeboot"
+
+#define CONFIG_AUTO_COMPLETE	1
+#define CONFIG_ENV_SIZE         (64*1024)
+
+#define CONFIG_STORE_COMPATIBLE
+
+#ifdef  CONFIG_STORE_COMPATIBLE
+//spi
+#define CONFIG_ENV_OVERWRITE
+#define CONFIG_CMD_SAVEENV
+#define CONFIG_ENV_SECT_SIZE 0x1000
+ #define CONFIG_ENV_IN_SPI_OFFSET 0x100000
+//nand
+#define CONFIG_ENV_IN_NAND_OFFSET 0x400000
+#define CONFIG_ENV_BLOCK_NUM 2
+//emmc
+#define CONFIG_SYS_MMC_ENV_DEV 1
+#define CONFIG_ENV_IN_EMMC_OFFSET 0x80000
+
+#else
+
+//#define CONFIG_SPI_BOOT 1
+#define CONFIG_MMC_BOOT
+//#define CONFIG_NAND_BOOT 1
+
+#ifdef CONFIG_NAND_BOOT
+	#define CONFIG_AMLROM_NANDBOOT 1
+#endif 
+
+
+#ifdef CONFIG_SPI_BOOT
+	#define CONFIG_ENV_OVERWRITE
+	#define CONFIG_ENV_IS_IN_SPI_FLASH
+	#define CONFIG_CMD_SAVEENV	
+	#define CONFIG_ENV_SECT_SIZE		0x10000
+	#define CONFIG_ENV_OFFSET           0x1f0000
+#elif defined CONFIG_NAND_BOOT
+	#define CONFIG_ENV_IS_IN_AML_NAND
+	#define CONFIG_CMD_SAVEENV
+	#define CONFIG_ENV_OVERWRITE	
+	#define CONFIG_ENV_OFFSET       0x400000
+	#define CONFIG_ENV_BLOCK_NUM    2
+#elif defined CONFIG_MMC_BOOT
+	#define CONFIG_ENV_IS_IN_MMC
+	#define CONFIG_CMD_SAVEENV
+    #define CONFIG_SYS_MMC_ENV_DEV        0	
+	#define CONFIG_ENV_OFFSET       0x1000000		
+#else
+	#define CONFIG_ENV_IS_NOWHERE    1
+#endif
+
+#endif
+
+
+//----------------------------------------------------------------------
+//Please set the M8 CPU clock(unit: MHz)
+//legal value: 600, 792, 996, 1200
+#define M8_CPU_CLK 		    (792)
+#define CONFIG_SYS_CPU_CLK	(M8_CPU_CLK)
+//----------------------------------------------------------------------
+
+//-----------------------------------------------------------------------
+//DDR setting
+//For DDR PUB training not check the VT done flag
+#define CONFIG_NO_DDR_PUB_VT_CHECK 1
+
+//For M8 DDR clock gating disable
+//#define CONFIG_GATEACDDRCLK_DISABLE 1
+
+//For M8 DDR low power feature disable
+//#define CONFIG_DDR_LOW_POWER_DISABLE 1
+
+//For M8 DDR PUB WL/WD/RD/RG-LVT, WD/RD-BVT disable
+//#define CONFIG_PUB_WLWDRDRGLVTWDRDBVT_DISABLE 1
+
+//Please just define m8 DDR clock here only
+//current DDR clock range (408~804)MHz with fixed step 12MHz
+#define CFG_DDR_CLK    636 //696 //768  //792// (636)
+#define CFG_DDR_MODE   CFG_DDR_32BIT
+
+#ifdef CONFIG_ACS
+//#define CONFIG_DDR_MODE_AUTO_DETECT	//ddr bus-width auto detection
+#define CONFIG_DDR_SIZE_AUTO_DETECT	//ddr size auto detection
+#endif
+
+//On board DDR capactiy
+#if !(defined(CONFIG_DDR3_512MB) || defined(CONFIG_DDR3_1GB) \
+	|| defined(CONFIG_DDR3_2GB))
+	#error "Please set DDR capacity first!\n"
+#endif
+//above setting will affect following:
+//board/amlogic/m8_m201_v1/firmware/timming.c
+//arch/arm/cpu/aml_meson/m8/mmutable.s
+
+#define CONFIG_DUMP_DDR_INFO 1
+#define CONFIG_ENABLE_WRITE_LEVELING 1
+
+//DDR row/col size
+//row size.  2'b01 : A0~A12.   2'b10 : A0~A13.  2'b11 : A0~A14.  2'b00 : A0~A15.
+//col size.   2'b01 : A0~A8,      2'b10 : A0~A9  
+#define PHYS_MEMORY_START        (0x00000000) // ???
+#if   defined(CONFIG_DDR3_512MB)
+	#define CONFIG_DDR3_ROW_SIZE (2)
+	#define CONFIG_DDR3_COL_SIZE (2)
+	#define CONFIG_DDR_ROW_BITS  (14)
+	#define PHYS_MEMORY_SIZE     (0x20000000) // 512MB
+#elif defined(CONFIG_DDR3_1GB)
+	//2Gb(X16) x 4pcs
+	#define CONFIG_DDR3_ROW_SIZE (3)
+	#define CONFIG_DDR3_COL_SIZE (2)
+	#define CONFIG_DDR_ROW_BITS  (15)
+	#define PHYS_MEMORY_SIZE     (0x40000000) // 1GB
+#elif defined(CONFIG_DDR3_2GB)
+	//4Gb(X16) x 4pcs
+	#define CONFIG_DDR3_ROW_SIZE (3)
+	#define CONFIG_DDR3_COL_SIZE (2)
+	#define CONFIG_DDR_ROW_BITS  (15)
+	#define PHYS_MEMORY_SIZE     (0x80000000) // 2GB
+#endif
+
+#define CONFIG_SYS_MEMTEST_START      0x10000000  /* memtest works on */      
+#define CONFIG_SYS_MEMTEST_END        0x18000000  /* 0 ... 128 MB in DRAM */  
+#define CONFIG_ENABLE_MEM_DEVICE_TEST 1
+#define CONFIG_NR_DRAM_BANKS	      1	          /* CS1 may or may not be populated */
+
+#ifdef CONFIG_DDR_SIZE_AUTO_DETECT
+#define CONFIG_AUTO_SET_MULTI_DT_ID    //if wanna pass mem=xx to kernel, pls disable this config
+#ifndef CONFIG_AUTO_SET_MULTI_DT_ID
+#define CONFIG_AUTO_SET_BOOTARGS_MEM
+#endif
+#endif
+
+/* Pass open firmware flat tree*/
+#define CONFIG_OF_LIBFDT	1
+#define CONFIG_DT_PRELOAD	1
+#define CONFIG_SYS_BOOTMAPSZ   PHYS_MEMORY_SIZE       /* Initial Memory map for Linux */
+#define CONFIG_ANDROID_IMG	1
+
+#define CONFIG_CMD_IMGPACK 1
+
+//M8 secure boot disable
+//#define CONFIG_AML_DISABLE_CRYPTO_UBOOT 1
+
+//M8 L1 cache enable for uboot decompress speed up
+#define CONFIG_AML_SPL_L1_CACHE_ON	1
+
+//To use RSA2048 key aml-rsa-key.k2a
+#define CONFIG_AML_RSA_2048 1
+
+
+/*-----------------------------------------------------------------------
+ * power down
+ */
+//#define CONFIG_CMD_RUNARC 1 /* runarc */
+#define CONFIG_AML_SUSPEND 1
+
+#define CONFIG_CMD_LOGO
+
+/*
+* CPU switch test for uboot
+*/
+//#define CONFIG_TEST_CPU_SWITCH 1
+
+
+#if defined(CONFIG_VLSI_EMULATOR)
+   //#undef CFG_DDR3_2GB
+
+   #undef CONFIG_BOOTCOMMAND
+   #define CONFIG_BOOTCOMMAND "echo Uboot for PXP is run..."
+
+   //#define CFG_DDR3_1GB
+   #define CONFIG_NO_DDR_PUB_VT_CHECK 1
+
+   #undef CONFIG_CMD_AUTOSCRIPT
+
+   #undef CONFIG_CMD_REBOOT
+   #undef CONFIG_PREBOOT
+
+   #undef CONFIG_AML_SUSPEND
+   #undef CONFIG_CMD_SUSPEND
+
+   #define CONFIG_AML_DISABLE_CRYPTO_UBOOT
+#endif
+/*
+ * Secure OS
+ */
+#ifdef CONFIG_MESON_TRUSTZONE
+
+//#define CONFIG_MESON_SECUREARGS  1
+#define CONFIG_JOIN_UBOOT_SECUREOS 1
+#define SECUREOS_KEY_BASE_ADDR 0x06100000
+#define SECURE_OS_DECOMPRESS_ADDR 0x06200000
+#define CONFIG_SECURE_STORAGE_BURNED
+#ifdef CONFIG_SECURE_STORAGE_BURNED
+#define CONFIG_MESON_STORAGE_BURN 1
+#define CONFIG_MESON_STORAGE_DEBUG
+#define CONFIG_SECURESTORAGEKEY
+#define CONFIG_RANDOM_GENERATE
+#define CONFIG_CMD_SECURESTORE
+#define CONFIG_CMD_RANDOM
+/* secure storage support both spi and emmc */
+#define CONFIG_SECURE_MMC
+#define CONFIG_SPI_NOR_SECURE_STORAGE
+#define CONFIG_SECURE_NAND 1
+#endif // CONFIG_SECURE_STORAGE_BURNED
+
+#endif //CONFIG_MESON_TRUSTZONE
+
+
+
+#endif //__CONFIG_M8B_M201_V1_H__
diff --git a/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-fbset-patch/u-boot-aml-2011.03-20160716-new/common/cmd_bmp.c b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-fbset-patch/u-boot-aml-2011.03-20160716-new/common/cmd_bmp.c
new file mode 100644
index 000000000..729d678ad
--- /dev/null
+++ b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-fbset-patch/u-boot-aml-2011.03-20160716-new/common/cmd_bmp.c
@@ -0,0 +1,355 @@
+/*
+ * (C) Copyright 2002
+ * Detlev Zundel, DENX Software Engineering, dzu@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program 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.
+ *
+ * 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 the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/*
+ * BMP handling routines
+ */
+
+#include <common.h>
+#include <lcd.h>
+#include <bmp_layout.h>
+#include <command.h>
+#include <asm/byteorder.h>
+#include <malloc.h>
+
+static int bmp_info (ulong addr);
+static int bmp_display (ulong addr, int x, int y);
+#ifdef CONFIG_OSD_SCALE_ENABLE
+static int bmp_scale(void);
+#else
+static int bmp_scale(ulong src_addr, ulong dst_addr, unsigned int new_width,unsigned new_height);
+#endif
+
+/*
+ * Allocate and decompress a BMP image using gunzip().
+ *
+ * Returns a pointer to the decompressed image data. Must be freed by
+ * the caller after use.
+ *
+ * Returns NULL if decompression failed, or if the decompressed data
+ * didn't contain a valid BMP signature.
+ */
+#ifdef CONFIG_VIDEO_BMP_GZIP
+bmp_image_t *gunzip_bmp(unsigned long addr, unsigned long *lenp)
+{
+	void *dst;
+	unsigned long len;
+	bmp_image_t *bmp;
+
+	/*
+	 * Decompress bmp image
+	 */
+	len = CONFIG_SYS_VIDEO_LOGO_MAX_SIZE;
+	dst = malloc(CONFIG_SYS_VIDEO_LOGO_MAX_SIZE);
+	if (dst == NULL) {
+		puts("Error: malloc in gunzip failed!\n");
+		return NULL;
+	}
+	if (gunzip(dst, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE, (uchar *)addr, &len) != 0) {
+		free(dst);
+		return NULL;
+	}
+	if (len == CONFIG_SYS_VIDEO_LOGO_MAX_SIZE)
+		puts("Image could be truncated"
+				" (increase CONFIG_SYS_VIDEO_LOGO_MAX_SIZE)!\n");
+
+	bmp = dst;
+
+	/*
+	 * Check for bmp mark 'BM'
+	 */
+	if (!((bmp->header.signature[0] == 'B') &&
+	      (bmp->header.signature[1] == 'M'))) {
+		free(dst);
+		return NULL;
+	}
+
+	debug("Gzipped BMP image detected!\n");
+
+	return bmp;
+}
+#else
+bmp_image_t *gunzip_bmp(unsigned long addr, unsigned long *lenp)
+{
+	return NULL;
+}
+#endif
+
+static int do_bmp_info(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+{
+	ulong addr;
+
+	switch (argc) {
+	case 1:		/* use load_addr as default address */
+		addr = load_addr;
+		break;
+	case 2:		/* use argument */
+		addr = simple_strtoul(argv[1], NULL, 16);
+		break;
+	default:
+		return cmd_usage(cmdtp);
+	}
+
+	return (bmp_info(addr));
+}
+
+static int do_bmp_display(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+{
+	ulong addr;
+	int x = 0, y = 0;
+
+	switch (argc) {
+	case 1:		/* use load_addr as default address */
+		addr = load_addr;
+		break;
+	case 2:		/* use argument */
+		addr = simple_strtoul(argv[1], NULL, 16);
+		x = -1;
+		y = -1;
+		break;
+
+        case 5://Added by Sam, to control whether disable OSD in 'bmp display'
+	case 4:
+		addr = simple_strtoul(argv[1], NULL, 16);
+	        x = simple_strtoul(argv[2], NULL, 10);
+	        y = simple_strtoul(argv[3], NULL, 10);
+	        break;
+	default:
+		return cmd_usage(cmdtp);
+	}
+
+#ifdef CONFIG_OSD_SCALE_ENABLE
+        setenv("bmp_osd_control", argc > 4 ? argv[4] : "");//Added by Sam, to control whether disable OSD in 'bmp display'
+#endif//#ifdef CONFIG_OSD_SCALE_ENABLE
+
+	 return (bmp_display(addr, x, y));
+}
+
+static int do_bmp_scale(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
+{
+#ifndef CONFIG_OSD_SCALE_ENABLE
+	ulong src_addr,dst_addr;
+	unsigned width,height;
+
+	switch (argc) {
+	case 3:
+		src_addr = simple_strtoul(argv[1], NULL, 16);
+		dst_addr = simple_strtoul(argv[2], NULL, 16);
+		width = simple_strtoul(getenv("display_width"), NULL, 0);
+		height = simple_strtoul(getenv("display_height"), NULL, 0);
+		printf("src_addr=0x%x,dst_addr=0x%x,w=%d,h=%d\n",(uint)src_addr,(uint)dst_addr,width,height);
+		break;
+	default:
+		return cmd_usage(cmdtp);
+		break;
+	}
+	return (bmp_scale(src_addr, dst_addr, width,height));
+#else
+	return (bmp_scale());
+#endif
+}
+
+static cmd_tbl_t cmd_bmp_sub[] = {
+	U_BOOT_CMD_MKENT(info, 3, 0, do_bmp_info, "", ""),
+	U_BOOT_CMD_MKENT(display, 6, 0, do_bmp_display, "", ""),
+	U_BOOT_CMD_MKENT(scale, 4, 0, do_bmp_scale, "", ""),
+};
+
+#ifdef CONFIG_NEEDS_MANUAL_RELOC
+void bmp_reloc(void) {
+	fixup_cmdtable(cmd_bmp_sub, ARRAY_SIZE(cmd_bmp_sub));
+}
+#endif
+
+/*
+ * Subroutine:  do_bmp
+ *
+ * Description: Handler for 'bmp' command..
+ *
+ * Inputs:	argv[1] contains the subcommand
+ *
+ * Return:      None
+ *
+ */
+static int do_bmp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	cmd_tbl_t *c;
+
+	/* Strip off leading 'bmp' command argument */
+	argc--;
+	argv++;
+
+	c = find_cmd_tbl(argv[0], &cmd_bmp_sub[0], ARRAY_SIZE(cmd_bmp_sub));
+
+	if (c)
+		return  c->cmd(cmdtp, flag, argc, argv);
+	else
+		return cmd_usage(cmdtp);
+}
+
+U_BOOT_CMD(
+	bmp,	6,	1,	do_bmp,
+	"manipulate BMP image data",
+	"info <imageAddr>          - display image info\n"
+	"bmp display <imageAddr> [x y] - display image at x,y\n"
+	"bmp scale imageaddr scaleaddr 	- scale image\n"
+);
+
+/*
+ * Subroutine:  bmp_info
+ *
+ * Description: Show information about bmp file in memory
+ *
+ * Inputs:	addr		address of the bmp file
+ *
+ * Return:      None
+ *
+ */
+static int bmp_info(ulong addr)
+{
+	bmp_image_t *bmp=(bmp_image_t *)addr;
+	unsigned long len;
+
+	if (!((bmp->header.signature[0]=='B') &&
+	      (bmp->header.signature[1]=='M')))
+		bmp = gunzip_bmp(addr, &len);
+
+	if (bmp == NULL) {
+		printf("bmp_info(): There is no valid bmp file at the given address: 0x%08X\n", addr);
+		return 1;
+	}
+
+	printf("Image size    : %d x %d\n", le32_to_cpu(bmp->header.width),
+	       le32_to_cpu(bmp->header.height));
+	printf("Bits per pixel: %d\n", le16_to_cpu(bmp->header.bit_count));
+	printf("Compression   : %d\n", le32_to_cpu(bmp->header.compression));
+
+	if ((unsigned long)bmp != addr)
+		free(bmp);
+
+	return(0);
+}
+
+/*
+ * Subroutine:  bmp_display
+ *
+ * Description: Display bmp file located in memory
+ *
+ * Inputs:	addr		address of the bmp file
+ *
+ * Return:      None
+ *
+ */
+static int bmp_display(ulong addr, int x, int y)
+{
+	int ret;
+	bmp_image_t *bmp = (bmp_image_t *)addr;
+	unsigned long len;
+
+	if (!((bmp->header.signature[0]=='B') &&
+	      (bmp->header.signature[1]=='M')))
+		bmp = gunzip_bmp(addr, &len);
+
+	if (!bmp) {
+		printf("bmp_display(): There is no valid bmp file at the given address: 0x%08X\n", addr);
+		return 1;
+	}
+    
+#if (defined(CONFIG_LCD) || defined(CONFIG_VIDEO_AMLLCD) || defined(CONFIG_VIDEO) || defined(CONFIG_VIDEO_AML))
+	extern int video_display_bitmap (ulong, int, int);
+    ret = video_display_bitmap ((unsigned long)bmp, x, y);
+#else
+# error bmp_display() requires CONFIG_LCD or CONFIG_VIDEO
+#endif
+
+	if ((unsigned long)bmp != addr)
+		free(bmp);
+
+	return ret;
+}
+
+#ifdef CONFIG_OSD_SCALE_ENABLE
+static int bmp_scale(void)
+{
+	int ret = 0;
+	extern int video_scale_bitmap (void);
+	ret = video_scale_bitmap();
+	return 0;
+}
+#else
+static int bmp_scale(ulong src_addr, ulong dst_addr, unsigned int new_width,unsigned new_height)
+{
+	//ulong new_width,new_height;
+	bmp_image_t *bmp = (bmp_image_t *)src_addr;
+	bmp_image_t *bmp_dst = (bmp_image_t *)dst_addr;	
+	unsigned long len;
+
+	char *pBuf = (char*)bmp+bmp->header.data_offset;
+	printf("Begin bmp scale ...\n");
+
+	if (!((bmp->header.signature[0]=='B') &&
+		      (bmp->header.signature[1]=='M')))
+			bmp = gunzip_bmp(src_addr, &len);
+
+	if (!bmp) {
+		printf("bmp_scale(): There is no valid bmp file at the given address: 0x%08X\n", src_addr);
+		return 1;
+	}	      
+
+	memcpy(bmp_dst, bmp, sizeof(bmp_image_t));
+	bmp_dst->header.width=new_width;
+	bmp_dst->header.height=new_height;
+	char *pBuf_dst = (char*)bmp_dst+bmp_dst->header.data_offset;
+
+#if 1//Fast scale
+	int   nWidth   ,   nHeight	 ,	 nNewWidth	 ,	 nNewHeight   ,   nNewWidthBit; 
+	float m_xscale,m_yscale;
+	int i,j,x,y,oldoffset;	
+	char *pNewTmp = NULL; 
+	
+	m_xscale = (float)bmp_dst->header.width/(float)bmp->header.width;
+	m_yscale = (float)bmp_dst->header.height/(float)bmp->header.height;
+	nWidth = bmp->header.width;
+	nHeight = bmp->header.height;
+	nNewHeight = bmp_dst->header.width;
+	nNewWidth =	bmp_dst->header.width;
+	nNewWidthBit = ( 4 - nNewWidth * 3 % 4 )%4 + nNewWidth * 3;
+
+	for( i=0; i<nNewHeight; i++ )
+	{ 
+		pNewTmp = pBuf_dst + nNewWidthBit * i; 
+		for( j=0; j<nNewWidth * 3; j += 3 ) 
+		{ 
+			x = (int) (j/m_xscale); 
+			y = (int) (i/m_yscale); 
+			oldoffset = (y*nWidth*3 + x) - (y*nWidth*3 + x)%3; //correct positon in 3 byte mode
+			memcpy(pNewTmp+j, pBuf + oldoffset, 3);
+		} 
+	} 
+#endif
+	printf("End bmp scale \n");
+	return 0;
+}
+#endif
+
+
diff --git a/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-fbset-patch/u-boot-aml-2011.03-20160716-new/drivers/video/aml_video.c b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-fbset-patch/u-boot-aml-2011.03-20160716-new/drivers/video/aml_video.c
new file mode 100644
index 000000000..e3e3830e0
--- /dev/null
+++ b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-fbset-patch/u-boot-aml-2011.03-20160716-new/drivers/video/aml_video.c
@@ -0,0 +1,564 @@
+/*-----------------------------------------------------------------------------
+ * aml_video.c -- Elvis Yu
+ *-----------------------------------------------------------------------------
+ */
+
+#include <common.h>
+#include <video_fb.h>
+#include <asm/arch/osd.h>
+#include <asm/arch/osd_hw.h>
+#include <stdio_dev.h>
+#include <bmp_layout.h>
+#include <amlogic/aml_tv.h>
+#include <amlogic/vinfo.h>
+#include <malloc.h>
+
+
+GraphicDevice aml_gdev;
+
+//set default LCD_BPP
+#ifndef LCD_BPP
+#define LCD_BPP LCD_COLOR24
+#endif
+
+/*-----------------------------------------------------------------------------
+ * osd_init --
+ *-----------------------------------------------------------------------------
+ */
+static void osd_layer_init(GraphicDevice gdev, int layer)
+{
+//	printf("%s\n", __FUNCTION__);
+	osd_init_hw();
+#ifdef CONFIG_OSD_SCALE_ENABLE
+	osd_setup(0,
+                0,
+                gdev.fb_width,
+                gdev.fb_height,
+                gdev.fb_width,
+                gdev.fb_height * 2,
+                0,
+                0,
+                gdev.fb_width- 1,
+                gdev.fb_height- 1,
+                gdev.frameAdrs,
+                &default_color_format_array[gdev.gdfIndex],
+                layer);
+#else
+	osd_setup(0,
+                0,
+                gdev.winSizeX,
+                gdev.winSizeY,
+                gdev.winSizeX,
+                gdev.winSizeY * 2,
+                0,
+                0,
+                gdev.winSizeX- 1,
+                gdev.winSizeY- 1,
+                gdev.frameAdrs,
+                &default_color_format_array[gdev.gdfIndex],
+                layer);
+#endif
+}
+
+/*-----------------------------------------------------------------------------
+ * osd_init --
+ *-----------------------------------------------------------------------------
+ */
+static void video_layer_init(GraphicDevice gdev)
+{
+	return;
+}
+
+
+/*-----------------------------------------------------------------------------
+ * video_hw_init --
+ *-----------------------------------------------------------------------------
+ */
+void *video_hw_init (void)
+{	
+	u32 fb_addr, display_width, display_height, display_bpp, color_format_index, fg, bg;
+	u32 fb_width, fb_height;
+	char *layer_str;
+	fb_addr = simple_strtoul (getenv ("fb_addr"), NULL, 16);
+#ifdef CONFIG_OSD_SCALE_ENABLE
+	fb_width = simple_strtoul (getenv ("fb_width"), NULL, 10 );
+	fb_height = simple_strtoul (getenv ("fb_height"), NULL, 10);
+#else
+	fb_width = 0;
+	fb_height = 0;
+#endif
+	display_width = simple_strtoul (getenv ("display_width"), NULL, 10);
+	display_height = simple_strtoul (getenv ("display_height"), NULL, 10);
+	display_bpp = simple_strtoul (getenv ("display_bpp"), NULL, 10);
+	color_format_index = simple_strtoul (getenv ("display_color_format_index"), NULL, 10);
+	layer_str = getenv ("display_layer");
+	fg = simple_strtoul (getenv ("display_color_fg"), NULL, 10);
+	bg = simple_strtoul (getenv ("display_color_bg"), NULL, 10);
+	
+	/* fill in Graphic Device */
+	aml_gdev.frameAdrs = fb_addr;
+	aml_gdev.fb_width = fb_width;
+	aml_gdev.fb_height = fb_height;
+	aml_gdev.winSizeX = display_width;
+	aml_gdev.winSizeY = display_height;
+	aml_gdev.gdfBytesPP = display_bpp/8;
+	aml_gdev.fg = fg;
+	aml_gdev.bg = bg;
+
+	//different method with other video gdfIndex
+	//if((color_format_index < ARRAY_SIZE(default_color_format_array)) && (default_color_format_array[color_format_index] != INVALID_BPP_ITEM))
+	if((color_format_index < ARRAY_SIZE(default_color_format_array)) && (default_color_format_array[color_format_index].color_index != COLOR_INDEX_NULL))
+	{
+		aml_gdev.gdfIndex = color_format_index;
+	}
+	else
+	{
+		printf("ERROR:env color_format_index invalid! color_format_index is %d\n", color_format_index);
+		return NULL;
+	}
+
+	if(strcmp(layer_str, "osd1") == 0)
+	{
+		osd_layer_init(aml_gdev, OSD1);
+	}
+	else if(strcmp(layer_str, "osd2") == 0)
+	{
+		osd_layer_init(aml_gdev, OSD2);
+	}
+	else if(strcmp(layer_str, "video") == 0)
+	{
+		video_layer_init(aml_gdev);
+	}
+	else
+	{
+		printf("ERROR:env display_layer invalid! display_layer is %d\n", display_bpp);
+		return NULL;
+	}
+
+	return (void *) &aml_gdev;
+
+}
+
+/*-----------------------------------------------------------------------------
+ * video_set_lut --
+ *-----------------------------------------------------------------------------
+ */
+void video_set_lut (
+	unsigned int index,           /* color number */
+	unsigned char r,              /* red */
+	unsigned char g,              /* green */
+	unsigned char b               /* blue */
+	)
+{
+	return;
+}
+
+
+int video_display_bitmap(ulong bmp_image, int x, int y)
+{
+    vidinfo_t * info = NULL;
+#if defined CONFIG_VIDEO_AMLLCD
+    extern vidinfo_t panel_info;
+    info = & panel_info;
+#endif
+#if defined CONFIG_VIDEO_AMLTVOUT
+    extern vidinfo_t tv_info;
+    info = & tv_info;
+#endif
+#if(LCD_BPP ==LCD_COLOR8)	
+	ushort *cmap_base = NULL;
+	unsigned long byte_width;
+#endif	
+	ushort i, j;
+	uchar *fb;
+	bmp_image_t *bmp=(bmp_image_t *)bmp_image;
+	uchar *bmap;
+	ushort padded_line;
+	unsigned long width, height;
+#ifdef CONFIG_OSD_SCALE_ENABLE
+	unsigned long pheight = aml_gdev.fb_height;
+	unsigned long pwidth = aml_gdev.fb_width;
+#else
+	unsigned long pwidth = info->vl_col;
+#endif
+	unsigned colors, bpix, bmp_bpix;
+	unsigned long compression;
+	int lcd_line_length = (pwidth * NBITS (info->vl_bpix)) / 8;
+	char *layer_str = NULL;
+	int osd_index = -1;
+
+	layer_str = getenv ("display_layer");
+	if(strcmp(layer_str, "osd1") == 0)
+	{
+		osd_index = 0;
+	}
+	else if(strcmp(layer_str, "osd2") == 0)
+	{
+		osd_index = 1;
+	}
+
+	if (!((bmp->header.signature[0]=='B') &&
+		(bmp->header.signature[1]=='M'))) {
+		printf ("Error: no valid bmp image at %lx\n", bmp_image);
+		return 1;
+	}
+
+	width = le32_to_cpu (bmp->header.width);
+	height = le32_to_cpu (bmp->header.height);
+	bmp_bpix = le16_to_cpu(bmp->header.bit_count);
+	colors = 1 << bmp_bpix;
+	compression = le32_to_cpu (bmp->header.compression);
+
+	bpix = NBITS(info->vl_bpix);
+
+#ifdef CONFIG_OSD_SCALE_ENABLE
+	if((x == -1) &&(y == -1))
+	{
+		if((width > pwidth) || (height > pheight))
+		{
+			x = 0;
+			y = 0;
+		}
+		else
+		{
+			x = (pwidth - width) / 2;
+			y = (pheight - height) / 2;
+		}
+	}
+#else
+	if((x == -1) &&(y == -1))
+	{
+		if((width > info->vl_col) || (height > info->vl_row))
+		{
+			x = 0;
+			y = 0;
+		}
+		else
+		{
+			x = (info->vl_col - width) / 2;
+			y = (info->vl_row - height) / 2;
+		}
+	}
+#endif
+
+	if ((bpix != 1) && (bpix != 8) && (bpix != 16) && (bpix != 24) && (bpix != 32)) {
+		printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n",
+			bpix, bmp_bpix);
+		return 1;
+	}
+
+	/* We support displaying 8bpp BMPs on 16bpp LCDs */
+	if (bpix != bmp_bpix && (bmp_bpix != 8 || bpix != 16)) {
+		printf ("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n",
+			bpix,
+			le16_to_cpu(bmp->header.bit_count));
+		return 1;
+	}
+
+	debug ("Display-bmp: %d x %d  with %d colors\n",
+		(int)width, (int)height, (int)colors);
+
+
+	/*
+	 *  BMP format for Monochrome assumes that the state of a
+	 * pixel is described on a per Bit basis, not per Byte.
+	 *  So, in case of Monochrome BMP we should align widths
+	 * on a byte boundary and convert them from Bit to Byte
+	 * units.
+	 *  Probably, PXA250 and MPC823 process 1bpp BMP images in
+	 * their own ways, so make the converting to be MCC200
+	 * specific.
+	 */
+	padded_line = (width&0x3) ? ((width&~0x3)+4) : (width);
+
+#ifdef CONFIG_SPLASH_SCREEN_ALIGN
+	if (x == BMP_ALIGN_CENTER)
+		x = max(0, (pwidth - width) / 2);
+	else if (x < 0)
+		x = max(0, pwidth - width + x + 1);
+
+	if (y == BMP_ALIGN_CENTER)
+		y = max(0, (info->vl_row - height) / 2);
+	else if (y < 0)
+		y = max(0, info->vl_row - height + y + 1);
+#endif /* CONFIG_SPLASH_SCREEN_ALIGN */
+
+#ifdef CONFIG_OSD_SCALE_ENABLE
+	if ((x + width)>pwidth)
+		width = pwidth - x;
+	if ((y + height)>pheight)
+		height = pheight - y;
+#else
+	if ((x + width)>pwidth)
+		width = pwidth - x;
+	if ((y + height)>info->vl_row)
+		height = info->vl_row - y;
+#endif
+
+#ifdef CONFIG_OSD_SCALE_ENABLE
+        if(getenv("bmp_osd_control")) {
+                osd_enable_hw(simple_strtoul(getenv("bmp_osd_control"), NULL, 10), osd_index);
+        }
+        else{
+                osd_enable_hw(0, osd_index);//default to close osd in 'bmp display'
+        }
+#endif
+	bmap = (uchar *)bmp + le32_to_cpu (bmp->header.data_offset);
+	fb   = (uchar *) (info->vd_base +
+		(y + height - 1) * lcd_line_length + x*(LCD_BPP/8));
+
+	debug("fb=0x%08x; bmap=0x%08x, width=%d, height= %d, lcd_line_length=%d, padded_line=%d\n",
+			fb, bmap, width, height, lcd_line_length, padded_line);
+	switch (bmp_bpix) {
+#if(LCD_BPP ==LCD_COLOR8)
+	case 8:
+		if (bpix != 16)
+			byte_width = width;
+		else
+			byte_width = width * 2;
+
+		for (i = 0; i < height; ++i) {
+			for (j = 0; j < width; j++) {
+				if (bpix != 16) {
+					*(fb++) = *(bmap++);
+				} else {
+					*(uint16_t *)fb = cmap_base[*(bmap++)];
+					fb += sizeof(uint16_t) / sizeof(*fb);
+				}
+			}
+			bmap += (width - padded_line);
+			fb   -= (byte_width + lcd_line_length);
+		}
+		break;
+#endif /* LCD_BPP ==LCD_COLOR8 */
+
+#if(LCD_BPP ==LCD_COLOR16)
+	case 16:
+		for (i = 0; i < height; ++i) {
+			for (j = 0; j < width; j++) {
+
+				*(fb++) = *(bmap++);
+				*(fb++) = *(bmap++);
+			}
+			bmap += (padded_line - width) * 2;
+			fb   -= (width * 2 + lcd_line_length);
+		}
+		break;
+#endif /* LCD_BPP ==LCD_COLOR16 */
+
+#if(LCD_BPP ==LCD_COLOR24)
+	case 24:
+		for (i = 0; i < height; ++i) {
+			for (j = 0; j < width; j++) {
+
+				*(fb++) = *(bmap++);
+				*(fb++) = *(bmap++);
+				*(fb++) = *(bmap++);
+			}
+			bmap += (padded_line - width);
+			fb   -= (width * 3 + lcd_line_length);
+		}
+		break;
+#endif /* LCD_BPP ==LCD_COLOR24 */
+#if(LCD_BPP ==LCD_COLOR32)
+		case 32:
+			for (i = 0; i < height; ++i) {
+				for (j = 0; j < width; j++) {
+
+					*(fb++) = *(++bmap);     /* B */
+					*(fb++) = *(++bmap);     /* G */
+					*(fb++) = *(++bmap);     /* R */
+					*(fb++) = *(++bmap - 4); /* A */
+				}
+				bmap += (padded_line - width);
+				fb   -= (width * 4 + lcd_line_length);
+			}
+			break;
+#endif /* LCD_BPP ==LCD_COLOR32 */
+
+	default:
+		printf("ERROR LCD_BPP is %d\n", LCD_BPP);
+		return (-1);
+	};
+	flush_cache((unsigned long)info->vd_base, info->vl_col*info->vl_row*info->vl_bpix/8);
+
+	return (0);
+}
+
+int my_atoi(const char *str){
+    int result = 0;
+    int signal = 1;
+	
+    if((*str >= '0' && *str<='9') || *str == '-' || *str == '+'){
+        if(*str == '-' || *str == '+'){  
+            if(*str=='-')
+                signal = -1; 
+            str++;
+        } 
+    }else 
+		return 0;
+	
+    while(*str >= '0' && *str <= '9')
+        result = result * 10 + (*str++ -'0');
+
+	return signal * result;
+}
+
+#ifdef CONFIG_OSD_SCALE_ENABLE
+int getenv_int(char *env, int def){
+    if (getenv(env) == NULL) {
+		//printf("bmp scale:  def=%d\n", def);
+        return def;
+    } else {
+    	//printf("bmp scale:   %s=%s\n", env, getenv(env));
+        return my_atoi(getenv(env));
+    }
+}
+
+int* get_window_axis(void) {
+    char *mode = getenv("outputmode");
+    int* axis = (int *)malloc(4*4);
+
+    if (strcmp(mode, "480i") == 0 || strcmp(mode, "480cvbs") == 0) {
+        axis[0] = getenv_int("480ioutputx", 0);
+        axis[1] = getenv_int("480ioutputy", 0);
+        axis[2] = getenv_int("480ioutputwidth", 720);
+        axis[3] = getenv_int("480ioutputheight", 480);
+    } else if (strcmp(mode, "480p") == 0) {
+        axis[0] = getenv_int("480poutputx", 0);
+        axis[1] = getenv_int("480poutputy", 0);
+        axis[2] = getenv_int("480poutputwidth", 720);
+        axis[3] = getenv_int("480poutputheight", 480);
+    } else if (strcmp(mode, "576i") == 0 || strcmp(mode, "576cvbs") == 0) {
+        axis[0] = getenv_int("576ioutputx", 0);
+        axis[1] = getenv_int("576ioutputy", 0);
+        axis[2] = getenv_int("576ioutputwidth", 720);
+        axis[3] = getenv_int("576ioutputheight", 576);
+    } else if (strcmp(mode, "576p") == 0) {
+        axis[0] = getenv_int("576poutputx", 0);
+        axis[1] = getenv_int("576poutputy", 0);
+        axis[2] = getenv_int("576poutputwidth", 720);
+        axis[3] = getenv_int("576poutputheight", 576);
+    } else if (strcmp(mode, "720p") == 0 || strcmp(mode, "720p50hz") == 0) {
+        axis[0] = getenv_int("720poutputx", 0);
+        axis[1] = getenv_int("720poutputy", 0);
+        axis[2] = getenv_int("720poutputwidth", 1280);
+        axis[3] = getenv_int("720poutputheight", 720);
+    } else if (strcmp(mode, "1080i") == 0 || strcmp(mode, "1080i50hz") == 0) { 
+        axis[0] = getenv_int("1080ioutputx", 0);
+        axis[1] = getenv_int("1080ioutputy", 0);
+        axis[2] = getenv_int("1080ioutputwidth", 1920);
+        axis[3] = getenv_int("1080ioutputheight", 1080);
+    } else if (strcmp(mode, "4k2k24hz") == 0) {
+        axis[0] = getenv_int("4k2k24hz_x", 0);
+        axis[1] = getenv_int("4k2k24hz_y", 0);
+        axis[2] = getenv_int("4k2k24hz_width", 3840);
+        axis[3] = getenv_int("4k2k24hz_height", 2160);
+    } else if (strcmp(mode, "4k2k25hz") == 0) {
+        axis[0] = getenv_int("4k2k25hz_x", 0);
+        axis[1] = getenv_int("4k2k25hz_y", 0);
+        axis[2] = getenv_int("4k2k25hz_width", 3840);
+        axis[3] = getenv_int("4k2k25hz_height", 2160);
+    } else if (strcmp(mode, "4k2k30hz") == 0) {
+        axis[0] = getenv_int("4k2k30hz_x", 0);
+        axis[1] = getenv_int("4k2k30hz_y", 0);
+        axis[2] = getenv_int("4k2k30hz_width", 3840);
+        axis[3] = getenv_int("4k2k30hz_height", 2160);
+    }  else if (strcmp(mode, "4k2k50hz420") == 0) {
+        axis[0] = getenv_int("4k2k420_x", 0);
+        axis[1] = getenv_int("4k2k420_y", 0);
+        axis[2] = getenv_int("4k2k420_w", 3840);
+        axis[3] = getenv_int("4k2k420_h", 2160);
+    } else if (strcmp(mode, "4k2k60hz420") == 0) {
+        axis[0] = getenv_int("4k2k420_x", 0);
+        axis[1] = getenv_int("4k2k420_y", 0);
+        axis[2] = getenv_int("4k2k420_w", 3840);
+        axis[3] = getenv_int("4k2k420_h", 2160);
+    } else if (strcmp(mode, "4k2ksmpte") == 0) {
+        axis[0] = getenv_int("4k2ksmpte_x", 0);
+        axis[1] = getenv_int("4k2ksmpte_y", 0);
+        axis[2] = getenv_int("4k2ksmpte_width", 4096);
+        axis[3] = getenv_int("4k2ksmpte_height", 2160);
+    } else if (strcmp(mode, "4k2k50hz") == 0) {
+        axis[0] = getenv_int("4k2k50hz_x", 0);
+        axis[1] = getenv_int("4k2k50hz_y", 0);
+        axis[2] = getenv_int("4k2k50hz_w", 3840);
+        axis[3] = getenv_int("4k2k50hz_h", 2160);
+    } else if (strcmp(mode, "4k2k60hz") == 0) {
+        axis[0] = getenv_int("4k2k60hz_x", 0);
+        axis[1] = getenv_int("4k2k60hz_y", 0);
+        axis[2] = getenv_int("4k2k60hz_w", 3840);
+        axis[3] = getenv_int("4k2k60hz_h", 2160);
+    } else if (strcmp(mode, "1080p") == 0 || strcmp(mode, "1080p50hz") == 0 || strcmp(mode, "1080p24hz") == 0) {
+        axis[0] = getenv_int("1080poutputx", 0);
+        axis[1] = getenv_int("1080poutputy", 0);
+        axis[2] = getenv_int("1080poutputwidth", 1920);
+        axis[3] = getenv_int("1080poutputheight", 1080);
+    } else if ((strcmp(mode, "768p50hz") == 0) || (strcmp(mode, "768p60hz") == 0) ){
+        axis[0] = getenv_int("768p_x", 0);
+        axis[1] = getenv_int("768p_y", 0);
+        axis[2] = getenv_int("768p_w", 1366);
+        axis[3] = getenv_int("768p_h", 768);
+    } else {
+        axis[0] = getenv_int("1080poutputx", 0);
+        axis[1] = getenv_int("1080poutputy", 0);
+        axis[2] = getenv_int("1080poutputwidth", 1920);
+        axis[3] = getenv_int("1080poutputheight", 1080);
+    }
+    printf("bmp scale:  mode=%s , x=%d, y=%d, w=%d, h=%d\n", mode, axis[0], axis[1], axis[2], axis[3]);
+    return axis;
+}
+
+
+int video_scale_bitmap(void)
+{
+//	printf("video_scale_bitmap src width is %d, height is %d, dst width is %d, dst height is %d\n",
+//			aml_gdev.fb_width, aml_gdev.fb_height, aml_gdev.winSizeX, aml_gdev.winSizeY);
+	char *layer_str = NULL;
+	int osd_index = -1;
+	layer_str = getenv ("display_layer");
+	int *axis = get_window_axis();
+	if(strcmp(layer_str, "osd1") == 0)
+	{
+		osd_index = 0;
+	}
+	else if(strcmp(layer_str, "osd2") == 0)
+	{
+		osd_index = 1;
+	}
+#ifdef CONFIG_OSD_SUPERSCALE_ENABLE
+	if ((aml_gdev.fb_width*2 != aml_gdev.winSizeX) || (aml_gdev.fb_height*2 != aml_gdev.winSizeY)) {
+		osd_enable_hw(1, osd_index);
+		return (-1);
+	}
+	osd_free_scale_mode_hw(osd_index, 2);
+#else
+	osd_free_scale_mode_hw(osd_index, 1);
+#endif
+	osd_set_free_scale_axis_hw(osd_index, 0,0,aml_gdev.fb_width-1,aml_gdev.fb_height-1);
+	osd_set_window_axis_hw(osd_index,axis[0],axis[1],axis[0]+axis[2]-1,axis[1]+axis[3]-1);
+	free(axis);
+	osd_free_scale_enable_hw(osd_index, 0x10001);
+	osd_enable_hw(1, osd_index);
+	return (1);
+}
+#endif
+
+void reset_console(void)
+{
+    vidinfo_t * info = NULL;
+#if defined CONFIG_VIDEO_AMLLCD
+    extern vidinfo_t panel_info;
+    info = & panel_info;
+#endif
+#if defined CONFIG_VIDEO_AMLTVOUT
+    extern vidinfo_t tv_info;
+    info = & tv_info;
+#endif
+	info->console_col = 0;
+#ifdef CONFIG_LCD_INFO_BELOW_LOGO
+	info->console_row = 7 + BMP_LOGO_HEIGHT / VIDEO_FONT_HEIGHT;
+#else
+	info->console_row = 1;	/* leave 1 blank line below logo */
+#endif
+}
diff --git a/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-mmcboot-patch/create.patch.sh b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-mmcboot-patch/create.patch.sh
new file mode 100755
index 000000000..986f1f893
--- /dev/null
+++ b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-mmcboot-patch/create.patch.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=2011.03-20160716
+
+tar --files-from=file.list -xJvf ../u-boot-aml-$VERSION.tar.xz
+mv u-boot-aml-$VERSION u-boot-aml-$VERSION-orig
+
+cp -rf ./u-boot-aml-$VERSION-new ./u-boot-aml-$VERSION
+
+diff -b --unified -Nr  u-boot-aml-$VERSION-orig  u-boot-aml-$VERSION > u-boot-aml-$VERSION-m8b_m201-mmcboot.patch
+
+mv u-boot-aml-$VERSION-m8b_m201-mmcboot.patch ../patches
+
+rm -rf ./u-boot-aml-$VERSION
+rm -rf ./u-boot-aml-$VERSION-orig
diff --git a/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-mmcboot-patch/file.list b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-mmcboot-patch/file.list
new file mode 100644
index 000000000..7b0b121f8
--- /dev/null
+++ b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-mmcboot-patch/file.list
@@ -0,0 +1 @@
+u-boot-aml-2011.03-20160716/board/amlogic/configs/m8b_m201_v1.h
diff --git a/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-mmcboot-patch/u-boot-aml-2011.03-20160716-new/board/amlogic/configs/m8b_m201_v1.h b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-mmcboot-patch/u-boot-aml-2011.03-20160716-new/board/amlogic/configs/m8b_m201_v1.h
new file mode 100644
index 000000000..17cb35bb6
--- /dev/null
+++ b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-mmcboot-patch/u-boot-aml-2011.03-20160716-new/board/amlogic/configs/m8b_m201_v1.h
@@ -0,0 +1,485 @@
+#ifndef __CONFIG_M8B_M201_V1_H__
+#define __CONFIG_M8B_M201_V1_H__
+
+#define CONFIG_MACH_MESON8_M201  // generate M8 M201 machid number
+
+#define CONFIG_POWER_SPL
+#ifdef CONFIG_M201_COSTDOWN
+#define CONFIG_PWM_VDDEE_VOLTAGE            1100   //VDDEE voltage when boot, must have
+#else
+#define CONFIG_PWM_VDDEE_VOLTAGE            1100   //VDDEE voltage when boot, must have
+#endif
+#define CONFIG_PWM_VDDEE_SUSPEND_VOLTAGE    1100 //VDDEE voltage when suspend, must have
+#define CONFIG_IR_REMOTE_WAKEUP 1
+#define CONFIG_SECURITYKEY
+//#define TEST_UBOOT_BOOT_SPEND_TIME
+
+// cart type of each port
+#define PORT_A_CARD_TYPE            CARD_TYPE_UNKNOWN
+#define PORT_B_CARD_TYPE            CARD_TYPE_UNKNOWN
+#define PORT_C_CARD_TYPE            CARD_TYPE_MMC // CARD_TYPE_MMC/CARD_TYPE_SD
+
+//UART Sectoion
+#define CONFIG_CONS_INDEX   2
+
+#define CONFIG_NEXT_NAND
+//#define CONFIG_SECURE_NAND  1
+//support "boot,bootd"
+//#define CONFIG_CMD_BOOTD 1
+//#define CONFIG_AML_I2C      1
+
+//Enable HDMI Tx
+//#define CONFIG_VIDEO_AMLTVOUT 1
+//Enable LCD output
+//#define CONFIG_VIDEO_AMLLCD
+#define LCD_BPP LCD_COLOR16
+
+#define CONFIG_ACS
+#ifdef CONFIG_ACS
+#define CONFIG_DDR_SIZE_IND_ADDR 0xD9000000	//pass memory size, spl->uboot
+#endif
+
+#ifdef CONFIG_NEXT_NAND
+#define CONFIG_CMD_IMGREAD  1   //read the actual size of boot.img/recovery.img/logo.img use cmd 'imgread'
+#define CONFIG_AML_V2_USBTOOL 1
+#define CONFIG_AUTO_START_SD_BURNING     1//1 then auto detect whether or not jump into sdc_burning when boot from external mmc card 
+#define CONFIG_SHA1
+#define CONFIG_POWER_KEY_NOT_SUPPORTED_FOR_BURN 1//power key and poweroff can't work
+#define CONFIG_SD_BURNING_SUPPORT_UI     1//have bmp display to indicate burning state when sdcard burning
+#endif//#ifdef CONFIG_NEXT_NAND
+
+#define CONFIG_UNIFY_KEY_MANAGE 1       //Support burning key with usb tool
+#define CONFIG_CMD_PWM  1
+
+//Enable storage devices
+#define CONFIG_CMD_NAND  1
+#define CONFIG_VIDEO_AML 1
+#define CONFIG_CMD_BMP 1
+#define CONFIG_VIDEO_AMLTVOUT 1
+#define CONFIG_AML_HDMI_TX  1
+#define CONFIG_OSD_SCALE_ENABLE 1
+
+//Enable storage devices
+#define CONFIG_CMD_SF    1
+#if defined(CONFIG_CMD_SF)
+	#define SPI_WRITE_PROTECT  1
+	#define CONFIG_CMD_MEMORY  1
+#endif /*CONFIG_CMD_SF*/
+
+//Amlogic SARADC support
+//#define CONFIG_SARADC 1
+#define CONFIG_EFUSE 1
+//#define CONFIG_MACHID_CHECK 1
+#define CONFIG_CMD_SUSPEND 1
+//#define CONFIG_IR_REMOTE 1
+#define CONFIG_IR_REMOTE 1
+#define CONFIG_L2_OFF	 1
+
+#define CONFIG_CMD_NET   1
+#if defined(CONFIG_CMD_NET)
+	#define CONFIG_AML_ETHERNET 1
+	#define RMII_PHY_INTERFACE    1
+	#define CONFIG_NET_MULTI 1
+	#define CONFIG_CMD_PING 1
+	#define CONFIG_CMD_DHCP 1
+	#define CONFIG_CMD_RARP 1
+	//#define CONFIG_NET_RGMII
+	//#define CONFIG_NET_RMII_CLK_EXTERNAL //use external 50MHz clock source
+	#define CONFIG_AML_ETHERNET    1                   /*to link /driver/net/aml_ethernet.c*/
+	#define CONFIG_HOSTNAME        arm_m8
+	#define CONFIG_ETHADDR         00:15:18:01:81:31   /* Ethernet address */
+	#define CONFIG_IPADDR          10.18.9.97          /* Our ip address */
+	#define CONFIG_GATEWAYIP       10.18.9.1           /* Our getway ip address */
+	#define CONFIG_SERVERIP        10.18.9.113         /* Tftp server ip address */
+	#define CONFIG_NETMASK         255.255.255.0
+#endif /* (CONFIG_CMD_NET) */
+
+
+#define CONFIG_SDIO_B1   1
+#define CONFIG_SDIO_A    1
+#define CONFIG_SDIO_B    1
+#define CONFIG_SDIO_C    1
+#define CONFIG_ENABLE_EXT_DEVICE_RETRY 1
+
+
+#define CONFIG_MMU                    1
+#define CONFIG_PAGE_OFFSET 	0xc0000000
+#define CONFIG_SYS_LONGHELP	1
+
+/* USB
+ * Enable CONFIG_MUSB_HCD for Host functionalities MSC, keyboard
+ * Enable CONFIG_MUSB_UDD for Device functionalities.
+ */
+/* #define CONFIG_MUSB_UDC		1 */
+#define CONFIG_CMD_USB 1
+#if defined(CONFIG_CMD_USB)
+	#define CONFIG_M8_USBPORT_BASE_A	0xC9040000
+	#define CONFIG_M8_USBPORT_BASE_B	0xC90C0000
+	#define CONFIG_USB_STORAGE      1
+	#define CONFIG_USB_DWC_OTG_HCD  1
+	#define CONFIG_USB_DWC_OTG_294	1
+#endif //#if defined(CONFIG_CMD_USB)
+
+#define CONFIG_ENABLE_CVBS 1
+
+#define CONFIG_UCL 1
+#define CONFIG_SELF_COMPRESS 
+//#define CONFIG_PREBOOT "mw da004004 80000510;mw c81000014 4000;mw c1109900 0"
+
+#define CONFIG_CMD_AUTOSCRIPT
+
+#define CONFIG_CMD_REBOOT 1
+#define CONFIG_PREBOOT 
+
+#define  CONFIG_AML_GATE_INIT	1
+
+/* Environment information */
+#define CONFIG_BOOTDELAY	1
+#define CONFIG_BOOTFILE		boot.img
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	"loadaddr=0x12000000\0" \
+	"loadaddr_logo=0x13000000\0" \
+	"testaddr=0x12400000\0" \
+	"console=ttyS0,115200n8\0" \
+	"bootm_low=0x00000000\0" \
+	"bootm_size=0x80000000\0" \
+	"mmcargs=setenv bootargs console=${console} " \
+	"boardname=m8_board\0" \
+	"chipname=8726m8\0" \
+	"get_dt=checkhw\0" \
+	"initrd_high=60000000\0" \
+	"hdmimode=1080p\0" \
+	"cvbsmode=576cvbs\0" \
+	"outputmode=1080p\0" \
+	"vdac_config=0x10\0" \
+	"initargs=root=/dev/system rootfstype=ext4 init=/sbin/init console=ttyS0,115200n8 no_console_suspend \0" \
+	"video_dev=tvout\0" \
+	"display_width=1920\0" \
+	"display_height=1080\0" \
+	"display_bpp=16\0" \
+	"display_color_format_index=16\0" \
+	"display_layer=osd2\0" \
+	"display_color_fg=0xffff\0" \
+	"display_color_bg=0\0" \
+	"fb_addr=0x7900000\0" \
+	"fb_width=1280\0"\
+	"fb_height=720\0"\
+	"partnum=2\0" \
+	"p0start=1000000\0" \
+	"p0size=400000\0" \
+	"p0path=uImage\0" \
+	"p1start=1400000\0" \
+	"p1size=8000000\0" \
+	"p1path=android.rootfs\0" \
+	"bootstart=0\0" \
+	"bootsize=100000\0" \
+	"bootpath=u-boot.bin\0" \
+	"sdcburncfg=aml_sdc_burn.ini\0"\
+	"normalstart=1000000\0" \
+	"normalsize=400000\0" \
+	"upgrade_step=0\0" \
+	"firstboot=1\0" \
+	"store=0\0"\
+	"wipe_data=success\0"\
+	"mmcdev=0\0" \
+	"bootpart=0:1\0" \
+	"scriptaddr=0x0f000000\0" \
+	"loadbootscript=fatload mmc ${bootpart} ${scriptaddr} boot.scr\0" \
+	"bootscript=echo Running bootscript from mmc${mmcdev} ...; " \
+		"source ${scriptaddr}\0" \
+	"mmcboot=run loadbootscript; run bootscript;\0" \
+	"preloaddtb=imgread dtb boot ${loadaddr}\0" \
+	"preboot="\
+        "if itest ${upgrade_step} == 3; then run prepare; run storeargs; run update; fi; "\
+        "if itest ${upgrade_step} == 1; then  "\
+            "defenv; setenv upgrade_step 2; saveenv;"\
+        "fi; "\
+        "run check_rebootmode;"\
+        "run prepare;"\
+        "run storeargs;"\
+        "run update_ir; " \
+        "run switch_bootmode\0" \
+    \
+    "update_ir="\
+        "if irdetect; then run update; fi\0" \
+    \
+   	"update="\
+        /*first try usb burning, second sdc_burn, third autoscr, last recovery*/\
+        "run usb_burning; "\
+        "if mmcinfo; then "\
+            "if fatexist mmc 0 ${sdcburncfg}; then "\
+                "run sdc_burning; "\
+            "else "\
+                "if fatload mmc 0 ${loadaddr} aml_autoscript; then autoscr ${loadaddr}; fi;"\
+                "run recovery;"\
+            "fi;"\
+        "else "\
+            "run recovery;"\
+        "fi;\0"\
+    \
+   	"storeargs="\
+        "setenv bootargs ${initargs} vdaccfg=${vdac_config} logo=osd1,loaded,${fb_addr},${outputmode},full hdmimode=${hdmimode} cvbsmode=${cvbsmode} androidboot.firstboot=${firstboot} hdmitx=${cecconfig}\0"\
+    \
+	"switch_bootmode="\
+        "if test ${reboot_mode} = factory_reset; then "\
+			"run recovery;"\
+        "else if test ${reboot_mode} = update; then "\
+        	"run update;"\
+        "else if test ${reboot_mode} = usb_burning; then "\
+        	"run usb_burning;"\
+		"else if test ${wipe_data} = failed; then "\
+			"echo wipe_data=${wipe_data}; run recovery;"\
+        "else " \
+        	"  "\
+        "fi;fi;fi;fi\0" \
+    \
+    "prepare="\
+        "logo size ${outputmode}; video open; video clear; video dev open ${outputmode};"\
+        "imgread pic logo bootup ${loadaddr_logo}; "\
+        "bmp display ${bootup_offset}; bmp scale;"\
+        "\0"\
+	\
+	"storeboot="\
+        "echo Booting...; "\
+        "if unifykey get usid; then  "\
+            "setenv bootargs ${bootargs} androidboot.serialno=${usid};"\
+        "fi;"\
+        "imgread kernel boot ${loadaddr};"\
+        "bootm;"\
+        "run recovery\0" \
+    \
+	"recovery="\
+        "echo enter recovery;"\
+        "if mmcinfo; then "\
+            "if fatload mmc 0 ${loadaddr} recovery.img; then bootm;fi;"\
+        "fi; "\
+        "if usb start 0; then "\
+                "if fatload usb 0 ${loadaddr} recovery.img; then bootm; fi;"\
+        "fi;"\
+	      "if imgread kernel recovery ${loadaddr}; then "\
+	        "bootm; "\
+				"else "\
+					"echo no recovery in flash; "\
+				"fi;\0" \
+    \
+    "check_rebootmode="\
+		"get_rebootmode; clear_rebootmode; echo reboot_mode=${reboot_mode};"\
+		"if test ${reboot_mode} = factory_reset; then defenv; fi;\0" \
+    \
+	"usb_burning=update 1000\0" \
+    "sdc_burning=sdc_burn ${sdcburncfg}\0"
+
+
+#define CONFIG_BOOTCOMMAND   "run mmcboot"
+
+#define CONFIG_AUTO_COMPLETE	1
+#define CONFIG_ENV_SIZE         (64*1024)
+
+#define CONFIG_STORE_COMPATIBLE
+
+#ifdef  CONFIG_STORE_COMPATIBLE
+//spi
+#define CONFIG_ENV_OVERWRITE
+#define CONFIG_CMD_SAVEENV
+#define CONFIG_ENV_SECT_SIZE 0x1000
+ #define CONFIG_ENV_IN_SPI_OFFSET 0x100000
+//nand
+#define CONFIG_ENV_IN_NAND_OFFSET 0x400000
+#define CONFIG_ENV_BLOCK_NUM 2
+//emmc
+#define CONFIG_SYS_MMC_ENV_DEV 1
+#define CONFIG_ENV_IN_EMMC_OFFSET 0x80000
+
+#else
+
+//#define CONFIG_SPI_BOOT 1
+#define CONFIG_MMC_BOOT
+//#define CONFIG_NAND_BOOT 1
+
+#ifdef CONFIG_NAND_BOOT
+	#define CONFIG_AMLROM_NANDBOOT 1
+#endif 
+
+
+#ifdef CONFIG_SPI_BOOT
+	#define CONFIG_ENV_OVERWRITE
+	#define CONFIG_ENV_IS_IN_SPI_FLASH
+	#define CONFIG_CMD_SAVEENV	
+	#define CONFIG_ENV_SECT_SIZE		0x10000
+	#define CONFIG_ENV_OFFSET           0x1f0000
+#elif defined CONFIG_NAND_BOOT
+	#define CONFIG_ENV_IS_IN_AML_NAND
+	#define CONFIG_CMD_SAVEENV
+	#define CONFIG_ENV_OVERWRITE	
+	#define CONFIG_ENV_OFFSET       0x400000
+	#define CONFIG_ENV_BLOCK_NUM    2
+#elif defined CONFIG_MMC_BOOT
+	#define CONFIG_ENV_IS_IN_MMC
+	#define CONFIG_CMD_SAVEENV
+    #define CONFIG_SYS_MMC_ENV_DEV        0	
+	#define CONFIG_ENV_OFFSET       0x1000000		
+#else
+	#define CONFIG_ENV_IS_NOWHERE    1
+#endif
+
+#endif
+
+
+//----------------------------------------------------------------------
+//Please set the M8 CPU clock(unit: MHz)
+//legal value: 600, 792, 996, 1200
+#define M8_CPU_CLK 		    (792)
+#define CONFIG_SYS_CPU_CLK	(M8_CPU_CLK)
+//----------------------------------------------------------------------
+
+//-----------------------------------------------------------------------
+//DDR setting
+//For DDR PUB training not check the VT done flag
+#define CONFIG_NO_DDR_PUB_VT_CHECK 1
+
+//For M8 DDR clock gating disable
+//#define CONFIG_GATEACDDRCLK_DISABLE 1
+
+//For M8 DDR low power feature disable
+//#define CONFIG_DDR_LOW_POWER_DISABLE 1
+
+//For M8 DDR PUB WL/WD/RD/RG-LVT, WD/RD-BVT disable
+//#define CONFIG_PUB_WLWDRDRGLVTWDRDBVT_DISABLE 1
+
+//Please just define m8 DDR clock here only
+//current DDR clock range (408~804)MHz with fixed step 12MHz
+#define CFG_DDR_CLK    636 //696 //768  //792// (636)
+#define CFG_DDR_MODE   CFG_DDR_32BIT
+
+#ifdef CONFIG_ACS
+//#define CONFIG_DDR_MODE_AUTO_DETECT	//ddr bus-width auto detection
+#define CONFIG_DDR_SIZE_AUTO_DETECT	//ddr size auto detection
+#endif
+
+//On board DDR capactiy
+#if !(defined(CONFIG_DDR3_512MB) || defined(CONFIG_DDR3_1GB) \
+	|| defined(CONFIG_DDR3_2GB))
+	#error "Please set DDR capacity first!\n"
+#endif
+//above setting will affect following:
+//board/amlogic/m8_m201_v1/firmware/timming.c
+//arch/arm/cpu/aml_meson/m8/mmutable.s
+
+#define CONFIG_DUMP_DDR_INFO 1
+#define CONFIG_ENABLE_WRITE_LEVELING 1
+
+//DDR row/col size
+//row size.  2'b01 : A0~A12.   2'b10 : A0~A13.  2'b11 : A0~A14.  2'b00 : A0~A15.
+//col size.   2'b01 : A0~A8,      2'b10 : A0~A9  
+#define PHYS_MEMORY_START        (0x00000000) // ???
+#if   defined(CONFIG_DDR3_512MB)
+	#define CONFIG_DDR3_ROW_SIZE (2)
+	#define CONFIG_DDR3_COL_SIZE (2)
+	#define CONFIG_DDR_ROW_BITS  (14)
+	#define PHYS_MEMORY_SIZE     (0x20000000) // 512MB
+#elif defined(CONFIG_DDR3_1GB)
+	//2Gb(X16) x 4pcs
+	#define CONFIG_DDR3_ROW_SIZE (3)
+	#define CONFIG_DDR3_COL_SIZE (2)
+	#define CONFIG_DDR_ROW_BITS  (15)
+	#define PHYS_MEMORY_SIZE     (0x40000000) // 1GB
+#elif defined(CONFIG_DDR3_2GB)
+	//4Gb(X16) x 4pcs
+	#define CONFIG_DDR3_ROW_SIZE (3)
+	#define CONFIG_DDR3_COL_SIZE (2)
+	#define CONFIG_DDR_ROW_BITS  (15)
+	#define PHYS_MEMORY_SIZE     (0x80000000) // 2GB
+#endif
+
+#define CONFIG_SYS_MEMTEST_START      0x10000000  /* memtest works on */      
+#define CONFIG_SYS_MEMTEST_END        0x18000000  /* 0 ... 128 MB in DRAM */  
+#define CONFIG_ENABLE_MEM_DEVICE_TEST 1
+#define CONFIG_NR_DRAM_BANKS	      1	          /* CS1 may or may not be populated */
+
+#ifdef CONFIG_DDR_SIZE_AUTO_DETECT
+#define CONFIG_AUTO_SET_MULTI_DT_ID    //if wanna pass mem=xx to kernel, pls disable this config
+#ifndef CONFIG_AUTO_SET_MULTI_DT_ID
+#define CONFIG_AUTO_SET_BOOTARGS_MEM
+#endif
+#endif
+
+/* Pass open firmware flat tree*/
+#define CONFIG_OF_LIBFDT	1
+#define CONFIG_DT_PRELOAD	1
+#define CONFIG_SYS_BOOTMAPSZ   PHYS_MEMORY_SIZE       /* Initial Memory map for Linux */
+#define CONFIG_ANDROID_IMG	1
+
+#define CONFIG_CMD_IMGPACK 1
+
+//M8 secure boot disable
+//#define CONFIG_AML_DISABLE_CRYPTO_UBOOT 1
+
+//M8 L1 cache enable for uboot decompress speed up
+#define CONFIG_AML_SPL_L1_CACHE_ON	1
+
+//To use RSA2048 key aml-rsa-key.k2a
+#define CONFIG_AML_RSA_2048 1
+
+
+/*-----------------------------------------------------------------------
+ * power down
+ */
+//#define CONFIG_CMD_RUNARC 1 /* runarc */
+#define CONFIG_AML_SUSPEND 1
+
+#define CONFIG_CMD_LOGO
+
+/*
+* CPU switch test for uboot
+*/
+//#define CONFIG_TEST_CPU_SWITCH 1
+
+
+#if defined(CONFIG_VLSI_EMULATOR)
+   //#undef CFG_DDR3_2GB
+
+   #undef CONFIG_BOOTCOMMAND
+   #define CONFIG_BOOTCOMMAND "echo Uboot for PXP is run..."
+
+   //#define CFG_DDR3_1GB
+   #define CONFIG_NO_DDR_PUB_VT_CHECK 1
+
+   #undef CONFIG_CMD_AUTOSCRIPT
+
+   #undef CONFIG_CMD_REBOOT
+   #undef CONFIG_PREBOOT
+
+   #undef CONFIG_AML_SUSPEND
+   #undef CONFIG_CMD_SUSPEND
+
+   #define CONFIG_AML_DISABLE_CRYPTO_UBOOT
+#endif
+/*
+ * Secure OS
+ */
+#ifdef CONFIG_MESON_TRUSTZONE
+
+//#define CONFIG_MESON_SECUREARGS  1
+#define CONFIG_JOIN_UBOOT_SECUREOS 1
+#define SECUREOS_KEY_BASE_ADDR 0x06100000
+#define SECURE_OS_DECOMPRESS_ADDR 0x06200000
+#define CONFIG_SECURE_STORAGE_BURNED
+#ifdef CONFIG_SECURE_STORAGE_BURNED
+#define CONFIG_MESON_STORAGE_BURN 1
+#define CONFIG_MESON_STORAGE_DEBUG
+#define CONFIG_SECURESTORAGEKEY
+#define CONFIG_RANDOM_GENERATE
+#define CONFIG_CMD_SECURESTORE
+#define CONFIG_CMD_RANDOM
+/* secure storage support both spi and emmc */
+#define CONFIG_SECURE_MMC
+#define CONFIG_SPI_NOR_SECURE_STORAGE
+#define CONFIG_SECURE_NAND 1
+#endif // CONFIG_SECURE_STORAGE_BURNED
+
+#endif //CONFIG_MESON_TRUSTZONE
+
+
+
+#endif //__CONFIG_M8B_M201_V1_H__
diff --git a/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-patch/create.patch.sh b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-patch/create.patch.sh
new file mode 100755
index 000000000..1cda33a29
--- /dev/null
+++ b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-patch/create.patch.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=2011.03-20160716
+
+tar --files-from=file.list -xJvf ../u-boot-aml-$VERSION.tar.xz
+mv u-boot-aml-$VERSION u-boot-aml-$VERSION-orig
+
+cp -rf ./u-boot-aml-$VERSION-new ./u-boot-aml-$VERSION
+
+diff -b --unified -Nr  u-boot-aml-$VERSION-orig  u-boot-aml-$VERSION > u-boot-aml-$VERSION-m8b_m201.patch
+
+mv u-boot-aml-$VERSION-m8b_m201.patch ../patches
+
+rm -rf ./u-boot-aml-$VERSION
+rm -rf ./u-boot-aml-$VERSION-orig
diff --git a/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-patch/file.list b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-patch/file.list
new file mode 100644
index 000000000..4d33bce0b
--- /dev/null
+++ b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-patch/file.list
@@ -0,0 +1,2 @@
+u-boot-aml-2011.03-20160716/arch/arm/cpu/aml_meson/m8b/firmware/appf/Makefile
+u-boot-aml-2011.03-20160716/arch/arm/cpu/aml_meson/m8b/firmware/arc_power/Makefile.gcc
diff --git a/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-patch/u-boot-aml-2011.03-20160716-new/arch/arm/cpu/aml_meson/m8b/firmware/appf/Makefile b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-patch/u-boot-aml-2011.03-20160716-new/arch/arm/cpu/aml_meson/m8b/firmware/appf/Makefile
new file mode 100644
index 000000000..153d08ac9
--- /dev/null
+++ b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-patch/u-boot-aml-2011.03-20160716-new/arch/arm/cpu/aml_meson/m8b/firmware/appf/Makefile
@@ -0,0 +1,114 @@
+#
+# Copyright (C) 2008-2010 ARM Limited                           
+#
+# This software is provided 'as-is', without any express or implied
+# warranties including the implied warranties of satisfactory quality, 
+# fitness for purpose or non infringement.  In no event will  ARM be 
+# liable for any damages arising from the use of this software.
+#
+# Permission is granted to anyone to use, copy and modify this software for 
+# any purpose, and to redistribute the software, subject to the following 
+# restrictions: 
+#
+# 1. The origin of this software must not be misrepresented; you must not
+#    claim that you wrote the original software. If you use this software
+#    in a product, an acknowledgment in the product documentation would be
+#    appreciated but is not required.                                       
+# 2. Altered source versions must be plainly marked as such, and must not be
+#    misrepresented as being the original software.
+# 3. This notice may not be removed or altered from any source distribution.
+#
+include $(TOPDIR)/config.mk
+TOOLSDIR = $(SRCTREE)/build/tools
+OUTDIR = $(SRCTREE)/build/appf
+EXTINCDIR=$(SRCTREE)/build/include2
+EXTINCDIR2=$(SRCTREE)/build/include
+EXTINCDIR3=$(SRCTREE)/include
+PLATFORM?=a9-eb
+ENTRY_POINT=appf_boottime_init
+LISTFILE=$(OUTDIR)/symbols.txt
+HEADERS=appf_boot_api.h appf_internals.h appf_types.h \
+        appf_helpers.h appf_platform_api.h
+
+OBJECTS= $(OUTDIR)/os_api.o \
+         $(OUTDIR)/entry.o \
+         $(OUTDIR)/translation.o \
+         $(OUTDIR)/table_data.o \
+         $(OUTDIR)/helpers.o \
+				 $(OUTDIR)/gic.o \
+				 $(OUTDIR)/pl310.o \
+				 $(OUTDIR)/v7.o \
+				 $(OUTDIR)/a9.o \
+				 $(OUTDIR)/a9_c.o \
+				 $(OUTDIR)/scu.o \
+				 $(OUTDIR)/c_helpers.o \
+				 $(OUTDIR)/platform/$(PLATFORM)/platform.o \
+				 $(OUTDIR)/platform/$(PLATFORM)/power.o \
+	       $(OUTDIR)/platform/$(PLATFORM)/context.o \
+         $(OUTDIR)/platform/$(PLATFORM)/reset.o \
+         $(OUTDIR)/serial.o
+        
+CPU = cortex-a5
+GCC = TRUE
+ifeq ($(GCC),TRUE)
+CC=$(CROSS_COMPILE)gcc
+AS=$(CROSS_COMPILE)gcc
+LD=$(CROSS_COMPILE)ld
+fromelf=$(CROSS_COMPILE)objcopy
+MAPFILE=appf.gls
+CFLAGS= -g -O2 -fpie -fpic -mcpu=$(CPU) -I. -DNO_PCU -I$(EXTINCDIR) -I$(EXTINCDIR2) -I$(EXTINCDIR3) 
+# -DUSE_REALVIEW_EB_RESETS
+ASFLAGS= -g -mcpu=$(CPU) -mfpu=vfpv4 -c
+LDFLAGS= -g -nostartfiles -pie -static -e $(ENTRY_POINT) --verbose -T $(MAPFILE) -M
+
+$(OUTDIR)/%.o : $(OUTDIR)/%.S	# Remove make's implicit rule for .S files
+.PRECIOUS : $(OUTDIR)/%.gnu.S
+$(OUTDIR)/%.gnu.S : %.S
+		perl arm_to_gnu.pl $< $@
+$(OUTDIR)/%.o : $(OUTDIR)/%.gnu.S Makefile $(MAPFILE) $(HEADERS)
+		$(AS) $(ASFLAGS) $< -o $@
+
+else
+
+CC=armcc
+AS=armasm
+LD=armlink
+MAPFILE=appf.scf
+CFLAGS= -g  -O2 --cpu=$(CPU) --fpu=none -I. --apcs=/fpic --gnu -DNO_PCU 
+# -DUSE_REALVIEW_EB_RESETS
+ASFLAGS= --keep -g  --cpu $(CPU) --fpu=none --apcs=/fpic 
+LDFLAGS= --verbose --map --fpu=none --symbols --noremove --datacompressor=off --fpic --entry $(ENTRY_POINT) --scatter $(MAPFILE)
+
+%.o : %.S Makefile $(MAPFILE) $(HEADERS)
+		$(AS) $(ASFLAGS) $< -o $@
+
+
+endif
+
+all: $(OUTDIR)/appf.axf $(OUTDIR)/appf.bin $(OUTDIR)/appf_srec.txt
+
+clean:
+	rm -f $(OBJECTS)
+	rm -f $(LISTFILE)
+	rm -f $(OUTDIR)/appf.axf
+	rm -f $(OUTDIR)/appf.bin
+	rm -f $(OUTDIR)/appf_srec.txt
+	rm -f $(EXTINCDIR)/power_firmware.dat
+	rm -f $(SRCTREE)/arch/arm/cpu/aml_meson/m8b/power_firmware.dat
+	mkdir -p $(OUTDIR)/platform/$(PLATFORM)
+	
+$(OUTDIR)/%.o : %.c Makefile $(MAPFILE) $(HEADERS)
+		mkdir -p $(OUTDIR)/platform/$(PLATFORM)
+		$(CC) $(CFLAGS) -c $< -o $@
+
+$(OUTDIR)/appf.axf: $(OBJECTS) $(MAPFILE) Makefile
+	$(LD) $(LDFLAGS) $(OBJECTS) -o $@ > $(LISTFILE)
+
+$(OUTDIR)/appf.bin: $(OUTDIR)/appf.axf
+	$(fromelf) -O binary $<  $@
+	$(TOOLSDIR)/bin2code power_firmware_code $@ $(EXTINCDIR)/power_firmware.dat
+#	cp -f $(OUTDIR)/power_firmware.dat $(SRCTREE)/arch/arm/cpu/aml_meson/m8b/power_firmware.dat
+
+$(OUTDIR)/appf_srec.txt: $(OUTDIR)/appf.axf
+	$(fromelf) --gap-fill 0xff -O srec $< $@
+	
diff --git a/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-patch/u-boot-aml-2011.03-20160716-new/arch/arm/cpu/aml_meson/m8b/firmware/arc_power/Makefile.gcc b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-patch/u-boot-aml-2011.03-20160716-new/arch/arm/cpu/aml_meson/m8b/firmware/arc_power/Makefile.gcc
new file mode 100644
index 000000000..45b18db34
--- /dev/null
+++ b/sources/U-Boot/Amlogic/M201/create-2011.03-20160716-m8b_m201-patch/u-boot-aml-2011.03-20160716-new/arch/arm/cpu/aml_meson/m8b/firmware/arc_power/Makefile.gcc
@@ -0,0 +1,120 @@
+# ------------------------------------------------------------
+# Makefile for ROM BOOT CODE
+# ------------------------------------------------------------
+include $(TOPDIR)/config.mk
+
+TOOLSDIR = $(SRCTREE)/build/tools
+
+ARCCC = arc-elf32-em4-gcc
+ARCASM = arc-elf32-em4-as
+ARCLD = arc-elf32-em4-ld
+ifeq ($(OS),Windows_NT)
+MKDIR=if not exist $(subst /,\,$(1)) mkdir $(subst /,\,$(1))
+else
+MKDIR=mkdir -p $(1)
+endif
+
+ARCOBJCOPY = arc-elf32-em4-objcopy
+ARCDUMPELF = arc-elf32-em4-elfdump
+ARCDUMP_FLAGS = -z
+ARCCPP=arc-elf32-em4-cpp
+
+#ARCCC_FLAGS = -mA7 -mno-volatile-cache -O2 -D__ARC__ -DCONFIG_ARC -I. -Iinclude -Wall
+
+#BASEFLAGS = -arcv2em -core1 -Xcd -Xbs -DAML_ARCEM4
+BASEFLAGS = -mcpu=em4
+#CC_FLAGS = $(BASEFLAGS) -O -HL -Hnocrt -Hnolib  -I$(ucode) -c $(CC_FLAGS_ADD) -DARC6 -DAO_ARC
+CC_FLAGS = $(BASEFLAGS) -O  -c $(CC_FLAGS_ADD)
+#ASM_FLAGS = $(BASEFLAGS) -HL -Hnocrt -Hnolib $(ASM_FLAGS_ADD) -I$(ucode) -c  $(ASM_FLAGS_ADD)
+#LD_FLAGS =  -Bbase=0x00000000 -L${METAWARE_ROOT}/arc/lib/av2em/le -l ct -l mw
+#DUMP_FLAGS = -z
+
+
+ARCCC_FLAGS = $(CC_FLAGS) -Iinclude -Wall
+ARCCC_FLAGS += -g -MD -mno-sdata -fno-builtin -ffreestanding -nostdinc -isystem -pipe -fomit-frame-pointer
+#ARCCC_FLAGS += -Wstrict-prototypes -fno-stack-protector -D__KERNEL__ -mno-cond-exec
+ARCCC_FLAGS += -I./include/ -I$(TOPDIR)/arch/arm/include/asm/arch-m8b/ -I$(TOPDIR)/arch/arm/include/ -I$(TOPDIR)/arch/arm/include/asm/ -I$(TOPDIR)/build/include
+ARCCC_FLAGS += -include $(TOPDIR)/build/include/config.h -I $(TOPDIR)/include/ -I $(TOPDIR)/arch/arm/include/
+
+ifdef CONFIG_SUPPORT_CUSOTMER_BOARD
+VPATH_LIST = $(TOPDIR)/customer/board/$(BOARD) \
+             $(SRCTREE)/$(CPUDIR)/$(SOC)       \
+             $(SRCTREE)/$(CPUDIR)
+else
+VPATH_LIST = $(TOPDIR)/board/$(BOARDDIR) \
+             $(SRCTREE)/$(CPUDIR)/$(SOC) \
+             $(SRCTREE)/$(CPUDIR)
+endif
+
+VPATH_LIST:=$(VPATH_LIST:%=%/firmware/arc_power/)
+ARCCC_FLAGS += $(VPATH_LIST:%=-I%)
+vpath %.c $(VPATH_LIST)
+
+ARCCC_FLAGS += -I.
+
+ARCASM_FLAGS = -D__ASSEMBLY__ $(CC_FLAGS)
+
+ARCGCCLIBPATH=$(dir $(shell $(ARCCC) -print-libgcc-file-name))
+
+ARCCOPY_FLAGS= -I elf32-little -O binary
+
+obj =$(SRCTREE)/build/arc_power/
+
+ARCLD_FLAGS   =  -Bstatic -T $(obj)romboot.lds -L$(ARCGCCLIBPATH) -lgcc
+ARCLD_FLAGS += -marcelf
+define MAP_OUT_OPTION
+	  -Map $(obj)code_elf.map
+endef
+
+
+#CSRCS = $(wildcard *.c lib/*.c)
+CSRCS = i2c.c arc_pwr.c mmc.c lib/serial.c
+OBJS = $(CSRCS:%.c=$(obj)%.o)
+
+#all : clean $(obj)code_elf.out
+all : clean $(obj)code_elf.out $(obj)arc_pwr.bin
+
+$(obj)arc_pwr.bin: $(obj)code_elf.out
+	$(ARCOBJCOPY) -I elf32-little --gap-fill=0xff -O binary $< $@
+
+$(obj)code_elf.out: $(obj)romboot.lds Makefile  $(obj)start_arc.o $(OBJS)
+	$(ARCLD) $(ARCLD_FLAGS) $(filter %.o,$^)  $(MAP_OUT_OPTION) --cref -o $@
+ifneq ($(OS),Windows_NT)
+	$(ARCOBJCOPY) -I elf32-little --gap-fill=0xff -O binary $@ $(@:%.out=%.bin)
+endif
+	$(TOOLSDIR)/bin2code arc_code $(obj)code_elf.bin $(SRCTREE)/build/include2/arc_code.dat
+
+down: $(obj)code_elf.out
+	mdb -jtag -OKN $<
+
+$(obj)%.o: %.s
+	@$(call MKDIR, $(@D))
+	$(ARCCC) $(ARCASM_FLAGS) -o $@ $< -c
+
+$(obj)%.o: %.S
+	@$(call MKDIR, $(@D))
+	$(ARCCC) $(ASM_FLAGS) -o $@ $< -c
+
+$(obj)%.S: %.s
+	@$(call MKDIR, $(@D))
+	$(ARCCPP) -I. -ansi -D__ASSEMBLY__ -MD -MT $@ -E $< -o $@
+
+$(obj)%.o: %.c
+	@$(call MKDIR, $(@D))
+	$(ARCCC) $(ARCCC_FLAGS) -o $@ $< -c
+
+clean:
+	rm -r -f $(obj)
+	rm -f $(SRCTREE)/build/include2/arc_code.dat
+
+help:
+	@echo "test arc_power"
+	@echo "VPATH_LIST="$(VPATH_LIST)
+	@echo "SRCTREE="$(SRCTREE)
+	@echo "CPUDIR="$(CPUDIR)
+	@echo "SOC="$(SOC)
+
+$(obj)romboot.lds: romboot.lds
+	@$(call MKDIR, $(@D))
+	$(ARCCPP) $(ARCCPPFLAGS) $(ARCLDPPFLAGS) -std=c99 -D__ASSEMBLY__ -P - <$^ >$@
+-include $(wildcard $(OBJS:%.o=%.d))