Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abailon/i500 upstream v1 #139

Closed
wants to merge 4 commits into from

Conversation

anobli
Copy link

@anobli anobli commented Nov 27, 2020

Hello,

This pull request intends to add support of the AI Processing Unit (APU), a dual core VP6 (Xtensa LX7 ISA).
This just adds the minimum required for Rpmsg to work on the Mediatek i500 SoC.
Because there many other SoC or microcontroller using the Xtensa architecture, the support of xtensa and APU have been separated.

To build libmetal, gcc 10 could be used. Still this requires few additional low level libraries so I could provided a prebuilt toolchain for people interested (until I could fully document how to rebuild one).
XCC (Cadence complier) could also be used but this requires more cmake options to be configured.

For testing libmetal, we are building and running test-metal-static.
Currently, we can only load it on a real target, using remoteproc which add some constraints (e.g a resource table is required).
In addition, there are no uart so all the log must go to a log buffer.
I may try to use qemu or Candence ISS instead of real target as this would be more convenient for CI.

Thanks,
Alexandre

Copy link
Contributor

@arnopo arnopo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello,

Few comments , i think the main point is the logs management.
Concerning CI I let @edmooring responds, he is working on CI relying on QEMU for Xilinx platform.
Then we can also imagine a CI build test based on a github action using XCC if your build environment is opensource. Something similar to existing github actions: https://github.com/OpenAMP/libmetal/tree/master/.github/actions/build_ci.

lib/processor/xtensa/CMakeLists.txt Outdated Show resolved Hide resolved
lib/processor/xtensa/atomic.h Outdated Show resolved Hide resolved
lib/system/generic/xtensa_common/CMakeLists.txt Outdated Show resolved Hide resolved
lib/io.h Show resolved Hide resolved
cmake/platforms/i500-apu-generic.cmake Outdated Show resolved Hide resolved
lib/system/generic/i500_apu/sys.h Outdated Show resolved Hide resolved
lib/system/generic/i500_apu/log.c Outdated Show resolved Hide resolved
lib/system/generic/i500_apu/log.c Outdated Show resolved Hide resolved
lib/system/generic/i500_apu/sys.h Outdated Show resolved Hide resolved
test/system/generic/irq.c Outdated Show resolved Hide resolved
This adds support of xtensa processor.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
This adds support of xtensa architecture.
This dependens on xtos, a low level library from Cadence.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
@anobli anobli force-pushed the abailon/i500_upstream_v1 branch 2 times, most recently from cec9bfa to 4966613 Compare December 3, 2020 16:28
@anobli
Copy link
Author

anobli commented Dec 3, 2020

I pushed a new branch. Thanks for you feed back.

The i500 has a dual core VP6 (Xtensa LX7 ISA), also know as APU.
This adds a basic support of i500 Mediatek APU to libmetal.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
To load the firmware on i500 APU, we need to use remoteproc.
This implies to have a resource table.
This adds the resource table and the linker script required
to build a firmware for i500 apu.

Signed-off-by: Alexandre Bailon <abailon@baylibre.com>
Copy link
Contributor

@arnopo arnopo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few additional comments and questions, no major points.

collect (PROJECT_LIB_SOURCES irq.c)
collect (PROJECT_LIB_SOURCES sys.c)

add_subdirectory(../xtensa_common ${CMAKE_CURRENT_BINARY_DIR}/../xtensa_common)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should have following hierarchy instead:
/lib/ssytem/generic/xtensa/i500_apu/
means /familly/product/ hierarchy
@edmooring : any opinion on that?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum, this is going to imply some changes in the libmetal code.
Currently, the cmake files and some headers expect the following hierarchy:
/lib/ssytem/generic/machine/

So to have a hierarchy like /familly/product/ I will have to change many files if I want to do it correctly (e.g do the same for all the supported machines).

Another intermediate options would be to replace PROJECT_MACHINE in CMakeLists.txt and some headers by another variable that would contains the good path, depending if we using the current hierarchy or the family/product hierarchy.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your point is valid. As the hierarchy would have to be reworked. if @edmooring is Ok i propose to not update this ( so similar to xlnx_common) and treat it is a separate point. The include hierarchy is something that as to be improved in libmetal

sys_irq_enable(number);
value = i500_read_reg(VPU_INT_MASK_REG);
value &= ~(1 << number);
i500_write_reg(VPU_INT_MASK_REG, value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to protect agains concurrent access, the read, update, write action? or an atomic way to do it?


*lib:
-lc -lgloss -lminrt -lc -lhandler-reset -lhandlers-board -lminrt -lhal -lc

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with this kind of file... Is this can not be handle by cmake?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have discovered the specs file by working on this project so I my understanding might be wrong.
I think I need to have to override some default options of the linker.
IIRC, the default options are to build a firmware that could run on an emulator.
I don't know if there is another to way to override those options but I will check.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I spent some time to figure out how to do the same thing using gcc command line and I failed.
The closer result I got was making the command line really big and complex and it was still failing at link step.
The only other option we have if we want to get ride of this file is too do some changes in the toolchain itself.
If this OK for you, I would like to keep the spec file as it makes things simpler.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you try to just add in cmake/platforms/i500-apu-generic.cmake?
set(CMAKE_EXE_LINKER_FLAGS "-lc -lgloss -lminrt -lhandler-reset -lhandlers-board -lhal")

Seems also that -lc and -lminrt are defined several times in the command line...

@@ -0,0 +1,510 @@
/* This linker script generated from xt-genldscripts.tpp for LSP . */
/* Linker Script for default link */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A reason to place the linker in a specific folder?
Otherwise, as for other platforms, please place it directly in test/system/generic/i500_apu/

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is legacy. Usually, the linker scripts for these platform are generated using a tool, which creates many files in ldscripts.
I kept only the linker script but I have not though to move it out from this folder.
I will do it.

Copy link
Contributor

@edmooring edmooring left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @arnopo's comments.
Can you please add appropriate information to README.md describing the supported platforms and the addition of a new architecture, with pointers to the tools needed?
My CI work is primarily focused on ARM-based platform, so I'm not sure how this would fit in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants