0:09
hello and welcome to controllers Tech I
0:12
have covered a lot of videos in the w25
0:15
Q Series explaining different topics
0:18
which include the regular SBI Flash and
0:20
also the quad SBI mode I have also
0:24
covered the video explaining how to
0:26
create an external loader for the custom
0:30
even after explaining it in so much
0:32
detail some of you still have issues
0:34
running it on the cortex M7 based
0:37
boards so today this video will explain
0:40
how to do everything related to w25 Q
0:43
external flash memory on ah7 series
0:47
microcontroller we will see how to set
0:49
up the quad SBI peripheral how to add
0:52
the libraries how to test if everything
0:54
is working how to create an external
0:56
loader and finally how to use the loader
1:00
I am going to use the SDM 32
1:03
h750 custom development board from
1:06
devbox these boards containing the
1:09
h750 and h74 3 chipsets will soon be
1:13
available on controller's tech store so
1:16
the Indian audience can purchase it from
1:18
there today I am using this
1:21
h750 based development
1:24
board both these boards have w25 q64
1:28
external flash memory connected via the
1:32
mode here is the zoomed in picture of
1:35
the board and here you can see the w25
1:38
q64 chip soldered on the
1:41
board I am going to use my own tutorial
1:44
to set up the w25 Q flash in the quad
1:48
mode here is the schematic for the
1:51
development board I am
1:53
using here you can see the w25 Q flash
1:57
memory is connected via the quad SBI
2:01
we will set up our quad SBI peripheral
2:03
according to this all right let's start
2:06
the cube ID and create a new
2:09
project I have the SDM 32 h750 vbt 6
2:16
MCU give some name to the project and
2:20
finish let's start with the clock setup
2:23
first I am choosing the external Crystal
2:26
for the clock the board has 25 mehz
2:30
Crystal on it so make sure the input
2:35
25 here you can see in the image the 25
2:38
MHz crystal is present on the board we
2:42
will run the system at 400 MHz
2:45
frequency all right the clock is
2:48
configured now go to quad SBI and enable
2:54
lines now first of all we will set up
2:57
the pins as per the connection shown in
3:03
itic you can search for the pin name and
3:06
then enable the respective quad SBI
3:11
pin all right all the pins have been
3:13
configured as per the schematic so now
3:16
we will configure the
3:18
parameters I am going to configure it as
3:21
tutorial the quad SBI clock is running
3:24
at 200 MHz so let's set the prescaler to
3:28
one which will bring down the clock to
3:31
mahz the fifo threshold is set to four
3:35
and the sample shifting to half
3:37
cycle next is The Flash
3:40
size here is the formula to calculate
3:43
the flash size the value here in this
3:47
tutorial is 21 for the 32 megabits flash
3:51
memory so for the 64 megabits memory the
3:54
size will be one Higher that is
3:57
22 that is all we need to configure the
4:01
parameters if you check the pin settings
4:04
all the pins are configured with low
4:05
output speed we actually need these pins
4:09
to have the maximum output speed so
4:12
select all the pins then scroll down and
4:16
set the output speed to very high now
4:19
since we are using the cortex M7 core we
4:22
need to configure the memory protection
4:24
unit also enable the mpu in the default
4:28
mode now en enable the first mpu region
4:32
set the base region to 90 million hex we
4:36
have 64 megabits memory so the size is 8
4:40
megab there is no sub region the text
4:44
field level should be zero set the
4:46
permission to All Access permitted
4:49
instruction access should be disabled
4:52
sharability should be disabled and
4:54
enable the buffable and cachable
4:57
permissions make sure to enable the I
5:01
dcash now let's go to the project
5:03
manager code generator and check this
5:06
box to generate the separate Library
5:09
files that is all we need to configure
5:12
click save to generate the project now
5:15
we need to modify the quad SBA
5:19
files I will use the code from my
5:21
previous tutorial again let's download
5:25
the project from this tutorial
5:36
we need to copy the code from quad SPF
5:39
files let's copy the code from user Code
5:42
Zero part to the same part in our
5:45
project now copy the code from the user
5:48
code one to the same part
6:01
next we need to copy the code from the
6:02
Quad SBI header file to our
6:20
project the only data we need to modify
6:23
here is this the memory size the memory
6:26
size is 64 megabits so set the
6:29
equivalent hexadecimal value our quad
6:32
SBI driver is ready so we need to test
6:35
it I will use the quad SBI testing code
6:39
from the SD's GitHub page here is the
6:42
SD's library for the external loader for
6:45
the quad SBI flash memories switch to
6:50
Branch here you can see the quad SBI
6:53
testing folder open the mount test file
6:57
now let's copy the content from this
7:13
file all right let's build the project
7:17
now we don't have any errors so let's
7:25
it we will set a break point to our
7:28
while loop if this breakpoint is hit
7:30
that means the test is successful let's
7:33
run the debugger now all right we have
7:36
hit the breake point which means the
7:41
successful actually in this we first
7:43
initialize the memory and then erase the
7:47
sectors then we write data to these
7:50
sectors then we enable the memory Mac
7:53
mode and compare the data stored in
7:55
these 100 sectors to the data we wrote
7:59
If if there is any mismatch the control
8:01
will enter an infinite Loop since the
8:04
memory mapped mode is enabled the
8:06
external memory is mapped as an internal
8:09
memory and hence we can even view the
8:11
external memory in the memory viewer
8:13
tab here you can see the data present in
8:18
memory now that the memory test is
8:21
successful we will create and test the
8:23
external loader we will use the loader
8:26
files provided in the SD's GitHub page
8:29
so let's download this entire code
8:35
first we need the loader files so open
8:39
folder we are using the H7 based device
8:43
so open the respective
8:45
folder now copy these files inside the
8:49
folder copy the C files inside the
8:52
source directory and H files inside the
8:56
directory also copy the Linker script to
9:01
folder let's open the device info source
9:04
file here we can set the name for the
9:07
loader I am setting it to
9:14
box the start address is set to qbi
9:20
hex the memory size is fetched from the
9:23
Quad SBI header file which we have
9:31
all right now open the Linker
9:34
file here check the size of ram D1 and
9:37
set it according to your
9:39
MCU comment out his code which we wrote
9:44
memory now we need to set the Linker
9:47
file as the default Linker file for this
9:50
project open the project properties go
9:53
to cc++ build setting GCC Linker General
9:59
here the flash script is set as the
10:01
default Linker file so change it to the
10:03
Linker script file we copied just now
10:07
make sure to uncheck the discard unused
10:11
box now build the project to generate
10:14
loader our build is successful and you
10:17
can see in the memory details now we
10:21
D1 let's delete this debug folder once
10:25
and rebuild the project again or write
10:28
the debug bug folder has been generated
10:31
again and our loader is inside this
10:34
itself this elf file is what we
10:37
need let's open this folder in the
10:40
system Explorer and copy this elf file
10:43
inside the main project
10:44
folder now rename this file and give it
10:51
ldr our external loader is ready now so
10:55
we will quickly test it we should create
10:57
a new project to test it but I don't
11:00
want to waste time on creating another
11:02
project so I will test it on this
11:05
itself let's exclude the source files we
11:08
just copied from the
11:10
project we don't need these files
11:12
anymore as our loader is already
11:15
created now delete the debug folder and
11:19
we also need to set the Linker back to
11:24
script also make sure to check the box
11:27
for discard unused section
11:35
now let's build the project once to see
11:37
if everything is fine we got the
11:40
memories in the memory regions
11:42
window now initialize the quad SBI
11:45
driver and enable the memory mapped
11:54
mode open the flash script and Define a
11:57
new region qsb I the start address will
12:01
be 90 million hex and the size is 8
12:07
megab at the end of this script file we
12:10
will Define a new section where we will
12:13
relocate the data from internal
12:15
flash this section will point to the qbi
12:21
defined let's build the project
12:24
once here in the memory region you can
12:27
see the qsp region has also been added
12:31
now let's define the data that we want
12:33
to copy to the qsba memory also Define
12:37
another buffer to store the data which
12:39
we will read from the
12:41
memory right now this buffer is defined
12:44
in the flash memory to relocate it to
12:47
the external flash we need to give it a
12:50
section attribute which should point to
12:52
the section we defined in the flash
12:55
script now inside the main function
12:58
after the memory has been mapped as the
12:59
internal memory we can use the mem copy
13:02
function to copy the data from external
13:04
memory to the buffer we
13:06
defined let's build the project now here
13:10
you can see the qbi occupancy is 27
13:14
bytes these 27 bytes are the data bytes
13:17
we relocated to qbi memory
13:20
region all right that is all we need
13:23
here let's test it now since we are
13:26
writing the data to the external flash
13:28
memory memory we need the loader to do
13:31
so open the debug configuration go to
13:35
the debugger tab scroll down to external
13:37
loaders click add to add the loader
13:41
since I have the loader inside this
13:43
project itself I am using the workspace
13:46
to locate it or right click apply to
13:49
save the configuration and debug the
13:56
project let's open the memory viewer to
13:58
check the data in the qbi
14:01
memory I am setting a breakpoint here we
14:05
have hit the breakpoint and the memory
14:09
accessible let's step over this
14:12
statement the memory has been mapped as
14:15
internal memory and now we can access it
14:17
in the memory viewer you can see that it
14:21
contains the same data that we relocated
14:23
to it the read buffer is empty right now
14:28
let's step over this
14:30
statement the read buffer now contains
14:33
the same data that we have in the
14:35
external memory so everything is working
14:39
fine instead of copying the data from
14:41
the buffer we defined we can also copy
14:44
the data from the external flash memory
14:50
location let's quickly test if we can
14:52
copy the data successfully
14:55
here the read buffer is empty right now
14:58
and and when we step over the statement
15:00
we get the data stored in the qbi memory
15:04
so we were able to successfully test the
15:06
external loader we created we can now
15:09
use this loader in our application to
15:12
copy larger data to the external flash
15:14
memory we will use it in the next video
15:17
to load the entire lvgl from the
15:19
external memory basically the xip
15:23
execute in place this is it for the
15:26
video we were able to test the quad I
15:29
flash memory created an external loader
15:31
for our custom board and successfully
15:34
tested the loader I hope you understood
15:37
everything explained in the video you
15:40
can download the project from the link
15:42
in the description leave comments in
15:45
case of any doubt keep watching and have