SlideShare une entreprise Scribd logo
1  sur  39
Embedded System on SD

Vincent Chen
Annie Cheng
YuChin Huang
Jason Kung
2013-09-18
Motivation
Typically, most embedded systems load system from NAND flash on the target
device. That means the boot loader, kernel and file system are fused on the NAND
flash.
However, in the beginning stage of implementation, the NAND flash is totally empty,
which means, at least, we have to fuse boot loader into the NAND flash, and then
fuse kernel and file system to bring up the system.

To fuse the boot loader into NAND flash is not easy as just copy a file. We have to
use specific tools like chip programmer or JTAG. Some of these tools are
expensive or not easy to get. Users also need to wait patiently while programming
a NAND flash because it takes time. Frequently programming NAND flash also
impacts its endurance due to its physical character. Thus, if we can find a way to
build a system on other external storage device, like SD card, it would be save a lot
of time, cost, and even NAND flash life cycle.
Embedded System (boot from NAND)

SD I/F

Boot Loader

CPU
Memory
controller

NAND flash
controller

Kernel

Memory

NAND
File System
Embedded System (SD recovery mode)

SD I/F

Boot Loader
SD / SDHC

CPU
Memory
controller

NAND flash
controller

Kernel

Memory

NAND
File System
Embedded System (boot from SD)

SD I/F

Boot Loader
SD / SDHC

CPU
Memory
controller

NAND flash
controller

Kernel

Memory

NAND
File System
Purpose
- Build the embedded system on SD card
- Loading system from SD card completely without NAND flash support.
- The file system on SD card supports read and write facility.
- Implement a utility to fuse boot loader, kernel and file system to SD card easily.

Replace boot from NAND
Load u-boot
Loader Kernel
Load File system
File system readable / writable












Benefits
- System is easy to recover/update
just simply replace the SD card.

- Cost down
NAND/NOR flash become optional, not a necessary component anymore.
It saves BOM cost.

- Product in test stage
Modify/update codes easily.

- Multi-OS in one device
Switch OS among different SD cards.
Platform - DMA6410L
- AP: Samsung S3C6410XH-66, 667Mhz
- RAM: mDDR 128MB (64MB * 2)
- Ethernet I/F: DM9000AE

- Display: 4.3” TFT (480*272)
- UART: UART * 1 (for debug)
- SD card I/F: SD card slot * 1
How …
To achieve system on SD card, we will face the following issues,

- CPU supports boot from SD card. How does it work?

- An embedded system has three parts: u-boot (boot loader), kernel and file system.
We have to know the exact position in SD card.

- SD card has SDSC (Standard-Capacity), SDHC (High-Capacity) and SDXC
(eXtended-Capacity.) Does all of them can be supported by CPU?

- How to make the boot loader loads kernel and than kernel loads file system
exactly?
Boot Loader (u-boot)
S3C6410 iROM booting
S3C6410
ARM1176JZF-S

SDRAM
Controller

SDRAM
Booting Device
(SD/MMC Card,
OneNAND, Nand)

Stepping
Stone (8KB)

iROM(BL0)
(32KB)

OM=iROM Boot

HS-MMC
Controller

BL2

Kernel

OneNAND
Controller

D-TCM (16KB)

BL1
(8KB)

File
System

NAND
Controller

GPN[15:13]:Booting
device pin selection

1.iROM supports initial boot up
Initialize system clock, D-TCM,
device specific controller and
booting device.
S3C6410 iROM booting

(cont.)

S3C6410
ARM1176JZF-S

SDRAM
Controller

SDRAM
Booting Device
(SD/MMC Card,
OneNAND, Nand)

Stepping
Stone (8KB)

iROM(BL0)
(32KB)

OM=iROM Boot

HS-MMC
Controller

BL2

Kernel

OneNAND
Controller

D-TCM (16KB)

BL1
(8KB)

File
System

NAND
Controller

GPN[15:13]:Booting
device pin selection

2.iROM boot codes can load 8KB of
boot loader to stepping stone.
The 8 KB boot loader is called
BL1.
S3C6410 iROM booting

(cont.)

S3C6410
ARM1176JZF-S

SDRAM
Controller

SDRAM
Booting Device
(SD/MMC Card,
OneNAND, Nand)

Stepping
Stone (8KB)

iROM(BL0)
(32KB)

OM=iROM Boot

HS-MMC
Controller

BL2

Kernel

OneNAND
Controller

D-TCM (16KB)

BL1
(8KB)

File
System

NAND
Controller

GPN[15:13]:Booting
device pin selection

3.BL1 can initialize system clock,
UART, and SDRAM for user.
After initializing, BL1 will load the
remaining boot loader called BL2
to SDRAM.
S3C6410 iROM booting

(cont.)

S3C6410
ARM1176JZF-S

SDRAM
Controller

SDRAM
Booting Device
(SD/MMC Card,
OneNAND, Nand)

Stepping
Stone (8KB)

iROM(BL0)
(32KB)

OM=iROM Boot

HS-MMC
Controller

BL2

Kernel

OneNAND
Controller

D-TCM (16KB)

BL1
(8KB)

File
System

NAND
Controller

GPN[15:13]:Booting
device pin selection

4.Finally, jump to start address of
BL2. That will make good
environment to use system.
SD/SDHC Device Block Assignment

1 Block = 512 bytes

SD/MMC Device
File System

Kernel

BL2

BL1

Signature

Reserved

(4MB)

(256KB)

(8KB)

(512B)

(512B)

8192

512

16

1

1
Last

1 Block = 512 bytes

SDHC Device
File System

Kernel
(4MB)

BL2
(256KB)

8192

512

BL1 Signature
(8KB) (1024B)
16

2

Skipped
(512KB)
1024
Last
For Instance …
2 GB SD

4 GB SDHC

2,021,654,528 bytes
3,958,544 blocks

3,965,190,144 bytes
7,744,512 blocks

File System

File System

3,939,822

7,734,766
Kernel

Kernel

8,192 blocks

3,948,014
BL2

BL2

512 blocks

3,948,526

8,192 blocks

7,742,958

512 blocks

7,743,470
BL1

BL1
16 blocks

3,958,542

3,958,544

16 blocks

7,743,486

Last
2 blocks
1 Block = 512 bytes

7,744,488
7,744,512

Last
Skipped

2 blocks
1,024 blocks
1 Block = 512 bytes
Screenshot (boot from 2G SD)
2 GB SD
2,021,654,528 bytes
3,958,544 blocks

File System

2GB SD
3,939,822
Kernel

8,192 blocks

3,948,014
BL2

512 blocks

3,948,526
BL1

16 blocks

3,958,542

3,958,544

Last
2 blocks
1 Block = 512 bytes
Screenshot (boot from 4G SD)
4 GB SDHC
3,965,190,144 bytes
7,744,512 blocks

File System

4GB SD
7,734,766
Kernel

8,192 blocks

7,742,958
BL2

512 blocks

7,743,470
BL1

16 blocks

7,743,486
7,744,488
7,744,512

Last
Skipped

2 blocks
1,024 blocks
1 Block = 512 bytes
smdk6410.h
Bootloaderu-bootincludeconfigssmdk6410.h
/***********************************************************
* Command definition
***********************************************************/
#define CONFIG_COMMANDS

(CONFIG_CMD_DFL
| 
CFG_CMD_CACHE
| 
CFG_CMD_USB
| 
CFG_CMD_REGINFO
| 
Add CFG_CMD_MOVINAND
CFG_CMD_LOADS
| 
CFG_CMD_LOADB
| 
to make u-boot supports
CFG_CMD_ENV
| 
movinand (SD/MMC)
CFG_CMD_NAND
| 
CFG_CMD_MOVINAND
| 
CFG_CMD_RUN
| 
CFG_CMD_DATE
| 
CFG_CMD_PING
| 
CFG_CMD_ELF)

& ~(CFG_CMD_AUTOSCRIPT
| 
CFG_CMD_BOOTD
| 
CFG_CMD_IMI
| 
CFG_CMD_CONSOLE | 
0)
smdk6410.h

(cont.)

Bootloaderu-bootincludeconfigssmdk6410.h
/* Boot configuration (define only one of next 3) */
//#define CONFIG_BOOT_NOR
// #define CONFIG_BOOT_NAND
Make u-boot boots from
#define CONFIG_BOOT_MOVINAND
movinand
//#define CONFIG_BOOT_ONENAND
//#define CONFIG_BOOT_ONENAND_IROM

#define CONFIG_NAND
//#define CONFIG_ONENAND
#define CONFIG_MOVINAND
//#define CONFIG_MMC
//#define CONFIG_MMC_S3C
//#define CFG_MMC_BASE
//#define CFG_MMC_BASE

1
1
0xff000000
0xf0000000

bootcmd setting
#elif defined(CONFIG_BOOT_MOVINAND)
#define CFG_ENV_IS_IN_MOVINAND
#define CONFIG_BOOTCOMMAND "movi read zImage c0008000;bootm c0008000"
movi.h
Bootloaderu-bootincludemovi.h
#if defined(CONFIG_S3C2450) || defined(CONFIG_S3C2416)
#define HSMMC_CHANNEL
1
Define HSMMC_CHANNEL
#else
#define HSMMC_CHANNEL
1
//0-->TF 1--> SD
#endif

/* offset information */
#define PART_UBOOT_OFFSET
#define PART_ZIMAGE_OFFSET
#define PART_ROOTFS_OFFSET
#define PART_EXTRA_OFFSET

/* movinand definitions */
#define MOVI_BLKSIZE

0x0
0x40000
0x440000
0x3200000

512

Offset in movinand (SD card)

**refer page 16
Block size definition
1 block = 512 bytes
movi.h

(cont.)

Bootloaderu-bootincludemovi.h
#define
#define
#define
#define

MOVI_LAST_BLKPOS
MOVI_BL1_BLKCNT
MOVI_ENV_BLKCNT
MOVI_BL2_BLKCNT

#define MOVI_ZIMAGE_BLKCNT
#define MOVI_BL2_POS
#define MOVI_ROOTFS_BLKCNT

(MOVI_TOTAL_BLKCNT - (eFUSE_SIZE / MOVI_BLKSIZE))
(SS_SIZE / MOVI_BLKSIZE)
(CFG_ENV_SIZE / MOVI_BLKSIZE)
(((PART_ZIMAGE_OFFSET - PART_UBOOT_OFFSET) /
MOVI_BLKSIZE) - MOVI_ENV_BLKCNT)
((PART_ROOTFS_OFFSET - PART_ZIMAGE_OFFSET) /
MOVI_BLKSIZE)
(MOVI_LAST_BLKPOS - MOVI_BL1_BLKCNT –
MOVI_BL2_BLKCNT - MOVI_ENV_BLKCNT)
8 * 1024 * 1024 / MOVI_BLKSIZE
//(PART_SIZE_ROOTFS / MOVI_BLKSIZE)

According to the formulas above, we can easily calculate the exact position of each
segment.
(you can check the following excel file to get more detailed information.)

**refer page 16
hs_mmc.c
Bootloaderu-bootcpus3c64xxhs_mmc.c
int hsmmc_init (void)
{
u32 reg;
uint width;

issue_command(MMC_GO_IDLE_STATE, 0x00, 0, 0);

issue_command(MMC_SEND_EXT_CSD, 0x000001AA, 0, MMC_RSP_R1);

Add this statement to initial
SDHC

/* MMC_SET_BLOCKLEN */
while (!issue_command(MMC_SET_BLOCKLEN, 512, 0, MMC_RSP_R1));
s3c_hsmmc_writew(0xffff, HM_NORINTSTS);
return 0;
}
Kernel (zImage)
Kernel Configuration
Kernel Configuration (cont.)
Kernel Configuration (cont.)
Kernel Configuration (cont.)
Environment Setting - bootcmd
setenv bootcmd “movi read zImage c0008000;bootm c0008000”
**refer page 21
File System
Environment Setting - bootargs
setenv bootargs “root=/dev/mmcblk0p2 rootfstype=ext3 rootdelay=3 init=/linuxrc
console=ttySAC0,115200”
**set bootargs at smdk6410.h
Screenshot
Note: The root file system is pre-built in SD card.
Fusing Tool
Fusing Tool
To fuse the boot loader (u-boot.bin), kernel (zImage), and file system (rootfs.tar) to
SD card automatically.
sdcard=$1
if [ "$sdcard" = "" ];then
echo " # Usage - ./sd.sh /dev/SDcardDevicename (ex. sd.sh /dev/sdc)"
echo " # prepare the necessary files(zImage,rootfs.tar,uboot.bin
rootfs.tar is a tar.bz2 file)"
echo " # and verify that the device is correct"
exit 0

.
mkdir /mnt1
mount ${sdcard}2 /mnt1
tar -jxvf rootfs.tar -C /mnt1
cp -rap /mnt/rootfs/* /mnt1
umount /mnt1
rm -rf /mnt1
How to use the fusing tool
root@Linux:~# ./sd4.sh /dev/sdc

1. Run the shell script “sd4.sh” as root.
2. Assign the block device where the SD card exists (ex. /dev/sdc).
3. The root file system has to be packed as rootfs.tar before running this shell
script.
4. The boot loader (u-boot.bin), kernel (zImage) and the file system (rootfs.tar)
must exist in the same folder.
5. The name of the files u-boot.bin, zImage, and rootfs.tar are fixed, casesensitive.
How the shell script works
step

command

1. Check the device user enters exists and make sure it is an SD card.
2. Partition the device (two partitions will be made).

fdisk

3. Format the second partition as ext3.

mkfs.ext3

4. Fuse the first 8k of u-boot.bin to the BL1 area of the SD card.

dd

5. Fuse the u-boot.bin to the BL2 area of he SD card.
(u-boot.bin has to be smaller than 256KB)

dd

6. Fuse the zImage to the kernel area of he SD card.

dd

7. Make a directory named /mnt1 as the mount point

mkdir

8. Mount the second partition (ext3) to the mount point (/mnt1).

mount

9. Extract rootfs.tar to /mnt1

Tar

10. Un-mount the mount point (/mnt1)

umount

11. Delete the mount point (/mnt1)

rm
Member Introduction
Member Introduction
Name

Education
Background

Tasks of the project

Working
Experience

Vincent Chen
(Team Leader)

Lan Yang Institute of Technology
BS. Electronics Engineering

- Kernel implement:
- MTD support
- MMC/SD card support
- Kernel logo display

- R&D Engineer
(Electric Meters)
- Field Application Engineer

Annie Cheng

Ming Hsin University of Science and
Technology
BS. In Electronic Engineering

- Hardware layout tracing for
SD/SDHC boot
- Documentation

- Senior Validation Engineer
(CPU Electrical / Margining)
- System Validation Test
Engineer

YiChin Huang

Chih Lee Institute of Technology
BS. in Information Management

- U-boot support SDHC
implement
- SD card fusing tool implement

Jason Kung

Texas A&M University - Commerce
MS. In Computer Science
MS. In Management

- U-boot support SD implement
- Kernel, File System
(ext3, readable/writable)on SD

- Field Application Engineer
(ARM Application Processor)
- Product Manager
(ARM Application Processor)
Thank You

Contenu connexe

Tendances

Uboot startup sequence
Uboot startup sequenceUboot startup sequence
Uboot startup sequence
Houcheng Lin
 
LCU14 302- How to port OP-TEE to another platform
LCU14 302- How to port OP-TEE to another platformLCU14 302- How to port OP-TEE to another platform
LCU14 302- How to port OP-TEE to another platform
Linaro
 
TEE - kernel support is now upstream. What this means for open source security
TEE - kernel support is now upstream. What this means for open source securityTEE - kernel support is now upstream. What this means for open source security
TEE - kernel support is now upstream. What this means for open source security
Linaro
 
LAS16-111: Easing Access to ARM TrustZone – OP-TEE and Raspberry Pi 3
LAS16-111: Easing Access to ARM TrustZone – OP-TEE and Raspberry Pi 3LAS16-111: Easing Access to ARM TrustZone – OP-TEE and Raspberry Pi 3
LAS16-111: Easing Access to ARM TrustZone – OP-TEE and Raspberry Pi 3
Linaro
 
U boot porting guide for SoC
U boot porting guide for SoCU boot porting guide for SoC
U boot porting guide for SoC
Macpaul Lin
 

Tendances (20)

Lcu14 107- op-tee on ar mv8
Lcu14 107- op-tee on ar mv8Lcu14 107- op-tee on ar mv8
Lcu14 107- op-tee on ar mv8
 
BKK16-110 A Gentle Introduction to Trusted Execution and OP-TEE
BKK16-110 A Gentle Introduction to Trusted Execution and OP-TEEBKK16-110 A Gentle Introduction to Trusted Execution and OP-TEE
BKK16-110 A Gentle Introduction to Trusted Execution and OP-TEE
 
ソフトウェア技術者から見たFPGAの魅力と可能性
ソフトウェア技術者から見たFPGAの魅力と可能性ソフトウェア技術者から見たFPGAの魅力と可能性
ソフトウェア技術者から見たFPGAの魅力と可能性
 
Uboot startup sequence
Uboot startup sequenceUboot startup sequence
Uboot startup sequence
 
LCU14 302- How to port OP-TEE to another platform
LCU14 302- How to port OP-TEE to another platformLCU14 302- How to port OP-TEE to another platform
LCU14 302- How to port OP-TEE to another platform
 
TEE - kernel support is now upstream. What this means for open source security
TEE - kernel support is now upstream. What this means for open source securityTEE - kernel support is now upstream. What this means for open source security
TEE - kernel support is now upstream. What this means for open source security
 
Zynq VIPを利用したテストベンチ
Zynq VIPを利用したテストベンチZynq VIPを利用したテストベンチ
Zynq VIPを利用したテストベンチ
 
Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...
Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...
Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...
 
Project ACRN hypervisor introduction
Project ACRN hypervisor introduction Project ACRN hypervisor introduction
Project ACRN hypervisor introduction
 
LAS16-111: Easing Access to ARM TrustZone – OP-TEE and Raspberry Pi 3
LAS16-111: Easing Access to ARM TrustZone – OP-TEE and Raspberry Pi 3LAS16-111: Easing Access to ARM TrustZone – OP-TEE and Raspberry Pi 3
LAS16-111: Easing Access to ARM TrustZone – OP-TEE and Raspberry Pi 3
 
HKG15-311: OP-TEE for Beginners and Porting Review
HKG15-311: OP-TEE for Beginners and Porting ReviewHKG15-311: OP-TEE for Beginners and Porting Review
HKG15-311: OP-TEE for Beginners and Porting Review
 
BKK16-205 RDK-B IoT
BKK16-205 RDK-B IoTBKK16-205 RDK-B IoT
BKK16-205 RDK-B IoT
 
仮想化技術によるマルウェア対策とその問題点
仮想化技術によるマルウェア対策とその問題点仮想化技術によるマルウェア対策とその問題点
仮想化技術によるマルウェア対策とその問題点
 
LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例
LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例
LLVM 總是打開你的心:從電玩模擬器看編譯器應用實例
 
U boot porting guide for SoC
U boot porting guide for SoCU boot porting guide for SoC
U boot porting guide for SoC
 
BKK16-504 Running Linux in EL2 Virtualization
BKK16-504 Running Linux in EL2 VirtualizationBKK16-504 Running Linux in EL2 Virtualization
BKK16-504 Running Linux in EL2 Virtualization
 
[嵌入式系統] 嵌入式系統進階
[嵌入式系統] 嵌入式系統進階[嵌入式系統] 嵌入式系統進階
[嵌入式系統] 嵌入式系統進階
 
ARM Trusted FirmwareのBL31を単体で使う!
ARM Trusted FirmwareのBL31を単体で使う!ARM Trusted FirmwareのBL31を単体で使う!
ARM Trusted FirmwareのBL31を単体で使う!
 
Building Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARMBuilding Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARM
 
Enable DPDK and SR-IOV for containerized virtual network functions with zun
Enable DPDK and SR-IOV for containerized virtual network functions with zunEnable DPDK and SR-IOV for containerized virtual network functions with zun
Enable DPDK and SR-IOV for containerized virtual network functions with zun
 

Similaire à 建構嵌入式Linux系統於SD Card

Comp 129 final exam 100% correct answers
Comp 129 final exam 100% correct answersComp 129 final exam 100% correct answers
Comp 129 final exam 100% correct answers
ProfessorLance
 
Comp 129 final exam 100% correct answers
Comp 129 final exam 100% correct answersComp 129 final exam 100% correct answers
Comp 129 final exam 100% correct answers
ProfessorLance
 
Embedded_Linux_Booting
Embedded_Linux_BootingEmbedded_Linux_Booting
Embedded_Linux_Booting
Rashila Rr
 

Similaire à 建構嵌入式Linux系統於SD Card (20)

Bringing up Android on your favorite X86 Workstation or VM (AnDevCon Boston, ...
Bringing up Android on your favorite X86 Workstation or VM (AnDevCon Boston, ...Bringing up Android on your favorite X86 Workstation or VM (AnDevCon Boston, ...
Bringing up Android on your favorite X86 Workstation or VM (AnDevCon Boston, ...
 
Comp 129 final exam 100% correct answers
Comp 129 final exam 100% correct answersComp 129 final exam 100% correct answers
Comp 129 final exam 100% correct answers
 
Comp 129 final exam 100% correct answers
Comp 129 final exam 100% correct answersComp 129 final exam 100% correct answers
Comp 129 final exam 100% correct answers
 
Bootstrap process of u boot (NDS32 RISC CPU)
Bootstrap process of u boot (NDS32 RISC CPU)Bootstrap process of u boot (NDS32 RISC CPU)
Bootstrap process of u boot (NDS32 RISC CPU)
 
U-Boot Porting on New Hardware
U-Boot Porting on New HardwareU-Boot Porting on New Hardware
U-Boot Porting on New Hardware
 
Armboot process zeelogic
Armboot process zeelogicArmboot process zeelogic
Armboot process zeelogic
 
U-Boot presentation 2013
U-Boot presentation  2013U-Boot presentation  2013
U-Boot presentation 2013
 
eMMC Embedded Multimedia Card overview
eMMC Embedded Multimedia Card overvieweMMC Embedded Multimedia Card overview
eMMC Embedded Multimedia Card overview
 
U Boot or Universal Bootloader
U Boot or Universal BootloaderU Boot or Universal Bootloader
U Boot or Universal Bootloader
 
Когда предрелизный не только софт
Когда предрелизный не только софтКогда предрелизный не только софт
Когда предрелизный не только софт
 
BeagleBone Black Booting Process
BeagleBone Black Booting ProcessBeagleBone Black Booting Process
BeagleBone Black Booting Process
 
COMPUTER HARDWARE - SHORT NOTES
COMPUTER HARDWARE - SHORT NOTESCOMPUTER HARDWARE - SHORT NOTES
COMPUTER HARDWARE - SHORT NOTES
 
BeagleBoard-xM Booting Process
BeagleBoard-xM Booting ProcessBeagleBoard-xM Booting Process
BeagleBoard-xM Booting Process
 
Embedded_Linux_Booting
Embedded_Linux_BootingEmbedded_Linux_Booting
Embedded_Linux_Booting
 
Study on Android Emulator
Study on Android EmulatorStudy on Android Emulator
Study on Android Emulator
 
HKG15-409: ARM Hibernation enablement on SoCs - a case study
HKG15-409: ARM Hibernation enablement on SoCs - a case studyHKG15-409: ARM Hibernation enablement on SoCs - a case study
HKG15-409: ARM Hibernation enablement on SoCs - a case study
 
SiteGround Tech TeamBuilding
SiteGround Tech TeamBuildingSiteGround Tech TeamBuilding
SiteGround Tech TeamBuilding
 
BeagleBone Black Bootloaders
BeagleBone Black BootloadersBeagleBone Black Bootloaders
BeagleBone Black Bootloaders
 
Introduction to Computer Hardware slides ppt
Introduction to Computer Hardware slides pptIntroduction to Computer Hardware slides ppt
Introduction to Computer Hardware slides ppt
 
101 1.1 hardware settings
101 1.1 hardware settings101 1.1 hardware settings
101 1.1 hardware settings
 

Plus de 艾鍗科技

Plus de 艾鍗科技 (20)

TinyML - 4 speech recognition
TinyML - 4 speech recognition TinyML - 4 speech recognition
TinyML - 4 speech recognition
 
Appendix 1 Goolge colab
Appendix 1 Goolge colabAppendix 1 Goolge colab
Appendix 1 Goolge colab
 
Project-IOT於餐館系統的應用
Project-IOT於餐館系統的應用Project-IOT於餐館系統的應用
Project-IOT於餐館系統的應用
 
02 IoT implementation
02 IoT implementation02 IoT implementation
02 IoT implementation
 
Tiny ML for spark Fun Edge
Tiny ML for spark Fun EdgeTiny ML for spark Fun Edge
Tiny ML for spark Fun Edge
 
Openvino ncs2
Openvino ncs2Openvino ncs2
Openvino ncs2
 
Step motor
Step motorStep motor
Step motor
 
2. 機器學習簡介
2. 機器學習簡介2. 機器學習簡介
2. 機器學習簡介
 
5.MLP(Multi-Layer Perceptron)
5.MLP(Multi-Layer Perceptron) 5.MLP(Multi-Layer Perceptron)
5.MLP(Multi-Layer Perceptron)
 
3. data features
3. data features3. data features
3. data features
 
心率血氧檢測與運動促進
心率血氧檢測與運動促進心率血氧檢測與運動促進
心率血氧檢測與運動促進
 
利用音樂&情境燈幫助放鬆
利用音樂&情境燈幫助放鬆利用音樂&情境燈幫助放鬆
利用音樂&情境燈幫助放鬆
 
IoT感測器驅動程式 在樹莓派上實作
IoT感測器驅動程式在樹莓派上實作IoT感測器驅動程式在樹莓派上實作
IoT感測器驅動程式 在樹莓派上實作
 
無線聲控遙控車
無線聲控遙控車無線聲控遙控車
無線聲控遙控車
 
最佳光源的研究和實作
最佳光源的研究和實作最佳光源的研究和實作
最佳光源的研究和實作
 
無線監控網路攝影機與控制自走車
無線監控網路攝影機與控制自走車無線監控網路攝影機與控制自走車
無線監控網路攝影機與控制自走車
 
Reinforcement Learning
Reinforcement LearningReinforcement Learning
Reinforcement Learning
 
人臉辨識考勤系統
人臉辨識考勤系統人臉辨識考勤系統
人臉辨識考勤系統
 
智慧家庭Smart Home
智慧家庭Smart Home智慧家庭Smart Home
智慧家庭Smart Home
 
智能健身
智能健身智能健身
智能健身
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Dernier (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

建構嵌入式Linux系統於SD Card

  • 1. Embedded System on SD Vincent Chen Annie Cheng YuChin Huang Jason Kung 2013-09-18
  • 2. Motivation Typically, most embedded systems load system from NAND flash on the target device. That means the boot loader, kernel and file system are fused on the NAND flash. However, in the beginning stage of implementation, the NAND flash is totally empty, which means, at least, we have to fuse boot loader into the NAND flash, and then fuse kernel and file system to bring up the system. To fuse the boot loader into NAND flash is not easy as just copy a file. We have to use specific tools like chip programmer or JTAG. Some of these tools are expensive or not easy to get. Users also need to wait patiently while programming a NAND flash because it takes time. Frequently programming NAND flash also impacts its endurance due to its physical character. Thus, if we can find a way to build a system on other external storage device, like SD card, it would be save a lot of time, cost, and even NAND flash life cycle.
  • 3. Embedded System (boot from NAND) SD I/F Boot Loader CPU Memory controller NAND flash controller Kernel Memory NAND File System
  • 4. Embedded System (SD recovery mode) SD I/F Boot Loader SD / SDHC CPU Memory controller NAND flash controller Kernel Memory NAND File System
  • 5. Embedded System (boot from SD) SD I/F Boot Loader SD / SDHC CPU Memory controller NAND flash controller Kernel Memory NAND File System
  • 6. Purpose - Build the embedded system on SD card - Loading system from SD card completely without NAND flash support. - The file system on SD card supports read and write facility. - Implement a utility to fuse boot loader, kernel and file system to SD card easily. Replace boot from NAND Load u-boot Loader Kernel Load File system File system readable / writable          
  • 7. Benefits - System is easy to recover/update just simply replace the SD card. - Cost down NAND/NOR flash become optional, not a necessary component anymore. It saves BOM cost. - Product in test stage Modify/update codes easily. - Multi-OS in one device Switch OS among different SD cards.
  • 8. Platform - DMA6410L - AP: Samsung S3C6410XH-66, 667Mhz - RAM: mDDR 128MB (64MB * 2) - Ethernet I/F: DM9000AE - Display: 4.3” TFT (480*272) - UART: UART * 1 (for debug) - SD card I/F: SD card slot * 1
  • 9. How … To achieve system on SD card, we will face the following issues, - CPU supports boot from SD card. How does it work? - An embedded system has three parts: u-boot (boot loader), kernel and file system. We have to know the exact position in SD card. - SD card has SDSC (Standard-Capacity), SDHC (High-Capacity) and SDXC (eXtended-Capacity.) Does all of them can be supported by CPU? - How to make the boot loader loads kernel and than kernel loads file system exactly?
  • 11. S3C6410 iROM booting S3C6410 ARM1176JZF-S SDRAM Controller SDRAM Booting Device (SD/MMC Card, OneNAND, Nand) Stepping Stone (8KB) iROM(BL0) (32KB) OM=iROM Boot HS-MMC Controller BL2 Kernel OneNAND Controller D-TCM (16KB) BL1 (8KB) File System NAND Controller GPN[15:13]:Booting device pin selection 1.iROM supports initial boot up Initialize system clock, D-TCM, device specific controller and booting device.
  • 12. S3C6410 iROM booting (cont.) S3C6410 ARM1176JZF-S SDRAM Controller SDRAM Booting Device (SD/MMC Card, OneNAND, Nand) Stepping Stone (8KB) iROM(BL0) (32KB) OM=iROM Boot HS-MMC Controller BL2 Kernel OneNAND Controller D-TCM (16KB) BL1 (8KB) File System NAND Controller GPN[15:13]:Booting device pin selection 2.iROM boot codes can load 8KB of boot loader to stepping stone. The 8 KB boot loader is called BL1.
  • 13. S3C6410 iROM booting (cont.) S3C6410 ARM1176JZF-S SDRAM Controller SDRAM Booting Device (SD/MMC Card, OneNAND, Nand) Stepping Stone (8KB) iROM(BL0) (32KB) OM=iROM Boot HS-MMC Controller BL2 Kernel OneNAND Controller D-TCM (16KB) BL1 (8KB) File System NAND Controller GPN[15:13]:Booting device pin selection 3.BL1 can initialize system clock, UART, and SDRAM for user. After initializing, BL1 will load the remaining boot loader called BL2 to SDRAM.
  • 14. S3C6410 iROM booting (cont.) S3C6410 ARM1176JZF-S SDRAM Controller SDRAM Booting Device (SD/MMC Card, OneNAND, Nand) Stepping Stone (8KB) iROM(BL0) (32KB) OM=iROM Boot HS-MMC Controller BL2 Kernel OneNAND Controller D-TCM (16KB) BL1 (8KB) File System NAND Controller GPN[15:13]:Booting device pin selection 4.Finally, jump to start address of BL2. That will make good environment to use system.
  • 15. SD/SDHC Device Block Assignment 1 Block = 512 bytes SD/MMC Device File System Kernel BL2 BL1 Signature Reserved (4MB) (256KB) (8KB) (512B) (512B) 8192 512 16 1 1 Last 1 Block = 512 bytes SDHC Device File System Kernel (4MB) BL2 (256KB) 8192 512 BL1 Signature (8KB) (1024B) 16 2 Skipped (512KB) 1024 Last
  • 16. For Instance … 2 GB SD 4 GB SDHC 2,021,654,528 bytes 3,958,544 blocks 3,965,190,144 bytes 7,744,512 blocks File System File System 3,939,822 7,734,766 Kernel Kernel 8,192 blocks 3,948,014 BL2 BL2 512 blocks 3,948,526 8,192 blocks 7,742,958 512 blocks 7,743,470 BL1 BL1 16 blocks 3,958,542 3,958,544 16 blocks 7,743,486 Last 2 blocks 1 Block = 512 bytes 7,744,488 7,744,512 Last Skipped 2 blocks 1,024 blocks 1 Block = 512 bytes
  • 17. Screenshot (boot from 2G SD) 2 GB SD 2,021,654,528 bytes 3,958,544 blocks File System 2GB SD 3,939,822 Kernel 8,192 blocks 3,948,014 BL2 512 blocks 3,948,526 BL1 16 blocks 3,958,542 3,958,544 Last 2 blocks 1 Block = 512 bytes
  • 18. Screenshot (boot from 4G SD) 4 GB SDHC 3,965,190,144 bytes 7,744,512 blocks File System 4GB SD 7,734,766 Kernel 8,192 blocks 7,742,958 BL2 512 blocks 7,743,470 BL1 16 blocks 7,743,486 7,744,488 7,744,512 Last Skipped 2 blocks 1,024 blocks 1 Block = 512 bytes
  • 19. smdk6410.h Bootloaderu-bootincludeconfigssmdk6410.h /*********************************************************** * Command definition ***********************************************************/ #define CONFIG_COMMANDS (CONFIG_CMD_DFL | CFG_CMD_CACHE | CFG_CMD_USB | CFG_CMD_REGINFO | Add CFG_CMD_MOVINAND CFG_CMD_LOADS | CFG_CMD_LOADB | to make u-boot supports CFG_CMD_ENV | movinand (SD/MMC) CFG_CMD_NAND | CFG_CMD_MOVINAND | CFG_CMD_RUN | CFG_CMD_DATE | CFG_CMD_PING | CFG_CMD_ELF) & ~(CFG_CMD_AUTOSCRIPT | CFG_CMD_BOOTD | CFG_CMD_IMI | CFG_CMD_CONSOLE | 0)
  • 20. smdk6410.h (cont.) Bootloaderu-bootincludeconfigssmdk6410.h /* Boot configuration (define only one of next 3) */ //#define CONFIG_BOOT_NOR // #define CONFIG_BOOT_NAND Make u-boot boots from #define CONFIG_BOOT_MOVINAND movinand //#define CONFIG_BOOT_ONENAND //#define CONFIG_BOOT_ONENAND_IROM #define CONFIG_NAND //#define CONFIG_ONENAND #define CONFIG_MOVINAND //#define CONFIG_MMC //#define CONFIG_MMC_S3C //#define CFG_MMC_BASE //#define CFG_MMC_BASE 1 1 0xff000000 0xf0000000 bootcmd setting #elif defined(CONFIG_BOOT_MOVINAND) #define CFG_ENV_IS_IN_MOVINAND #define CONFIG_BOOTCOMMAND "movi read zImage c0008000;bootm c0008000"
  • 21. movi.h Bootloaderu-bootincludemovi.h #if defined(CONFIG_S3C2450) || defined(CONFIG_S3C2416) #define HSMMC_CHANNEL 1 Define HSMMC_CHANNEL #else #define HSMMC_CHANNEL 1 //0-->TF 1--> SD #endif /* offset information */ #define PART_UBOOT_OFFSET #define PART_ZIMAGE_OFFSET #define PART_ROOTFS_OFFSET #define PART_EXTRA_OFFSET /* movinand definitions */ #define MOVI_BLKSIZE 0x0 0x40000 0x440000 0x3200000 512 Offset in movinand (SD card) **refer page 16 Block size definition 1 block = 512 bytes
  • 22. movi.h (cont.) Bootloaderu-bootincludemovi.h #define #define #define #define MOVI_LAST_BLKPOS MOVI_BL1_BLKCNT MOVI_ENV_BLKCNT MOVI_BL2_BLKCNT #define MOVI_ZIMAGE_BLKCNT #define MOVI_BL2_POS #define MOVI_ROOTFS_BLKCNT (MOVI_TOTAL_BLKCNT - (eFUSE_SIZE / MOVI_BLKSIZE)) (SS_SIZE / MOVI_BLKSIZE) (CFG_ENV_SIZE / MOVI_BLKSIZE) (((PART_ZIMAGE_OFFSET - PART_UBOOT_OFFSET) / MOVI_BLKSIZE) - MOVI_ENV_BLKCNT) ((PART_ROOTFS_OFFSET - PART_ZIMAGE_OFFSET) / MOVI_BLKSIZE) (MOVI_LAST_BLKPOS - MOVI_BL1_BLKCNT – MOVI_BL2_BLKCNT - MOVI_ENV_BLKCNT) 8 * 1024 * 1024 / MOVI_BLKSIZE //(PART_SIZE_ROOTFS / MOVI_BLKSIZE) According to the formulas above, we can easily calculate the exact position of each segment. (you can check the following excel file to get more detailed information.) **refer page 16
  • 23. hs_mmc.c Bootloaderu-bootcpus3c64xxhs_mmc.c int hsmmc_init (void) { u32 reg; uint width; issue_command(MMC_GO_IDLE_STATE, 0x00, 0, 0); issue_command(MMC_SEND_EXT_CSD, 0x000001AA, 0, MMC_RSP_R1); Add this statement to initial SDHC /* MMC_SET_BLOCKLEN */ while (!issue_command(MMC_SET_BLOCKLEN, 512, 0, MMC_RSP_R1)); s3c_hsmmc_writew(0xffff, HM_NORINTSTS); return 0; }
  • 29. Environment Setting - bootcmd setenv bootcmd “movi read zImage c0008000;bootm c0008000” **refer page 21
  • 31. Environment Setting - bootargs setenv bootargs “root=/dev/mmcblk0p2 rootfstype=ext3 rootdelay=3 init=/linuxrc console=ttySAC0,115200” **set bootargs at smdk6410.h
  • 32. Screenshot Note: The root file system is pre-built in SD card.
  • 34. Fusing Tool To fuse the boot loader (u-boot.bin), kernel (zImage), and file system (rootfs.tar) to SD card automatically. sdcard=$1 if [ "$sdcard" = "" ];then echo " # Usage - ./sd.sh /dev/SDcardDevicename (ex. sd.sh /dev/sdc)" echo " # prepare the necessary files(zImage,rootfs.tar,uboot.bin rootfs.tar is a tar.bz2 file)" echo " # and verify that the device is correct" exit 0 . mkdir /mnt1 mount ${sdcard}2 /mnt1 tar -jxvf rootfs.tar -C /mnt1 cp -rap /mnt/rootfs/* /mnt1 umount /mnt1 rm -rf /mnt1
  • 35. How to use the fusing tool root@Linux:~# ./sd4.sh /dev/sdc 1. Run the shell script “sd4.sh” as root. 2. Assign the block device where the SD card exists (ex. /dev/sdc). 3. The root file system has to be packed as rootfs.tar before running this shell script. 4. The boot loader (u-boot.bin), kernel (zImage) and the file system (rootfs.tar) must exist in the same folder. 5. The name of the files u-boot.bin, zImage, and rootfs.tar are fixed, casesensitive.
  • 36. How the shell script works step command 1. Check the device user enters exists and make sure it is an SD card. 2. Partition the device (two partitions will be made). fdisk 3. Format the second partition as ext3. mkfs.ext3 4. Fuse the first 8k of u-boot.bin to the BL1 area of the SD card. dd 5. Fuse the u-boot.bin to the BL2 area of he SD card. (u-boot.bin has to be smaller than 256KB) dd 6. Fuse the zImage to the kernel area of he SD card. dd 7. Make a directory named /mnt1 as the mount point mkdir 8. Mount the second partition (ext3) to the mount point (/mnt1). mount 9. Extract rootfs.tar to /mnt1 Tar 10. Un-mount the mount point (/mnt1) umount 11. Delete the mount point (/mnt1) rm
  • 38. Member Introduction Name Education Background Tasks of the project Working Experience Vincent Chen (Team Leader) Lan Yang Institute of Technology BS. Electronics Engineering - Kernel implement: - MTD support - MMC/SD card support - Kernel logo display - R&D Engineer (Electric Meters) - Field Application Engineer Annie Cheng Ming Hsin University of Science and Technology BS. In Electronic Engineering - Hardware layout tracing for SD/SDHC boot - Documentation - Senior Validation Engineer (CPU Electrical / Margining) - System Validation Test Engineer YiChin Huang Chih Lee Institute of Technology BS. in Information Management - U-boot support SDHC implement - SD card fusing tool implement Jason Kung Texas A&M University - Commerce MS. In Computer Science MS. In Management - U-boot support SD implement - Kernel, File System (ext3, readable/writable)on SD - Field Application Engineer (ARM Application Processor) - Product Manager (ARM Application Processor)