Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for BananaPi BPi-R2 #1135

Closed
wants to merge 11 commits into from
49 changes: 49 additions & 0 deletions package/boot/uboot-mtk-bpi-r2/Makefile
@@ -0,0 +1,49 @@
#
# Copyright (C) 2016 Gary Wang <gary.wang@bananapi.org>
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk

PKG_NAME:=uboot-mtk-bpi-r2
PKG_VERSION:=v1.0
PKG_RELEASE:=1
HOSTCPPFLAGS:="-I."
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/BPI-SINOVOIP/BPI-R2-LEDE-Uboot.git
PKG_SOURCE_VERSION:=b05a4e323e1fd8727fcfe32c35d562f12b88a23b

PKG_LICENSE:=GPL-2.0 GPL-2.0+
PKG_LICENSE_FILES:=Licenses/README

PKG_MAINTAINER:=Gary Wang <gary.wang@bananapi.com>

include $(INCLUDE_DIR)/u-boot.mk
include $(INCLUDE_DIR)/package.mk

define U-Boot/bpi_r2
BUILD_TARGET:=mediatek
NAME:=Mediatek Banana Pi R2 board
BUILD_DEVICES:=7623n-bananapi-bpi-r2
endef

UBOOT_TARGETS := \
bpi_r2


UBOOT_CONFIGURE_VARS += USE_PRIVATE_LIBGCC=yes

define Build/InstallDev
$(INSTALL_DIR) $(STAGING_DIR_IMAGE)
$(CP) $(PKG_BUILD_DIR)/$(UBOOT_IMAGE) $(STAGING_DIR_IMAGE)/mtk-bpi-r2-uboot.bin
$(CP) $(PKG_BUILD_DIR)/bpi_r2_preloader/EMMC_PRELOADER_1600MHz.img $(STAGING_DIR_IMAGE)/mtk-bpi-r2-preloader-emmc.bin
$(CP) $(PKG_BUILD_DIR)/bpi_r2_preloader/SD_PRELOADER_1600MHz.img $(STAGING_DIR_IMAGE)/mtk-bpi-r2-preloader-sd.bin
endef

define Package/u-boot/install/default
endef

$(eval $(call BuildPackage/U-Boot))
56 changes: 56 additions & 0 deletions package/boot/uboot-mtk-bpi-r2/patches/002-use-static-inline.patch
@@ -0,0 +1,56 @@
Index: uboot-mtk-bpi-r2-v1.0/arch/arm/include/asm/io.h
===================================================================
--- uboot-mtk-bpi-r2-v1.0.orig/arch/arm/include/asm/io.h
+++ uboot-mtk-bpi-r2-v1.0/arch/arm/include/asm/io.h
@@ -75,7 +75,7 @@ static inline phys_addr_t virt_to_phys(v
#define __arch_putw(v,a) (*(volatile unsigned short *)(a) = (v))
#define __arch_putl(v,a) (*(volatile unsigned int *)(a) = (v))

-extern inline void __raw_writesb(unsigned long addr, const void *data,
+static inline void __raw_writesb(unsigned long addr, const void *data,
int bytelen)
{
uint8_t *buf = (uint8_t *)data;
@@ -83,7 +83,7 @@ extern inline void __raw_writesb(unsigne
__arch_putb(*buf++, addr);
}

-extern inline void __raw_writesw(unsigned long addr, const void *data,
+static inline void __raw_writesw(unsigned long addr, const void *data,
int wordlen)
{
uint16_t *buf = (uint16_t *)data;
@@ -91,7 +91,7 @@ extern inline void __raw_writesw(unsigne
__arch_putw(*buf++, addr);
}

-extern inline void __raw_writesl(unsigned long addr, const void *data,
+static inline void __raw_writesl(unsigned long addr, const void *data,
int longlen)
{
uint32_t *buf = (uint32_t *)data;
@@ -99,21 +99,21 @@ extern inline void __raw_writesl(unsigne
__arch_putl(*buf++, addr);
}

-extern inline void __raw_readsb(unsigned long addr, void *data, int bytelen)
+static inline void __raw_readsb(unsigned long addr, void *data, int bytelen)
{
uint8_t *buf = (uint8_t *)data;
while(bytelen--)
*buf++ = __arch_getb(addr);
}

-extern inline void __raw_readsw(unsigned long addr, void *data, int wordlen)
+static inline void __raw_readsw(unsigned long addr, void *data, int wordlen)
{
uint16_t *buf = (uint16_t *)data;
while(wordlen--)
*buf++ = __arch_getw(addr);
}

-extern inline void __raw_readsl(unsigned long addr, void *data, int longlen)
+static inline void __raw_readsl(unsigned long addr, void *data, int longlen)
{
uint32_t *buf = (uint32_t *)data;
while(longlen--)
38 changes: 38 additions & 0 deletions package/boot/uboot-mtk-bpi-r2/patches/003-use-weak-in-board.patch
@@ -0,0 +1,38 @@
Index: uboot-mtk-bpi-r2-v1.0/arch/arm/lib/board.c
===================================================================
--- uboot-mtk-bpi-r2-v1.0.orig/arch/arm/lib/board.c
+++ uboot-mtk-bpi-r2-v1.0/arch/arm/lib/board.c
@@ -69,24 +69,15 @@ extern void dataflash_print_info(void);
************************************************************************
* May be supplied by boards if desired
*/
-inline void __coloured_LED_init(void) {}
-void coloured_LED_init(void) __attribute__((weak, alias("__coloured_LED_init")));
-inline void __red_led_on(void) {}
-void red_led_on(void) __attribute__((weak, alias("__red_led_on")));
-inline void __red_led_off(void) {}
-void red_led_off(void) __attribute__((weak, alias("__red_led_off")));
-inline void __green_led_on(void) {}
-void green_led_on(void) __attribute__((weak, alias("__green_led_on")));
-inline void __green_led_off(void) {}
-void green_led_off(void) __attribute__((weak, alias("__green_led_off")));
-inline void __yellow_led_on(void) {}
-void yellow_led_on(void) __attribute__((weak, alias("__yellow_led_on")));
-inline void __yellow_led_off(void) {}
-void yellow_led_off(void) __attribute__((weak, alias("__yellow_led_off")));
-inline void __blue_led_on(void) {}
-void blue_led_on(void) __attribute__((weak, alias("__blue_led_on")));
-inline void __blue_led_off(void) {}
-void blue_led_off(void) __attribute__((weak, alias("__blue_led_off")));
+__weak void coloured_LED_init(void) {}
+__weak void red_led_on(void) {}
+__weak void red_led_off(void) {}
+__weak void green_led_on(void) {}
+__weak void green_led_off(void) {}
+__weak void yellow_led_on(void) {}
+__weak void yellow_led_off(void) {}
+__weak void blue_led_on(void) {}
+__weak void blue_led_off(void) {}

/*
************************************************************************
14 changes: 14 additions & 0 deletions package/boot/uboot-mtk-bpi-r2/patches/004-use-weak-in-main.patch
@@ -0,0 +1,14 @@
Index: uboot-mtk-bpi-r2-v1.0/common/main.c
===================================================================
--- uboot-mtk-bpi-r2-v1.0.orig/common/main.c
+++ uboot-mtk-bpi-r2-v1.0/common/main.c
@@ -27,8 +27,7 @@ DECLARE_GLOBAL_DATA_PTR;
/*
* Board-specific Platform code can reimplement show_boot_progress () if needed
*/
-void inline __show_boot_progress (int val) {}
-void show_boot_progress (int val) __attribute__((weak, alias("__show_boot_progress")));
+__weak void show_boot_progress(int val) {}

#define MAX_DELAY_STOP_STR 32