什么是bootloader?有什么用处?当我们在flash下载两个app时,如何从一个app转到另一个app?这个要怎么去做到?这时候就需要bootloader
。bootloader就是在cc3200启动的时候有选择性地启动我们的app,因为app是会更新的,譬如我们可以通过服务器下载一个新的app到cc3200上,这时候就起到了一个无线更新app的效果,无线更新app的功能叫做OTA,其底层就需要bootloader的支持。这里我们不讲OTA,仅仅就讲bootloader。
软件思路:通过bootloader我们启动另一个app,因此本例程需要两个bin文件,但是ccs需要三个工程,出于方便,我就先介绍思路,这里app我就采用uart_demo,
sram的空间分部是从0x2000 0000开始的,结束,我就不太清楚了,以前有看过,但是想不起来了。
cc3200是有内置bootloader,当上电的时候,会把内置bootloader拷贝到0x2000 0000 – 0x2000 4000内,所以一般我们的app的地址是在0x2000 4000,这个地址怎么知道了?ccs是需要看cc3200v1p32.cmd这个文件,这个文件里有
#define RAM_BASE 0x20004000
/* System memory map */
MEMORY
{
/* Application uses internal RAM for program and data */
SRAM_CODE (RWX) : origin = 0x20004000, length = 0x13000
SRAM_DATA (RWX) : origin = 0x20017000, length = 0x19000
}
很明显啊,这个工程的内存地址是从0x2000 4000的开始的,如果你修改了这个值,就会导致你的app跑不起来。
bootloader需要3个bin文件构成,
第一个bin文件叫relocator,这个bin文件是sdk就提供的,这里我不想改这个文件,理由么?太简单了
第二个bin文件叫BootLoaderManage,这个是我在blink的基础上修改的
第三个bin文件叫bootloader。这三者有什么关系?
relocator的空间位置是位于0x2000 4000
BootLoaderManage的空间位置是位于0x2000 0000
bootloader是上面两者的结合体,等于relocator + BootLoaderManage,relocator 是在前面的。BootLoaderManage在后面。
relocator 占据了0x100大小,
这里我截图,其中relocator 不足0x100大小,但是如果你把它看成了0x100大小,然后再跟BootLoaderManage的大小相加,最后就会发现大小是等于bootloader的大小,
怎么生成这个文件,需要把这句话
"${CC3200_SDK_ROOT}/example/application_bootloader/ccs/bootgen.exe" "${CC3200_SDK_ROOT}/example/application_bootloader/relocator/ewarm/Release/Exe/relocator.bin" "${BuildArtifactFileBaseName}.bin" "bootloader.bin"加在下面的位置。
这句话其实就是调用bootgen.exe这个工具把两个bin文件合成一个bin文件,具体是怎么合成的,我也不太清楚。
cc3200上电流程:跑内置的bootloader,内置的bootloader把我们的bootloader拷贝到0x2000 4000处,这时候会运行relocator这个bin文件,这个bin文件的功能就是把BootLoaderManage拷贝到0x2000 0000 处(单纯的拷贝功能,所以文件很小),接着跳到0x2000 0000处执行BootLoaderManage这个bin文件,接着我们在BootLoaderManage这个bin文件读取flash的文件,并把flash的文件拷贝到0x2000 4000 处,接着执行0x2000 4000 的app文件。
截图:
特别点:::::::::还需要特别一点的地方:修改下面这个静态库,如果没修改的话,会导致你的bootloader的文件大小大于0x4000,
大于这个数,会产生很大的麻烦
BootLoaderManage代码: