You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/02/17 01:59:37 UTC

[GitHub] [incubator-nuttx] masayuki2009 opened a new pull request #5522: Fix binfmt for BUILD_KERNEL & ADDRENV

masayuki2009 opened a new pull request #5522:
URL: https://github.com/apache/incubator-nuttx/pull/5522


   ## Summary
   
   - This PR contains 2 commits
   - commit1: binfmt: Call umm_initialize() for BUILD_KERNEL & ADDRENV
     - I noticed that the user heap is not initialized correctly
         if BUILD_KERNEL=y and ADDRENV=y
     - This commit fixes this issue
   - commit2: binfmt, include: Change the g_mmheap location
     - I noticed that the user heap is not correctly recognized
         from kernel if BUILD_KERNEL=y and ADDRENV=y
     - This commit fixes this issue by explicitly locating g_mmheap
         to at the start of .data section
   
   ## Impact
   
    - None
   
   ## Testing
   
   - Tested with sabre-6quad:netknsh (not merged yet)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] minabeoki commented on pull request #5522: Fix binfmt for BUILD_KERNEL & ADDRENV

Posted by GitBox <gi...@apache.org>.
minabeoki commented on pull request #5522:
URL: https://github.com/apache/incubator-nuttx/pull/5522#issuecomment-1042604134


   @masayuki2009
   `__KERNEL__` is defined only for the kernel binary.
   In case of user land, `__KERNEL__` is not defined.
   mm is compiled for kernel and usr land. (libmm.a and libkmm.a)
   
   * kernel: CONFIG_BUILD_KERNEL and `__KERNEL__` are defined.
   * user land: CONFIG_BUILD_KERNEL is defined and `__KERNEL__` is not defined.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] pkarashchenko merged pull request #5522: Fix binfmt for BUILD_KERNEL & ADDRENV

Posted by GitBox <gi...@apache.org>.
pkarashchenko merged pull request #5522:
URL: https://github.com/apache/incubator-nuttx/pull/5522


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] masayuki2009 commented on pull request #5522: Fix binfmt for BUILD_KERNEL & ADDRENV

Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on pull request #5522:
URL: https://github.com/apache/incubator-nuttx/pull/5522#issuecomment-1042624363


   @minabeoki 
   So, we don't need the second commit but need the following change instead.
   
   ```
   diff --git a/mm/umm_heap/umm_heap.h b/mm/umm_heap/umm_heap.h
   index 7d8e8a49da..7d74ea94e1 100644
   --- a/mm/umm_heap/umm_heap.h
   +++ b/mm/umm_heap/umm_heap.h
   @@ -35,7 +35,7 @@
     * Pre-processor Definitions
     ****************************************************************************/
    
   -#if defined(CONFIG_ARCH_ADDRENV) && defined(__KERNEL__)
   +#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)
    /* In the kernel build, there are multiple user heaps; one for each task
     * group.  In this build configuration, the user heap structure lies
     * in a reserved region at the beginning of the .bss/.data address
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] minabeoki commented on pull request #5522: Fix binfmt for BUILD_KERNEL & ADDRENV

Posted by GitBox <gi...@apache.org>.
minabeoki commented on pull request #5522:
URL: https://github.com/apache/incubator-nuttx/pull/5522#issuecomment-1042579863


   @masayuki2009 san,
   g_mmheap problem caused by mm/umm_heap/umm_heap.h define.
   In the ADDRENV and BUILD_KERNEL case, USR_HEAP uses ARCH_DATA_RESERVE->ar_usrheap.
   current condition is
   `#if defined(CONFIG_ARCH_ADDRENV) && defined(__KERNEL__)`
   NuttX-9.0.0's umm_heap.h condition is
   `#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)`
   Maybe this is correct.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] masayuki2009 commented on pull request #5522: Fix binfmt for BUILD_KERNEL & ADDRENV

Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on pull request #5522:
URL: https://github.com/apache/incubator-nuttx/pull/5522#issuecomment-1042627367


   >@minabeoki
   >So, we don't need the second commit but need the following change instead.
   
   The nsh works.
   
   [    4.190000] load_absmodule: Successfully loaded module /mnt/nfs/bin/init
   [    4.190000] binfmt_dumpmodule: Module:
   [    4.190000] binfmt_dumpmodule:   entrypt:   0x80001a34
   [    4.190000] binfmt_dumpmodule:   mapped:    0 size=0
   [    4.190000] binfmt_dumpmodule:   alloc:     0 0 0
   [    4.190000] binfmt_dumpmodule:   addrenv:   0x18000000
   [    4.190000] binfmt_dumpmodule:   stacksize: 2048
   [    4.190000] binfmt_dumpmodule:   unload:    0
   [    4.190000] exec_module: Executing /mnt/nfs/bin/init
   [    4.190000] up_addrenv_select: addrenv=0x10863e64 oldenv=0x10868ac8
   [    4.190000] up_addrenv_select: text: set l1 entry (paddr=18000000 vaddr=80000000)
   [    4.190000] up_addrenv_select: data: set l1 entry (paddr=18028000 vaddr=80100000)
   [    4.200000] up_addrenv_select: heap: set l1 entry (paddr=1802a000 vaddr=80200000)
   [    4.200000] exec_module: Initialize the user heap (heapsize=1048576)
   [    4.200000] up_addrenv_kstackalloc: tcb=0x10866820 stacksize=3072
   [    4.200000] up_addrenv_clone: src=0x10863e64 dest=0x10863ed8
   [    4.200000] up_addrenv_restore: oldenv=0x10868ac8
   [    4.210000] up_addrenv_select: addrenv=0x10863ed8 oldenv=0
   [    4.210000] up_addrenv_select: text: set l1 entry (paddr=18000000 vaddr=80000000)
   [    4.210000] up_addrenv_select: data: set l1 entry (paddr=18028000 vaddr=80100000)
   [    4.210000] up_addrenv_select: heap: set l1 entry (paddr=1802a000 vaddr=80200000)
   
   NuttShell (NSH) NuttX-10.2.0
   nsh> free
   [   29.080000] load_absmodule: Loading free
   [   29.080000] elf_loadbinary: Loading file: free
   [   29.080000] elf_init: filename: free loadinfo: 0x10867400
   [   29.080000] elf_filelen: Failed to stat file: -2
   [   29.080000] elf_init: elf_filelen failed: -2
   [   29.080000] elf_dumploadinfo: LOAD_INFO:
   [   29.080000] elf_dumploadinfo:   textalloc:    00000000
   [   29.080000] elf_dumploadinfo:   dataalloc:    00000000
   [   29.080000] elf_dumploadinfo:   textsize:     0
   [   29.080000] elf_dumploadinfo:   datasize:     0
   [   29.080000] elf_dumploadinfo:   textalign:    0
   [   29.080000] elf_dumploadinfo:   dataalign:    0
   [   29.080000] elf_dumploadinfo:   filelen:      0
   [   29.080000] elf_dumploadinfo:   symtabidx:    0
   [   29.080000] elf_dumploadinfo:   strtabidx:    0
   [   29.090000] elf_dumploadinfo: ELF Header:
   [   29.090000] elf_dumploadinfo:   e_ident:      00 00 00 00
   [   29.090000] elf_dumploadinfo:   e_type:       0000
   [   29.090000] elf_dumploadinfo:   e_machine:    0000
   [   29.090000] elf_dumploadinfo:   e_version:    00000000
   [   29.090000] elf_dumploadinfo:   e_entry:      00000000
   [   29.090000] elf_dumploadinfo:   e_phoff:      0
   [   29.090000] elf_dumploadinfo:   e_shoff:      0
   [   29.090000] elf_dumploadinfo:   e_flags:      00000000
   [   29.090000] elf_dumploadinfo:   e_ehsize:     0
   [   29.090000] elf_dumploadinfo:   e_phentsize:  0
   [   29.090000] elf_dumploadinfo:   e_phnum:      0
   [   29.090000] elf_dumploadinfo:   e_shentsize:  0
   [   29.090000] elf_dumploadinfo:   e_shnum:      0
   [   29.090000] elf_dumploadinfo:   e_shstrndx:   0
   [   29.090000] elf_loadbinary: Failed to initialize for load of ELF program: -2
   [   29.090000] exec_spawn: ERROR: Failed to load program 'free': -2
                      total       used       free    largest  nused  nfree
           Umem:    1048224       3728    1044496    1038304      6      2
           Kmem:  259647584      30160  259617424  259608800     53      4
           Page:  134217728    1224704  132993024  132993024
   nsh> ps
   [   69.830000] load_absmodule: Loading ps
   [   69.840000] elf_loadbinary: Loading file: ps
   [   69.840000] elf_init: filename: ps loadinfo: 0x10867400
   [   69.840000] elf_filelen: Failed to stat file: -2
   [   69.840000] elf_init: elf_filelen failed: -2
   [   69.840000] elf_dumploadinfo: LOAD_INFO:
   [   69.840000] elf_dumploadinfo:   textalloc:    00000000
   [   69.840000] elf_dumploadinfo:   dataalloc:    00000000
   [   69.840000] elf_dumploadinfo:   textsize:     0
   [   69.840000] elf_dumploadinfo:   datasize:     0
   [   69.840000] elf_dumploadinfo:   textalign:    0
   [   69.840000] elf_dumploadinfo:   dataalign:    0
   [   69.840000] elf_dumploadinfo:   filelen:      0
   [   69.840000] elf_dumploadinfo:   symtabidx:    0
   [   69.840000] elf_dumploadinfo:   strtabidx:    0
   [   69.840000] elf_dumploadinfo: ELF Header:
   [   69.840000] elf_dumploadinfo:   e_ident:      00 00 00 00
   [   69.840000] elf_dumploadinfo:   e_type:       0000
   [   69.840000] elf_dumploadinfo:   e_machine:    0000
   [   69.840000] elf_dumploadinfo:   e_version:    00000000
   [   69.840000] elf_dumploadinfo:   e_entry:      00000000
   [   69.840000] elf_dumploadinfo:   e_phoff:      0
   [   69.840000] elf_dumploadinfo:   e_shoff:      0
   [   69.840000] elf_dumploadinfo:   e_flags:      00000000
   [   69.840000] elf_dumploadinfo:   e_ehsize:     0
   [   69.840000] elf_dumploadinfo:   e_phentsize:  0
   [   69.840000] elf_dumploadinfo:   e_phnum:      0
   [   69.840000] elf_dumploadinfo:   e_shentsize:  0
   [   69.840000] elf_dumploadinfo:   e_shnum:      0
   [   69.840000] elf_dumploadinfo:   e_shstrndx:   0
   [   69.840000] elf_loadbinary: Failed to initialize for load of ELF program: -2
   [   69.840000] exec_spawn: ERROR: Failed to load program 'ps': -2
     PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK   STACK   USED  FILLED COMMAND
       0     0   0 FIFO     Kthread N-- Ready              00000000 002024 000616  30.4%  Idle Task
       1     1 224 RR       Kthread --- Waiting  Semaphore 00000000 002016 000388  19.2%  hpwork 0x1085bcfc
       2     2 100 RR       Kthread --- Waiting  Semaphore 00000000 002016 000728  36.1%  lpwork 0x1085bd08
       3     3 100 RR       Kthread --- Waiting  Semaphore 00000000 003056 001948  63.7%  nfsroot
       4     4 100 RR       Task    --- Running            00000000 002016 001296  64.2%  /mnt/nfs/bin/init
   nsh> 
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] masayuki2009 commented on pull request #5522: Fix binfmt for BUILD_KERNEL & ADDRENV

Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on pull request #5522:
URL: https://github.com/apache/incubator-nuttx/pull/5522#issuecomment-1042541551


   Hmm, Build / macOS (sim-01) failed.
   
   ```
   curl: (28) Failed to connect to git.busybox.net port 443 after 75212 ms: Operation timed out
   make[1]: *** [/Users/runner/work/incubator-nuttx/incubator-nuttx/sources/nuttx/include/uClibc++] Error 28
   make[1]: Target `context' not remade because of errors.
   make: *** [libs/libxx/.context] Error 2
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] masayuki2009 commented on pull request #5522: Fix binfmt for BUILD_KERNEL & ADDRENV

Posted by GitBox <gi...@apache.org>.
masayuki2009 commented on pull request #5522:
URL: https://github.com/apache/incubator-nuttx/pull/5522#issuecomment-1042595129


   > @masayuki2009 san, g_mmheap problem caused by mm/umm_heap/umm_heap.h define. In the ADDRENV and BUILD_KERNEL case, USR_HEAP uses ARCH_DATA_RESERVE->ar_usrheap. current condition is `#if defined(CONFIG_ARCH_ADDRENV) && defined(__KERNEL__)` NuttX-9.0.0's umm_heap.h condition is `#if defined(CONFIG_ARCH_ADDRENV) && defined(CONFIG_BUILD_KERNEL)` Maybe this is correct.
   
   @minabeoki 
   Thanks for the comments.
   
   Actually, `__KERNEL__` is defined in tools/Config.mk
   
   ```
   ...
   # This define is passed as EXTRAFLAGS for kernel-mode builds.  It is also passed                                                                                                                   
   # during PASS1 (but not PASS2) context and depend targets.                                                                                                                                         
                                                                                                                                                                                                      
   KDEFINE ?= ${shell $(DEFINE) "$(CC)" __KERNEL__}  
   ...
   ```
   
   And you will see the build logs
   
   ```
   make[1]: Entering directory '/mnt/m2ssd/opensource/github_masayuki2009/apache-nuttx-imx6-knsh/nuttx/libs/libc'                                                                                     
   for dir in  sched drivers boards arch/arm/src fs binfmt net ; do \                                                                                                                                 
           make -C $dir EXTRAFLAGS="-D__KERNEL__ -Wno-cpp -Werror" depend || exit; \                                                                                                                  
   done        
   ````
   
   So, I think the current `mm/umm_heap/umm_heap.h` is correct.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org