-
Hello, I am working on creating a static cFS executable and trying to get a file to be embedded into the executable from the host. I modified 'targets.cmake' and added the file via the EMBED_FILELIST directive. From what I understand the file should now be stored in a C structure and then linked into the binary. My question now is, how can I access the file I linked? My plan is to read it and store it into my RAM based file system. The line I added: Sorry if I misunderstood what EMBED_FILELIST does but I couldn't find much info, any help will be appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
After a lot of digging and trying to understand the cmake and source code and how it all interacts - I figured out the answer. Strangely, this is not documented anywhere I could find, so here are the steps I took to make this work: 1- You need to add the file first in "sample_defs" folder, prefix it with "cpu1_". In this example it'll be "cpu1_mytestfile.txt" 2- In "targets.cmake" add the line "SET(cpu1_EMBED_FILELIST mytestfile,mytestfile.txt)" 3- You will then need to modify two files, "target_config.h" and "target_config.c", both can be found under "cFS/cfe/cmake/target/" 4- In "target_config.h", you will need to add a new struct similar to this and extern it:
5- In "target_config.c" you will need to define the variables cmake will store the data into, which should simply be the file name with _DATA and _SIZE like so:
Once all that is done, rebuild and you should now be able to get the data by simply accessing the GLOBAL_HOSTFILE struct. Not sure if this is the ideal way but it works. Hope it helps. |
Beta Was this translation helpful? Give feedback.
After a lot of digging and trying to understand the cmake and source code and how it all interacts - I figured out the answer.
Strangely, this is not documented anywhere I could find, so here are the steps I took to make this work:
1- You need to add the file first in "sample_defs" folder, prefix it with "cpu1_". In this example it'll be "cpu1_mytestfile.txt"
2- In "targets.cmake" add the line "SET(cpu1_EMBED_FILELIST mytestfile,mytestfile.txt)"
3- You will then need to modify two files, "target_config.h" and "target_config.c", both can be found under "cFS/cfe/cmake/target/"
4- In "target_config.h", you will need to add a new struct similar to this and extern it: