[ion] DFU reallocation: clean DCache after copying the DFU bootloader to the RAM

This commit is contained in:
Émilie Feral
2019-03-21 13:58:27 +01:00
parent d68c568e8d
commit 47327c39c9
2 changed files with 8 additions and 0 deletions

View File

@@ -47,6 +47,7 @@ dfu_src += liba/src/memset.c
dfu_src += liba/src/memcpy.c
dfu_src += libaxx/src/cxxabi/pure_virtual.cpp
dfu_src += ion/src/device/shared/usb/boot.cpp
dfu_src += ion/src/device/$(MODEL)/drivers/cache.cpp
dfu_src += $(addprefix ion/src/device/shared/drivers/, \
base64.cpp \
external_flash.cpp \

View File

@@ -1,6 +1,7 @@
#include <ion/usb.h>
#include <string.h>
#include <assert.h>
#include <drivers/cache.h>
#include "../drivers/timing.h"
extern char _stack_end;
@@ -47,6 +48,12 @@ void DFU() {
/* 3- Copy the DFU bootloader from Flash to RAM. */
memcpy(dfu_bootloader_ram_start, &_dfu_bootloader_flash_start, dfu_bootloader_size);
/* The DFU bootloader might have been copied in the DCache. However, when we
* run the instructions from the DFU bootloader, the CPU looks for
* instructions in the ICache and then in the RAM. We thus need to flush the
* DCache to update the RAM. */
// Flush data cache
Device::Cache::cleanDCache();
/* 4- Disable all interrupts
* The interrupt service routines live in the Flash and could be overwritten