I'm trying to preinit my MCU's OPTION_BYTE to create a binary with the OPTION_BYTE allready set ! This work fine with a assembly file in Ride7 with raisonnance compiler, but now i'm trying to do the same thing with ST Visual Develop and Cosmic compiler but I don't work ! Of course a find pseudo-solution, but I want a solution without modifying the linker command file (this isn't a profesionnal solution !) I don't agree with the other solution trough STVP, because my code will be shared I prefer something in a assembly file or C source to avoid mistake instead of a extra manipulation ! And I prefer something who work in debug mode too ! Please help me !
Thanks but I found by myself what i'm looking for !
Here is my code : #pragma section const {OptionByte} const struct OPT_struct OPTION_BYTE = {0x00, 0x00, 0xFF, 0x02, 0xFD, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF}; #pragma section () You need to add this new section in your lkf file, forget hand modification, goto Project -> Settings -> Linker -> Category : Input Add a Segment and add a sub section, enter address of start and end. Set the option of the section to -k to avoid linker optimisation, the linker will keep this unused section. The final binary fille will include the OPTION_BYTE set according to your need !