Merge remote-tracking branch 'origin/master'

# Conflicts:
#	firmware/Makefile
This commit is contained in:
rusefi 2020-04-25 16:33:06 -04:00
commit 824317df16
22 changed files with 157 additions and 113 deletions

@ -1 +1 @@
Subproject commit 85cf4582a9f6a57cc49759c606af5fda2f52d106
Subproject commit 1a2c5967dc813bdbf1cc7eabfea8377340c8a29e

View File

@ -80,18 +80,6 @@ ifeq ($(USE_VERBOSE_COMPILE),)
USE_VERBOSE_COMPILE = no
endif
# If enabled, this option makes the build process faster by not compiling
# modules not used in the current configuration.
# without USE_SMART_BUILD all ChibiOS (including all drivers) are builded. And all drivers includes get included.
ifeq ($(USE_SMART_BUILD),)
USE_SMART_BUILD = yes
endif
# for this to work it has to be defined before hal.mk
ifeq ($(CONFDIR),)
CONFDIR = config/stm32f4ems
endif
ifeq ($(USE_BOOTLOADER),)
USE_BOOTLOADER = no
endif
@ -135,15 +123,24 @@ MAKEFLAGS += ${NUMJOBS}
# Architecture or project specific options
##############################################################################
BOARDS_DIR = $(PROJECT_DIR)/config/boards
# we want this above hal.mk since we often define CONFDIR inside board.mk
include $(PROJECT_DIR)/config/boards/$(PROJECT_BOARD)/board.mk
##############################################################################
# Project, sources and paths
#
BOARDS_DIR = $(PROJECT_DIR)/config/boards
include $(PROJECT_DIR)/config/boards/$(PROJECT_BOARD)/board.mk
# If enabled, this option makes the build process faster by not compiling
# modules not used in the current configuration.
# without USE_SMART_BUILD all ChibiOS (including all drivers) are builded. And all drivers includes get included.
ifeq ($(USE_SMART_BUILD),)
USE_SMART_BUILD = yes
endif
ifeq ($(CONFDIR),)
CONFDIR = $(PROJECT_DIR)/config/stm32f4ems
endif
# Startup files.
include $(CPU_STARTUP_DIR)
# HAL-OSAL files (optional).
@ -180,7 +177,6 @@ ifeq ($(BOOTLOADERINC),)
BOOTLOADERINC= $(PROJECT_DIR)/bootloader/
endif
ifeq ($(USE_BOOTLOADER),yes)
include $(PROJECT_DIR)/bootloader/bootloader.mk
endif
@ -197,7 +193,9 @@ CSRC = $(STARTUPSRC) \
$(PORTSRC) \
$(OSALSRC) \
$(HALSRC) \
$(HALSRC_CONTRIB) \
$(PLATFORMSRC) \
$(PLATFORMSRC_CONTRIB) \
$(BOARDSRC) \
$(BOOTLOADERSRC) \
$(CHIBIOS)/os/ex/ST/lis302dl.c \
@ -283,6 +281,7 @@ INCDIR = $(CHIBIOS)/os/license \
$(HALINC) \
$(HALINC_CONTRIB) \
$(PLATFORMINC) \
$(PLATFORMINC_CONTRIB) \
$(BOARDINC) \
$(BOOTLOADERINC) \
$(CHCPPINC) \

View File

@ -12,8 +12,14 @@ ifeq ($(DEBUG_LEVEL_OPT),)
DDEFS += -DEFI_ENABLE_ASSERTS=FALSE -DCH_DBG_ENABLE_ASSERTS=FALSE -DCH_DBG_ENABLE_STACK_CHECK=FALSE -DCH_DBG_FILL_THREADS=FALSE -DCH_DBG_THREADS_PROFILING=FALSE
endif
ifeq ($(CONFDIR),)
CONFDIR = $(PROJECT_DIR)/config/stm32f4ems
endif
# disable some modules to shrink bootloader binary
DDEFS += -DHAL_USE_ADC=FALSE -DHAL_USE_CAN=FALSE -DHAL_USE_EXT=FALSE -DHAL_USE_GPT=FALSE -DHAL_USE_I2C=FALSE -DHAL_USE_ICU=FALSE -DHAL_USE_PWM=FALSE -DHAL_USE_RTC=FALSE -DHAL_USE_I2C=FALSE
#disable ChibiOS flsah driver and prevent header from include
DDEFS += -DHAL_USE_FLASH=FASLE
# disable USB (The bootloader has currently UART support only)
DDEFS += -DEFI_USB_SERIAL=FALSE -DHAL_USE_SERIAL_USB=FALSE -DHAL_USE_USB=FALSE -DHAL_USE_USB_MSD=FALSE
@ -71,7 +77,7 @@ endif
# If enabled, this option makes the build process faster by not compiling
# modules not used in the current configuration.
ifeq ($(USE_SMART_BUILD),)
USE_SMART_BUILD = no
USE_SMART_BUILD = yes
endif
#

View File

@ -2,7 +2,7 @@
#include "hardware.h"
#include "efi_gpio.h"
#include "flash.h"
#include "flash_int.h"
#include "dfu.h"
@ -165,7 +165,7 @@ static void dfuHandleRead(void) {
if (isInVirtualPageBuffer(addr))
memcpy(buffer, (uint8_t *)addr, numBytes);
else
flashRead(addr, (char *)buffer, numBytes);
intFlashRead(addr, (char *)buffer, numBytes);
// transmit data
sr5WriteData(&blTsChannel, (uint8_t *)buffer, numBytes);
@ -197,7 +197,7 @@ static void dfuHandleWrite(void) {
if (isInVirtualPageBuffer(addr))
memcpy((uint8_t *)addr, (buffer + 1), numBytes);
else
flashWrite(addr, (const char *)(buffer + 1), numBytes);
intFlashWrite(addr, (const char *)(buffer + 1), numBytes);
// we're done!
sendByte(DFU_ACK_BYTE);
@ -233,7 +233,7 @@ static void dfuHandleErase(void) {
continue;
}
// erase sector
flashSectorErase(sectorIdx);
intFlashSectorErase(sectorIdx);
}
sendByte(DFU_ACK_BYTE);

View File

@ -7,7 +7,7 @@ set EXTRA_PARAMS=-DDUMMY -DCPU_MKE16F512VLH16 -DCPU_MKE16F512VLH16_cm4 -D__USE_C
rem set BUILDDIR=build_kinetis
set BUILDDIR=build
set PROJECT_BOARD=kinetis
set USE_SMART_BUILD=no
set USE_SMART_BUILD=yes
set PROJECT_CPU=kinetis
set DEBUG_LEVEL_OPT="-O2"
set USE_FATFS=no

View File

@ -14,10 +14,4 @@ BOARDSRC_CPP += $(CONTROLLERS_ALGO_AUTO_GENERATED_ENUMS)
# Define linker script file here
LDSCRIPT= $(STARTUPLD)/MKE1xF512.ld
PLATFORMSRC += $(PLATFORMSRC_CONTRIB)
PLATFORMINC += $(PLATFORMINC_CONTRIB)
# Using external ChibiOS-Contrib code for Comparator HAL
HALSRC += $(CHIBIOS_CONTRIB)/os/hal/src/hal_comp.c
CONFDIR = $(BOARD_DIR)

View File

@ -171,13 +171,19 @@
#endif
/**
* @brief Enables the Comparator subsystem.
* @brief Enables the community overlay.
*/
#if !defined(HAL_USE_COMMUNITY) || defined(__DOXYGEN__)
#define HAL_USE_COMMUNITY TRUE
#endif
/**
* @brief Enables the TIMCAP subsystem.
*/
#if !defined(HAL_USE_COMP) || defined(__DOXYGEN__)
#define HAL_USE_COMP TRUE
#endif
/*===========================================================================*/
/* PAL driver related settings. */
/*===========================================================================*/

View File

@ -0,0 +1,28 @@
/*
ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef HALCONF_COMMUNITY_H
#define HALCONF_COMMUNITY_H
/**
* @brief Enables the TIMCAP subsystem.
*/
#if !defined(HAL_USE_COMP) || defined(__DOXYGEN__)
#define HAL_USE_COMP TRUE
#endif
#endif /* HALCONF_COMMUNITY_H */
/** @} */

View File

@ -30,6 +30,20 @@
#include "mcuconf.h"
/* THIS IS HACK: to allow smooth transition to ChibiOS with ELF support we
* need to disable hal_flash.h until we move to ChibiOS EFL driver.
* hal_flash.h in ChibiOS has definitions that conflict with current RusEFI
* flash driver.
* but it is included unconditionaly from hal.h */
#define HAL_FLASH_H
/**
* @brief Enables the FLASH subsystem.
*/
#if !defined(HAL_USE_FLASH) || defined(__DOXYGEN__)
#define HAL_USE_FLASH FALSE
#endif
/**
* @brief Enables the PAL subsystem.
*/

View File

@ -30,6 +30,20 @@
#include "mcuconf.h"
/* THIS IS HACK: to allow smooth transition to ChibiOS with ELF support we
* need to disable hal_flash.h until we move to ChibiOS EFL driver.
* hal_flash.h in ChibiOS has definitions that conflict with current RusEFI
* flash driver.
* but it is included unconditionaly from hal.h */
#define HAL_FLASH_H
/**
* @brief Enables the FLASH subsystem.
*/
#if !defined(HAL_USE_FLASH) || defined(__DOXYGEN__)
#define HAL_USE_FLASH FALSE
#endif
/**
* @brief Enables the PAL subsystem.
*/

View File

@ -145,7 +145,7 @@ static fuel_table_t alphaNfuel = {
* todo: place this field next to 'engineConfiguration'?
*/
#ifdef EFI_ACTIVE_CONFIGURATION_IN_FLASH
#include "flash.h"
#include "flash_int.h"
engine_configuration_s & activeConfiguration = reinterpret_cast<persistent_config_container_s*>(getFlashAddrFirstCopy())->persistentConfiguration.engineConfiguration;
// we cannot use this activeConfiguration until we call rememberCurrentConfiguration()
bool isActiveConfigurationVoid = true;

View File

@ -13,7 +13,7 @@
#include "flash_main.h"
#include "eficonsole.h"
#include "flash.h"
#include "flash_int.h"
#include "engine_math.h"
// this message is part of console API, see FLASH_SUCCESS_MSG in java code
@ -69,8 +69,8 @@ void writeToFlashIfPending() {
template <typename TStorage>
int eraseAndFlashCopy(flashaddr_t storageAddress, const TStorage& data)
{
flashErase(storageAddress, sizeof(TStorage));
return flashWrite(storageAddress, reinterpret_cast<const char*>(&data), sizeof(TStorage));
intFlashErase(storageAddress, sizeof(TStorage));
return intFlashWrite(storageAddress, reinterpret_cast<const char*>(&data), sizeof(TStorage));
}
void writeToFlashNow(void) {
@ -114,7 +114,7 @@ persisted_configuration_state_e flashState;
static persisted_configuration_state_e doReadConfiguration(flashaddr_t address, Logging * logger) {
printMsg(logger, "readFromFlash %x", address);
flashRead(address, (char *) &persistentState, sizeof(persistentState));
intFlashRead(address, (char *) &persistentState, sizeof(persistentState));
if (!isValidCrc(&persistentState)) {
return CRC_FAILED;

View File

@ -1,5 +1,5 @@
/**
* @file flash.h
* @file flash_int.h
*
*/
@ -69,28 +69,6 @@ size_t flashSectorSize(flashsector_t sector);
uintptr_t getFlashAddrFirstCopy(void);
uintptr_t getFlashAddrSecondCopy(void);
/**
* @brief Get the beginning address of @p sector.
* @param sector Sector to retrieve the beginning address of.
* @return First address (inclusive) of @p sector.
*/
flashaddr_t flashSectorBegin(flashsector_t sector);
/**
* @brief Get the end address of @p sector.
* @param sector Sector to retrieve the end address of.
* @return End address (exclusive) of @p sector (i.e. beginning address of the next sector).
*/
flashaddr_t flashSectorEnd(flashsector_t sector);
/**
* @brief Get the sector containing @p address.
* @warning @p address must be in the flash addresses range.
* @param address Address to be searched for.
* @return Sector containing @p address.
*/
flashsector_t flashSectorAt(flashaddr_t address);
/**
* @brief Erase the flash @p sector.
* @details The sector is checked for errors after erase.
@ -101,7 +79,7 @@ flashsector_t flashSectorAt(flashaddr_t address);
* @return FLASH_RETURN_BAD_FLASH Flash cell error.
* @return FLASH_RETURN_NO_PERMISSION Access denied.
*/
int flashSectorErase(flashsector_t sector);
int intFlashSectorErase(flashsector_t sector);
/**
* @brief Erase the sectors containing the span of @p size bytes starting at @p address.
@ -117,7 +95,7 @@ int flashSectorErase(flashsector_t sector);
* @return FLASH_RETURN_BAD_FLASH Flash cell error.
* @return FLASH_RETURN_NO_PERMISSION Access denied.
*/
int flashErase(flashaddr_t address, size_t size);
int intFlashErase(flashaddr_t address, size_t size);
/**
* @brief Check if the @p size bytes of flash memory starting at @p address are erased.
@ -127,7 +105,7 @@ int flashErase(flashaddr_t address, size_t size);
* @return TRUE Memory is already erased.
* @return FALSE Memory is not erased.
*/
bool flashIsErased(flashaddr_t address, size_t size);
bool intFlashIsErased(flashaddr_t address, size_t size);
/**
* @brief Check if the data in @p buffer are identical to the one in flash memory.
@ -137,7 +115,7 @@ bool flashIsErased(flashaddr_t address, size_t size);
* @return TRUE if the flash memory and the buffer contain identical data.
* @return FALSE if the flash memory and the buffer don't contain identical data.
*/
bool flashCompare(flashaddr_t address, const char* buffer, size_t size);
bool intFlashCompare(flashaddr_t address, const char* buffer, size_t size);
/**
* @brief Copy data from the flash memory to a @p buffer.
@ -147,7 +125,7 @@ bool flashCompare(flashaddr_t address, const char* buffer, size_t size);
* @param size Size of the data to be copied in bytes.
* @return FLASH_RETURN_SUCCESS if successfully copied.
*/
int flashRead(flashaddr_t address, char* buffer, size_t size);
int intFlashRead(flashaddr_t address, char* buffer, size_t size);
/**
* @brief Copy data from a @p buffer to the flash memory.
@ -159,7 +137,7 @@ int flashRead(flashaddr_t address, char* buffer, size_t size);
* @return FLASH_RETURN_SUCCESS No error.
* @return FLASH_RETURN_NO_PERMISSION Access denied.
*/
int flashWrite(flashaddr_t address, const char* buffer, size_t size);
int intFlashWrite(flashaddr_t address, const char* buffer, size_t size);
#ifdef __cplusplus
}

View File

@ -1,6 +1,6 @@
/**
*
* @file flash.c
* @file flash_int.c
* @brief Lower-level code for Kinetis related to internal flash memory
* @author andreika <prometheus.pcb@gmail.com>
*/
@ -9,7 +9,7 @@
#if EFI_INTERNAL_FLASH
#include "flash.h"
#include "flash_int.h"
#include "fsl_ftfx_flexnvm.h"
#include <string.h>
@ -112,7 +112,7 @@ static int alignToWord(int v) {
return (v + FSL_FEATURE_FLASH_FLEX_NVM_SECTOR_CMD_ADDRESS_ALIGMENT - 1) & ~(FSL_FEATURE_FLASH_FLEX_NVM_SECTOR_CMD_ADDRESS_ALIGMENT - 1);
}
int flashErase(flashaddr_t address, size_t size) {
int intFlashErase(flashaddr_t address, size_t size) {
if (!flashUnlock())
return FLASH_RETURN_NO_PERMISSION;
@ -130,7 +130,7 @@ int flashErase(flashaddr_t address, size_t size) {
return -(int)status;
}
int flashWrite(flashaddr_t address, const char* buffer, size_t size) {
int intFlashWrite(flashaddr_t address, const char* buffer, size_t size) {
if (!flashUnlock())
return FLASH_RETURN_NO_PERMISSION;
@ -150,7 +150,7 @@ int flashWrite(flashaddr_t address, const char* buffer, size_t size) {
return -(int)status;
}
bool flashIsErased(flashaddr_t address, size_t size) {
bool intFlashIsErased(flashaddr_t address, size_t size) {
/* Check for default set bits in the flash memory
* For efficiency, compare flashdata_t values as much as possible,
* then, fallback to byte per byte comparison. */
@ -170,7 +170,7 @@ bool flashIsErased(flashaddr_t address, size_t size) {
return TRUE;
}
bool flashCompare(flashaddr_t address, const char* buffer, size_t size) {
bool intFlashCompare(flashaddr_t address, const char* buffer, size_t size) {
#if 0
uint32_t failAddr = 0, failDat = 0;
status_t status = FLEXNVM_DflashVerifyProgram(&flashCfg, address, size, (const uint8_t *)buffer,
@ -197,7 +197,7 @@ bool flashCompare(flashaddr_t address, const char* buffer, size_t size) {
return TRUE;
}
int flashRead(flashaddr_t address, char* buffer, size_t size) {
int intFlashRead(flashaddr_t address, char* buffer, size_t size) {
memcpy(buffer, (char*) address, size);
return FLASH_RETURN_SUCCESS;
}

View File

@ -2,7 +2,7 @@ ifeq ($(KINETIS_CONTRIB),)
KINETIS_CONTRIB = $(CHIBIOS_CONTRIB)
endif
HW_LAYER_EMS += $(PROJECT_DIR)/hw_layer/ports/kinetis/flash.c \
HW_LAYER_EMS += $(PROJECT_DIR)/hw_layer/ports/kinetis/flash_int.c \
$(KINETIS_CONTRIB)/os/hal/ports/KINETIS/KE1xF/fsl/fsl_ftfx_flexnvm.c \
$(KINETIS_CONTRIB)/os/hal/ports/KINETIS/KE1xF/fsl/fsl_ftfx_controller.c

View File

@ -11,7 +11,7 @@
#if EFI_PROD_CODE
#include "mpu_util.h"
#include "flash.h"
#include "flash_int.h"
#include "engine.h"
#include "pin_repository.h"
#include "os_util.h"

View File

@ -3,7 +3,7 @@
* http://www.chibios.com/forum/viewtopic.php?f=8&t=820
* https://github.com/tegesoft/flash-stm32f407
*
* @file flash_main.c
* @file flash_int.c
* @brief Lower-level code related to internal flash memory
*/
@ -12,10 +12,10 @@
#if EFI_INTERNAL_FLASH
#include "flash.h"
#include "flash_int.h"
#include <string.h>
flashaddr_t flashSectorBegin(flashsector_t sector) {
flashaddr_t intFlashSectorBegin(flashsector_t sector) {
flashaddr_t address = FLASH_BASE;
while (sector > 0) {
--sector;
@ -24,13 +24,13 @@ flashaddr_t flashSectorBegin(flashsector_t sector) {
return address;
}
flashaddr_t flashSectorEnd(flashsector_t sector) {
return flashSectorBegin(sector + 1);
flashaddr_t intFlashSectorEnd(flashsector_t sector) {
return intFlashSectorBegin(sector + 1);
}
flashsector_t flashSectorAt(flashaddr_t address) {
flashsector_t intFlashSectorAt(flashaddr_t address) {
flashsector_t sector = 0;
while (address >= flashSectorEnd(sector))
while (address >= intFlashSectorEnd(sector))
++sector;
return sector;
}
@ -38,14 +38,14 @@ flashsector_t flashSectorAt(flashaddr_t address) {
/**
* @brief Wait for the flash operation to finish.
*/
#define flashWaitWhileBusy() { while (FLASH->SR & FLASH_SR_BSY) {} }
#define intFlashWaitWhileBusy() { while (FLASH->SR & FLASH_SR_BSY) {} }
/**
* @brief Unlock the flash memory for write access.
* @return HAL_SUCCESS Unlock was successful.
* @return HAL_FAILED Unlock failed.
*/
static bool flashUnlock(void) {
static bool intFlashUnlock(void) {
/* Check if unlock is really needed */
if (!(FLASH->CR & FLASH_CR_LOCK))
return HAL_SUCCESS;
@ -63,15 +63,15 @@ static bool flashUnlock(void) {
/**
* @brief Lock the flash memory for write access.
*/
#define flashLock() { FLASH->CR |= FLASH_CR_LOCK; }
#define intFlashLock() { FLASH->CR |= FLASH_CR_LOCK; }
int flashSectorErase(flashsector_t sector) {
int intFlashSectorErase(flashsector_t sector) {
/* Unlock flash for write access */
if (flashUnlock() == HAL_FAILED)
if (intFlashUnlock() == HAL_FAILED)
return FLASH_RETURN_NO_PERMISSION;
/* Wait for any busy flags. */
flashWaitWhileBusy();
intFlashWaitWhileBusy();
/* Setup parallelism before any program/erase */
FLASH->CR &= ~FLASH_CR_PSIZE_MASK;
@ -108,30 +108,30 @@ int flashSectorErase(flashsector_t sector) {
FLASH->CR |= FLASH_CR_STRT;
/* Wait until it's finished. */
flashWaitWhileBusy();
intFlashWaitWhileBusy();
/* Sector erase flag does not clear automatically. */
FLASH->CR &= ~FLASH_CR_SER;
/* Lock flash again */
flashLock()
intFlashLock()
;
/* Check deleted sector for errors */
if (flashIsErased(flashSectorBegin(sector), flashSectorSize(sector)) == FALSE)
if (intFlashIsErased(intFlashSectorBegin(sector), flashSectorSize(sector)) == FALSE)
return FLASH_RETURN_BAD_FLASH; /* Sector is not empty despite the erase cycle! */
/* Successfully deleted sector */
return FLASH_RETURN_SUCCESS;
}
int flashErase(flashaddr_t address, size_t size) {
int intFlashErase(flashaddr_t address, size_t size) {
while (size > 0) {
flashsector_t sector = flashSectorAt(address);
int err = flashSectorErase(sector);
flashsector_t sector = intFlashSectorAt(address);
int err = intFlashSectorErase(sector);
if (err != FLASH_RETURN_SUCCESS)
return err;
address = flashSectorEnd(sector);
address = intFlashSectorEnd(sector);
size_t sector_size = flashSectorSize(sector);
if (sector_size >= size)
break;
@ -141,7 +141,7 @@ int flashErase(flashaddr_t address, size_t size) {
return FLASH_RETURN_SUCCESS;
}
bool flashIsErased(flashaddr_t address, size_t size) {
bool intFlashIsErased(flashaddr_t address, size_t size) {
/* Check for default set bits in the flash memory
* For efficiency, compare flashdata_t values as much as possible,
* then, fallback to byte per byte comparison. */
@ -161,7 +161,7 @@ bool flashIsErased(flashaddr_t address, size_t size) {
return TRUE;
}
bool flashCompare(flashaddr_t address, const char* buffer, size_t size) {
bool intFlashCompare(flashaddr_t address, const char* buffer, size_t size) {
/* For efficiency, compare flashdata_t values as much as possible,
* then, fallback to byte per byte comparison. */
while (size >= sizeof(flashdata_t)) {
@ -182,12 +182,12 @@ bool flashCompare(flashaddr_t address, const char* buffer, size_t size) {
return TRUE;
}
int flashRead(flashaddr_t address, char* buffer, size_t size) {
int intFlashRead(flashaddr_t address, char* buffer, size_t size) {
memcpy(buffer, (char*) address, size);
return FLASH_RETURN_SUCCESS;
}
static void flashWriteData(flashaddr_t address, const flashdata_t data) {
static void intFlashWriteData(flashaddr_t address, const flashdata_t data) {
/* Enter flash programming mode */
FLASH->CR |= FLASH_CR_PG;
@ -201,19 +201,19 @@ static void flashWriteData(flashaddr_t address, const flashdata_t data) {
#endif
/* Wait for completion */
flashWaitWhileBusy();
intFlashWaitWhileBusy();
/* Exit flash programming mode */
FLASH->CR &= ~FLASH_CR_PG;
}
int flashWrite(flashaddr_t address, const char* buffer, size_t size) {
int intFlashWrite(flashaddr_t address, const char* buffer, size_t size) {
/* Unlock flash for write access */
if (flashUnlock() == HAL_FAILED)
if (intFlashUnlock() == HAL_FAILED)
return FLASH_RETURN_NO_PERMISSION;
/* Wait for any busy flags */
flashWaitWhileBusy();
intFlashWaitWhileBusy();
/* Setup parallelism before any program/erase */
FLASH->CR &= ~FLASH_CR_PSIZE_MASK;
@ -241,7 +241,7 @@ int flashWrite(flashaddr_t address, const char* buffer, size_t size) {
memcpy((char*) &tmp + alignOffset, buffer, chunkSize);
/* Write the new data in flash */
flashWriteData(alignedFlashAddress, tmp);
intFlashWriteData(alignedFlashAddress, tmp);
/* Advance */
address += chunkSize;
@ -254,7 +254,7 @@ int flashWrite(flashaddr_t address, const char* buffer, size_t size) {
* copied requires special treatment. */
while (size >= sizeof(flashdata_t)) {
// print("flash write size=%d\r\n", size);
flashWriteData(address, *(const flashdata_t*) buffer);
intFlashWriteData(address, *(const flashdata_t*) buffer);
address += sizeof(flashdata_t);
buffer += sizeof(flashdata_t);
size -= sizeof(flashdata_t);
@ -267,11 +267,11 @@ int flashWrite(flashaddr_t address, const char* buffer, size_t size) {
if (size > 0) {
flashdata_t tmp = *(volatile flashdata_t*) address;
memcpy(&tmp, buffer, size);
flashWriteData(address, tmp);
intFlashWriteData(address, tmp);
}
/* Lock flash again */
flashLock()
intFlashLock()
;
return FLASH_RETURN_SUCCESS;

View File

@ -1,4 +1,4 @@
HW_LAYER_EMS += $(PROJECT_DIR)/hw_layer/ports/stm32/flash.c \
HW_LAYER_EMS += $(PROJECT_DIR)/hw_layer/ports/stm32/flash_int.c \
$(PROJECT_DIR)/hw_layer/ports/stm32/stm32f4/stm32f4xx_hal_flash.c \
$(PROJECT_DIR)/hw_layer/ports/stm32/stm32f4/stm32f4xx_hal_flash_ex.c

View File

@ -10,7 +10,7 @@
#if EFI_PROD_CODE
#include "mpu_util.h"
#include "flash.h"
#include "flash_int.h"
#include "engine.h"
#include "pin_repository.h"
#include "stm32f4xx_hal_flash.h"

View File

@ -132,7 +132,12 @@ typedef struct
* @{
*/
#define FLASH_FLAG_EOP FLASH_SR_EOP /*!< FLASH End of Operation flag */
/* migrate to updated header */
#ifdef FLASH_SR_OPERR
#define FLASH_FLAG_OPERR FLASH_SR_OPERR /*!< FLASH operation Error flag */
#else
#define FLASH_FLAG_OPERR FLASH_SR_SOP /*!< FLASH operation Error flag */
#endif
#define FLASH_FLAG_WRPERR FLASH_SR_WRPERR /*!< FLASH Write protected error flag */
#define FLASH_FLAG_PGAERR FLASH_SR_PGAERR /*!< FLASH Programming Alignment error flag */
#define FLASH_FLAG_PGPERR FLASH_SR_PGPERR /*!< FLASH Programming Parallelism error flag */

View File

@ -1,4 +1,4 @@
HW_LAYER_EMS += $(PROJECT_DIR)/hw_layer/ports/stm32/flash.c \
HW_LAYER_EMS += $(PROJECT_DIR)/hw_layer/ports/stm32/flash_int.c \
$(PROJECT_DIR)/hw_layer/ports/stm32/stm32f7/stm32f7xx_hal_flash.c \
$(PROJECT_DIR)/hw_layer/ports/stm32/stm32f7/stm32f7xx_hal_flash_ex.c

View File

@ -7,7 +7,7 @@
#include "global.h"
#include "mpu_util.h"
#include "flash.h"
#include "flash_int.h"
#include "engine.h"
#include "pin_repository.h"
#include "stm32f7xx_hal_flash.h"