Hi,
Can someone give your suggestion ?
Create an assembler file (.s) and include something like this. The variable mydata and mydata_size are used to reference your binary data. Of course, these can be called anything that you want.
.section rodata
.global mydata
.type mydata, @object
.align 4
mydata:
.incbin "data.bin"
.global mydata_size
.type mydata_size, @object
.align 4
mydata_size:
.int mydata_size - mydata
Hi
When I use object
i.e .type mydata_size, @object
.type mydata, @object
I get the following error
../src/aaa.s:11: Error: unrecognized symbol type " "
Can someone help me to solve the error explain with an example?
use
.type mydata, "object"
instead. The @ symbol is a comment, so it ignored the following text in my original example.
in C you want to use
extern int mydata, mydata_size ;
and then use &mydata for the start address of your data and mydata_size as the length of your data
Hi,
I have tried that like below,
1. Created an assembly file and included the data as below
.section rodata
.global mydata
.type mydata, "object"
.align 4
mydata:
.incbin "blinky.bin"
.global mydata_size
.type mydata_size, "object"
.align 4
mydata_size:
.int mydata_size - mydata
NOTE : blinky.bin is my bin file with 3276 bytes in size
2. I have used the below in main .c file
extern int mydata,mydata_size;
static const int *ata ;
unsigned char flash[20];
int main(void) {
ata = &mydata;
memcpy(&flash, ata, 16);
}
It is building without error and warning.
here i am trying to copy of first 16 bytes of ata's data into array flash but is giving some wrong data.
i.e.
I have opened the blinky.bin file using HEX editor NEO. It is having values like below (shown first 16 bytes only)
00 98 00 20 a5 04 00 20 ad 04 00 20 c5 04 00 20 but it is not matching with the values of array flash which was copied by ata (pointed by address of mydata).
3.
Without adding bin file (assembly file is not added), it shows the below at console tab.
make --no-print-directory post-build
Performing post-build steps
arm-none-eabi-size "ProxM_GTL.axf"; # arm-none-eabi-objcopy -v -O binary "ProxM_GTL.axf" "ProxM_GTL.bin" ; # checksum -p LPC54101J512 -d "ProxM_GTL.bin";
text data bss dec hex filename
13148 0 408 13556 34f4 ProxM_GTL.axf
After Adding bin file (added of assembly file), it shows the below at console tab.
make --no-print-directory post-build
Performing post-build steps
arm-none-eabi-size "ProxM_GTL.axf"; # arm-none-eabi-objcopy -v -O binary "ProxM_GTL.axf" "ProxM_GTL.bin" ; # checksum -p LPC54101J512 -d "ProxM_GTL.bin";
text data bss dec hex filename
13148 0 408 13556 34f4 ProxM_GTL.axf
My questions are ,
1. Whether i missed anything there in section 1&2 ? if it is correct what i have to do next ?
2. is there any other ways to complete this?
3. In section 3, both ways hex file size (34f4) was same, but I think it should be greater of 3276 in the bin file added project , is it correct or bin file is not included?
Perhaps you could post your project (export it, and attach the zip file to your post) so we can see what you are missing.
You project, as supplied, works perfectly. The contents of the "flash" array is exactly the same as the first 20 bytes of the binary image.
What do you think is wrong?
Hi ,
Thank you ...
it is working if i block .section rodata in the assembler file, then .section rodata line is required or not
Hi,
Thanks to your reply
I have followed your instructions and have some doubts.
My questions are
1. what do you mean object in both mydata & mydata_size ?
2. how can I utilise those in main.c file to retrieve bin file datas?
3. Can you explain that with an example?
Hi,
I am using LPCXpresso_8.1.0_597 and LPC54102 board.
I am also in the same situation like above but not able to find the answer.
my questions are
1. how do i create assembler file ?
2. How do i use .incbin directives? or .incbin is available anywhere in the project directory?
3. where i have to define labels of my bin file?
I have seen & understand the below descriptions from help but i don't know how to use this
Incbin - Using as
.incbin "
file"[,
skip[,
count]]
The incbin
directive includes file verbatim at the current location. You can control the search paths used with the ‘-I’ command-line option (see Command-Line Options). Quotation marks are required around file.
The skip argument skips a number of bytes from the start of the file. The count argument indicates the maximum number of bytes to read. Note that the data is not aligned in any way, so it is the user's responsibility to make sure that proper alignment is provided both before and after the incbin
directive
Please guide me in a proper direction