[U-Boot] U-Boot: Enhancement request to get flash device specific information

Hi U-boot team,
I am looking for u-boot command which can give me flash device specific properties. For example, there should be dedicated commands to get the flash memory size, sector size, page size etc.
Currently I found there is command "sf probe" for spi flash device which is returning device properties into text format as below: SF : Detected N25Q128A with page size 256 Bytes, erase size 64 KiB, total 16 MiB
Similarly I found there is command "nand info" for nand device which is also returning device properties into text format.
These commands ("sf probe" and "nand info") are giving device information in form of message. Which does not meet my requirement.
Actually I would like to integrate u-boot with my tool, where tool will run u-boot command to get the device information. Based on device information tool will react. Here I am looking for some dedicated command which return these property separately. It is difficult to parse the message string to get individual
Let say we includes following commands: "nand info pagesize/sectorsize/size/device" "sf info pagesize/sectorsize/size/device"
for example: "nand info pagesize" command should return page size ( e.g. *256*) "nand info sectorsize" command should return sector size (e.g. *65536* which is 64K) "nand info size" command should return the total size (e.g. *268435456 *which is 16 MB)
Could you please consider this enhancement request in u-boot? Please comment.
Regards, Heera

Hi,
On 2 July 2014 10:05, HEERA NAND BHAGTANI diamond.mbm@gmail.com wrote:
Hi U-boot team,
I am looking for u-boot command which can give me flash device specific properties. For example, there should be dedicated commands to get the flash memory size, sector size, page size etc.
Currently I found there is command "sf probe" for spi flash device which is returning device properties into text format as below: SF : Detected N25Q128A with page size 256 Bytes, erase size 64 KiB, total 16 MiB
Similarly I found there is command "nand info" for nand device which is also returning device properties into text format.
These commands ("sf probe" and "nand info") are giving device information in form of message. Which does not meet my requirement.
Actually I would like to integrate u-boot with my tool, where tool will run u-boot command to get the device information. Based on device information tool will react. Here I am looking for some dedicated command which return these property separately. It is difficult to parse the message string to get individual
Let say we includes following commands: "nand info pagesize/sectorsize/size/device" "sf info pagesize/sectorsize/size/device"
for example: "nand info pagesize" command should return page size ( e.g. *256*) "nand info sectorsize" command should return sector size (e.g. *65536* which is 64K) "nand info size" command should return the total size (e.g. *268435456 *which is 16 MB)
Could you please consider this enhancement request in u-boot? Please comment.
What kind of tool? Is it a U-Boot script? How does it get access to the output from U-Boot?
You could use a regular expression to extract the information you need. For the commands you suggest, it might be better to put the values in an environment variable.
Regards, Simon

Hi Simon,
This tool is basically using u-boot technology to communicating to remote board. This tool is developed such a way that it can load u-boot elf on remote processor (available on remote board). This tool communicates with processor using u-boot commands. It can send the u-boot command, and can read the u-boot output message.
I am avoiding to use regular expression to extract the information. It has two reasons, 1) In future realise of u-boot if string format is changed, my regular expression will fail. So I need to track the format change in this message. 2) It is possible that current message does not carry all informations of Flash device. For example,this message does not specify the kind of spi flash it is (dual or single). So we may need to enhance message to provide flash type. So for any new property, we need to change this message and as a result it would break scripts/tools for those people who have been used regular expression on this message.
So here I am suggesting to have a dedicated flag in u-boot command for each property of flash device. In future any new property would be needed, we only need to add a new tag and it would work without breaking any existing stuff for users.
As per my current requirement, I can make the changes in my local u-boot source code and can bring these new flags which will work for me. Here I am suggesting, if we can provide this is generic solution for everyone. I believe, it would be quite helpful for those guys who would like to integrate u-boot in their tools or scripts.
Regards, Heera
On Thu, Jul 3, 2014 at 10:28 PM, Simon Glass sjg@chromium.org wrote:
Hi,
On 2 July 2014 10:05, HEERA NAND BHAGTANI diamond.mbm@gmail.com wrote:
Hi U-boot team,
I am looking for u-boot command which can give me flash device specific properties. For example, there should be dedicated commands to get the flash memory size, sector size, page size etc.
Currently I found there is command "sf probe" for spi flash device which
is
returning device properties into text format as below: SF : Detected N25Q128A with page size 256 Bytes, erase size 64 KiB, total 16 MiB
Similarly I found there is command "nand info" for nand device which is also returning device properties into text format.
These commands ("sf probe" and "nand info") are giving device information in form of message. Which does not meet my requirement.
Actually I would like to integrate u-boot with my tool, where tool will
run
u-boot command to get the device information. Based on device information tool will react. Here I am looking for some dedicated command which
return
these property separately. It is difficult to parse the message string to get individual
Let say we includes following commands: "nand info pagesize/sectorsize/size/device" "sf info pagesize/sectorsize/size/device"
for example: "nand info pagesize" command should return page size ( e.g. *256*) "nand info sectorsize" command should return sector size (e.g. *65536* which is 64K) "nand info size" command should return the total size (e.g. *268435456
*which
is 16 MB)
Could you please consider this enhancement request in u-boot? Please comment.
What kind of tool? Is it a U-Boot script? How does it get access to the output from U-Boot?
You could use a regular expression to extract the information you need. For the commands you suggest, it might be better to put the values in an environment variable.
Regards, Simon

Dear Heera,
In message CANiu2MrgDg8zmHK8Dm90TJn1SgsRTe2juXScgGq11M=JEDKZYQ@mail.gmail.com you wrote:
I am avoiding to use regular expression to extract the information. It has two reasons,
- In future realise of u-boot if string format is changed, my regular
expression will fail. So I need to track the format change in this message. 2) It is possible that current message does not carry all informations of Flash device. For example,this message does not specify the kind of spi flash it is (dual or single). So we may need to enhance message to provide flash type. So for any new property, we need to change this message and as a result it would break scripts/tools for those people who have been used regular expression on this message.
I think you are taking a wrong approach to solve the task you actually have in mind. Instead of trying to get all kinds if deeply low-leven information out of U-Boot, you should try to find an abstraction level that allows you to perform your task without knowledge about these details.
Normally you do not really want to have to bother about details like page size or erase size - you want to store some data on your device, and the low-level internal organization of the storage device is not really important here. The usual approach to abstract away from such lowlevel details is to use command formats that do not refer to such data.
One approach that allows this is the structuring of your storage device into logical units, like for example MTD partitions. This has the added benefit that you can pass the information about this partitioning to the Linux kernel, so both U-Boot and Linux use the same data layout.
I am aware that current mainline does not support "mtdparts" for SPI-NOR flash devices, but patches have been posted before, and it should be not too difficult to rebase these against current code (and fix the issues that prevented their inclusion into mainline).
Such an approach that abstracts away the internal complexity of the storage device and provides higher level access methods looks much more promising to me, especially when you think about including it into mainline.
Frankly, I don;t think your original proposal has much chance for being included into mainline. It is way too complex and fragile.
Best regards,
Wolfgang Denk
participants (3)
-
HEERA NAND BHAGTANI
-
Simon Glass
-
Wolfgang Denk