Skip to contentSkip to conversation

Ethernet support for Raspberry Pi 4

PATCH Superseded Andre Przywara 5 participants 16 messages Jan 27, 2020 – Feb 18, 2020

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v3 cover Ethernet support for Raspberry Pi 4

This series adds Ethernet support for the Raspberry Pi 4. The SoC includes a "Broadcom Genet v5 MAC" IP, connected as a proper platform device (no USB anymore!). Patch 1 provides a driver for that. There does not seem to be publicly available documentation, so this is based on the Linux driver, but stripped down to just provide what U-Boot needs. Patch 2 fixes up the RPi4 memory map to accommodate the MMIO area the MAC lives in, while patch 3 enables it in the respective defconfigs.

This version fixes the nasty SError issue that showed when booting Linux. To see the changes as patches, refer to [1].

Please have a look and test it, I hope this helps to simplify development, as you spare the SD card and its slot from heavy swapping.

Cheers,
Andre.

[1] https://github.com/apritzel/u-boot/commits/rpi4-eth-v3

Changelog v2 ... v3:
- properly reset MAC in eth_probe() to avoid SError in Linux
- disable RX DMA upon stopping the device

Changelog v1 ... v2:
- use native endianess functions when accessing MMIO registers
- use dev_* DM wrappers for accessing devicetree data
- round base and length for flush_dcache_range, plus a comment
- check and round length for invalidate_cache_range
- support RGMII_RXID PHY mode, to support mainline .dtb

Amit Singh Tomar (3):
net: Add support for Broadcom GENETv5 Ethernet controller
rpi4: Update memory map to accommodate scb devices
rpi4: Enable GENET Ethernet controller

 arch/arm/mach-bcm283x/init.c |   6 +-
 configs/rpi_4_32b_defconfig  |   2 +
 configs/rpi_4_defconfig      |   2 +
 configs/rpi_arm64_defconfig  |   1 +
 drivers/net/Kconfig          |   7 +
 drivers/net/Makefile         |   1 +
 drivers/net/bcmgenet.c       | 729 +++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 745 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/bcmgenet.c
Signature · 1 line
2.14.5
#1 lore raw

PATCH v3 1/3 net: Add support for Broadcom GENETv5 Ethernet controller

From: Amit Singh Tomar <[email protected]>

The Broadcom GENET Ethernet MACs are used in several MIPS based SoCs and in the Broadcom 2711/2838 SoC used on the Raspberry Pi 4. There is no publicly available documentation, so this driver is based on the Linux driver. Compared to that the queue management is drastically simplified, also we only support version 5 of the IP and RGMII connections between MAC and PHY, as used on the RPi4.

[Andre: heavy cleanup and a few fixes]
---
 drivers/net/Kconfig    |   7 +
 drivers/net/Makefile   |   1 +
 drivers/net/bcmgenet.c | 729 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 737 insertions(+)
 create mode 100644 drivers/net/bcmgenet.c
drivers/net/Kconfig +7 -0
index 01d087f229..4d1013c984 100644
@@ -136,6 +136,13 @@ config BCM6368_ETH
 	help
 	  This driver supports the BCM6368 Ethernet MAC.
 
+config BCMGENET
+	bool "BCMGENET V5 support"
+	depends on DM_ETH
+	select PHYLIB
+	help
+	  This driver supports the BCMGENET Ethernet MAC.
+
 config DWC_ETH_QOS
 	bool "Synopsys DWC Ethernet QOS device support"
 	depends on DM_ETH
drivers/net/Makefile +1 -0
index 30991834ec..6e0a68834d 100644
@@ -8,6 +8,7 @@ obj-$(CONFIG_AG7XXX) += ag7xxx.o
 obj-$(CONFIG_ARMADA100_FEC) += armada100_fec.o
 obj-$(CONFIG_BCM6348_ETH) += bcm6348-eth.o
 obj-$(CONFIG_BCM6368_ETH) += bcm6368-eth.o
+obj-$(CONFIG_BCMGENET) += bcmgenet.o
 obj-$(CONFIG_DRIVER_AT91EMAC) += at91_emac.o
 obj-$(CONFIG_DRIVER_AX88180) += ax88180.o
 obj-$(CONFIG_BCM_SF2_ETH) += bcm-sf2-eth.o
drivers/net/bcmgenet.c new file +729 -0

729 lines not on this page · raw message

Signature · 1 line
2.14.5
#2 lore raw

PATCH v3 2/3 rpi4: Update memory map to accommodate scb devices

In reply to Andre Przywara

From: Amit Singh Tomar <[email protected]>

Some of the devices(for instance, pcie and gnet controller) sitting on SCB bus falls behind/below the memory range that we currenty have.

This patch updates the memory range to map those devices correctly.

---
 arch/arm/mach-bcm283x/init.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/mach-bcm283x/init.c +3 -3
index 3b5f45b431..9966d6c833 100644
@@ -42,9 +42,9 @@ static struct mm_region bcm2711_mem_map[] = {
 		.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
 			 PTE_BLOCK_INNER_SHARE
 	}, {
-		.virt = 0xfe000000UL,
-		.phys = 0xfe000000UL,
-		.size = 0x01800000UL,
+		.virt = 0xfc000000UL,
+		.phys = 0xfc000000UL,
+		.size = 0x03800000UL,
 		.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
 			 PTE_BLOCK_NON_SHARE |
 			 PTE_BLOCK_PXN | PTE_BLOCK_UXN
Signature · 1 line
2.14.5
#3 lore raw

PATCH v3 3/3 rpi4: Enable GENET Ethernet controller

In reply to Andre Przywara

From: Amit Singh Tomar <[email protected]>

The Raspberry Pi 4 SoC features an integrated Gigabit Ethernet controller, connected as a platform device.

Enable the new driver in the three applicable defconfigs, to allow TFTP booting on the board.

[Andre: Add joined and 32-bit configs]
---
 configs/rpi_4_32b_defconfig | 2 ++
 configs/rpi_4_defconfig     | 2 ++
 configs/rpi_arm64_defconfig | 1 +
 3 files changed, 5 insertions(+)
configs/rpi_4_32b_defconfig +2 -0
index 00f80f71ad..e7ea88bd4b 100644
@@ -24,6 +24,8 @@ CONFIG_DM_KEYBOARD=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_BCM2835=y
+CONFIG_DM_ETH=y
+CONFIG_BCMGENET=y
 CONFIG_PINCTRL=y
 # CONFIG_PINCTRL_GENERIC is not set
 # CONFIG_REQUIRE_SERIAL_CONSOLE is not set
configs/rpi_4_defconfig +2 -0
index 8cf1bb81ff..b0f9cf1c0e 100644
@@ -24,6 +24,8 @@ CONFIG_DM_KEYBOARD=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_SDHCI=y
 CONFIG_MMC_SDHCI_BCM2835=y
+CONFIG_DM_ETH=y
+CONFIG_BCMGENET=y
 CONFIG_PINCTRL=y
 # CONFIG_PINCTRL_GENERIC is not set
 # CONFIG_REQUIRE_SERIAL_CONSOLE is not set
configs/rpi_arm64_defconfig +1 -0
index 10fbe0db92..00b3096481 100644
@@ -36,6 +36,7 @@ CONFIG_USB_KEYBOARD=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_LAN78XX=y
 CONFIG_USB_ETHER_SMSC95XX=y
+CONFIG_BCMGENET=y
 CONFIG_DM_VIDEO=y
 CONFIG_VIDEO_BPP32=y
 CONFIG_SYS_WHITE_ON_BLACK=y
Signature · 1 line
2.14.5
#4 lore raw

v3 cover Ethernet support for Raspberry Pi 4

In reply to Andre Przywara
Quoted 35 lines · Andre Przywara

This series adds Ethernet support for the Raspberry Pi 4. The SoC includes a "Broadcom Genet v5 MAC" IP, connected as a proper platform device (no USB anymore!). Patch 1 provides a driver for that. There does not seem to be publicly available documentation, so this is based on the Linux driver, but stripped down to just provide what U-Boot needs. Patch 2 fixes up the RPi4 memory map to accommodate the MMIO area the MAC lives in, while patch 3 enables it in the respective defconfigs.

This version fixes the nasty SError issue that showed when booting Linux. To see the changes as patches, refer to [1].

Please have a look and test it, I hope this helps to simplify development, as you spare the SD card and its slot from heavy swapping.

Cheers,
Andre.

[1] https://github.com/apritzel/u-boot/commits/rpi4-eth-v3

Changelog v2 ... v3:
- properly reset MAC in eth_probe() to avoid SError in Linux
- disable RX DMA upon stopping the device

Changelog v1 ... v2:
- use native endianess functions when accessing MMIO registers
- use dev_* DM wrappers for accessing devicetree data
- round base and length for flush_dcache_range, plus a comment
- check and round length for invalidate_cache_range
- support RGMII_RXID PHY mode, to support mainline .dtb

Amit Singh Tomar (3):
net: Add support for Broadcom GENETv5 Ethernet controller
rpi4: Update memory map to accommodate scb devices
rpi4: Enable GENET Ethernet controller

Quoted 11 lines
 arch/arm/mach-bcm283x/init.c |   6 +-
 configs/rpi_4_32b_defconfig  |   2 +
 configs/rpi_4_defconfig      |   2 +
 configs/rpi_arm64_defconfig  |   1 +
 drivers/net/Kconfig          |   7 +
 drivers/net/Makefile         |   1 +
 drivers/net/bcmgenet.c       | 729 +++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 745 insertions(+), 3 deletions(-)
 create mode 100644 drivers/net/bcmgenet.c

Hello

I have successfully started a kernel (5.5.0-rc7-next-20200124-00075-gd1ea5e663326) with this serie. Thanks for your help by IRC, updating firmware seems to did the trick.
The kernel panic just after with "OF: reserved mem: failed to allocate memory for node 'linux,cma'" but that's another story.

Thanks

#5 lore raw

v3 cover Ethernet support for Raspberry Pi 4

Hi,

Quoted 1 line

The kernel panic just after with "OF: reserved mem: failed to allocate memory for node 'linux,cma'" but that's another story.

But this comes even without having Ethernet patches and when one use booti instead of bootefi, right ?

Thanks
-Amit

#6 lore raw

v3 cover Ethernet support for Raspberry Pi 4

Quoted 7 lines · Amit Tomer

Hi,

Quoted 1 line

The kernel panic just after with "OF: reserved mem: failed to allocate memory for node 'linux,cma'" but that's another story.

But this comes even without having Ethernet patches and when one use booti instead of bootefi, right ?

So booti is unsupported on rpi 4 ?
I need to set a ramdisk and bootefi dont support that.

Regards

#7 lore raw

v3 cover Ethernet support for Raspberry Pi 4

On Mon, 27 Jan 2020 12:50:16 +0100
LABBE Corentin <[email protected]> wrote:

Hi,

Quoted 10 lines · Amit Tomer
Quoted 7 lines

Hi,

Quoted 1 line

The kernel panic just after with "OF: reserved mem: failed to allocate memory for node 'linux,cma'" but that's another story.

But this comes even without having Ethernet patches and when one use booti instead of bootefi, right ?

So booti is unsupported on rpi 4 ?

It should be supported, but apparently there is some bug. I guess it's about not properly reserving memory used by the armstub/ATF. Do you use the embedded RPi foundation armstub or ATF (do you have an "armstub=..." line in config.txt)?

I will try take a look at this later.

Quoted 1 line

I need to set a ramdisk and bootefi dont support that.

Try "initrd=<filename>" on the kernel command line.
This is actually an EFI stub feature, the EFI command line is parsed by this pre-kernel code, which filters for initrd= and loads the initrd using the UEFI API (implemented by U-Boot). So the initrd has to live on the EFI system partition, which means you can't load it easily via TFTP :-(
More details here: https://www.kernel.org/doc/html/latest/admin-guide/efi-stub.html#the-initrd-option

Cheers,
Andre

#8 lore raw

v3 cover Ethernet support for Raspberry Pi 4

Quoted 10 lines · Andre Przywara

On Mon, 27 Jan 2020 12:50:16 +0100
LABBE Corentin <[email protected]> wrote:

Hi,

Quoted 5 lines · Amit Tomer
Quoted 4 lines

Hi,

Quoted 1 line

The kernel panic just after with "OF: reserved mem: failed to allocate memory for node 'linux,cma'" but that's another story.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

But this comes even without having Ethernet patches and when one use booti instead of bootefi, right ?

So booti is unsupported on rpi 4 ?

It should be supported, but apparently there is some bug. I guess it's about not properly reserving memory used by the armstub/ATF. Do you use the embedded RPi foundation armstub or ATF (do you have an "armstub=..." line in config.txt)?

I didnt use armstub=, but even with it, no change.

Quoted 9 lines

I will try take a look at this later.

Quoted 1 line

I need to set a ramdisk and bootefi dont support that.

Try "initrd=<filename>" on the kernel command line.
This is actually an EFI stub feature, the EFI command line is parsed by this pre-kernel code, which filters for initrd= and loads the initrd using the UEFI API (implemented by U-Boot). So the initrd has to live on the EFI system partition, which means you can't load it easily via TFTP :-(
More details here: https://www.kernel.org/doc/html/latest/admin-guide/efi-stub.html#the-initrd-option

I need to load it via TFTP.

Thanks for your help
Regards

#9 lore raw

v3 cover Ethernet support for Raspberry Pi 4

In reply to Andre Przywara
Quoted 14 lines · Andre Przywara

On Mon, 27 Jan 2020 12:50:16 +0100
LABBE Corentin <[email protected]> wrote:

Hi,

Quoted 9 lines · Amit Tomer
Quoted 7 lines

Hi,

Quoted 1 line

The kernel panic just after with "OF: reserved mem: failed to allocate memory for node 'linux,cma'" but that's another story.

But this comes even without having Ethernet patches and when one use booti instead of bootefi, right ?

Quoted 5 lines
Quoted 1 line

So booti is unsupported on rpi 4 ?

It should be supported, but apparently there is some bug. I guess it's about not properly reserving memory used by the armstub/ATF. Do you use the embedded RPi foundation armstub or ATF (do you have an "armstub=..." line in config.txt)?

I will try take a look at this later.

I'm not sure, i had similar issue about failed to allocate memory cma.
I had enabled CONFIG_ARCH_FIXUP_OF_MEMORY. And i changed the loading address (kernel/ramdisk/device-tree) in boot script for our environment. Because sometime some address range is overwritten.

Best Regards,
Jaehoon Chung

Quoted 12 lines
Quoted 2 lines

I need to set a ramdisk and bootefi dont support that.

Try "initrd=<filename>" on the kernel command line.
This is actually an EFI stub feature, the EFI command line is parsed by this pre-kernel code, which filters for initrd= and loads the initrd using the UEFI API (implemented by U-Boot). So the initrd has to live on the EFI system partition, which means you can't load it easily via TFTP :-(
More details here: https://www.kernel.org/doc/html/latest/admin-guide/efi-stub.html#the-initrd-option

Cheers,
Andre

#10 lore raw

v3 cover Ethernet support for Raspberry Pi 4

Quoted 17 lines · Jaehoon Chung
Quoted 16 lines · Andre Przywara

On Mon, 27 Jan 2020 12:50:16 +0100
LABBE Corentin <[email protected]> wrote:

Hi,

Quoted 10 lines · Amit Tomer
Quoted 7 lines

Hi,

Quoted 1 line

The kernel panic just after with "OF: reserved mem: failed to allocate memory for node 'linux,cma'" but that's another story.

But this comes even without having Ethernet patches and when one use booti instead of bootefi, right ?

So booti is unsupported on rpi 4 ?

Quoted 8 lines
Quoted 3 lines

It should be supported, but apparently there is some bug. I guess it's about not properly reserving memory used by the armstub/ATF. Do you use the embedded RPi foundation armstub or ATF (do you have an "armstub=..." line in config.txt)?

I will try take a look at this later.

I'm not sure, i had similar issue about failed to allocate memory cma.
I had enabled CONFIG_ARCH_FIXUP_OF_MEMORY. And i changed the loading address (kernel/ramdisk/device-tree) in boot script for our environment. Because sometime some address range is overwritten.

Can you share some more details? Might it make sense to change the memory addresses in include/configs/rpi.h so that it work out-of-the-box for all cases?

Regards,
Matthias

#11 lore raw

v3 cover Ethernet support for Raspberry Pi 4

In reply to Jaehoon Chung
Quoted 17 lines · Jaehoon Chung
Quoted 16 lines · Andre Przywara

On Mon, 27 Jan 2020 12:50:16 +0100
LABBE Corentin <[email protected]> wrote:

Hi,

Quoted 10 lines · Amit Tomer
Quoted 7 lines

Hi,

Quoted 1 line

The kernel panic just after with "OF: reserved mem: failed to allocate memory for node 'linux,cma'" but that's another story.

But this comes even without having Ethernet patches and when one use booti instead of bootefi, right ?

So booti is unsupported on rpi 4 ?

Quoted 8 lines
Quoted 3 lines

It should be supported, but apparently there is some bug. I guess it's about not properly reserving memory used by the armstub/ATF. Do you use the embedded RPi foundation armstub or ATF (do you have an "armstub=..." line in config.txt)?

I will try take a look at this later.

I'm not sure, i had similar issue about failed to allocate memory cma.
I had enabled CONFIG_ARCH_FIXUP_OF_MEMORY. And i changed the loading address (kernel/ramdisk/device-tree) in boot script for our environment. Because sometime some address range is overwritten.

Hello

I have searched both in uboot and linux sources and didnt found any CONFIG_ARCH_FIXUP_OF_MEMORY. Could you give what you did exactly ?

Regards

#12 lore raw

v3 cover Ethernet support for Raspberry Pi 4

Quoted 22 lines · LABBE Corentin
Quoted 21 lines · Jaehoon Chung
Quoted 19 lines · Andre Przywara

On Mon, 27 Jan 2020 12:50:16 +0100
LABBE Corentin <[email protected]> wrote:

Hi,

Quoted 10 lines · Amit Tomer
Quoted 7 lines

Hi,

Quoted 1 line

The kernel panic just after with "OF: reserved mem: failed to allocate memory for node 'linux,cma'" but that's another story.

But this comes even without having Ethernet patches and when one use booti instead of bootefi, right ?

So booti is unsupported on rpi 4 ?

It should be supported, but apparently there is some bug. I guess it's about not properly reserving memory used by the armstub/ATF. Do you use the embedded RPi foundation armstub or ATF (do you have an "armstub=..." line in config.txt)?

I will try take a look at this later.

Quoted 8 lines
Quoted 4 lines

I'm not sure, i had similar issue about failed to allocate memory cma.
I had enabled CONFIG_ARCH_FIXUP_OF_MEMORY. And i changed the loading address (kernel/ramdisk/device-tree) in boot script for our environment. Because sometime some address range is overwritten.

Hello

I have searched both in uboot and linux sources and didnt found any CONFIG_ARCH_FIXUP_OF_MEMORY.

Sorry. It's CONFIG_ARCH_FIXUP_FDT_MEMORY.

Best Regards,
Jaehoon Chung

Quoted 5 lines

Could you give what you did exactly ?

Regards

#13 lore raw

v3 cover Ethernet support for Raspberry Pi 4

Hi LABBE,

Quoted 28 lines · Jaehoon Chung
Quoted 27 lines · LABBE Corentin
Quoted 25 lines · Jaehoon Chung
Quoted 14 lines · Andre Przywara

On Mon, 27 Jan 2020 12:50:16 +0100
LABBE Corentin <[email protected]> wrote:

Hi,

Quoted 9 lines · Amit Tomer
Quoted 7 lines

Hi,

Quoted 1 line

The kernel panic just after with "OF: reserved mem: failed to allocate memory for node 'linux,cma'" but that's another story.

But this comes even without having Ethernet patches and when one use booti instead of bootefi, right ?

Quoted 5 lines
Quoted 1 line

So booti is unsupported on rpi 4 ?

It should be supported, but apparently there is some bug. I guess it's about not properly reserving memory used by the armstub/ATF. Do you use the embedded RPi foundation armstub or ATF (do you have an "armstub=..." line in config.txt)?

I will try take a look at this later.

I'm not sure, i had similar issue about failed to allocate memory cma.
I had enabled CONFIG_ARCH_FIXUP_OF_MEMORY. And i changed the loading address (kernel/ramdisk/device-tree) in boot script for our environment. Because sometime some address range is overwritten.

Quoted 5 lines
Quoted 3 lines

Hello

I have searched both in uboot and linux sources and didnt found any CONFIG_ARCH_FIXUP_OF_MEMORY.

Sorry. It's CONFIG_ARCH_FIXUP_FDT_MEMORY.

In my case, disable CONFIG_ARCH_FIXUP_FDT_MEMORY. (RAM size is returned to 0.)

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.19.81-arm-rpi4-v7l (abuild at obspw03) (gcc version 9.2.0 (Tizen GCC 9.2.0 20190812 3.5)) #1 SMP Thu Feb 13 12:18:13 UTC 2020
[    0.000000] CPU: ARMv7 Processor [410fd083] revision 3 (ARMv7), cr=30c5383d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction cache
[    0.000000] OF: fdt: Machine model: Raspberry Pi 4 Model B
[    0.000000] earlycon: uart8250 at MMIO32 0x00000000fe215040 (options '')
[    0.000000] bootconsole [uart8250] enabled
[    0.000000] INITRD: 0x02700000+0x00800000 is not a memory region - disabling initrd
[    0.000000] cma: Size (0x0000000010000000) of region at 0x0000000000000000 exceeds limit (0x0000000000000000)
[    0.000000] cma: Failed to reserve 256 MiB

After enabled CONFIG_ARCH_FIXUP_FDT_MEMORY.

tarting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.19.81-arm-rpi4-v7l (abuild at obspw03) (gcc version 9.2.0 (Tizen GCC 9.2.0 20190812 3.5)) #1 SMP Thu Feb 13 12:18:13 UTC 2020
[    0.000000] CPU: ARMv7 Processor [410fd083] revision 3 (ARMv7), cr=30c5383d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction cache
[    0.000000] OF: fdt: Machine model: Raspberry Pi 4 Model B
[    0.000000] earlycon: uart8250 at MMIO32 0x00000000fe215040 (options '')
[    0.000000] bootconsole [uart8250] enabled
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] cma: Reserved 256 MiB at 0x000000001ec00000
[    0.000000] random: get_random_bytes called from start_kernel+0xc0/0x4f0 with crng_init=0
[    0.000000] percpu: Embedded 16 pages/cpu s36812 r8192 d20532 u65536
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 1011008

Kernel is based on RPI vendor kernel. (32bit) And I have changed ramdisk/kernel/fdt loading address.(I think that it's not important.)

I have checked 1G/2G/4G RPI4 target. Each board is displayed correct ram-size on Kernel side.

Best Regards,
Jaehoon Chung

Quoted 12 lines

Best Regards,
Jaehoon Chung

Quoted 5 lines

Could you give what you did exactly ?

Regards

#14 lore raw

v3 cover Ethernet support for Raspberry Pi 4

Quoted 69 lines · Jaehoon Chung

Hi LABBE,

Quoted 28 lines · Jaehoon Chung
Quoted 27 lines · LABBE Corentin
Quoted 25 lines · Jaehoon Chung
Quoted 14 lines · Andre Przywara

On Mon, 27 Jan 2020 12:50:16 +0100
LABBE Corentin <[email protected]> wrote:

Hi,

Quoted 9 lines · Amit Tomer
Quoted 7 lines

Hi,

Quoted 1 line

The kernel panic just after with "OF: reserved mem: failed to allocate memory for node 'linux,cma'" but that's another story.

But this comes even without having Ethernet patches and when one use booti instead of bootefi, right ?

Quoted 5 lines
Quoted 1 line

So booti is unsupported on rpi 4 ?

It should be supported, but apparently there is some bug. I guess it's about not properly reserving memory used by the armstub/ATF. Do you use the embedded RPi foundation armstub or ATF (do you have an "armstub=..." line in config.txt)?

I will try take a look at this later.

I'm not sure, i had similar issue about failed to allocate memory cma.
I had enabled CONFIG_ARCH_FIXUP_OF_MEMORY. And i changed the loading address (kernel/ramdisk/device-tree) in boot script for our environment. Because sometime some address range is overwritten.

Quoted 5 lines
Quoted 3 lines

Hello

I have searched both in uboot and linux sources and didnt found any CONFIG_ARCH_FIXUP_OF_MEMORY.

Sorry. It's CONFIG_ARCH_FIXUP_FDT_MEMORY.

In my case, disable CONFIG_ARCH_FIXUP_FDT_MEMORY. (RAM size is returned to 0.)

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.19.81-arm-rpi4-v7l (abuild at obspw03) (gcc version 9.2.0 (Tizen GCC 9.2.0 20190812 3.5)) #1 SMP Thu Feb 13 12:18:13 UTC 2020
[    0.000000] CPU: ARMv7 Processor [410fd083] revision 3 (ARMv7), cr=30c5383d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction cache
[    0.000000] OF: fdt: Machine model: Raspberry Pi 4 Model B
[    0.000000] earlycon: uart8250 at MMIO32 0x00000000fe215040 (options '')
[    0.000000] bootconsole [uart8250] enabled
[    0.000000] INITRD: 0x02700000+0x00800000 is not a memory region - disabling initrd
[    0.000000] cma: Size (0x0000000010000000) of region at 0x0000000000000000 exceeds limit (0x0000000000000000)
[    0.000000] cma: Failed to reserve 256 MiB

After enabled CONFIG_ARCH_FIXUP_FDT_MEMORY.

tarting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.19.81-arm-rpi4-v7l (abuild at obspw03) (gcc version 9.2.0 (Tizen GCC 9.2.0 20190812 3.5)) #1 SMP Thu Feb 13 12:18:13 UTC 2020
[    0.000000] CPU: ARMv7 Processor [410fd083] revision 3 (ARMv7), cr=30c5383d
[    0.000000] CPU: div instructions available: patching division code
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction cache
[    0.000000] OF: fdt: Machine model: Raspberry Pi 4 Model B
[    0.000000] earlycon: uart8250 at MMIO32 0x00000000fe215040 (options '')
[    0.000000] bootconsole [uart8250] enabled
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] cma: Reserved 256 MiB at 0x000000001ec00000
[    0.000000] random: get_random_bytes called from start_kernel+0xc0/0x4f0 with crng_init=0
[    0.000000] percpu: Embedded 16 pages/cpu s36812 r8192 d20532 u65536
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 1011008
Quoted 4 lines

Kernel is based on RPI vendor kernel. (32bit) And I have changed ramdisk/kernel/fdt loading address.(I think that it's not important.)

I have checked 1G/2G/4G RPI4 target. Each board is displayed correct ram-size on Kernel side.

Thanks after enabling CONFIG_ARCH_FIXUP_FDT_MEMORY, I successully booted a linux-next via booti.

Thanks again.

Regards

#15 lore raw

v3 cover Ethernet support for Raspberry Pi 4

In reply to Andre Przywara
Quoted 22 lines · Andre Przywara

On Mon, 27 Jan 2020 12:50:16 +0100
LABBE Corentin <[email protected]> wrote:

Hi,

Quoted 10 lines · Amit Tomer
Quoted 7 lines

Hi,

Quoted 1 line

The kernel panic just after with "OF: reserved mem: failed to allocate memory for node 'linux,cma'" but that's another story.

But this comes even without having Ethernet patches and when one use booti instead of bootefi, right ?

So booti is unsupported on rpi 4 ?

It should be supported, but apparently there is some bug. I guess it's about not properly reserving memory used by the armstub/ATF. Do you use the embedded RPi foundation armstub or ATF (do you have an "armstub=..." line in config.txt)?

I will try take a look at this later.

Quoted 1 line

I need to set a ramdisk and bootefi dont support that.

Quoted 7 lines

Try "initrd=<filename>" on the kernel command line.
This is actually an EFI stub feature, the EFI command line is parsed by this pre-kernel code, which filters for initrd= and loads the initrd using the UEFI API (implemented by U-Boot). So the initrd has to live on the EFI system partition, which means you can't load it easily via TFTP :-(
More details here: https://www.kernel.org/doc/html/latest/admin-guide/efi-stub.html#the-initrd-option

Cheers,
Andre

Just for more information, the official kernel from rpi also panic when booted with booti.

[    0.000000] Linux version 4.19.80 (oe-user at oe-host) (gcc version 8.2.0 (GCC)) #1 SMP PREEMPT Mon Jan 13 16:34:20 UTC 2020
[    0.000000] Machine model: Raspberry Pi 4 Model B
[    0.000000] earlycon: uart0 at MMIO32 0x00000000fe215040 (options '')
[    0.000000] bootconsole [uart0] enabled
[    0.000000] efi: Getting EFI parameters from FDT:
[    0.000000] efi: UEFI not found.
[    0.000000] cma: Failed to reserve 8 MiB
[    0.000000] Kernel panic - not syncing: ERROR: Failed to allocate 0x0000000000001000 bytes below 0x0000000000000000.

Regards