diff mbox series

[1/1] hw/arm/aspeed: Add Fuji machine type

Message ID 20210901225946.500125-2-pdel@fb.com
State New
Headers show
Series hw/arm/aspeed: Add Fuji machine type | expand

Commit Message

Peter Delevoryas Sept. 1, 2021, 10:59 p.m. UTC
From: Peter Delevoryas <pdel@fb.com>

This adds a new machine type "fuji-bmc" that's equivalent to
"ast2600-evb" except that it uses MAC3 and UART1. It might be
appropriate to change other aspects of this machine type in the future,
but so far this is all the specificity necessary to get a Fuji OpenBMC
image booting and networking within QEMU.

Here's a link to the device tree:

https://github.com/facebook/openbmc-uboot/blob/openbmc/helium/v2019.04/arch/arm/dts/aspeed-bmc-facebook-fuji.dts

I tested this by building a Fuji image from Facebook's OpenBMC repo,
booting it, and ssh'ing into it.

git clone https://github.com/facebook/openbmc
cd openbmc
./sync_yocto.sh
source openbmc-init-build-env fuji build-fuji
bitbake fuji-image
dd if=/dev/zero of=/tmp/fuji.mtd bs=1M count=128
dd if=./tmp/deploy/images/fuji/flash-fuji of=/tmp/fuji.mtd \
    bs=1k conv=notrunc

git clone --branch aspeed-next https://github.com/peterdelevoryas/qemu
cd qemu
./configure --target-list=arm-softmmu --disable-vnc
make -j $(nproc)
./build/arm-softmmu/qemu-system-arm \
    -machine fuji-bmc \
    -drive file=/tmp/fuji.mtd,format=raw,if=mtd \
    -serial stdio \
    -nic user,hostfwd=::2222-:22

U-Boot 2019.04 fuji-b9c651226b (Aug 25 2021 - 17:27:02 +0000)

SOC: AST2600-A3
eSPI Mode: SIO:Enable : SuperIO-2e
Eth: MAC0: RGMII, MAC1: RGMII, MAC2: RGMII, MAC3: RGMII
Model: Aspeed BMC
DRAM:  896 MiB (capacity:1024 MiB, VGA:64 MiB, ECC:on, ECC size:896 MiB)
MMC:   emmc_slot0@100: 0
...

sshpass -p 0penBmc ssh root@localhost -p 2222

Warning: Permanently added '[localhost]:2222' (ECDSA) to the list of known
Last login: Fri Mar  9 04:36:31 2018
root@bmc-oob:~# exit
logout
Connection to localhost closed.

I also created a Github release with the Fuji mtd image and added an
acceptance test utilizing it.

https://github.com/peterdelevoryas/openbmc/releases/tag/fuji-v0.1-alpha

Signed-off-by: Peter Delevoryas <pdel@fb.com>
---
 hw/arm/aspeed.c                        | 14 ++++++++++++++
 tests/acceptance/boot_linux_console.py | 25 +++++++++++++++++++++++++
 2 files changed, 39 insertions(+)
diff mbox series

Patch

diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index 7a9459340c..3b8b660a34 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -1070,6 +1070,16 @@  static void aspeed_machine_rainier_class_init(ObjectClass *oc, void *data)
         aspeed_soc_num_cpus(amc->soc_name);
 };
 
+static void aspeed_machine_fuji_class_init(ObjectClass *oc, void *data)
+{
+    MachineClass *mc = MACHINE_CLASS(oc);
+    AspeedMachineClass *amc = ASPEED_MACHINE_CLASS(oc);
+
+    mc->desc = "Facebook Fuji BMC (Cortex-A7)";
+    amc->macs_mask = ASPEED_MAC3_ON;
+    amc->uart_default = ASPEED_DEV_UART1;
+};
+
 static const TypeInfo aspeed_machine_types[] = {
     {
         .name          = MACHINE_TYPE_NAME("palmetto-bmc"),
@@ -1119,6 +1129,10 @@  static const TypeInfo aspeed_machine_types[] = {
         .name          = MACHINE_TYPE_NAME("rainier-bmc"),
         .parent        = TYPE_ASPEED_MACHINE,
         .class_init    = aspeed_machine_rainier_class_init,
+    }, {
+        .name          = MACHINE_TYPE_NAME("fuji-bmc"),
+        .parent        = MACHINE_TYPE_NAME("ast2600-evb"),
+        .class_init    = aspeed_machine_fuji_class_init,
     }, {
         .name          = TYPE_ASPEED_MACHINE,
         .parent        = TYPE_MACHINE,
diff --git a/tests/acceptance/boot_linux_console.py b/tests/acceptance/boot_linux_console.py
index 5248c8097d..63d32f6743 100644
--- a/tests/acceptance/boot_linux_console.py
+++ b/tests/acceptance/boot_linux_console.py
@@ -1143,6 +1143,31 @@  def test_arm_ast2600_debian(self):
         self.wait_for_console_pattern("SMP: Total of 2 processors activated")
         self.wait_for_console_pattern("No filesystem could mount root")
 
+    def test_arm_ast2600_fuji_openbmc(self):
+        """
+        :avocado: tags=arch:arm
+        :avocado: tags=machine:fuji-bmc
+        """
+
+        image_url = ('https://github.com/peterdelevoryas/openbmc/releases/download/'
+                     'fuji-v0.1-alpha/fuji.mtd')
+        image_hash = '36dd945a2ee34694684b5f3e7351517598bb39d8b6899c71bbd23791b42e082e'
+        image_path = self.fetch_asset(image_url, asset_hash=image_hash,
+                                      algorithm='sha256')
+
+        self.vm.set_console()
+        self.vm.add_args('-drive', 'file=' + image_path + ',if=mtd,format=raw',
+                         '-net', 'nic')
+        self.vm.launch()
+
+        self.wait_for_console_pattern("U-Boot 2019.04")
+        self.wait_for_console_pattern("## Loading kernel from FIT Image at 20100000")
+        self.wait_for_console_pattern("Starting kernel ...")
+        self.wait_for_console_pattern("Booting Linux on physical CPU 0xf00")
+        self.wait_for_console_pattern(
+                "aspeed-smc 1e620000.spi: read control register: 203b0041")
+        self.wait_for_console_pattern("ftgmac100 1e690000.ftgmac eth0: irq ")
+
     def test_m68k_mcf5208evb(self):
         """
         :avocado: tags=arch:m68k