简体   繁体   English

使用jtag编程sam4e时如何防止启动区域

[英]how to prevent boot region when program the sam4e using jtag

I am using at91sam4e16e and working on bootloader. 我正在使用at91sam4e16e并正在使用引导程序。 boot region is defined at 0x400000 and application region is at 0x420000 onwards. 引导区域定义为0x400000,应用程序区域定义为0x420000起。

i have downloaded bootloader code into that region and compiled application code with 0x420000 link address. 我已将Bootloader代码下载到该区域,并使用0x420000链接地址编译了应用程序代码。 now I want to download that application to 0x420000 using Jtag but when I download it, all the memory goes erased and only application remains. 现在我想使用Jtag将该应用程序下载到0x420000,但是当我下载它时,所有内存都将被擦除,仅剩下应用程序。

In avr, I could prevent the boot area in debugger option; 在AVR中,我可以在调试器选项中阻止引导区; How to do the same in sam4e? 如何在sam4e中做同样的事情?

regards, shreyas. 问候,shreyas。

Go to project options. 转到项目选项。

In Debugger -> Images you can download extra image. Debugger -> Images您可以下载额外的图像。

Note that I have only used this with the Debug info only -option enabled, but I have bundled bootloader with my app, so it is a bit different situation. 请注意,我仅在启用了“ Debug info only -option的情况下使用此功能,但是我将Bootloader与我的应用程序捆绑在一起,因此情况有些不同。 (You can bundle bootloader in Linker -> Input tab.) (您可以在引导程序Linker -> Input选项卡中捆绑引导程序。)

I also had a problem that since application wasn't in normal starting location, I had to initialize program counter, and stack pointer registers manually. 我还遇到一个问题,因为应用程序不在正常的起始位置,所以我必须初始化程序计数器,并手动堆栈指针寄存器。 You can do this by defining a macro file in Debugger -> Setup . 您可以通过在Debugger -> Setup定义一个宏文件来实现。

Macro file could look like this (note that this is for different MCU, so you may have different registers/addresses): 宏文件可能如下所示(请注意,这是针对不同的MCU的,因此您可能具有不同的寄存器/地址):

execUserReset() 
{
    // Set the stack pointer
    MSP = *(int*)0x00008000; 
    // Set the program counter
    PC = *(int*)0x00008004; 
}

This macro file skips bootloader when using debugger reset, but you could also make macro file which enters bootloader on reset by using different addresses. 使用调试器重置时,此宏文件会跳过引导程序,但是您也可以使宏文件在重置时通过使用不同的地址进入引导程序。

Edit: Bundling the bootloader: 编辑:捆绑引导程序:

It's been a while since I have done this, so hopefully I remember everything. 自从我这样做已经有一段时间了,所以希望我能记住一切。

You need to add your bootloader .bin file to Linker -> Input -> Raw binary image . 您需要将Bootloader .bin文件添加到Linker -> Input -> Raw binary image Also define symbol bootloader , and section .bootloader . 还定义符号bootloader.bootloader部分。 (I think alignment needs to be specified too, even if you use absolute placement.) (我认为即使您使用绝对放置,也需要指定对齐方式。)

Add your bootloader symbol to Keep symbols: box above. 在上方的“ Keep symbols:框中添加您的bootloader符号。 This should make sure that bootloader is always included. 这应确保始终包含引导加载程序。

In your linker file, add line 在链接器文件中,添加行

place at address mem:0x00000000 { section .bootloader };

to place bootloader at specific address (change address to match your bootloader address). 将引导加载程序放置在特定地址(更改地址以匹配您的引导加载程序地址)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM