主题中讨论的其他部件:MSP432E401Y、 EK-TM4C129EXL
大家好、
首先,请允许我感谢你们在这一大流行病下为我们所做的一切努力。
我之所以打开此主题、是因为以下原因。 我们正在为 TM4C129ENCPDT 和 MSP432E401Y 开发软件、并遇到一些问题。
我想为 EK-TM4C129EXL 创建一个定制的引导加载程序。
在开发阶段、我从 TivaWare_C_Series-2.2.0.295中获取了 boot_EMAC_FLASH 示例。
我修改了 BL_config.h 未注释 #define BL_INIT_FN_HOOK 和 #define BL_CHECK_UPDATE_FN_HOOK。
我编写了自己的函数。
首先、我想确保这些函数正在运行、因此使用了一个简单的闪烁函数。
void MyInitFunc(void){
volatile uint32_t ui32Loop;
//
// Enable the GPIO port that is used for the on-board LED.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
//
// Check if the peripheral access is enabled.
//
while(!ROM_SysCtlPeripheralReady(SYSCTL_PERIPH_GPION))
{
}
//
// Enable the GPIO pin for the LED (PN0). Set the direction as output, and
// enable the GPIO pin for digital function.
//
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0);
//
// Loop forever.
//
volatile uint16_t xi;
for( xi = 0; xi <100; xi++)
{
//
// Turn on the LED.
//
ROM_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, GPIO_PIN_0);
//
// Delay for a bit.
//
for(ui32Loop = 0; ui32Loop < 500000; ui32Loop++)
{
}
//
// Turn off the LED.
//
ROM_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, 0x0);
//
// Delay for a bit.
//
for(ui32Loop = 0; ui32Loop < 500000; ui32Loop++)
{
}
}
}
在最初的试验中、没有发生任何事情。 之后、我尝试对其进行调试、但有点棘手、我意识到引导加载程序卡住了。
我尝试了一些更改(使用了 volatile)和 prev。 插入的代码可以在调试模式下运行。
但是、当我尝试在独立模式下运行器件时、不会闪烁、会注意到发生了什么情况。 器件已完全重新读取 PRV。
或多或少、我很高兴、因为在调试模式下它可以正常工作。 因此、我的微型项目中的第二步就完成了。
下面是我在 BL_CONFIG.h 中修改的内容:
- #define BL_CHECK_UPDATE_FN_Hook DetermineBootSeq
- #define BL_INIT_FN_Hook MyStartFunc
我编写了自定义 BL_CHECK_UPDATE_FN_HOOK 以检查指定地址处的 EEPROM 内容。
uint32_t DetermineBootSeq(void){
uint32_t ui32EEPROMInit;
uint32_t ReadCustomBLFlags[2];
//
// Enable the EEPROM module.
//
SysCtlPeripheralEnable(SYSCTL_PERIPH_EEPROM0);
//
// Wait for the EEPROM module to be ready.
//
while (!SysCtlPeripheralReady(SYSCTL_PERIPH_EEPROM0))
{
}
//
// Wait for the EEPROM Initialization to complete
//
ui32EEPROMInit = EEPROMInit();
//
// Check if the EEPROM Initialization returned an error
// and inform the application
//
if (ui32EEPROMInit != EEPROM_INIT_OK)
{
while (1)
{
}
}
// //Get the EEPROMSize +
//READ some data FROM THE LAST 2 WORD OF the EEPROM
//
//uint32_t EepromMaxSize = EEPROMSizeGet();
EEPROMRead(ReadCustomBLFlags, BL_CUSTOME_FLAGS_ADDRESS,
sizeof(ReadCustomBLFlags));
if (ReadCustomBLFlags[BL_ALWAYS_RUN_ADDRESS] == BL_ALWAYS_RUN)
{
return (1);
}
else
{
if (ReadCustomBLFlags[BL_UPDATE_STATUS_ADDRESS] == BL_UPDATE_END)
{
//
// See if the first location is 0xfffffffff or something that does not
// look like a stack pointer, or if the second location is 0xffffffff or
// something that does not look like a reset vector.
//
volatile uint32_t *pui32App;
pui32App = (uint32_t*) APP_START_ADDRESS;
if ((pui32App[0] == 0xffffffff)
|| ((pui32App[0] & 0xfff00000) != 0x20000000)
|| (pui32App[1] == 0xffffffff)
|| ((pui32App[1] & 0xfff00001) != 0x00000001))
{
return (1);
}
//a valid image exists
// and no update is needed.
// return(0)
return (0);
}
else
{
//If the update not complated run the bootloader for update
return (1);
}
}
}
还编写 了 BL_init_fn_hook:
void MyStartFunc(void){
volatile uint32_t ui32Loop;
//
// Enable the GPIO port that is used for the on-board LED.
//
ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION);
//
// Check if the peripheral access is enabled.
//
while(!ROM_SysCtlPeripheralReady(SYSCTL_PERIPH_GPION))
{
}
//
// Enable the GPIO pin for the LED (PN0). Set the direction as output, and
// enable the GPIO pin for digital function.
//
ROM_GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0);
//
// Loop forever.
//
volatile uint32_t xi;
for( xi = 0; xi <100; xi++)
{
//
// Turn on the LED.
//
ROM_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, GPIO_PIN_0);
//
// Delay for a bit.
//
for(ui32Loop = 0; ui32Loop < 500000; ui32Loop++)
{
}
//
// Turn off the LED.
//
ROM_GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, 0x0);
//
// Delay for a bit.
//
for(ui32Loop = 0; ui32Loop < 500000; ui32Loop++)
{
}
}
}
现在、它只在调试模式下工作、但是如果我更改代码中的某个内容、则会冻结、而不会发生任何情况。
我应该从哪里开始检查?
那么、我有两个问题。
为什么它仅在调试模式下工作?
- 我是否应该修改 BL_LINK_CSS.cmd 中的内容?
为什么该代码可以在调试模式下运行、但如果我更改它卡住的内容
我读取 了 SW-TM4C-BOOTLDR-UG.2.2.0.295。
我们欢迎您提供任何帮助。
IM 使用 CCS 版本:10.2.0.00009、 TivaWare_C_Series-2.2.0.295。
如果我们能够开始解决这些问题、如果您能提出更好的想法、我将不胜感激。
保持安全和平静。