Running applications from dataflash
Hello, I intend to implement a firmware update feature for my project, which is based on stm32f4discovery. My idea is to load a separated ELF file on the dataflash, which is loaded using the approach described in the following video: https://www.youtube.com/watch?v=oL6KAgkTb8M When running this application, another content from this same dataflash, the new firmware, will be used to erase the mcu flash and write the new firmware. While evaluating this approach and watching the video, I had 2 questions: 1. Can an ELF file be executed from dataflash too? 2. Is this execution totally independent from the MCU flash? Best regards, Flavio -- Flavio de Castro Alves Filho flavio.al...@gmail.com Twitter: http://twitter.com/#!/fraviofii LinkedIn profile: www.linkedin.com/in/flaviocastroalves
Nonexistent CONFIG_FILE_MODE?
I noticed several instances of preprocessor logic like this example from register_driver() in fs_registerdriver.c: #ifdef CONFIG_FILE_MODE node->i_mode= mode; #endif But there doesn't seem to be such a Kconfig option. Did I miss something? Or is this a remnant from a bygone era? Thanks, Nathan
Re: Nonexistent CONFIG_FILE_MODE?
I noticed several instances of preprocessor logic like this example from register_driver() in fs_registerdriver.c: #ifdef CONFIG_FILE_MODE node->i_mode= mode; #endif But there doesn't seem to be such a Kconfig option. Did I miss something? Or is this a remnant from a bygone era? No, it was intended to be a placeholder for future support. These security-related features will be needed someday, but they are not used today (or even fully implemented). This conditions out logic that depends on user and group privileges. No harm in removing code conditioned on CONFIG_FILE_MODE other than we will have to restore it someday.
Re: Nonexistent CONFIG_FILE_MODE?
Hehehe, you are not the first one to notice it, in fact I commented that this kind of code exist but is not implemented: https://issues.apache.org/jira/browse/NUTTX-8 Patch are welcome! ;-) BR, Alan On 4/25/21, Nathan Hartman wrote: > I noticed several instances of preprocessor logic like this example > from register_driver() in fs_registerdriver.c: > > #ifdef CONFIG_FILE_MODE > node->i_mode= mode; > #endif > > But there doesn't seem to be such a Kconfig option. > > Did I miss something? Or is this a remnant from a bygone era? > > Thanks, > Nathan >
Re: Nonexistent CONFIG_FILE_MODE?
Covered in this Issue: https://github.com/apache/incubator-nuttx/issues/3399 On 4/25/2021 12:29 PM, Gregory Nutt wrote: I noticed several instances of preprocessor logic like this example from register_driver() in fs_registerdriver.c: #ifdef CONFIG_FILE_MODE node->i_mode = mode; #endif But there doesn't seem to be such a Kconfig option. Did I miss something? Or is this a remnant from a bygone era? No, it was intended to be a placeholder for future support. These security-related features will be needed someday, but they are not used today (or even fully implemented). This conditions out logic that depends on user and group privileges. No harm in removing code conditioned on CONFIG_FILE_MODE other than we will have to restore it someday.
Re: Nonexistent CONFIG_FILE_MODE?
On 4/25/2021 12:31 PM, Alan Carvalho de Assis wrote: Hehehe, you are not the first one to notice it, in fact I commented that this kind of code exist but is not implemented: https://issues.apache.org/jira/browse/NUTTX-8 To be a POSIX, Unix-like system, NuttX should support privileges. Adding privileges to the NSH login would be pretty easy (I actually started that one time in the past). There has been no motivation to implement this feature, mostly because the only file system with privilege information is ROMFS. But privileges are more than just file privileges: I could be useful to have super-user capabilities in NSH for many things, not just file access.
Re: Trying to build nxflat example in simulator
Hi Tanushree, It seams the error is related to documentation, maybe if you disable generating it the binutils will compile. BR, Alan On 4/25/21, Tanushree Baindur wrote: > Hi, > > I started working on issue Illegal calls to romdisk_register() #246 a while > back. I've been able to figure out how to run all of the examples listed in > the issue on the simulator, except for these two : examples/ nxflat and > examples/thttpd. > > I found information regarding nxflat on this website: > https://nuttx.apache.org/docs/latest/components/nxflat.html > > In the above website I found the following information: > "GCC/ARM/Cortex-M3/4 Only: At present, the NXFLAT toolchain is only > available for ARM and Cortex-M3/4 (thumb2) targets." Does this mean that > the nxflat example cannot be run in the simulator? > > I went ahead and tried to install the NXFLAT toolchain. I followed the > instructions under "Building the NXFLAT Toolchain" in the above website. On > doing a 'make' I now get the following errors: > > > /home/tanushree/nuttx-code/buildroot/toolchain_build_i686/binutils-2.17/bfd/doc/elf.texi:11: > raising the section level of @subsubsection which is too low > mv: cannot move '.am15588/bfd.info' to > './/home/tanushree/nuttx-code/buildroot/toolchain_build_i686/binutils-2.17/bfd/doc/': > No such file or directory > Makefile:364: recipe for target > '/home/tanushree/nuttx-code/buildroot/toolchain_build_i686/binutils-2.17/bfd/doc/ > bfd.info' failed > make[4]: *** > [/home/tanushree/nuttx-code/buildroot/toolchain_build_i686/binutils-2.17/bfd/doc/ > bfd.info] Error 1 > make[4]: Leaving directory > '/home/tanushree/nuttx-code/buildroot/toolchain_build_i686/binutils-2.17-build/bfd/doc' > Makefile:1029: recipe for target 'info-recursive' failed > make[3]: *** [info-recursive] Error 1 > make[3]: Leaving directory > '/home/tanushree/nuttx-code/buildroot/toolchain_build_i686/binutils-2.17-build/bfd' > Makefile:2720: recipe for target 'all-bfd' failed > make[2]: *** [all-bfd] Error 2 > make[2]: Leaving directory > '/home/tanushree/nuttx-code/buildroot/toolchain_build_i686/binutils-2.17-build' > Makefile:629: recipe for target 'all' failed > make[1]: *** [all] Error 2 > make[1]: Leaving directory > '/home/tanushree/nuttx-code/buildroot/toolchain_build_i686/binutils-2.17-build' > toolchain/binutils/binutils.mk:55: recipe for target > '/home/tanushree/nuttx-code/buildroot/toolchain_build_i686/binutils-2.17-build/binutils/objdump' > failed > make: *** > [/home/tanushree/nuttx-code/buildroot/toolchain_build_i686/binutils-2.17-build/binutils/objdump] > Error 2 > > > Following is my .config file: > # > # Automatically generated make config: don't edit > # > BR2_HAVE_DOT_CONFIG=y > # BR2_alpha is not set > # BR2_arm is not set > # BR2_armeb is not set > # BR2_avr is not set > # BR2_avr32 is not set > # BR2_bfin is not set > # BR2_cris is not set > BR2_i386=y > # BR2_lm32 is not set > # BR2_m32c is not set > # BR2_m68k is not set > # BR2_m68hc11 is not set > # BR2_m68hc12 is not set > # BR2_m9s12x is not set > # BR2_mips is not set > # BR2_mipsel is not set > # BR2_nios2 is not set > # BR2_powerpc is not set > # BR2_sh is not set > # BR2_sh64 is not set > # BR2_h8300 is not set > # BR2_sparc is not set > # BR2_x86_64 is not set > # BR2_GCC_CORTEX is not set > # BR2_GCC_CORTEX_M4F is not set > # BR2_x86_i386 is not set > # BR2_x86_i486 is not set > # BR2_x86_i586 is not set > BR2_x86_i686=y > BR2_ARCH="i686" > BR2_GCC_TARGET_TUNE="i686" > BR2_GCC_TARGET_ARCH="i686" > > # > # Build options > # > BR2_WGET="wget --passive-ftp" > BR2_SVN="svn co" > BR2_ZCAT="zcat" > BR2_BZCAT="bzcat" > BR2_TAR_OPTIONS="" > BR2_DL_DIR="$(BASE_DIR)/dl" > BR2_STAGING_DIR="$(BUILD_DIR)/staging_dir" > BR2_NUTTX_DIR="$(TOPDIR)/../nuttx" > BR2_TOPDIR_PREFIX="" > BR2_TOPDIR_SUFFIX="" > BR2_GNU_BUILD_SUFFIX="pc-elf" > BR2_GNU_TARGET_SUFFIX="nuttx-elf" > # BR2_PREFER_IMA is not set > > # > # Toolchain Options > # > > # > # Binutils Options > # > BR2_PACKAGE_BINUTILS=y > BR2_BINUTILS_VERSION_2_17=y > # BR2_BINUTILS_VERSION_2_18 is not set > # BR2_BINUTILS_VERSION_2_19 is not set > # BR2_BINUTILS_VERSION_2_19_1 is not set > # BR2_BINUTILS_VERSION_2_21_1 is not set > # BR2_BINUTILS_VERSION_2_22 is not set > # BR2_BINUTILS_VERSION_2_24 is not set > # BR2_BINUTILS_VERSION_2_26_1 is not set > # BR2_BINUTILS_VERSION_2_28_1 is not set > BR2_BINUTILS_VERSION="2.17" > BR2_EXTRA_BINUTILS_CONFIG_OPTIONS="" > > # > # GCC Options > # > BR2_PACKAGE_GCC=y > # BR2_GCC_VERSION_3_3_6 is not set > # BR2_GCC_VERSION_3_4_6 is not set > # BR2_GCC_VERSION_4_2_4 is not set > BR2_GCC_VERSION_4_3_3=y > # BR2_GCC_VERSION_4_5_2 is not set > # BR2_GCC_VERSION_4_6_3 is not set > # BR2_GCC_VERSION_4_7_4 is not set > # BR2_GCC_VERSION_4_8_5 is not set > # BR2_GCC_VERSION_4_9_4 is not set > # BR2_GCC_VERSION_5_5_0 is not set > # BR2_GCC_VERSION_6_4_0 is not set > # BR2_GCC_VERSION_7_3_0 is not set > BR2_GCC_SUPPORTS_SYSROOT=y > BR2_GCC_VERSION="4.3.3" > # BR2_GCC_USE_SJLJ_EXCEPTIONS is not se
Re: Trying to build nxflat example in simulator
It seams the error is related to documentation, maybe if you disable generating it the binutils will compile. NxFLAT is currently only supported on ARM 32-bit and ARM Thumb ISAs. Some development would be required to extend that to other architectures.
Re: Running applications from dataflash
1. Can an ELF file be executed from dataflash too? No. ELF cannot run XIP (eXecute In Place) in NOR FLASH. That is because the ELF module is only partially linked and requires run-time relocations to the ELF image to access the data area arbitrarily located in RAM. An option is to use a fully linked file... basically a binary nuttx.bin image ... that already has all of the RAM addresses resolved. Another option is to use NxFLAT which does not require any relocations in FLASH and which runs PIC/PID (Position Independent Code/Data). NxFLAT has other limitations, however. 2. Is this execution totally independent from the MCU flash? If I understand the question correctly... ELF is copied into RAM when it executes and no longer needs to use FLASH memory for any execution.
Re: Nonexistent CONFIG_FILE_MODE?
beside the privilege, it's more useful to modify the timestamp for IoT device by utime: https://pubs.opengroup.org/onlinepubs/009604599/functions/utime.html BTW, the permission is meaningless in FLAT mode with the unsafe language(e.g. C/C++). On Mon, Apr 26, 2021 at 2:39 AM Gregory Nutt wrote: > > On 4/25/2021 12:31 PM, Alan Carvalho de Assis wrote: > > Hehehe, you are not the first one to notice it, in fact I commented > > that this kind of code exist but is not implemented: > > > > https://issues.apache.org/jira/browse/NUTTX-8 > > To be a POSIX, Unix-like system, NuttX should support privileges. > Adding privileges to the NSH login would be pretty easy (I actually > started that one time in the past). > > There has been no motivation to implement this feature, mostly because > the only file system with privilege information is ROMFS. But privileges > are more than just file privileges: I could be useful to have > super-user capabilities in NSH for many things, not just file access. > > >