Differences

This shows you the differences between two versions of the page.

Link to this comparison view

ass:laboratoare:01:tasks:03 [2023/07/14 18:11]
radu.mantu
ass:laboratoare:01:tasks:03 [2025/05/16 13:00] (current)
radu.mantu
Line 1: Line 1:
-==== 03. [??p] Booting up the board ====+==== 03. Finally booting ​the board====
  
 The i.MX8M family of processors can boot from multiple sources: eMMC, SD card, etc. Our board lacks an SD card slot so this method can be discarded right off the bat. Although booting from eMMC is possible, it would require us to overwrite its persistent storage with a disk image every single time. We will do this at some point in the following sessions but for now the most convenient solution is using SDP to download **flash.bin** via a serial connection, over USB. The i.MX8M family of processors can boot from multiple sources: eMMC, SD card, etc. Our board lacks an SD card slot so this method can be discarded right off the bat. Although booting from eMMC is possible, it would require us to overwrite its persistent storage with a disk image every single time. We will do this at some point in the following sessions but for now the most convenient solution is using SDP to download **flash.bin** via a serial connection, over USB.
  
-=== [??p] Task A - Selecting the boot method ​===+=== Preparation ​===
  
 In order to select Serial Download as the preferred method of boot, you will need to set two jumpers on the board. Find J1 and J2 and configure them according to the figure below. In order to select Serial Download as the preferred method of boot, you will need to set two jumpers on the board. Find J1 and J2 and configure them according to the figure below.
  
-{{ :​ass:​laboratoare:​01:​tasks:​boot_jumpers.png?​500 |}}+{{ :​ass:​laboratoare:​01:​tasks:​boot_jumpers.png?​400 |}}
  
-=== [??p] Task B - Universal Update Utility ​===+== Step 6. Download & compile the IMX Universal Update Utility ==
  
 The Universal Update Utility (UUU) is an image deployment tool created by NXP for it's i.MX architecture. For more information about its usage, scripting interface and supported protocols, check out the [[https://​community.nxp.com/​pwmxy87654/​attachments/​pwmxy87654/​imx-processors/​140261/​1/​UUU.pdf|documentation]]. The Universal Update Utility (UUU) is an image deployment tool created by NXP for it's i.MX architecture. For more information about its usage, scripting interface and supported protocols, check out the [[https://​community.nxp.com/​pwmxy87654/​attachments/​pwmxy87654/​imx-processors/​140261/​1/​UUU.pdf|documentation]].
  
-Grab the source code from [[https://​github.com/​nxp-imx/​mfgtools.git|here]] and compile ​***uuu***. The project uses the **cmake** build system for the sake of portability. If you haven'​t encountered it yet, follow these setup steps:+Grab the source code from [[https://​github.com/​nxp-imx/​mfgtools.git|here]] and compile **uuu**. The project uses the **cmake** build system for the sake of portability. If you haven'​t encountered it yet, follow these setup steps:
  
 <code bash> <code bash>
Line 23: Line 23:
 </​code>​ </​code>​
  
-=== [??p] Task C - Boot from SDP === +=== Connecting to the board ===
- +
-== Step 1: Plug it in ==+
  
 First things first, connect the Micro USB and USB-C cables. While the latter will be used to power on the board, the former will expose two Serial Devices to your computer. The one used for console I/O by the bootloaders should appear to you as ''/​dev/​ttyUSB0''​. First things first, connect the Micro USB and USB-C cables. While the latter will be used to power on the board, the former will expose two Serial Devices to your computer. The one used for console I/O by the bootloaders should appear to you as ''/​dev/​ttyUSB0''​.
  
-== Step 2: Connect ​to the serial console ​==+<note warning>​ 
 +If you're using a Virtual Machine, you first need to identify ​the USB device on the host (it should be something like ''​NXP Semiconductors i.MX 8M ... Serial Downloader''​) and forward it to the VM. 
 + 
 +Otherwise (if you're using a Windows host), you will need to download and install both the NXP IMX ''​uuu''​ utility and a serial console ​program for your native platform; but not recommended. 
 +</​note>​
  
 Connect to this device using a serial terminal emulation tool of your choice. We recommend **picocom**. The default baud rate of i.MX devices is 115200 by convention. Connect to this device using a serial terminal emulation tool of your choice. We recommend **picocom**. The default baud rate of i.MX devices is 115200 by convention.
  
-== Step 3: Provide ​the FIP ==+Note that nothing will be printed on the console yet, but you need to stay connected to receive the messages that will follow!
  
-Ever since the USB-C cable was plugged in, **bl1** has been waiting for the FIP data over serial, thanks to our jumper configuration. Now we can finally provide this data using **uuu** and it's SDP implementation:​+== Step 7: Upload the firmware image package (FIP)! == 
 + 
 +Ever since the USB-C cable was plugged in, **BL1** has been waiting for the FIP data over serial, thanks to our jumper configuration. Now we can finally provide this data using **uuu** and it's SDP implementation:​
  
 <code bash> <code bash>
Line 42: Line 46:
 </​code>​ </​code>​
  
-About now you should see lots of debug messages ​via **picocom**If the last log line is ''​Run fastboot ...'', ​send it a //Ctrl + C// and you should get the ''​u-boot=>'' prompt.+About now you should see some debug messages ​in your serial console tool. 
 + 
 +Unfortunately (as per Murphy's law)notice we have some boot errors (: **don't worry, this is expected**!
  
 <​note>​ <​note>​
Line 48: Line 54:
 </​note>​ </​note>​
  
-=== [??p] Task D - Interacting with U-Boot (bl33) ===+== Step 8. Troubleshooting ​==
  
-Now that we have access to the interactive shell, try to run ''​bdinfo''​ for some generic board information. Run ''​help''​ to see what other commands are available to you, and ''​help <​command>''​ for detailed information of said command. Note that this may not be an exhaustive list of commands; some may not have been compiled into the final binary, depending on your ''​.config''​.+You should get this error: <​code>​ 
 +Trying to boot from USB SDP 
 +alloc space exhausted 
 +failed to initialize gadget 
 +couldn'​t find an available UDC 
 +g_dnl_register:​ failed!, error: -19 
 +SDP dnl register failed: -19 
 +</​code>​ 
 + 
 +The proper debugging procedure is to find the location of the exact error message inside u-boot'​s source code. 
 + 
 +It seems that the [[https://​github.com/​TechNexion/​u-boot-tn-imx/​blob/​6e5acadb0e01131b24d4508a7af01021efeca7d5/​common/​malloc_simple.c#​L30|malloc()]] call fails due to memory exhaustion. Recall that BL2 (U-Boot SPL) runs entirely from the internal SRAM of the chip, which is just ''​128K''​! But we also saw some messages about 2GB of DRAM becoming initialized,​ but we still need to properly tell our bootloader to use them! 
 + 
 +Thus, go back to **Step 4** (//​Modifying U-Boot configuration//​) and do some more configuration changes! But first, we must find out which options control the malloc pools. You can do that by [[https://​github.com/​TechNexion/​u-boot-tn-imx/​blob/​6e5acadb0e01131b24d4508a7af01021efeca7d5/​include/​system-constants.h#​L25|reading the source code here]] and [[https://​github.com/​TechNexion/​u-boot-tn-imx/​blob/​6e5acadb0e01131b24d4508a7af01021efeca7d5/​common/​spl/​spl.c#​L755|here]]. 
 + 
 +Use menuconfig to search for the following options: 
 +  * SYS_SPL_MALLOC -- must enable additional malloc pools; 
 +  * SPL_MALLOC_ADDR -- enter a physical address inside the board'​s DRAM memory (reminder: DDR starts from ''​0x40000000''​);​ 
 +  * SPL_MALLOC_SIZE -- make it bigger, e.g. ''​1MB''​ (in hex!); 
 + 
 +<spoiler Click to see them><​code>​ 
 +CONFIG_SYS_SPL_MALLOC=y 
 +CONFIG_HAS_CUSTOM_SPL_MALLOC_START=y 
 +CONFIG_CUSTOM_SYS_SPL_MALLOC_ADDR=0x42200000 
 +CONFIG_SYS_SPL_MALLOC_SIZE=0x100000 
 +CONFIG_USB_GADGET_MANUFACTURER="​ASS"​ 
 +CONFIG_USB_GADGET_VENDOR_NUM=0x1fc9 
 +CONFIG_USB_GADGET_PRODUCT_NUM=0x012b 
 +CONFIG_USB_FUNCTION_SDP=y 
 +</​code></​spoiler>​ 
 + 
 +You may enter them inside a simple text file (e.g.: ''​ass-extra.config'';​ don't forget the ''​CONFIG_*''​ prefix) and use the following script to mergem them inside the main ''​.config'':​ <code sh> 
 +# note: run this inside u-boot'​s source directory 
 +scripts/​kconfig/​merge_config.sh "​.config"​ "​ass-extra.config"​ 
 +</​code>​ 
 + 
 +Return after re-building the entire firmware image (i.e. ''​flash.bin''​ -- including the ''​mkimage''​ step -- hope you've scripted it in a Makefile!). 
 + 
 +Finally, when everything is in working condition, you should see a ''​Run fastboot ...''​ message, press //Ctrl + C// and you should get the ''​u-boot%%=>​%%''​ prompt. 
 + 
 +== Step 9. Time to play! == 
 + 
 +You might be wondering: but we don't have an OS installed yet... is this all we can do now? 
 + 
 +Don't worry, we'll now get to see why ''​u-boot''​ is the most popular choice for embedded devices (here'​s another fact: most Android phones also use it)! 
 + 
 +Now that we finally ​have access to the interactive shell (we've stopped at **BL33**), try to run ''​bdinfo''​ for some generic board information. Run ''​help''​ to see what other commands are available to you, and ''​help <​command>''​ for detailed information of said command. Note that this may not be an exhaustive list of commands; some may not have been compiled into the final binary, depending on your ''​.config''​. 
 + 
 +Try to perform the following:
  
-Try performing the following: 
   * Get the vendor and System on Chip (SOC) name from the environment variables.   * Get the vendor and System on Chip (SOC) name from the environment variables.
   * Print the available eMMC devices, as well as their partition tables (if any are available).   * Print the available eMMC devices, as well as their partition tables (if any are available).
-  * Perform a memory test on the first GB of DRAM. Note that U-Boot relocates itself toward the end of the DRAM bank during its initialization phase (check ''​bdinfo''​ for the exact address). Stay away from that region unless you want to overwrite **bl33** itself with your test pattern.+  * Perform a memory test on the first GB of DRAM. Note that U-Boot relocates itself toward the end of the DRAM bank during its initialization phase (check ''​bdinfo''​ for the exact address). Stay away from that region unless you want to overwrite **BL33** itself with your test pattern. 
 + 
ass/laboratoare/01/tasks/03.1689347479.txt.gz · Last modified: 2023/07/14 18:11 by radu.mantu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0