Skip to main content
Associate II
February 23, 2024
Question

Include a bin file to my project

  • February 23, 2024
  • 2 replies
  • 2390 views

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

2 replies

Tesla DeLorean
Guru
February 23, 2024

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 VenmoUp vote any posts that you find helpful, it shows what's working..
ElmoftyAuthor
Associate II
February 24, 2024

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

ElmoftyAuthor
Associate II
February 24, 2024

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

Tesla DeLorean
Guru
February 24, 2024

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 VenmoUp vote any posts that you find helpful, it shows what's working..