Skip to content

Commit

Permalink
arch/arm64: Add support for FriendlyElec NanoPi M4
Browse files Browse the repository at this point in the history
  • Loading branch information
JianyuWang0623 authored and xiaoxiang781216 committed Sep 17, 2023
1 parent f2f9e6a commit 59e5037
Show file tree
Hide file tree
Showing 14 changed files with 615 additions and 0 deletions.
11 changes: 11 additions & 0 deletions boards/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1977,6 +1977,16 @@ config ARCH_BOARD_PINEPHONE_PRO
---help---
This options selects support for NuttX on PINE64 PinePhone based
on Rockchip RK3399 SoC with ARM Cortex-A53

config ARCH_BOARD_NANOPI_M4
bool "FriendlyElec NanoPi M4"
depends on ARCH_CHIP_RK3399
select ARCH_HAVE_LEDS
select ARCH_HAVE_IRQBUTTONS
---help---
This options selects support for NuttX on FriendlyElec NanoPi M4
based on Rockchip RK3399 SoC with ARM Cortex-A53

config ARCH_BOARD_FVP_ARMV8R
bool "FVP ARM-v8r CPUs board"
depends on ARCH_CHIP_FVP_ARMV8R
Expand Down Expand Up @@ -3146,6 +3156,7 @@ config ARCH_BOARD
default "qemu-armv8a" if ARCH_BOARD_QEMU_ARMV8A
default "pinephone" if ARCH_BOARD_PINEPHONE
default "pinephonepro" if ARCH_BOARD_PINEPHONE_PRO
default "nanopi_m4" if ARCH_BOARD_NANOPI_M4
default "fvp-armv8r" if ARCH_BOARD_FVP_ARMV8R
default "fvp-armv8r-aarch32" if ARCH_BOARD_FVP_ARMV8R_AARCH32
default "imx8qm-mek" if ARCH_BOARD_IMX8QM_MEK
Expand Down
3 changes: 3 additions & 0 deletions boards/arm64/rk3399/nanopi_m4/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
etctmp.c
src/etctmp
tags
7 changes: 7 additions & 0 deletions boards/arm64/rk3399/nanopi_m4/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

if ARCH_BOARD_NANOPI_M4
endif # ARCH_BOARD_NANOPI_M4
68 changes: 68 additions & 0 deletions boards/arm64/rk3399/nanopi_m4/configs/nsh/defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#
# This file is autogenerated: PLEASE DO NOT EDIT IT.
#
# You can use "make menuconfig" to make any modifications to the installed .config file.
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
# modifications.
#
CONFIG_ARCH="arm64"
CONFIG_ARCH_ARM64=y
CONFIG_ARCH_BOARD="nanopi_m4"
CONFIG_ARCH_BOARD_NANOPI_M4=y
CONFIG_ARCH_CHIP="rk3399"
CONFIG_ARCH_CHIP_RK3399=y
CONFIG_ARCH_EARLY_PRINT=y
CONFIG_ARCH_INTERRUPTSTACK=4096
CONFIG_BOARD_LOOPSPERMSEC=116524
CONFIG_BUILTIN=y
CONFIG_DEBUG_ASSERTIONS=y
CONFIG_DEBUG_FEATURES=y
CONFIG_DEBUG_FULLOPT=y
CONFIG_DEBUG_IRQ=y
CONFIG_DEBUG_IRQ_INFO=y
CONFIG_DEBUG_SCHED=y
CONFIG_DEBUG_SCHED_ERROR=y
CONFIG_DEBUG_SCHED_WARN=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEFAULT_TASK_STACKSIZE=8192
CONFIG_DEV_ZERO=y
CONFIG_EXAMPLES_HELLO=y
CONFIG_EXAMPLES_LEDS=y
CONFIG_EXPERIMENTAL=y
CONFIG_FRAME_POINTER=y
CONFIG_FS_PROCFS=y
CONFIG_FS_ROMFS=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_IDLETHREAD_STACKSIZE=8192
CONFIG_INIT_ENTRYPOINT="nsh_main"
CONFIG_NSH_ARCHINIT=y
CONFIG_NSH_ARCHROMFS=y
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_READLINE=y
CONFIG_NSH_ROMFSETC=y
CONFIG_PREALLOC_TIMERS=4
CONFIG_PTHREAD_STACK_MIN=8192
CONFIG_RAMLOG=y
CONFIG_RAM_SIZE=268435456
CONFIG_RAM_START=0x02080000
CONFIG_RAW_BINARY=y
CONFIG_READLINE_CMD_HISTORY=y
CONFIG_RR_INTERVAL=200
CONFIG_SCHED_BACKTRACE=y
CONFIG_SCHED_HPWORK=y
CONFIG_SCHED_HPWORKPRIORITY=192
CONFIG_SPINLOCK=y
CONFIG_STACK_COLORATION=y
CONFIG_START_MONTH=11
CONFIG_START_YEAR=2022
CONFIG_SYMTAB_ORDEREDBYNAME=y
CONFIG_SYSTEM_NSH=y
CONFIG_SYSTEM_SYSTEM=y
CONFIG_SYSTEM_TIME64=y
CONFIG_TESTING_GETPRIME=y
CONFIG_TESTING_OSTEST=y
CONFIG_UART2_BAUD=1500000
CONFIG_USEC_PER_TICK=1000
CONFIG_USERLED=y
34 changes: 34 additions & 0 deletions boards/arm64/rk3399/nanopi_m4/include/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/****************************************************************************
* boards/arm64/rk3399/nanopi_m4/include/board.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/

#ifndef __BOARDS_ARM64_RK3399_NANOPI_M4_INCLUDE_BOARD_H
#define __BOARDS_ARM64_RK3399_NANOPI_M4_INCLUDE_BOARD_H

/****************************************************************************
* Included Files
****************************************************************************/

#include <nuttx/config.h>

/****************************************************************************
* Pre-processor Definitions
****************************************************************************/

#endif /* __BOARDS_ARM64_RK3399_NANOPI_M4_INCLUDE_BOARD_H */
22 changes: 22 additions & 0 deletions boards/arm64/rk3399/nanopi_m4/include/nsh_romfsimg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/***************************************************************************
* boards/arm64/rk3399/nanopi_m4/include/nsh_romfsimg.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
***************************************************************************/

extern const unsigned char romfs_img[];
extern unsigned int romfs_img_len;
48 changes: 48 additions & 0 deletions boards/arm64/rk3399/nanopi_m4/scripts/Make.defs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
############################################################################
# boards/arm64/rk3399/nanopi_m4/scripts/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################

include $(TOPDIR)/.config
include $(TOPDIR)/tools/Config.mk
include $(TOPDIR)/arch/arm64/src/Toolchain.defs

LDSCRIPT = dramboot.ld

ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)

CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
AFLAGS := $(CFLAGS) -D__ASSEMBLY__

# NXFLAT module definitions

NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)$(DELIM)binfmt$(DELIM)libnxflat$(DELIM)gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048

# ELF module definitions

CELFFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
CXXELFFLAGS = $(CXXFLAGS) -mlong-calls # --target1-abs

LDELFFLAGS = -r -e main
LDELFFLAGS += -T $(call CONVERT_PATH,$(TOPDIR)/binfmt/libelf/gnu-elf.ld)
138 changes: 138 additions & 0 deletions boards/arm64/rk3399/nanopi_m4/scripts/dramboot.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
/****************************************************************************
* boards/arm64/rk3399/nanopi_m4/scripts/dramboot.ld
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/

OUTPUT_ARCH(aarch64)

ENTRY(__start)

PHDRS
{
text PT_LOAD ;
}

SECTIONS
{
/* Ref to https://github.com/apache/nuttx/pull/10193
*
* This comes from (https://github.com/u-boot/u-boot/blob/v2022.04/
* include/configs/rk3399_common.h)
* with patch from (https://github.com/armbian/build/tree/main/
* patch/u-boot/u-boot-rockchip64-v2022.04)
*
* Using U-Boot(U-Boot 2020.10-armbian (Jan 05 2021 - 01:05:57 +0100))
* from Armbian(https://www.armbian.com/), and replace `Image` with nuttx.bin
*/
. = 0x02080000; /* U-Boot loads NuttX at this address (kernel_addr_r) */
_start = .;
.text : {
_stext = .; /* Text section */
*(.text)
*(.text.cold)
*(.text.unlikely)
*(.fixup)
*(.gnu.warning)
} :text = 0x9090

. = ALIGN(4096);

.init_section : {
_sinit = ABSOLUTE(.);
KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
KEEP(*(.init_array .ctors))
_einit = ABSOLUTE(.);
}

. = ALIGN(4096);

.vector : {
_vector_start = .;
KEEP(*(.exc_vector_table))
KEEP(*(".exc_vector_table.*"))
KEEP(*(.vectors))
_vector_end = .;
} :text
. = ALIGN(4096);
_etext = .; /* End_1 of .text */
_sztext = _etext - _stext;

. = ALIGN(4096);
.rodata : {
_srodata = .; /* Read-only data */
*(.rodata)
*(.rodata.*)
*(.data.rel.ro)
*(.data.rel.ro.*)
} :text
. = ALIGN(4096);
_erodata = .; /* End of read-only data */
_szrodata = _erodata - _srodata;
_eronly = .; /* End of read-only data */

. = ALIGN(4096);
.data : { /* Data */
_sdata = .;
*(.data.page_aligned)
*(.data)
. = ALIGN(8);
*(.data.rel)
*(.data.rel.*)
CONSTRUCTORS
} :text
_edata = .; /* End+1 of .data */

.bss : { /* BSS */
. = ALIGN(8);
_sbss = .;
*(.bss)
. = ALIGN(8);
} :text
. = ALIGN(4096);
_ebss = .;
_szbss = _ebss - _sbss;

.initstack : { /* INIT STACK */
_s_initstack = .;
*(.initstack)
. = ALIGN(16);
} :text
. = ALIGN(4096);
_e_initstack = . ;
g_idle_topstack = . ;

_szdata = _e_initstack - _sdata;

/* Sections to be discarded */
/DISCARD/ : {
*(.exit.text)
*(.exit.data)
*(.exitcall.exit)
*(.eh_frame)
}

/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
}

32 changes: 32 additions & 0 deletions boards/arm64/rk3399/nanopi_m4/src/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
############################################################################
# boards/arm64/rk3399/nanopi_m4/src/Makefile
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################

include $(TOPDIR)/Make.defs

CSRCS = nanopi_m4_boardinit.c
CSRCS += nanopi_m4_appinit.c

ifeq ($(CONFIG_NSH_ROMFSETC),y)
ifneq ($(CONFIG_NSH_CUSTOMROMFS),y)
RCSRCS = etc/init.d/rc.sysinit etc/init.d/rcS
endif
endif

include $(TOPDIR)/boards/Board.mk
Loading

0 comments on commit 59e5037

Please sign in to comment.