Andes Workshop

Specify a binary file to an absolute address by SaG
Page 1 of 1

Author:  TangLei [ Tue May 15, 2018 4:52 pm ]
Post subject:  Specify a binary file to an absolute address by SaG

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:
header_file.png [ 20.56 KiB | Viewed 90 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;


demo-printf.tgz [610.03 KiB]
Downloaded 10 times

Page 1 of 1 All times are UTC + 8 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group