Andes Workshop

It is currently Wed Jun 20, 2018 12:58 am

All times are UTC + 8 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Specify a binary file to an absolute address by SaG
PostPosted: Tue May 15, 2018 4:52 pm 
Offline

Joined: Thu Jan 07, 2016 12:29 pm
Posts: 5
If we want to specify a binary file to an absolute address, we can burn the binary file to FLASH by burner or load the file to the RAM. Today I will introduce a new easier solution to achieve this purpose, and it can tell programmer the size of binary at the same time.
It is hard for linker to link the binary file to elf, but it can handle the object files(*.o). So we can use the ld tool to translate binary files to object files(*.bin—>*.o) with below command:
nds32le-elf-ld.exe -r -b binary -o binary.o binary.bin
Then we can use SaG to specify this binary.o to an absolute address:
FLASH 0x80000000 0x00100000
{
EXEC1 0x80000000 0x00100000
{
ADDR NEXT __bin_start
*binary.o (+RO,+RW)
ADDR __bin_end
}
}

The header of the elf file:
Attachment:
header_file.png
header_file.png [ 20.56 KiB | Viewed 63 times ]

And in the C code, we can invoke the start and end addresses and the size of the binary as follow:
extern unsigned char __bin_start, __bin_end;
unsigned int bin_size = &__bin_start - &__bin_end;


End...


Attachments:
demo-printf.tgz [610.03 KiB]
Downloaded 6 times
Top
 Profile Send private message E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group