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

Imx9 downstream #227

Merged
merged 4 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 145 additions & 0 deletions Documentation/platforms/arm64/imx9/boards/imx93-evk/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
README.txt
==========

The kit i.MX93 Evaluation Kit has a pre-installed Linux image which contains
u-boot and the i.MX93 reference Linux installation.

u-boot is required to boot NuttX (for now) as it initializes the hardware for
us, i.e. DDR, clocks, I/O muxes etc.

==========================================

How to run nuttx on i.MX93 Evaluation Kit.

==========================================

Below is a set of instructions on how to run NuttX on the i.MX93 EVK

==========================================

Pre-requisites

==========================================

- imx93_ca55.JLinkScript which is a custom file, put it wherever you want

==========================================

U-Boot configuration

==========================================

Two things need to be configured on u-boot before NuttX can be loaded:

- u-boot data cache must be turned off
- u-boot must stop to the u-boot console, i.e. the Linux payload must not be loaded

Manual option:

1. Disable u-boot autostart (needs to be done only once):

Hit any key to stop autoboot: 0
u-boot=> setenv bootdelay -1
u-boot=> saveenv
Saving Environment to MMC... Writing to MMC(0)... OK
u-boot=> reset

2. On every boot, the data cache must be disabled for options 2 and 3 to work

u-boot=> dcache off

Automated option:

1. Replace the default bootcmd to disable dcache automatically:

u-boot=> setenv bootcmd dcache off
u-boot=> saveenv
Saving Environment to MMC... Writing to MMC(0)... OK
u-boot=> reset

To restore the default bootcmd which starts Linux automatically:

u-boot=> setenv bootcmd run distro_bootcmd;run bsp_bootcmd
u-boot=> saveenv
Saving Environment to MMC... Writing to MMC(0)... OK
u-boot=> reset

The default bootcmd is:

u-boot=> env print bootcmd
bootcmd=run distro_bootcmd;run bsp_bootcmd

==========================================

Loading and running the NuttX image

==========================================

You have three options:

1 - Load via u-boot from SD-card
2 - Load via gdb
3 - Load via JLink

==========================================

Option 1: load via u-boot from SD-card:

==========================================

1. Build nuttx, and move nuttx.bin to SD-card

2. Load from SD-card and start nuttx payload

u-boot=> dcache off; fatload mmc 1 0x80000000 nuttx.bin; go 0x80000000

==========================================

Option 2: start via gdb:

==========================================

1. Start JLinkGDBServer

JLinkGDBServer -device CORTEX-A55 -JLinkScriptFile <path_to>/imx93_ca55.JLinkScript

2. Start gdb

$ aarch64-none-elf-gdb

2.1 Attach and load nuttx

(gdb) target remote localhost:2331
(gdb) set mem inaccessible-by-default off
(gdb) load <path_to>/nuttx
(gdb) monitor go

==========================================

Option 3: load with JLink:

==========================================

1. Start JLink

$ JLinkExe -device CORTEX-A55 -if JTAG -jtagconf -1,-1 -speed 4000 -JLinkScriptFile <path_to>/imx93_ca55.JLinkScript

1.1 Add -AutoConnect 1 to connect automatically

$ JLinkExe -device CORTEX-A55 -if JTAG -jtagconf -1,-1 -speed 4000 -JLinkScriptFile <path_to>/imx93_ca55.JLinkScript -AutoConnect 1

2. Connect JLink

2.1 Connect to the debugger

Type "connect" to establish a target connection, '?' for help
J-Link>connect

You should now have a JLink prompt.

Cortex-A55 identified.
J-Link>

3. Load nuttx. Note that JLink expects the .elf extension, the default build output of nuttx is just "nuttx" without the extension, so it must be added to the file...

J-Link>LoadFile <path_to>/nuttx.elf
6 changes: 6 additions & 0 deletions Documentation/platforms/arm64/imx9/boards/imx93-evk/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
==========
imx93-evk
==========

.. include:: README.txt
:literal:
12 changes: 12 additions & 0 deletions Documentation/platforms/arm64/imx9/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
=========
NXP i.MX9
=========

Supported Boards
================

.. toctree::
:glob:
:maxdepth: 1

boards/*/*
25 changes: 25 additions & 0 deletions arch/arm64/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ config ARCH_CHIP_IMX8
---help---
NXP i.MX8 (ARMv8a) applications processors

config ARCH_CHIP_IMX9
bool "NXP i.MX9 Platform (ARMv8.2a)"
select ARCH_HAVE_ADDRENV
select ARCH_HAVE_IRQTRIGGER
select ARCH_NEED_ADDRENV_MAPPING
---help---
NXP i.MX9 (ARMv8.2a) applications processors

config ARCH_CHIP_ARM64_CUSTOM
bool "Custom ARM64 chip"
select ARCH_CHIP_CUSTOM
Expand Down Expand Up @@ -181,6 +189,18 @@ config ARCH_CORTEX_A53
select ARCH_HAVE_TESTSET
select ARM_HAVE_NEON

config ARCH_CORTEX_A55
bool
default n
select ARCH_ARMV8A
select ARCH_HAVE_TRUSTZONE
select ARCH_DCACHE
select ARCH_ICACHE
select ARCH_HAVE_MMU
select ARCH_HAVE_FPU
select ARCH_HAVE_TESTSET
select ARM_HAVE_NEON

config ARCH_CORTEX_A57
bool
default n
Expand Down Expand Up @@ -229,6 +249,7 @@ config ARCH_CHIP
default "goldfish" if ARCH_CHIP_GOLDFISH
default "fvp-v8r" if ARCH_CHIP_FVP_ARMV8R
default "imx8" if ARCH_CHIP_IMX8
default "imx9" if ARCH_CHIP_IMX9

config ARM_HAVE_NEON
bool
Expand Down Expand Up @@ -311,6 +332,10 @@ if ARCH_CHIP_IMX8
source "arch/arm64/src/imx8/Kconfig"
endif

if ARCH_CHIP_IMX9
source "arch/arm64/src/imx9/Kconfig"
endif

if ARCH_CHIP_GOLDFISH
source "arch/arm64/src/goldfish/Kconfig"
endif
Expand Down
77 changes: 77 additions & 0 deletions arch/arm64/include/imx9/chip.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/****************************************************************************
* arch/arm64/include/imx9/chip.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 __ARCH_ARM64_INCLUDE_IMX9_CHIP_H
#define __ARCH_ARM64_INCLUDE_IMX9_CHIP_H

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

#include <nuttx/config.h>

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

/* Number of bytes in x kibibytes/mebibytes/gibibytes */

#define KB(x) ((x) << 10)
#define MB(x) (KB(x) << 10)
#define GB(x) (MB(UINT64_C(x)) << 10)

#if defined(CONFIG_ARCH_CHIP_IMX93)

#if CONFIG_ARM_GIC_VERSION == 3 || CONFIG_ARM_GIC_VERSION == 4

#define CONFIG_GICD_BASE 0x48000000
#define CONFIG_GICR_BASE 0x48040000
#define CONFIG_GICR_OFFSET 0x20000

#else

#error CONFIG_ARM_GIC_VERSION should be 2, 3 or 4

#endif /* CONFIG_ARM_GIC_VERSION */

#define CONFIG_RAMBANK1_ADDR 0x80000000
#define CONFIG_RAMBANK1_SIZE MB(128)

#define CONFIG_DEVICEIO_BASEADDR 0x40000000
#define CONFIG_DEVICEIO_SIZE MB(512)

#define MPID_TO_CLUSTER_ID(mpid) ((mpid) & ~0xff)

#endif

/****************************************************************************
* Assembly Macros
****************************************************************************/

#ifdef __ASSEMBLY__

.macro get_cpu_id xreg0
mrs \xreg0, mpidr_el1
ubfx \xreg0, \xreg0, #0, #8
.endm

#endif /* __ASSEMBLY__ */

#endif /* __ARCH_ARM64_INCLUDE_IMX9_CHIP_H */
Loading
Loading