[U-Boot-Users] Multiple Flash Devices

Hello,
I'm currently working on getting u-boot to work from the internal flash of the 5282. I have it booting. and now I am working on getting all the flash programming stuff setup.
I want to be able to access two (very different) flash devices. I want to be able to write to the internal flash device so that I can save environmental variables, but I also want to be able to write to the external flash so I can program data into it.
Is there a good method of setting up two flash devices at once? As far as I can tell, all the flash functions (like flash_print_info, for example) can only be defined for one type of flash at a time.
There are two solutions I have thought of so far. One of them is pick whichever flash device is used the most and set that up normally. For the other flash, I could create different functions for it and in the code that calls it I can make the necessary changes to call the right functions. I don't like this as much, because I'd have to put special code various commands/ files to handle this.
The other option might be to create my own flash function wrappers that call the appropriate flash function based on, for example, the address passed into the function.
Has anyone else ran into this problem? Perhaps that is another board config that already deals with this? I looked around, but there are a lot of configs and I easily could have missed what I was looking for.

Zachary,
Is there a good method of setting up two flash devices at once? As far as I can tell, all the flash functions (like flash_print_info, for example) can only be defined for one type of flash at a time.
You can use the addresses to differentiate which flash device are accessed. Keep the same interfaces uboot has already had and just develop your own functions to do the actual jobs.
There are two solutions I have thought of so far. One of them is pick whichever flash device is used the most and set that up normally. For the other flash, I could create different functions for it and in the code that calls it I can make the necessary changes to call the right functions. I don't like this as much, because I'd have to put special code various commands/ files to handle this.
Nah, I wouldn't do that.
The other option might be to create my own flash function wrappers that call the appropriate flash function based on, for example, the address passed into the function.
That's what I did before on a EP8245 board. This way shields all the differences.
Good luck, -Shawn.

Is there a good method of setting up two flash devices at once? As far as I can tell, all the flash functions (like flash_print_info, for example) can only be defined for one type of flash at a time.
You can use the addresses to differentiate which flash device are accessed. Keep the same interfaces uboot has already had and just develop your own functions to do the actual jobs.
The other option might be to create my own flash function wrappers that call the appropriate flash function based on, for example, the address passed into the function.
That's what I did before on a EP8245 board. This way shields all the differences.
Shawn,
In that case, did both flash devices use the same driver? My two flash devices use different drivers. So what I am currently doing is adding a prefix to the different flash driver functions (ie: change CFI's write_buff to cfi_write_buff) and then adding function pointers to each flash bank structure indicating which function to use.
This seems to be a decent approach. The main problem is that the flash calls are a bit scattered, and also it will require all flash devices to be changed. But I'll continue with it unless someone has a better solution?

In message a04f56da050223073036aa7551@mail.gmail.com Zachary Landau wrote:
In that case, did both flash devices use the same driver? My two
There is always only one flash driver.
flash devices use different drivers. So what I am currently doing is adding a prefix to the different flash driver functions (ie: change CFI's write_buff to cfi_write_buff) and then adding function pointers to each flash bank structure indicating which function to use.
Why do you think this is necessary?
This seems to be a decent approach. The main problem is that the flash calls are a bit scattered, and also it will require all flash devices to be changed. But I'll continue with it unless someone has a
Such a change will never be accepted for the common source tree.
Best regards,
Wolfgang Denk

In message a04f56da05022109345c7fb8fc@mail.gmail.com you wrote:
I want to be able to access two (very different) flash devices. I
Just do it, then.
Is there a good method of setting up two flash devices at once? As
Yes, U-Boot has always been capable of doing this. Your flash devices will form spearate "banks" of flash memory. Thee is no requirement that all banks must be identical. In fact, several boards use different flash types on different banks.
far as I can tell, all the flash functions (like flash_print_info, for example) can only be defined for one type of flash at a time.
You are wrong.
There are two solutions I have thought of so far. One of them is pick whichever flash device is used the most and set that up normally. For the other flash, I could create different functions for it and in the
This is not accetable, and not necessary.
The other option might be to create my own flash function wrappers that call the appropriate flash function based on, for example, the address passed into the function.
You don't have to create any new interfaces. The existing code which provides a flash_info struncture per bank of flash memory is sufficient.
Has anyone else ran into this problem? Perhaps that is another board
It's not a problem. It's somthiong that is working fine on several boards.
config that already deals with this? I looked around, but there are a lot of configs and I easily could have missed what I was looking for.
See for example "board/cpu86/flash.c"
Best regards,
Wolfgang Denk

config that already deals with this? I looked around, but there are a lot of configs and I easily could have missed what I was looking for.
See for example "board/cpu86/flash.c"
The difference in my case is that I would like to make use of the drivers already included with u-boot for one of the flash devices. In my case, the external flash uses the CFI driver. I then wrote another flash driver to access the internal flash.
In the cpu86 example, they wrote drivers for both flash devices. I could do that, if necessary, but it seems better to reuse as much of the existing code as possible.
participants (3)
-
Shawn Jin
-
Wolfgang Denk
-
Zachary Landau