Hi,
Please let me ask the questions about the Advanced Boot loader and usage of SRAM related things on DA14583.
我们想为DA14583创建高级引导加载程序。我已经阅读了“UM-B-012”,但我想确认这些相关的东西。
Our Scenario:
- We write two application images(bin) on Flash. The size of both images are almost 32kB(ROM)/8kB(RAM). When each image is executed 40kB RAM would be consumed.
- 我们在Flash上分配1个字节标志,以选择应加载哪个图像。
- Advanced boot loader will check this flag and decide which one to boot.
Questions:
1. I suppose that Advanced Boot Loader is loaded to SysRAM and it would be executed (from 0x2000000). Size of Advanced Boot Loader is approximately 6KB. Are these right?
2. When Advanced Boot Loader loads an appriication image to RAM, are there any rooms to load? (An application image size is 40kB on RAM, but Advanced Boolt Loader have also consumed 6kB RAM…) Does it work well? Is our scenario achievable???
3. When Advanced Boot Loader loads an apprication image to SRAM, can we assign the address to be loaded on SRAM? Or, is it fixed?
4. When Advanced Boot Loader resets itself, can we set the entry address of Program Counter? or is it fixed?
Sorry for many questions, but we wouled like to confirm whether our scenario is possible or not.
Thank you very much for your supports in advance.
此致,
光盘
You should check out the boot loader project in the SDK. It is located in utilities\secondary_bootloader. It does almost exactly what you want. Two images are located on flash and the one selected to run is copied into SysRAM and is then started.
The size of the advanced boot loader is about 6 kb, depending how you configure it. It is loaded to SysRAM and executed from address 0x0. Note that when address 0x0 is remapped to SysRAM, address 0x0 is mapped to the same memory cell as 0x20000000.
When you create an image, you have two sizes, the actual size of the image and the RAM usage of the application. The amount of RAM needed by the application is initialized when the application starts and does therefore not take up any space in the image. The initial PC is chosen by the linker and placed at offset 0x4 in the image and should not be changed.
如果在高级引导加载程序(startup \ bootloader.sct)的散点图中,您将看到启动代码之外的所有内容都放在执行区域0x80000中。这意味着ARM链接器会生成代码,当高级引导加载程序启动时,所有引导加载程序代码都将复制到0x80000,然后从那里运行。这意味着Sysram现在可以使用最终应用程序填写引导加载程序。
When your final application is then started (32 kb), the linker-generated code of the application will initiate the RAM sections you have declared (8 kb) with zeros. That means if you have variables at address 0x80000 the initialization code will overwrite the boot loader which is ok since it is not needed anymore.
我不确定你的意思或想要在内存中的特定位置加载应用程序。臂处理器假设当调用复位处理程序时,它最初被放置在地址0x0处。所有中断处理程序也必须放在Sysram的开始工作。当然,您可以使用分散文件将功能和变量放在特定地址,如果您愿意。
Note that applications are however normally designed to be run from 0x20000000 rather than 0x0. This will also work, even if 0x0 is remapped to ROM since (almost) all ROM interrupt handlers are trampolines into the interrupt handlers at 0x20000000.
Hope this answers your questions.
Hi Joacimwe,
Thank you very much for your detailed comment. Now, I'm getting understood little by little.
You mentioned "Advanced boot loader except startup code is going to be placed 0x80000 region and executed", which is what I would like to know. Actually, I had not understood about scatter file and ARMLinker behaviors until you pointed them out.
让我确认我对系统启动和图像加载的理解是否正确,请:
- (Primary) Bootloader
Bootloader is hard-coded in ROM. When powered ON, Bootloader is executed and check whether Advanced bootloader is existing or not. If it exists, Bootloader loads Secondary bootloader which is burned in factory, and if it doesn't exist, Advanced bootloader and copy it to 0x20000000, then executes it. (then, advanced bootloader can located in OTP only.)
- 辅助引导程序(Adcanced Bootloader)
Scatter file is defined to:
*两个初始化文件(startup_cmsdk_cm0.o和system_cmsdk.o)被解决到0x0000000。
* Rest of ROM, RAM, Stack parts are addressed to 0x80000.
So, ARMLinker allocates the objects and also generates the code to copy them to appropriate place. The code generated by ARMLinker is executes in advance of initializing files. (maybe..)
When Secondary bootloader copies the target image from the external memory to 0x20000000, Secondary bootloader itself is executed on 0x80000 region. So, it is ready to copy it at that time.
以上是我所知的知识......它是正确的吗?
非常感谢您的合作。
此致,
光盘
你完全正确about the second part.
For the first part, I agree the terms are a bit confusing. DA14580 and DA14583 have the exact same ROM code and therefore the same primary bootloader.
“二次引导加载程序”项目由DA14580上的客户编程为OTP。
On DA14583, this project is instead called "advanced bootloader", since there is already a pre-programmed (completely different) secondary bootloader on the OTP.
在DA14583上,ROM代码始终启动次级引导程序,因为它是硬编码的。现在,如果客户编程了“高级引导程序”,则辅助引导加载程序将检测到(根据UM-B-012)并启动它。所以最后,如果您编程高级引导加载程序和应用程序代码,则在总共三个引导加载程序中将在您的应用程序代码运行之前运行;)
Hi Joacimwe,
Now all things are clear to me.
Thank you sooo much for sparing your time for my questions!
此致,
光盘