2018-06-21 01:35 AM
Hello STM32 people!
I informed myselfe about bootloaders, and I am curious if it is possible to use NFC(Near feald communication) to download a hex file into a STM32 microcontroller. I did not find anything online, so I am asking here, if there is a way to do that.
thank you!
#bootloader #nfc2018-06-21 06:09 AM
.HEX files are about 2.5x larger than necessary.
If you can transfer the data you can update the firmware.
Might be challenging, and you might want to stage the firmware in an external memory or RAM if it will fit.
Review the IAP (In Application Programming) examples, and then tailor to your data delivery method.
2018-06-22 03:23 AM
Thank you for your answere!
I red the IAP examples and I decided to use the UART to update the user programm of the MCU. The UART of my MCU is connected with a XBEE wireless module, which is able to communicate with a host PC. However my problem is now, that this XBEE modul needs a speific protocol to send data, but the bootloader does not understand this protocol. So the data which the bootloader sends over the UART will not be understood by the XBEE modul and thus not be send to my host pc. Is there a solution for this problem? (I was thinking of a seperate MCU, which is serves as a translater of the XBEE protocol to the bootloader UART protocol, but this would not be really a acceptable solution).
Goal is to update the firmware of the MCU wirelessly.
regards, Benjamin
2018-06-22 03:49 AM
ok, I managed to deactivate the protocol of the XBEE module, they work in transparent mode which is just like a UART connection via a cable. Next problem is, that I do not know how to transfere the HEX file without a programm like the flash loader demonstrator from ST over the UART connection... any ideas would help me.
Thank you
2018-06-22 04:39 AM
You can have a look to this open source project that implements the STM32 bootloader UART protocol:
2018-06-24 11:31 PM
OK thank you, this seems like a huge effort...
Anyway, trying to get the bootloader started from the application, with a code I found online. I changed the system memory address, according to the datasheet, however after executing the code, I always get a hard fault error. Anyone knows why?
CODE:
void (*SysMemBootJump)(void);
volatile uint32_t addr = 0x1FFF0000; if(BootLoaderStatus == 1) { //Shutdown any tasks runningHAL_UART_DeInit(&huart1);
HAL_UART_DeInit(&huart2); HAL_GPIO_DeInit(GPIOA,GPIO_PIN_6); HAL_GPIO_DeInit(GPIOD,GPIO_PIN_5); HAL_GPIO_DeInit(GPIOD,GPIO_PIN_4);HAL_RCC_DeInit();
//Reset the systick timer
SysTick->CTRL = 0; SysTick->LOAD = 0; SysTick->VAL = 0;//Disable Interrupts
__disable_irq();//Remap system memory
__HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH();HAL_DeInit();
//suspend all tasks from freeRTOS vTaskSuspendAll(); //Set jump memory location for system memory (bootloader) //Addres + 4 bytes offset which specifies jump location where programm starts SysMemBootJump = (void(*)(void)) (*((uint32_t *)(addr + 4))); //Set the main stack pointer to its default value__set_MSP(*(uint32_t *)addr);//Call the function to jump to the set location
//This will start system memory execution SysMemBootJump();while(1);
}thank you
2018-06-24 11:38 PM
MCU is a STM32L476
2018-06-25 01:32 AM
OK, update. The problem has to do with the freeRTOS which I am using. When I enter the bootloader (with the code I posted before) before I start the sheduler of the RTOS, it workes just fine. I can communicate with the bootloader via the UART. However if i execute the code from a task, it causes a hard fault, any suggestions?
2018-06-25 05:56 AM
OK, figured it out. Just for other people which face the same problem.
If you are using freeRTOS and want to start the bootloader, it is important to deactivate the systick interrupt like this:
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_ENABLE_Msk;
hope someone will help this information
have a nice day!