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.

[参考译文] UCD3138:将自定义 BL 跳转到主 FW 的正确方法

Guru**** 2539500 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/power-management-group/power-management/f/power-management-forum/1120551/ucd3138-proper-way-to-jump-form-custom-bl-to-main-fw

器件型号:UCD3138

您好!

我查看了 TI 定制 BL 示例、并在 TI 示例中配置了我的 AS:

链接器文件:

PVECS1         : org = 0x00000800, len = 0x00000004    /* copy of vector table for main FW */
.
.

.pvectors1     : {} > PVECS1
.
.

加载 asm 文件:

.global _user_main
.
.

.sect ".pvectors1"
.state32
_user_main

然后在 main.c 中,我声明函数: void user_main (void);我只需调用它跳转到 main FW:user_main();  

针对它的 asm 输出是正确的、但不是完美的(B 可用于代替 BL)、_user_main 常数也被正确定义为0x800:  

	.dwpsn	file "../main.c",line 64,column 13,is_stmt,isa 1
$C$DW$41	.dwtag  DW_TAG_TI_branch
	.dwattr $C$DW$41, DW_AT_low_pc(0x00)
	.dwattr $C$DW$41, DW_AT_name("_user_main")
	.dwattr $C$DW$41, DW_AT_TI_call
        BL        _user_main            ; [] |64| 
        ; CALL OCCURS {_user_main }      ; [] |64| 

我收到了常规警告: 警告#10441-D:生成符号"_user_main"的 trampoline、该符号位于不可执行段中

但链接器不想将其组合在一起: user_main();就像调用 nop 一样:它不做任何事情。 我可以使用标准 C hack 跳转到主固件: ((void (*)(void)) 0x800)();

奇怪的是、将常规中断转发到主 FW 工作正常:

linker:
PVECS2         : org = 0x00000804, len = 0x00000004    /* Vector table                */
.
.

.pvectors2       : {} > PVECS2
.
.

asm:
.sect ".bvectors"
.state32
B		b_int00					;after reset jump to BL main
B		vec_2					;forward interrupt to main FW
.
.
.

.sect ".pvectors2"
.state32
vec_2

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    Tomasz、链接器会执行各种智能操作、例如处理从 ARM 模式切换到 Thumb 模式以及删除未生成的函数。  我想知道这样的东西是否会弄乱它。  我查看了我的其中一个代码、我所做的就是输入如下内容:

    asm (".global _user_main");

    asm (" B _user_main");

    这样、您实际上就有一个标签。  当然、您需要确保在 ARM 模式下调用它。

    执行编译器并非真正设计的操作时、通常会很混乱。   

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    由于  main.c 的 thumb 代码状态,调用 USER_MAIN()可能会失败  

    我无法使您的 asm 命令正常工作、但我确实进行了很好的绕车演示、以使其从 C:

    我在我的第一个帖子中向包含跳转到主固件的32位状态文件添加了4字节段:

      全局_TO_USER_PROGRAM
      .sect ".jump 至_user_program"
      .state32.
    _至_用户_程序
      b _user_main

    然后在 main.c 中: void to _user_program (void);并运行它 to _user_program ();我相信 这样的链接器会切换到 ARM 模式 并执行跳转、因为 直接调用 asm 函数 具有明确的目标