On Thu, 29 Jun 2023 at 2:53 PM Kevin Brodsky <kevin.brodsky@arm.com> wrote:
On 26/06/2023 12:06, Menna Mahmoud wrote:
> Hi All,
>
> I am Menna, a Linux kernel intern- Outreahy internship. I worked on a
> project related to the Morello kernel. I checked the user guides and
> followed this: https://git.morello-project.org/morello/morello-linux,
> but I have a problem I couldn't create my own FVP kernel image and run
> it, I want to develop the kernel and update the FVP image and run it
> but I don't know how to do that.
>
> Could you please help me?

Hi Menna,

Welcome to Morello! I apologise for getting back to you only now. We'll
be happy to help you get started.

I understand that you have already managed to build the kernel using the
SDK [1]. Running it on FVP using the environment provided in [2] is
unfortunately not as straightforward at the moment. That said, we have
put together some instructions that should allow you to do this fairly
easily.

Assuming you already have an SDK environment looking like this (with the
kernel built under workspace/linux-out):
  |-> workspace/
      |-> linux/
      |-> linux-out/
  |-> docker-compose.yml

You can combine this with the morello-linux environment by adding it to
docker-compose.yml; for reference I copied the docker-compose.yml I used
at the end of this email.

You should then be able to use the following instructions:

1. Start the containers:

$ docker-compose up -d

2. Still on the host, download this package for later use:

$ curl -O --output-dir workspace
http://deb.debian.org/debian/pool/main/k/kexec-tools/kexec-tools_2.0.20-2.1_arm64.deb

3. Enter the morello-linux container:

$ docker exec -it -u 1000 morello-linux /bin/bash

4. Using an editor like vim, open /usr/bin/morello and append on the
last line "-v /morello", it should now look like this:

morello-run.sh -f distro -i
/usr/share/morello/images/morello-fvp/morello-fvp.img -v /morello

(This specifies that /morello should be made available to be mounted as
a 9P filesystem in FVP, see step 6.)

5. Start FVP:

# morello

6. Once FVP has booted, mount the 9P filesystem to access the /morello
directory in the container:

# mkdir /mnt/9p
# mount -t 9p -o trans=virtio,version=9p2000.L FM /mnt/9p

7. Install the previously downloaded kexec-tools package:

# dpkg -i /mnt/9p/kexec-tools_2.0.20-2.1_arm64.deb

8. You should now be able to boot your own kernel image using kexec [3]:

# kexec -l /mnt/9p/linux-out/arch/arm64/boot/Image --reuse-cmdline
# systemctl kexec

The system will shut down and then reboot using the provided image. To
make development easier, you could automate the mounting of the 9P
filesystem, for instance by adding it to /etc/fstab.

I hope this will work well for you, let us know otherwise. We are
working on improving the environments to remove the need for some of the
steps above, and generally make it easier to run custom kernels.

Do not hesitate to ask any further question on the linux-morello list -
this is the best place for any question related to Morello kernel
development.

Cheers,
Kevin

[1] https://sdk.morello-project.org/docs/linux/
[2] https://linux.morello-project.org/docs/intro/
[3] https://man7.org/linux/man-pages/man8/kexec.8.html

------8<------

docker-compose.yml

# Docker composer file for Morello Linux
version: '3.8'
services:
  linux-morello-sdk:
    image:
"git.morello-project.org:5050/morello/morello-sdk/morello-sdk:latest"
    container_name: "linux-morello-sdk"
    volumes:
      - ./workspace:/home/morello/workspace
    tty: true
    restart: unless-stopped
  morello-linux:
    image:
"git.morello-project.org:5050/morello/morello-linux/morello-linux:latest"
    container_name: "morello-linux"
    environment:
      - UID=1000
      - GID=1000
    volumes:
      - ./workspace:/morello
    tty: true
    restart: unless-stopped

Hi Kevin,

Never mind, appreciate your time and your help, got it and will follow these. Thanks a lot.

Many thanks and Best regards,
Menna