diff mbox series

iMX8MM USB support?

Message ID CAJ+vNU0cH4BLDe_Dzg2KpXD94KM-qjJ8yKu6L6KONZD4KXTkbw@mail.gmail.com
State New
Headers show
Series iMX8MM USB support? | expand

Commit Message

Tim Harvey April 7, 2020, 5:06 p.m. UTC
On Mon, Apr 6, 2020 at 2:43 AM Schrempf Frieder
<frieder.schrempf at kontron.de> wrote:
>
> Hi Tim,
>
> On 01.04.20 19:55, Tim Harvey wrote:
> > Peng,
> >
> > It looks like IMX8MM USB support hasn't made it upstream yet. Is this
> > something your working on?
> >
> > I'm interested in booting an IMX8MM via SDP.
>
> If I remember correctly, the main issue is that the ci_udc driver is
> missing DM support. See here: [1].
>
> I have pulled some patches/hacks into our tree to make SDP work, at
> least without DM [2].
>
> If someone could come up with a proper solution for upstream that would
> be great and I would be happy to review/test.
>
> [1] http://u-boot.10912.n7.nabble.com/DM-for-ci-udc-td368249.html#a370228
> [2] https://git.kontron-electronics.de/linux/u-boot/-/commits/v2020.01-ktn
>

Frieder,

Thanks - this was very helpful! After applying the patches adding
IMX8MM USB I can boot the EVK SPL via SDP and get it to transition
over to providing a gadget at 0525:c4a4 but when I try to load
u-boot.img to that it fails with a header not found error:

sudo ../imx_usb_loader/imx_usb u-boot.imx; sleep 2; sudo
../imx_usb_loader/imx_usb u-boot.img
config file <../imx_usb_loader//imx_usb.conf>
...
vid=0x1fc9 pid=0x0134 file_name=mx8mm_usb_work.conf
...
config file <../imx_usb_loader//mx8mm_usb_work.conf>
parse ../imx_usb_loader//mx8mm_usb_work.conf
Trying to open device vid=0x1fc9 pid=0x0134
Interface 0 claimed
HAB security state: development mode (0x56787856)
== work item
filename u-boot.imx
load_size 0 bytes
load_addr 0x00000000
dcd 1
clear_dcd 0
plug 1
jump_mode 3
jump_addr 0x00000000
== end work item
No DCD table

loading binary file(u-boot.imx) to 007e0fc0, skip=0, fsize=37600 type=aa

<<<226816, 226816 bytes>>>
succeeded (security 0x56787856, status 0x88888888)
jumping to 0x007e0fc0
config file <../imx_usb_loader//imx_usb.conf>
...
config file <../imx_usb_loader//mx8mm_usb_sdp_spl.conf>
parse ../imx_usb_loader//mx8mm_usb_sdp_spl.conf
Trying to open device vid=0x0525 pid=0xc4a4
Interface 0 claimed
HAB security state: development mode (0x56787856)
== work item
filename u-boot.img
load_size 0 bytes
load_addr 0x00000000
dcd 1
clear_dcd 0
plug 1
jump_mode 3
jump_addr 0x00000000
== end work item
header not found 8400:91000694, 4000
do_download failed, err=-22
HAB security state: development mode (0x56787856)

Note I had to add a line to imx_usb.conf to map 0525:c4a4 to
mx8mm_usb_sdp_spl.conf:

Do you know what's missing from u-boot.img?

Best Regards,

Tim

Comments

Frieder Schrempf April 8, 2020, 7:35 a.m. UTC | #1
Hi Tim,

On 07.04.20 19:06, Tim Harvey wrote:
> On Mon, Apr 6, 2020 at 2:43 AM Schrempf Frieder
> <frieder.schrempf at kontron.de> wrote:
>>
>> Hi Tim,
>>
>> On 01.04.20 19:55, Tim Harvey wrote:
>>> Peng,
>>>
>>> It looks like IMX8MM USB support hasn't made it upstream yet. Is this
>>> something your working on?
>>>
>>> I'm interested in booting an IMX8MM via SDP.
>>
>> If I remember correctly, the main issue is that the ci_udc driver is
>> missing DM support. See here: [1].
>>
>> I have pulled some patches/hacks into our tree to make SDP work, at
>> least without DM [2].
>>
>> If someone could come up with a proper solution for upstream that would
>> be great and I would be happy to review/test.
>>
>> [1] https://eur04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fu-boot.10912.n7.nabble.com%2FDM-for-ci-udc-td368249.html%23a370228&amp;data=02%7C01%7Cfrieder.schrempf%40kontron.de%7Cb62b33f13a5546ece4d508d7db16044c%7C8c9d3c973fd941c8a2b1646f3942daf1%7C0%7C0%7C637218759927463384&amp;sdata=cSQl5z%2FRjvX4IKPWs71wOUhcc3ivvrq%2BObr7EeFbwCU%3D&amp;reserved=0
>> [2] https://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kontron-electronics.de%2Flinux%2Fu-boot%2F-%2Fcommits%2Fv2020.01-ktn&amp;data=02%7C01%7Cfrieder.schrempf%40kontron.de%7Cb62b33f13a5546ece4d508d7db16044c%7C8c9d3c973fd941c8a2b1646f3942daf1%7C0%7C0%7C637218759927463384&amp;sdata=pgoX%2Bh0E%2FiY49ebT16RD3y8hKuzO0NtmdKvrXHjBnuA%3D&amp;reserved=0
>>
> 
> Frieder,
> 
> Thanks - this was very helpful! After applying the patches adding
> IMX8MM USB I can boot the EVK SPL via SDP and get it to transition
> over to providing a gadget at 0525:c4a4 but when I try to load
> u-boot.img to that it fails with a header not found error:
> 
> sudo ../imx_usb_loader/imx_usb u-boot.imx; sleep 2; sudo
> ../imx_usb_loader/imx_usb u-boot.img
> config file <../imx_usb_loader//imx_usb.conf>
> ...
> vid=0x1fc9 pid=0x0134 file_name=mx8mm_usb_work.conf
> ...
> config file <../imx_usb_loader//mx8mm_usb_work.conf>
> parse ../imx_usb_loader//mx8mm_usb_work.conf
> Trying to open device vid=0x1fc9 pid=0x0134
> Interface 0 claimed
> HAB security state: development mode (0x56787856)
> == work item
> filename u-boot.imx
> load_size 0 bytes
> load_addr 0x00000000
> dcd 1
> clear_dcd 0
> plug 1
> jump_mode 3
> jump_addr 0x00000000
> == end work item
> No DCD table
> 
> loading binary file(u-boot.imx) to 007e0fc0, skip=0, fsize=37600 type=aa
> 
> <<<226816, 226816 bytes>>>
> succeeded (security 0x56787856, status 0x88888888)
> jumping to 0x007e0fc0
> config file <../imx_usb_loader//imx_usb.conf>
> ...
> config file <../imx_usb_loader//mx8mm_usb_sdp_spl.conf>
> parse ../imx_usb_loader//mx8mm_usb_sdp_spl.conf
> Trying to open device vid=0x0525 pid=0xc4a4
> Interface 0 claimed
> HAB security state: development mode (0x56787856)
> == work item
> filename u-boot.img
> load_size 0 bytes
> load_addr 0x00000000
> dcd 1
> clear_dcd 0
> plug 1
> jump_mode 3
> jump_addr 0x00000000
> == end work item
> header not found 8400:91000694, 4000
> do_download failed, err=-22
> HAB security state: development mode (0x56787856)
> 
> Note I had to add a line to imx_usb.conf to map 0525:c4a4 to
> mx8mm_usb_sdp_spl.conf:
> diff --git a/imx_usb.conf b/imx_usb.conf
> index c7c00f6..4d89230 100644
> --- a/imx_usb.conf
> +++ b/imx_usb.conf
> @@ -17,6 +17,7 @@
>   0x066f:0x37ff, linux_gadget.conf
>   0x1b67:0x4fff, mx6_usb_sdp_spl.conf
>   0x0525:0xb4a4, mx6_usb_sdp_spl.conf
> +0x0525:0xc4a4, mx8mm_usb_sdp_spl.conf
>   0x1fc9:0x012b, mx8mq_usb_work.conf
>   0x1fc9:0x0134, mx8mm_usb_work.conf
>   0x1fc9:0x013e, mx8mn_usb_work.conf
> 
> Do you know what's missing from u-boot.img?

In my case I'm loading a FIT image, so things are a bit different.
Where are you loading the image to?

I have the following line in mx8mm_usb_sdp_spl.conf to load my FIT image 
to DDR and jump to it:

/path/to/image/u-boot.itb:load 0x40200000, jump_direct 0x40200000

Best Regards,
Frieder
Tim Harvey April 8, 2020, 3:31 p.m. UTC | #2
On Wed, Apr 8, 2020 at 12:35 AM Schrempf Frieder
<frieder.schrempf at kontron.de> wrote:
>
> Hi Tim,
>
> On 07.04.20 19:06, Tim Harvey wrote:
> > On Mon, Apr 6, 2020 at 2:43 AM Schrempf Frieder
> > <frieder.schrempf at kontron.de> wrote:
> >>
> >> Hi Tim,
> >>
> >> On 01.04.20 19:55, Tim Harvey wrote:
> >>> Peng,
> >>>
> >>> It looks like IMX8MM USB support hasn't made it upstream yet. Is this
> >>> something your working on?
> >>>
> >>> I'm interested in booting an IMX8MM via SDP.
> >>
> >> If I remember correctly, the main issue is that the ci_udc driver is
> >> missing DM support. See here: [1].
> >>
> >> I have pulled some patches/hacks into our tree to make SDP work, at
> >> least without DM [2].
> >>
> >> If someone could come up with a proper solution for upstream that would
> >> be great and I would be happy to review/test.
> >>
> >> [1] https://eur04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fu-boot.10912.n7.nabble.com%2FDM-for-ci-udc-td368249.html%23a370228&amp;data=02%7C01%7Cfrieder.schrempf%40kontron.de%7Cb62b33f13a5546ece4d508d7db16044c%7C8c9d3c973fd941c8a2b1646f3942daf1%7C0%7C0%7C637218759927463384&amp;sdata=cSQl5z%2FRjvX4IKPWs71wOUhcc3ivvrq%2BObr7EeFbwCU%3D&amp;reserved=0
> >> [2] https://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kontron-electronics.de%2Flinux%2Fu-boot%2F-%2Fcommits%2Fv2020.01-ktn&amp;data=02%7C01%7Cfrieder.schrempf%40kontron.de%7Cb62b33f13a5546ece4d508d7db16044c%7C8c9d3c973fd941c8a2b1646f3942daf1%7C0%7C0%7C637218759927463384&amp;sdata=pgoX%2Bh0E%2FiY49ebT16RD3y8hKuzO0NtmdKvrXHjBnuA%3D&amp;reserved=0
> >>
> >
> > Frieder,
> >
> > Thanks - this was very helpful! After applying the patches adding
> > IMX8MM USB I can boot the EVK SPL via SDP and get it to transition
> > over to providing a gadget at 0525:c4a4 but when I try to load
> > u-boot.img to that it fails with a header not found error:
> >
> > sudo ../imx_usb_loader/imx_usb u-boot.imx; sleep 2; sudo
> > ../imx_usb_loader/imx_usb u-boot.img
> > config file <../imx_usb_loader//imx_usb.conf>
> > ...
> > vid=0x1fc9 pid=0x0134 file_name=mx8mm_usb_work.conf
> > ...
> > config file <../imx_usb_loader//mx8mm_usb_work.conf>
> > parse ../imx_usb_loader//mx8mm_usb_work.conf
> > Trying to open device vid=0x1fc9 pid=0x0134
> > Interface 0 claimed
> > HAB security state: development mode (0x56787856)
> > == work item
> > filename u-boot.imx
> > load_size 0 bytes
> > load_addr 0x00000000
> > dcd 1
> > clear_dcd 0
> > plug 1
> > jump_mode 3
> > jump_addr 0x00000000
> > == end work item
> > No DCD table
> >
> > loading binary file(u-boot.imx) to 007e0fc0, skip=0, fsize=37600 type=aa
> >
> > <<<226816, 226816 bytes>>>
> > succeeded (security 0x56787856, status 0x88888888)
> > jumping to 0x007e0fc0
> > config file <../imx_usb_loader//imx_usb.conf>
> > ...
> > config file <../imx_usb_loader//mx8mm_usb_sdp_spl.conf>
> > parse ../imx_usb_loader//mx8mm_usb_sdp_spl.conf
> > Trying to open device vid=0x0525 pid=0xc4a4
> > Interface 0 claimed
> > HAB security state: development mode (0x56787856)
> > == work item
> > filename u-boot.img
> > load_size 0 bytes
> > load_addr 0x00000000
> > dcd 1
> > clear_dcd 0
> > plug 1
> > jump_mode 3
> > jump_addr 0x00000000
> > == end work item
> > header not found 8400:91000694, 4000
> > do_download failed, err=-22
> > HAB security state: development mode (0x56787856)
> >
> > Note I had to add a line to imx_usb.conf to map 0525:c4a4 to
> > mx8mm_usb_sdp_spl.conf:
> > diff --git a/imx_usb.conf b/imx_usb.conf
> > index c7c00f6..4d89230 100644
> > --- a/imx_usb.conf
> > +++ b/imx_usb.conf
> > @@ -17,6 +17,7 @@
> >   0x066f:0x37ff, linux_gadget.conf
> >   0x1b67:0x4fff, mx6_usb_sdp_spl.conf
> >   0x0525:0xb4a4, mx6_usb_sdp_spl.conf
> > +0x0525:0xc4a4, mx8mm_usb_sdp_spl.conf
> >   0x1fc9:0x012b, mx8mq_usb_work.conf
> >   0x1fc9:0x0134, mx8mm_usb_work.conf
> >   0x1fc9:0x013e, mx8mn_usb_work.conf
> >
> > Do you know what's missing from u-boot.img?
>
> In my case I'm loading a FIT image, so things are a bit different.
> Where are you loading the image to?
>
> I have the following line in mx8mm_usb_sdp_spl.conf to load my FIT image
> to DDR and jump to it:
>
> /path/to/image/u-boot.itb:load 0x40200000, jump_direct 0x40200000
>

Frieder,

I was trying to load u-boot.img

The SPL boots fine:
U-Boot SPL 2020.01-00029-g5ad7797 (Apr 08 2020 - 08:16:53 -0700)
read error from device: 9310b8 register: x!Normal Boot
Trying to boot from USB SDP
SDP: initialize...
SDP: handle requests..

But when I 'imx_usb u-boot.img' it complains there is no header on
u-boot.img. I enabled FIT generation and attempted to 'imx_usb
u-boot.itb' but imx_usb still complains about no header found.

My mx8mm_usb_sdp_spl.conf loooks like this:
mx8mm_spl_sdp
#hid/bulk,[old_header,]max packet size, {ram start, ram size}(repeat
valid ram areas)
#In SPL, we typically load u-boot.img which has a U-boot header...
hid,1024,0x910000,0x40000000,1G,0x00900000,0x40000

#0x60000 - 0x8400 = 0x57c00, +0x3000=5ac00 (FIT image)
../u-boot-imx6/u-boot.bin:load 0x40200000
../u-boot-imx6/bl31-iMX8MM.bin:load 0x00920000,jump 0x920000

What does your mx8mm_usb_sdp_spl.conf look like? I must admit I don't
really understand how these are configured.

Thanks,

Tim
Frieder Schrempf April 9, 2020, 10:02 a.m. UTC | #3
On 08.04.20 17:31, Tim Harvey wrote:
[...]
>>
>> In my case I'm loading a FIT image, so things are a bit different.
>> Where are you loading the image to?
>>
>> I have the following line in mx8mm_usb_sdp_spl.conf to load my FIT image
>> to DDR and jump to it:
>>
>> /path/to/image/u-boot.itb:load 0x40200000, jump_direct 0x40200000
>>
> 
> Frieder,
> 
> I was trying to load u-boot.img
> 
> The SPL boots fine:
> U-Boot SPL 2020.01-00029-g5ad7797 (Apr 08 2020 - 08:16:53 -0700)
> read error from device: 9310b8 register: x!Normal Boot
> Trying to boot from USB SDP
> SDP: initialize...
> SDP: handle requests..
> 
> But when I 'imx_usb u-boot.img' it complains there is no header on
> u-boot.img. I enabled FIT generation and attempted to 'imx_usb
> u-boot.itb' but imx_usb still complains about no header found.
> 
> My mx8mm_usb_sdp_spl.conf loooks like this:
> mx8mm_spl_sdp
> #hid/bulk,[old_header,]max packet size, {ram start, ram size}(repeat
> valid ram areas)
> #In SPL, we typically load u-boot.img which has a U-boot header...
> hid,1024,0x910000,0x40000000,1G,0x00900000,0x40000
> 
> #0x60000 - 0x8400 = 0x57c00, +0x3000=5ac00 (FIT image)
> ../u-boot-imx6/u-boot.bin:load 0x40200000
> ../u-boot-imx6/bl31-iMX8MM.bin:load 0x00920000,jump 0x920000
> 
> What does your mx8mm_usb_sdp_spl.conf look like? I must admit I don't
> really understand how these are configured.

It looks just like yours except that I have a single instruction as 
already stated above:

/path/to/image/u-boot.itb:load 0x40200000, jump_direct 0x40200000

and I'm loading the FIT image by running './imx_usb' without arguments.

As imx_usb_loader can't parse FIT image headers, I use 'jump_direct' to 
jump to the raw image entry point and let SPL parse the FIT. I think in 
that case imx_usb_loader shouldn't complain about a missing header.
Tim Harvey April 9, 2020, 9:45 p.m. UTC | #4
On Thu, Apr 9, 2020 at 3:02 AM Schrempf Frieder
<frieder.schrempf at kontron.de> wrote:
>
> On 08.04.20 17:31, Tim Harvey wrote:
> [...]
> >>
> >> In my case I'm loading a FIT image, so things are a bit different.
> >> Where are you loading the image to?
> >>
> >> I have the following line in mx8mm_usb_sdp_spl.conf to load my FIT image
> >> to DDR and jump to it:
> >>
> >> /path/to/image/u-boot.itb:load 0x40200000, jump_direct 0x40200000
> >>
> >
> > Frieder,
> >
> > I was trying to load u-boot.img
> >
> > The SPL boots fine:
> > U-Boot SPL 2020.01-00029-g5ad7797 (Apr 08 2020 - 08:16:53 -0700)
> > read error from device: 9310b8 register: x!Normal Boot
> > Trying to boot from USB SDP
> > SDP: initialize...
> > SDP: handle requests..
> >
> > But when I 'imx_usb u-boot.img' it complains there is no header on
> > u-boot.img. I enabled FIT generation and attempted to 'imx_usb
> > u-boot.itb' but imx_usb still complains about no header found.
> >
> > My mx8mm_usb_sdp_spl.conf loooks like this:
> > mx8mm_spl_sdp
> > #hid/bulk,[old_header,]max packet size, {ram start, ram size}(repeat
> > valid ram areas)
> > #In SPL, we typically load u-boot.img which has a U-boot header...
> > hid,1024,0x910000,0x40000000,1G,0x00900000,0x40000
> >
> > #0x60000 - 0x8400 = 0x57c00, +0x3000=5ac00 (FIT image)
> > ../u-boot-imx6/u-boot.bin:load 0x40200000
> > ../u-boot-imx6/bl31-iMX8MM.bin:load 0x00920000,jump 0x920000
> >
> > What does your mx8mm_usb_sdp_spl.conf look like? I must admit I don't
> > really understand how these are configured.
>
> It looks just like yours except that I have a single instruction as
> already stated above:
>
> /path/to/image/u-boot.itb:load 0x40200000, jump_direct 0x40200000
>
> and I'm loading the FIT image by running './imx_usb' without arguments.
>
> As imx_usb_loader can't parse FIT image headers, I use 'jump_direct' to
> jump to the raw image entry point and let SPL parse the FIT. I think in
> that case imx_usb_loader shouldn't complain about a missing header.

Frieder,

Ok, I finally understand. Using 'imx_usb <file>' which is what I was
doing is not the same as loading it via the conf file and was why it
was looking for a header.

So now that I'm using the imx_usb.conf files fully instead It's
loading u-boot.itb and jumping but unfortunately I'm still not quite
there.

Here's what I'm seeing:

U-Boot SPL 2020.01-00029-g6529a03-dirty (Apr 09 2020 - 13:02:21 -0700)
Normal Boot
Trying to boot from USB SDP
SDP: initialize...
SDP: handle requests...
Downloading file of size 584020 to 0x40200000... done
Jumping to header at 0x40200000
Header Tag is not an IMX image

Is the 'Header Tag' message normal? From adding some debugging it
appears to matching the dts name in my board_fit_config_name_match and
parsing the FIT image, loading the ATF and jumping but then I get
nothing. What would I expect at this point and do you have any
troubleshooting tips?

Thanks,

Tim
Tim Harvey April 10, 2020, 6:37 p.m. UTC | #5
On Thu, Apr 9, 2020 at 2:45 PM Tim Harvey <tharvey at gateworks.com> wrote:
>
> On Thu, Apr 9, 2020 at 3:02 AM Schrempf Frieder
> <frieder.schrempf at kontron.de> wrote:
> >
> > On 08.04.20 17:31, Tim Harvey wrote:
> > [...]
> > >>
> > >> In my case I'm loading a FIT image, so things are a bit different.
> > >> Where are you loading the image to?
> > >>
> > >> I have the following line in mx8mm_usb_sdp_spl.conf to load my FIT image
> > >> to DDR and jump to it:
> > >>
> > >> /path/to/image/u-boot.itb:load 0x40200000, jump_direct 0x40200000
> > >>
> > >
> > > Frieder,
> > >
> > > I was trying to load u-boot.img
> > >
> > > The SPL boots fine:
> > > U-Boot SPL 2020.01-00029-g5ad7797 (Apr 08 2020 - 08:16:53 -0700)
> > > read error from device: 9310b8 register: x!Normal Boot
> > > Trying to boot from USB SDP
> > > SDP: initialize...
> > > SDP: handle requests..
> > >
> > > But when I 'imx_usb u-boot.img' it complains there is no header on
> > > u-boot.img. I enabled FIT generation and attempted to 'imx_usb
> > > u-boot.itb' but imx_usb still complains about no header found.
> > >
> > > My mx8mm_usb_sdp_spl.conf loooks like this:
> > > mx8mm_spl_sdp
> > > #hid/bulk,[old_header,]max packet size, {ram start, ram size}(repeat
> > > valid ram areas)
> > > #In SPL, we typically load u-boot.img which has a U-boot header...
> > > hid,1024,0x910000,0x40000000,1G,0x00900000,0x40000
> > >
> > > #0x60000 - 0x8400 = 0x57c00, +0x3000=5ac00 (FIT image)
> > > ../u-boot-imx6/u-boot.bin:load 0x40200000
> > > ../u-boot-imx6/bl31-iMX8MM.bin:load 0x00920000,jump 0x920000
> > >
> > > What does your mx8mm_usb_sdp_spl.conf look like? I must admit I don't
> > > really understand how these are configured.
> >
> > It looks just like yours except that I have a single instruction as
> > already stated above:
> >
> > /path/to/image/u-boot.itb:load 0x40200000, jump_direct 0x40200000
> >
> > and I'm loading the FIT image by running './imx_usb' without arguments.
> >
> > As imx_usb_loader can't parse FIT image headers, I use 'jump_direct' to
> > jump to the raw image entry point and let SPL parse the FIT. I think in
> > that case imx_usb_loader shouldn't complain about a missing header.
>
> Frieder,
>
> Ok, I finally understand. Using 'imx_usb <file>' which is what I was
> doing is not the same as loading it via the conf file and was why it
> was looking for a header.
>
> So now that I'm using the imx_usb.conf files fully instead It's
> loading u-boot.itb and jumping but unfortunately I'm still not quite
> there.
>
> Here's what I'm seeing:
>
> U-Boot SPL 2020.01-00029-g6529a03-dirty (Apr 09 2020 - 13:02:21 -0700)
> Normal Boot
> Trying to boot from USB SDP
> SDP: initialize...
> SDP: handle requests...
> Downloading file of size 584020 to 0x40200000... done
> Jumping to header at 0x40200000
> Header Tag is not an IMX image
>
> Is the 'Header Tag' message normal? From adding some debugging it
> appears to matching the dts name in my board_fit_config_name_match and
> parsing the FIT image, loading the ATF and jumping but then I get
> nothing. What would I expect at this point and do you have any
> troubleshooting tips?
>

Frieder,

My issue was that I forgot to set ATF_LOAD_ADDR=0x920000!

So I'm running now, booting imx8mm-evk via SDP using your USB patches
and imx_usb configuration.

Thank you for your help!

Tim
Fabio Estevam July 1, 2021, 11:15 p.m. UTC | #6
Hi Tim and Schrempf,

On Fri, Apr 10, 2020 at 3:37 PM Tim Harvey <tharvey@gateworks.com> wrote:

> Frieder,

>

> My issue was that I forgot to set ATF_LOAD_ADDR=0x920000!

>

> So I'm running now, booting imx8mm-evk via SDP using your USB patches

> and imx_usb configuration.


Sorry for resurrecting such an old thread.

I am trying to accomplish the same here: boot imx8mm-evk via SDP.

I tried building Schremp's U-Boot from
https://git.kontron-electronics.de/linux/u-boot/-/commits/v2020.01-ktn
with the additional changes:

--- a/configs/imx8mm_evk_defconfig
+++ b/configs/imx8mm_evk_defconfig
@@ -85,3 +85,14 @@ CONFIG_MXC_UART=y
 CONFIG_SYSRESET=y
 CONFIG_SYSRESET_PSCI=y
 CONFIG_DM_THERMAL=y
+CONFIG_SPL_USB_HOST_SUPPORT=y
+CONFIG_SPL_USB_GADGET=y
+CONFIG_SPL_USB_SDP_SUPPORT=y
+CONFIG_SPL_WATCHDOG_SUPPORT=y
+CONFIG_USB=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_MANUFACTURER="FSL"
+CONFIG_USB_GADGET_VENDOR_NUM=0x0525
+CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
+CONFIG_CI_UDC=y
diff --git a/include/configs/imx8mm_evk.h b/include/configs/imx8mm_evk.h
index 991fe0056c4a..d41704d60754 100644
--- a/include/configs/imx8mm_evk.h
+++ b/include/configs/imx8mm_evk.h
@@ -35,6 +35,11 @@

 #endif

+#define CONFIG_EHCI_HCD_INIT_AFTER_RESET
+#define CONFIG_MXC_USB_PORTSC          (PORT_PTS_UTMI | PORT_PTS_PTW)
+#define CONFIG_MXC_USB_FLAGS           0
+#define CONFIG_USB_MAX_CONTROLLER_COUNT        2
+
 /* Initial environment variables */
 #define CONFIG_EXTRA_ENV_SETTINGS              \
        "script=boot.scr\0" \


but I get the following error:

U-Boot SPL 2020.01-01059-geb5a1eb17cea-dirty (Jul 01 2021 - 19:45:58 -0300)
Normal Boot
WDT:   Not found!
SPL: Unsupported Boot Device!
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

Tim,

Do you still have the imx8mm-evk patches and mx8mm_usb_sdp_spl.conf
that you used?

This version of U-Boot does not generate u-boot.itb by default, so I
passed the following
line in mx8mm_usb_sdp_spl.conf:

.../u-boot/flash.bin:dcd,clear_dcd,plug,jump header

Any help is appreciated.

I plan to upstream this support once I get it resolved.

Thanks,

Fabio Estevam
Tim Harvey July 1, 2021, 11:58 p.m. UTC | #7
On Thu, Jul 1, 2021 at 4:15 PM Fabio Estevam <festevam@gmail.com> wrote:
>

> Hi Tim and Schrempf,

>

> On Fri, Apr 10, 2020 at 3:37 PM Tim Harvey <tharvey@gateworks.com> wrote:

>

> > Frieder,

> >

> > My issue was that I forgot to set ATF_LOAD_ADDR=0x920000!

> >

> > So I'm running now, booting imx8mm-evk via SDP using your USB patches

> > and imx_usb configuration.

>

> Sorry for resurrecting such an old thread.

>

> I am trying to accomplish the same here: boot imx8mm-evk via SDP.

>

> I tried building Schremp's U-Boot from

> https://git.kontron-electronics.de/linux/u-boot/-/commits/v2020.01-ktn

> with the additional changes:

>

> --- a/configs/imx8mm_evk_defconfig

> +++ b/configs/imx8mm_evk_defconfig

> @@ -85,3 +85,14 @@ CONFIG_MXC_UART=y

>  CONFIG_SYSRESET=y

>  CONFIG_SYSRESET_PSCI=y

>  CONFIG_DM_THERMAL=y

> +CONFIG_SPL_USB_HOST_SUPPORT=y

> +CONFIG_SPL_USB_GADGET=y

> +CONFIG_SPL_USB_SDP_SUPPORT=y

> +CONFIG_SPL_WATCHDOG_SUPPORT=y

> +CONFIG_USB=y

> +CONFIG_USB_EHCI_HCD=y

> +CONFIG_USB_GADGET=y

> +CONFIG_USB_GADGET_MANUFACTURER="FSL"

> +CONFIG_USB_GADGET_VENDOR_NUM=0x0525

> +CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5

> +CONFIG_CI_UDC=y

> diff --git a/include/configs/imx8mm_evk.h b/include/configs/imx8mm_evk.h

> index 991fe0056c4a..d41704d60754 100644

> --- a/include/configs/imx8mm_evk.h

> +++ b/include/configs/imx8mm_evk.h

> @@ -35,6 +35,11 @@

>

>  #endif

>

> +#define CONFIG_EHCI_HCD_INIT_AFTER_RESET

> +#define CONFIG_MXC_USB_PORTSC          (PORT_PTS_UTMI | PORT_PTS_PTW)

> +#define CONFIG_MXC_USB_FLAGS           0

> +#define CONFIG_USB_MAX_CONTROLLER_COUNT        2

> +

>  /* Initial environment variables */

>  #define CONFIG_EXTRA_ENV_SETTINGS              \

>         "script=boot.scr\0" \

>

>

> but I get the following error:

>

> U-Boot SPL 2020.01-01059-geb5a1eb17cea-dirty (Jul 01 2021 - 19:45:58 -0300)

> Normal Boot

> WDT:   Not found!

> SPL: Unsupported Boot Device!

> SPL: failed to boot from all boot devices

> ### ERROR ### Please RESET the board ###

>

> Tim,

>

> Do you still have the imx8mm-evk patches and mx8mm_usb_sdp_spl.conf

> that you used?

>

> This version of U-Boot does not generate u-boot.itb by default, so I

> passed the following

> line in mx8mm_usb_sdp_spl.conf:

>

> .../u-boot/flash.bin:dcd,clear_dcd,plug,jump header

>

> Any help is appreciated.

>

> I plan to upstream this support once I get it resolved.

>


Fabio,

I no longer have the patches/config around and am not sure I even have
a working imx8mm-evk anymore.

Do you have the patches I submitted to enable USB OTG in general on IMX8MM?
usb: ehci-mx6: add IMX8MM and IMX8MN OTG support
usb: ehci-mx6: move mode set/detect to probe

I would like to get those patches accepted and I think there was some
concern that 'usb: ehci-mx6: move mode set/detect to probe' may break
gadget support.

I haven't needed to use SDP in some time (we have JTAG programming
support for eMMC now). Let me see if I can get SDP working on
imx8mm-venice.

Best regards,

Tim
Fabio Estevam July 2, 2021, 12:36 a.m. UTC | #8
Hi Tim,

On Thu, Jul 1, 2021 at 8:58 PM Tim Harvey <tharvey@gateworks.com> wrote:

> Fabio,

>

> I no longer have the patches/config around and am not sure I even have

> a working imx8mm-evk anymore.

>

> Do you have the patches I submitted to enable USB OTG in general on IMX8MM?

> usb: ehci-mx6: add IMX8MM and IMX8MN OTG support

> usb: ehci-mx6: move mode set/detect to probe


Thanks for pointing out these patches. Does "ums 0 mmc 0" work for you?

I will have a try.

> I would like to get those patches accepted and I think there was some

> concern that 'usb: ehci-mx6: move mode set/detect to probe' may break

> gadget support.


I have applied this one and tested on warp7 board via "ums 0 mmc 0"
and it still works.

> I haven't needed to use SDP in some time (we have JTAG programming

> support for eMMC now). Let me see if I can get SDP working on

> imx8mm-venice.


Thanks, appreciate it.

Regards,

Fabio Estevam
Tim Harvey July 2, 2021, 12:49 a.m. UTC | #9
On Thu, Jul 1, 2021 at 5:36 PM Fabio Estevam <festevam@gmail.com> wrote:
>

> Hi Tim,

>

> On Thu, Jul 1, 2021 at 8:58 PM Tim Harvey <tharvey@gateworks.com> wrote:

>

> > Fabio,

> >

> > I no longer have the patches/config around and am not sure I even have

> > a working imx8mm-evk anymore.

> >

> > Do you have the patches I submitted to enable USB OTG in general on IMX8MM?

> > usb: ehci-mx6: add IMX8MM and IMX8MN OTG support

> > usb: ehci-mx6: move mode set/detect to probe

>

> Thanks for pointing out these patches. Does "ums 0 mmc 0" work for you?

>


Yes, this works on my board. I just sent a v2 of these patches (cc'd you).

By the way, I took a quick stab at enabling SDP on
imx8mm-venice-gw73xx-0x and found compile issues so I configured for
an imx8mm_evk using your diffs and hit the same issues.

drivers/usb/host/ehci-mx6.c: In function ‘ehci_hcd_init’:
drivers/usb/host/ehci-mx6.c:360:46: error: ‘USB_BASE_ADDR’ undeclared
(first use in this function); did you mean ‘SRC_BASE_ADDR’?
  struct usb_ehci *ehci = (struct usb_ehci *)(USB_BASE_ADDR +
                                              ^~~~~~~~~~~~~
                                              SRC_BASE_ADDR
drivers/usb/host/ehci-mx6.c:360:46: note: each undeclared identifier
is reported only once for each function it appears in
drivers/usb/host/ehci-mx6.c:361:4: error: ‘controller_spacing’
undeclared (first use in this function); did you mean ‘console_start’?
   (controller_spacing * index));
    ^~~~~~~~~~~~~~~~~~
...

The above is resolved with CONFIG_DM_USB=y and CONFIG_SPL_DM_USB=y

After enabling those I just run into other issues with things such as:
WARNING 'mkimage.flash.mkimage' not found, resulting binary is not-functional
 ...
aarch64-linux-ld.bfd: cmd/nvedit.o: in function `env_match':
/usr/src/venice/uboot-master/cmd/nvedit.c:824: undefined reference to
`env_get_char'
aarch64-linux-ld.bfd: /usr/src/venice/uboot-master/cmd/nvedit.c:828:
undefined reference to `env_get_char'
...

What branch were you working with here? I tried the above with v2021.07-rc5

Tim
Fabio Estevam July 2, 2021, 12:56 a.m. UTC | #10
Hi Tim,

On Thu, Jul 1, 2021 at 9:49 PM Tim Harvey <tharvey@gateworks.com> wrote:

> Yes, this works on my board. I just sent a v2 of these patches (cc'd you).


I have just tried "ums 0 mmc 1" and it works on a imx8mm-evk now after
applying your patches, thanks!

> By the way, I took a quick stab at enabling SDP on

> imx8mm-venice-gw73xx-0x and found compile issues so I configured for

> an imx8mm_evk using your diffs and hit the same issues.

>

> drivers/usb/host/ehci-mx6.c: In function ‘ehci_hcd_init’:

> drivers/usb/host/ehci-mx6.c:360:46: error: ‘USB_BASE_ADDR’ undeclared

> (first use in this function); did you mean ‘SRC_BASE_ADDR’?

>   struct usb_ehci *ehci = (struct usb_ehci *)(USB_BASE_ADDR +

>                                               ^~~~~~~~~~~~~

>                                               SRC_BASE_ADDR

> drivers/usb/host/ehci-mx6.c:360:46: note: each undeclared identifier

> is reported only once for each function it appears in

> drivers/usb/host/ehci-mx6.c:361:4: error: ‘controller_spacing’

> undeclared (first use in this function); did you mean ‘console_start’?

>    (controller_spacing * index));

>     ^~~~~~~~~~~~~~~~~~

> ...

>

> The above is resolved with CONFIG_DM_USB=y and CONFIG_SPL_DM_USB=y

>

> After enabling those I just run into other issues with things such as:

> WARNING 'mkimage.flash.mkimage' not found, resulting binary is not-functional

>  ...

> aarch64-linux-ld.bfd: cmd/nvedit.o: in function `env_match':

> /usr/src/venice/uboot-master/cmd/nvedit.c:824: undefined reference to

> `env_get_char'

> aarch64-linux-ld.bfd: /usr/src/venice/uboot-master/cmd/nvedit.c:828:

> undefined reference to `env_get_char'

> ...

>

> What branch were you working with here? I tried the above with v2021.07-rc5


I am also testing against 2021.07-rc5.

Please see the complete diff (your patches + imx8mm_evk defconfig
changes against 2021.07-rc5):
https://pastebin.com/raw/BtCD0xat

Now the missing part is SDP. Hopefully we can get SDK working too.

Thanks!
Fabio Estevam July 2, 2021, 1:13 a.m. UTC | #11
On Thu, Jul 1, 2021 at 9:49 PM Tim Harvey <tharvey@gateworks.com> wrote:

> By the way, I took a quick stab at enabling SDP on

> imx8mm-venice-gw73xx-0x and found compile issues so I configured for

> an imx8mm_evk using your diffs and hit the same issues.

>

> drivers/usb/host/ehci-mx6.c: In function ‘ehci_hcd_init’:

> drivers/usb/host/ehci-mx6.c:360:46: error: ‘USB_BASE_ADDR’ undeclared


Ah, now that I try to enable SDP I see these errors too. To fix this
error we need:
https://git.kontron-electronics.de/linux/u-boot/-/commit/975e36c71164483a7c690e81126f77f6de482378.patch

This one is also needed:
https://git.kontron-electronics.de/linux/u-boot/-/commit/344c83522650ef8d8ea6c12c6a8209e54f0f31e6.patch


> (first use in this function); did you mean ‘SRC_BASE_ADDR’?

>   struct usb_ehci *ehci = (struct usb_ehci *)(USB_BASE_ADDR +

>                                               ^~~~~~~~~~~~~

>                                               SRC_BASE_ADDR

> drivers/usb/host/ehci-mx6.c:360:46: note: each undeclared identifier

> is reported only once for each function it appears in

> drivers/usb/host/ehci-mx6.c:361:4: error: ‘controller_spacing’


I need to check on this one.

Thanks
Fabio Estevam July 2, 2021, 1:36 a.m. UTC | #12
Tim,

On Thu, Jul 1, 2021 at 10:13 PM Fabio Estevam <festevam@gmail.com> wrote:
>

> On Thu, Jul 1, 2021 at 9:49 PM Tim Harvey <tharvey@gateworks.com> wrote:

>

> > By the way, I took a quick stab at enabling SDP on

> > imx8mm-venice-gw73xx-0x and found compile issues so I configured for

> > an imx8mm_evk using your diffs and hit the same issues.

> >

> > drivers/usb/host/ehci-mx6.c: In function ‘ehci_hcd_init’:

> > drivers/usb/host/ehci-mx6.c:360:46: error: ‘USB_BASE_ADDR’ undeclared

>

> Ah, now that I try to enable SDP I see these errors too. To fix this

> error we need:

> https://git.kontron-electronics.de/linux/u-boot/-/commit/975e36c71164483a7c690e81126f77f6de482378.patch

>

> This one is also needed:

> https://git.kontron-electronics.de/linux/u-boot/-/commit/344c83522650ef8d8ea6c12c6a8209e54f0f31e6.patch

>

>

> > (first use in this function); did you mean ‘SRC_BASE_ADDR’?

> >   struct usb_ehci *ehci = (struct usb_ehci *)(USB_BASE_ADDR +

> >                                               ^~~~~~~~~~~~~

> >                                               SRC_BASE_ADDR

> > drivers/usb/host/ehci-mx6.c:360:46: note: each undeclared identifier

> > is reported only once for each function it appears in

> > drivers/usb/host/ehci-mx6.c:361:4: error: ‘controller_spacing’

>

> I need to check on this one.


Attached is a diff with all the changes that allow building SDP
support for imx8mm_evk.

But I still get:

U-Boot SPL 2021.07-rc5-00002-g5f269bf8bd14-dirty (Jul 01 2021 - 22:28:29 -0300)
WDT:   Not starting
SPL: Unsupported Boot Device!
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

Please let me know if you get any progress with SDP.

Thanks
From e7cc6989bd69eb0d346ae06023bb4525d4fc6858 Mon Sep 17 00:00:00 2001
From: Fabio Estevam <festevam@gmail.com>
Date: Thu, 1 Jul 2021 22:33:12 -0300
Subject: [PATCH] imx8mmgadgetsdp

Signed-off-by: Fabio Estevam <festevam@gmail.com>
---
 arch/arm/include/asm/arch-imx8m/clock.h    |  1 +
 arch/arm/include/asm/arch-imx8m/imx-regs.h | 11 +++++
 arch/arm/mach-imx/imx8m/clock_imx8mm.c     | 16 +++++++
 configs/imx8mm_evk_defconfig               | 27 +++++++++++
 drivers/usb/host/ehci-mx6.c                | 54 +++++++++-------------
 5 files changed, 78 insertions(+), 31 deletions(-)

diff --git a/arch/arm/include/asm/arch-imx8m/clock.h b/arch/arm/include/asm/arch-imx8m/clock.h
index 77d9428a188a..fcd111c918fd 100644
--- a/arch/arm/include/asm/arch-imx8m/clock.h
+++ b/arch/arm/include/asm/arch-imx8m/clock.h
@@ -276,3 +276,4 @@ int enable_i2c_clk(unsigned char enable, unsigned int i2c_num);
 int set_clk_enet(enum enet_freq type);
 int set_clk_eqos(enum enet_freq type);
 void hab_caam_clock_enable(unsigned char enable);
+void enable_usboh3_clk(unsigned char enable);
diff --git a/arch/arm/include/asm/arch-imx8m/imx-regs.h b/arch/arm/include/asm/arch-imx8m/imx-regs.h
index b800da13a1e4..de01e9969626 100644
--- a/arch/arm/include/asm/arch-imx8m/imx-regs.h
+++ b/arch/arm/include/asm/arch-imx8m/imx-regs.h
@@ -51,6 +51,17 @@
 
 #define TZASC_BASE_ADDR		0x32F80000
 
+#ifdef CONFIG_IMX8MM
+#define USB1_BASE_ADDR		0x32E40000
+#define USB2_BASE_ADDR		0x32E50000
+#else
+#define USB1_BASE_ADDR		0x38100000
+#define USB2_BASE_ADDR		0x38200000
+#endif
+#define USB_BASE_ADDR		USB1_BASE_ADDR
+#define USB1_PHY_BASE_ADDR	0x381F0000
+#define USB2_PHY_BASE_ADDR	0x382F0000
+
 #define MXS_LCDIF_BASE		IS_ENABLED(CONFIG_IMX8MQ) ? \
 					0x30320000 : 0x32e00000
 
diff --git a/arch/arm/mach-imx/imx8m/clock_imx8mm.c b/arch/arm/mach-imx/imx8m/clock_imx8mm.c
index f8e4ec0d9052..dd40e2f1e772 100644
--- a/arch/arm/mach-imx/imx8m/clock_imx8mm.c
+++ b/arch/arm/mach-imx/imx8m/clock_imx8mm.c
@@ -277,6 +277,22 @@ int intpll_configure(enum pll_clocks pll, ulong freq)
 	return 0;
 }
 
+void enable_usboh3_clk(unsigned char enable)
+{
+	if (enable) {
+		clock_enable(CCGR_USB_MSCALE_PL301, 0);
+		/* 500M */
+		clock_set_target_val(USB_BUS_CLK_ROOT, CLK_ROOT_ON | CLK_ROOT_SOURCE_SEL(1));
+		/* 100M */
+		clock_set_target_val(USB_CORE_REF_CLK_ROOT, CLK_ROOT_ON | CLK_ROOT_SOURCE_SEL(1));
+		/* 100M */
+		clock_set_target_val(USB_PHY_REF_CLK_ROOT, CLK_ROOT_ON | CLK_ROOT_SOURCE_SEL(1));
+		clock_enable(CCGR_USB_MSCALE_PL301, 1);
+	} else {
+		clock_enable(CCGR_USB_MSCALE_PL301, 0);
+	}
+}
+
 void init_uart_clk(u32 index)
 {
 	/*
diff --git a/configs/imx8mm_evk_defconfig b/configs/imx8mm_evk_defconfig
index a06c6f9794ac..88a95a4fe5b5 100644
--- a/configs/imx8mm_evk_defconfig
+++ b/configs/imx8mm_evk_defconfig
@@ -85,3 +85,30 @@ CONFIG_SYSRESET_PSCI=y
 CONFIG_SYSRESET_WATCHDOG=y
 CONFIG_DM_THERMAL=y
 CONFIG_IMX_WATCHDOG=y
+# CONFIG_SPL_DM_USB is not set
+CONFIG_USB_HOST_ETHER=y
+CONFIG_USB_ETHER_ASIX=y
+CONFIG_USB_ETHER_ASIX88179=y
+CONFIG_USB_ETHER_LAN75XX=y
+CONFIG_USB_ETHER_LAN78XX=y
+CONFIG_USB_ETHER_MCS7830=y
+CONFIG_USB_ETHER_RTL8152=y
+CONFIG_USB_ETHER_SMSC95XX=y
+CONFIG_POWER_DOMAIN=y
+CONFIG_IMX8M_POWER_DOMAIN=y
+CONFIG_CMD_USB=y
+CONFIG_CMD_USB_MASS_STORAGE=y
+CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_MXC_USB_OTG_HACTIVE=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_GADGET_MANUFACTURER="FSL"
+CONFIG_USB_GADGET_VENDOR_NUM=0x0525
+CONFIG_USB_GADGET_PRODUCT_NUM=0xa4a5
+CONFIG_CI_UDC=y
+CONFIG_USB_GADGET_DOWNLOAD=y
+CONFIG_SPL_USB_HOST_SUPPORT=y
+CONFIG_SPL_USB_GADGET=y
+CONFIG_SPL_USB_SDP_SUPPORT=y
+CONFIG_CMD_USB_SDP=y
diff --git a/drivers/usb/host/ehci-mx6.c b/drivers/usb/host/ehci-mx6.c
index c3e4170513ec..83f63e4cc930 100644
--- a/drivers/usb/host/ehci-mx6.c
+++ b/drivers/usb/host/ehci-mx6.c
@@ -141,12 +141,12 @@ static void __maybe_unused
 usb_power_config_mx6(void *anatop, int anatop_bits_index) { }
 #endif
 
-#if defined(CONFIG_MX7) && !defined(CONFIG_PHY)
+#if (defined(CONFIG_MX7) || defined(CONFIG_IMX8M))&& !defined(CONFIG_PHY)
 static void usb_power_config_mx7(struct usbnc_regs *usbnc)
 {
 	void __iomem *phy_cfg2 = (void __iomem *)(&usbnc->phy_cfg2);
 
-	if (!is_mx7())
+	if (!is_mx7() || !is_imx8mm())
 		return;
 
 	/*
@@ -248,7 +248,7 @@ int usb_phy_mode(int port)
 		return USB_INIT_HOST;
 }
 
-#elif defined(CONFIG_MX7)
+#elif defined(CONFIG_MX7) || defined(CONFIG_IMX8M)
 int usb_phy_mode(int port)
 {
 	struct usbnc_regs *usbnc = (struct usbnc_regs *)(USB_BASE_ADDR +
@@ -346,7 +346,7 @@ int ehci_hcd_init(int index, enum usb_init_type init,
 		(struct anatop_regs __iomem *)ANATOP_BASE_ADDR;
 	struct usbnc_regs *usbnc = (struct usbnc_regs *)(USB_BASE_ADDR +
 			USB_OTHERREGS_OFFSET);
-#elif defined(CONFIG_MX7)
+#elif defined(CONFIG_MX7) || defined(CONFIG_IMX8M)
 	u32 controller_spacing = 0x10000;
 	struct usbnc_regs *usbnc = (struct usbnc_regs *)(USB_BASE_ADDR +
 			(0x10000 * index) + USBNC_OFFSET);
@@ -390,7 +390,9 @@ int ehci_hcd_init(int index, enum usb_init_type init,
 	usb_power_config_mx7ulp(usbphy);
 #endif
 
+#if !defined(CONFIG_PHY)
 	usb_oc_config(usbnc, index);
+#endif
 
 #if defined(CONFIG_MX6) || defined(CONFIG_MX7ULP) || defined(CONFIG_IMXRT)
 	if (index < ARRAY_SIZE(phy_bases)) {
@@ -523,7 +525,7 @@ static int ehci_usb_phy_mode(struct udevice *dev)
 			plat->init_type = USB_INIT_DEVICE;
 		else
 			plat->init_type = USB_INIT_HOST;
-	} else if (is_mx7()) {
+	} else if (is_mx7() || is_imx8mm()) {
 		phy_status = (void __iomem *)(addr +
 					      USBNC_PHY_STATUS_OFFSET);
 		val = readl(phy_status);
@@ -539,28 +541,6 @@ static int ehci_usb_phy_mode(struct udevice *dev)
 	return 0;
 }
 
-static int ehci_usb_of_to_plat(struct udevice *dev)
-{
-	struct usb_plat *plat = dev_get_plat(dev);
-	enum usb_dr_mode dr_mode;
-
-	dr_mode = usb_get_dr_mode(dev_ofnode(dev));
-
-	switch (dr_mode) {
-	case USB_DR_MODE_HOST:
-		plat->init_type = USB_INIT_HOST;
-		break;
-	case USB_DR_MODE_PERIPHERAL:
-		plat->init_type = USB_INIT_DEVICE;
-		break;
-	case USB_DR_MODE_OTG:
-	case USB_DR_MODE_UNKNOWN:
-		return ehci_usb_phy_mode(dev);
-	};
-
-	return 0;
-}
-
 static int mx6_parse_dt_addrs(struct udevice *dev)
 {
 #if !defined(CONFIG_PHY)
@@ -622,7 +602,6 @@ static int ehci_usb_probe(struct udevice *dev)
 	struct usb_plat *plat = dev_get_plat(dev);
 	struct usb_ehci *ehci = dev_read_addr_ptr(dev);
 	struct ehci_mx6_priv_data *priv = dev_get_priv(dev);
-	enum usb_init_type type = plat->init_type;
 	struct ehci_hccr *hccr;
 	struct ehci_hcor *hcor;
 	int ret;
@@ -640,7 +619,6 @@ static int ehci_usb_probe(struct udevice *dev)
 		return ret;
 
 	priv->ehci = ehci;
-	priv->init_type = type;
 
 #if CONFIG_IS_ENABLED(CLK)
 	ret = clk_get_by_index(dev, 0, &priv->clk);
@@ -656,6 +634,21 @@ static int ehci_usb_probe(struct udevice *dev)
 	mdelay(1);
 #endif
 
+	switch (usb_get_dr_mode(dev_ofnode(dev))) {
+	case USB_DR_MODE_HOST:
+		plat->init_type = USB_INIT_HOST;
+		break;
+	case USB_DR_MODE_PERIPHERAL:
+		plat->init_type = USB_INIT_DEVICE;
+		break;
+	case USB_DR_MODE_OTG:
+	case USB_DR_MODE_UNKNOWN:
+		ret = ehci_usb_phy_mode(dev);
+		if (ret)
+			return ret;
+	};
+	priv->init_type = plat->init_type;
+
 #if CONFIG_IS_ENABLED(DM_REGULATOR)
 	ret = device_get_supply_regulator(dev, "vbus-supply",
 					  &priv->vbus_supply);
@@ -679,7 +672,7 @@ static int ehci_usb_probe(struct udevice *dev)
 #if CONFIG_IS_ENABLED(DM_REGULATOR)
 	if (priv->vbus_supply) {
 		ret = regulator_set_enable(priv->vbus_supply,
-					   (type == USB_INIT_DEVICE) ?
+					   (priv->init_type == USB_INIT_DEVICE) ?
 					   false : true);
 		if (ret && ret != -ENOSYS) {
 			printf("Error enabling VBUS supply (ret=%i)\n", ret);
@@ -764,7 +757,6 @@ U_BOOT_DRIVER(usb_mx6) = {
 	.name	= "ehci_mx6",
 	.id	= UCLASS_USB,
 	.of_match = mx6_usb_ids,
-	.of_to_plat = ehci_usb_of_to_plat,
 	.probe	= ehci_usb_probe,
 	.remove = ehci_usb_remove,
 	.ops	= &ehci_usb_ops,
Fabio Estevam July 2, 2021, 2:50 p.m. UTC | #13
Hi Tim,

On Thu, Jul 1, 2021 at 10:36 PM Fabio Estevam <festevam@gmail.com> wrote:

> But I still get:

>

> U-Boot SPL 2021.07-rc5-00002-g5f269bf8bd14-dirty (Jul 01 2021 - 22:28:29 -0300)

> WDT:   Not starting

> SPL: Unsupported Boot Device!

> SPL: failed to boot from all boot devices

> ### ERROR ### Please RESET the board ###

>

> Please let me know if you get any progress with SDP.


The USB_BOOT option was missing in imx8mm_evk spl:

--- a/board/freescale/imx8mm_evk/spl.c
+++ b/board/freescale/imx8mm_evk/spl.c
@@ -33,6 +33,8 @@ DECLARE_GLOBAL_DATA_PTR;
 int spl_board_boot_device(enum boot_device boot_dev_spl)
 {
        switch (boot_dev_spl) {
+       case USB_BOOT:
+               return BOOT_DEVICE_BOARD;
        case SD2_BOOT:
        case MMC2_BOOT:
                return BOOT_DEVICE_MMC1;

After that I can load flash.bin and u-boot.itb via uuu like this
(thanks to Heiko's suggestion!)

sudo uuu flash.bin
sudo uuu SDPV: write -f u-boot.itb -addr 0x42000000
sudo uuu SDPV: jump -addr 0x42000000

I will submit the support for imx8mm-evk SDP soon. Will also add these
commands into the readme.

Thanks
Tim Harvey July 2, 2021, 9:12 p.m. UTC | #14
On Fri, Jul 2, 2021 at 7:50 AM Fabio Estevam <festevam@gmail.com> wrote:
>

> Hi Tim,

>

> On Thu, Jul 1, 2021 at 10:36 PM Fabio Estevam <festevam@gmail.com> wrote:

>

> > But I still get:

> >

> > U-Boot SPL 2021.07-rc5-00002-g5f269bf8bd14-dirty (Jul 01 2021 - 22:28:29 -0300)

> > WDT:   Not starting

> > SPL: Unsupported Boot Device!

> > SPL: failed to boot from all boot devices

> > ### ERROR ### Please RESET the board ###

> >

> > Please let me know if you get any progress with SDP.

>

> The USB_BOOT option was missing in imx8mm_evk spl:

>

> --- a/board/freescale/imx8mm_evk/spl.c

> +++ b/board/freescale/imx8mm_evk/spl.c

> @@ -33,6 +33,8 @@ DECLARE_GLOBAL_DATA_PTR;

>  int spl_board_boot_device(enum boot_device boot_dev_spl)

>  {

>         switch (boot_dev_spl) {

> +       case USB_BOOT:

> +               return BOOT_DEVICE_BOARD;

>         case SD2_BOOT:

>         case MMC2_BOOT:

>                 return BOOT_DEVICE_MMC1;

>

> After that I can load flash.bin and u-boot.itb via uuu like this

> (thanks to Heiko's suggestion!)

>

> sudo uuu flash.bin

> sudo uuu SDPV: write -f u-boot.itb -addr 0x42000000

> sudo uuu SDPV: jump -addr 0x42000000

>

> I will submit the support for imx8mm-evk SDP soon. Will also add these

> commands into the readme.

>


Fabio,

After applying the other patches in your diff I'm able to get SDP
booting on my board as well.

Please CC me when you submit your SDP series. It will overlap with my
'usb: ehci-mx6: move mode set/detect to probe'.

Also, when you prepare your patches note you don't need the following
in your include/config/imx8mm_evk.h
#define CONFIG_MXC_USB_PORTSC   (PORT_PTS_UTMI | PORT_PTS_PTW)
^^^  this is defaulted in drivers/usb/host/ehci-mx6.c
#define CONFIG_MXC_USB_FLAGS 0
^^^ doesn't appear to be used by ehci-mx6.c

Unfortunately enabling SPL SDP for my board brings me over the SPL
size. I really want to come up with a way to load dram config
dynamically.

Best regards,

Tim
Fabio Estevam July 2, 2021, 9:32 p.m. UTC | #15
Hi Tim,

On Fri, Jul 2, 2021 at 6:13 PM Tim Harvey <tharvey@gateworks.com> wrote:

> Fabio,

>

> After applying the other patches in your diff I'm able to get SDP

> booting on my board as well.

>

> Please CC me when you submit your SDP series. It will overlap with my

> 'usb: ehci-mx6: move mode set/detect to probe'.


Ok, great. I will submit your two patches, Frieder's and mine in a
single series.

> Also, when you prepare your patches note you don't need the following

> in your include/config/imx8mm_evk.h

> #define CONFIG_MXC_USB_PORTSC   (PORT_PTS_UTMI | PORT_PTS_PTW)

> ^^^  this is defaulted in drivers/usb/host/ehci-mx6.c

> #define CONFIG_MXC_USB_FLAGS 0

> ^^^ doesn't appear to be used by ehci-mx6.c


Thanks, I have removed it.

> Unfortunately enabling SPL SDP for my board brings me over the SPL

> size. I really want to come up with a way to load dram config

> dynamically.


Yes, I am interested in doing this too.

I saw the same issue on an imx8mm-cl-iot-gate.

They support several DDR config options and after enabling SPL SDP
there was an OCRAM overflow.

Thanks,

Fabio Estevam
Michael Trimarchi March 9, 2022, 10:52 a.m. UTC | #16
Hi

Adding Tommaso

On Fri, Apr 10, 2020 at 8:37 PM Tim Harvey <tharvey@gateworks.com> wrote:
>
> On Thu, Apr 9, 2020 at 2:45 PM Tim Harvey <tharvey@gateworks.com> wrote:
> >
> > On Thu, Apr 9, 2020 at 3:02 AM Schrempf Frieder
> > <frieder.schrempf@kontron.de> wrote:
> > >
> > > On 08.04.20 17:31, Tim Harvey wrote:
> > > [...]
> > > >>
> > > >> In my case I'm loading a FIT image, so things are a bit different.
> > > >> Where are you loading the image to?
> > > >>
> > > >> I have the following line in mx8mm_usb_sdp_spl.conf to load my FIT image
> > > >> to DDR and jump to it:
> > > >>
> > > >> /path/to/image/u-boot.itb:load 0x40200000, jump_direct 0x40200000
> > > >>
> > > >
> > > > Frieder,
> > > >
> > > > I was trying to load u-boot.img
> > > >
> > > > The SPL boots fine:
> > > > U-Boot SPL 2020.01-00029-g5ad7797 (Apr 08 2020 - 08:16:53 -0700)
> > > > read error from device: 9310b8 register: x!Normal Boot
> > > > Trying to boot from USB SDP
> > > > SDP: initialize...
> > > > SDP: handle requests..
> > > >
> > > > But when I 'imx_usb u-boot.img' it complains there is no header on
> > > > u-boot.img. I enabled FIT generation and attempted to 'imx_usb
> > > > u-boot.itb' but imx_usb still complains about no header found.
> > > >
> > > > My mx8mm_usb_sdp_spl.conf loooks like this:
> > > > mx8mm_spl_sdp
> > > > #hid/bulk,[old_header,]max packet size, {ram start, ram size}(repeat
> > > > valid ram areas)
> > > > #In SPL, we typically load u-boot.img which has a U-boot header...
> > > > hid,1024,0x910000,0x40000000,1G,0x00900000,0x40000
> > > >
> > > > #0x60000 - 0x8400 = 0x57c00, +0x3000=5ac00 (FIT image)
> > > > ../u-boot-imx6/u-boot.bin:load 0x40200000
> > > > ../u-boot-imx6/bl31-iMX8MM.bin:load 0x00920000,jump 0x920000
> > > >
> > > > What does your mx8mm_usb_sdp_spl.conf look like? I must admit I don't
> > > > really understand how these are configured.
> > >
> > > It looks just like yours except that I have a single instruction as
> > > already stated above:
> > >
> > > /path/to/image/u-boot.itb:load 0x40200000, jump_direct 0x40200000
> > >
> > > and I'm loading the FIT image by running './imx_usb' without arguments.
> > >
> > > As imx_usb_loader can't parse FIT image headers, I use 'jump_direct' to
> > > jump to the raw image entry point and let SPL parse the FIT. I think in
> > > that case imx_usb_loader shouldn't complain about a missing header.
> >
> > Frieder,
> >
> > Ok, I finally understand. Using 'imx_usb <file>' which is what I was
> > doing is not the same as loading it via the conf file and was why it
> > was looking for a header.
> >
> > So now that I'm using the imx_usb.conf files fully instead It's
> > loading u-boot.itb and jumping but unfortunately I'm still not quite
> > there.
> >
> > Here's what I'm seeing:
> >
> > U-Boot SPL 2020.01-00029-g6529a03-dirty (Apr 09 2020 - 13:02:21 -0700)
> > Normal Boot
> > Trying to boot from USB SDP
> > SDP: initialize...
> > SDP: handle requests...
> > Downloading file of size 584020 to 0x40200000... done
> > Jumping to header at 0x40200000
> > Header Tag is not an IMX image
> >
> > Is the 'Header Tag' message normal? From adding some debugging it
> > appears to matching the dts name in my board_fit_config_name_match and
> > parsing the FIT image, loading the ATF and jumping but then I get
> > nothing. What would I expect at this point and do you have any
> > troubleshooting tips?
> >
>
> Frieder,
>
> My issue was that I forgot to set ATF_LOAD_ADDR=0x920000!
>
> So I'm running now, booting imx8mm-evk via SDP using your USB patches
> and imx_usb configuration.
>
> Thank you for your help!
>
> Tim


Michael
Tommaso Merciai March 9, 2022, 11:06 a.m. UTC | #17
Hi All,
In these days I'm working on SDP_SPL support on iMX8MM, thanks to Tim
that guide me over the following patches:

https://patchwork.ozlabs.org/project/uboot/list/?series=251796&state=*

I'm able to reach the goal to boot U-Boot 2022.04-rc3 over SDP from
SPL. I would like to suggest that at the current state of the project you need 
to add also the following configs:

CONFIG_SPL_USB_HOST=y
CONFIG_SDP_LOADADDR=0x40400000

Using that I'm able to boot the U-Boot 2022.04-rc3 with the following
.lst file:

sudo uuu file.lst

file.lst
------------------------------------------------------------------------
uuu_version 1.2.39

# This command will be run when i.MX6/7 i.MX8MM, i.MX8MQ
SDP: boot -f flash.bin

# These commands will be run when use SPL and will be skipped if no spl
# if (SPL support SDPV)
# {
SDPV: delay 1000
SDPV: write -f flash.bin  -skipspl -offset 0x0
SDPV: jump
# }

FB: done
------------------------------------------------------------------------

I hope this can help some other person.

Regards,
Tommaso

On Wed, Mar 09, 2022 at 11:52:47AM +0100, Michael Nazzareno Trimarchi wrote:
> Hi
> 
> Adding Tommaso
> 
> On Fri, Apr 10, 2020 at 8:37 PM Tim Harvey <tharvey@gateworks.com> wrote:
> >
> > On Thu, Apr 9, 2020 at 2:45 PM Tim Harvey <tharvey@gateworks.com> wrote:
> > >
> > > On Thu, Apr 9, 2020 at 3:02 AM Schrempf Frieder
> > > <frieder.schrempf@kontron.de> wrote:
> > > >
> > > > On 08.04.20 17:31, Tim Harvey wrote:
> > > > [...]
> > > > >>
> > > > >> In my case I'm loading a FIT image, so things are a bit different.
> > > > >> Where are you loading the image to?
> > > > >>
> > > > >> I have the following line in mx8mm_usb_sdp_spl.conf to load my FIT image
> > > > >> to DDR and jump to it:
> > > > >>
> > > > >> /path/to/image/u-boot.itb:load 0x40200000, jump_direct 0x40200000
> > > > >>
> > > > >
> > > > > Frieder,
> > > > >
> > > > > I was trying to load u-boot.img
> > > > >
> > > > > The SPL boots fine:
> > > > > U-Boot SPL 2020.01-00029-g5ad7797 (Apr 08 2020 - 08:16:53 -0700)
> > > > > read error from device: 9310b8 register: x!Normal Boot
> > > > > Trying to boot from USB SDP
> > > > > SDP: initialize...
> > > > > SDP: handle requests..
> > > > >
> > > > > But when I 'imx_usb u-boot.img' it complains there is no header on
> > > > > u-boot.img. I enabled FIT generation and attempted to 'imx_usb
> > > > > u-boot.itb' but imx_usb still complains about no header found.
> > > > >
> > > > > My mx8mm_usb_sdp_spl.conf loooks like this:
> > > > > mx8mm_spl_sdp
> > > > > #hid/bulk,[old_header,]max packet size, {ram start, ram size}(repeat
> > > > > valid ram areas)
> > > > > #In SPL, we typically load u-boot.img which has a U-boot header...
> > > > > hid,1024,0x910000,0x40000000,1G,0x00900000,0x40000
> > > > >
> > > > > #0x60000 - 0x8400 = 0x57c00, +0x3000=5ac00 (FIT image)
> > > > > ../u-boot-imx6/u-boot.bin:load 0x40200000
> > > > > ../u-boot-imx6/bl31-iMX8MM.bin:load 0x00920000,jump 0x920000
> > > > >
> > > > > What does your mx8mm_usb_sdp_spl.conf look like? I must admit I don't
> > > > > really understand how these are configured.
> > > >
> > > > It looks just like yours except that I have a single instruction as
> > > > already stated above:
> > > >
> > > > /path/to/image/u-boot.itb:load 0x40200000, jump_direct 0x40200000
> > > >
> > > > and I'm loading the FIT image by running './imx_usb' without arguments.
> > > >
> > > > As imx_usb_loader can't parse FIT image headers, I use 'jump_direct' to
> > > > jump to the raw image entry point and let SPL parse the FIT. I think in
> > > > that case imx_usb_loader shouldn't complain about a missing header.
> > >
> > > Frieder,
> > >
> > > Ok, I finally understand. Using 'imx_usb <file>' which is what I was
> > > doing is not the same as loading it via the conf file and was why it
> > > was looking for a header.
> > >
> > > So now that I'm using the imx_usb.conf files fully instead It's
> > > loading u-boot.itb and jumping but unfortunately I'm still not quite
> > > there.
> > >
> > > Here's what I'm seeing:
> > >
> > > U-Boot SPL 2020.01-00029-g6529a03-dirty (Apr 09 2020 - 13:02:21 -0700)
> > > Normal Boot
> > > Trying to boot from USB SDP
> > > SDP: initialize...
> > > SDP: handle requests...
> > > Downloading file of size 584020 to 0x40200000... done
> > > Jumping to header at 0x40200000
> > > Header Tag is not an IMX image
> > >
> > > Is the 'Header Tag' message normal? From adding some debugging it
> > > appears to matching the dts name in my board_fit_config_name_match and
> > > parsing the FIT image, loading the ATF and jumping but then I get
> > > nothing. What would I expect at this point and do you have any
> > > troubleshooting tips?
> > >
> >
> > Frieder,
> >
> > My issue was that I forgot to set ATF_LOAD_ADDR=0x920000!
> >
> > So I'm running now, booting imx8mm-evk via SDP using your USB patches
> > and imx_usb configuration.
> >
> > Thank you for your help!
> >
> > Tim
> 
> 
> Michael
> 
> -- 
> Michael Nazzareno Trimarchi
> Co-Founder & Chief Executive Officer
> M. +39 347 913 2170
> michael@amarulasolutions.com
> __________________________________
> 
> Amarula Solutions BV
> Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
> T. +31 (0)85 111 9172
> info@amarulasolutions.com
> www.amarulasolutions.com
diff mbox series

Patch

diff --git a/imx_usb.conf b/imx_usb.conf
index c7c00f6..4d89230 100644
--- a/imx_usb.conf
+++ b/imx_usb.conf
@@ -17,6 +17,7 @@ 
 0x066f:0x37ff, linux_gadget.conf
 0x1b67:0x4fff, mx6_usb_sdp_spl.conf
 0x0525:0xb4a4, mx6_usb_sdp_spl.conf
+0x0525:0xc4a4, mx8mm_usb_sdp_spl.conf
 0x1fc9:0x012b, mx8mq_usb_work.conf
 0x1fc9:0x0134, mx8mm_usb_work.conf
 0x1fc9:0x013e, mx8mn_usb_work.conf