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

arch: arm64: ARMv8-A support for NuttX #6478

Merged
merged 1 commit into from
Jul 14, 2022
Merged

Conversation

qinwei2004
Copy link
Contributor

Summary:

Arm64 support for NuttX, Features supported:

  1. Cotex-a53 single core and SMP support: it's can run into nsh shell at
    qemu virt machine.
  2. qemu-a53 board configuration support: it's only for evaluate propose
  3. FPU support for armv8-a: FPU context switching at NEON/floating-point
    TRAP is supported.
  4. psci interface, armv8 cache operation(data cache) and smccc support.

Please refer to boards/arm64/qemu/qemu-a53/README.txt for detail

Signed-off-by: qinwei1 [email protected]

Impact

No impact to the other platform

Testing

testing with ostest, smp.

@qinwei2004 qinwei2004 marked this pull request as draft June 19, 2022 04:11
@qinwei2004 qinwei2004 marked this pull request as ready for review June 19, 2022 04:12
@qinwei2004 qinwei2004 marked this pull request as draft June 19, 2022 04:14
@qinwei2004 qinwei2004 marked this pull request as ready for review June 19, 2022 04:15
@qinwei2004
Copy link
Contributor Author

@xiaoxiang781216 , please review

@xiaoxiang781216 xiaoxiang781216 linked an issue Jun 19, 2022 that may be closed by this pull request
Copy link
Contributor

@hartmannathan hartmannathan left a comment

Choose a reason for hiding this comment

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

Wow, this PR represents a tremendous amount of work and a huge potential improvement to NuttX! I will be very excited the day NuttX can run on SBCs such as the Raspberry Pi 4. I have given an initial cursory look over the 93 added files and I don't see any glaring obvious issues; currently I don't have the toolchain but I will try to at least do a test build with it soon. Hopefully we will get other reviews as well.

arch/arm64/include/arch.h Outdated Show resolved Hide resolved
arch/arm64/include/arch.h Outdated Show resolved Hide resolved
arch/arm64/include/arch.h Outdated Show resolved Hide resolved
arch/arm64/include/inttypes.h Outdated Show resolved Hide resolved
arch/arm64/include/inttypes.h Outdated Show resolved Hide resolved
boards/arm64/qemu/qemu-a53/src/qemu-a53.h Outdated Show resolved Hide resolved
boards/arm64/qemu/qemu-a53/scripts/dramboot.ld Outdated Show resolved Hide resolved
boards/arm64/qemu/qemu-a53/scripts/Make.defs Outdated Show resolved Hide resolved
boards/arm64/qemu/qemu-a53/include/board_memorymap.h Outdated Show resolved Hide resolved
boards/arm64/qemu/qemu-a53/include/board_memorymap.h Outdated Show resolved Hide resolved
arch/arm64/include/irq.h Outdated Show resolved Hide resolved
arch/arm64/include/syscall.h Outdated Show resolved Hide resolved
arch/arm64/include/syscall.h Outdated Show resolved Hide resolved
arch/arm64/src/common/arm64_arch_timer.h Outdated Show resolved Hide resolved
arch/arm64/src/common/arm64_arch_timer.h Outdated Show resolved Hide resolved
arch/arm64/src/common/arm64_fpu.c Outdated Show resolved Hide resolved
arch/arm64/src/common/arm64_fpu.h Outdated Show resolved Hide resolved
arch/arm64/src/common/arm64_fpu.h Outdated Show resolved Hide resolved
arch/arm64/src/common/arm64_gic.h Outdated Show resolved Hide resolved
arch/arm64/src/common/arm64_gic.h Outdated Show resolved Hide resolved
boards/arm64/qemu/qemu-a53/scripts/Make.defs Outdated Show resolved Hide resolved
boards/Kconfig Show resolved Hide resolved
arch/arm64/src/common/arm64_gic.h Outdated Show resolved Hide resolved
arch/Kconfig Show resolved Hide resolved
tools/ci/docker/linux/Dockerfile Outdated Show resolved Hide resolved
tools/ci/testlist/other.dat Show resolved Hide resolved
@xiaoxiang781216
Copy link
Contributor

@qinwei2004 please rebase your patch to the latest mainline and squash the temp change to the master one.

Copy link
Contributor

@hartmannathan hartmannathan left a comment

Choose a reason for hiding this comment

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

Accidentally merged some unrelated commits into this PR? Some changes in graphics, drivers, etc., which are good changes, seem unrelated to this PR. Suggest to separate these and submit in other PRs. Not necessary to wait for this PR to be merged, IMO. Thanks!

arch/arm64/src/common/arm64_cache.c Outdated Show resolved Hide resolved
arch/arm64/src/common/arm64_checkstack.c Outdated Show resolved Hide resolved
arch/arm64/src/common/arm64_cpuidlestack.c Outdated Show resolved Hide resolved
arch/arm64/src/common/arm64_fpu.c Outdated Show resolved Hide resolved
@qinwei2004 qinwei2004 force-pushed the arm64 branch 3 times, most recently from 44e2c0b to c7d9b43 Compare June 23, 2022 01:59
@qinwei2004
Copy link
Contributor Author

qinwei2004 commented Jun 23, 2022

Accidentally merged some unrelated commits into this PR? Some changes in graphics, drivers, etc., which are good changes, seem unrelated to this PR. Suggest to separate these and submit in other PRs. Not necessary to wait for this PR to be merged, IMO. Thanks!

----Sorry, error submit and fix already, please check again, thanks

@qinwei2004 qinwei2004 closed this Jun 23, 2022
@qinwei2004 qinwei2004 deleted the arm64 branch June 23, 2022 02:06
@qinwei2004 qinwei2004 restored the arm64 branch June 23, 2022 02:06
@qinwei2004 qinwei2004 reopened this Jun 23, 2022
@qinwei2004 qinwei2004 force-pushed the arm64 branch 2 times, most recently from aec6a6f to caad346 Compare June 23, 2022 12:47
@hartmannathan
Copy link
Contributor

Accidentally merged some unrelated commits into this PR? Some changes in graphics, drivers, etc., which are good changes, seem unrelated to this PR. Suggest to separate these and submit in other PRs. Not necessary to wait for this PR to be merged, IMO. Thanks!

----Sorry, error submit and fix already, please check again, thanks

Yes, this looks much better. Thanks!

@hartmannathan
Copy link
Contributor

In first commit log, s/Cotex-a53/Cortex-a53/

tools/ci/testlist/macos.dat Outdated Show resolved Hide resolved
arch/arm64/src/common/arm64_initialstate.c Outdated Show resolved Hide resolved
arch/arm64/src/common/arm64_syscall.c Outdated Show resolved Hide resolved
arch/arm64/src/common/arm64_head.S Outdated Show resolved Hide resolved
arch/arm64/src/common/arm64_head.S Outdated Show resolved Hide resolved
arch/arm64/src/qemu/qemu_lowputc.S Outdated Show resolved Hide resolved
@xiaoxiang781216
Copy link
Contributor

Yes, I agree. @qinwei2004 please squash your change, thanks.

@pkarashchenko
Copy link
Contributor

I think many comments have been addressed. I will not be able to do a review till Friday and I'm fine to address any leftovers with the next PR after this PR is merged. I will most probably post some comments to this PR after it is merged

@qinwei2004
Copy link
Contributor Author

I squashed all change into two commit, please check
@xiaoxiang781216, @hartmannathan @pkarashchenko

@xiaoxiang781216
Copy link
Contributor

let's merge the comment path into the master one too. it doesn't make sense to use two patch.

@qinwei2004
Copy link
Contributor Author

@qinwei2004 qinwei2004 closed this Jul 13, 2022
@qinwei2004 qinwei2004 reopened this Jul 13, 2022
@qinwei2004
Copy link
Contributor Author

the comments have merge, please check
@xiaoxiang781216

arch/arm64/include/irq.h Outdated Show resolved Hide resolved
arch/arm64/include/irq.h Outdated Show resolved Hide resolved
arch/arm64/include/irq.h Outdated Show resolved Hide resolved
arch/arm64/include/irq.h Outdated Show resolved Hide resolved
#define CONFIG_GICR_BASE 0x80a0000

#define CONFIG_RAMBANK1_ADDR 0x40000000
#define CONFIG_RAMBANK1_SIZE MB(128)
Copy link
Contributor

Choose a reason for hiding this comment

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

above at line 32 of this file

arch/arm64/src/common/arm64_releasestack.c Outdated Show resolved Hide resolved
arch/arm64/src/common/arm64_schedulesigaction.c Outdated Show resolved Hide resolved
arch/arm64/src/common/arm64_usestack.c Outdated Show resolved Hide resolved
arch/arm64/src/qemu/Kconfig Outdated Show resolved Hide resolved
arch/arm64/src/qemu/Kconfig Outdated Show resolved Hide resolved
@qinwei2004
Copy link
Contributor Author

@xiaoxiang781216 @pkarashchenko @hartmannathan
please check again

Copy link
Contributor

@pkarashchenko pkarashchenko left a comment

Choose a reason for hiding this comment

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

Few minor comments, then please squash and let's move forward to merging

arch/arm64/include/irq.h Outdated Show resolved Hide resolved
arch/arm64/include/irq.h Outdated Show resolved Hide resolved
arch/arm64/include/irq.h Outdated Show resolved Hide resolved
arch/arm64/src/common/arm64_arch.h Outdated Show resolved Hide resolved
arch/arm64/src/common/arm64_arch.h Outdated Show resolved Hide resolved
arch/arm64/src/common/arm64_fatal.c Outdated Show resolved Hide resolved
arch/arm64/src/common/arm64_fatal.h Outdated Show resolved Hide resolved
arch/arm64/src/common/arm64_mmu.c Outdated Show resolved Hide resolved
@qinwei2004
Copy link
Contributor Author

@pkarashchenko , please check again
thanks for you careful check

@pkarashchenko
Copy link
Contributor

Please squash into a single commit

N/A

Summary:

Arm64 support for NuttX, Features supported:

1. Cortex-a53 single core and SMP support: it's can run into nsh shell at
   qemu virt machine.

2. qemu-a53 board configuration support: it's only for evaluate propose

3. FPU support for armv8-a: FPU context switching at NEON/floating-point
  TRAP is supported.

4. psci interface, armv8 cache operation(data cache) and smccc support.

5. fix mass code style issue, thank for @xiaoxiang781216, @hartmannathan @pkarashchenko

Please refer to boards/arm64/qemu/qemu-a53/README.txt for detail

Note:
1. GCC MACOS issue
The GCC 11.2 toolchain for MACOS may get crash while compiling
float operation function, the following link describe the issue
and give analyse at the issue:

https://bugs.linaro.org/show_bug.cgi?id=5825

it's seem GCC give a wrong instruction at certain machine which
without architecture features

the new toolchain is not available still, so just disable the MACOS
cibuild check at present

Signed-off-by: qinwei1 <[email protected]>
@qinwei2004
Copy link
Contributor Author

Please squash into a single commit

Done

Copy link
Contributor

@hartmannathan hartmannathan left a comment

Choose a reason for hiding this comment

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

Beautiful! LGTM

@hartmannathan hartmannathan merged commit e77b067 into apache:master Jul 14, 2022
@hartmannathan
Copy link
Contributor

I would like to say Congratulations on this HUGE PR!

In the Single Core case, ostest is running successfully for me.

In the SMP case, it seems that ostest fails or hangs in different places, but my system is ancient and I am running QEMU 3.1.0 (!!!), so it is possible that I am seeing old bugs in QEMU. I would need to upgrade my system and try the latest QEMU before I could draw any conclusions.

Anyway, this PR is a very good starting point for NuttX on Arm64 and I look forward to seeing NuttX on real Arm64 hardware!

@qinwei2004
Copy link
Contributor Author

I would like to say Congratulations on this HUGE PR!

In the Single Core case, ostest is running successfully for me.

In the SMP case, it seems that ostest fails or hangs in different places, but my system is ancient and I am running QEMU 3.1.0 (!!!), so it is possible that I am seeing old bugs in QEMU. I would need to upgrade my system and try the latest QEMU before I could draw any conclusions.

Anyway, this PR is a very good starting point for NuttX on Arm64 and I look forward to seeing NuttX on real Arm64 hardware!

Yes, for SMP,the PR in qemu seem behave very different!!
In the beginning, I debug the PR with Ubuntu which is running in VMware. For Single Core, everything is OK, but for SMP, ostest hangs in different places just like your description. After fix some cache sync issue, the crash is occurred at signal testing every time, I check the crash with GDB and see a very strange phenomenon that data is different between CPU register and seeing with GDB, so it seem a data sync issue. I try different cache sync operation at this crash point but not work at all

things change when I debug the PR with a real Ubuntu PC, the crash not occurs anymore in that environment. I cannot explain why I see the phenomenon, but I cannot say it's certain a bug in qemu. because maybe with different speed it have different execution order between these two environment.

My real Ubuntu environment
Ubuntu 18.04.6 LTS
QEMU emulator version 4.0.1 (v4.0.1)
Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
memory: 16GB

I have a IMX8 porting patch but some change need to be done, I will testing it and submit ASAP

@lupyuen
Copy link
Member

lupyuen commented Aug 24, 2022

Hi @qinwei2004 thank you so much for implementing Arm64 support! I have written an article that's based on your work, I hope to run it on PinePhone soon :-)

"Apache NuttX RTOS on Arm Cortex-A53: How it might run on PinePhone"

@jerpelea jerpelea added this to To-Add in Release Notes - 11.0.0 Aug 30, 2022
@jerpelea jerpelea moved this from To-Add to Added in Release Notes - 11.0.0 Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

ARMv8-A/R support in NuttX
6 participants