From 08083d3b2e23b721221693987e8267a0a314121e Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 20 Mar 2018 08:44:16 -0600 Subject: [PATCH] apps/examples/cromfs: Add an example of how to build a CROMFS file system image. --- examples/cromfs/.gitignore | 13 +++ examples/cromfs/Kconfig | 19 ++++ examples/cromfs/Make.defs | 39 +++++++ examples/cromfs/Makefile | 104 ++++++++++++++++++ examples/cromfs/cromfs/BaaBaaBlackSheep.txt | 8 ++ examples/cromfs/cromfs/JackSprat.txt | 4 + .../cromfs/cromfs/testdir1/DingDongDell.txt | 11 ++ .../cromfs/testdir1/SeeSawMargorieDaw.txt | 8 ++ .../cromfs/testdir2/HickoryDickoryDock.txt | 5 + .../cromfs/testdir2/TheThreeLittlePigs.txt | 17 +++ .../cromfs/cromfs/testdir3/JackBeNimble.txt | 9 ++ 11 files changed, 237 insertions(+) create mode 100644 examples/cromfs/.gitignore create mode 100644 examples/cromfs/Kconfig create mode 100644 examples/cromfs/Make.defs create mode 100644 examples/cromfs/Makefile create mode 100644 examples/cromfs/cromfs/BaaBaaBlackSheep.txt create mode 100644 examples/cromfs/cromfs/JackSprat.txt create mode 100644 examples/cromfs/cromfs/testdir1/DingDongDell.txt create mode 100644 examples/cromfs/cromfs/testdir1/SeeSawMargorieDaw.txt create mode 100644 examples/cromfs/cromfs/testdir2/HickoryDickoryDock.txt create mode 100644 examples/cromfs/cromfs/testdir2/TheThreeLittlePigs.txt create mode 100644 examples/cromfs/cromfs/testdir3/JackBeNimble.txt diff --git a/examples/cromfs/.gitignore b/examples/cromfs/.gitignore new file mode 100644 index 000000000..9abe6fec2 --- /dev/null +++ b/examples/cromfs/.gitignore @@ -0,0 +1,13 @@ +/Make.dep +/.depend +/.built +/*.asm +/*.obj +/*.rel +/*.lst +/*.sym +/*.adb +/*.lib +/*.src +/cromfs.c + diff --git a/examples/cromfs/Kconfig b/examples/cromfs/Kconfig new file mode 100644 index 000000000..6c24a914c --- /dev/null +++ b/examples/cromfs/Kconfig @@ -0,0 +1,19 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +config EXAMPLES_CROMFS + bool "CROMFS Example" + default n + depends on FS_CROMFS && BUILD_FLAT + ---help--- + Enable the CROMFS loader example + + NOTE: This example simple creates a CROMFS image. There is no + program to be executed. If properly constructed, it should provide + the in-memory, compressed file system image used by the CROMFS file + system. + + NOTE: Since this example does export symbols used with the OS, it + can only be used in the FLAT build mode. diff --git a/examples/cromfs/Make.defs b/examples/cromfs/Make.defs new file mode 100644 index 000000000..6b7e82bd2 --- /dev/null +++ b/examples/cromfs/Make.defs @@ -0,0 +1,39 @@ +############################################################################ +# apps/examples/cromfs/Make.defs +# Adds selected applications to apps/ build +# +# Copyright (C) 2018 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +ifeq ($(CONFIG_EXAMPLES_CROMFS),y) +CONFIGURED_APPS += examples/cromfs +endif diff --git a/examples/cromfs/Makefile b/examples/cromfs/Makefile new file mode 100644 index 000000000..8b976669e --- /dev/null +++ b/examples/cromfs/Makefile @@ -0,0 +1,104 @@ +############################################################################ +# apps/examples/cromfs/Makefile +# +# Copyright (C) 2012 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +-include $(TOPDIR)/.config +-include $(TOPDIR)/Make.defs +include $(APPDIR)/Make.defs + +# CROMFS Example + +CSRCS = cromfs.c +COBJS = $(CSRCS:.c=$(OBJEXT)) + +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else +ifeq ($(WINTOOL),y) + BIN = ..\\..\\libapps$(LIBEXT) +else + BIN = ../../libapps$(LIBEXT) +endif +endif + +NXTOOLDIR = $(TOPDIR)/tools +GENCROMFSSRC = gencromfs.c +GENCROMFSEXE = gencromfs$(EXEEXT) +ROOTDEPPATH = --dep-path . + +# Build targets + +VPATH = . + +all: .built +.PHONY: clean depend distclean preconfig +.PRECIOUS: ../../libapps$(LIBEXT) + +$(COBJS) : %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +$(NXTOOLDIR)$(DELIM)$(GENCROMFSEXE): $(NXTOOLDIR)$(DELIM)$(GENCROMFSSRC) + $(Q) $(MAKE) -C $(NXTOOLDIR) -f Makefile.host $(GENCROMFSEXE) + +cromfs.c: $(NXTOOLDIR)$(DELIM)$(GENCROMFSEXE) + $(Q) $(NXTOOLDIR)$(DELIM)$(GENCROMFSEXE) cromfs cromfs.c + +.built: cromfs.c $(COBJS) + $(call ARCHIVE, $(BIN), $(COBJS)) + @touch .built + +install: + +context: + +# We can't make dependencies in this directory because the required +# header files may not yet exist. + +.depend: + @touch $@ + +depend: .depend + +clean: + $(call DELFILE, .built) + $(call CLEAN) + +distclean: clean + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) + $(call DELFILE, cromfs.c) + +preconfig: + +-include Make.dep diff --git a/examples/cromfs/cromfs/BaaBaaBlackSheep.txt b/examples/cromfs/cromfs/BaaBaaBlackSheep.txt new file mode 100644 index 000000000..d6acebe40 --- /dev/null +++ b/examples/cromfs/cromfs/BaaBaaBlackSheep.txt @@ -0,0 +1,8 @@ +Baa, baa, black sheep, +Have you any wool? +Yes sir, yes sir, +Three bags full; +One for the master, +And one for the dame, +And one for the little boy +Who lives down the lane. diff --git a/examples/cromfs/cromfs/JackSprat.txt b/examples/cromfs/cromfs/JackSprat.txt new file mode 100644 index 000000000..71487131c --- /dev/null +++ b/examples/cromfs/cromfs/JackSprat.txt @@ -0,0 +1,4 @@ +Jack Sprat could eat no fat, +His wife could eat no lean, +And so betwixt the two of them +They licked the platter clean diff --git a/examples/cromfs/cromfs/testdir1/DingDongDell.txt b/examples/cromfs/cromfs/testdir1/DingDongDell.txt new file mode 100644 index 000000000..fe4920bf5 --- /dev/null +++ b/examples/cromfs/cromfs/testdir1/DingDongDell.txt @@ -0,0 +1,11 @@ +Ding, dong, bell, +Pussy's in the well. +Who put her in? +Little Johnny Green. + +Who pulled her out? +Little Tommy Stout. +What a naughty boy was that, +To try to drown poor pussy cat, +Who never did him any harm, +And killed the mice in his father's barn. diff --git a/examples/cromfs/cromfs/testdir1/SeeSawMargorieDaw.txt b/examples/cromfs/cromfs/testdir1/SeeSawMargorieDaw.txt new file mode 100644 index 000000000..c5763f495 --- /dev/null +++ b/examples/cromfs/cromfs/testdir1/SeeSawMargorieDaw.txt @@ -0,0 +1,8 @@ +See, saw, Marjorie Daw, +Jennie shall have a new master. +She shall have but a penny a day, +because she can't work any faster. +See, saw, Marjorie Daw, +Jimmy shall have a new master. +He shall have but a penny a day, +because he can't work any faster. diff --git a/examples/cromfs/cromfs/testdir2/HickoryDickoryDock.txt b/examples/cromfs/cromfs/testdir2/HickoryDickoryDock.txt new file mode 100644 index 000000000..a337f4ca7 --- /dev/null +++ b/examples/cromfs/cromfs/testdir2/HickoryDickoryDock.txt @@ -0,0 +1,5 @@ +Hickory, dickory, dock, +The mouse ran up the clock. +The clock struck one, +The mouse ran down! +Hickory, dickory, dock. diff --git a/examples/cromfs/cromfs/testdir2/TheThreeLittlePigs.txt b/examples/cromfs/cromfs/testdir2/TheThreeLittlePigs.txt new file mode 100644 index 000000000..0761a54f4 --- /dev/null +++ b/examples/cromfs/cromfs/testdir2/TheThreeLittlePigs.txt @@ -0,0 +1,17 @@ +Once upon a time there were three little pigs and the time came for them to leave home and seek their fortunes. Before they left, their mother told them " Whatever you do , do it the best that you can because that's the way to get along in the world. + +The first little pig built his house out of straw because it was the easiest thing to do. The second little pig built his house out of sticks. This was a little bit stronger than a straw house. The third little pig built his house out of bricks. + +One night the big bad wolf, who dearly loved to eat fat little piggies, came along and saw the first little pig in his house of straw. He said "Let me in, Let me in, little pig or I'll huff and I'll puff and I'll blow your house in!" "Not by the hair of my chinny chin chin", said the little pig. But of course the wolf did blow the house in and ate the first little pig. + +The wolf then came to the house of sticks. "Let me in ,Let me in little pig or I'll huff and I'll puff and I'll blow your house in" "Not by the hair of my chinny chin chin", said the little pig. But the wolf blew that house in too, and ate the second little pig. + +The wolf then came to the house of bricks. " Let me in , let me in" cried the wolf "Or I'll huff and I'll puff till I blow your house in" "Not by the hair of my chinny chin chin" said the pigs. Well, the wolf huffed and puffed but he could not blow down that brick house. + +But the wolf was a sly old wolf and he climbed up on the roof to look for a way into the brick house. + +The little pig saw the wolf climb up on the roof and lit a roaring fire in the fireplace and placed on it a large kettle of water. + +When the wolf finally found the hole in the chimney he crawled down and KERSPLASH right into that kettle of water and that was the end of his troubles with the big bad wolf. + +The next day the little pig invited his mother over . She said "You see it is just as I told you. The way to get along in the world is to do things as well as you can." Fortunately for that little pig, he learned that lesson. And he just lived happily ever after! \ No newline at end of file diff --git a/examples/cromfs/cromfs/testdir3/JackBeNimble.txt b/examples/cromfs/cromfs/testdir3/JackBeNimble.txt new file mode 100644 index 000000000..0fbd338e1 --- /dev/null +++ b/examples/cromfs/cromfs/testdir3/JackBeNimble.txt @@ -0,0 +1,9 @@ +Jack, be nimble, +Jack, be quick, +Jack, jump over +The candlestick. + +Jack jumped high +Jack jumped low +Jack jumped over +and burned his toe.