Jump to content


Photo

Orange Pi zero NOR Flash


  • Please log in to reply
11 replies to this topic

#1 Voloviq

Voloviq

    Newbie

  • Senior Members
  • Pip
  • 7 posts

Posted 15 February 2017 - 03:07 PM

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.o..._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



#2 martinayotte

martinayotte

    Advanced Member

  • Senior Members
  • PipPipPip
  • 442 posts

Posted 15 February 2017 - 04:20 PM

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 :

 

Spoiler

 

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


  • awef likes this

#3 Voloviq

Voloviq

    Newbie

  • Senior Members
  • Pip
  • 7 posts

Posted 15 February 2017 - 09:05 PM

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



#4 zador.blood.stained

zador.blood.stained

    Advanced Member

  • Moderators
  • 1838 posts

Posted 15 February 2017 - 09:18 PM

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.o..._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.


Spoiler

#5 Voloviq

Voloviq

    Newbie

  • Senior Members
  • Pip
  • 7 posts

Posted 15 February 2017 - 09:35 PM

So if I good understand I need to download nightly build and burn to sdcard, and than modify DT.



#6 Voloviq

Voloviq

    Newbie

  • Senior Members
  • Pip
  • 7 posts

Posted 15 February 2017 - 10:03 PM

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



#7 Voloviq

Voloviq

    Newbie

  • Senior Members
  • Pip
  • 7 posts

Posted 16 February 2017 - 09:21 AM

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



#8 zador.blood.stained

zador.blood.stained

    Advanced Member

  • Moderators
  • 1838 posts

Posted 16 February 2017 - 11:37 AM

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.


Spoiler

#9 Voloviq

Voloviq

    Newbie

  • Senior Members
  • Pip
  • 7 posts

Posted 16 February 2017 - 01:50 PM

Thanks zador,

 

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

First updated to nightly build

 

Spoiler

 

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

 

Spoiler

 

Regards

Voloviq



#10 martinayotte

martinayotte

    Advanced Member

  • Senior Members
  • PipPipPip
  • 442 posts

Posted 16 February 2017 - 02:33 PM

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.



#11 zador.blood.stained

zador.blood.stained

    Advanced Member

  • Moderators
  • 1838 posts

Posted 16 February 2017 - 02:40 PM

Linux version after update

 

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

That is what you needed to start with. These instructions don't apply for the legacy kernel. You can use flashrom on /dev/spidev0.0 to read/write flash contents.


Spoiler

#12 Voloviq

Voloviq

    Newbie

  • Senior Members
  • Pip
  • 7 posts

Posted 16 February 2017 - 08:39 PM

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