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

[HELP] How to print MMU related information on ARM FVP? #13062

Closed
1 task done
lzc1001 opened this issue Aug 20, 2024 · 16 comments
Closed
1 task done

[HELP] How to print MMU related information on ARM FVP? #13062

lzc1001 opened this issue Aug 20, 2024 · 16 comments
Labels
Community: Question Further information is requested

Comments

@lzc1001
Copy link

lzc1001 commented Aug 20, 2024

Description

I want to print virtual address and physical address when initialize MMU in arm64_mmu.c. So, I set CONFIG_MMU_DEBUG = 1 and set other configuration as following picture.
image
But the related mmu configuration information do not print.
Thanks for everyone!

Verification

  • I have verified before submitting the report.
@lzc1001 lzc1001 added the Community: Question Further information is requested label Aug 20, 2024
@acassis
Copy link
Contributor

acassis commented Aug 20, 2024

@lzc1001 look inside arch/arm64/src/common/arm64_mmu.c the virtual and physical addresses are no printed by default, you need to add a new "sinfo()" with that values you want to print

@lzc1001
Copy link
Author

lzc1001 commented Aug 21, 2024

@acassis Thanks for your answer!😀 So, I need to write a new "sinfo()" by myself? Because I found that this function was already written in the code, but it was wrapped in the macro.
image

@acassis
Copy link
Contributor

acassis commented Aug 21, 2024

@lzc1001 hmm, I think I discovered the issue: there is not CONFIG_MMU_DEBUG.
Just run: $ git grep MMU_DEBUG

There need to exist an MMU_DEBUG symbol defined inside a Kconfig or you can just comment out these lines:

/* MMU debug option
 * #define CONFIG_MMU_ASSERT 1
 * #define CONFIG_MMU_DEBUG 1
 * #define CONFIG_MMU_DUMP_PTE 1
 */

@acassis
Copy link
Contributor

acassis commented Aug 22, 2024

@lzc1001 if you get it working, please close this Issue

@lzc1001
Copy link
Author

lzc1001 commented Aug 22, 2024

@acassis i add "#define CONFIG_MMU_DEBUG 1" to arch/arm64/src/common/arm64_mmu.c, then run on FVP. But the related mmu information still do not print.😫

@acassis
Copy link
Contributor

acassis commented Aug 22, 2024

@lupyuen any idea?

@lupyuen
Copy link
Member

lupyuen commented Aug 23, 2024

Hi @lzc1001 you mentioned FVP, could you verify that this is the Build Config that we used?

$ tools/configure.sh fvp-armv8r:nsh

fvp-armv8r:nsh doesn't seem to support MMU. Maybe that's why the MMU Logging wasn't working?

$ grep MMU .config
# CONFIG_ARCH_HAVE_MMU is not set

I tried qemu-armv8a:nsh, but it doesn't support MMU either:

$ ./tools/configure.sh qemu-armv8a:nsh
$ grep MMU .config
CONFIG_ARCH_HAVE_MMU=y
# CONFIG_ARCH_USE_MMU is not set

Update: Sorry I forgot to enable Scheduler Info Logging for QEMU, now I can see the MMU Log for QEMU.

Here's how I enabled logging MMU Logging in arch/arm64/src/common/arm64_mmu.c:

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

// Uncommented the MMU debug options
#define CONFIG_MMU_ASSERT 1
#define CONFIG_MMU_DEBUG 1
#define CONFIG_MMU_DUMP_PTE 1

// CONFIG_MMU_ASSERT needs this
#define trace_printf sinfo

// Existing code below...
#ifdef CONFIG_MMU_DEBUG

And here's the MMU Log for QEMU:

$ ./tools/configure.sh -l qemu-armv8a:nsh
$ make menuconfig
## TODO: Enable Scheduler Info Logging
$ make
$ qemu-system-aarch64 -cpu cortex-a53 -nographic \
     -machine virt,virtualization=on,gic-version=3 \
     -net none -chardev stdio,id=con,mux=on -serial chardev:con \
     -mon chardev=con,mode=readline -kernel ./nuttx

arm64_mmu_init: xlat tables:
arm64_mmu_init: base table(L1): 0x403c5000, 64 entries
arm64_mmu_init: 0: 0x403be000
arm64_mmu_init: 1: 0x403bf000
arm64_mmu_init: 2: 0x403c0000
arm64_mmu_init: 3: 0x403c1000
arm64_mmu_init: 4: 0x403c2000
arm64_mmu_init: 5: 0x403c3000
arm64_mmu_init: 6: 0x403c4000
init_xlat_tables: mmap: virt 117440512x phys 117440512x size 536870912x

Could you verify that MMU is enabled for NuttX on FVP? Thanks.

@lzc1001
Copy link
Author

lzc1001 commented Aug 23, 2024

@lupyuen Thanks for your answer! I ported NuttX to A53 based on FVP in the last few days and ARM A53 have MMU. Then, NuttX can boot and input command to terminal, like "ls", "hello", etc. So, I think MMU is enabled for NuttX on FVP. But I do't make sure that the porting code have some potential bug, hhh😀.
According to your answer, I add code to arch/arm64/src/common/arm64_mmu.c and enable the related congfiguration by menuconfig. But the MMU infnormation still do not print. Maybe porting code have other issues. I will check my added code. The NuttX commit ID is 7a865b2, tag: nuttx-12.6.0-RC1
Thank you very much again!
image
image

@lupyuen
Copy link
Member

lupyuen commented Aug 23, 2024

@lzc1001 Can you verify that the NuttX Config supports MMU?

$ grep MMU .config
CONFIG_ARCH_HAVE_MMU=y
# CONFIG_ARCH_USE_MMU is not set

Is it possible that the MMU code is disabled due to other reasons? Perhaps we can add an Error Message in arch/arm64/src/common/arm64_mmu.c:

int arm64_mmu_init(bool is_primary_core)
{
#error MMU is enabled
...

@lzc1001
Copy link
Author

lzc1001 commented Aug 23, 2024

@lupyuen Yes! The config support MMU
image

@lupyuen
Copy link
Member

lupyuen commented Aug 23, 2024

@lzc1001 I wonder if sinfo is failing to log correctly. What if you rename all sinfo to _info?

@raiden00pl
Copy link
Member

arm64_mmu_init() is called early in arm64_chip_boot() so it's possible that serial console is not yet initialized. arm64_earlyserialinit() is called after arm64_mmu_init(). You can add simple debug message (_info("xxxx")) at the top of arm64_chip_boot() and after arm64_mmu_init() to see if serial port works at this boot stage.

@acassis
Copy link
Contributor

acassis commented Aug 23, 2024

@raiden00pl @lupyuen @lzc1001 maybe RAMLOG could solve this issue.

@raiden00pl
Copy link
Member

raiden00pl commented Aug 23, 2024

@acassis RAMLOG is registered also late in boot process (in drivers_initialize()). One option if serial is not available since boot and requires some kind of initialization is to separate arm64_mmu_init() from MMU debug dump functionality like it's done for ACPI in x86:

  1. ACPI is parsed in early boot stage in __nxstart() as it's required for other initialization tasks
  2. ACPI dump is done in up_initialize() when some low-level initialization is already done (like x86_64_serialinit())

@acassis
Copy link
Contributor

acassis commented Aug 23, 2024

Understood! Thank you @raiden00pl

@lzc1001
Copy link
Author

lzc1001 commented Aug 23, 2024

@acassis @raiden00pl @lupyuen Thank you very much!
I added simple debug message (_info("111111111111111\n")). Then, the MMU information still don't print. but I added "_info("1111111111111111\n");" before and after up_initialize() in nuttx/sched/init/nx_start.c, the debug information after up_initialize() do print!! hhh, you are very niubility!😀✌
Then I tried to use ARM TF-A to boot NuttX and added the related macro in arch/arm64/src/common/arm64_mmu.c, the terminal print the related MMU information. But the exact cause of this problem in my code is still unknown, I will continue to check my poring code!
Thank you very much again!

@lzc1001 lzc1001 closed this as completed Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community: Question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants