Writing to DataFlash from linux

Discussion around AT91RM9200 and SAM9 Series Products.

Moderator: nferre

vranckenc
Posts: 12
Joined: Fri Oct 12, 2007 4:56 am

Writing to DataFlash from linux

Tue Feb 19, 2008 8:41 pm

Is it possible to replace AT91Bootstrap (on the DataFlash) from Linux user space?

This is what my target system (AT91SAM9263-EK, busybox, manual /dev nodes) tells me about MTD:

# cat /proc/mtd
dev: size erasesize name
mtd0: 04000000 00020000 "Partition 1"
mtd1: 0c000000 00020000 "Partition 2"
mtd2: 00840000 00000420 "spi0.0-AT45DB642x"
# ls -l /dev/mtd2
crw-r--r-- 1 root root 90, 4 Feb 19 2008 /dev/mtd2
# mtd_debug info /dev/mtd2
mtd.type = (unknown type - new MTD API maybe?)
mtd.flags =
mtd.size = 8650752 (8M)
mtd.erasesize = 1056 (1K)
mtd.oobblock = 1056 (1K)
mtd.oobsize = 0
mtd.ecctype = (unknown ECC type - new MTD API maybe?)
regions = 0

I have tried using:

# mtd_debug write /dev/mtd2 0 4120 /home/dataflash_at91sam9263ek.bin
Copied 4120 bytes from /home/dataflash_at91sam9263ek.bin to address 0x00000000 in flash

But AT91Bootstrap is not functional after that, I need to flash it manually using the SAM-BA tool. Flashing the exact same .bin image with this method works. And by the way, the .bin file size is 4120 byte:

# ls /home/dataflash_at91sam9263ek.bin -l
-rw-r--r-- 1 500 500 4120 Feb 19 2008 /home/dataflash_at91sam9263ek.bin

Another approach:

# flash_info /dev/mtd2
Device /dev/mtd2 has 0 erase regions

# flashcp -v /dev/mtd2 /home/dataflash_at91sam9263ek.bin
This doesn't seem to be a valid MTD flash device!

Anyone has a suggestion..?

Thanks a lot,

Carlos
Stefan J
Posts: 12
Joined: Thu Sep 15, 2016 10:07 am

Re: Writing to DataFlash from linux

Thu Sep 22, 2016 12:24 pm

Same problem:

root@sama5d3xek:~# cat /proc/mtd
dev: size erasesize name
mtd0: 00040000 00020000 "bootstrap"
mtd1: 00080000 00020000 "uboot"
mtd2: 00040000 00020000 "env"
mtd3: 00040000 00020000 "env_redundant"
mtd4: 00040000 00020000 "spare"
mtd5: 00080000 00020000 "dtb"
mtd6: 00600000 00020000 "kernel"
mtd7: 0f800000 00020000 "rootfs"
mtd8: 00400000 00001000 "spi32766.0"

root@sama5d3xek:~# mtd_debug info /dev/mtd8
mtd.type = MTD_NORFLASH
mtd.flags = MTD_CAP_NORFLASH
mtd.size = 4194304 (4M)
mtd.erasesize = 4096 (4K)
mtd.writesize = 1
mtd.oobsize = 0
regions = 0

Any idea to solve that?
blue_z
Location: USA
Posts: 1497
Joined: Thu Apr 19, 2007 10:15 pm

Re: Writing to DataFlash from linux

Fri Sep 23, 2016 8:43 pm

vranckenc wrote:Is it possible to replace AT91Bootstrap (on the DataFlash) from Linux user space?
Yes, assuming that you have a properly configured system.

Older versions of AT91Bootstrap (certainly one circa 2008) did not build with an ARM Exception vector suitable for RomBOOT.
Specifically the length value in the sixth word was missing. Refer to the Atmel datasheets (the boot strategy section) for more detail.
vranckenc wrote:I need to flash it manually using the SAM-BA tool. Flashing the exact same .bin image with this method works.
That provides a clue to the solution.
All you had to do was read this image from flash (using the complementary operation that you used in Linux userspace), and then compare it with the original image.
Then you'd realize that the SAM-BA utility had modified the vector.

Regards

Return to “SAM9 ARM9 MPU”

Who is online

Users browsing this forum: No registered users and 5 guests