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 Imagination's Pistachio SoC and (Ci40) Marduk platform support #201

4 changes: 2 additions & 2 deletions include/image.mk
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ endef
define Image/BuildKernel/MkFIT
$(TOPDIR)/scripts/mkits.sh \
-D $(1) -o $(KDIR)/fit-$(1).its -k $(2) $(if $(3),-d $(3)) -C $(4) -a $(5) -e $(6) \
-A $(ARCH) -v $(LINUX_VERSION)
-A $(LINUX_KARCH) -v $(LINUX_VERSION)
PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $(KDIR)/fit-$(1).its $(KDIR)/fit-$(1)$(7).itb
endef

Expand Down Expand Up @@ -342,7 +342,7 @@ define Build/fit
-D $(DEVICE_NAME) -o $@.its -k $@ \
$(if $(word 2,$(1)),-d $(word 2,$(1))) -C $(word 1,$(1)) \
-a $(KERNEL_LOADADDR) -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \
-A $(ARCH) -v $(LINUX_VERSION)
-A $(LINUX_KARCH) -v $(LINUX_VERSION)
PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.new
@mv $@.new $@
endef
Expand Down
4 changes: 4 additions & 0 deletions package/boot/uboot-envtools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ ifneq ($(CONFIG_TARGET_oxnas),)
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_BIN) ./files/oxnas $(1)/etc/uci-defaults/30_uboot-envtools
endif
ifneq ($(CONFIG_TARGET_pistachio),)
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_DATA) ./files/pistachio $(1)/etc/uci-defaults/30_uboot-envtools
endif
ifneq ($(CONFIG_TARGET_ramips),)
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_DATA) ./files/ramips $(1)/etc/uci-defaults/30_uboot-envtools
Expand Down
29 changes: 29 additions & 0 deletions package/boot/uboot-envtools/files/pistachio
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh
#
# Copyright (C) 2016 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

[ -e /etc/config/ubootenv ] && exit 0

touch /etc/config/ubootenv

. /lib/functions/pistachio.sh
. /lib/uboot-envtools.sh
. /lib/functions.sh

board=$(pistachio_board_name)

case "$board" in
Marduk)
ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x2000" "0x1000" ""
;;
esac

config_load ubootenv
config_foreach ubootenv_add_app_config ubootenv

exit 0

12 changes: 12 additions & 0 deletions target/linux/generic/config-4.4
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ CONFIG_BLOCK=y
CONFIG_BOOKE_WDT_DEFAULT_TIMEOUT=3
# CONFIG_BOOT_PRINTK_DELAY is not set
CONFIG_BOOT_RAW=y
# CONFIG_BOUNCE is not set
CONFIG_BPF=y
# CONFIG_BPF_JIT is not set
CONFIG_BPF_SYSCALL=y
Expand Down Expand Up @@ -952,6 +953,7 @@ CONFIG_DEVPORT=y
CONFIG_DOUBLEFAULT=y
# CONFIG_DP83848_PHY is not set
# CONFIG_DP83867_PHY is not set
# CONFIG_DPM_WATCHDOG is not set
CONFIG_DQL=y
# CONFIG_DRAGONRISE_FF is not set
# CONFIG_DRM is not set
Expand Down Expand Up @@ -1657,6 +1659,7 @@ CONFIG_IOSCHED_NOOP=y
# CONFIG_IP6_NF_MATCH_RT is not set
# CONFIG_IP6_NF_NAT is not set
# CONFIG_IP6_NF_RAW is not set
# CONFIG_IP6_NF_SECURITY is not set
# CONFIG_IP6_NF_TARGET_HL is not set
# CONFIG_IP6_NF_TARGET_REJECT is not set
# CONFIG_IP6_NF_TARGET_SYNPROXY is not set
Expand Down Expand Up @@ -2203,6 +2206,7 @@ CONFIG_MMC_BLOCK_MINORS=8
# CONFIG_MMC_USHC is not set
# CONFIG_MMC_VIA_SDMMC is not set
# CONFIG_MMC_VUB300 is not set
# CONFIG_MMC_WBSD is not set
# CONFIG_MMIOTRACE is not set
CONFIG_MMU=y
CONFIG_MODULES=y
Expand Down Expand Up @@ -2465,6 +2469,7 @@ CONFIG_NETDEVICES=y
# CONFIG_NETFILTER_XT_TARGET_NOTRACK is not set
# CONFIG_NETFILTER_XT_TARGET_RATEEST is not set
# CONFIG_NETFILTER_XT_TARGET_REDIRECT is not set
# CONFIG_NETFILTER_XT_TARGET_SECMARK is not set
# CONFIG_NETFILTER_XT_TARGET_TCPMSS is not set
# CONFIG_NETFILTER_XT_TARGET_TCPOPTSTRIP is not set
# CONFIG_NETFILTER_XT_TARGET_TEE is not set
Expand Down Expand Up @@ -2673,6 +2678,7 @@ CONFIG_NFS_V3=y
CONFIG_NF_CONNTRACK_PROCFS=y
# CONFIG_NF_CONNTRACK_PROC_COMPAT is not set
# CONFIG_NF_CONNTRACK_SANE is not set
# CONFIG_NF_CONNTRACK_SECMARK is not set
# CONFIG_NF_CONNTRACK_SIP is not set
# CONFIG_NF_CONNTRACK_SNMP is not set
# CONFIG_NF_CONNTRACK_TFTP is not set
Expand Down Expand Up @@ -2979,7 +2985,9 @@ CONFIG_PINMUX=y
# CONFIG_PMIC_ADP5520 is not set
# CONFIG_PMIC_DA903X is not set
# CONFIG_PM_AUTOSLEEP is not set
# CONFIG_PM_DEBUG is not set
# CONFIG_PM_DEVFREQ is not set
# CONFIG_PM_TEST_SUSPEND is not set
# CONFIG_PM_WAKELOCKS is not set
# CONFIG_POSIX_MQUEUE is not set
# CONFIG_POWERCAP is not set
Expand Down Expand Up @@ -3259,6 +3267,7 @@ CONFIG_RTC_INTF_SYSFS=y
CONFIG_RTC_LIB=y
CONFIG_RTC_SYSTOHC=y
CONFIG_RTC_SYSTOHC_DEVICE="rtc0"
# CONFIG_RTL8XXXU is not set
# CONFIG_RTL8180 is not set
# CONFIG_RTL8187 is not set
# CONFIG_RTL8192E is not set
Expand Down Expand Up @@ -4229,6 +4238,7 @@ CONFIG_TRAD_SIGNALS=y
# CONFIG_TRANSPARENT_HUGEPAGE is not set
# CONFIG_TREE_RCU is not set
# CONFIG_TREE_RCU_TRACE is not set
# CONFIG_TRUSTED_KEYS is not set
# CONFIG_TSL2583 is not set
# CONFIG_TSL2x7x is not set
# CONFIG_TSL4531 is not set
Expand Down Expand Up @@ -4606,6 +4616,7 @@ CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV=y
# CONFIG_VFAT_FS is not set
# CONFIG_VGASTATE is not set
# CONFIG_VGA_ARB is not set
# CONFIG_VGA_CONSOLE is not set
# CONFIG_VGA_SWITCHEROO is not set
# CONFIG_VIA_RHINE is not set
# CONFIG_VIA_VELOCITY is not set
Expand Down Expand Up @@ -4759,6 +4770,7 @@ CONFIG_WEXT_CORE=y
CONFIG_WEXT_PRIV=y
CONFIG_WEXT_PROC=y
CONFIG_WEXT_SPY=y
# CONFIG_WILC1000_DRIVER is not set
CONFIG_WILINK_PLATFORM_DATA=y
# CONFIG_WIMAX is not set
# CONFIG_WIMAX_GDM72XX is not set
Expand Down
26 changes: 26 additions & 0 deletions target/linux/pistachio/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#
# Copyright (C) 2016 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

ARCH:=mipsel
BOARD:=pistachio
BOARDNAME:=IMG MIPS Pistachio
FEATURES:=targz nand squashfs ubifs audio ramdisk fpu usb usbgadget
SUBTARGETS=marduk
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have any plans to add more subtargets soon? If not, you should drop this line.


KERNEL_PATCHVER:=4.4

CPU_TYPE:=mips32r2

include $(INCLUDE_DIR)/target.mk

define Target/Description
Build firmware images for Pistachio board.
endef

$(eval $(call BuildTarget))
7 changes: 7 additions & 0 deletions target/linux/pistachio/base-files/etc/init.d/resetbootcount
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh /etc/rc.common

START=99

start() {
echo 0 > `ls -1 /sys/devices/platform/*uboot-count/bootcount`
}
29 changes: 29 additions & 0 deletions target/linux/pistachio/base-files/lib/functions/pistachio.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/sh

pistachio_board_detect() {
name=`grep "^machine" /proc/cpuinfo | sed "s/machine.*: IMG \(.*\)/\1/g" | sed "s/\(.*\) - .*/\1/g"`
model=`grep "^machine" /proc/cpuinfo | sed "s/machine.*: \(.*\)/\1/g" | sed "s/.* - \(.*\)/\1/g"`
[ -z "$name" ] && name="unknown"
[ -z "$model" ] && model="unknown"
[ -e "/tmp/sysinfo/" ] || mkdir -p "/tmp/sysinfo/"
echo $name > /tmp/sysinfo/board_name
echo $model > /tmp/sysinfo/model
}

pistachio_board_model() {
local model

[ -f /tmp/sysinfo/model ] && model=$(cat /tmp/sysinfo/model)
[ -z "$model" ] && model="unknown"

echo "$model"
}

pistachio_board_name() {
local name

[ -f /tmp/sysinfo/board_name ] && name=$(cat /tmp/sysinfo/board_name)
[ -z "$name" ] && name="unknown"

echo "$name"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

do_pistachio() {
. /lib/functions/pistachio.sh

pistachio_board_detect
}

boot_hook_add preinit_main do_pistachio
37 changes: 37 additions & 0 deletions target/linux/pistachio/base-files/lib/upgrade/platform.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
. /lib/functions/pistachio.sh

platform_check_image()
{
local board=$(pistachio_board_name)
nand_do_platform_check "$board" "$1"
return $?
}

platform_pre_upgrade()
{
export RAMFS_COPY_BIN="${RAMFS_COPY_BIN} /usr/sbin/fw_printenv /usr/sbin/fw_setenv"
export RAMFS_COPY_BIN="${RAMFS_COPY_BIN} /bin/mkdir /bin/touch"
export RAMFS_COPY_DATA="${RAMFS_COPY_DATA} /etc/fw_env.config /var/lock/fw_printenv.lock"
}

platform_do_upgrade()
{
mkdir -p /var/lock
touch /var/lock/fw_printenv.lock

boot_partition=`fw_printenv -n boot_partition`
echo "Current boot partiton " $boot_partition

if [ "$boot_partition" == "1" ]
then
CI_UBIPART="firmware0"
fw_setenv boot_partition 0
else
CI_UBIPART="firmware1"
fw_setenv boot_partition 1
fi

echo "Writing image to " $CI_UBIPART

nand_upgrade_ubinized $1;
}