Jump to content

Orange Pi zero NOR Flash


Voloviq

Recommended Posts

Hello,

 

today I try to recompile armbian and produce some image which can be fited into nor flash. I would like to fit uboot, dtb and kernel into Winbond W25Q128FVSSIG and rootfs into sdcard. So I found some instruction in which I need to modify first kernel and dts (ref. http://linux-sunxi.org/Xunlong_Orange_Pi_Zerochapter SPI NOR flash). For Armbian it is quit difficult, when I issue ./compile.sh than everything regarding to Uboot is cleared. First what I need to do is modify sun8i-h3-orangepi-one.dts with following content

&spi0 {        status = "okay";        flash: m25p80@0 {                #address-cells = <1>;                #size-cells = <1>;                compatible = "winbond,w25q128";                reg = <0>;                spi-max-frequency = <40000000>;        };};

Than I need to modify .config file of Uboot by adding CONFIG_SPI_BOOT=yes. But as I mentioned after issue ./compile.sh everything go back to let we say factory settings. How to workaround this issue to pass through necessary options.

 

Final question is that if all of mentioned modification allows me to manipulate and see /dev/mtd0.

 

Thanks in advanced

Best Regards

Voloviq

Link to comment
Share on other sites

You don't need to do all this since nightly builds already provides SPI-NOR support. The only thing you have to do is changing the partitions sizes in the current DT :

 

 

 

                spi@01c68000 {
                        compatible = "allwinner,sun8i-h3-spi";
                        reg = <0x1c68000 0x1000>;    
                        interrupts = <0x0 0x41 0x4>;
                        clocks = <0x2 0x1e 0x2 0x52>;
                        clock-names = "ahb", "mod";  
                        dmas = <0x19 0x17 0x19 0x17>;
                        dma-names = "rx", "tx";   
                        pinctrl-names = "default";
                        pinctrl-0 = <0x1a>;
                        resets = <0x2 0xf>;
                        status = "okay";
                        #address-cells = <0x1>;
                        #size-cells = <0x0>;   
                        linux,phandle = <0x4c>;
                        phandle = <0x4c>;

                        spi-flash@0 {
                                #address-cells = <0x1>;
                                #size-cells = <0x0>;
                                compatible = "jedec,spi-nor";
                                reg = <0x0>;
                                spi-max-frequency = <0x989680>;
                                status = "okay";

                                partitions {
                                        compatible = "fixed-partitions";
                                        #address-cells = <0x1>;
                                        #size-cells = <0x1>;

                                        partition@0 {
                                                label = "uboot";
                                                reg = <0x0 0x100000>;
                                        };

                                        partition@100000 {
                                                label = "env";
                                                reg = <0x100000 0x100000>;
                                        };

                                        partition@200000 {
                                                label = "data";
                                                reg = <0x200000 0x200000>;
                                        };
                                };
                        };
                };

 

 

 

You will see the MTD partitions by doing "cat /proc/mtd", and you can use flashcp from mtd-utils to write to /dev/mtd0.

Link to comment
Share on other sites

Thanks Martinayotte,

 

I newbie in Armbian compilation, can You explain me how to compile nightly build in Armbian and which exactly ?.dts needs to be modified.

 

Regarding Your final sentence I understand that it is possible fit kernel, uboot and dtb into spi nor flash. Am I right?

 

Thanks,

Regards

Voloviq

Link to comment
Share on other sites

today I try to recompile armbian and produce some image which can be fited into nor flash. I would like to fit uboot, dtb and kernel into Winbond W25Q128FVSSIG and rootfs into sdcard. So I found some instruction in which I need to modify first kernel and dts (ref. http://linux-sunxi.org/Xunlong_Orange_Pi_Zerochapter SPI NOR flash).

Right now you won't be able to use DT and kernel from the SPI flash since there is no SPI driver or SPL FIT image support in u-boot. These instructions are for having only the u-boot in the SPI flash.

I'm not saying this is completely impossible, but you will need to put significant effort into finding and applying additional patches to the u-boot and it's up to you to do that work.

 

For Armbian it is quit difficult, when I issue ./compile.sh than everything regarding to Uboot is cleared.

The Armbian documentation was made and linked from the project page for a good reason.

Link to comment
Share on other sites

Hello zador.blood.stained

 

yes You have completely right my question was really silly. After study short build documentation everything start to be easy.  Now I understand why uboot and kernel are cleared after issue only ./compile.sh. Nevertheless which option I should use together with ./compile.sh to keep changed configuration for kernel and uboot?

 

Do compilation don't clean current configuration of kernel and uboot after issue following

 

./compile.sh CLEAN_LEVEL=images KERNEL_KEEP_CONFIG=yes

 

Thanks

Regards

Voloviq

Link to comment
Share on other sites

Hello martinayote

 

It seems to that in current system don't exist *.dtb or *.dts file. Instead of it exist script.bin which can be convert to *.fex. After conver *.fex file is somehow similar to *.dts. Unfortunately I don't now this standard. I understand what You wrote regarding to DT, and any modification in DT are easy. Usually I made modification of dts but not on working system, I just recompile it and write in host on sdcard. So how can I provide modification pointed by You into *.fex file and again compile *.fex to script.bin.

 

Thanks

Regards

Voloviq

Link to comment
Share on other sites

First, you don't need to recompile anything for the Orange Pi Zero & Armbian. If for some reason you chose the mainline/dev kernel, SPI flash support is already enabled both in the kernel and u-boot - check your dmesg log and presence of /dev/mtd* device nodes.

 

Second, in order to adjust partition sizes as per @martinayotte's post you can use dtc - device tree compiler on the board itself, you can search the forum for the instructions or just read the man page for dtc. Also please note that DT file name for Orange Pi Zeo is sun8i-h2plus-orangepi-zero.dtb

 

And third, as I said before, even if you adjust partition sizes you will be able to access data from the kernel but not from the u-boot, at least without additional patches or non-standard hacks (SPL FIT support, experimental u-boot H3 SPI driver), which were not tested and are not documented well enough yet because all this is work-in-progress and is subjected to change at any time before it is accepted in the mainline.

Link to comment
Share on other sites

Thanks zador,

 

Your answer is very comprehensive. Small summarize what I made.

First updated to nightly build

 

 

sed -i "s/apt/beta/" /etc/apt/sources.list.d/armbian.list
apt-get update
apt-get upgrade

 

 

Than I make a reboot, connect oscilloscope to pin 6 of nor flash to check clock. After two reboots I noticed nothing on clock pin as well on others pins. This means that nightly build have no DTS default support for NOR flash, Am I right?

 

So I focus my efforts now to recompile dts, fex to add lines mentioned by martinayotte. IMHO without change dts I have no chance to see mtd.

 

Linux version after update

 

Linux orangepizero 3.4.113-sun8i #50 SMP PREEMPT Thu Feb 16 03:00:06 CET 2017 armv7l

 

Regards

Voloviq

Link to comment
Share on other sites

First, from what I'm aware, only Mainline kernel support SPI-NOR, so Legacy won't work.

Second, the clock on the chip is only present during transactions and idle the rest of the time, so connecting an oscilloscope is a bit useless since during boot the only transaction happening is the JEDEC ID query which last only few microseconds.

Third, DTS is only use in Mainline. Legacy is using FEX, but again no SPI-NOR support in Legacy.

Link to comment
Share on other sites

Hello Guys,

 

thank You both. Now I see where I made a mistake. Regarding oscilloscope I mean that during kernel boot up it checks connected devices (NOR - jedec discover at least). Yes of course that if nothing is requested from flash nothing will happen on pins.

 

So thank You for support my efforts. I'll keep You inform.

 

Thanks a lot

Best Regards

Volvoiq

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines