From ab76fca4cc144270eb50ace58519b277e1259c39 Mon Sep 17 00:00:00 2001 From: Zoltan HERPAI Date: Fri, 18 Aug 2023 09:15:50 +0200 Subject: [PATCH] leon: bring back / add new target for LEON3 SPARC support This target has been removed in 2014, re-add target with renewed interest. It will support LEON3/4-based SPARC CPUs, as well as running images via QEMU/leon3. Signed-off-by: Zoltan HERPAI --- target/linux/leon/Makefile | 25 ++++ target/linux/leon/config-5.15 | 225 +++++++++++++++++++++++++++++++ target/linux/leon/image/Makefile | 55 ++++++++ 3 files changed, 305 insertions(+) create mode 100644 target/linux/leon/Makefile create mode 100644 target/linux/leon/config-5.15 create mode 100644 target/linux/leon/image/Makefile diff --git a/target/linux/leon/Makefile b/target/linux/leon/Makefile new file mode 100644 index 0000000000..f67802bdb9 --- /dev/null +++ b/target/linux/leon/Makefile @@ -0,0 +1,25 @@ +# +# Copyright (C) 2023 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +include $(TOPDIR)/rules.mk + +ARCH:=sparc +BOARD:=leon +BOARDNAME:=LEON +FEATURES+=fpu tgz +CPU_TYPE:=v8 + +#origi: CFLAGS:=-Os -pipe -mcpu=v8 -fno-caller-saves +#CFLAGS:= -mcpu=leon3 -D__sparc_v8__ +# -Os -pipe -msoft-float +KERNELNAME:="uImage" + +KERNEL_PATCHVER:=5.15 +MAINTAINER:=Zoltan HERPAI + +include $(INCLUDE_DIR)/target.mk + +$(eval $(call BuildTarget)) diff --git a/target/linux/leon/config-5.15 b/target/linux/leon/config-5.15 new file mode 100644 index 0000000000..6629b57091 --- /dev/null +++ b/target/linux/leon/config-5.15 @@ -0,0 +1,225 @@ +# CONFIG_64BIT is not set +CONFIG_ARCH_32BIT_OFF_T=y +CONFIG_ARCH_MAY_HAVE_PC_FDC=y +CONFIG_ARCH_MIGHT_HAVE_PC_SERIO=y +CONFIG_ARCH_PROC_KCORE_TEXT=y +CONFIG_ASSOCIATIVE_ARRAY=y +CONFIG_AUDIT_ARCH=y +CONFIG_AUTOFS4_FS=y +CONFIG_AUTOFS_FS=y +CONFIG_BCM_NET_PHYLIB=y +CONFIG_BINFMT_MISC=y +CONFIG_BLK_DEBUG_FS=y +CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0 +CONFIG_BOUNCE=y +# CONFIG_BPF_SYSCALL is not set +# CONFIG_BRIDGE is not set +CONFIG_BROADCOM_PHY=y +# CONFIG_CACHEFILES is not set +CONFIG_CICADA_PHY=y +CONFIG_CLZ_TAB=y +# CONFIG_COMMON_CLK is not set +# CONFIG_COMPACTION is not set +CONFIG_COMPAT_32BIT_TIME=y +CONFIG_COMPAT_BRK=y +CONFIG_CONSOLE_TRANSLATIONS=y +CONFIG_COREDUMP=y +CONFIG_CPU_BIG_ENDIAN=y +CONFIG_CPU_ISOLATION=y +CONFIG_CPU_NO_EFFICIENT_FFS=y +CONFIG_CPU_RMAP=y +CONFIG_CRASH_CORE=y +# CONFIG_CRC32_SARWATE is not set +CONFIG_CRC32_SLICEBY8=y +CONFIG_CROSS_MEMORY_ATTACH=y +CONFIG_DAVICOM_PHY=y +CONFIG_DEBUG_BUGVERBOSE=y +CONFIG_DEBUG_INFO=y +CONFIG_DEBUG_MISC=y +CONFIG_DECOMPRESS_GZIP=y +CONFIG_DEFAULT_HOSTNAME="leon" +CONFIG_DETECT_HUNG_TASK=y +CONFIG_DEVMEM=y +CONFIG_DEVTMPFS=y +CONFIG_DEVTMPFS_MOUNT=y +CONFIG_DMA_OPS=y +CONFIG_DNOTIFY=y +CONFIG_DNS_RESOLVER=y +CONFIG_DST_CACHE=y +CONFIG_DUMMY_CONSOLE=y +CONFIG_ELF_CORE=y +CONFIG_EMULATED_CMPXCHG=y +CONFIG_FIXED_PHY=y +CONFIG_FORCE_MAX_ZONEORDER=13 +CONFIG_FWNODE_MDIO=y +# CONFIG_FW_LOADER_USER_HELPER is not set +CONFIG_GENERIC_ATOMIC64=y +CONFIG_GENERIC_CLOCKEVENTS=y +CONFIG_GENERIC_IRQ_SHOW=y +CONFIG_GENERIC_ISA_DMA=y +CONFIG_GENERIC_PCI_IOMAP=y +CONFIG_GENERIC_SMP_IDLE_THREAD=y +CONFIG_GENERIC_STRNCPY_FROM_USER=y +CONFIG_GENERIC_STRNLEN_USER=y +CONFIG_GRACE_PERIOD=y +CONFIG_GRETH=y +CONFIG_GRO_CELLS=y +CONFIG_HAS_DMA=y +CONFIG_HAS_IOMEM=y +CONFIG_HAS_IOPORT_MAP=y +CONFIG_HID=y +CONFIG_HIGHMEM=y +CONFIG_HW_CONSOLE=y +CONFIG_HZ_PERIODIC=y +CONFIG_ICPLUS_PHY=y +CONFIG_IKCONFIG=y +CONFIG_IKCONFIG_PROC=y +CONFIG_INET_DIAG=y +# CONFIG_INET_DIAG_DESTROY is not set +# CONFIG_INET_RAW_DIAG is not set +CONFIG_INET_TCP_DIAG=y +CONFIG_INET_TUNNEL=y +CONFIG_INITRAMFS_COMPRESSION_GZIP=y +# CONFIG_INITRAMFS_COMPRESSION_NONE is not set +CONFIG_INITRAMFS_ROOT_GID=0 +CONFIG_INITRAMFS_ROOT_UID=0 +CONFIG_INITRAMFS_SOURCE="${BR_BINARIES_DIR}/rootfs.cpio" +CONFIG_INPUT=y +CONFIG_IO_URING=y +CONFIG_IPV6=y +CONFIG_IPV6_SIT=y +CONFIG_IRQ_WORK=y +CONFIG_KALLSYMS=y +CONFIG_KEYS=y +CONFIG_KMAP_LOCAL=y +CONFIG_LEGACY_PTYS=y +CONFIG_LEGACY_PTY_COUNT=256 +CONFIG_LOCALVERSION_AUTO=y +CONFIG_LOCKD=y +CONFIG_LOG_BUF_SHIFT=14 +CONFIG_LSI_ET1011C_PHY=y +CONFIG_LSM="lockdown,yama,loadpin,safesetid,integrity,bpf" +CONFIG_LXT_PHY=y +CONFIG_MAGIC_SYSRQ=y +CONFIG_MAGIC_SYSRQ_SERIAL=y +CONFIG_MARVELL_PHY=y +CONFIG_MDIO_BUS=y +CONFIG_MDIO_DEVICE=y +CONFIG_MDIO_DEVRES=y +CONFIG_MEMFD_CREATE=y +CONFIG_MICREL_PHY=y +CONFIG_MODULES_USE_ELF_RELA=y +CONFIG_MQ_IOSCHED_DEADLINE=y +CONFIG_MQ_IOSCHED_KYBER=y +CONFIG_NATIONAL_PHY=y +CONFIG_NEED_DMA_MAP_STATE=y +CONFIG_NEED_SG_DMA_LENGTH=y +CONFIG_NETFS_SUPPORT=y +CONFIG_NET_FLOW_LIMIT=y +CONFIG_NET_IP_TUNNEL=y +CONFIG_NET_SELFTESTS=y +CONFIG_NLS=y +CONFIG_NR_CPUS=32 +CONFIG_NVMEM=y +CONFIG_NVMEM_SYSFS=y +CONFIG_ODD_RT_SIGACTION=y +CONFIG_OF=y +CONFIG_OF_KOBJ=y +CONFIG_OF_MDIO=y +CONFIG_OF_PROMTREE=y +CONFIG_OID_REGISTRY=y +CONFIG_OLD_SIGACTION=y +CONFIG_OLD_SIGSUSPEND=y +# CONFIG_OVERLAY_FS is not set +# CONFIG_PANIC_ON_OOPS is not set +CONFIG_PANIC_ON_OOPS_VALUE=0 +CONFIG_PANIC_TIMEOUT=0 +# CONFIG_PARTITION_ADVANCED is not set +CONFIG_PGTABLE_LEVELS=3 +CONFIG_PHYLIB=y +CONFIG_PROC_KCORE=y +CONFIG_PROC_PAGE_MONITOR=y +CONFIG_PTP_1588_CLOCK_OPTIONAL=y +CONFIG_QSEMI_PHY=y +CONFIG_RCU_CPU_STALL_TIMEOUT=21 +CONFIG_RCU_TRACE=y +CONFIG_RD_GZIP=y +CONFIG_REALTEK_PHY=y +CONFIG_RFS_ACCEL=y +CONFIG_ROOT_NFS=y +CONFIG_RPS=y +CONFIG_RTC_CLASS=y +CONFIG_RTC_DRV_M48T59=y +CONFIG_RTC_NVMEM=y +CONFIG_SBUS=y +CONFIG_SBUSCHAR=y +# CONFIG_SCHED_STACK_END_CHECK is not set +# CONFIG_SECURITY_DMESG_RESTRICT is not set +# CONFIG_SERIAL_8250 is not set +CONFIG_SERIAL_CONSOLE=y +CONFIG_SERIAL_GRLIB_GAISLER_APBUART=y +CONFIG_SERIAL_GRLIB_GAISLER_APBUART_CONSOLE=y +CONFIG_SERIAL_SUNCORE=y +CONFIG_SERIAL_SUNZILOG=y +CONFIG_SERIAL_SUNZILOG_CONSOLE=y +CONFIG_SERIO=y +CONFIG_SERIO_SERPORT=y +CONFIG_SGETMASK_SYSCALL=y +CONFIG_SLAB=y +# CONFIG_SLAB_FREELIST_HARDENED is not set +# CONFIG_SLAB_FREELIST_RANDOM is not set +# CONFIG_SLUB is not set +CONFIG_SMP=y +CONFIG_SMSC_PHY=y +CONFIG_SOCK_DIAG=y +CONFIG_SOCK_RX_QUEUE_MAPPING=y +CONFIG_SPARC=y +CONFIG_SPARC32=y +CONFIG_SPARC32_SMP=y +# CONFIG_SPARC_LED is not set +CONFIG_SPARC_LEON=y +CONFIG_SPLIT_PTLOCK_CPUS=999999 +CONFIG_SRCU=y +# CONFIG_STAGING is not set +CONFIG_STE10XP=y +# CONFIG_STRIP_ASM_SYMS is not set +# CONFIG_SUNBMAC is not set +# CONFIG_SUNLANCE is not set +# CONFIG_SUNQE is not set +CONFIG_SUNRPC=y +CONFIG_SUNRPC_GSS=y +CONFIG_SUN_OPENPROMFS=y +CONFIG_SUN_OPENPROMIO=y +CONFIG_SUN_PARTITION=y +CONFIG_SUN_PM=y +CONFIG_SWPHY=y +# CONFIG_SYN_COOKIES is not set +CONFIG_SYSCTL_EXCEPTION_TRACE=y +CONFIG_SYSFS_SYSCALL=y +# CONFIG_TADPOLE_TS102_UCTRL is not set +# CONFIG_TCP_CONG_ADVANCED is not set +CONFIG_TICK_CPU_ACCOUNTING=y +# CONFIG_TMPFS_XATTR is not set +CONFIG_TRACE_CLOCK=y +CONFIG_TREE_RCU=y +CONFIG_TREE_SRCU=y +CONFIG_UBOOT_ENTRY_ADDR=0xf0004000 +CONFIG_UBOOT_FLASH_ADDR=0x00080000 +CONFIG_UBOOT_LOAD_ADDR=0x40004000 +CONFIG_UEVENT_HELPER_PATH="" +CONFIG_USB_EHCI_BIG_ENDIAN_DESC=y +CONFIG_USB_EHCI_BIG_ENDIAN_MMIO=y +CONFIG_USB_UHCI_BIG_ENDIAN_DESC=y +CONFIG_USB_UHCI_BIG_ENDIAN_MMIO=y +CONFIG_USELIB=y +# CONFIG_VHOST_MENU is not set +# CONFIG_VIRTIO_MENU is not set +CONFIG_VITESSE_PHY=y +# CONFIG_VLAN_8021Q is not set +CONFIG_VM_EVENT_COUNTERS=y +CONFIG_VT=y +CONFIG_VT_CONSOLE=y +# CONFIG_VT_HW_CONSOLE_BINDING is not set +CONFIG_XPS=y +# CONFIG_XZ_DEC is not set +CONFIG_ZLIB_INFLATE=y diff --git a/target/linux/leon/image/Makefile b/target/linux/leon/image/Makefile new file mode 100644 index 0000000000..3351375426 --- /dev/null +++ b/target/linux/leon/image/Makefile @@ -0,0 +1,55 @@ +# +# Copyright (C) 2023 OpenWrt.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)/image.mk + +define Build/leon-image + rm -f $@.boot #$(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img + mkfs.fat $@.boot -C $(FAT32_BLOCKS) + + mcopy -i $@.boot $(STAGING_DIR_IMAGE)/$(DEVICE_NAME)-boot.scr ::boot.scr + mcopy -i $@.boot $(DTS_DIR)/$(DEVICE_DTS).dtb ::dtb + mcopy -i $@.boot $(IMAGE_KERNEL) ::Image + + ./gen_sifiveu_sdcard_img.sh \ + $@ \ + $@.boot \ + $(IMAGE_ROOTFS) \ + $(CONFIG_SIFIVEU_SD_BOOT_PARTSIZE) \ + $(CONFIG_TARGET_ROOTFS_PARTSIZE) \ + $(STAGING_DIR_IMAGE)/$(DEVICE_NAME)-u-boot.itb \ + $(STAGING_DIR_IMAGE)/$(DEVICE_NAME)-u-boot.itb-spl +endef + +define Device/Default + PROFILES := Default + KERNEL_NAME := Image + KERNEL := kernel-bin | libdeflate-gzip + IMAGES := sdcard.img.gz + IMAGE/sdcard.img.gz := riscv-sdcard | append-metadata | gzip +endef + +define Device/sifive_unleashed + DEVICE_VENDOR := SiFive + DEVICE_MODEL := Unleashed (FU540) + DEVICE_DTS := sifive/hifive-unleashed-a00 + UBOOT := sifive_unleashed +endef +TARGET_DEVICES += sifive_unleashed + + +define Image/Prepare + cp $(LINUX_DIR)/arch/sparc/boot/vmlinux $(KDIR)/vmlinux + $(STAGING_DIR_IMAGE)/mklinux/mklinuximg $(KDIR)/vmlinux $(STAGING_DIR_IMAGE)/image0.ram +endef + +define Image/BuildKernel + mkdir -p $(BIN_DIR) + cp $(KDIR)/image0.ram $(BIN_DIR)/$(IMG_PREFIX)-image0.ram +endef + +$(eval $(call BuildImage)) -- 2.30.2