-------------------------------------------------------------- -------------------------------------------------------------- Linux BSP Development Traning -------------------------------------------------------------- Toolchain Bootloader Kernel RootFS + Application Development Setup 1. Host PC with Ubuntu-12.04 LTS 2. Install additional req. pkgs ( elinux_pkg.sh ) linux arch -mach- -plat- ------------------------ Flash ( Images using TFTP ) -MLO ( pbl) -barebox.bin ( bl ) -uImage ( kernel ) -root.ubi ( apps ) -------- Setup the TFTP Server on Host ( tftp-script.sh ) /var/lib/tftpboot location Network Configuraiton ifup eth0 devinfo eth0 Target Barebox command promt ls /dev/nand0.* tftp barebox.bin ls erase /dev/nand0.barebox.bb cp barebox.bin /dev/nand0.barebox.bb tftp uImage ls+ erase /dev/nand0.kernel.bb cp uImage /dev/nand0.kernel.bb am335x ( bootflash, SRAM ( ~100KB ) DDR - 256MB NAND - 128MB SDCARD Ethernet USB UART ARM9->ARM11->ARM-CortexA8->A9->A5(small-A8) ->A15->A7(small-A9)->A53 (64bit) ---------------------------- Bootloader: Functionalites: - Hardware Init - Firmware Upgrade - OS Env Setup Component of Typical Bootloader - CPU Core Support - SOC support - Devices Support - CLI & Tools mkdir ~/easyarm/work -p cd ~/easyarm/work tar -xvf /barebarebox-2013.11.0.tar.bz2 Dir Structure BareBox arch arm cpu ( arch specifc init code ) board lib mach- tools ----------------------------------------------------- Code Flow: --------- .text_entry -> start -> barebox_arm_head -> barebox_arm_reset_vector -> barebox_arm_entry -> __start -> start_barebox -> Files: ------ - cpu/start.c - include/asm/barebox-arm-head.h - boards/pcm051/lowlevel.c - common/startup.c API's: ----- device_initcall console_initcall mem_initcall device_platform_driver grep device_initcall * -nr --------------------- 1. make ARCH=arm \ CROSS_COMPILE=arm-cortexa8-linux-gnueabihf- \ distclean 2. make ARCH=arm \ CROSS_COMPILE=arm-cortexa8-linux-gnueabihf- \ pcm051_defconfig 3. make ARCH=arm \ CROSS_COMPILE=arm-cortexa8-linux-gnueabihf- \ --------------------- Adding Status LED in Board File GPIO_PIN 82 ( GPIO2_18 == emu1 pad_name ) mach-omap/include/mach/am33xx-mux.h -struct module_pin_mux -configure_module_pin_mux boards/pcm051/mux.h extern void pcm051_status_led_pin_mux(void); boards/pcm051/mux.c static const __maybe_unused struct module_pin_mux status_led_pin_mux[] = { {OFFSET(emu1), (MODE(7) | PULLUP_EN)}, /* gpio */ {-1}, }; void pcm051_status_led_pin_mux(void) { configure_module_pin_mux(status_led_pin_mux); } board/pcm051/board.c #define GPIO_STATUS_LED 82 /* 2x32+18 GPIO2_18 */ static void pcm051_status_led_init() { pcm051_status_led_pin_mux(); gpio_direction_output(GPIO_STATUS_LED, 0); gpio_set_value(GPIO_STATUS_LED, 1); } ---------------------------------- Kernel: cd ~/easyarm/work tar -xvf /Linux/PD14.0.0/src/kernel/linux-3.2.tar.bz2 linux arch/arm mach- plat- boot kernel configs tools drivers init kernel fs net sound Documentation 1. stext is the starting point of kernel arch/arm/kernel/head.S & head-common.S In this sptep all the lowlevel init is done and jumps to start_kernel 2. start_kernel is defined in init/main.c start_kernel is the only funciton where kernel boot starts and ends setup_arch() would internally call init_machine() function pointer 3. init_machine is initilized with board_init() in board-pcm051.c MACHINE_START() structure. 4. after machine init jumps back to start_kernel() rest_init --> kthredd + kernel_init kthreadd thread manages all the kernel services kernel_init will spawn the init process. ------------------------- Kernel KConfig Configuraiton System 1. KConfig File ( used as input config file ) config PCM051_SLED tristate "Vasu test driver" depends on I2C default y help This is the help text msg 2. make menuconfig / xconfig / gconfig ( user interface to configure) 3. .config generated 4. Makefile in respetive subdir uses the MACRO CONIFG_ which could be "y"/"m"/"numeric"/"string"/"" obj-${CONFIG_ITEM} += item.o obj-y +=item.o or obj-m +=item.o or obj- +=item.o 4. Compilation make ARCH=arm CROSS_COMPILE=arm-cortexa8-linux-gnueabihf- ------------------------ Adding New Board to the Kernel 1. Add new Machine ID in the arch/arm/tools/mach-types wega MACH_WEGA WEGA 4660 2. Create new board file in the mach- folder arch/arm/mach-ompa2 gedit board-wega.c ------------------ 1. Register the MACHINE Structure MACHINE_START -------------------------- MACHINE_START(WEGA, "pcm051") /* Maintainer: PHYTEC */ .atag_offset = 0x100, .map_io = am33xx_map_io_set_globals, .init_early = am33xx_init_early, .init_irq = ti81xx_init_irq, .handle_irq = omap3_intc_handle_irq, .timer = &omap3_am33xx_timer, .init_machine = pcm051_init, MACHINE_END ---------------------------------- 2. Board Init funcation a. Do all the muxing b. Do all the device inits 3. Pin Muxing data structures a. static struct pinmux_config wega_uart1_pin_mux[] b. static struct pinmux_config wega_nand_pin_mux[] called in wega_pin_mux() setup_pin_mux( ); 4. Device Inits a. For Serial Init omap_serial_init() b. For Nand Init am335x_nand_init( ) static struct gpmc_timings wega_nand_timings 5. Modify the Build system entries a. KConfig file in mach-omap2 folder config MACH_WEGA bool "AM335X based phyCORE WEGA AM335X" depends on SOC_OMAPAM33XX default y b. Makefile obj-$(CONFIG_MACH_WEGA) += board-wega.o c. copy the pcm051_defconfig to wega_defconfig arch/arm/configs cp pcm051_defconfig wega_defconfig ------------------------------------- Platform Driver Platform Data Platform device platform driver ----------------In Board File /* Defining our device specific data so to share to the generic driver */ struct sled_platform_data { char *name; int id; int bus_id; int sled_gpio_num; int sled_blink_delay; }; /* Create a instance of the sled data */ static struct sled_platform_data = { .name = "Status led data for Wega Board", .id = 0, .bus_id = -1, .sled_gpio_num=105, .sled_blink_delay=10 }; /* Create a platform device for sled */ static struct platform_device wega_sled_device = { .name = "sleddrv", .id = 0, .dev = { .relese = sled_device_release, .platform_data = &sled_platform_data, }, }; platform_device_register(&wega_sled_device); ----------In Driver file struct platform_driver sled_drv = { .driver = { .owner = THIS_MODULE, .name = "sleddrv", }, .probe = sled_probe, .remove = __devexit_p(sled_remove), } platform_driver_register(&sled_drv); -------------------------------------------------------------- -------------------------------------------- i2C driver: ----------In BoardFile struct i2c_board_info i2c_dev_brdInfo = { I2C_BOARD_INFO(name,id), .platform_data = &platData, } wega_i2c_adc_int() { struct i2c_adapter *adapter; struct i2c_client *client; unsigned int i2c_instance=1; // i2c_bus_num; //Bus Number adapter = i2c_get_adapter(i2c_instance); client = i2c_new_device(adapter,i2c_dev_brdInfo); } ------------------ Driver File struct i2c_driver i2c_add_driver( struct i2c_driver &drv) i2c_del_driver( struct i2c_driver &drv) DataStructures: struct i2c_client *client; struct i2c_device_id Methods: ------probe i2c_check_functionality() i2c_set_clientdata i2c_get_clientdata ---- Device interaction i2c_smbus_read_byte_data(client,reg) i2c_smbus_write_byte_data(client,reg,value) i2c_smbus_read_word_data i2c_smbus_write_word_data ------------------------------------------------------------------------------- -------------------------- Memory Mgmt in Linux: PHY MEM - 256MB -> 4GB ( 1GB Kernel + 3GB USER ) 3GB -> 4GB Window for each user process -------------------------- ------------- Contact: Support: info@easyarm.com H/W : support@phytec.in "Enabling Embedded Learning in INDIA" ================================ web: www.easyarm.com || e-mail: info@easyarm.com || Ph: +91-8041307589 || Mob: +91-9731885420