From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7A4CF219FE for ; Wed, 29 Nov 2023 23:57:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=none Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 76E521042; Wed, 29 Nov 2023 15:58:00 -0800 (PST) Received: from [192.168.1.247] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 157C63F73F; Wed, 29 Nov 2023 15:57:11 -0800 (PST) Message-ID: <0d46cc83-8820-4bf2-95bd-a0c12b6f7aff@arm.com> Date: Wed, 29 Nov 2023 23:57:09 +0000 Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: mdt_debug write Content-Language: en-US To: Stephen Graf Cc: Mikhail Kalashnikov , Jagan Teki , Vignesh R , Jaehoon Chung , Jernej Skrabec , Piotr Oniszczuk , u-boot@lists.denx.de, linux-sunxi@lists.linux.dev References: <20231114013106.31336-1-andre.przywara@arm.com> <20231114013106.31336-4-andre.przywara@arm.com> <0eab5c21-4fdc-478e-9071-f43c12e01fb3@gmail.com> <20231126002349.55404e43@slackpad.lan> <465a5608-89f7-4691-a2e0-ebec9b85d994@gmail.com> <20231126122342.3944cad5@slackpad.lan> <20231128013746.23648d39@slackpad.lan> <5d7ea381-2a57-46f7-85c6-2bcad339d1db@gmail.com> From: Andre Przywara In-Reply-To: <5d7ea381-2a57-46f7-85c6-2bcad339d1db@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi Stephen, On 28/11/2023 20:07, Stephen Graf wrote: > Below is the consol log from trying to use mtd_debug write. It returned > immediately with a strange success message. > > root@orangepizero3:~# mtd_debug write /dev/mtd0 0 0xf0000 > /home/sysadmin/u-boot-sunxi-with-spl.bin > file_to_flash: fread, size 0xf0000, n 0xf0000 > fread(): Success interesting, I was under the impression that "mtd_debug write" would be the way to write to flash. In hindsight, the "debug" in that name should have probably put me off. Anyway, "cat" is probably not a good choice, "dd" is better, but it looks like "flashcp" (also part of mtdutils) is the go-to tool, since it does the required erasing automatically and also reportedly does some error detection. Can you please test this? # flashcp u-boot-sunxi-with-spl.bin /dev/mtd0 I would test this on my end ASAP as well. Do you feel like sending a patch to the U-Boot documentation to get this changed then? Thanks, Andre > I then used the cat command to write to the SPI flash which took a few > seconds to execute: > > root@orangepizero3:~# cat /home/sysadmin/u-boot-sunxi-with-spl.bin > > /dev/mtd0 > > > >>>> >>>> I tried to follow the u-boot documentation on writing the SPI flash but >>>> had problems with the write command.  When issued it returned >>>> immediately. The erase command took about 5 sec to execute. I >>>> researched >>>> use of mtd commands and got a suggestion to use cat instead, which >>>> worked. >>>> >>>> "root@orangepizero3:~# mtdinfo >>>> Count of MTD devices:           1 >>>> Present MTD devices:            mtd0 >>>> Sysfs interface supported:      yes >>>> root@orangepizero3:~# mtd_debug erase /dev/mtd0 0 0xf0000 >>>> Erased 983040 bytes from address 0x00000000 in flash >>>> root@orangepizero3:~# mtd_debug write /dev/mtd0 0 0xf0000 >>>> /home/sysadmin/u-boot-sunxi-with-spl.bin >>>> file_to_flash: fread, size 0xf0000, n 0xf0000 >>>> fread(): Success >>>> >>>> >