Difference between revisions of "Prepare a bootable MicroSD Card"

From IGEP - ISEE Wiki

Jump to: navigation, search
 
(41 intermediate revisions by 3 users not shown)
Line 14: Line 14:
  
  
 +
 +
===<span id="Texas_Instruments_Processors" class="mw-headline">General Processors</span>===
 
<span class="mw-headline">Inside General processors we can find Texas Instruments</span>
 
<span class="mw-headline">Inside General processors we can find Texas Instruments</span>
  
===<span id="Texas_Instruments_Processors" class="mw-headline">Texas Instruments Processors</span>===
 
 
* The microsd card must be content at latest 2 partitions.
 
* The microsd card must be content at latest 2 partitions.
 
* The first one must be primary partition with the boot flag mark and formated using FAT(16 or 32) file system.
 
* The first one must be primary partition with the boot flag mark and formated using FAT(16 or 32) file system.
Line 23: Line 24:
  
 
''The processor when boot ONLY load and execute the MLO program and ignore all the rest it's the X-loader(MLO) the program responsible to load the next programs such kernel or uboot if you use this last one approach.''
 
''The processor when boot ONLY load and execute the MLO program and ignore all the rest it's the X-loader(MLO) the program responsible to load the next programs such kernel or uboot if you use this last one approach.''
 +
 +
 +
 +
{{Message/Information Message|title=TITLE|message= <span style="color: #000000;">Freescale has a different structure</span>}}
  
  
Line 34: Line 39:
  
 
Therefore, we are going to '''setup a microSD card with these requirements''' and '''install a custom software distribution''' into it.
 
Therefore, we are going to '''setup a microSD card with these requirements''' and '''install a custom software distribution''' into it.
 
 
 
===Boot from Flash===
 
* Exist other ways of boot and in this link we can see how to do it with the Flash Memory-> LINK
 
  
  
Line 51: Line 51:
  
 
===<span id="ToolChain" class="mw-headline">ToolChain</span>===
 
===<span id="ToolChain" class="mw-headline">ToolChain</span>===
* Read: [index.php/Ubuntu_16.04_LTS_Toolchain Ubuntu 16.04 LTS Toolchain]
+
* Read: [[Ubuntu 16.04 LTS Toolchain]]
  
  
  
==<span id="Preparing_the_microSD_card" class="mw-headline">Preparing the microSD card</span>==
+
<span class="mw-headline">In order to start developing with an IGEP PROCESSOR BOARD we can use a microSD Card to flash our system and boot from it. Most of the cases is the easiest way to boot a board.<br /></span>
Open a terminal window and clear your dmesg using:
 
  
<pre>sudo dmesg -c</pre>
+
<span class="mw-headline">The following steps details how to prepare a booteable MicroSD Card</span>
Now insert a new microsd card in your PC and then check your dmesg:
 
  
<pre>dmesg</pre>
+
==<span class="mw-headline">Prepare a SD to boot</span>==
You should see something like this:
+
<div style="text-align: left;">{{Message/Information Message|message=The following steps has been tested using an Ubuntu 16.04}}</div>
 +
<div style="text-align: left;">First of all it is important to detect which device is our microSD Card. In order to do that we can follow this instructions in a Linux terminal:</div>
 +
<div style="text-align: left; padding-left: 30px;">'''1-''' Clean the ''dmesg'' information:</div>
 +
sudo dmesg -c
 +
'''2-''' Insert the microSD Card and show the ''dmesg'' information:
  
<pre>mmc0: new high speed SDHC card at address 0001
+
dmesg
mmcblk0: mmc0:0001 00000 3.79 GiB
+
The result have to be similar to this:
mmcblk0: unknown partition table
 
</pre>
 
Ensure all in your microsd card it's erased:
 
  
<pre>$ sudo dd if=/dev/zero of=/dev/mmcblk0 bs=1024 count=1024
 
[sudo] password for jdoe:</pre>
 
='''<span class="mw-headline">Prepare a SD to boot</span>'''=
 
{{Message/Information Message|title=TITLE|message= <span style="color: #000000;">We are using this version of Ubuntu .........</span>}}
 
  
 +
[[File:dev.png]]
  
 +
<div style="text-align: left;">We can see the name of our device in the system: '''/dev/sdX''' where X is the character assigned by our system, in this case /dev/sdc'''.'''</div>
 +
<div style="text-align: left;">Now we have to ensure that the MicroSD Card is completely clean. We can use the following command to do that:</div>
 +
sudo dd if=/dev/zero of=/dev/sdX bs=1024 count=1024
 +
Where '''X''' is the character returned previously by your system, for example, in the previous situation:
  
==<span id="Install_GParted" class="mw-headline">Downloading GParted</span>==
+
sudo dd if=/dev/zero of=/dev/sdc bs=1024 count=1024
In order to prepare a micro SD with your already generated u-boot you need to flash the u-boot.imx using the command dd.
+
Before use anyway of partition one good practise is unmount the dev where is inserted the SD. -> <code>umount /dev/sdx</code>
  
It is important to prepare your micro SD card first creating a partition that leave some free space for the u-boot.imx. It can be used GPARTED as it is shown in the image. This method is much more graphic than sfdisk method. 
+
Now we are ready to create the corresponding partitions in our MicroSD Card.
  
 +
==How to partition the MicroSD card==
 +
<div style="text-align: left;">There are several ways to partition a MicroSD Card. In this post we are using the GParted tool that can be installed as:</div>
 +
sudo apt-get install gparted
 +
<span class="mw-headline">Other tools as sfdisk and mkfs are useful too.</span>
  
[[File:GPARTED.png|center|713x201px]]
+
<span class="mw-headline">It is important to difference between a MicroSD Card for a NXP processor and the other cases. The process of partition is similar but, in the case of NXP chips, there exists some differences. </span>
  
 +
==='''<span class="mw-headline">Using Gparted:</span>'''===
 +
{| class="contenttable sortable"
 +
|-
 +
!|
 +
====='''GENERAL CASE'''=====
 +
!|
 +
====='''NXP PROCESSORS'''=====
 +
|-
 +
||'''1- '''Select the corresponding device
 +
||'''1- '''Select the corresponding device
 +
|-
 +
||<span class="mw-headline">[[File:1.png|429x186px]]</span>
 +
||<span class="mw-headline">[[File:1.png|413x179px]]</span>
 +
|-
 +
||'''2- '''Create a partition table
 +
||'''2- '''Create a partition table
 +
|-
 +
||<span class="mw-headline">[[File:2.png|430x202px]]</span><span class="mw-headline">[[File:SD4.png|433x298px]]</span>
 +
||<span class="mw-headline">[[File:2.png|418x197px]]</span><span class="mw-headline">[[File:SD4.png|431x297px]]</span>
 +
|-
 +
||'''<span class="mw-headline">3- </span>'''<span class="mw-headline">Create a FAT32 '''boot '''partition</span>
 +
||<span class="mw-headline">'''3- '''Create a FAT32 '''boot '''partition '''leaving 8MB before'''</span>
 +
|-
 +
||
 +
<span class="mw-headline">[[File:2.png|432x203px]]</span>[[File:fat32_c121.png|429x293px]]
  
In this image we can see the devices plugged in our computer. And it can be installed with this command.
 
 
<pre>sudo apt-get install gparted</pre>
 
<span style="color: #000000;">Now we will see all the steps for this partition with GPARTED after another brief  explanation of  sfdisk method.</span>
 
 
 
 
* <span style="color: #000000;">Using fdisk we create directly two partitions</span>
 
 
<div class="code panel pdl conf-macro output-block" data-hasbody="true" data-macro-name="code">
 
==<span style="color: #000000;">Using sfdisk partition method</span>==
 
<div id="highlighter_789287">
 
 
 
<pre>sudo sfdisk /dev/ 16065,128520,0x0C,*<br>144585,,,-<br>EOF</pre>
 
 
</div>
 
</div>
 
<div class="code panel pdl conf-macro output-block" data-hasbody="true" data-macro-name="code"><div class="codeHeader panelHeader pdl">'''Define partitions'''</div>
 
<div class="codeContent panelContent pdl"><div class="syntaxhighlighter sh-eclipse nogutter  bash"></div>
 
<div class="syntaxhighlighter sh-eclipse nogutter  bash">
 
<pre>$ sudo mkfs.vfat -F 32 /dev/ -n boot</pre>
 
<pre>$ sudo mkfs.ext3 /dev/ -L rootfs</pre></div>
 
<div class="syntaxhighlighter sh-eclipse nogutter  bash"></div>
 
</div>
 
</div>
 
Then you only have to use dd command in order to copy the u-boot.imx to the SD card.
 
 
<u>'''Please, be sure you have write correctly the following command because in if not, it can corrupt your computer.'''</u>
 
 
<div class="code panel pdl conf-macro output-block" data-hasbody="true" data-macro-name="code"><div class="codeHeader panelHeader pdl">'''u-boot.imx copy'''</div>
 
<div id="highlighter_550267">
 
<pre>$ sudo dd if=//u-boot.imx of=/dev/ bs=512 seek=2 <br>$ sync</pre>
 
 
</div>
 
</div>
 
For example
 
 
<div class="code panel pdl conf-macro output-block" data-hasbody="true" data-macro-name="code"><div class="codeHeader panelHeader pdl">'''u-boot.imx copy'''</div>
 
<div id="highlighter_209438">
 
<pre>$ sudo dd if=/home/user/Project/u-boot/u-boot.imx of=/dev/sdd bs=512 seek=2<br>$ sync</pre>
 
 
</div>
 
</div>
 
 
 
==<span id="GParted_and_Creation_of_Partitions" class="mw-headline">Using GParted and Creation of Partitions</span>==
 
When the install procedure ends you can call the program from your system tools menu or directly using a terminal console.
 
 
We can see our devices and their size.
 
 
 
===<span id="Create_the_MSDOS.C2.A0Partition_Table" class="mw-headline">Create the MSDOS Partition Table</span>===
 
The next step it's create the msdos table partition for it you should click in the "Device" menu and then in the "Create Partition Table" option.
 
 
<div class="center"><div class="thumb tnone"><div class="thumbinner"><div class="thumbcaption"><div class="magnify"></div>
 
</div>
 
</div>
 
</div>
 
</div>
 
Check the default option it's create a msdos partition table.
 
 
After that you can '''Apply'''.
 
 
 
 
===<span id="Create_the_BOOT_Partition_-_IGEP_Texas_Instruments_Processor_based" class="mw-headline">Create the BOOT Partition - '''IGEP Texas Instruments Processor based'''</span>===
 
<u>This Step it's only for OMAP35xx, DM37xx, AM335x, OMAP5432 processor based IGEP boards.</u>
 
 
The Next step it's create the partitions for it you should go to the partition menu and select the "New" option then the application show a window like this:
 
 
<div class="center"><div class="thumb tnone"><div class="thumbinner"><div class="thumbcaption"><div class="magnify"></div>
 
</div>
 
</div>
 
</div>
 
</div>
 
 
We will configure the partition as:
 
We will configure the partition as:
  
 +
* Free Space Preceding: 1MB
 
* Primary Partition
 
* Primary Partition
* Format: FAT32
+
* File system/ Format: FAT32
* Size: 100 MegaBytes
+
* Size: 100 MB
* '''Free Space Preceding: 0 MiB'''
+
* Label: '''Boot'''
* Label: Boot
 
 
* '''Align to: cylinder'''
 
* '''Align to: cylinder'''
  
It is recommended to '''apply changes''' now or you might get an error later.
+
||
 +
<span class="mw-headline">[[File:2.png|432x203px]]</span>[[File:im_1.png|425x290px]]
  
===<span id="Create_the_BOOT_Partition_-_IGEP_NXP-Freescale_Processor_based" class="mw-headline">Create the BOOT Partition - '''IGEP NXP-Freescale Processor based'''</span>===
 
<u>This Step it's only for iMX6 processor based IGEP boards.</u>
 
 
The Next step it's create the partitions for it you should go to the partition menu and select the "New" option then the application show a window like this:
 
 
<div class="center"><div class="thumb tnone"><div class="thumbinner"><div class="thumbcaption"><div class="magnify"></div>
 
</div>
 
</div>
 
</div>
 
</div>
 
 
We will configure the partition as:
 
We will configure the partition as:
  
 +
* Free Space Preceding: '''8MB'''
 
* Primary Partition
 
* Primary Partition
* Format: FAT32
+
* File system/ Format: FAT32
* '''Free Space Preceding: 8 MiB'''
+
* Size: 100 MB
* Size: 100 MegaBytes
+
* Label: '''Boot'''
* Label: Boot
 
 
* '''Align to: cylinder'''
 
* '''Align to: cylinder'''
  
<br />It is recommended to '''apply changes''' now or you might get an error later.
+
|-
 +
||'''<span class="mw-headline">4- </span>'''<span class="mw-headline">Create a ext4 '''rootfs '''partition</span>
 +
||'''<span class="mw-headline">4- </span>'''<span class="mw-headline">Create a ext4 '''rootfs '''partition</span>
 +
|-
 +
||[[File:fat32_c2.png|407x279px]]'''7-''' Check the results are similar to the followings:
 +
||[[File:fat32_c2.png|407x279px]]
 +
|-
 +
||'''<span class="mw-headline">5- </span>'''<span class="mw-headline">Apply changes<br /></span>
 +
||'''<span class="mw-headline">5- </span>'''<span class="mw-headline">Apply changes</span>
 +
|-
 +
||'''<span class="mw-headline">[[File:fat32_c3.png|411x279px]]</span>'''
 +
||[[File:im_2.png|403x275px]]
 +
|-
 +
||'''<span class="mw-headline">6- </span>'''<span class="mw-headline">Set boot flag to boot partition</span>
 +
||'''<span class="mw-headline">6- </span>'''<span class="mw-headline">Set boot flag to boot partition</span>
 +
|-
 +
||
 +
[[File:fat32_c4.png|411x278px]]
  
===<span id="Create_the_ROOTFS_Partition" class="mw-headline">Create the ROOTFS Partition</span>===
+
[[File:fat32_c5.png|432x291px]]
The Next step it's create the root file system partition.
 
  
First you should select the unallocated partition area and then  you should go to the partition menu and select the "New" option then the application show a window like this:
+
||
 +
[[File:IM_25.png|414x281px]]
  
<div class="center"><div class="thumb tnone"><div class="thumbinner"><div class="thumbcaption"><div class="magnify"></div>
+
[[File:fat32_c5.png|431x291px]]
</div>
 
</div>
 
</div>
 
</div>
 
We will configure the rootfs partition as:
 
  
* Primary Partition
+
|-
* Format: EXT4
+
||'''7-''' Check the results are similar to the followings:
* Size: All the Rest
+
||'''7-''' Check the results are similar to the followings:
* Label: Rootfs'''<br />'''
+
|-
 +
||[[File:fat32_c6.png|434x294px]]
 +
||[[File:im_3.png|438x301px]]
 +
|}
  
At end we will click on "Add" button.
+
'''<span class="mw-headline">By doing that we will have ready the microSD Card in order to copy our files.</span>'''
  
<div class="center"><div class="thumb tnone"><div class="thumbinner"><div class="thumbcaption"><div class="magnify"></div>
 
</div>
 
</div>
 
</div>
 
</div>
 
or
 
  
<div class="center"><div class="thumb tnone"><div class="thumbinner"><div class="thumbcaption"><div class="magnify"></div>
 
</div>
 
</div>
 
</div>
 
</div>
 
After all apply all changes
 
  
===<span id="Select_.22Boot_flag.22_for_the_boot_partition" class="mw-headline">Select "Boot flag" for the boot partition</span>===
+
==='''Using SFDISK & MKFS<br />'''===
Now we must select the boot flag for the first partition for it we use the right mouse button over the boot partition and select "Manage Flags" option
+
Another method is to use the following commands in order to prepare the microSD card. These commands will perform the same operations that in the previous part.
  
<div class="center"><div class="thumb tnone"><div class="thumbinner"><div class="thumbcaption"><div class="magnify"></div>
+
{| class="contenttable sortable" style="width: 890px;"
</div>
+
|-
</div>
+
! style="width: 431.367px;"|GENERAL CASE
</div>
+
! style="width: 436.633px;"|NXP PROCESSORS
</div>
+
|-
Now we have the microsd prepared for copy the boot files
+
| style="width: 431.367px;"|
 +
sudo sfdisk /dev/ <<EOF<br>label: dos<br>63,144522,0x0C,*<br>160650,,,-<br>EOF
 +
| style="width: 436.633px;"|
 +
sudo sfdisk /dev/ <<EOF<br>label: dos<br>16065,128520,0x0C,*<br>144585,,,-<br>EOF
 +
|-
 +
| style="width: 431.367px;"|
 +
sudo mkfs.vfat -F32 /dev/ -n boot
 +
| style="width: 436.633px;"|
 +
sudo mkfs.vfat -F32 /dev/ -n boot
 +
|-
 +
| style="width: 431.367px;"|
 +
sudo mkfs.ext4 /dev/ -L rootfs
 +
| style="width: 436.633px;"|
 +
sudo mkfs.ext4 /dev/ -L rootfs
 +
|-
 +
| style="width: 431.367px;"|'''For example:'''
 +
| style="width: 436.633px;"|'''For example:'''
 +
|-
 +
| style="width: 431.367px;"|
 +
sudo sfdisk /dev/<strong>sdc</strong> <<EOF<br data-attributes="%20/">label: dos<br data-attributes="%20/">63,144522,0x0C,*<br data-attributes="%20/">160650,,,-<br data-attributes="%20/">EOF<br><br>sudo mkfs.vfat -F32 /dev/<strong>sdc1</strong> -n boot<br data-attributes="%20/"><br data-attributes="%20/">sudo mkfs.ext4 /dev/<strong>sdc2</strong> -L rootfs<br><br>
 +
| style="width: 436.633px;"|
 +
sudo sfdisk /dev/<strong>sdc</strong> <<EOF<br data-attributes="%20/">label: dos<br data-attributes="%20/">16065,128520,0x0C,*<br data-attributes="%20/">144585,,,-<br data-attributes="%20/">EOF<br><br>sudo mkfs.vfat -F32 /dev/<strong>sdc1</strong> -n boot<br><br>sudo mkfs.ext4 /dev/<strong>sdc2</strong> -L rootfs<br><br>
 +
|}
  
 
+
='''How to copy everything into the MicroSD Card<br />'''=
 
+
Once the MicroSD is completely prepared, it is time to copy the u-boot, kernel and root dile system to the MicroSD Card.
='''How to boot each part'''=
 
Now we will see where to put each part and how to.
 
  
 
==U-Boot==
 
==U-Boot==
'''Texas'''
+
'''General processors<br />'''
  
 
After build or download the MLO and u-boot you should follow the next steps:
 
After build or download the MLO and u-boot you should follow the next steps:
  
* Copy MLO and u-boot.img to primary boot partition
+
* Copy MLO and u-boot.img to primary into the ''root folder'' of the '''boot partition'''
  
<pre>$ cp MLO u-boot.img /media/user/boot
+
<pre>cp [your_u-boot_directory]/u.boot.img /media/user/boot
 +
 
 +
cp [your_u-boot_directory]/MLO /media/user/boot
 
</pre>
 
</pre>
You can follow this [[How to prepare a bootable MicroSD Card|link]] if you want build the MLO and u-boot
+
You can follow this post [[The bootloader U-Boot|U-boot Bootloader]] if you want build the MLO and u-boot
  
  
'''iMX6'''
+
'''Freescale processors<br />'''
  
 
* Copy u-boot.imx using dd before primary partition in raw mode as
 
* Copy u-boot.imx using dd before primary partition in raw mode as
  
<pre>sudo dd if=/home/user/u-boot-imx/u-boot.imx of=/dev/sde bs=512 seek=2
+
<pre>sudo dd if=/[your_u-boot_directory]/u-boot.imx of=/dev/[your_sd] bs=512 seek=2</pre>
</pre>
+
You can follow this post [[The bootloader U-Boot|U-boot Bootloader]] you want build the u-boot.imx
<u>Where /dev/sde is your microsd card</u>
 
  
  
You can follow this [[How to prepare a bootable MicroSD Card|link]] you want build the u-boot.imx
+
'''How to configure Uenv<br />'''
  
 +
It is need to indicate how start the boot. For this reason it will be created a file called uenv.txt with the correct configuration.
  
 +
We present two examples of help to start the system from the MicroSD Card or from an nfs server.
  
==Root file System==
+
* If we want boot from the bootable microSD Card. [http://downloads.isee.biz/pub/relaunch/uenv.txt uenv.txt]
In this tutorial we will use the [http://downloads.isee.biz/pub/files/linaro/releases/linaro-m-headless-tar-20101108-2.tar.gz linaro headless] (soft floating) image as rootfs but you can use your favorite rootfs also.
+
* If we want boot from nfs server. [http://downloads.isee.biz/pub/relaunch/uenv_nfs.txt uenv.txt]
  
 +
These two examples have an ip address assigned to them that can be modified as you want.
  
{| width="auto" cellspacing="1" cellpadding="1" align="center" border="0"
+
==Kernel==
|-
+
Kernel files, '''zImage '''and''' .dtb''', can be copied into the'' root folder'' of the''' boot partition'''
||
 
| style="text-align: center;"| 
 
|-
 
| scope="row"|[[]]
 
||Here there are many articles about how to get '''many other [index.php/Category:Software_distributions software distributions]'''.
 
|}
 
<br /> Here you've the [http://downloads.isee.biz/pub/files/linaro/releases/linaro-11.09-nano-n-tar-20110929-0.tar.gz linaro nano 11.09] (soft floating) available for download from the ISEE server.
 
  
Notes: You must build your programs with the hard floating if your rootfs is build with it.
+
'''Kernel Modules''' have to be copied using the command indicated in the kernel compilation [[Linux Kernel 4.9.y|post]] into the '''rootfs partition'''. 
  
Notes: IGEPv5 must use Hard floating Rootfs
 
 
 
===<span id="Create_the_Rootfs_mount_point" class="mw-headline">Create the Rootfs mount point</span>===
 
Go to /media directory and create one sub-folder called "binary"
 
 
<pre>cd /media
 
 
sudo mkdir binary
 
</pre>
 
===<span id="Mount_the_RootFS_partition" class="mw-headline">Mount the RootFS partition</span>===
 
Mount the rootfs partition using the 'binary' directory
 
 
<pre>$ media > sudo mount /dev/mmcblkp2 /media/binary
 
</pre>
 
===<span id="Untar_the_rootfs_package" class="mw-headline">Untar the rootfs package</span>===
 
Copy "linaro-m-headless-tar-20101108-2.tar.gz" file inside the /media directory and untar the file
 
 
<pre>$ media > sudo tar xvfz linaro-m-headless-tar-20101108-2.tar.gz</pre>
 
<br /> Now you should see inside your rootfs partition a similar structure like this.
 
 
<div class="center"><div class="thumb tnone"><div class="thumbinner" style="width: 302px;">[[]]<div class="thumbcaption"><div class="magnify"></div>
 
</div>
 
</div>
 
</div>
 
</div>
 
===<span id="Install_the_kernel_modules" class="mw-headline">Install the kernel modules</span>===
 
Now you should install your kernel modules inside your root file system.
 
 
<pre>$ media > cd /home/jdoe/linux-omap-2.6
 
 
$ /home/jdoe/linux-omap-2.6> sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- modules_install INSTALL_MOD_PATH=/media/binary
 
</pre>
 
Alternatively if you downloaded the binary package uncompress it inside the directory /media/binary
 
 
===<span id="Install_the_kernel_Image" class="mw-headline">Install the kernel Image</span>===
 
Just copy the zImage inside your boot partition, remember before that you must mount your mmc boot partition.
 
 
<pre>$ /home/jdoe/linux-omap-2.6> sudo cp arch/arm/boot/zImage /media/boot/
 
if you're using dtb kernel as 3.8.y you must copy the dtb too.
 
$ /home/jdoe/linuz-omap-2.6> sudo cp arch/arm/boot/dtbs/omap5-igep0050.dtb /media/boot
 
 
</pre>
 
After that you can unmount the boot & rootfs partitions.
 
 
Now we're ready for test our new microsd card
 
 
==Kernel & Modules==
 
You can follow this other howto about [index.php/The_Linux_kernel how compile and install the Linux Kernel].
 
  
  
 +
==Root file System==
 +
The root file system have to be extracted into the'' root folder''  of the '''rootfs''' '''partition'''. Where can be [http://labs.isee.biz/index.php/IGEP_Firmware_set-up downloaded here.]
  
=<span id="Test_your_new_MicroSD" class="mw-headline">Test your new MicroSD</span>=
 
You can test your new microSD card with a Serial client such as PuTTy. [index.php/Using_serial_debug_port_to_communicate Here] is an explanation about how to configure it.
 
  
(Note that speed should be configured to 115200 bauds).
 
  
If you already have configured it or you are using another Serial client and you have connected the Serial cable to the IGEPv2 board, then you are ready to test your microSD.
 
  
Insert the microSD in your IGEPv2 board and power up the board.
 
  
  

Latest revision as of 09:52, 1 July 2019

Introduction

This page explain how to create a microSD card to boot IGEP boards with  software distributions ( yocto, Ubuntu, Debian ...).

  • Now we can see an image of which are the steps to boot any module.

With a general processor all start with MLO file and U-Boot.img. Also it is the same procedure for Freescale- NXP. If you want to see how to create these files follow this link.

Next step is that once the processor is initialized,call the linux kernel making the execution of  your operative system available.

Finally your OS runs and you can initialize the board correctly 


How to SD.PNG


General Processors

Inside General processors we can find Texas Instruments

  • The microsd card must be content at latest 2 partitions.
  • The first one must be primary partition with the boot flag mark and formated using FAT(16 or 32) file system.
  • All names used in this partition must be msdos names (applies to OLD OMAP35xx processor).
  • The processor must load a first program called MLO, this program must reside in the first partition, this program it's also called x-loader or uboot-spl.

The processor when boot ONLY load and execute the MLO program and ignore all the rest it's the X-loader(MLO) the program responsible to load the next programs such kernel or uboot if you use this last one approach.


Information.jpg Freescale has a different structure


Freescale-NXP Processors

  • The microsd card must be content at latest 1 partitions.
  • The primary partition can be formatted with any filesystem that u-boot can mount.
  • The Processor will load the u-boot.imx it include the SPL and u-boot.

After load this u-boot.imx, u-boot will be ready for boot the kernel.

Therefore, we are going to setup a microSD card with these requirements and install a custom software distribution into it.


Prerequisites

  • PC with Linux (We use for this how to Ubuntu 16.04 LTS)
  • MicroSD Card (4 Gbytes - class 4) or bigger ...
  • Tools such, fdisk, mkfs.ext3, mkfs.vfat, gparted ...
  • Cross Toolchain included in Ubuntu 16.04 LTS gcc version 4.9.3 (Ubuntu/Linaro 4.9.3-13ubuntu2).


ToolChain


In order to start developing with an IGEP PROCESSOR BOARD we can use a microSD Card to flash our system and boot from it. Most of the cases is the easiest way to boot a board.

The following steps details how to prepare a booteable MicroSD Card

Prepare a SD to boot

Information.jpg The following steps has been tested using an Ubuntu 16.04
First of all it is important to detect which device is our microSD Card. In order to do that we can follow this instructions in a Linux terminal:
1- Clean the dmesg information:
sudo dmesg -c

2- Insert the microSD Card and show the dmesg information:

dmesg

The result have to be similar to this:


dev.png

We can see the name of our device in the system: /dev/sdX where X is the character assigned by our system, in this case /dev/sdc.
Now we have to ensure that the MicroSD Card is completely clean. We can use the following command to do that:
sudo dd if=/dev/zero of=/dev/sdX bs=1024 count=1024

Where X is the character returned previously by your system, for example, in the previous situation:

sudo dd if=/dev/zero of=/dev/sdc bs=1024 count=1024

Before use anyway of partition one good practise is unmount the dev where is inserted the SD. -> umount /dev/sdx

Now we are ready to create the corresponding partitions in our MicroSD Card.

How to partition the MicroSD card

There are several ways to partition a MicroSD Card. In this post we are using the GParted tool that can be installed as:
sudo apt-get install gparted

Other tools as sfdisk and mkfs are useful too.

It is important to difference between a MicroSD Card for a NXP processor and the other cases. The process of partition is similar but, in the case of NXP chips, there exists some differences. 

Using Gparted:

GENERAL CASE
NXP PROCESSORS
1- Select the corresponding device 1- Select the corresponding device
1.png 1.png
2- Create a partition table 2- Create a partition table
2.pngSD4.png 2.pngSD4.png
3- Create a FAT32 boot partition 3- Create a FAT32 boot partition leaving 8MB before

2.pngfat32 c121.png

We will configure the partition as:

  • Free Space Preceding: 1MB
  • Primary Partition
  • File system/ Format: FAT32
  • Size: 100 MB
  • Label: Boot
  • Align to: cylinder

2.pngim 1.png

We will configure the partition as:

  • Free Space Preceding: 8MB
  • Primary Partition
  • File system/ Format: FAT32
  • Size: 100 MB
  • Label: Boot
  • Align to: cylinder
4- Create a ext4 rootfs partition 4- Create a ext4 rootfs partition
fat32 c2.png7- Check the results are similar to the followings: fat32 c2.png
5- Apply changes
5- Apply changes
fat32 c3.png im 2.png
6- Set boot flag to boot partition 6- Set boot flag to boot partition

fat32 c4.png

fat32 c5.png

IM 25.png

fat32 c5.png

7- Check the results are similar to the followings: 7- Check the results are similar to the followings:
fat32 c6.png im 3.png

By doing that we will have ready the microSD Card in order to copy our files.


Using SFDISK & MKFS

Another method is to use the following commands in order to prepare the microSD card. These commands will perform the same operations that in the previous part.

GENERAL CASE NXP PROCESSORS
sudo sfdisk /dev/ <<EOF
label: dos
63,144522,0x0C,*
160650,,,-
EOF
sudo sfdisk /dev/ <<EOF
label: dos
16065,128520,0x0C,*
144585,,,-
EOF
sudo mkfs.vfat -F32 /dev/ -n boot
sudo mkfs.vfat -F32 /dev/ -n boot
sudo mkfs.ext4 /dev/ -L rootfs
sudo mkfs.ext4 /dev/ -L rootfs
For example: For example:
sudo sfdisk /dev/sdc <<EOF
label: dos
63,144522,0x0C,*
160650,,,-
EOF

sudo mkfs.vfat -F32 /dev/sdc1 -n boot

sudo mkfs.ext4 /dev/sdc2 -L rootfs

sudo sfdisk /dev/sdc <<EOF
label: dos
16065,128520,0x0C,*
144585,,,-
EOF

sudo mkfs.vfat -F32 /dev/sdc1 -n boot

sudo mkfs.ext4 /dev/sdc2 -L rootfs

How to copy everything into the MicroSD Card

Once the MicroSD is completely prepared, it is time to copy the u-boot, kernel and root dile system to the MicroSD Card.

U-Boot

General processors

After build or download the MLO and u-boot you should follow the next steps:

  • Copy MLO and u-boot.img to primary into the root folder of the boot partition
cp [your_u-boot_directory]/u.boot.img /media/user/boot

cp [your_u-boot_directory]/MLO /media/user/boot

You can follow this post U-boot Bootloader if you want build the MLO and u-boot


Freescale processors

  • Copy u-boot.imx using dd before primary partition in raw mode as
sudo dd if=/[your_u-boot_directory]/u-boot.imx of=/dev/[your_sd] bs=512 seek=2

You can follow this post U-boot Bootloader you want build the u-boot.imx


How to configure Uenv

It is need to indicate how start the boot. For this reason it will be created a file called uenv.txt with the correct configuration.

We present two examples of help to start the system from the MicroSD Card or from an nfs server.

  • If we want boot from the bootable microSD Card. uenv.txt
  • If we want boot from nfs server. uenv.txt

These two examples have an ip address assigned to them that can be modified as you want.

Kernel

Kernel files, zImage and .dtb, can be copied into the root folder of the boot partition

Kernel Modules have to be copied using the command indicated in the kernel compilation post into the rootfs partition


Root file System

The root file system have to be extracted into the root folder  of the rootfs partition. Where can be downloaded here.