SpresenseSDK Command Shell Initial Export Does Not Work

Asked 2 years ago, Updated 2 years ago, 325 views

When initializing the command shell of the SpresenseSDK, I defined the variable in export as follows, but the value is blank.
·The previous SDK version (v2.2.0) worked well.
·The new SDK version (v2.4.0) will not work.The value of the variable will be blank.
For example, have you changed the way you use the command, or are there any missing configuration settings?

  • SDK Configuration Settings
·CONFIG_NSH_VARS=Y
·NSH_DISABLE_ENV=N
  • Initial (init.rc, etc.)
sh/mnt/sd0/export.txt
sh/mnt/sd0/sample1
  • In export.txt
export DEF_SAMPLE10
export DEF_SAMPLE2"/mnt/sd0/"
  • In sample1
sh/mnt/sd0/sample2&
  • In sample2
 echo$DEF_SAMPLE1 ← NG with new SDK; blank data; OK with old SDK
echo${DEF_SAMPLE2} ← NG with new SDK; blank data; OK with old SDK

spresense

2022-09-30 22:01

1 Answers

According to NuttX Environment Variables, environment variables are managed by task group.
https://nuttx.apache.org/docs/latest/reference/user/09_env_vars.html

  • task—When creating a task, environment variables are replicated to child tasks but are independent of each other
  • thread—Environment variables are shared between threads

If you create a process with sh, and then export, the environment variable disappears as soon as the process ends.I don't know why the old SDK version worked, but the new SDK version seems to behave as designed (as far as the documentation and code are concerned).

If you use source instead of sh, I think the case for this question will work as intended.

  • Initial (init.rc, etc.)
source/mnt/sd0/export.txt
sh/mnt/sd0/sample1


2022-09-30 22:01

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.