diff --git a/etc/release-confs/make.conf b/etc/release-confs/make.conf new file mode 100644 --- /dev/null +++ b/etc/release-confs/make.conf @@ -0,0 +1,2 @@ +WITHOUT_DEBUG=YES +MK_PROFILE=no diff --git a/etc/release-confs/src.conf b/etc/release-confs/src.conf new file mode 100644 --- /dev/null +++ b/etc/release-confs/src.conf @@ -0,0 +1,6 @@ +WITHOUT_DEBUG_FILES=1 +WITHOUT_KERNEL_SYMBOLS=yes +WITHOUT_TESTS=yes +WITHOUT_PROFILE=yes +WITHOUT_LLVM_ASSERTIONS=yes +WITH_MALLOC_PRODUCTION=yes diff --git a/rk3328.sh b/rk3328.sh new file mode 100755 --- /dev/null +++ b/rk3328.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Here we build our own config for RK3328 SoC, skipping most of the generic stuff. +# Run `sudo ./rk3328.sh` during active development, or `sudo ./rk3328.sh NOCLEAN=NO` to build from scratch. +# +EXTRA=$1 +if [ "$EXTRA" == "clean" ]; then + EXTRA="" +else + EXTRA="NOCLEAN=YES" +fi + +KERNEL_BIN=/usr/obj/usr/home/marcusmae/glazomer/freebsd/src/arm64.aarch64/sys/RK3328/kernel.bin + +make buildkernel TARGET_ARCH=aarch64 KERNCONF=RK3328 $EXTRA && \ +gzip -f -9 $KERNEL_BIN && \ +sudo -i -u marcusmae scp $KERNEL_BIN.gz m17:/home/marcusmae/forge/docker-tftpd/tftpboot/ + diff --git a/sys/arm64/arm64/nexus.c b/sys/arm64/arm64/nexus.c --- a/sys/arm64/arm64/nexus.c +++ b/sys/arm64/arm64/nexus.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #include diff --git a/sys/arm64/conf/RK3328 b/sys/arm64/conf/RK3328 new file mode 100644 --- /dev/null +++ b/sys/arm64/conf/RK3328 @@ -0,0 +1,27 @@ +# +# ROCKCHIP -- Rockchip kernel configuration file for FreeBSD/arm64 +# +# For more information on this file, please read the config(5) manual page, +# and/or the handbook section on Kernel Configuration Files: +# +# https://docs.freebsd.org/en/books/handbook/kernelconfig/#kernelconfig-config +# +# The handbook is also available locally in /usr/share/doc/handbook +# if you've installed the doc distribution, otherwise always see the +# FreeBSD World Wide Web server (https://www.FreeBSD.org/) for the +# latest information. +# +# An exhaustive list of options and more detailed explanations of the +# device lines is also present in the ../../conf/NOTES and NOTES files. +# If you are in doubt as to the purpose or necessity of a line, check first +# in NOTES. +# + +#NO_UNIVERSE + +cpu ARM64 +ident ROCKCHIP + +include "std.arm64" +include "std.dev" +include "std.rk3328" diff --git a/sys/arm64/conf/std.rk3328 b/sys/arm64/conf/std.rk3328 new file mode 100644 --- /dev/null +++ b/sys/arm64/conf/std.rk3328 @@ -0,0 +1,61 @@ +# +# Rockchip SoC support +# + +# SoC support +options SOC_ROCKCHIP_RK3328 +#options SOC_ROCKCHIP_RK3399 +#options SOC_ROCKCHIP_RK3568 + +# GPIO / PINCTRL +device dwgpio # Synopsys DesignWare APB GPIO Controller +device rk_gpio # RockChip GPIO Controller +device rk_pinctrl # RockChip Pinmux Controller + +# Combo PHY support +device rk_combphy # Naneng Combo PHY + +# I2C +device rk_i2c # RockChip I2C controller +device fan53555 # Fairchild Semi FAN53555/SYR82x Regulator + +# Power management controllers +device rk805 # RockChip RK805 PMIC +#device rk817 # RockChip RK817 PMIC +#device syr827 # Silergy SYR827 PMIC +#device tcs4525 # TCS 4525 PMIC + +# SPI +device rk_spi # RockChip SPI controller + +# PWM +device rk_pwm + +# Serial (COM) ports +device uart_snps + +# Ethernet NICs +device dwc_rk # Rockchip Designware +#device eqos # Synopsys Designware Ethernet QoS controller + +# IO Domains +device rk_iodomain + +# USB support +device rk_usb2phy # Rockchip USB2PHY +device rk_typec_phy # Rockchip TypeC PHY +device dwc3 # Synopsys DWC controller +device rk_dwc3 # Rockchip DWC3 controller + +# MMC/SD/SDIO Card slot support +#device sdhci +#device dwmmc +#device rk_dwmmc +#device rk_emmcphy + +options FDT +device md_root_mem +options MD_ROOT_MEM # Enable use of initrd as MD root + +# DTBs +makeoptions MODULES_EXTRA+="dtb/rockchip" diff --git a/sys/arm64/ofw/ofw_initrd.c b/sys/arm64/ofw/ofw_initrd.c new file mode 100644 --- /dev/null +++ b/sys/arm64/ofw/ofw_initrd.c @@ -0,0 +1,98 @@ +/*- + * Copyright (C) 2018 Breno Leitao + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include "opt_md.h" + +extern u_char *mfs_root; +extern int mfs_root_size; + +static void ofw_initrd_probe_and_attach(void *junk); + +SYSINIT(ofw_initrd_probe_and_attach, SI_SUB_KMEM, SI_ORDER_ANY, + ofw_initrd_probe_and_attach, NULL); + +static void +ofw_initrd_probe_and_attach(void *junk) +{ + phandle_t chosen; + vm_paddr_t start, end; + pcell_t cell[2]; + ssize_t size; + u_char *taste; + + chosen = OF_finddevice("/chosen"); + if (chosen <= 0) + return; + + if (!OF_hasprop(chosen, "linux,initrd-start") || + !OF_hasprop(chosen, "linux,initrd-end")) + return; + + size = OF_getencprop(chosen, "linux,initrd-start", cell, sizeof(cell)); + if (size == 4) + start = cell[0]; + else if (size == 8) + start = (uint64_t)cell[0] << 32 | cell[1]; + else { + printf("ofw_initrd: Wrong linux,initrd-start size\n"); + return; + } + + size = OF_getencprop(chosen, "linux,initrd-end", cell, sizeof(cell)); + if (size == 4) + end = cell[0]; + else if (size == 8) + end = (uint64_t)cell[0] << 32 | cell[1]; + else{ + printf("ofw_initrd: Wrong linux,initrd-end size\n"); + return; + } + + if (end - start > 0) { + taste = (u_char *) PHYS_TO_DMAP(start); + mfs_root = taste; + mfs_root_size = end - start; + printf("ofw_initrd: initrd loaded at 0x%08lx-0x%08lx\n", + start, end); + } +} diff --git a/sys/conf/files.arm64 b/sys/conf/files.arm64 --- a/sys/conf/files.arm64 +++ b/sys/conf/files.arm64 @@ -338,6 +338,7 @@ dev/ofw/ofw_cpu.c optional fdt dev/ofw/ofw_pci.c optional fdt pci dev/ofw/ofw_pcib.c optional fdt pci +arm64/ofw/ofw_initrd.c optional fdt md_root_mem dev/pci/controller/pci_n1sdp.c optional pci_n1sdp acpi dev/pci/pci_host_generic.c optional pci