1 |
786 |
skrzyp |
MK_ROMFS - Make a ROMFS image
|
2 |
|
|
=============================
|
3 |
|
|
|
4 |
|
|
This program creates a ROMFS image that can be read by eCos.
|
5 |
|
|
|
6 |
|
|
mk_romfs - Create an eCos ROMFS disk image from the files
|
7 |
|
|
contained under a specified directory
|
8 |
|
|
|
9 |
|
|
Usage: ../support/mk_romfs [options]
|
10 |
|
|
fs_root is the directory containing the files to package into the ROMFS image
|
11 |
|
|
fs_file is the name of the ROMFS image file to create
|
12 |
|
|
Options include:
|
13 |
|
|
-v / -q increase / decrease verbosity
|
14 |
|
|
-n do everything EXCEPT creating the output file
|
15 |
|
|
-b write a big-endian image (default is little endian)
|
16 |
|
|
-l collapse hard links to a single node
|
17 |
|
|
|
18 |
|
|
-----------
|
19 |
|
|
How to use.
|
20 |
|
|
-----------
|
21 |
|
|
|
22 |
|
|
For example, suppose you wish to access the following directories and files:
|
23 |
|
|
/
|
24 |
|
|
/etc passwd, group
|
25 |
|
|
/dev
|
26 |
|
|
/mnt
|
27 |
|
|
/tmp (for a RAMFS)
|
28 |
|
|
/var (for a RAMFS)
|
29 |
|
|
|
30 |
|
|
1. Create the required directories and files under a suitable root, eg. under
|
31 |
|
|
~/rom:
|
32 |
|
|
$ mkdir ~/rom
|
33 |
|
|
$ cd ~/rom
|
34 |
|
|
$ mkdir etc dev mnt tmp var
|
35 |
|
|
$ cp /etc/passwd /etc/group etc/
|
36 |
|
|
( remembering to edit these files....;-)
|
37 |
|
|
|
38 |
|
|
2. Make the romfs image in a suitable place, eg /tftpboot for direct upload to
|
39 |
|
|
the RedBoot monitor.
|
40 |
|
|
$ mk_romfs -v . /tftpboot/romfs.img
|
41 |
|
|
mk_romfs: Verbosity 2 little endian
|
42 |
|
|
Phase 1 - Build file list
|
43 |
|
|
Phase 2 - Calculate space allocation
|
44 |
|
|
Phase 2a - * Directories
|
45 |
|
|
Phase 2b - * Regular files
|
46 |
|
|
Phase 2c - * Executable files
|
47 |
|
|
Phase 3 - Construct ROMFS image file (3 kb)
|
48 |
|
|
Phase 3a - * Node table
|
49 |
|
|
Phase 3b - * Data blocks
|
50 |
|
|
/tftpboot/romfs.img completed
|
51 |
|
|
|
52 |
|
|
3. Connect to your target RedBoot monitor, and load the romfs image. You will
|
53 |
|
|
need to determine a suitable place in RAM to load the image into.
|
54 |
|
|
$ telnet xxx.xxx.xxx.xxx 1000
|
55 |
|
|
Trying xxx.xxx.xxx.xxx...
|
56 |
|
|
Connected to xxx.xxx.xxx.xxx.
|
57 |
|
|
Escape character is '^]'.
|
58 |
|
|
RedBoot> load romfs.img -r -v -b 0x1000000
|
59 |
|
|
Raw file loaded 0x01000000-0x0100093e
|
60 |
|
|
RedBoot>
|
61 |
|
|
|
62 |
|
|
4. Determine where to load the romfs image in the ROM. See what's there...
|
63 |
|
|
RedBoot> fis list
|
64 |
|
|
Name FLASH addr Mem addr Length Entry point
|
65 |
|
|
RedBoot 0x50000000 0x50000000 0x020000 0x00000000
|
66 |
|
|
RedBoot[backup] 0x50020000 0x50020000 0x020000 0x00000000
|
67 |
|
|
RedBoot config 0x503C0000 0x503C0000 0x020000 0x00000000
|
68 |
|
|
FIS directory 0x503E0000 0x503E0000 0x020000 0x00000000
|
69 |
|
|
RedBoot> fis free
|
70 |
|
|
0x50040000 .. 0x503C0000
|
71 |
|
|
RedBoot>
|
72 |
|
|
We can see that a suitable place would be 0x50040000.
|
73 |
|
|
Alternatively, you can let RedBoot determine the address itself...
|
74 |
|
|
|
75 |
|
|
5. Copy the image from RAM to ROM...
|
76 |
|
|
RedBoot> fis create -b 0x1000000 -l 0x940 RomFs
|
77 |
|
|
... Erase from 0x50040000-0x50040940: .
|
78 |
|
|
... Program from 0x01000000-0x01000940 at 0x50040000: .
|
79 |
|
|
... Erase from 0x503e0000-0x50400000: .
|
80 |
|
|
... Program from 0x01fd0000-0x01ff0000 at 0x503e0000: .
|
81 |
|
|
RedBoot> fis list
|
82 |
|
|
Name FLASH addr Mem addr Length Entry point
|
83 |
|
|
RedBoot 0x50000000 0x50000000 0x020000 0x00000000
|
84 |
|
|
RedBoot[backup] 0x50020000 0x50020000 0x020000 0x00000000
|
85 |
|
|
RedBoot config 0x503C0000 0x503C0000 0x020000 0x00000000
|
86 |
|
|
FIS directory 0x503E0000 0x503E0000 0x020000 0x00000000
|
87 |
|
|
RomFs 0x50040000 0x01000000 0x000940 0x00000000
|
88 |
|
|
RedBoot>
|
89 |
|
|
|
90 |
|
|
6. MAKE A NOTE OF THE ADDRESS IN FLASH THAT THE IMAGE IS LOADED AT.
|
91 |
|
|
|
92 |
|
|
This address can then be used in your program in order to mount the
|
93 |
|
|
filesystem.
|
94 |
|
|
|
95 |
|
|
For example, to automatically mount the new romfs created above at
|
96 |
|
|
/rom, you can use the following macro in your application:
|
97 |
|
|
|
98 |
|
|
MTAB_ENTRY( romfs_mte1,
|
99 |
|
|
"/rom",
|
100 |
|
|
"romfs",
|
101 |
|
|
"",
|
102 |
|
|
(CYG_ADDRWORD) 0x50040000 );
|
103 |
|
|
|
104 |
|
|
See the File I/O package documentation in the eCos Reference Manual
|
105 |
|
|
("Writing a New Filesystem") for more information about the MTAB_ENTRY
|
106 |
|
|
macro.
|
107 |
|
|
|
108 |
|
|
Alternatively, the filesystem can be dynamically mounted with a call
|
109 |
|
|
to mount() such as the following:
|
110 |
|
|
|
111 |
|
|
err = mount( "0x50040000", "/rom", "romfs" );
|