How to configure SPI on BBB?

Discussion about U-Boot and the kernel.

Re: How to configure SPI on BBB?

Postby Zeno » Mon Mar 26, 2018 11:41 am

@summers. Thanks, I am using BBB+arch in applications which are much more electronics oriented (I/O, PRU), for me this open community/collaboration is perfect. Still, the underlying development pace is quite fast, for a soloer like me, whenever there is a new approach in some part of the system, one has to dig deep everytime, that is good in the end as one has to study around and also it widens overall grasp of things.

Personally, I like the new DT approach, it seems to me as more mature solution - as I do think that parameters like hardware modes and such should be decided/set at boot time (ok, there are probably special cases). With the new boot.txt/mkscr way, you cleanly see what you do with u-boot on lowest level and general function of device trees is also brought closer to the user. The more experiments, the faster the documentation will gather up (forum sort of :)). It could be also a good reference to users of other distributions, that hide this setup in front of them. Long live rolling (stone) release model.

As to the question, FDT_ERR_NOSPACE was returned when using resize WITHOUT the size parameter. Just out of curiosity I looked on the sizes of the main DTB and my overlay - DTB is of 56253 size in bytes, which has 1091 bytes remaining to its 4KB boundary, the size of my overlay is 2947 bytes - evidently won't fit. Seems like fdt resize function and FDT_ERR_NOSPACE is now clear. Therefore I will use the fdt resize 0x60000 approch from now on. To sum up again the process of loading DTB with overlays:
1) load base DTB
2) point fdt to its address, resize its size to accomodate desired overlays
3) load overlay to safe address (behind base DTB, or ramdisk space)
4) apply loaded overlay from its address
That is all I could comment on this problem for now.
Have a nice day.
Zeno
Zeno
 
Posts: 14
Joined: Wed May 03, 2017 5:00 pm

Re: How to configure SPI on BBB?

Postby summers » Mon Mar 26, 2018 7:11 pm

Hi Zeno,

Think I see the confusion. Uboot help for "fdt resize" says:

$this->bbcode_second_pass_quote('', 'f')dt resize [<extrasize>] - Resize fdt to size + padding to 4k addr + some optional <extrasize> if needed


Which I take as saying the parameter adds that to the existing size of the device tree. If so we should be fine if:

$this->bbcode_second_pass_code('', 'fdt resize 2947')

is used, as that would guarantee at least that number of extra bytes.

I'll test that in a mo.

Now what would be good is if we could automatically get the size, I though when a file was loaded it printed the size - I wonder if it sets a variable, because then we could just use that ...

OK- just tested, and this worked:

$this->bbcode_second_pass_code('', ' load ${devtype} ${devnum}:${bootpart} 0x88060000 /lib/firmware/BB-SPIDEV0-00A0.dtbo
fdt resize ${filesize}
fdt apply 0x88060000')

Now that should *I think* work with any size of overlay, and could be done multiple times with many overlays.

Oh yes - I agree with you about the device tree approach to overlays, changing the device tree in uboot is the way to avoid problems and race conditions in the kernel ....

And just an idle thought added later. Some parts of the overlay are probably things like setting status flags. Now most of these are probably already in the device tree. So when we do the overlay, does it take extra space? If it overwrites part of the original tree, then we may not need the full ${filesize} additional space. If that is the case, and we are sensitive to this, can we just fix it if after the last "fdt apply" we do another "fdt resize", where this just checks the device tree and sets the size to its preferred value. Now it would seem that this would only at most save a few bytes (well 4k) - so I suspect this isn't worth worrying about as its so small ...

And another update - just tried:
$this->bbcode_second_pass_code('', ' load ${devtype} ${devnum}:${bootpart} 0x88060000 /lib/firmware/BB-SPIDEV0-00A0.dtbo
fdt resize ${filesize}
fdt apply 0x88060000
load ${devtype} ${devnum}:${bootpart} 0x88060000 /lib/firmware/BB-SPIDEV1-00A0.dtbo
fdt resize ${filesize}
fdt apply 0x88060000')
And on rebooting - this worked as well. I have:
$this->bbcode_second_pass_code('', '/dev/spidev0.0
/dev/spidev0.1
/dev/spidev1.0
/dev/spidev1.1')
So looks to me like we have cracked the easy way of overlays in arch.
summers
 
Posts: 984
Joined: Sat Sep 06, 2014 12:56 pm

Previous

Return to U-Boot/Kernel

Who is online

Users browsing this forum: No registered users and 7 guests