2015-03-31 05:32 AM
I have a bootloader which needs to read an 8 byte char array from the application area to identify it's version information.
So bootloader is located at 0x08000000Application firmware at : 0x08020000the char array will look something like this:const char software_versions[] = ''AB1234XY'';I need the char array to be at a fixed location in the application section so the bootloader always knows where to point.Is it as simple as:const char software_versions[] __attribute((at(0x08021000)) = ''AB1234XY'';or is there a neater way so fixed variables could have own section before main maybe. I'm not too well up on scatter files.2015-04-03 03:03 AM
Sorry to be answering my own question but this might help someone else.
I found two methods to do what I wanted. Editing the startup .s file.DCD FPU_IRQHandler ; FPU
DCD 0x0000000D
; Revision
DCB ''XYa0104b'' ; Version String
__Vectors_End
__Vectors_Size EQU __Vectors_End - __Vectors
This method just added the require fixed data to the end of the vector table. If you check the map file you can find the__Vectors_End address so you know the location of your data.
The second method also requires you to know where the__Vectors_End address is (for my device STM32F4 vector end address is 0x08000188, 0x08020188 when using bootloader in first sector). Then you can use:
const unsigned int map_rev __attribute__((at(0x08020188))) = 13;
const unsigned char code_rev[] __attribute__((at(0x0802018C))) = ''XYa0104b'';
somewhere in you code. You will need to keep the memory use word aligned. So use int for variables and if placing strings make sure is multiple of 4.
You can then access the data using:
uint8_t my_rev = (*(const uint8_t *)((uint32_t)0x08020188));
if just want the fist byte of the map_rev
uint32_t other_rev = (*(const uint32_t *)((uint32_t)0x08020188));
to grab the whole word. Do the same for the string, just read and assign each byte individually.
So looks like no need to start playing around with scatter files. I think this method is safe? Anyone any thoughts?2015-04-03 03:39 AM
Since I believe to recognise Keil syntax in your examples, I'd like to point you to the
. You probably get much more response from people with first-hand knowledge of the Keil toolchain, including employees. There is rarely enother forum in the embedded realm with less participation of the owner company's employees as this one here.2015-04-03 03:44 AM
2015-04-03 04:37 AM
You right, the ST participation is quite lackluster which is a real shame.
I sense some schizophrenia at ST's side here. On one side, they attract hobbyists and students with cheap boards and free tools, and on the other side, they let them ''fight out'' their issues with ST's tools among themselves. Put away two or three volunteering main posters (like clive1), and this forum is in effect dead ...