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

examples/hello_nim: Fix nimcache location #4

Closed
wants to merge 1 commit into from
Closed

examples/hello_nim: Fix nimcache location #4

wants to merge 1 commit into from

Conversation

lupyuen
Copy link

@lupyuen lupyuen commented Jan 2, 2024

Summary

The Nim Example App fails to build because the .nimcache is located 2 folders up. This PR fixes the location of .nimcache in the Makefile of the Nim Example App.

.nimcache is explained in this article.

Impact

Nim Example App builds and runs correctly after fixing the .nimcache location.

No impact on other apps, since the Makefile is used only by the Nim Example App.

Testing

We tested on QEMU Arm64:

$ tools/configure.sh -l qemu-armv8a:nsh
## TODO: Init networking: https://github.com/lupyuen2/wip-pinephone-nuttx/commit/77b8295eb761954370481ed113254b7e930f65c0
## TODO: Suppress warnings: https://github.com/lupyuen2/wip-pinephone-nuttx/commit/e82be7d1f9f662ef369a3c4adc8290a4035f9857

$ make menuconfig
## Enable "Application Configuration > Examples > Hello World Example (Nim)"
## Networking support: Enable "Networking support"
## Networking Support → SocketCAN Support:
##   Enable "SocketCAN Support"
##   Enable "sockopt support"
## RTOS Features → Tasks and Scheduling:
##   Enable "Support parent/child task relationships"
##   Enable "Retain child exit status"

$ make

Before Fixing

NuttX Build fails because .nimcache/hello_nim_async.h could not be found:

./hello_nim_main.c:26:10: fatal error: hello_nim_async.h: No such file or directory
   26 | #include "hello_nim_async.h"

(See the Build Log)

After Fixing

NuttX Build succeeds and Nim Example App runs correctly. Note that we need to suppress the warnings and initialise the network. We might need to fix these in a future PR.

$ 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

NuttShell (NSH) NuttX-12.0.3
nsh> uname -a
NuttX  12.0.3 77b8295eb76 Jan  2 2024 04:53:17 arm64 qemu-armv8a

nsh> hello_nim
task_spawn: name=hello_nim entry=0x402a4f4c file_actions=0x403ede48 attr=0x403ede50 argv=0x403edf90
spawn_execattrs: Setting policy=2 priority=100 for pid=3
pthread_mutex_init: mutex=0x403e4918 attr=0
pthread_mutex_init: Returning 0
Hello from task 1! loops: 0
pthread_mutex_timedlock: mutex=0x403e4918
pthread_mutex_timedlock: Returning 0
pthread_mutex_unlock: mutex=0x403e4918
pthread_mutex_unlock: Returning 0
Hello from task 2! loops: 0
Hello from task 3! loops: 0
Hello from task 1! loops: 1
Hello from task 2! loops: 1
Hello from task 3! loops: 1
Hello from task 1! loops: 2
Hello from task 2! loops: 2
Hello from task 3! loops: 2
nxsig_tcbdispatch: TCB=0x403ebd40 pid=2 signo=17 code=5 value=0 masked=NO
nsh> 

(See the NuttX Log)

@lupyuen lupyuen marked this pull request as draft January 2, 2024 04:26
@lupyuen lupyuen changed the title Move nimcache up 2 folders examples/hello_nim: Fix nimcache location Jan 2, 2024
The Nim Example App fails to build because the `.nimcache` is located 2 folders up. This PR fixes the location of `.nimcache` in the `Makefile` of the Nim Example App.

`.nimcache` is explained in this article: https://lupyuen.github.io/articles/nim#inside-nim-on-nuttx
@lupyuen lupyuen closed this Jan 3, 2024
lupyuen pushed a commit that referenced this pull request Oct 2, 2024
wdog.c:190:3: runtime error: signed integer overflow: 9223372036854775807 + 1 cannot be represented in type 'long int'
    #0 0x40e35d3a in wdog_test_run /home/cuiziwei/ska/vela/vela-dev2/apps/testing/ostest/wdog.c:190
    #1 0x40e35e75 in wdog_test_thread /home/cuiziwei/ska/vela/vela-dev2/apps/testing/ostest/wdog.c:207
    #2 0x40773ffa in pthread_startup pthread/pthread_create.c:59
    #3 0x4495e037 in pthread_start pthread/pthread_create.c:139
    #4 0x40301864 in pre_start sim/sim_initialstate.c:52

Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
lupyuen pushed a commit that referenced this pull request Dec 2, 2024
Even though one could in theory simply set CONFIG_MBEDTLS_VERSION="3.6.2",
this commit is needed for 2 reasons:
  1. The patches need to be updated: 0001 works almost as-is (with fuzz 2)
     but 0002 hunk #4 fails and needed adjustment. Otherwise, the patches
     are identical.
  2. mbedtls_config.h needs to be updated: Following the same approach
     for the Kconfig this commit updates both Kconfig and mbedtls_config.h
     according to the changes:
       mbedtls$ git diff v3.4.0...v3.6.2 -- include/mbedtls/mbedtls_config.h

Minor edits also to crypto/controlse to comply with v3.6.2.

Signed-off-by: George Poulios <gpoulios@census-labs.com>
lupyuen pushed a commit that referenced this pull request Dec 24, 2024
…ter was read

    #0 0x43c7443a in strnlen nuttx/libs/libc/string/lib_strnlen.c:42
    #1 0x43c698aa in vsprintf_internal nuttx/libs/libc/stdio/lib_libvsprintf.c:933
    #2 0x43c6ca80 in lib_vsprintf nuttx/libs/libc/stdio/lib_libvsprintf.c:1383
    #3 0x4409c0bd in vsnprintf nuttx/libs/libc/stdio/lib_vsnprintf.c:72
    #4 0x47137cd0 in vcmocka_print_error apps/testing/cmocka/cmocka/src/cmocka.c:2097
    #5 0x47139573 in cmocka_print_error apps/testing/cmocka/cmocka/src/cmocka.c:2422
    #6 0x471376ff in string_equal_display_error apps/testing/cmocka/cmocka/src/cmocka.c:1410
    #7 0x471379a0 in _assert_string_equal apps/testing/cmocka/cmocka/src/cmocka.c:1952
    #8 0x4433d972 in read_default apps/testing/drivertest/drivertest_uart.c:242
    #9 0x4713c6cd in cmocka_run_one_test_or_fixture apps/testing/cmocka/cmocka/src/cmocka.c:3029
    apache#10 0x4713d487 in cmocka_run_one_tests apps/testing/cmocka/cmocka/src/cmocka.c:3143
    apache#11 0x4713f2ca in _cmocka_run_group_tests apps/testing/cmocka/cmocka/src/cmocka.c:3294
    apache#12 0x443444c6 in cmocka_driver_uart_main apps/testing/drivertest/drivertest_uart.c:358
    apache#13 0x4409a472 in nxtask_startup nuttx/libs/libc/sched/task_startup.c:72
    apache#14 0x43dc92e7 in nxtask_start nuttx/sched/task/task_start.c:116
    apache#15 0x43e31f00 in pre_start nuttx/arch/sim/src/sim/sim_initialstate.c:52

Signed-off-by: zhangshoukui <zhangshoukui@xiaomi.com>
lupyuen pushed a commit that referenced this pull request Jan 20, 2025
…int to a stack space

==1805058==ERROR: AddressSanitizer: heap-use-after-free on address 0xe18126a0 at pc 0x52b06320 bp 0xd7b13ee8 sp 0xd7b13ed8
READ of size 1 at 0xe18126a0 thread T0
    #0 0x52b0631f in tre_parse regex/regcomp.c:1356
    #1 0x52b2b1d0 in regcomp regex/regcomp.c:3710
    #2 0x48f55435 in c_regexmatch cmocka/src/cmocka.c:494
    #3 0x48f65bcf in _cmocka_run_group_tests cmocka/src/cmocka.c:3252
    #4 0x48f67e2d in cmocka_fs_test_main apps/testing/testsuites/kernel/fs/cmocka_fs_test.c:201
    #5 0x46210b2a in nxtask_startup sched/task_startup.c:72
    #6 0x45ff40fb in nxtask_start task/task_start.c:116
    #7 0x462695bb in pre_start sim/sim_initialstate.c:52

Signed-off-by: zhangshoukui <zhangshoukui@xiaomi.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant