cancel
Showing results for 
Search instead for 
Did you mean: 

Include a bin file to my project

Elmofty
Associate II

Hello to all

i have build my project as programmer on stm32f103c8t6 to connect as master host to slave one stm32f103c8t6 and program the slave device with code which saved in eeprom connected to the master with i2c it working well with me but I need to remove the eeprom and link the file to the master host programmer as a part of the code generate

5 REPLIES 5

In a .s file (assembler source)

.section .databin
.incbin "data.bin"

In the .ld file (linker script)

.data : {

*(.databin*)

}

 

Or export/dump formatted as a uint8_t array, and add that to your code, or as an include file.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Elmofty
Associate II

MAY BE YOU NOT UNDERSTAND ME I WANT TO ADD EXTERNAL BIN FILE TO INCLUDE IN THE CODE SO WHEN I COMPILING THE CODE IT GENERATE THE CODE WITH THIS BIN FILE AS APART OF THE CODE

FOR EXAMPLE I WANT TO FILE CALL Slave.bin TO INCLUDE TO MY CODE  FROM ADDRESS 0X800F000

THIS FILE SIZE 2048 BYTE

now i add 

.section .databin

.incbin "Slave.bin" at the end of the file /Startup/startup_stm32f103c8tx.s and compile it got the bin file at the code and i can find it but t need an option to set fixed start address in the flash for this file

Reduce one of the MEMORY sections in the Linker Script, and create another describing the region you want the .BIN data to live, and then drive that data into that section

.data : {

*(.databin*)

} >BINFLASH

 

Also please try not to post in ALL-CAPS, this is generally frowned upon in email and forum communications.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Hi!

 

I had the same problem as Elmofty, but I couldn't fix the starting address of the .bin file in the flash using only Tesla's last tip.

 

So, I did the following to make it work:

 

- I added it to the end of the file "startup_stm32********.s" :

 

.section .data_Prog_00,"a",%progbits

.type PROGRAM_00, %object

.size PROGRAM_00, .-PROGRAM_00

PROGRAMA_00:

.incbin "program.bin"

 

- in the file "STM32********_FLASH.ld" :

 

The flash was set like this:

 

FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2048K

 

So I reduced the flash and created the section Prog_00:

 

FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 2016K

Prog_00 (rx) : ORIGIN = 0x081F8000, LENGTH = 32K

 

Then include the code below to position the .bin file at the beginning of the section Prog_00:

 

.data_Prog_00 :

{

. = ALIGN(4);

KEEP(*(.data_Prog_00))

. = ALIGN(4);

} >Prog_00