Sysprogs forums › Forums › VisualGDB › How introduce file in the .bin file
- This topic has 1 reply, 2 voices, and was last updated 11 years ago by
support.
-
AuthorPosts
-
July 20, 2015 at 06:45 #6707
andrei0686
ParticipantHello. I want to use visualGBD and try to resolve some issues.
I need to insert an external file in .bin file at the specified address to access it from the program. For example a picture or file .css. in IAR is done with the aid of the linker configuration file .icf.
1) set .icf file
define symbol __ICFEDIT_region_APP_start__ = 0x00020100;
define symbol __ICFEDIT_region_APP_end__ = 0x0007FFFF;define region APP_region = mem:[from __ICFEDIT_region_APP_start__ to __ICFEDIT_region_APP_end__];
define region APP_region = mem:[from __ICFEDIT_region_APP_start__ to __ICFEDIT_region_APP_end__];
place in APP_region {readonly section favicon.ico};
place in APP_region {readonly section MasterPage.html};
place in APP_region {readonly section style.css};2) set project options -> Linker -> Extra Options
–keep __favicon.ico
–image_input $PROJ_DIR$\WebPages\html\favicon.ico,__favicon.ico,favicon.ico,4
–keep __MasterPage.html
–image_input $PROJ_DIR$\WebPages\html\MasterPage.html,__MasterPage.html,MasterPage.html,4
–keep __style.css
–image_input $PROJ_DIR$\WebPages\html\style.css,__style.css,style.css,43) Use in code:
#pragma section = “favicon.ico”
/**/
bool GetFavIcon(http_t* http)
{
http_writen(http, (const char*)__section_begin(“favicon.ico”), __section_size(“favicon.ico”) );
http_writen(http, “\r\n\r\n”, sizeof(“\r\n\r\n”) );
return true;
}whether it is possible to do something like?
-
This topic was modified 11 years ago by
andrei0686.
-
This topic was modified 11 years ago by
andrei0686.
-
This topic was modified 11 years ago by
andrei0686.
July 23, 2015 at 19:54 #6731support
KeymasterYou can achieve this by adding a section to the linker script (see this post for details) and then using a script to convert your binary file to a .c file like this:
__attribute__((section(“.mysection”))) const unsigned char MyFile1[] = {0xXX, 0xYY, … };
Do not forget to use the KEEP statement in the linker script file, otherwise the MyFile1 variable will be optimized out.
You can define labels before and after the section contents and then reference those labels similar to _sdata and _edata (see the startup file for an example).
You can also use objcopy as described here to convert your binary files to object files. This will be equivalent to making a .c file as described above and compiling it to a .o file.
-
This topic was modified 11 years ago by
-
AuthorPosts
- You must be logged in to reply to this topic.