SlideShare a Scribd company logo
Embedded Linux BSP
U-Boot Porting
Organised & Supported by RuggedBOARD
Agenda
• U-BOOT Architecture
• U-BOOT Code Flow
• U-BOOT Porting on new Hardware
• U-BOOT Compilation & Flashing on RB-A5D2x (P)
• U-BOOT Commands (P)
• Adding new commands in U-BOOT (P)
• Custom Driver in U-BOOT (P)
Embedded Systems Classification
MCU Based
Very Low Power
Small Code (KB’s)
Baremetal
Small RTOS
MPU Based
High Speed (200MHz till 1GHz)
OS + Application Code
MPU+ Based
Special Co-Processors
Very High Computation Power
Special Hardware Accelerator
Engines like TPU, VPU, GPU’s
S1.0 S2.0 S3.0
Mostly uses Cortex-M4
having BLE comm and few
sensors need companion
mobile
Mostly uses Cortex-A7, 4G
comm friendly UI, make
calls, check emails etc …
Mostly uses Cortex-53, 4G
and advance AI/ML
capabilities to process the
data on-device and generate
analytics & feedback
RootFS
Toolchain
eLinux System ARCH
System Hardware
Processor Blueprint, defines IS & other hardware blocks of Processor
Processor design in VHDL / Verilog having ALU, Registors, TCU, Buses …
Product = SBC + Software + Housing/Mechanicals
Silicon with Processor & peripherals like GPIO, UART, I2C, SPI, USB,
Ethernet …
SOM = SOC+ RAM + Flash + PMIC, SBC = Board with SOM & interfacing
devices like LCD, Connectors, Sensors & Communication modules
Gateway RuggedBOARD
phyCORE-
A5D2x
ATMEL
SAMA5D7
ARM CORTEX-
A5
armV7a
RuggedBOARD
Industrial Grade Hardware for IIoT
https://Community.ruggedboard.com
Bootloader
Boot Process
ON PC:
Power On-> BIOS (POST, Bootstraploader) -> MBR -> Bootloader -> Kernel -> RFS
ON RuggedBOARD:
1. Power On SBC
2. SOC BootROM Code will exec
3. BootCFG Pins will define the bootdevice ( NAND, NOR, SDCARD ..... )
4. From Bootdevice first piece of code (PBL) loaded in SRAM and executed
5. PBL responsible for External RAM Init and loads the BL to External RAM and execute.
6. BL will load the kernel and executes
7. Kernel boots and mounts the RootFS and finally executes the init binary
8. Init will follow init rc scripts to start services and applications
Boot Process
Flash Memory
Main Memory / DDR
SOC (SAMA5D27)
AT91 Bootstrap
U-Boot
Kernel
Mounts on
/
Kernel
U-Boot
AT91 Bootstrap
Device Tree Bin(DTB)Device Tree Bin(DTB)
Root FS
SRAM
BOOTROM
U-BOOT Source
Browse Source: https://github.com/rugged-board/uboot-rba5d2x
Download U-Boot for RuggedBOARD
$ wget https://github.com/rugged-board/uboot-rba5d2x/archive/uboot-rba5d2x.zip
Or
$ git clone https://github.com/rugged-board/uboot-rba5d2x.git
U-BOOT Dir Structure
uboot/board/atmel/rugged_board_a5d2x Board directory contains board files with syntax <vendor>/<boardname>
boardname.c called board file.
uboot/arch/arm/dts device tree directory consists of device tree files for SOC, SOM, SBC
sama5d2.dsi , rb_a5d2x.dtsi, rugged_board_a5d2x.dts
uboot/arch/arm/mach-at91 SOC specific code, armv7/sama5d2_devices.c
uboot/arch/arm/cpu Arch & Core specific code, u-boot.lds armv7/start.S, cpu.c
uboot/configs Contains board default configuration file used to configure uboot for a
specific board. <boardname_defconfig> for ruggedboard we have two
files for NOR: rugged_board_a5d2x_qspiflash_defconfig & for
SDCARD: rugged_board_a5d2x_mmc1_defconfig
uboot/drivers Contains bus drivers & device drivers (gpio, serial, i2c, spi, mmc, usb, net)
at91_gpio.c, atmel_usart.c, at91_i2c.c, atmel_sdhci.c, atmel_spi/qspi.c,
at91_emac.c
Device Driver: rtc/ds1307.c, misc/i2c_eeprom.c …
U-BOOT Code Flow
board_init_f()
- initf_bootstage /* uses its own timer,so doesn’t need DM */
- arch_cpu_init /* basic arch cpu dependent setup */
- mach_cpu_init /* SoC/machine dependent CPU setup */
- get_clocks /* get CPU and bus clocks (etc.) */
- timer_init /* initialize timer */
- env_init /* initialize environment */
- init_baud_rate /* initialze baudrate settings */
- serial_init /* serial communications setup */
- console_init_f /* stage 1 init of console */
- dram_init /* configure available RAM banks */
U-BOOT Code Flow
board_init_r()
- board_init /* Setup chipselects */
- set_cpu_clk_info /* Setup clock information */
- initr_nand /* initialize flash */
- initr_mmc /* initialize fmmc */
- console_init_r /* fully init console as a device */
- arch_misc_init /* miscellaneous arch-dependent init */
- misc_init_r /* misc platform-dependent init */
- interrupt_init /*set up exceptions */
- initr_enable_interrupts /* enable exceptions */
- initr_ethaddr /* setup ethernet */
- board_late_init /* board late initialization */
- run_main_loop /* jump to main loop & waiting for commands from console */
U-BOOT Code Flow
U-BOOT Porting
1. Identify the ARCH, CORE & SOC used in your board
2. Check the ARCH & Core support in u-boot location /arch/arm/cpu
3. Check the SOC support location uboot/arch/arm/mach-<soc_family>
4. Create new board folder in u-boot/boards/<board_name>
5. Take ref of existing boards in uboot and develop the code for your board
Add board.c, modify Kconfig & Makefile
6. Create a default configuration file for your board in u-boot/configs
7. Driver level modification if required u-boot/drivers/
8. Make sure you did modified Makfiles corresponding to your code/file changes.
U-boot Compilation
Browse Source: https://github.com/rugged-board/uboot-rba5d2x
Compiling U-Boot for RuggedBOARD
#Set the toolchain path first
$ . env_setup.sh
# Download uboot Source
$ git clone https://github.com/rugged-board/uboot-rba5d2x.git
$ cd uboot-rba5d2x
$ git checkout origin/uboot-rba5d2x
# Compile u-boot bootloader
make
# Configure u-boot bootloader for RB-A5D2x
$ make rugged_board_a5d2x_mmc1_defconfig # For SD Card
Or
$ make rugged_board_a5d2x_qspiflash_defconfig # For NOR Boot
#Configure for RuggedBOARD-A5D2x
$ source sources/poky/oe-init-build-env
$ vi conf/local.conf
# Edit MACHINE ?= "rugged-board-a5d2x-sd1“
U-boot compiling using Yocto
#Compile
$ bitbake u-boot
#Images for NOR
$ cd tmp/deploy/images/rugged-board-a5d2x/
#Follow NOR Flashing Tutorial..
U-boot Flashing on RB-A5D2x (SDCARD)
# Power on board and stop at bootlaoder prompt
#check mmc card info
u-boot$ mmcinfo
# init serial flash
u-boot$ sf probe
#copy uboot image from mmc to RAM
u-boot$ fatload mmc 1 0x21FF0000 NOR/u-boot.bin
#erase serial flash(NOR) u-boot partition
u-boot$ sf erase 0x20000 0x80000
# copy from uboot image from RAM to NOR Flash
u-boot$ sf write 0x21FF0000 0x20000 0x80000.
U-boot Flashing on RB-A5D2x (TFTP)
# Power on board and stop at bootlaoder prompt
#check network connection by pining host PC
u-boot$ ping <serverip>
# Download uboot image from PC to Board RAM
u-boot$ tftp 0x21FF0000 u-boot.bin
#erase serial flash(NOR) u-boot partition
u-boot$ sf erase 0x20000 0x80000
# copy from uboot image from RAM to NOR Flash
u-boot$ sf write 0x21FF0000 0x20000 0x80000
U-boot Flashing on RB-A5D2x (Serial)
# Power on board in serial download mode by pressing the boot switch
U-Boot Commands
Information Commands
help print online help
bdinfo print Board Info structure
coninfo print console devices and information
flinfo print FLASH memory information
Environment Variables Commands
env environment handling commands
printenv print environment variables
setenv set environment variables
editenv edit environment variable
saveenv save environment variables to persistent storage
Basic Commands
version print monitor version
echo echo arguments to console
reset perform RESET of the CPU
sleep delay execution for some time
cls Clear screen
Memory Commands
mtest simple RAM test
md echo arguments to console
mm memory modify (auto incrementing)
mw memory write (fill)
nm memory modify (constant address)
base print or set address offset
crc32 checksum calculation
cp memory copy
Download & BOOT Commands
loadb load binary file over serial line (kermit mode)
loady load binary file over serial line (ymodem mode)
loads load S-Record file over serial line
Ping send ICMP ECHO REQUEST to network host
bootp boot image via network using BOOTP/TFTP
protocol
dhcp invoke DHCP client to obtain IP/boot params
tftpboot boot image via network using TFTP protocol
nfs boot image via network using NFS protocol
boot boot default, i.e., run 'bootcmd'
bootm boot application image from memory
Nboot boot from NAND device
go start application at address 'addr'
fatload load binary file from a FAT file system
Ext2load load binary file from a Ext2 filesystem
HW Subsytem
gpio manipulate gpios
i2c I2C sub-system control
mmc MMC sub system
usb USB sub-system control
ftd flattened device tree utility commands
mtdparts define flash/nand partitions
eeprom EEPROM sub-system control
nand NAND sub-system control
flinfo print FLASH memory information
erase erase FLASH memory
sf Serial Flash sub-system
U-Boot Commands
Adding new command in U-Boot
U_BOOT_CMD() is the Macro used to add new command in u-boot.
name: is the name of the command. THIS IS NOT a string.
maxargs: the maximum numbers of arguments this function takes
command: Command implementation Function pointer (*cmd)(struct cmd_tbl_s *, int, int, char *[]);
Usage: Short description. This is a string
help: long description. This is a string
U_BOOT_CMD(name, maxargs, repeatable, command, "usage", "help")
Command Function Prototype:
cmdtp – Command table pointer (function vector table)
flag -- Unused
argc -- Argument count, including command name itself
argv[] -- Array of arguments (string).
int do_funcname (cmd_tbl_t *cmdtp, int flag, int argc, char *const Argv[] )
Step-2: Modify Kconfig file under command folder
$vim Kconfig
Step-1 : create demo.c in u-boot/command folder
$ cd <uboot_path>/command
$ vim dummy.c
Adding new command in U-Boot
#include<common.h>
#include<command.h>
static int do_dummy(cmd_tbl_t *cmdtp, int flag, int argc,
char * const argv[])
{
printf("Hello Rugged Board A5d2xn");
printf("This is dummy command implementationn");
return 0;
}
U_BOOT_CMD(dummy, 2, 1, do_dummy, "testing
hello","arg1 not needed");
config CMD_DUMMY
bool “Dummy Command"
default y
help
This is testing the new command in rugged board..
Step-4: Compile & Flash
Step-5: Test the command on Target Bootloader prompt
=> hello
Hello Rugged Board A5d2x
This is dummy command implementation
Step-3: Modify Makefile
$vim Makefile // bootloader/uboot-rba5d2x/cmd
obj-$(CONFIG_CMD_DUMMY) += dummy.o
Adding new Driver in U-Boot
#Step-1: Define your device in dts file
$ vim <uboot_path>/arch/arm/dts/rugged_board_a5d2x.dts
leds {
compatible = "sled-testing";
status = "okay";
UserLed {
label = "UserLed";
sled-default-state = "blink";
};
};
# Step-2: Define your driver sled.c in uboot/driver folder
$ vim <uboot_path>/driver/led/sled.c
# copy the sled.c code
# Step-3: Add sled configuration in Kconfig file
$ vim <uboot_path>/driver/led/Kconfig
config SLED
bool "SLED support for LEDs"
depends on LED
help
Sled driver on RuggedBOARD-A5D2x
# Step-4: Add sled configuration in Kconfig file
$ vim <uboot_path>/driver/led/Makefile
obj-$(CONFIG_SLED) += sled.o
# Step-5: Write a test code cmd_sled.c under
command folder and which calls the driver functions
$ vim <uboot_path>/command/cmd_sled.c
#implement do_sled() & register using U_BOOT_CMD
Driver Code Flow
File Description
u-boot/driver/gpio/at91_gpio.c Atmel GPIO Driver core bus driver
u-boot/driver/gpio/gpio-uclass.c U-Boot GPIO Subsystem HAL
u-boot/driver/led/sled.c Sled device driver which used gpio bus driver
u-boot/command/sled_cmd.c Test app / command implemented to test sled driver
Demo’s
Next Sessions
1. Linux Kernel Porting using RuggedBOARD-A5D2x
a. Source Code walkthrough & Code flow
b. Kconfig Kernel Configuration System
c. Adding Custom driver
2. Yocto BSP using RuggedBOARD-A5D2x
3. Design your own Single Board Computer using phyCORE-A5D2x. [HW Design]
4. Building Gateway Hardware and Open Source Linux Stacks for Gateway. [HW Design]
To get update’s follow RuggedBOARD on LinkedIn, Youtube, Twitter, Facebook &
Instagram links are on next slide …
Connect-us
Open Discussions
B Vasu Dev
ABOUT Vasu
Vasu has 15+ Years of industry experience in Embedded Technologies mainly on ARM & Linux, he
has worked at major MNC’s like LG, Wipro, MIC Electronics and is currently heading PHYTEC INDA,
a subsidiary of PHYTEC Messtechnik GmbH GERMANY as Managing Director. PHYTEC serves as
OEM for many electronic and embedded companies to develop and deploy their products at the
lowest possible time with high reliability and quality using ARM based SOMs (System On Modules )
& SBCs (Single Board Computers). The industry verticals he was engaged are Industrial
Automation, Mobility & Energy, Medical/Healthcare, Retail market.
Apart from his technical work, he is an active coach & guide for Embedded developers and actively
spend his time to train the developers on Embedded Linux, Yocto, IoT, Android System
Development. He is the master mind behind RuggedBOARD Open Source Hardware Platform. Vasu
as a mentor helped many start-ups to build their products and position them in market.
Managing Director
PHYTEC Embedded Pvt Ltd
vasu.b@phytec.in
+91-9535504414
Presenter Profile
U-Boot Porting on New Hardware

More Related Content

PDF
Uboot startup sequence
PDF
U-Boot - An universal bootloader
PDF
Embedded Linux BSP Training (Intro)
PPTX
Bootloaders (U-Boot)
PPT
U boot porting guide for SoC
PPT
linux device driver
PDF
Arm device tree and linux device drivers
PPTX
Linux Device Tree
Uboot startup sequence
U-Boot - An universal bootloader
Embedded Linux BSP Training (Intro)
Bootloaders (U-Boot)
U boot porting guide for SoC
linux device driver
Arm device tree and linux device drivers
Linux Device Tree

What's hot (20)

PPTX
U-Boot presentation 2013
PDF
BusyBox for Embedded Linux
PDF
Jagan Teki - U-boot from scratch
PPTX
Linux Initialization Process (2)
PPT
U Boot or Universal Bootloader
PPTX
Linux device drivers
PPTX
Linux Kernel Booting Process (1) - For NLKB
PPT
Process scheduling linux
PDF
Introduction to Modern U-Boot
PDF
Embedded_Linux_Booting
PDF
PDF
Kdump and the kernel crash dump analysis
PDF
PDF
Part 02 Linux Kernel Module Programming
PPTX
QEMU - Binary Translation
PDF
Device Tree for Dummies (ELC 2014)
PDF
Embedded Linux Kernel - Build your custom kernel
PDF
I2c drivers
PDF
Vmlinux: anatomy of bzimage and how x86 64 processor is booted
PDF
Video Drivers
U-Boot presentation 2013
BusyBox for Embedded Linux
Jagan Teki - U-boot from scratch
Linux Initialization Process (2)
U Boot or Universal Bootloader
Linux device drivers
Linux Kernel Booting Process (1) - For NLKB
Process scheduling linux
Introduction to Modern U-Boot
Embedded_Linux_Booting
Kdump and the kernel crash dump analysis
Part 02 Linux Kernel Module Programming
QEMU - Binary Translation
Device Tree for Dummies (ELC 2014)
Embedded Linux Kernel - Build your custom kernel
I2c drivers
Vmlinux: anatomy of bzimage and how x86 64 processor is booted
Video Drivers
Ad

Similar to U-Boot Porting on New Hardware (20)

PPT
PDF
Armboot process zeelogic
PDF
Masters porting linux
PDF
BeagleBoard-xM Booting Process
PPT
How to build and load linux to embedded system
PDF
BeagleBone Black Bootloaders
PDF
Details on Bootloaders in Embedded LInux
PDF
Embedded platform choices
PDF
Elc Europe 2020 : u-boot- porting and maintaining a bootloader for a multimed...
PPTX
Embedded Fest 2019. Игорь Опанюк. Das U-boot v2019: a look under the hood
PPTX
BSP.pptx
PDF
Building
PDF
BeagleBone Black Booting Process
PPTX
System Booting Process overview
PPT
Bootstrap process boot loader
PDF
Let's trace Linux Lernel with KGDB @ COSCUP 2021
PPTX
TeksunLab Pegasus Program Details 2014
PPTX
Open Enea Linux workshop at the Embedded Conference Scandinavia 2014
PDF
CONFidence 2017: Hacking embedded with OpenWrt (Vladimir Mitiouchev)
PDF
Linux Porting to a Custom Board
Armboot process zeelogic
Masters porting linux
BeagleBoard-xM Booting Process
How to build and load linux to embedded system
BeagleBone Black Bootloaders
Details on Bootloaders in Embedded LInux
Embedded platform choices
Elc Europe 2020 : u-boot- porting and maintaining a bootloader for a multimed...
Embedded Fest 2019. Игорь Опанюк. Das U-boot v2019: a look under the hood
BSP.pptx
Building
BeagleBone Black Booting Process
System Booting Process overview
Bootstrap process boot loader
Let's trace Linux Lernel with KGDB @ COSCUP 2021
TeksunLab Pegasus Program Details 2014
Open Enea Linux workshop at the Embedded Conference Scandinavia 2014
CONFidence 2017: Hacking embedded with OpenWrt (Vladimir Mitiouchev)
Linux Porting to a Custom Board
Ad

Recently uploaded (20)

PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Big Data Technologies - Introduction.pptx
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Electronic commerce courselecture one. Pdf
PDF
Encapsulation theory and applications.pdf
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
KodekX | Application Modernization Development
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
DOCX
The AUB Centre for AI in Media Proposal.docx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
NewMind AI Weekly Chronicles - August'25 Week I
Network Security Unit 5.pdf for BCA BBA.
Chapter 3 Spatial Domain Image Processing.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Empathic Computing: Creating Shared Understanding
Big Data Technologies - Introduction.pptx
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Digital-Transformation-Roadmap-for-Companies.pptx
Unlocking AI with Model Context Protocol (MCP)
Electronic commerce courselecture one. Pdf
Encapsulation theory and applications.pdf
NewMind AI Monthly Chronicles - July 2025
Spectral efficient network and resource selection model in 5G networks
Reach Out and Touch Someone: Haptics and Empathic Computing
KodekX | Application Modernization Development
Dropbox Q2 2025 Financial Results & Investor Presentation
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
The AUB Centre for AI in Media Proposal.docx

U-Boot Porting on New Hardware

  • 1. Embedded Linux BSP U-Boot Porting Organised & Supported by RuggedBOARD
  • 2. Agenda • U-BOOT Architecture • U-BOOT Code Flow • U-BOOT Porting on new Hardware • U-BOOT Compilation & Flashing on RB-A5D2x (P) • U-BOOT Commands (P) • Adding new commands in U-BOOT (P) • Custom Driver in U-BOOT (P)
  • 3. Embedded Systems Classification MCU Based Very Low Power Small Code (KB’s) Baremetal Small RTOS MPU Based High Speed (200MHz till 1GHz) OS + Application Code MPU+ Based Special Co-Processors Very High Computation Power Special Hardware Accelerator Engines like TPU, VPU, GPU’s S1.0 S2.0 S3.0 Mostly uses Cortex-M4 having BLE comm and few sensors need companion mobile Mostly uses Cortex-A7, 4G comm friendly UI, make calls, check emails etc … Mostly uses Cortex-53, 4G and advance AI/ML capabilities to process the data on-device and generate analytics & feedback
  • 5. System Hardware Processor Blueprint, defines IS & other hardware blocks of Processor Processor design in VHDL / Verilog having ALU, Registors, TCU, Buses … Product = SBC + Software + Housing/Mechanicals Silicon with Processor & peripherals like GPIO, UART, I2C, SPI, USB, Ethernet … SOM = SOC+ RAM + Flash + PMIC, SBC = Board with SOM & interfacing devices like LCD, Connectors, Sensors & Communication modules Gateway RuggedBOARD phyCORE- A5D2x ATMEL SAMA5D7 ARM CORTEX- A5 armV7a
  • 6. RuggedBOARD Industrial Grade Hardware for IIoT https://Community.ruggedboard.com
  • 7. Bootloader Boot Process ON PC: Power On-> BIOS (POST, Bootstraploader) -> MBR -> Bootloader -> Kernel -> RFS ON RuggedBOARD: 1. Power On SBC 2. SOC BootROM Code will exec 3. BootCFG Pins will define the bootdevice ( NAND, NOR, SDCARD ..... ) 4. From Bootdevice first piece of code (PBL) loaded in SRAM and executed 5. PBL responsible for External RAM Init and loads the BL to External RAM and execute. 6. BL will load the kernel and executes 7. Kernel boots and mounts the RootFS and finally executes the init binary 8. Init will follow init rc scripts to start services and applications
  • 8. Boot Process Flash Memory Main Memory / DDR SOC (SAMA5D27) AT91 Bootstrap U-Boot Kernel Mounts on / Kernel U-Boot AT91 Bootstrap Device Tree Bin(DTB)Device Tree Bin(DTB) Root FS SRAM BOOTROM
  • 9. U-BOOT Source Browse Source: https://github.com/rugged-board/uboot-rba5d2x Download U-Boot for RuggedBOARD $ wget https://github.com/rugged-board/uboot-rba5d2x/archive/uboot-rba5d2x.zip Or $ git clone https://github.com/rugged-board/uboot-rba5d2x.git
  • 10. U-BOOT Dir Structure uboot/board/atmel/rugged_board_a5d2x Board directory contains board files with syntax <vendor>/<boardname> boardname.c called board file. uboot/arch/arm/dts device tree directory consists of device tree files for SOC, SOM, SBC sama5d2.dsi , rb_a5d2x.dtsi, rugged_board_a5d2x.dts uboot/arch/arm/mach-at91 SOC specific code, armv7/sama5d2_devices.c uboot/arch/arm/cpu Arch & Core specific code, u-boot.lds armv7/start.S, cpu.c uboot/configs Contains board default configuration file used to configure uboot for a specific board. <boardname_defconfig> for ruggedboard we have two files for NOR: rugged_board_a5d2x_qspiflash_defconfig & for SDCARD: rugged_board_a5d2x_mmc1_defconfig uboot/drivers Contains bus drivers & device drivers (gpio, serial, i2c, spi, mmc, usb, net) at91_gpio.c, atmel_usart.c, at91_i2c.c, atmel_sdhci.c, atmel_spi/qspi.c, at91_emac.c Device Driver: rtc/ds1307.c, misc/i2c_eeprom.c …
  • 12. board_init_f() - initf_bootstage /* uses its own timer,so doesn’t need DM */ - arch_cpu_init /* basic arch cpu dependent setup */ - mach_cpu_init /* SoC/machine dependent CPU setup */ - get_clocks /* get CPU and bus clocks (etc.) */ - timer_init /* initialize timer */ - env_init /* initialize environment */ - init_baud_rate /* initialze baudrate settings */ - serial_init /* serial communications setup */ - console_init_f /* stage 1 init of console */ - dram_init /* configure available RAM banks */ U-BOOT Code Flow
  • 13. board_init_r() - board_init /* Setup chipselects */ - set_cpu_clk_info /* Setup clock information */ - initr_nand /* initialize flash */ - initr_mmc /* initialize fmmc */ - console_init_r /* fully init console as a device */ - arch_misc_init /* miscellaneous arch-dependent init */ - misc_init_r /* misc platform-dependent init */ - interrupt_init /*set up exceptions */ - initr_enable_interrupts /* enable exceptions */ - initr_ethaddr /* setup ethernet */ - board_late_init /* board late initialization */ - run_main_loop /* jump to main loop & waiting for commands from console */ U-BOOT Code Flow
  • 14. U-BOOT Porting 1. Identify the ARCH, CORE & SOC used in your board 2. Check the ARCH & Core support in u-boot location /arch/arm/cpu 3. Check the SOC support location uboot/arch/arm/mach-<soc_family> 4. Create new board folder in u-boot/boards/<board_name> 5. Take ref of existing boards in uboot and develop the code for your board Add board.c, modify Kconfig & Makefile 6. Create a default configuration file for your board in u-boot/configs 7. Driver level modification if required u-boot/drivers/ 8. Make sure you did modified Makfiles corresponding to your code/file changes.
  • 15. U-boot Compilation Browse Source: https://github.com/rugged-board/uboot-rba5d2x Compiling U-Boot for RuggedBOARD #Set the toolchain path first $ . env_setup.sh # Download uboot Source $ git clone https://github.com/rugged-board/uboot-rba5d2x.git $ cd uboot-rba5d2x $ git checkout origin/uboot-rba5d2x # Compile u-boot bootloader make # Configure u-boot bootloader for RB-A5D2x $ make rugged_board_a5d2x_mmc1_defconfig # For SD Card Or $ make rugged_board_a5d2x_qspiflash_defconfig # For NOR Boot
  • 16. #Configure for RuggedBOARD-A5D2x $ source sources/poky/oe-init-build-env $ vi conf/local.conf # Edit MACHINE ?= "rugged-board-a5d2x-sd1“ U-boot compiling using Yocto #Compile $ bitbake u-boot #Images for NOR $ cd tmp/deploy/images/rugged-board-a5d2x/ #Follow NOR Flashing Tutorial..
  • 17. U-boot Flashing on RB-A5D2x (SDCARD) # Power on board and stop at bootlaoder prompt #check mmc card info u-boot$ mmcinfo # init serial flash u-boot$ sf probe #copy uboot image from mmc to RAM u-boot$ fatload mmc 1 0x21FF0000 NOR/u-boot.bin #erase serial flash(NOR) u-boot partition u-boot$ sf erase 0x20000 0x80000 # copy from uboot image from RAM to NOR Flash u-boot$ sf write 0x21FF0000 0x20000 0x80000.
  • 18. U-boot Flashing on RB-A5D2x (TFTP) # Power on board and stop at bootlaoder prompt #check network connection by pining host PC u-boot$ ping <serverip> # Download uboot image from PC to Board RAM u-boot$ tftp 0x21FF0000 u-boot.bin #erase serial flash(NOR) u-boot partition u-boot$ sf erase 0x20000 0x80000 # copy from uboot image from RAM to NOR Flash u-boot$ sf write 0x21FF0000 0x20000 0x80000
  • 19. U-boot Flashing on RB-A5D2x (Serial) # Power on board in serial download mode by pressing the boot switch
  • 20. U-Boot Commands Information Commands help print online help bdinfo print Board Info structure coninfo print console devices and information flinfo print FLASH memory information Environment Variables Commands env environment handling commands printenv print environment variables setenv set environment variables editenv edit environment variable saveenv save environment variables to persistent storage Basic Commands version print monitor version echo echo arguments to console reset perform RESET of the CPU sleep delay execution for some time cls Clear screen Memory Commands mtest simple RAM test md echo arguments to console mm memory modify (auto incrementing) mw memory write (fill) nm memory modify (constant address) base print or set address offset crc32 checksum calculation cp memory copy
  • 21. Download & BOOT Commands loadb load binary file over serial line (kermit mode) loady load binary file over serial line (ymodem mode) loads load S-Record file over serial line Ping send ICMP ECHO REQUEST to network host bootp boot image via network using BOOTP/TFTP protocol dhcp invoke DHCP client to obtain IP/boot params tftpboot boot image via network using TFTP protocol nfs boot image via network using NFS protocol boot boot default, i.e., run 'bootcmd' bootm boot application image from memory Nboot boot from NAND device go start application at address 'addr' fatload load binary file from a FAT file system Ext2load load binary file from a Ext2 filesystem HW Subsytem gpio manipulate gpios i2c I2C sub-system control mmc MMC sub system usb USB sub-system control ftd flattened device tree utility commands mtdparts define flash/nand partitions eeprom EEPROM sub-system control nand NAND sub-system control flinfo print FLASH memory information erase erase FLASH memory sf Serial Flash sub-system U-Boot Commands
  • 22. Adding new command in U-Boot U_BOOT_CMD() is the Macro used to add new command in u-boot. name: is the name of the command. THIS IS NOT a string. maxargs: the maximum numbers of arguments this function takes command: Command implementation Function pointer (*cmd)(struct cmd_tbl_s *, int, int, char *[]); Usage: Short description. This is a string help: long description. This is a string U_BOOT_CMD(name, maxargs, repeatable, command, "usage", "help") Command Function Prototype: cmdtp – Command table pointer (function vector table) flag -- Unused argc -- Argument count, including command name itself argv[] -- Array of arguments (string). int do_funcname (cmd_tbl_t *cmdtp, int flag, int argc, char *const Argv[] )
  • 23. Step-2: Modify Kconfig file under command folder $vim Kconfig Step-1 : create demo.c in u-boot/command folder $ cd <uboot_path>/command $ vim dummy.c Adding new command in U-Boot #include<common.h> #include<command.h> static int do_dummy(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { printf("Hello Rugged Board A5d2xn"); printf("This is dummy command implementationn"); return 0; } U_BOOT_CMD(dummy, 2, 1, do_dummy, "testing hello","arg1 not needed"); config CMD_DUMMY bool “Dummy Command" default y help This is testing the new command in rugged board.. Step-4: Compile & Flash Step-5: Test the command on Target Bootloader prompt => hello Hello Rugged Board A5d2x This is dummy command implementation Step-3: Modify Makefile $vim Makefile // bootloader/uboot-rba5d2x/cmd obj-$(CONFIG_CMD_DUMMY) += dummy.o
  • 24. Adding new Driver in U-Boot #Step-1: Define your device in dts file $ vim <uboot_path>/arch/arm/dts/rugged_board_a5d2x.dts leds { compatible = "sled-testing"; status = "okay"; UserLed { label = "UserLed"; sled-default-state = "blink"; }; }; # Step-2: Define your driver sled.c in uboot/driver folder $ vim <uboot_path>/driver/led/sled.c # copy the sled.c code # Step-3: Add sled configuration in Kconfig file $ vim <uboot_path>/driver/led/Kconfig config SLED bool "SLED support for LEDs" depends on LED help Sled driver on RuggedBOARD-A5D2x # Step-4: Add sled configuration in Kconfig file $ vim <uboot_path>/driver/led/Makefile obj-$(CONFIG_SLED) += sled.o # Step-5: Write a test code cmd_sled.c under command folder and which calls the driver functions $ vim <uboot_path>/command/cmd_sled.c #implement do_sled() & register using U_BOOT_CMD
  • 25. Driver Code Flow File Description u-boot/driver/gpio/at91_gpio.c Atmel GPIO Driver core bus driver u-boot/driver/gpio/gpio-uclass.c U-Boot GPIO Subsystem HAL u-boot/driver/led/sled.c Sled device driver which used gpio bus driver u-boot/command/sled_cmd.c Test app / command implemented to test sled driver
  • 27. Next Sessions 1. Linux Kernel Porting using RuggedBOARD-A5D2x a. Source Code walkthrough & Code flow b. Kconfig Kernel Configuration System c. Adding Custom driver 2. Yocto BSP using RuggedBOARD-A5D2x 3. Design your own Single Board Computer using phyCORE-A5D2x. [HW Design] 4. Building Gateway Hardware and Open Source Linux Stacks for Gateway. [HW Design] To get update’s follow RuggedBOARD on LinkedIn, Youtube, Twitter, Facebook & Instagram links are on next slide …
  • 30. B Vasu Dev ABOUT Vasu Vasu has 15+ Years of industry experience in Embedded Technologies mainly on ARM & Linux, he has worked at major MNC’s like LG, Wipro, MIC Electronics and is currently heading PHYTEC INDA, a subsidiary of PHYTEC Messtechnik GmbH GERMANY as Managing Director. PHYTEC serves as OEM for many electronic and embedded companies to develop and deploy their products at the lowest possible time with high reliability and quality using ARM based SOMs (System On Modules ) & SBCs (Single Board Computers). The industry verticals he was engaged are Industrial Automation, Mobility & Energy, Medical/Healthcare, Retail market. Apart from his technical work, he is an active coach & guide for Embedded developers and actively spend his time to train the developers on Embedded Linux, Yocto, IoT, Android System Development. He is the master mind behind RuggedBOARD Open Source Hardware Platform. Vasu as a mentor helped many start-ups to build their products and position them in market. Managing Director PHYTEC Embedded Pvt Ltd vasu.b@phytec.in +91-9535504414 Presenter Profile