Hi all,
My board is custom build, based on davinici da830evm. Processor is am1705, SDK is PSP-SDK-03.22.00.06.
I have been round and round with trying to get fw_setenv working but it never gets past the ioctl call with MEMERASE. However, fw_printenv is working fine. So I've come to the experts for help.
root@module:/sbin#
root@module:/sbin# fw_printenv csi_fs_dev
csi_fs_dev=5
root@module:/sbin# fw_setenv csi_fs_dev 6
MTD erase error on /dev/mtd3: Invalid argument
Error: can't write fw_env to flash
root@module:/sbin#
I have CONFIG_ENV_SIZE defined as 0x2800 in da830evm.h
I am trying to write to the uboot environment stored at /dev/mtd3 on a NAND flash device.
root@module:/sbin# cat /proc/mtd
dev: size erasesize name
mtd0: 00020000 00020000 "bootloader"
mtd1: 00020000 00020000 "AISUBL"
mtd2: 00120000 00020000 "U-Boot"
mtd3: 00040000 00020000 "U-BootEnv"
mtd4: 00600000 00020000 "kernel"
mtd5: 0fc20000 00020000 "rootfs1"
mtd6: 0fc20000 00020000 "rootfs2"
mtd7: 00002000 00001000 "BOARD-INFO"
mtd8: 001fe000 00001000 "CSI-Storage"
Here is the fw_env.config
/dev/mtd3 0x0000 0x2800 0x20000 1
Here is strace of the same command from above.
root@module:/sbin# strace fw_setenv csi_fs_dev 6
execve("/sbin/fw_setenv", ["fw_setenv", "csi_fs_dev", "6"], [/* 12 vars */]) = 0
brk(0) = 0x13000
uname({sys="Linux", node="module", ...}) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f4b000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=13799, ...}) = 0
mmap2(NULL, 13799, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb6f47000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabi/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\230\204\1\0004\0\0\0"..., 512) = 512
lseek(3, 1264508, SEEK_SET) = 1264508
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 2840) = 2840
lseek(3, 1261076, SEEK_SET) = 1261076
read(3, "A)\0\0\0aeabi\0\1\37\0\0\0\0054T\0\6\2\10\1\t\1\22\4\23\1\24\1"..., 42) = 42
fstat64(3, {st_mode=S_IFREG|0755, st_size=1267348, ...}) = 0
mmap2(NULL, 1303968, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6de6000
mprotect(0xb6f17000, 32768, PROT_NONE) = 0
mmap2(0xb6f1f000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x131000) = 0xb6f1f000
mmap2(0xb6f22000, 9632, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6f22000
close(3) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f46000
set_tls(0xb6f466d0, 0xb6f46db8, 0xb6f4d050, 0xb6f466d0, 0xb6f4d050) = 0
mprotect(0xb6f1f000, 8192, PROT_READ) = 0
mprotect(0xb6f4c000, 4096, PROT_READ) = 0
munmap(0xb6f47000, 13799) = 0
stat64("/dev/mtd3", {st_mode=S_IFCHR|0600, st_rdev=makedev(90, 6), ...}) = 0
brk(0) = 0x13000
brk(0x36000) = 0x36000
open("/dev/mtd3", O_RDONLY) = 3
ioctl(3, MCE_GET_RECORD_LEN or MEMGETINFO or MTRRIOC_SET_ENTRY, {type=MTD_NANDFLASH, flags=MTD_WRITEABLE, size=0x40000, erasesize=0x20000, writesize=0x800, oobsize=0x40, padding=0}) = 0
ioctl(3, MEMGETBADBLOCK, [0]) = 0
lseek(3, 0, SEEK_SET) = 0
read(3, "\242[A\10baudrate=115200\0bootargs=mem"..., 10240) = 10240
close(3) = 0
open("/dev/mtd3", O_RDWR) = 3
ioctl(3, MEMGETBADBLOCK, [0]) = 0
ioctl(3, MEMUNLOCK or MTRRIOC_SET_PAGE_ENTRY, {start=0, length=0x2800}) = -1 EOPNOTSUPP (Operation not supported)
ioctl(3, MCE_GET_LOG_LEN or MEMERASE or MTRRIOC_DEL_ENTRY, {start=0, length=0x2800}) = -1 EINVAL (Invalid argument)
write(2, "MTD erase error on /dev/mtd3: In"..., 47MTD erase error on /dev/mtd3: Invalid argument
) = 47
close(3) = 0
write(2, "Error: can't write fw_env to fla"..., 35Error: can't write fw_env to flash
) = 35
exit_group(1) = ?
+++ exited with 1 +++
root@module:/sbin#
thanks for reviewing this.
Dan