1# **EDK II firmware for Intel(R) Quark SoC X1000 based platforms**
2
3## **Features**
4* UEFI firmware image with ability to enable/disable major features such as
5    - Logging
6    - Source level debug using [Intel(R) UEFI Development Kit Debugger Tool](
7      https://firmware.intel.com/develop/intel-uefi-tools-and-utilities/intel-uefi-development-kit-debugger-tool)
8    - Boot Performance Measurements
9    - UEFI Secure Boot with Physical Presence
10    - TCG Measured Boot using TPM 1.2 hardware devices on I2C bus
11* Minimal firmware image for initial power-on and debug
12* UEFI Shell built into FLASH image
13* UEFI Linux operating system boot support from Micro SD FLASH
14* Hardware Support
15    -  [Intel(R) Quark SoC X1000 CPU](
16       http://www.intel.com/content/www/us/en/embedded/products/quark/quark-x1000-datasheet.html)
17    -  [Intel(R) Galileo Development Board](
18       http://www.intel.com/content/www/us/en/embedded/products/galileo/galileo-g1-datasheet.html)
19    -  [Intel(R) Galileo Gen 2 Development Board](
20       http://www.intel.com/content/www/us/en/embedded/products/galileo/galileo-overview.html)
21    -  HPET Timer
22    -  Real Time Clock
23* Major I/O Subsystems
24    - PCI including support for Mini PCI Express Cards
25    - USB using EHCI and OHCI host controllers
26    - Micro SD FLASH with FAT file system support
27    - Serial UART up to 921600 baud for console, logging, and debug
28* ACPI Tables with ACPI S3 sleep state support
29* SMBIOS Tables
30
31## **Windows Build Instructions**
32
33### Pre-requisites
34
35* GIT client: Available from https://git-scm.com/downloads
36* Microsoft Visual Studio.
37  - Visual Studio 2015 recommended and is used in the examples below.
38* Microsoft Windows Driver Development Kit 3790.1830
39  - http://download.microsoft.com/download/9/0/f/90f019ac-8243-48d3-91cf-81fc4093ecfd/1830_usa_ddk.iso
40  - Mount ISO image
41  - Right click on ```x86\kitsetup.exe``` & choose **Run as administrator**
42  - Install to C:\WINDDK\3790.1830
43  - Uncheck all Component Groups
44  - Expand Build Environment Component
45  - Check Windows Driver Development Kit 16-bit Additional Build Tools
46  - Install
47* ASL compiler: Available from http://www.acpica.org
48  - Install into ```C:\ASL``` to match default tools_def.txt configuration.
49
50Create a new directory for an EDK II WORKSPACE.
51
52The code block below shows the GIT clone operations required to pull the EDK II
53source tree, the FatPkg sources, the pre-built versions of BaseTools as WIN32
54binaries, and the edk2-non-osi repository that provides a binary file for the
55Quark Remote Management Unit (RMU).
56
57Next it sets environment variables that must be set before running
58```edksetup.bat```. Since content is being pulled from multiple repositories,
59the EDK II [Multiple Workspace](
60https://github.com/tianocore/tianocore.github.io/wiki/Multiple_Workspace)
61feature is used.
62
63Next, the ```edksetup.bat``` file is run to complete the initialization of an
64EDK II build environment.  Two example build commands are shown.  The first one
65in ```QuarkPlatformPlg/Quark.dsc``` builds a full UEFI firmware image that is
66able to boot the built-in UEFI Shell and Linux from a micro SD FLASH card.  The
67second one in ```QuarkPlatformPkg/QuarkMin.dsc``` builds a minimal firmware
68image that is useful for initial power-on and debug of new features.
69
70```cmd
71git clone https://github.com/tianocore/edk2.git
72git clone https://github.com/tianocore/edk2-FatPkg.git FatPkg
73git clone https://github.com/tianocore/edk2-BaseTools-win32.git
74git clone https://github.com/tianocore/edk2-non-osi.git
75
76set WORKSPACE=%CD%
77set PACKAGES_PATH=%WORKSPACE%\edk2;%WORKSPACE%\edk2-non-osi
78set EDK_TOOLS_BIN=%WORKSPACE%\edk2-BaseTools-win32
79
80cd edk2
81edksetup.bat
82
83build -a IA32 -t VS2015x86 -p QuarkPlatformPkg/Quark.dsc
84build -a IA32 -t VS2015x86 -p QuarkPlatformPkg/QuarkMin.dsc
85```
86
87## **Linux Build Instructions**
88
89### Pre-requisites
90
91* GIT client
92* GCC 4.9 compiler
93* ASL compiler: Available from http://www.acpica.org.
94
95Create a new directory for an EDK II WORKSPACE.
96
97The code block below shows the GIT clone operations required to pull the EDK II
98source tree, the FatPkg sources, and the edk2-non-osi repository that provides a
99binary file for the Quark Remote Management Unit (RMU).
100
101Next it sets environment variables that must be set before running
102```edksetup.bat```. Since content is being pulled from multiple repositories,
103the EDK II [Multiple Workspace](
104https://github.com/tianocore/tianocore.github.io/wiki/Multiple_Workspace)
105feature is used.
106
107Next, the EDK II BaseTools required to build firmware images are built.
108
109Next, the ```edksetup.bat``` file is run to complete the initialization of an
110EDK II build environment.  Two example build commands are shown.  The first one
111in ```QuarkPlatformPlg/Quark.dsc``` builds a full UEFI firmware image that is
112able to boot the built-in UEFI Shell and Linux from a micro SD FLASH card.  The
113second one in ```QuarkPlatformPkg/QuarkMin.dsc``` builds a minimal firmware
114image that is useful for initial power-on and debug of new features.
115
116```sh
117git clone https://github.com/tianocore/edk2.git
118git clone https://github.com/tianocore/edk2-FatPkg.git FatPkg
119git clone https://github.com/tianocore/edk2-non-osi.git
120
121export WORKSPACE=$PWD
122export PACKAGES_PATH=$WORKSPACE/edk2:$WORKSPACE/edk2-non-osi
123export EDK_TOOLS_PATH=$WORKSPACE/edk2/BaseTools
124
125make -C edk2/BaseTools
126
127cd $WORKSPACE/edk2
128
129. edksetup.sh BaseTools
130
131build -a IA32 -t GCC49 -p QuarkPlatformPkg/Quark.dsc
132build -a IA32 -t GCC49 -p QuarkPlatformPkg/QuarkMin.dsc
133```
134
135## **Build Features**
136
137The table below contains a summary of the build flags to enable or disable
138features on the build command line using ```-D``` flags.
139
140| **Define Name**            | **Default Value** | **Supported Values** |
141| -------------------------- | ----------------- | -------------------- |
142| ```GALILEO```              |              GEN2 | GEN1, GEN2           |
143| ```LOGGING```              |              TRUE | TRUE, FALSE          |
144| ```SOURCE_DEBUG_ENABLE```  |             FALSE | TRUE, FALSE          |
145| ```PERFORMANCE_ENABLE```   |             FALSE | TRUE, FALSE          |
146| ```SECURE_BOOT_ENABLE```   |             FALSE | TRUE, FALSE          |
147| ```MEASURED_BOOT_ENABLE``` |             FALSE | TRUE, FALSE          |
148| ```TPM_12_HARDWARE```      |              NONE | NONE, LPC, ATMEL_I2C, INFINEON_I2C |
149| ```CAPSULE_ENABLE```       |             FALSE | TRUE, FALSE          |
150| ```RECOVERY_ENABLE```      |             FALSE | TRUE, FALSE          |
151
152* ```GALILEO``` - Used to specify the type of Intel(R) Galileo board type.  The
153  default is ```GEN2``` for the [Intel(R) Galileo Gen 2 Development Board](
154  http://www.intel.com/content/www/us/en/embedded/products/galileo/galileo-overview.html).
155  The other supported value is ```GEN1``` for the [Intel(R) Galileo Development Board](
156  http://www.intel.com/content/www/us/en/embedded/products/galileo/galileo-g1-datasheet.html).
157  Add ```-D GALILEO=GEN1``` to the build command for [Intel(R) Galileo Development Board](
158  http://www.intel.com/content/www/us/en/embedded/products/galileo/galileo-g1-datasheet.html).
159
160* ```LOGGING``` - Used to enable/disable logging messages from DEBUG() macros to
161  a serial UART.  The default is TRUE for enabled when the BUILDTARGET is DEBUG
162  (```-b DEBUG```).  The default is FALSE for disabled when the BUILDTARGET is
163  not DEBUG (e.g. ```-b RELEASE```).  Add ```-D LOGGING``` to the build command
164  to force logging enabled.  Add ```-D LOGGING=FALSE``` to force logging
165  disabled.
166
167* ```SOURCE_DEBUG_ENABLE``` - Used to enable/disable source level debug using the
168  [Intel(R) UEFI Development Kit Debugger Tool](
169  https://firmware.intel.com/develop/intel-uefi-tools-and-utilities/intel-uefi-development-kit-debugger-tool).
170  The default is FALSE for disabled.  Add ```-D SOURCE_DEBUG_ENABLE``` to the
171  build command line to enable source level debug.
172
173* ```PERFORMANCE_ENABLE``` - Used to enable/disable boot performance measurement.
174  The default is FALSE for disabled.  Add ```-D PERFORMANCE_ENABLE``` to the
175  build command line to enable boot performance measurement.  When this feature
176  is enabled, both ```LOGGING``` and ```SOURCE_DEBUG_ENABLE``` are automatically
177  disabled so there is not boot time overhead from the serial UART for logging
178  messages or the debug agent.
179
180* ```SECURE_BOOT_ENABLE``` - Used to enable/disable UEFI Secure Boot features.
181  The default is FALSE for disabled.  Add ```-D SECURE_BOOT_ENABLE``` to the
182  build command line to enable UEFI Secure Boot features.
183
184* ```MEASURED_BOOT_ENABLE``` - Used to enable/disable measurement of firmware
185  code and data into a TPM 1.2 hardware device.  The default is FALSE for
186  disabled.  Add ```-D MEASURED_BOOT_ENABLE``` to the build command line to
187  enable UEFI Secure Boot features.
188
189* ```TPM_12_HARDWARE``` - Used to specify the type of TPM 1.2 hardware device
190  that is connected to the Galileo board.  This define is valid if the measure
191  boot feature is enabled using ```-D MEASURED_BOOT_ENABLE```.  The default is
192  NONE for no TPM 1.2 hardware device connected.  Add ```-D TPM_12_HARDWARE=LPC```
193  for a TPM hardware device attached to an LPC bus (not supported on on Intel(R)
194  Quark SoC X1000).  Add ```-D TPM_12_HARDWARE=ATMEL_I2C``` for an
195  [Atmel AT97SC3204T](http://www.atmel.com/devices/AT97SC3204T.aspx) or
196  [Atmel AT97SC3205T](http://www.atmel.com/images/atmel-8883s-tpm-at97sc3205t-datasheet-summary.pdf)
197  attached to the I2C bus of the Galileo Arduino header.  Add
198  ```-D TPM_12_HARDWARE=INFINION_I2C``` for an [Infineon SLB9645](
199  http://www.infineon.com/dgdl/Infineon-TPM+SLB+9645-DS-v01_00-EN.pdf?fileId=5546d4625185e0e201518b83d0c63d7c)
200  attached to the I2C bus of the Galileo Arduino header.  The ATMEL_I2C setting
201  has been tested with the [CryptoShield](https://www.sparkfun.com/products/13183)
202  available from [SparkFun](https://www.sparkfun.com/).
203
204* ```CAPSULE_ENABLE``` - Used to enable/disable capsule update features.
205  The default is FALSE for disabled.  Add ```-D CAPSULE_ENABLE``` to the
206  build command line to enable capsule update features.
207  The build process generate capsule update image - QUARKFIRMWAREUPDATECAPSULEFMPPKCS7.Cap.
208  The user need copy QUARKFIRMWAREUPDATECAPSULEFMPPKCS7.Cap and CapsuleApp.efi
209  to a storage media attached to the Quark Board.
210  Then the user can boot to shell and run ```CapsuleApp QUARKFIRMWAREUPDATECAPSULEFMPPKCS7.Cap```.
211  In next reboot, the system firmware is updated.
212
213* ```RECOVERY_ENABLE``` - Used to enable/disable recovery features.
214  The default is FALSE for disabled.  Add ```-D RECOVERY_ENABLE``` to the
215  build command line to enable recovery features.
216  The build process generates the recovery capsule image - QUARKREC.Cap.
217  Then the user need copy QUARKREC.Cap to a USB KEY, plug the USB KEY to the Quark Board.
218  In next boot, if a user runs ForceRecovery.efi in shell, or if a user presses the RESET button during power on, warm reset or REBOOT,
219  or if the FvMain is corrupted in flash, the system will boot into recovery mode.
220
221### **Example Build Commands**
222
223Default build with logging enabled:
224
225```build -a IA32 -t VS2015x86 -p QuarkPlatformPkg/Quark.dsc```
226
227Release build with logging disabled:
228
229```build -a IA32 -t VS2015x86 -p QuarkPlatformPkg/Quark.dsc -b RELEASE```
230
231Enable source level debugging:
232
233```build -a IA32 -t VS2015x86 -p QuarkPlatformPkg/Quark.dsc -D SOURCE_DEBUG_ENABLE```
234
235Enable boot performance metrics:
236
237```build -a IA32 -t VS2015x86 -p QuarkPlatformPkg/Quark.dsc -D PERFORMANCE_ENABLE```
238
239Enable UEFI Secure Boot features:
240
241```build -a IA32 -t VS2015x86 -p QuarkPlatformPkg/Quark.dsc -D UEFI_SECURE_BOOT```
242
243Enable UEFI Secure Boot and Measured Boot using Atmel I2C TPM hardware device:
244
245```build -a IA32 -t VS2015x86 -p QuarkPlatformPkg/Quark.dsc -D UEFI_SECURE_BOOT
246-D MEASURED_BOOT_ENABLE -D TPM_12_HARDWARE=ATMEL_I2C```
247
248## **FLASH Update using DediProg SF100**
249
250Once the sources have been downloaded, an EDK II build environment established,
251and an EDK II firmware image has been built, the EDK II firmware image needs to
252installed into the FLASH device on the target Galileo development board.  One
253way to do this is with the [Dediprog SF100 IC Programmer](
254http://www.dediprog.com/pd/spi-flash-solution/SF100).
255
256* Install the DediProg SF100 software.
257
258* Connect the DediProg SF100 to the Galileo development board.
259
260    ![](https://github.com/tianocore/tianocore.github.io/wiki/Projects/QuarkPlatformPkg/Images/Dediprog.jpg)
261
262* Make sure ```dpcmd.exe``` is in ```PATH```
263
264  ```PATH=%PATH%;"c:\Program Files (x86)\DediProg\SF100"```
265
266* **NOTE**: It is recommended that the FLASH image that was shipped with the
267  Galileo development board be read and saved before updating FLASH image.  The
268  command shown below read the FLASH image and saves it to the file
269  called ```GalileoOriginalFirmware.bin```.
270
271  ```dpcmd.exe -r GalileoOriginalFirmware.bin```
272
273* Update FLASH image using either the DediProg SF100 GUI or ```dpcmd.exe```.
274  - Example update of Galileo firmware image when BUILDTARGET is DEBUG (default)
275
276    ```dpcmd.exe -u%WORKSPACE%\Build\Quark\DEBUG_VS2015x86\FV\QUARK.fd ```
277
278  - Example update of Galileo firmware image when BUILDTARGET is RELEASE
279    (```-b RELEASE```)
280
281    ```dpcmd.exe -u%WORKSPACE%\Build\Quark\RELEASE_VS2015x86\FV\QUARK.fd ```
282
283## **Setting up a Serial Console and Booting to UEFI Shell**
284
285After the FLASH is updated on Galileo, a serial cable is connected between the
286host system and the Galileo target.  A serial terminal emulator (such as
287[Tera Term](https://en.osdn.jp/projects/ttssh2/releases/)) can be used to see
288the logging messages from DEBUG() macros and the serial console for the UEFI
289Boot Manager, UEFI Shell, and operating system.
290
291The default serial communication parameters for the Intel(R) Galileo Gen 2
292Development Board is 921600,n,8,1 with no hardware flow control.
293
294![](https://github.com/tianocore/tianocore.github.io/wiki/Projects/QuarkPlatformPkg/Images/TeraTermSerialParameters.png)
295
296The default serial communication parameters for the Intel(R) Galileo Development
297Board is 461800,n,8,1 with no hardware flow control.
298
299The following changes to the [Tera Term](https://en.osdn.jp/projects/ttssh2/releases/)
300configuration files are recommended for UEFI serial console compatibility.
301Some of the later use cases involve using the TCPIP mode, so some of these
302recommendation apply to the TCPIP use cases.
303
304* TERATERM.INI - Set terminal size to 80 x 25 and terminal settings to UTF8.
305
306![](https://github.com/tianocore/tianocore.github.io/wiki/Projects/QuarkPlatformPkg/Images/TeraTermTerminal.png)
307
308* TERATERM.INI - Set font type to Terminal to support box drawing glyphs.
309
310![](https://github.com/tianocore/tianocore.github.io/wiki/Projects/QuarkPlatformPkg/Images/TeraTermFont.png)
311
312* TERATERM.INI - Disable line mode to make TCPIP mode work like COM port mode.
313
314```ini
315; Line at a time mode
316EnableLineMode=off
317```
318
319* KEYBOARD.CNF - Disable VT function keys for F5..F10
320
321```ini
322[VT function keys]
323;F6 key
324;F6=64
325;F7 key
326;F7=65
327;F8 key
328;F8=66
329;F9 key
330;F9=67
331;F10 key
332;F10=68
333```
334
335* KEYBOARD.CNF - Disable X function keys for F1..F4
336
337```ini
338[X function keys]
339; F1 key
340XF1=off
341; F2 key
342;XF2=60
343XF2=off
344; F3 key
345;XF3=61
346XF3=off
347; F4 key
348;XF4=62
349XF4=off
350; F5 key
351;XF5=63
352```
353
354* KEYBOARD.CNF - Add UEFI serial console sequences for F1..F10
355
356```ini
357[User keys]
358User1=59,0,$1B[M
359User2=60,0,$1B[N
360User3=61,0,$1B[O
361User4=62,0,$1B[P
362User5=63,0,$1B[Q
363User6=64,0,$1B[R
364User7=65,0,$1B[S
365User8=66,0,$1B[T
366User9=67,0,$1B[U
367User10=68,0,$1B[V
368```
369
370Connect power adapter to Galileo development board, and the logging messages
371should be seen, followed by 5 second countdown, followed by an automatic boot to
372the built-in UEFI Shell.
373
374![](https://github.com/tianocore/tianocore.github.io/wiki/Projects/QuarkPlatformPkg/Images/UefiShell.png)
375
376## **Source Level Debug Using Intel(R) UEFI Development Kit Debugger Tool**
377
378### Pre-requisites
379
380* Intel(R) UEFI Development Kit Debugger Tool User Manual for Ver 1.5 or higher:
381  Available from https://firmware.intel.com/develop/intel-uefi-tools-and-utilities/intel-uefi-development-kit-debugger-tool
382* Intel(R) UEFI Development Kit Debugger Tool Ver 1.5 or higher: Available from
383  https://firmware.intel.com/develop/intel-uefi-tools-and-utilities/intel-uefi-development-kit-debugger-tool
384* [Tera Term](https://en.osdn.jp/projects/ttssh2/releases/) or other serial
385  terminal emulator with TCPIP support
386
387Follow instructions in Intel(R) UEFI Development Kit Debugger Tool User manual
388to setup host system.
389
390Build a firmware image with SOURCE_DEBUG_ENABLE enabled
391(```-D SOURCE_DEBUG_ENABLE```).  This will select the appropriate libraries,
392debug agent, and PCDs for Galileo.  Galileo does not support a USB 2.0 debug
393port, so only the UART based communications library is used.
394
395Use Dediprog SF100 to update the Galileo development board FLASH image.
396
397Update the ```[Debug Port]``` section of the SoftDebugger.ini file with the host
398side UART configuration settings.  The following example uses COM5, which must
399be updated with the COM port the Galileo target is attached.  The following
400example also shows a baud rate of 921600 which is correct for a Galileo Gen 2.
401If a Galileo Gen 1 is being used, set the baud rate to 460800.  By default, the
402Galileo console is redirected to TCPIP port 20715.
403
404```ini
405[Debug Port]
406Channel = Serial
407Port = COM5
408FlowControl = 0
409BaudRate = 921600
410Server =
411```
412
413Connect power adapter to Galileo development board and run a command script with
414the contents below to start a Tera Term session on TCPIP port 20715 and start
415the Intel(R) UEFI Development Kit Debugger Tool using UART connection between
416the host and target and WinDbg.  The REBOOT button on the Galileo development
417board may need to be pressed for the debugger to perform the initial connect.
418
419```cmd
420start "Console" /B "c:\Program Files (x86)\teraterm\ttermpro.exe" localhost:20715 /nossh
421start "Debugger" /B "C:\Program Files (x86)\Intel\Intel(R) UEFI Development Kit Debugger Tool\eXdi.exe" /LaunchWinDbg
422```
423
424The figure below should be seen when a connection is made.  The SoftDebugger
425Debug Console window shows the status of the connection between the host and the
426target.  The Tera Term window shows the console output from the SEC phase until
427the debug agent is initialized.  The WinDbg window shows that the debugger is
428connected and the WinDbg application can be used for run control, breakpoint
429management, and viewing call stacks, local variables,  global variables, etc.
430
431![](https://github.com/tianocore/tianocore.github.io/wiki/Projects/QuarkPlatformPkg/Images/UdkDebugger.png)
432
433## **Debug Using Intel(R) System Debugger using OpenOCD**
434
435Setup hardware and software components following the instructions in the article at:
436https://software.intel.com/en-us/articles/using-intel-system-debugger-with-openocd
437
438Connect power adapter to Galileo development board.
439
440The following batch file starts Tera Term serial console on COM5 at 921600 baud,
441starts OpenOCD using a Flyswatter2, and starts Intel(R) System Studio Debugger.
442Select the **Connect** button to complete the host to target connection.
443
444```cmd
445set OPENOCD="C:\Program Files (x86)\IntelSWTools\system_studio_for_windows_2016.0.023\debugger\openocd"
446start "Console" /B "c:\Program Files (x86)\teraterm\ttermpro.exe" /C=5 /BAUD=921600
447start "OpenOcd" /B %OPENOCD%\bin\openocd.exe -f ..\scripts\interface\ftdi\flyswatter2.cfg -f ..\scripts\board\quark_x10xx_board.cfg
448call "C:\Program Files (x86)\IntelSWTools\System Debugger 2016\system_debugger\start_xdb_gdb_remote.bat"
449```
450
451When **Reset Target** is selected, the Galileo development board does not always
452halt at the first instruction at the reset vector.  If debug is required from
453the first instruction of the reset vector, then update the file
454```UefiCpuPkg/SecCore/Ia32/ResetVector.asm``` and change the two NOP
455instructions at the label ```ResetHandler:``` to ```JMP $```.  This puts the CPU
456into a wait loop until the debugger is connected and the debugger is used to set
457instruction pointer to the next instruction.
458
459```
460;
461; For IA32, the reset vector must be at 0xFFFFFFF0, i.e., 4G-16 byte
462; Execution starts here upon power-on/platform-reset.
463;
464ResetHandler:
465;    nop
466;    nop
467    jmp $
468ApStartup:
469    ;
470    ; Jmp Rel16 instruction
471    ; Use machine code directly in case of the assembler optimization
472    ; SEC entry point relative address will be fixed up by some build tool.
473    ;
474    ; Typically, SEC entry point is the function _ModuleEntryPoint() defined in
475    ; SecEntry.asm
476    ;
477    DB      0e9h
478    DW      -3
479```
480
481## **Install, Configure, and Boot Linux**
482
483* Download SD Card Linux Image: Available at
484  http://www.intel.com/content/www/us/en/support/boards-and-kits/intel-galileo-boards/000005614.html
485* Extract the SD Card Linux Image to a FAT formatted Micro SD FLASH device
486* Install Micro SD FLASH device into Galileo development board
487
488Connect power adapter to Galileo development board and boot to the UEFI Shell.
489
490From the UEFI Shell execute the following commands to copy the GRUB EFI boot
491loader to ```\efi\boot\bootia32.efi```.  This allows the UEFI Boot Manager, on
492all future boots, to auto detect that the Micro SD FLASH device is bootable.
493
494```
495Shell> connect -r
496Shell> map -r
497Shell> fs0:
498FS0:> mkdir efi
499FS0:> mkdir efi\boot
500FS0:> cp grub.efi efi\boot\bootia32.efi
501```
502
503The GRUB boot loader is set to a UART baud rate of 115200.  A couple changes are
504required to change the baud rate to 460800 for Galileo Gen 1 or 921600 for
505Galileo Gen 2.  From the UEFI Shell, execute the following commands to make a
506backup copy and edit the GRUB configuration file.
507
508```
509FS0:> cp boot\grub\grub.conf boot\grub\grub.conf.org
510FS0:> edit boot\grub\grub.conf
511```
512
513* Delete the lines associated with the boot option with the following title.
514
515```
516title Clanton SVP kernel-SPI initrd-SPI IMR-On IO-APIC/HPET NoEMU
517```
518
519* Replace the two instances of 115200 in the following line to 460800 for
520  Galileo Gen 1 or 921600 for Galileo Gen 2.
521
522```
523kernel /bzImage root=/dev/ram0 console=ttyS1,115200n8 earlycon=uart8250,mmio32,$EARLY_CON_ADDR_REPLACE,115200n8 reboot=efi,warm apic=debug rw LABEL=boot debugshell=5 rootimage=image-full-galileo-clanton.ext3
524```
525* Press F3 to save the file
526* Run the ```exit``` command to exit from the UEFI Shell and return to the
527  UEFI Boot Manager
528* Select **Boot Manager**
529* Select **UEFI Misc Device** for the Micro SD FLASH device.
530* GRUB should run and Linux should boot with serial log messages.
531* When the serial log messages stop, change the Tera Term baud rate to 115200
532* Login as ```root```.   No password is required.
533* Use ```vi``` to edit ```/etc/inittab```
534* Change the baud rate of ttyS1 from 115200 to 460800 for Galileo Gen 1 or
535  921600 for Galileo Gen 2.  The line that need to be updated is shown below
536
537```
538S:2345:respawn:/sbin/getty 115200 ttyS1
539```
540
541* Save the updated ```/etc/inittab```
542* Run ```reboot -f``` to shutdown Linux and reboot the platform.
543* Set the Tera Term baud rate back to 460800 for Galileo Gen 1 or 921600 for
544  Galileo Gen 2.
545
546After these changes both the EDK II firmware and the Linux operating system use
547the same baud rate.
548
549### **Testing ACPI S3 Sleep**
550
551The ACPI S3 Sleep and Resume feature can be tested on a Galileo development
552board using the Real Time Clock (RTC) for a wake event.  The shell script shown
553below arms the RTC wake alarm 10 seconds in the future and puts the system to
554sleep.  A shorter time in seconds can be passed in as the first argument to the
555script, but do not use times shorter than 2 or 3 seconds.
556
557**NOTE**: The stmmac module is unloaded because the module is not compatible
558with S3 resume.
559
560```sh
561#
562# Unload NIC driver that causes S3 to fail
563#
564rmmod stmmac
565
566#
567# Disable RTC wake alarm
568#
569echo 0 > /sys/class/rtc/rtc0/wakealarm
570
571#
572# Compute wake time that is $1 seconds in the future
573#
574let WakeTime=`date '+%s'`
575echo $WakeTime
576if ["$1" = ""]; then
577  let WakeTime=$WakeTime+10
578else
579  let WakeTime=$WakeTime+$1
580fi
581echo $WakeTime
582
583#
584# Enable RTC wake alarm $1 seconds in the future
585#
586echo $WakeTime > /sys/class/rtc/rtc0/wakealarm
587
588#
589# Put systems into ACPI S3 sleep state
590#
591echo mem > /sys/power/state
592```
593
594## **UEFI Secure Boot Feature and Physical Presence**
595
596Build a firmware image with SECURE_BOOT_ENABLE enabled
597(```-D SECURE_BOOT_ENABLE```). This builds in support for UEFI authenticated
598variables, UEFI image verification, and UEFI Secure Boot configuration screens
599in the Device Manager. In order to change the UEFI Secure Boot configuration,
600the user must assert physical presence.  The Galileo development board only has
601two push buttons (REBOOT and RESET).  The REBOOT button unconditionally reboots
602the platform. The RESET button asserts the reset signal on the Arduino header
603and is also connected to a GPIO pin, so the state of the RESET button can be
604read.  The user asserts physical presence by holding the RESET button while the
605Galileo development board boots, or by holding the RESET button while selecting
606the **Secure Boot Configuration** option in the Device Manager.
607
608Use Dediprog SF100 to update the Galileo development board FLASH image.
609
610Connect power adapter to Galileo development board and boot to the UEFI Boot
611Manager by pressing F2 or running the ```exit``` command from the UEFI Shell.
612Select **Device Manager** and then**Secure Boot Configuration**.  Change
613**Customize Secure Boot** to **Customized** and then select **Custom Secure Boot
614Options**.  If **Custom Secure Boot Options** can not be selected, then physical
615presence was not asserted using one of two methods listed above.  Assert
616physical presence and try again.
617
618The **Custom Secure Boot Options** screen allows the Galileo development board
619to be enrolled into UEFI Secure Boot.  See [How to Sign UEFI Drivers & Application V1.31](
620http://sourceforge.net/projects/edk2/files/General%20Documentation/SigningUefiImages%20-v1dot31.pdf/download)
621in the [SecurityPkg Wiki](https://github.com/tianocore/tianocore.github.io/wiki/SecurityPkg)
622for details on how to complete the UEFI Secure Boot enrollment.
623
624## **Enable Measured Boot Feature using Atmel I2C TPM on CryptoShield**
625
626Build a firmware image with MEASURED_BOOT_ENABLE enabled
627(```-D MEASURED_BOOT_ENABLE```) and TPM_12_HARDWARE set to ATMEL_I2C
628(```-D TMP_12_HARDWARE=ATMEL_I2C```). This builds in the TCG PEIM and DXE
629modules and uses the library for the Atmel I2C TPM hardware device.
630
631Use Dediprog SF100 to update the Galileo development board FLASH image.
632
633Attach the CryptoShield to the Arduino header of the Galileo development board
634as shown below.
635
636![](https://github.com/tianocore/tianocore.github.io/wiki/Projects/QuarkPlatformPkg/Images/GalileoCryptoShield.jpg)
637
638Connect power adapter to Galileo development board and boot to the UEFI Shell.
639In the boot logging messages, messages similar to the following should be seen
640as the Atmel I2C TPM hardware device is detected and used to measure the
641contents of firmware volumes and firmware tables.
642
643```
644Loading PEIM at 0x0000FC75188 EntryPoint=0x0000FC75260 TrEEConfigPei.efi
645PROGRESS CODE: V03020002 I0
646TrEEConfiguration.TpmDevice from Setup: 1
647DetectTpmDevice:
648TpmDevice final: 1
649TpmDevice PCD: 8B01E5B6-4F19-46E8-AB93-1C53671B90CC
650. . .
651Loading PEIM at 0x0000FC70190 EntryPoint=0x0000FC70260 TcgPei.efi
652PROGRESS CODE: V03020002 I0
653Install PPI: E9DB0D58-D48D-47F6-9C6E-6F40E86C7B41
654Install PPI: A030D115-54DD-447B-9064-F206883D7CCC
655PROGRESS CODE: V03020003 I0
656The FV which is measured by TcgPei starts at: 0xFFF10000
657The FV which is measured by TcgPei has the size: 0xF0000
658The FV which is measured by TcgPei starts at: 0xFFD00000
659The FV which is measured by TcgPei has the size: 0x1E0000
660. . .
661Loading driver at 0x0000F620000 EntryPoint=0x0000F620260 TcgDxe.efi
662. . .
663TPM TcgDxe Measure Data when ReadyToBoot
664```
665See the [SecurityPkg Wiki](https://github.com/tianocore/tianocore.github.io/wiki/SecurityPkg)
666for additional details on EDK II TPM support
667
668## **Measuring Boot Performance**
669
670Build a firmware image with PERFORMANCE_ENABLE enabled
671(```-D PERFORMANCE_ENABLE```). This builds in the UEFI Shell and the DP.EFI
672(Dump Performance) into a firmware volume and also includes a simple file system
673driver for firmware volumes so the DP.EFI command can be run out of the FLASH.
674
675Use Dediprog SF100 to update the Galileo development board FLASH image.
676
677Connect power adapter to Galileo development board and let it boot to the UEFI
678Shell.  Then use the REBOOT button or the ```reset``` UEFI Shell command to
679reboot the Galileo development board.  The first boot after a FLASH update does
680extra work that is only performed one time.  In order to get correct performance
681measurements, use the 2nd or later boots.  After the 2nd boot, run the
682```dp -s``` command.  The output should look similar to the figure below.
683
684![](https://github.com/tianocore/tianocore.github.io/wiki/Projects/QuarkPlatformPkg/Images/DpCommand.png)
685