Using the Cortex M4 on IMX7D


Michael Graichen
 

Hey,

I have just started working on a IMX7D (https://www.kontron.de/products/boards-and-standard-form-factors/smarc/smarc-samx7.html) together with Zephyr
I noticed that the Colibri iMX7 Board has support for the Cortex M4.
So I've build an example by using:

cmake -GNinja -DBOARD=colibri_imx7d_m4 ../samples/basic/blinky

and tried to load that on the Cortex M4

echo -n zephyr.elf > /sys/class/remoteproc/remoteproc0/firmware
and
echo -n start > /sys/class/remoteproc/remoteproc0/state

Unfortunatly the start fails because the elf-file has no resource table.
I can select TOP ---> Additional libraries ---> [*] coprocessor resource table within menuconfig
but the resulting elf-file is still missing the resource table.

What am i missing? How can a add a resource table to the elf-file?

best regards
Michael


Kumar Gala
 

On Feb 26, 2021, at 3:43 AM, Michael Graichen <michael.graichen@...> wrote:

Hey,

I have just started working on a IMX7D (https://www.kontron.de/products/boards-and-standard-form-factors/smarc/smarc-samx7.html) together with Zephyr
I noticed that the Colibri iMX7 Board has support for the Cortex M4.
So I've build an example by using:

cmake -GNinja -DBOARD=colibri_imx7d_m4 ../samples/basic/blinky

and tried to load that on the Cortex M4

echo -n zephyr.elf > /sys/class/remoteproc/remoteproc0/firmware
and
echo -n start > /sys/class/remoteproc/remoteproc0/state

Unfortunatly the start fails because the elf-file has no resource table.
I can select TOP ---> Additional libraries ---> [*] coprocessor resource table within menuconfig
but the resulting elf-file is still missing the resource table.

What am i missing? How can a add a resource table to the elf-file?

best regards
Michael

I don’t believe the remoteproc loading was ever supported for the imx family with zephyr. This is something you’d need to add support for. I think it might be supported on the STM32 MP1 as an example. (I added Arnaud on CC as he added the STM32 MP1 support).

For the i.mx I think you can load via u-boot and there’s a section in the zephyr board docs here about it:

https://docs.zephyrproject.org/latest/boards/arm/colibri_imx7d_m4/doc/index.html

- k


Arnaud POULIQUEN
 

Hi,

-----Original Message-----
From: Kumar Gala <kumar.gala@...>
Sent: vendredi 26 février 2021 17:27
To: Michael Graichen <michael.graichen@...>
Cc: users@...; Arnaud POULIQUEN
<arnaud.pouliquen@...>
Subject: Re: [Zephyr-users] Using the Cortex M4 on IMX7D



On Feb 26, 2021, at 3:43 AM, Michael Graichen
<michael.graichen@...> wrote:

Hey,

I have just started working on a IMX7D
(https://www.kontron.de/products/boards-and-standard-form-
factors/smarc/smarc-samx7.html) together with Zephyr I noticed that the
Colibri iMX7 Board has support for the Cortex M4.
So I've build an example by using:

cmake -GNinja -DBOARD=colibri_imx7d_m4 ../samples/basic/blinky

and tried to load that on the Cortex M4

echo -n zephyr.elf > /sys/class/remoteproc/remoteproc0/firmware
and
echo -n start > /sys/class/remoteproc/remoteproc0/state

Unfortunatly the start fails because the elf-file has no resource table.
I can select TOP ---> Additional libraries ---> [*] coprocessor
resource table within menuconfig but the resulting elf-file is still missing the
resource table.

What am i missing? How can a add a resource table to the elf-file?
The Linux remoteproc framework allows you to load a firmware without a resource table.
The resource table is useful only if you want to use the RPMsg protocol or a trace buffer.
So this should work, except if the IMX platform driver doesn't allow this....


best regards
Michael

I don’t believe the remoteproc loading was ever supported for the imx family
with zephyr. This is something you’d need to add support for. I think it might
be supported on the STM32 MP1 as an example. (I added Arnaud on CC as he
added the STM32 MP1 support).
Right, I think today only the stm32mp1 support the resource table in zephyr, but this should be enough generic to
be supported by another platform.
Anyway if you don't want to use RPMsg, probably better as a first step to understand why you
can not load a firmware without resource table.

Regards
Arnaud


For the i.mx I think you can load via u-boot and there’s a section in the zephyr
board docs here about it:

https://docs.zephyrproject.org/latest/boards/arm/colibri_imx7d_m4/doc/index.
html

- k


Marco Cavallini
 

Hi,
I tested Zephyr with a Colibri i.MX7 and it works our of the box.

west build -p auto -b colibri_imx7d_m4 samples/philosophers

afterwards I loaded and run the binary using u-boot

--
Marco Cavallini - KOAN  - Italy


Michael Graichen
 

Am 26.02.21 um 17:27 schrieb Kumar Gala:

On Feb 26, 2021, at 3:43 AM, Michael Graichen <michael.graichen@...> wrote:

Hey,

I have just started working on a IMX7D (https://www.kontron.de/products/boards-and-standard-form-factors/smarc/smarc-samx7.html) together with Zephyr
I noticed that the Colibri iMX7 Board has support for the Cortex M4.
So I've build an example by using:

cmake -GNinja -DBOARD=colibri_imx7d_m4 ../samples/basic/blinky

and tried to load that on the Cortex M4

echo -n zephyr.elf > /sys/class/remoteproc/remoteproc0/firmware
and
echo -n start > /sys/class/remoteproc/remoteproc0/state

Unfortunatly the start fails because the elf-file has no resource table.
I can select TOP ---> Additional libraries ---> [*] coprocessor resource table within menuconfig
but the resulting elf-file is still missing the resource table.

What am i missing? How can a add a resource table to the elf-file?

best regards
Michael
I don’t believe the remoteproc loading was ever supported for the imx family with zephyr. This is something you’d need to add support for. I think it might be supported on the STM32 MP1 as an example. (I added Arnaud on CC as he added the STM32 MP1 support).
For the i.mx I think you can load via u-boot and there’s a section in the zephyr board docs here about it:
https://docs.zephyrproject.org/latest/boards/arm/colibri_imx7d_m4/doc/index.html
- k
Thanks for your reply.

This link was the reason why I thought to give it a try. But I'm using barebox as a bootloader right now, so I thought to test "the Linux way" first. I guess I will test u-boot next week.

I have looked over the boot instruction from the link.
u-boot is using the plain .bin file for loading the M4 while remoteproc is using the .elf file.

Is it right that all those environment variables, especially 'setenv m4addr 0x007f800' that are set in u-boot before booting the M4 should come out of the resource table when using remoteproc?

Do you have more information about how a resource table for the IMX7-M4 should look like?



Have a great weekend.
Michael


Michael Graichen
 

Am 27.02.21 um 09:32 schrieb Marco Cavallini:
Hi,
I tested Zephyr with a Colibri i.MX7 and it works our of the box.
west build -p auto -b colibri_imx7d_m4 samples/philosophers
afterwards I loaded and run the binary using u-boot
--
Marco Cavallini - KOAN  - Italy

Thanks you you reply.

guess I will test that next week.

What Memory addresses did you use when you tested the "out of the Box" example?

Have a great weekend
Michael


Michael Graichen
 

Am 26.02.21 um 18:06 schrieb Arnaud POULIQUEN:
Hi,

-----Original Message-----
From: Kumar Gala <kumar.gala@...>
Sent: vendredi 26 février 2021 17:27
To: Michael Graichen <michael.graichen@...>
Cc: users@...; Arnaud POULIQUEN
<arnaud.pouliquen@...>
Subject: Re: [Zephyr-users] Using the Cortex M4 on IMX7D



On Feb 26, 2021, at 3:43 AM, Michael Graichen
<michael.graichen@...> wrote:

Hey,

I have just started working on a IMX7D
(https://www.kontron.de/products/boards-and-standard-form-
factors/smarc/smarc-samx7.html) together with Zephyr I noticed that the
Colibri iMX7 Board has support for the Cortex M4.
So I've build an example by using:

cmake -GNinja -DBOARD=colibri_imx7d_m4 ../samples/basic/blinky

and tried to load that on the Cortex M4

echo -n zephyr.elf > /sys/class/remoteproc/remoteproc0/firmware
and
echo -n start > /sys/class/remoteproc/remoteproc0/state

Unfortunatly the start fails because the elf-file has no resource table.
I can select TOP ---> Additional libraries ---> [*] coprocessor
resource table within menuconfig but the resulting elf-file is still missing the
resource table.

What am i missing? How can a add a resource table to the elf-file?
The Linux remoteproc framework allows you to load a firmware without a resource table.
The resource table is useful only if you want to use the RPMsg protocol or a trace buffer.
So this should work, except if the IMX platform driver doesn't allow this....


best regards
Michael

I don’t believe the remoteproc loading was ever supported for the imx family
with zephyr. This is something you’d need to add support for. I think it might
be supported on the STM32 MP1 as an example. (I added Arnaud on CC as he
added the STM32 MP1 support).
Right, I think today only the stm32mp1 support the resource table in zephyr, but this should be enough generic to
be supported by another platform.
Anyway if you don't want to use RPMsg, probably better as a first step to understand why you
can not load a firmware without resource table.
Regards
Arnaud


For the i.mx I think you can load via u-boot and there’s a section in the zephyr
board docs here about it:

https://docs.zephyrproject.org/latest/boards/arm/colibri_imx7d_m4/doc/index.
html

- k


Hey Arnaud,

Thanks for your reply.

I've seen that stm32_rproc driver has additionally functions within static const struct rproc_ops st_rproc_ops
https://elixir.bootlin.com/linux/v5.11.2/source/drivers/remoteproc/stm32_rproc.c#L544
especially

.parse_fw = stm32_rproc_parse_fw,

within the plain rproc driver

rproc->ops->parse_fw = rproc_elf_load_rsc_table

is registerd within "static int rproc_alloc_ops()"

https://elixir.bootlin.com/linux/v5.11.2/source/drivers/remoteproc/remoteproc_core.c#L2202

and is called by doing the "echo start" command.

https://elixir.bootlin.com/linux/v5.11.2/source/drivers/remoteproc/remoteproc_elf_loader.c#L359


but fails after the find_table() function.

so if i just skip that for a test in https://elixir.bootlin.com/linux/v5.11.2/source/drivers/remoteproc/remoteproc_core.c#L1464, does that take me over the point?
I can not see the code where rproc actually "loads" the firmware to the M4?

best regards and a great weekend
Michael


Arnaud POULIQUEN
 

Hi,




Hey Arnaud,

Thanks for your reply.

I've seen that stm32_rproc driver has additionally functions within static const
struct rproc_ops st_rproc_ops
https://elixir.bootlin.com/linux/v5.11.2/source/drivers/remoteproc/stm32_rpro
c.c#L544
especially

.parse_fw = stm32_rproc_parse_fw,

within the plain rproc driver

rproc->ops->parse_fw = rproc_elf_load_rsc_table

is registerd within "static int rproc_alloc_ops()"
This is the generic elf parser functions that are available here:
https://elixir.bootlin.com/linux/latest/source/drivers/remoteproc/remoteproc_elf_loader.c


https://elixir.bootlin.com/linux/v5.11.2/source/drivers/remoteproc/remoteproc
_core.c#L2202

and is called by doing the "echo start" command.
Have you specified the firmware name?

Here is the sequence to load a firmware from Linux user application:
cp $1 /lib/firmware/
echo $1> /sys/class/remoteproc/remoteproc0/firmware
echo start >/sys/class/remoteproc/remoteproc0/state

with $1 is the firmware to load


https://elixir.bootlin.com/linux/v5.11.2/source/drivers/remoteproc/remoteproc
_elf_loader.c#L359


but fails after the find_table() function.
This function return NULL or the address of the resource table, but not return an error
Do you have a kernel error message ?


so if i just skip that for a test in
https://elixir.bootlin.com/linux/v5.11.2/source/drivers/remoteproc/remoteproc
_core.c#L1464,
does that take me over the point?
I can not see the code where rproc actually "loads" the firmware to the M4?

This is mainly done in https://elixir.bootlin.com/linux/latest/source/drivers/remoteproc/remoteproc_elf_loader.c

Regards,
Arnaud


best regards and a great weekend
Michael