Browse Source

user-doc: add instructions to build, flash and configure the TBM firmware.

S.J.R. van Schaik 4 years ago
parent
commit
72af764348
1 changed files with 153 additions and 0 deletions
  1. 153 0
      user-doc/user-doc.tex

+ 153 - 0
user-doc/user-doc.tex

@@ -386,4 +386,157 @@ At some point the kernel will run the init script in the initramfs.
386 386
 When this happens the ROTS will start communicating with the TBM to fetch the time as well as the certificates.
387 387
 Once these have been retrieved from the TBM, the ROTS will mount the external media such as hard disks and enumerate and verify possible boot images on those media.
388 388
 
389
+\section{Trusted Boot Module}
390
+
391
+In this section the process of building, flashing and configuring the firmware for the TBM is described.
392
+
393
+\subsection{Building}
394
+
395
+A cross-compiler targetting ARMv6 or ARMv7-M such as the GNU ARM Embedded Toolchain is required to build the source code for the Trusted Boot Module.
396
+Either install it using your package manager or download the toolchain from https://developer.arm.com/open-source/gnu-toolchain/gnu-rm.
397
+For Gentoo users, an ebuild is available in the tbm-overlay repository.
398
+Building your own cross-compiler using a tool like crossdev can be quite tricky, and is therefore discouraged.
399
+
400
+To build the source code in this repository, you will also need libopencm3.
401
+Download the source code for libopencm3 and build it as follows:
402
+
403
+\begin{minted}[breaklines]{text}
404
+git submodule init
405
+git submodule update
406
+make -C libopencm3
407
+\end{minted}
408
+
409
+To build the code for the Trusted Boot Module, run:
410
+
411
+\begin{minted}[breaklines]{text}
412
+TARGET=stm32f1 make
413
+\end{minted}
414
+
415
+\subsection{Flashing}
416
+
417
+Connect your computer with a JTAG device and connect the I/O, CLK, GND and VDD wires with the SWD pin-out of the TBM.
418
+Run the following as root:
419
+
420
+\begin{minted}[breaklines]{text}
421
+TARGET=stm32f1 make openocd
422
+\end{minted}
423
+
424
+If OpenOCD, the JTAG device and the TBM are functioning correctly, OpenOCD should report the available breakpoint registers.
425
+To flash the firmware onto the device, run the following command:
426
+
427
+\begin{minted}[breaklines]{text}
428
+TARGET=stm32f1 make run
429
+\end{minted}
430
+
431
+Close OpenOCD and disconnect the power from the TBM, then detach the I/O and CLK wires.
432
+
433
+\subsection{Configuration}
434
+
435
+Download the source code for gorots and build the admin utility as follows:
436
+
437
+\begin{minted}[breaklines]{text}
438
+go build
439
+\end{minted}
440
+
441
+Attach a serial cable to the debugging serial interface of the TBM.
442
+Power on the TBM using an external power source such as a JTAG adapter.
443
+Run the {\tt prepare.sh} script to perform an initial configuration of the TBM.
444
+This script will also perform tests to ensure the hardware is functioning as expected.
445
+
446
+\section{Using gorots}
447
+
448
+The gorots package consists of two tools: {\tt admin} and {\tt protocol}.
449
+The {\tt protocol} utility is used by the ROTS to communicate with the user serial interface.
450
+The {\tt admin} utility is used with the admin serial interface of the TBM to configure it.
451
+
452
+The following commands are available for the {\tt admin} utility:
453
+
454
+\begin{itemize}
455
+\item {\tt ./admin echo <string>}
456
+
457
+Returns the string passed as an argument to echo.
458
+\item {\tt ./admin flash\_probe}
459
+
460
+Mounts the SPI NOR flash device as a raw device.
461
+\item {\tt ./admin flash\_erase <offset> <length>}
462
+
463
+Erases the region provided by the offset and the length in blocks.
464
+
465
+\item {\tt ./admin ftl\_probe}
466
+
467
+Mounts the SPI NOR flash device and initialises the Flash Translation Layer.
468
+
469
+\item {\tt ./admin date}
470
+
471
+Returns the current time formatted as a human-readable date.
472
+
473
+\item {\tt ./admin time}
474
+
475
+Returns the current time in seconds since the UNIX epoch.
476
+
477
+\item {\tt ./admin set-time <seconds>}
478
+
479
+Sets the current time to the given time in seconds since the UNIX epoch.
480
+
481
+\item {\tt ./admin sync-time }
482
+
483
+Synchronizes the current time of the TBM with the current time of the host device
484
+		
485
+		\item {\tt ./admin set-time <seconds>}
486
+			
487
+		Sets the current time to the given time in seconds since the UNIX epoch.
488
+		
489
+\item {\tt ./admin sync-time }
490
+
491
+Synchronizes the current time of the TBM with the current time of the host device.
492
+
493
+\item {\tt ./admin mount }
494
+
495
+Mounts the filesystem on the flash device.
496
+
497
+\item {\tt ./admin umount}
498
+
499
+Unmounts the currently mounted filesystem.
500
+
501
+\item {\tt ./admin format}
502
+
503
+Formats the filesystem of the flash device.
504
+
505
+\item {\tt ./admin mkdir <path>}
506
+
507
+Creates a directory at the given path, if the path does not yet exist and if the parent is a directory.
508
+
509
+\item {\tt ./admin rmdir <path>}
510
+
511
+Removes the directory at the given path, if the path exists and points to a directory.
512
+
513
+\item {\tt ./admin ls <path>}
514
+
515
+Lists the files in the given path, if the path exists and points to a directory.
516
+
517
+\item {\tt ./admin cat <path>}
518
+
519
+Concatenates the file with the standard output.
520
+
521
+\item {\tt ./admin write <path> <file>}
522
+
523
+Writes the contents of the file to the file at the given path. Creates a new file if the path does not point to an existing file. Otherwise the file will be truncated first.
524
+
525
+\item {\tt ./admin append <path> <file>}
526
+
527
+Appends the contents of the file to the file at the given path. Creates a new file if the path does not point to an existing file.
528
+
529
+\item {\tt ./admin mv <old> <new>}
530
+
531
+Moves the file or directory from the old path to the new path.
532
+
533
+\item {\tt ./admin cp <old> <new>}
534
+
535
+Copies the contents of the file from the old path to the file pointed to by the new path. Creates a file at the new path if it does not exist yet. Otherwise the file is truncated before copying the contents.
536
+
537
+\item {\tt ./admin rm <path>}
538
+
539
+Removes the file at the given path, if the path exists and points to a file.
540
+\end{itemize}
541
+
389 542
 \end{document}