Commit fa07c8ab authored by Vladimir Khusainov's avatar Vladimir Khusainov

RT93137 Support U-Boot environment in eNVM on STM32F4

parent 2cbcf4d4
......@@ -63,6 +63,7 @@ COBJS-$(CONFIG_ENV_IS_IN_NVRAM) += env_nvram.o
COBJS-$(CONFIG_ENV_IS_IN_ONENAND) += env_onenand.o
COBJS-$(CONFIG_ENV_IS_IN_SPI_FLASH) += env_sf.o
COBJS-$(CONFIG_ENV_IS_IN_SPIFI) += env_spifi.o
COBJS-$(CONFIG_ENV_IS_IN_ENVM) += env_envm.o
COBJS-$(CONFIG_ENV_IS_NOWHERE) += env_nowhere.o
# command
......
......@@ -36,6 +36,9 @@
#ifdef CONFIG_SPIFI
#include <spifi.h>
#endif
#ifdef CONFIG_ENVM
#include <envm.h>
#endif
#include <u-boot/md5.h>
#include <sha1.h>
......@@ -467,6 +470,21 @@ int do_mem_cp ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
}
#endif
#ifdef CONFIG_ENVM
if (envm_addr(dest) || envm_addr(dest + count)) {
if (envm_addr(addr) || envm_addr(addr + count)) {
puts ("Cannot copy from ENVM to ENVM, aborting.\n\r");
return 1;
}
if (!envm_addr(dest) || !envm_addr(dest + count)) {
puts ("Cannot copy across ENVM boundaries, "\
"aborting.\n\r");
return 1;
}
return envm_write(dest, (void *)addr, count);
}
#endif
while (count-- > 0) {
if (size == 4)
*((ulong *)dest) = *((ulong *)addr);
......
......@@ -64,9 +64,10 @@ DECLARE_GLOBAL_DATA_PTR;
!defined(CONFIG_ENV_IS_IN_ONENAND) && \
!defined(CONFIG_ENV_IS_IN_SPI_FLASH) && \
!defined(CONFIG_ENV_IS_IN_SPIFI) && \
!defined(CONFIG_ENV_IS_IN_ENVM) && \
!defined(CONFIG_ENV_IS_NOWHERE)
# error Define one of CONFIG_ENV_IS_IN_{EEPROM|FLASH|DATAFLASH|ONENAND|\
SPI_FLASH|SPIFI|MG_DISK|NVRAM|NOWHERE}
SPI_FLASH|SPIFI|ENVM|MG_DISK|NVRAM|NOWHERE}
#endif
#define XMK_STR(x) #x
......
......@@ -31,6 +31,15 @@ void envm_init(void);
# error "LPC43XX ENVM requires RAMCODE"
#endif
/*
* Check if an address is in the eNVM.
*/
static inline int envm_addr(unsigned long addr)
{
return addr >= CONFIG_SYS_ENVM_BASE &&
addr < CONFIG_SYS_ENVM_BASE + CONFIG_SYS_ENVM_LEN;
}
/*
* Write a data buffer to eNVM.
* Note that we need for this function to reside in RAM since it
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment