This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

(总结)使用BIOS把某个函数放到固定地址的方法。

Other Parts Discussed in Thread: TPS65218

首先在你的函数声明的时候加入修饰符如下:

int __attribute__ ((section (".myEntryPoint"))) tps65218_voltage_update(I2C_Handle handle, uint8_t dc_cntrl_reg, uint8_t volt_sel)
{

.....

}

在你的工程里新加一个.cmd文件,一个工程可以有多个CMD文件,注意不要冲突。

在BIOS下会自动生成在debug/configPkg/linker.cmd,注意你的cmd不要和这个系统自动生成的重复或者冲突。我的例子如下

MEMORY

{

TEST : org = 0x88000000, len = 0x1000000
}

SECTIONS {

.myEntryPoint : {
KEEP (*(.myEntryPoint))
} > TEST

}

编译后查看.map文件可以看到

.myEntryPoint 0x88000000 0x100
*(.myEntryPoint)
.myEntryPoint 0x88000000 0xe4 ./pmic_tps65218.o
0x88000000 tps65218_voltage_update
*fill* 0x880000e4 0x4
.myEntryPoint.__stub
0x880000e8 0x18 linker stubs

tps65218_voltage_update这个函数就被放到了0x88000000位置了。