nshlib: add relative image path support in boot command - #3668
Conversation
cmd_boot passed the image path straight to boardctl(), which resolves it in a context that does not inherit the NSH shell cwd, so relative paths failed and only absolute paths worked. Use nsh_getfullpath() to resolve relative paths against the cwd before calling boardctl(). Signed-off-by: Junbo Zheng <zhengjunbo1@xiaomi.com>
cederom
left a comment
There was a problem hiding this comment.
Thank you @Junbo-Zheng :-)
acassis
left a comment
There was a problem hiding this comment.
@Junbo-Zheng I think this feature needs Documentation
|
I also wonder about impact on firmware size, have you compared that @Junbo-Zheng ? Maybe we want this as an option if the function is not part of the firmware by default? I understand that |
@acassis Done, please review apache/nuttx#19553 |
The Local build with
|
Summary
cmd_boot passed the image path straight to boardctl(), which resolves it in a context that does not inherit the NSH shell cwd, so relative paths failed, and only absolute paths worked. Use nsh_getfullpath() to resolve relative paths against the cwd before calling boardctl().
Impact
boot <relative-path>now resolves against the NSH cwd;absolute-path behavior is unchanged.
nsh_getfullpath/nsh_freefullpathhelpers, no new dependency.
paths behave exactly as before.
Testing
Local build on Cortex-M55 (enables CONFIG_BOARDCTL_BOOT_IMAGE); the boot ELF builds and the
bootNSH command succeeds.And the change follows the established
nsh_getfullpath()/nsh_freefullpath()convention already used by the other NSH file-path commands. Representative upstream examples (the same pattern is also used bymv,ls,ln,mkdir, and every other NSH file-path command):