0:09
welcome to the second video of the
0:11
ethernet configuration
0:14
you must watch part one before watching
0:18
in the previous video we configured the
0:20
mii with the memory configuration
0:22
and as i mentioned this video will cover
0:25
the rmii without memory configuration
0:34
so let's start the cube id
0:40
i am using stm 32 f 7 5 0
0:43
discovery board and here is the ethernet
0:49
give some name to the project and click
0:54
let's see the board schematics
1:03
here is the ethernet module and as you
1:07
it have the rmii connection type
1:15
first of all i am selecting the external
1:17
crystal for the clock
1:25
the ball have 25 megahertz crystal and i
1:28
am running it at the maximum
1:30
216 megahertz frequency
1:43
now let's go to the ethernet tab and
1:51
this entire thing looks too messy let me
1:53
clear the pin outs first
2:12
okay now let's enable the ethernet rmii
2:16
we will configure the parameters later
2:19
first as i mentioned in the first video
2:23
the cube mx will mostly configure the
2:27
so make sure the pins are configured
2:29
exactly as they are in the schematics
2:39
apparently they are correct here but if
2:42
all you have to do is click on the
2:44
correct pin and choose the function
2:47
the other one will disable itself
3:01
the pins are fine so let's go to the
3:06
notice that unlike the first video here
3:09
we don't have the option to configure
3:12
so let's configure the rest of the
3:16
make sure the p-h-y address is zero
3:19
this zero should be selected for
3:21
on-board ethernet port
3:23
just like i have on my discovery board
3:26
if you are using any external module
3:29
shown in the picture i think you need to
3:33
i am not very sure about this i will
3:36
leave the comment later
3:43
now leave everything to default
3:49
this is it for the ethernet
3:53
now let's configure the lwip
4:04
again we have d h c p and we will
4:09
now we will manually configure the i p
4:12
and the gateway this will be the static
4:18
leave everything to default and go to
4:23
here we will configure the heap size
4:26
just like the first video we will keep
4:31
notice here that we don't have the
4:32
option to configure the address for the
4:36
but that's ok leave the rest of them to
4:41
we don't need to configure these
4:44
make sure the checksum is enabled
4:48
that's it for the lwip configuration
4:52
this was considerably easier as compared
4:55
to the previous video
4:57
now i am enabling the cache
5:02
and finally we will configure the mpu
5:09
but before that let's build the code
5:12
to check for the sizes
5:21
i only have one ram here and everything
5:32
the txdma descriptor is 128 bytes in
5:38
also there is tx buffer which wasn't
5:40
present in the previous video
5:43
also keep an eye on their locations in
5:50
we have r x buffer and e m a descriptor
6:04
if we check the ethernet if dot c file
6:07
here you will notice that
6:08
there are no sections defined for the
6:10
buffers if you remember
6:12
the previous video this is how they were
6:16
well there is a valid reason for that
6:22
this is the memory organization for the
6:29
the ram is made up of dtcm sram
6:32
1 and s ram 2. if you notice the memory
6:36
locations of all the descriptors and
6:38
they are all defined in the dtcm region
6:42
if you have watched my previous videos
6:44
on memory configurations
6:46
you might remember that the tcm memories
6:50
so if we keep the dma descriptors in the
6:54
we don't need to worry about cache
6:55
coherency and that's what is happening
6:59
technically if i don't do any memory or
7:03
the code will still work all right this
7:06
i will show in the end of the video
7:09
but this won't be the case for everyone
7:11
so i am going to go ahead with memory
7:15
i am going to shift the descriptors and
7:17
buffers to this sram 1 region
7:23
so let's go back to our cube mx and
7:26
configure the mpu first
7:37
the base address will be the address for
7:46
now the size let's see how the memory
7:51
the allocation starts at 2 million 10
7:54
and here we will keep the dma rx
7:58
this will occupy 128 bytes
8:02
and there we will keep the d-m-a-t-x
8:05
which will occupy another 128 bytes
8:09
then we have the rx buffer and the tx
8:13
they both are taking 5.95 kilobytes of
8:23
altogether they will take 12.15
8:34
so in the mpu configuration choosing a
8:37
16 kilobytes region will do the job
8:45
now just like previous video we will
8:48
make this region as non-cachable
8:55
so select that x 1 commit all access
8:58
and set up the shareable non cacheable
9:05
that's it for the mpu configuration
9:08
the other configuration is for qspi
9:11
and you don't need to worry about that
9:29
now we need to add the sections in the
9:34
here i have added them starting with dma
9:38
and then the buffers the memories are
9:41
spaced as per the size requirement for
9:55
but the objects will not relocate just
9:57
yet because they are not linked to those
9:59
sections we defined so we need to link
10:09
everything i am doing now has been
10:12
covered in the memory configuration
10:15
so if you don't understand this watch
10:19
this will be our section and we will
10:21
link it to the dmarx descriptor
10:30
similarly we need to link others also
10:42
now comment out this part and build the
10:56
note here the locations for the tx
10:59
descriptor and buffer has been shifted
11:03
so we are good to go let's write our
11:07
just like we did in the previous video
11:24
let's debug it and check if we have any
11:39
it hit the break point so everything is
11:44
now we will let it run freely and ping
11:54
so it's working perfectly
11:59
one last thing i wanted to show you here
12:03
remember when i said the buffers and
12:05
descriptors are placed in the tcm ram
12:07
so they don't need the mpu or any memory
12:12
let's comment out this part now the
12:15
descriptors are placed in their default
12:18
and we can check it in the memory
12:27
you can see the location here it's in
12:34
also remember that m p u is not
12:38
we have configured it only for the sram
12:42
so this is basically the default setup
12:44
with no modifications for the memory
12:47
let me comment out this part also just
12:50
for the satisfaction
13:12
so we hit the break point means
13:16
and if we ping the address we do get the
13:20
so this was the configuration for the
13:24
i know for some of you this will be as
13:26
simple as the default setup
13:28
and for the rest it could get very
13:32
that's why i have covered every possible
13:36
every complicated thing shown in the
13:38
video have already been explained in the
13:42
watch the cortex m7 series videos from
13:46
and you will understand everything the
13:49
next video on ethernet will cover the
13:53
this is it for today you can download
13:56
the code from the link in the
13:59
keep watching be safe and have a nice