Re: Raspberry Pi SD access

2020-10-07 Thread Adam Lackorzynski
Hi Mohamed,

on the rpi4 there's a global offset used in Linux's device tree (check
for ranges statement in bcm2711.dtsi). The address of the sdhc/mmc
controller rather is 0xfe30. Also use 0x7e + 32 for the IRQ to
consider it's an SPI.



Adam

On Wed Oct 07, 2020 at 20:28:44 +0200, Mohamed Nasr wrote:
> I am trying to access SD card of Raspberry Pi 4 But the IO fail with
> IO  | new iomem region: p=007e00 v=40 s=40
> (bmb=0x24370)
> IO  | map mem: p=007e30 v=70 s=1000: failed(-12)
> VMM: FATAL: Insufficient memory
> 
> Can you help me on what I am missing?
> 
> My configurations are:
> 
> --- io.cfg --
> local Res = Io.Res
> local Hw = Io.Hw
> local add_children = Io.Dt.add_children
> 
> add_children(Io.system_bus(), function()
> mmc = Hw.Device(function()
> compatible = { "brcm,bcm2835-mmc" };
> Resource.reg0 = Res.mmio(0x7e30, 0x7e3000FF);
> Resource.irq0 = Res.irq(0x7e);
> Property.flags = Io.Hw_device_DF_dma_supported;
> end)
> end)
> 
>  vm_hw.vbus ---
> Io.add_vbusses
> {
>   vm_hw = Io.Vi.System_bus(function()
> MMC = wrap(Io.system_bus().mmc);
>   end);
> }
> 
>  rpi_mmc.ned -
> local L4 = require("L4");
> local l = L4.default_loader;
> 
> vbus_l4linux = l:new_channel();
> 
> -- Start io & flash memory
> l:start({
> caps = {
> sigma0 = L4.cast(L4.Proto.Factory,
> L4.Env.sigma0):create(L4.Proto.Sigma0),
> icu = L4.Env.icu,
> vm_hw = vbus_l4linux:svr()
> },
> log = {"IO", "y"}
> }, "rom/io rom/io.cfg rom/vm_hw.vbus -vv");
> 
> l:startv({
> caps = {
> ram = L4.Env.user_factory:create(L4.Proto.Dataspace, 256 * 1024 *
> 1024, 7, 21):m("rws");
> vbus = vbus_l4linux;
> },
> log = L4.Env.log:m("rws")
> }, "rom/uvmm", "-v", "-krom/image.bin",
> "-rrom/ramdisk-arm64.rd",
> "-drom/virt-arm_virt-64-2.dtb",
> "-cconsole=hvc0 ramdisk_size=1 root=/dev/ram0 rw");
> 
> --- modules.list -
> entry rpi-mmc
> kernel fiasco -serial_esc
> roottask moe rom/rpi-mmc.ned
> module uvmm
> module l4re
> module ned
> module virt-arm_virt-64-mod.dtb
> module ramdisk-arm64.rd
> module rpi-mmc.ned
> module image.bin
> module io
> module io.cfg
> module vm_hw.vbus
> 
> - I added mmc to device tree -
> mmc@7e30 {
>compatible = "brcm,bcm2835-mmc", "brcm,bcm2835-sdhci";
>reg = <0x7e30 0x100>;
>interrupts = <0x0 0x7e 0x4>;
>clocks = <0x3 0x1c>;
>dmas = <0xa 0xb>;
>dma-names = "rx-tx";
>brcm,overclock-50 = <0x0>;
>status = "disabled";
>pinctrl-names = "default";
>pinctrl-0 = <0x19>;
>bus-width = <0x4>;
>phandle = <0x2d>;
> };
> 
> 
> I tested Linux kernel with uvmm module and without IO module and it was
> working perfectly. I compiled it with the following options on:
> 
>  CONFIG_VIRTIO=y
>  CONFIG_VIRTIO_PCI=y
>  CONFIG_VIRTIO_BLK=y
>  CONFIG_BLK_MQ_VIRTIO=y
>  CONFIG_VIRTIO_CONSOLE=y
>  CONFIG_VIRTIO_INPUT=y
>  CONFIG_VIRTIO_NET=y
> 
> -
> boot log messages are:
> 
> L4 Bootstrapper
>   Build: #104 Wed Oct  7 20:14:57 EET 2020, 7.5.0
>   Raspberry Pi Model 4B, Rev 1.1, 4096MB, SoC BCM2711 [c03111]
>   Warranty intact, OTP reading allowed, OTP programming allowed,
> Overvoltage allowed
>   RAM:  - 3b3f: 970752kB
>   RAM: 4000 - fbff: 3080192kB
>   Total RAM: 3956MB
>   Scanning fiasco
>   Scanning sigma0
>   Scanning moe
>   Moving up to 14 modules behind 110
>   moving module 13 { 254-25400bb } -> { 262c000-262c0bb } [188]
>   moving module 12 { 253f000-253f555 } -> { 262b000-262b555 } [1366]
>   moving module 11 { 230c000-253e187 } -> { 23f8000-262a187 } [2302344]
>   moving module 10 { 15b3000-230b9ff } -> { 169f000-23f79ff } [13994496]
>   moving module 09 { 15b2000-15b22ea } -> { 169e000-169e2ea } [747]
>   moving module 08 { 1232000-15b1fff } -> { 131e000-169dfff } [3670016]
>   moving module 07 { 1231000-123176c } -> { 131d000-131d76c } [1901]
>   moving module 06 { 11be000-123041f } -> { 12aa000-131c41f } [468000]
>   moving module 05 { 11a-11bd14f } -> { 128c000-12a914f } [119120]
>   moving module 04 { 119f000-119fdbf } -> { 128b000-128bdbf } [3520]
>   moving module 03 { 10eb000-119e957 } -> { 11d7000-128a957 } [735576]
>   moving module 02 { 10ad000-10eaf0f } -> { 1199000-11d6f0f } [253712]
>   moving module 01 { 10a3000-10ac947 } -> { 118f000-1198947 } [39240]
>   moving module 00 { 1014000-10a24c7 } -> { 110-118e4c7 } [582856]
>   Loading fiasco
>   Loading sigma0
>   Loading moe
>   find kernel info page...
>   found kernel info page (via ELF) at 3000
> Regions of list 'regions'
> [0,   fff] { 

Raspberry Pi SD access

2020-10-07 Thread Mohamed Nasr
Hi L4 Team,

I am trying to access SD card of Raspberry Pi 4 But the IO fail with
IO  | new iomem region: p=007e00 v=40 s=40
(bmb=0x24370)
IO  | map mem: p=007e30 v=70 s=1000: failed(-12)
VMM: FATAL: Insufficient memory

Can you help me on what I am missing?

My configurations are:

--- io.cfg --
local Res = Io.Res
local Hw = Io.Hw
local add_children = Io.Dt.add_children

add_children(Io.system_bus(), function()
mmc = Hw.Device(function()
compatible = { "brcm,bcm2835-mmc" };
Resource.reg0 = Res.mmio(0x7e30, 0x7e3000FF);
Resource.irq0 = Res.irq(0x7e);
Property.flags = Io.Hw_device_DF_dma_supported;
end)
end)

 vm_hw.vbus ---
Io.add_vbusses
{
  vm_hw = Io.Vi.System_bus(function()
MMC = wrap(Io.system_bus().mmc);
  end);
}

 rpi_mmc.ned -
local L4 = require("L4");
local l = L4.default_loader;

vbus_l4linux = l:new_channel();

-- Start io & flash memory
l:start({
caps = {
sigma0 = L4.cast(L4.Proto.Factory,
L4.Env.sigma0):create(L4.Proto.Sigma0),
icu = L4.Env.icu,
vm_hw = vbus_l4linux:svr()
},
log = {"IO", "y"}
}, "rom/io rom/io.cfg rom/vm_hw.vbus -vv");

l:startv({
caps = {
ram = L4.Env.user_factory:create(L4.Proto.Dataspace, 256 * 1024 *
1024, 7, 21):m("rws");
vbus = vbus_l4linux;
},
log = L4.Env.log:m("rws")
}, "rom/uvmm", "-v", "-krom/image.bin",
"-rrom/ramdisk-arm64.rd",
"-drom/virt-arm_virt-64-2.dtb",
"-cconsole=hvc0 ramdisk_size=1 root=/dev/ram0 rw");

--- modules.list -
entry rpi-mmc
kernel fiasco -serial_esc
roottask moe rom/rpi-mmc.ned
module uvmm
module l4re
module ned
module virt-arm_virt-64-mod.dtb
module ramdisk-arm64.rd
module rpi-mmc.ned
module image.bin
module io
module io.cfg
module vm_hw.vbus

- I added mmc to device tree -
mmc@7e30 {
   compatible = "brcm,bcm2835-mmc", "brcm,bcm2835-sdhci";
   reg = <0x7e30 0x100>;
   interrupts = <0x0 0x7e 0x4>;
   clocks = <0x3 0x1c>;
   dmas = <0xa 0xb>;
   dma-names = "rx-tx";
   brcm,overclock-50 = <0x0>;
   status = "disabled";
   pinctrl-names = "default";
   pinctrl-0 = <0x19>;
   bus-width = <0x4>;
   phandle = <0x2d>;
};


I tested Linux kernel with uvmm module and without IO module and it was
working perfectly. I compiled it with the following options on:

 CONFIG_VIRTIO=y
 CONFIG_VIRTIO_PCI=y
 CONFIG_VIRTIO_BLK=y
 CONFIG_BLK_MQ_VIRTIO=y
 CONFIG_VIRTIO_CONSOLE=y
 CONFIG_VIRTIO_INPUT=y
 CONFIG_VIRTIO_NET=y

-
boot log messages are:

L4 Bootstrapper
  Build: #104 Wed Oct  7 20:14:57 EET 2020, 7.5.0
  Raspberry Pi Model 4B, Rev 1.1, 4096MB, SoC BCM2711 [c03111]
  Warranty intact, OTP reading allowed, OTP programming allowed,
Overvoltage allowed
  RAM:  - 3b3f: 970752kB
  RAM: 4000 - fbff: 3080192kB
  Total RAM: 3956MB
  Scanning fiasco
  Scanning sigma0
  Scanning moe
  Moving up to 14 modules behind 110
  moving module 13 { 254-25400bb } -> { 262c000-262c0bb } [188]
  moving module 12 { 253f000-253f555 } -> { 262b000-262b555 } [1366]
  moving module 11 { 230c000-253e187 } -> { 23f8000-262a187 } [2302344]
  moving module 10 { 15b3000-230b9ff } -> { 169f000-23f79ff } [13994496]
  moving module 09 { 15b2000-15b22ea } -> { 169e000-169e2ea } [747]
  moving module 08 { 1232000-15b1fff } -> { 131e000-169dfff } [3670016]
  moving module 07 { 1231000-123176c } -> { 131d000-131d76c } [1901]
  moving module 06 { 11be000-123041f } -> { 12aa000-131c41f } [468000]
  moving module 05 { 11a-11bd14f } -> { 128c000-12a914f } [119120]
  moving module 04 { 119f000-119fdbf } -> { 128b000-128bdbf } [3520]
  moving module 03 { 10eb000-119e957 } -> { 11d7000-128a957 } [735576]
  moving module 02 { 10ad000-10eaf0f } -> { 1199000-11d6f0f } [253712]
  moving module 01 { 10a3000-10ac947 } -> { 118f000-1198947 } [39240]
  moving module 00 { 1014000-10a24c7 } -> { 110-118e4c7 } [582856]
  Loading fiasco
  Loading sigma0
  Loading moe
  find kernel info page...
  found kernel info page (via ELF) at 3000
Regions of list 'regions'
[0,   fff] { 1000} Arch   mpspin
[ 1000, 9] {9f000} Kern   fiasco
[a, a01ff] {  200} Root   mbi_rt
[   10,10e46f] { e470} Sigma0 sigma0
[   14,17d70f] {3d710} Root   moe
[   17e710,189edf] { b7d0} Root   moe
[  100,   10122b3] {122b4} Boot   bootstrap
[  1013210,   1013c1c] {  a0d} Boot   modinfo
[  11d7000,   262c0bb] {  14550bc} Root   Module
  found kernel options (via ELF) at 4000
  Sigma0 configip:0010042c sp:
  Roottask config  ip:00141594 sp: