This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Serial Bootloader for NRF24LE1

I have used your example of a bootloader nAN_18. I can create a basic program, with new firmware, and also load my new bootloader program at the high end of memory.

My bootloader is running first. It sets up a few addresses then, on a command from the PC, it downloads a new firmware version. It then does an 'Exit' to the new program. This seems to be working, as i can send a message for the new firmware version, which is correct.

I can power off the Nordic and power on. The first three bytes unfortunately are still pointing at the Bootloader program, so it runs the bootloader again.

This code was run from the bootloader to initiate the changover. // Save the reset vector of THIS program as updated program needs it fot next update hal_flash_bytes_write(FW_RESET_VECTOR, L_bytResetVector, 3);*

// Reads address of firmware's reset vector. M_bytTempData[0] = hal_flash_byte_read(FW_RESET_ADDR_H); M_bytTempData[1] = hal_flash_byte_read(FW_RESET_ADDR_L); Firmware = (FirmwareStart)(((uint16_t)M_bytTempData[0] << 8) | (M_bytTempData[1]));

I can run a routine in the new firmware that also does the reverse of the changeover to go back to the bootloader (after disabling the interrupts). The code is:

// Reads address of firmware's reset vector.
M_bytTempData[0] = hal_flash_byte_read(FW_RESET_ADDR_H);
M_bytTempData[1] = hal_flash_byte_read(FW_RESET_ADDR_L);
Firmware = (FirmwareStart)(((uint16_t)M_bytTempData[0] << 8) | (M_bytTempData[1]));

// Jump to firmware. Goodbye!
Firmware();

This jumped back to the bootloader, no problem.

I altered the bootloader download to make the first 3 bytes the new firmware.

Now it runs the new firmware, and powers on and off to re-enter the new firmware, no problem.

Trouble is it now crashes when I want to go back to the bootloader!

What does the 'Firmware()' do. Do I need to erase the first block of memory in the new firmware and reset bytes 0, 1 and 2 before jumping to the bootloader?

Related