From 2498be1f4083c199d33755f24758d76cd95f9d0f Mon Sep 17 00:00:00 2001 From: Petro Karashchenko Date: Thu, 27 Jan 2022 16:32:39 +0200 Subject: [PATCH] romfsimg: add attribute to set minimum 4 bytes aignment for romfs image data Signed-off-by: Petro Karashchenko --- 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 9ff6c8a57..1ade3b106 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 " >$@ && \ + 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 a71102c95..248067f18 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 " >$@ && \ + 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 5b867d8e4..b14d2f74b 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 " >$@ && \ + 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 9b6e2850c..45008e5e1 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 " >$@ && \ + 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 4c465adc9..734944203 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 " >$@ && \ + 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 91d6c7bde..eeb241bba 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 " >$@ && \ + 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 7649f1876..906a5c0fe 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 " >$@ && \ + 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 e7ae00932..fde95c965 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 ' >${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}