You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/01/27 16:02:51 UTC

[incubator-nuttx-apps] branch master updated: romfsimg: add attribute to set minimum 4 bytes aignment for romfs image data

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 2498be1  romfsimg: add attribute to set minimum 4 bytes aignment for romfs image data
2498be1 is described below

commit 2498be1f4083c199d33755f24758d76cd95f9d0f
Author: Petro Karashchenko <pe...@gmail.com>
AuthorDate: Thu Jan 27 16:32:39 2022 +0200

    romfsimg: add attribute to set minimum 4 bytes aignment for romfs image data
    
    Signed-off-by: Petro Karashchenko <pe...@gmail.com>
---
 examples/elf/tests/Makefile              | 3 ++-
 examples/module/drivers/Makefile         | 3 ++-
 examples/nxflat/tests/Makefile           | 3 ++-
 examples/posix_spawn/filesystem/Makefile | 3 ++-
 examples/sotest/lib/Makefile             | 3 ++-
 examples/thttpd/content/Makefile.binfs   | 3 ++-
 examples/thttpd/content/Makefile.nxflat  | 3 ++-
 tools/mkromfsimg.sh                      | 3 ++-
 8 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/examples/elf/tests/Makefile b/examples/elf/tests/Makefile
index 9ff6c8a..1ade3b1 100644
--- a/examples/elf/tests/Makefile
+++ b/examples/elf/tests/Makefile
@@ -84,7 +84,8 @@ $(ROMFS_IMG): install
 # Create the romfs.c file from the romfs.img file
 
 $(FSIMG_SRC): $(ROMFS_IMG)
-	$(Q) (cd $(TESTS_DIR); xxd -i romfs.img | sed -e "s/^unsigned/const unsigned/g" >$@)
+	$(Q) (cd $(TESTS_DIR) && echo "#include <nuttx/compiler.h>" >$@ && \
+		xxd -i romfs.img | sed -e "s/^unsigned char/const unsigned char aligned_data(4)/g" >>$@)
 
 else
 # Make sure that the NuttX gencromfs tool has been built
diff --git a/examples/module/drivers/Makefile b/examples/module/drivers/Makefile
index a71102c..248067f 100644
--- a/examples/module/drivers/Makefile
+++ b/examples/module/drivers/Makefile
@@ -72,7 +72,8 @@ $(ROMFS_IMG): install
 # Create the romfs.c file from the romfs.img file
 
 $(FSIMG_SRC): $(ROMFS_IMG)
-	$(Q) (cd $(DRIVER_DIR); xxd -i romfs.img | sed -e "s/^unsigned/const unsigned/g" >$@)
+	$(Q) (cd $(DRIVER_DIR) && echo "#include <nuttx/compiler.h>" >$@ && \
+		xxd -i romfs.img | sed -e "s/^unsigned char/const unsigned char aligned_data(4)/g" >>$@)
 
 else ifeq ($(CONFIG_EXAMPLES_MODULE_CROMFS),y)
 # Make sure that the NuttX gencromfs tool has been built
diff --git a/examples/nxflat/tests/Makefile b/examples/nxflat/tests/Makefile
index 5b867d8..b14d2f7 100644
--- a/examples/nxflat/tests/Makefile
+++ b/examples/nxflat/tests/Makefile
@@ -64,7 +64,8 @@ $(ROMFS_IMG): install
 # Create the romfs.c file from the romfs.img file
 
 $(ROMFS_SRC): $(ROMFS_IMG)
-	$(Q) (cd $(TESTS_DIR); xxd -i romfs.img | sed -e "s/^unsigned/const unsigned/g" >$@)
+	$(Q) (cd $(TESTS_DIR) && echo "#include <nuttx/compiler.h>" >$@ && \
+		xxd -i romfs.img | sed -e "s/^unsigned char/const unsigned char aligned_data(4)/g" >>$@)
 
 # Create the dirlist.c file from the romfs directory
 
diff --git a/examples/posix_spawn/filesystem/Makefile b/examples/posix_spawn/filesystem/Makefile
index 9b6e285..45008e5 100644
--- a/examples/posix_spawn/filesystem/Makefile
+++ b/examples/posix_spawn/filesystem/Makefile
@@ -53,7 +53,8 @@ $(ROMFS_IMG): hello/hello redirect/redirect testdata.txt
 # Create the romfs.c file from the romfs.img file
 
 $(ROMFS_SRC): $(ROMFS_IMG)
-	$(Q) (cd $(FILESYSTEM_DIR); xxd -i romfs.img | sed -e "s/^unsigned/const unsigned/g" >$@)
+	$(Q) (cd $(FILESYSTEM_DIR) && echo "#include <nuttx/compiler.h>" >$@ && \
+		xxd -i romfs.img | sed -e "s/^unsigned char/const unsigned char aligned_data(4)/g" >>$@)
 
 # Create the exported symbol table
 
diff --git a/examples/sotest/lib/Makefile b/examples/sotest/lib/Makefile
index 4c465ad..7349442 100644
--- a/examples/sotest/lib/Makefile
+++ b/examples/sotest/lib/Makefile
@@ -63,7 +63,8 @@ $(ROMFS_IMG): install
 # Create the romfs.c file from the romfs.img file
 
 $(ROMFS_SRC): $(ROMFS_IMG)
-	$(Q) (cd $(LIB_DIR); xxd -i romfs.img | sed -e "s/^unsigned/const unsigned/g" >$@)
+	$(Q) (cd $(LIB_DIR) && echo "#include <nuttx/compiler.h>" >$@ && \
+		xxd -i romfs.img | sed -e "s/^unsigned char/const unsigned char aligned_data(4)/g" >>$@)
 endif
 
 # Create the exported symbol table
diff --git a/examples/thttpd/content/Makefile.binfs b/examples/thttpd/content/Makefile.binfs
index 91d6c7b..eeb241b 100644
--- a/examples/thttpd/content/Makefile.binfs
+++ b/examples/thttpd/content/Makefile.binfs
@@ -55,7 +55,8 @@ $(ROMFS_IMG): $(ROMFS_DIR)/index.html $(ROMFS_DIR)/style.css
 # Create the romfs.c file from the romfs.img file
 
 $(ROMFS_SRC): $(ROMFS_IMG)
-	$(Q) (cd $(CONTENT_DIR); xxd -i romfs.img | sed -e "s/^unsigned/const unsigned/g" >$@)
+	$(Q) (cd $(CONTENT_DIR) && echo "#include <nuttx/compiler.h>" >$@ && \
+	      xxd -i romfs.img | sed -e "s/^unsigned char/const unsigned char aligned_data(4)/g" >>$@)
 
 all:: $(ROMFS_SRC)
 
diff --git a/examples/thttpd/content/Makefile.nxflat b/examples/thttpd/content/Makefile.nxflat
index 7649f18..906a5c0 100644
--- a/examples/thttpd/content/Makefile.nxflat
+++ b/examples/thttpd/content/Makefile.nxflat
@@ -58,7 +58,8 @@ $(ROMFS_IMG): install
 # Create the romfs.c file from the romfs.img file
 
 $(ROMFS_SRC): $(ROMFS_IMG)
-	$(Q) (cd $(CONTENT_DIR); xxd -i romfs.img | sed -e "s/^unsigned/const unsigned/g" >$@)
+	$(Q) (cd $(CONTENT_DIR) && echo "#include <nuttx/compiler.h>" >$@ && \
+	      xxd -i romfs.img | sed -e "s/^unsigned char/const unsigned char aligned_data(4)/g" >>$@)
 
 # Create the exported symbol table list from the derived *-thunk.S files
 
diff --git a/tools/mkromfsimg.sh b/tools/mkromfsimg.sh
index e7ae009..fde95c9 100755
--- a/tools/mkromfsimg.sh
+++ b/tools/mkromfsimg.sh
@@ -55,6 +55,7 @@ genromfs -f ${romfsimg} -d ${fsdir} -V "NuttXBootVol" || { echo "genromfs failed
 
 # And, finally, create the header file
 
-xxd -i ${romfsimg} | sed 's/unsigned/const unsigned/' >${headerfile} || \
+echo '#include <nuttx/compiler.h>' >${headerfile}
+xxd -i ${romfsimg} | sed 's/^unsigned char/const unsigned char aligned_data(4)/g' >>${headerfile} || \
   { echo "ERROR: xxd of $< failed" ; rm -f ${romfsimg}; exit 1 ; }
 rm -f ${romfsimg}