MSPM0 L1306
一、基础
MSPM0L1306 是一款 Arm® 32 位 Cortex®-M0+ CPU,频率高达 32MHz。该器件具有64KB嵌入式闪存和4KB片上RAM。12位1MspsSAR ADC、零漂移和零交叉斩波运算放大器 (OPA) 和通用放大器 (GPAMP) 等集成高性能模拟外设可帮助用户设计其系统。
MCU包含精度为±1%的高速片上振荡器,无需外部晶体。其他特性包括3通道DMA、16位和32位CRC 加速器。
css 1.4.0 MSPM0 SDK-2.05.01.00
开发工具
CCS Theia 1.4.0
css getting started
MSPM0启动影像管理器(BIM)用户指南
将 SysConfig 与 MSPM0 配合使用
二、boot
MSPM0 引导加载程序 (BSL) 实现
There are two boot routines: the boot configuration routine (BCR), and the bootstrap loader(BSL).
The boot configuration routine sets up the device security policies, configures the device for operation, and optionally starts the BSL if it presents.
The BSL, if started by the BCR, can be used to program or verify the device memory (flash and SRAM) through the use of a standard serial interface (UART or I2C).
After the start-up routines have successfully completed execution, the CPU is reset and the application is started by unconditionally fetching the stack pointer (SP) and reset vector from 0x0000.0000 and 0x0000.0004 of the flash memory. To enable secure boot, this single point of entry into the application code is enforced by the boot sequence. It is not possible to boot into a different memory location.
UART: UART0, 9600, 8N1
I2C: I2C0, address 0x48
2.1 bsl
If enabled, the BSL may be invoked (started) in the following ways:
• The BSL is invoked during the boot process if the BSL_invoke pin state matches the defined BSL_invoke
logic level. If the device fast boot mode is enabled, this invocation check is skipped. An external host can
force the device into the BSL by asserting the invoke condition and applying a reset pulse to the NRST pin to
trigger a BOOTRST, after which the device will verify the invoke condition during the reboot process and start
the BSL if the invoke condition matches the expected logic level.
• The BSL is automatically invoked during the boot process if the reset vector and stack pointer are left
unprogrammed. As a result, a blank device from TI will invoke the BSL during the boot process without any
need to provide a hardware invoke condition on the BSL_invoke pin. This enables production programming
using just the serial interface signals.
• The BSL may be invoked at runtime from application software by issuing a SYSRST with BSL entry command.
2.2 Configuration Memory (NONMAIN)
The NONMAIN is a dedicated region of flash memory which stores the configuration data used by the BCR and BSL to boot the device. The region is not used for any other purpose.
The BCR and BSL both have configuration policies which can be left at their default values (as is typical during development and evaluation), or modified for specific purposes (as is typical during production programming) by altering the values programmed into the NONMAIN flash region.
The configuration data in the NONMAIN flash region is not affected by a mass erase command, but it is erased and re-programmed to factory defaults by a factory reset command sent to the BCR via the debug sub system mailbox (DSSM) over SWD.
The address ranges for the NONMAIN data structures are given in the NONMAIN Registers section.
2.3 bootloader host
三、hardware
芯片型号:MSPM0L1306SRGER (QFN24-050-0404-010-N)
L=32MHz 130=ADC,2xOPA, COMP 6=64KB flash,4KB SRAM S=-40C~125C
四、双固件升级
TI提供升级方案,启动映像管理器 (BIM) 是面向 MSP 器件公开发行的一种 mcuboot 实现方案,用于使客户在开发过程中获得安全启动特性。
方案由bootloader + APP1镜像 + APP2镜像 组成。
注意:mcuboot 将在使用就地执行 (XIP)的映像之间选择,因此映像默认不会交换。因此,开发人员必须针对映像将进入的槽位创建映像。在许多情况下,这可能意味着维护为主槽位和副槽位编译的两个映像。否则,可能出现异常行为。
升级模式
MCUboot支持的四种升级模式,分别是Overwrite、Swap、Direct XIP和加载到RAM中执行。
MCUBOOT_OVERWRITE_ONLY
MCUBOOT_SWAP_USING_MOVE
MCUBOOT_DIRECT_XIP
MCUBOOT_RAM_LOAD
bootloader
需要更新nonMain区。
应用镜像
应用镜像编译完成后,需要添加镜像头和校验。
[34]"C:/TI/ccstheia140/ccs/tools/compiler/ti-cgt-armllvm_3.2.2.LTS/bin/tiarmclang.exe" -march=thumbv6m -mcpu=cortex-m0plus -mfloat-abi=soft -mlittle-endian -mthumb -Oz -D__MSPM0G3507__ -DPRIMARY_SLOT -gdwarf-3 -gstrict-dwarf -Wl,-m"bim_sample_image_MSPM0G3507_nortos_ticlang.map" -Wl,--stack_size=0 -Wl,-i"C:/TI/ccstheia140/ccs/tools/compiler/ti-cgt-armllvm_3.2.2.LTS/lib" -Wl,--define=PRIMARY_SLOT -Wl,--diag_wrap=off -Wl,--display_error_number -Wl,--warn_sections -Wl,--xml_link_info="bim_sample_image_MSPM0G3507_nortos_ticlang_linkInfo.xml" -Wl,--rom_model -o "bim_sample_image_MSPM0G3507_nortos_ticlang.out" "./bim_sample_image.o" "./syscfg/ti_msp_dl_config.o" "./ticlang/startup_mspm0g3507_ticlang.o" "../mspm0g3507.cmd" -Wl,-l"C:/TI/mspm0_sdk_2_05_01_00/source/ti/driverlib/lib/ticlang/m0p/mspm0g1x0x_g3x0x/driverlib.a" -Wl,-llibc.a
[35]tiarmclang: warning: Strict DWARF is not supported. [-Winvalid-command-line-argument]
[36]Finished building target: "bim_sample_image_MSPM0G3507_nortos_ticlang.out"
[37]Building secondary target: "bim_sample_image_MSPM0G3507_nortos_ticlang.txt"
[38]Invoking: Arm Hex Utility
[39]"C:/TI/ccstheia140/ccs/tools/compiler/ti-cgt-armllvm_3.2.2.LTS/bin/tiarmhex.exe" --diag_wrap=off --ti_txt -o "bim_sample_image_MSPM0G3507_nortos_ticlang.txt" "bim_sample_image_MSPM0G3507_nortos_ticlang.out"
[40]Translating to TI-TXT format...
[41] "bim_sample_image_MSPM0G3507_nortos_ticlang.out" .intvecs ==> .intvecs
[42] "bim_sample_image_MSPM0G3507_nortos_ticlang.out" .text ==> .text
[43] "bim_sample_image_MSPM0G3507_nortos_ticlang.out" .rodata ==> .rodata
[44]Finished building secondary target: "bim_sample_image_MSPM0G3507_nortos_ticlang.txt"
[45]C:/TI/ccstheia140/ccs/tools/compiler/ti-cgt-armllvm_3.2.2.LTS/bin/tiarmobjcopy bim_sample_image_MSPM0G3507_nortos_ticlang.out --output-target binary bim_sample_image_MSPM0G3507_nortos_ticlang-unsigned.bin
[46]python C:/TI/mspm0_sdk_2_05_01_00/source/third_party/mcuboot/scripts/imgtool.py sign --header-size 0x100 --align 4 --slot-size 0xD000 --pad --version 1.0.0 --pad-header --key C:/TI/mspm0_sdk_2_05_01_00/source/third_party/mcuboot/image_signTEST.pem bim_sample_image_MSPM0G3507_nortos_ticlang-unsigned.bin bim_sample_image_MSPM0G3507_nortos_ticlang_0x5800_v1_green.bin
[47]**** Build Finished ****
# 编译和创建影像后转换为二进制格式
${CG_TOOL_ROOT}/bin/tiarmobjcopy ${ProjName}.out --output-target binary ${ProjName}-unsigned.bin
# 签名并提供合适的报头
./scripts/imgtool.py sign --header-size 0x100 --align 4 --slot-size 0x5400 --pad --version 1.0.0 -s 1 --pad-header --key path/to/private/key.pem ${ProjName}-unsigned.bin ${ProjName}.bin
- 密钥 - 开发人员必须将密钥路径更改为其私钥(pem 文件),私钥可以按照创建和使用密钥中的步骤生成
- 版本 - 开发人员应加入对映像的版本控制
- 槽位大小 - 如果存储器映射已更改,请参阅存储器映射自定义,需要考虑槽位大小。
- 安全版本 - 用户可以更改软件的安全版本(-s 选项)以进行回滚保护,但是测试版目前不支持此特性。
# 私钥
cd source/third_party/mcuboot/
scripts/imgtool.py keygen -k newkey.pem -t ecdsa-p256
# 公钥
# 从 .pem 文件派生出以 DER 格式编码的公钥
scripts/imgtool.py getpub -k newkey.pem
python imgtool.py getpub -k testpriv.pem
/* Autogenerated by imgtool.py, do not edit. */
const unsigned char ecdsa_pub_key[] = {
0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86,
0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a,
0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03,
0x42, 0x00, 0x04, 0x62, 0x1c, 0xf9, 0xe1, 0x15,
0x1e, 0x22, 0x4e, 0xac, 0x5e, 0x06, 0x1f, 0x3e,
0x4a, 0xb2, 0xff, 0xd6, 0x8d, 0x9f, 0x89, 0x98,
0x59, 0x3f, 0xfb, 0xed, 0xad, 0xa0, 0x03, 0x53,
0x6b, 0x2c, 0x6d, 0xcd, 0x08, 0x54, 0xc1, 0x9c,
0xe0, 0x78, 0x5a, 0x65, 0x09, 0xfa, 0xde, 0x5a,
0x79, 0x81, 0xaa, 0x91, 0x5c, 0x97, 0xe2, 0x22,
0x88, 0x8b, 0xbb, 0xb7, 0xd4, 0xb0, 0x07, 0x35,
0x7e, 0xe1, 0xa3,
};
const unsigned int ecdsa_pub_key_len = 91;
浙公网安备 33010602011771号