Skip to content

Commit 9944e65

Browse files
committed
docs(linux): J784S4: Add the PCIe boot documentation
Add PCIe boot documentation for J784S4. While at it also add more details to PCIe boot procedure. Signed-off-by: Hrushikesh Salunke <h-salunke@ti.com>
1 parent e9b852c commit 9944e65

File tree

2 files changed

+204
-49
lines changed

2 files changed

+204
-49
lines changed

configs/J784S4/J784S4_linux_toc.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ linux/Foundational_Components/U-Boot/UG-UFS
4040
linux/Foundational_Components/U-Boot/UG-DDRSS-J7
4141
linux/Foundational_Components/U-Boot/UG-HyperBus
4242
linux/Foundational_Components/U-Boot/UG-RemoteProc
43+
linux/Foundational_Components/U-Boot/UG-PCIeBoot
4344
linux/Foundational_Components/U-Boot/UG-HSM
4445
linux/Foundational_Components/U-Boot/Applications
4546
linux/Foundational_Components/U-Boot/Apps-SPL-Debug-OpenOCD

source/linux/Foundational_Components/U-Boot/UG-PCIeBoot.rst

Lines changed: 203 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ To enable PCIe boot mode, configure the boot mode switches as follows:
3131
SW2 (B0 - B7): 1 1 0 1 0 1 1 0
3232
SW3 (B8 - B15): 0 0 0 0 0 0 0 0
3333
34+
.. ifconfig:: CONFIG_part_variant in ('J784S4')
35+
36+
.. code-block:: text
37+
38+
SW7: 0 1 0 1 0 0 0 0
39+
SW11: 1 0 0 0 1 0 0 0
40+
3441
.. note::
3542

3643
DIP switch settings are EVM-specific and may not apply to all board designs.
@@ -48,7 +55,7 @@ Both boards should be powered off before making the connection, and the PCIe lin
4855
securely established before powering on the devices.
4956

5057
Other hardware configurations are possible. So adapt the setup steps as
51-
applicable to your board design.
58+
applicable to given board design.
5259

5360
Endpoint Configuration
5461
----------------------
@@ -57,21 +64,21 @@ The following configuration options are used to set up the |__PART_FAMILY_NAME__
5764
as a PCIe endpoint for PCIe boot. These options must be set in the
5865
board's defconfig in U-BOOT for the corresponding boot loader image.
5966

60-
- ``CONFIG_PCI_DFU_BAR_SIZE``:
67+
- ``CONFIG_SPL_PCI_DFU_BAR_SIZE``:
6168
Configures the size of the PCIe BAR (Base Address Register) that is
6269
exposed for device firmware update (DFU) and boot loader image download.
6370

64-
- ``CONFIG_PCI_DFU_VENDOR_ID``:
71+
- ``CONFIG_SPL_PCI_DFU_VENDOR_ID``:
6572
Specifies the PCIe vendor ID to be advertised by the endpoint.
6673

67-
- ``CONFIG_PCI_DFU_DEVICE_ID``:
74+
- ``CONFIG_SPL_PCI_DFU_DEVICE_ID``:
6875
Specifies the PCIe device ID to be advertised by the endpoint.
6976

70-
- ``CONFIG_PCI_DFU_MAGIC_WORD``:
77+
- ``CONFIG_SPL_PCI_DFU_MAGIC_WORD``:
7178
Magic word written by the root complex at the end of the image transfer to
7279
signal to the endpoint that the boot loader image is ready for processing.
7380

74-
- ``CONFIG_PCI_DFU_BOOT_PHASE``:
81+
- ``CONFIG_SPL_PCI_DFU_BOOT_PHASE``:
7582
Specify the current boot phase when booting via DFU over PCIe.
7683
This value can be read by the root complex to determine the
7784
current boot phase. Value of this config is written to memory
@@ -89,36 +96,66 @@ board's defconfig in U-BOOT for the corresponding boot loader image.
8996
To enable endpoint mode, the boot loaders must be built with the
9097
device tree overlay ``k3-am642-evm-pcie0-ep.dtso``.
9198

99+
.. ifconfig:: CONFIG_part_variant in ('J784S4')
100+
101+
.. note::
102+
103+
All the configs required for PCIe boot are enabled in
104+
``j784s4_evm_a72_defconfig`` and ``j784s4_evm_r5_defconfig`` by default.
105+
106+
By default, PCIe root complex mode is enabled in the device tree.
107+
To enable endpoint mode, the boot loaders must be built with the
108+
device tree overlay ``k3-j784s4-evm-pcie0-pcie1-ep.dtso``.
109+
92110
Ensure these configuration options are set appropriately in the build
93111
environment to enable a successful PCIe boot process.
94112

95113
PCIe Boot Procedure
96114
-------------------
97115

116+
Before starting, compile the sample host program provided in the next section:
117+
118+
.. code-block:: bash
119+
120+
gcc -o pcie_boot_copy pcie_boot_copy.c
121+
98122
1. After configuring the boot mode switches on the endpoint and
99123
connecting it to the root complex as shown in the figure, power
100124
on the endpoint.
101125

102-
2. On the root complex, rescan the PCIe bus to enumerate the PCIe
103-
endpoint. The endpoint will appear as a RAM device on the root
104-
complex. The enumeration may look similar to the following:
126+
2. On the root complex, check the initial PCIe enumeration using ``lspci``:
127+
128+
.. code-block:: bash
129+
130+
lspci
131+
132+
The endpoint will appear as a RAM device or with many functions.
133+
The enumeration might look similar to the following:
105134

106135
.. code-block:: text
107136
108-
01:00.0 RAM memory: Texas Instruments Device b010
109-
Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx+
110-
Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
111-
Latency: 0
112-
Interrupt: pin A routed to IRQ 526
113-
Region 0: Memory at 68100000 (32-bit, non-prefetchable) [size=1M]
114-
Region 1: Memory at 68200000 (32-bit, prefetchable) [size=2M]
115-
Region 2: Memory at 6a000000 (64-bit, prefetchable) [size=32M]
116-
Region 4: Memory at 6c000000 (64-bit, prefetchable) [size=32M]
137+
0000:00:00.0 PCI bridge: Texas Instruments Device b012
138+
0000:01:00.0 RAM memory: Texas Instruments Device b012
139+
0000:01:00.1 Non-VGA unclassified device: Texas Instruments Device 0100
140+
0000:01:00.2 Non-VGA unclassified device: Texas Instruments Device 0100
117141
118-
3. Copy ``tiboot3.bin`` to Region 1.
142+
.. note::
143+
144+
The exact device IDs and number of functions may vary depending on the
145+
platform and boot stage.
146+
147+
3. Copy ``tiboot3.bin`` to the endpoint using the sample host program.
148+
Use ``lspci -vv`` to identify the BAR (Base Address Register) region
149+
to write to.
119150

120151
.. ifconfig:: CONFIG_part_variant in ('AM64X')
121152

153+
Example command to copy ``tiboot3.bin`` (assuming BAR address ``0x68200000``):
154+
155+
.. code-block:: bash
156+
157+
sudo ./pcie_boot_copy am64x 0x68200000 tiboot3.bin
158+
122159
After the root complex has finished copying the image,
123160
it must write the PCIe boot data address to ``0x701BCFE0``.
124161

@@ -127,31 +164,108 @@ PCIe Boot Procedure
127164
memory base + offset) to ``0x701BCFE0``. This notifies the ROM
128165
that the image is ready to be authenticated and processed.
129166

130-
4. Once ``tiboot3.bin`` is transferred, rescan the PCIe bus on the
131-
root complex to enumerate the PCIe endpoint device, in order to
132-
transfer the next stage boot loader. The enumeration may now look
133-
like the following:
167+
.. ifconfig:: CONFIG_part_variant in ('J784S4')
168+
169+
Example command to copy ``tiboot3.bin`` (assuming BAR address ``0x4007100000``):
170+
171+
.. code-block:: bash
172+
173+
sudo ./pcie_boot_copy j784s4 0x4007100000 tiboot3.bin
174+
175+
After the root complex has finished copying the image, the R5 ROM
176+
waits for two specific checks to continue the boot sequence:
177+
178+
- The root complex must write the start address (32-bit) of the image
179+
to address location ``0x41CF3FE0``.
180+
- The root complex must write the magic word ``0xB17CEAD9`` to address
181+
location ``0x41CF3FE4``.
182+
183+
These two writes signal to the ROM that the image has been fully copied
184+
and is ready to be authenticated and processed. The sample program handles
185+
these writes automatically.
186+
187+
4. Once the ``tiboot3.bin`` transfer is complete, the PCIe link will go down briefly.
188+
Scan the PCIe bus on the root complex again to enumerate the endpoint device
189+
for transferring the next stage boot loader:
190+
191+
.. code-block:: bash
192+
193+
echo 1 > /sys/bus/pci/devices/0000\:00\:00.0/rescan
194+
195+
Check the new enumeration with ``lspci``:
196+
197+
.. code-block:: bash
198+
199+
lspci
200+
201+
The enumeration will look similar to the following:
134202

135203
.. code-block:: text
136204
137-
0000:01:00.0 RAM memory: Texas Instruments Device b010
138-
Subsystem: Device 7003:beef
139-
Flags: bus master, fast devsel, latency 0, IRQ 644
140-
Memory at 12000000 (32-bit, prefetchable) [size=4M]
141-
Capabilities: [80] Power Management version 3
142-
Capabilities: [90] MSI: Enable+ Count=1/1 Maskable+ 64bit+
143-
Capabilities: [b0] MSI-X: Enable- Count=1 Masked-
144-
Capabilities: [c0] Express Endpoint, IntMsgNum 0
145-
Capabilities: [100] Advanced Error Reporting
205+
0000:00:00.0 PCI bridge: Texas Instruments Device b012
206+
0000:01:00.0 RAM memory: Texas Instruments Device b010 (rev dc)
207+
208+
Use ``lspci -vv`` to identify the new BAR address for the memory region.
146209

147210
5. At this stage, only one memory region will be visible. Copy
148-
``tispl.bin`` to this region. After the copy, the root complex
149-
must write a 4-byte magic word (defined in the defconfig) at the
150-
end of the memory region. This indicates to the endpoint that the
151-
boot loader image has been copied.
211+
``tispl.bin`` to this region using the sample host program.
212+
213+
.. ifconfig:: CONFIG_part_variant in ('J784S4')
214+
215+
Example command (assuming BAR address ``0x4000400000``):
216+
217+
.. code-block:: bash
218+
219+
sudo ./pcie_boot_copy j784s4 0x4000400000 tispl.bin
220+
221+
.. ifconfig:: CONFIG_part_variant in ('AM64X')
222+
223+
Example command (assuming BAR address ``0x12000000``):
224+
225+
.. code-block:: bash
226+
227+
sudo ./pcie_boot_copy am64x 0x12000000 tispl.bin
228+
229+
After the copy, the root complex must write a 4-byte magic word (defined
230+
in the defconfig) at the end of the memory region. This indicates to the
231+
endpoint that the host has copied the boot loader image. The sample program
232+
handles this automatically.
233+
234+
6. The PCIe link will go down again after the endpoint processes ``tispl.bin``.
235+
Remove and scan the PCIe device again to enumerate it for the final stage:
236+
237+
.. code-block:: bash
238+
239+
echo 1 > /sys/bus/pci/devices/0000\:01\:00.0/remove
240+
echo 1 > /sys/bus/pci/devices/0000\:00\:00.0/rescan
241+
242+
Copy ``u-boot.img`` using the same procedure as step 5.
243+
244+
.. ifconfig:: CONFIG_part_variant in ('J784S4')
245+
246+
Example command (assuming BAR address ``0x4000400000``):
247+
248+
.. code-block:: bash
249+
250+
sudo ./pcie_boot_copy j784s4 0x4000400000 u-boot.img
251+
252+
.. ifconfig:: CONFIG_part_variant in ('AM64X')
253+
254+
Example command (assuming BAR address ``0x12000000``):
255+
256+
.. code-block:: bash
257+
258+
sudo ./pcie_boot_copy am64x 0x12000000 u-boot.img
259+
260+
7. After ``u-boot.img`` is successfully loaded and executed, the boot process
261+
is complete and U-Boot should be running on the endpoint device.
262+
263+
.. note::
264+
265+
During the boot process, "PCIe LINK DOWN" messages might be displayed in the
266+
kernel logs. The endpoint resets and re-initializes the PCIe link after
267+
processing each boot stage, which is expected behavior.
152268

153-
6. Repeat steps 4 and 5 to transfer ``u-boot.img`` using the same
154-
procedure.
155269

156270
Sample Host Program for Image Transfer
157271
--------------------------------------
@@ -174,6 +288,7 @@ appropriate memory regions using ``/dev/mem``.
174288
int main(int argc, char *argv[])
175289
{
176290
char *bootfilename = NULL;
291+
char *platform = NULL;
177292
off_t bar1_address = 0;
178293
int fd;
179294
void *map_base;
@@ -183,23 +298,44 @@ appropriate memory regions using ``/dev/mem``.
183298
int i;
184299
FILE * fptr;
185300
off_t load_addr, load_addr_offset, start_addr_offset;
301+
unsigned int magic_word = 0;
302+
int use_magic_word = 0;
186303
187-
if (argc != 3) {
188-
printf("Usage: %s <bar_address> <binary_file>\n", argv[0]);
304+
if (argc != 4) {
305+
printf("Usage: %s <platform> <bar_address> <binary_file>\n", argv[0]);
306+
printf(" platform: am64x or j784s4\n");
189307
return 0;
190308
}
191309
192-
bar1_address = strtoul(argv[1], NULL, 16);
193-
bootfilename = argv[2];
310+
platform = argv[1];
311+
bar1_address = strtoul(argv[2], NULL, 16);
312+
bootfilename = argv[3];
194313
314+
printf("platform: %s\n", platform);
195315
printf("bootfilename: %s\n", bootfilename);
196316
printf("bar1_address: 0x%lx\n", bar1_address);
197317
198318
if(!strcmp(bootfilename,"tiboot3.bin"))
199319
{
200-
load_addr = 0x70000000;
201-
load_addr_offset = 0x1000;
202-
start_addr_offset = 0x1bcfe0;
320+
if(!strcmp(platform, "am64x"))
321+
{
322+
load_addr = 0x70000000;
323+
load_addr_offset = 0x1000;
324+
start_addr_offset = 0x1bcfe0;
325+
}
326+
else if(!strcmp(platform, "j784s4"))
327+
{
328+
load_addr = 0x41C00000;
329+
load_addr_offset = 0x00;
330+
start_addr_offset = 0xf3fe0;
331+
magic_word = 0xB17CEAD9;
332+
use_magic_word = 1;
333+
}
334+
else
335+
{
336+
printf("Unsupported platform: %s\n", platform);
337+
return 0;
338+
}
203339
}
204340
else
205341
{
@@ -211,6 +347,8 @@ appropriate memory regions using ``/dev/mem``.
211347
printf("load_addr: 0x%lx\n", load_addr);
212348
printf("load_addr_offset: 0x%lx\n", load_addr_offset);
213349
printf("start_addr_offset: 0x%lx\n", start_addr_offset);
350+
if (use_magic_word)
351+
printf("magic_word: 0x%x\n", magic_word);
214352
215353
printf("try to open /dev/mem.\n");
216354
fd = open("/dev/mem", O_RDWR | O_SYNC);
@@ -268,18 +406,34 @@ appropriate memory regions using ``/dev/mem``.
268406
sleep(1);
269407
270408
*(unsigned int *)(map_base + start_addr_offset) = (unsigned int)(load_addr_offset + load_addr);
409+
410+
// Write magic word for J784S4 at R5 stage
411+
if(use_magic_word)
412+
{
413+
*(unsigned int *)(map_base + start_addr_offset + 4) = magic_word;
414+
printf("Magic word written.\n");
415+
}
416+
271417
return 0;
272418
}
273419
274420
Usage Example
275421
^^^^^^^^^^^^^
276422

277423
To copy a boot loader file (e.g., ``tiboot3.bin``) to the PCIe device,
278-
run:
424+
specify the platform, BAR address, and binary file.
425+
426+
For AM64X:
427+
428+
.. code-block:: bash
429+
430+
sudo ./pcie_boot_copy am64x 0x68200000 tiboot3.bin
431+
432+
For J784S4:
279433

280434
.. code-block:: bash
281435
282-
sudo ./pcie_boot_copy 0x68200000 tiboot3.bin
436+
sudo ./pcie_boot_copy j784s4 0x12000000 tiboot3.bin
283437
284-
Replace ``0x68200000`` with the appropriate BAR region address as
285-
enumerated on the root complex, and specify the correct binary file.
438+
Replace the BAR address with the appropriate BAR region address as
439+
enumerated on the root complex for specific setup.

0 commit comments

Comments
 (0)