cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 NFC bootloader

benjamin Gräf
Associate II
Posted on June 21, 2018 at 10:35

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 #nfc
8 REPLIES 8
Posted on June 21, 2018 at 15:09

.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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on June 22, 2018 at 10:23

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

Posted on June 22, 2018 at 10:49

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

Posted on June 22, 2018 at 11:39

You can have a look to this open source project that implements the STM32 bootloader UART protocol: 

https://sourceforge.net/p/stm32flash/code/ci/master/tree/

benjamin Gräf
Associate II
Posted on June 25, 2018 at 08:31

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 running

HAL_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

benjamin Gräf
Associate II
Posted on June 25, 2018 at 08:38

MCU is a STM32L476

benjamin Gräf
Associate II
Posted on June 25, 2018 at 10:32

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?

benjamin Gräf
Associate II
Posted on June 25, 2018 at 14:56

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!