Download presentation
Presentation is loading. Please wait.
1
Blackfin Linux development
12/17/08 Blackfin Linux development Aaron Wu ADI Open Source Solution
2
Contents Getting started development with Linux Blackfin
users new to Blackfin Linux get started from here Tool-chain introduction Blackfin GNU toolchain introduction Uboot introduction features porting Linux distribution introduction porting/development debugging 2012 Release buildroot 609 new features MCAPI Misc demos HD video capture/play, Bluetooth over USB, IEEE1588/PTP
3
Linux on Blackfin – Geting started
12/17/08 Linux on Blackfin – Geting started
4
Getting started--what’s needed?
Q: What do I need to prepare if I decide to start Linux development on Blackfin? A: All you need to get started is: A Linux PC with Ubuntu or equivalent A suite of ADI Blackfin development board (Or your customer board) Internet access
5
Set up environment Q: I have the Ubuntu installed on my host PC, what’s the next? A: Set up the host environment Install required packages on host PC: Install Blackfin Linux toolchain: tar jxvf blackfin-toolchain-2012R1-RC2.i386.tar.bz2 tar jxvf blackfin-toolchain-elf-gcc R1-RC2.i386.tar.bz2 tar jxvf blackfin-toolchain-uclibc-default-2012R1-RC2.i386.tar.bz2 Q: Where do I get the source code and binary? A: Download the release for u-boot, toolchain, and Blackfin Linux source code and binary from Note: Be sure to use the matched version of u-boot, toolchain and Linux, mix different versions up lead to unknown problems, and use the latest release version.
6
How to get help – support model
Q: I have a problem, I need support A: Asking questions on support forum: (English and Chinese) blackfin For toolchain For Linux distribution For U-boot Before summiting your question: Read the FAQ: Search the forum for historical issues When summiting your question, provide information: 1)detailed information for hardware environment and software version 2)log for the failure, along with your kernel and distribution configuration files 3)steps description to reproduce your failure Helpful document wiki: docs.blackfin.uclinux.org You are welcome to share your knowledge on the help forum
7
Typical development environment
Set up the hardware environment Switch to the appropriate boot mode Connect the serial cable, eth cable, power supply. Set up the host machine Set up the terminal for Linux, minicom, N-1, HW flow control off Set up the tftp server for Linux 1) sudo apt-get install tftp-hpa tftpd-hpa 2) sudo vi /etc/default/tftpd-hpa, set the TFTP_DIRECTOR to you own directory 3) sudo service tftpd-hpa restart Run Default image U-boot environment setting Run Linux uImage Update the bootloader Transfer the image to board by Ethernet bfin> tftp 0x u-boot.ldr Flash to the serial Flash bfin> sf probe 2 ? bfin> sf erase 0x0 0x100000 bfin> sf write 0x x0 $SIZE Initially Load the bootloader bfin-uclinux-ldr -l u-boot.ldr
8
Linux on Blackfin – Toolchain
12/17/08 Linux on Blackfin – Toolchain
9
Installing toolchain Where to get
3 files needed, choose the right one according to your host pc hardware and software architectures blackfin-toolchain-2012R1-RC2.i386.tar.bz2 blackfin-toolchain-elf-gcc R1-RC2.i386.tar.bz2 blackfin-toolchain-uclibc-default-2012R1-RC2.i386.tar.bz2 An example procedure tar jxvf blackfin-toolchain-09r1.1-2.i386.tar.bz2. tar blackfin-toolchain-elf-gcc R1-RC2.i386.tar.bz2 tar jxvf blackfin-toolchain-uclibc-default-2012R1-RC2.i386.tar.bz2 cp -fr opt/uClinux /opt Add to the PATH export PATH=$PATH:/opt/uClinux/bfin-uclinux/bin:/opt/uClinux/bfin-linux- uclibc/bin:/opt/uClinux/bfin-elf/bin Or edit the file ~/.bashrc to include the above line 9 9
10
Toolchain for 3 binary formats
FLAT bfin-uclinux-gcc Binary Flat files known as BFLT, relatively simple and lightweight executable format based on the original a.out format. BFLT files are the default file format in embedded Linux, automatically link the application with the Linux run time libraries, usually for static library linking. FDPIC ELF bfin-linux-uclibc-gcc originally developed by Unix System Laboratories and has become the standard in file formats. The ELF standard has greater power and more flexibility than the BFLT format. However, they are more heavyweight, requiring more disk space and having a small run-time penalty, usually for dynamic library linking. Bear metal bfin-elf-gcc used for Non-OS applications, nothing to do with Linux, one example is code running on coreB of BF561/BF609. FLAT and FDPIC can be selected from the menuconfig in linux distribution 10 10
11
Linux on Blackfin – U-boot
12/17/08 Linux on Blackfin – U-boot
12
U-boot – src download/compile
12/17/08 U-boot – src download/compile Git clone and check out the source git clone git://sources.blackfin.uclinux.org/git/u-boot (git:// /git/u-boot) git checkout -b 2012R1 remotes/origin/2012R1 Configure and compile vi include/configs/bf609-ezkit.h make bf609-ezkit Flash the u-boot By gnICE bfin-jtag cable gnICE detect businit YOUR_BOARD detectflash flashmem 0x u-boot.ldr By uart-utils bfin-uclinux-ldr -l u-boot.ldr connect to minicom, the uart version of u-boot is running use the runing u-boot to tftp load and flash bootloader 12 12
13
Boot-loader Terms Loader Boot ROM Bootloader / Bootstrap Loader
12/17/08 12/17/08 Boot-loader Terms Loader Program that loads another, more complex, program Boot ROM The Blackfin on-chip ROM Bootloader / Bootstrap Loader Program that boots the “first program” such as the Linux kernel 13
14
Boot ROM Power on Check BMODE pins Setup selected boot source
12/17/08 12/17/08 Boot ROM Power on Check BMODE pins Setup selected boot source Load and process LDR found at boot source Load & execute init block Load blocks (code & data) Initialize filled blocks Pass execution off to LDR U-Boot is a standard LDR Boot ROM boot modes tested every release: Parallel Flash SPI Serial Flash UART SD/MMC boot (BF60x) 14
15
Booting user program with U-boot
12/17/08 12/17/08 Booting user program with U-boot Most common behavior is to boot the Linux kernel U-Boot works with “bootable U-Boot images” Select boot source Load uImage over source Check CRC Decompress Jump to entry point 15
16
Booting user program (cont)
12/17/08 12/17/08 Booting user program (cont) U-Boot and program need not be in same storage Boot ROM boots U-Boot out of parallel flash, but U-Boot boots Linux off of SD card Linux and root file system need not be in same storage U-Boot boots Linux off of SD card, but Linux uses root file system in NAND flash Every file system format you can think of is supported FAT 12 / 16 / 32 JFFS / JFFS2 UBIFS Bad blocks with NAND Behavior is all controlled dynamically through U-Boot console 16
17
Bootmode selection 17 Support various booting methods How to select
12/17/08 Bootmode selection Support various booting methods Parallel NOR Flash SPI NOR Flash SD/MMC card (BF60x) UART How to select H/W design, Input Pins BMODE[2:0] to select the booting mode ROM code will check the BMODE Pins and choose the source accordingly In board configuration file, define the CONFIG_BFIN_BOOT_MODE properly 17 17
18
12/17/08 Porting U-boot --RAM Mostly done in board config files: include/configs/bfxx-yy.h DRAM: BF5xx For Blackfin's that have SDRAM, you will need to define:ne CONFIG_EBIU_SDRRC_VAL - SDRAM Refresh Rate Control CONFIG_EBIU_SDBCTL_VAL - SDRAM Bank Control CONFIG_EBIU_SDGCTL_VAL - SDRAM Global Control For Blackfin's that have DDR, you will need to define: CONFIG_EBIU_DDRCTL0_VAL - DDR Control CONFIG_EBIU_DDRCTL1_VAL - DDR Control CONFIG_EBIU_DDRCTL2_VAL - DDR Control CONFIG_EBIU_DDRCTL3_VAL - (Optional) DDR Control CONFIG_EBIU_RSTCTL_VAL - (Optional) DDR Reset Control DRAM: BF60x static struct ddr_config ddr_config_table[] = { [0] = { .ddr_clk = 125, /* 125MHz */ .dmc_ddrctl = 0x , .dmc_ddrcfg = 0x , .dmc_ddrtr0 = 0x , .dmc_ddrtr1 = 0x201003CF, .dmc_ddrtr2 = 0x , .dmc_ddrmr = 0x , .dmc_ddrmr1 = 0x4, }, 18 18
19
Porting U-boot --Nor 19 Parallel NOR Flash
12/17/08 Porting U-boot --Nor Parallel NOR Flash Need the following defines in your board header /* Board independent required settings */ #define CFG_FLASH_CFI 1 /* Flash is CFI compliant */ #define CFG_FLASH_CFI_DRIVER 1 /* Use the common CFI flash driver */ /* Board dependent required settings */ #define CFG_FLASH_BASE 0x /* Address flash is mapped */ #define CFG_MAX_FLASH_BANKS 1 /* Max number of banks -- can be greater than available, but cannot be smaller */ #define CFG_MAX_FLASH_SECT 71 /* Max number of sectors -- can be greater than available, but cannot be smaller */ /* Optional settings */ #define CFG_FLASH_PROTECTION 1 /* Use hardware flash protection */ 19 19
20
Porting U-boot --Nor 20 SPI NOR Flash
12/17/08 Porting U-boot --Nor SPI NOR Flash In board configuration and u-boot common file to enable support for serial flashes. CONFIG_BFIN_SPI -- Blackfin on-chip SPI controller CONFIG_SPI_FLASH -- SPI Flash subsystem CONFIG_CMD_SF -- Command line interface sf CONFIG_SF_DEFAULT_HZ -- speed to run the SPI flash CONFIG_SF_DEFAULT_MODE -- by default, SPI_MODE_3 is used (see spi for more info) If you want to store the U-Boot environment in SPI flash, then use these defines. CONFIG_ENV_IS_IN_SPI_FLASH -- store the env in SPI flash CONFIG_ENV_SPI_MAX_HZ -- speed to run the SPI flash CONFIG_ENV_SPI_MODE -- by default, SPI_MODE_3 is used (see spi for more info) CONFIG_ENV_SPI_BUS -- by default, bus 0 is used CONFIG_ENV_SPI_CS -- by default, the CS the bootrom uses Then you should define these according to the parts you have. CONFIG_SPI_FLASH_ATMEL CONFIG_SPI_FLASH_SPANSION CONFIG_SPI_FLASH_SST CONFIG_SPI_FLASH_STMICRO CONFIG_SPI_FLASH_WINBOND 20 20
21
Porting U-boot --Nand 21 NADN Flash
12/17/08 Porting U-boot --Nand NADN Flash Two ways to connect Nand to the system Via the asynchronous memory bank #define CONFIG_NAND_PLAT drivers/mtd/nand/nand_plat.c Via on-chip NAND controller for some Blackfins like BF52x or BF54x #define CONFIG_DRIVER_NAND_BFIN drivers/mtd/nand/bfin_nand.c Command line features supported bytes read/write query U-boot code features supported similar to the Linux MTD 21 21
22
Porting U-boot --Nand 22 NAND Settings in the board configuration file
12/17/08 Porting U-boot --Nand NAND Settings in the board configuration file #define CONFIG_BFIN_NFC_CTL_VAL 0x0033 #if (CONFIG_BFIN_BOOT_MODE == BFIN_BOOT_NAND) # define CONFIG_BFIN_NFC_BOOTROM_ECC #endif #define CONFIG_DRIVER_NAND_BFIN #define CONFIG_SYS_NAND_BASE /* not actually used */ #define CONFIG_SYS_MAX_NAND_DEVICE #define NAND_MAX_CHIPS CONFIG_BFIN_NFC_CTL_VAL: Dedails in HRM, parameters like page_size, bit width are defined here 22 22
23
Linux on Blackfin – Kernel and Blackfin distribution
12/17/08 Linux on Blackfin – Kernel and Blackfin distribution
24
Linux – src download/compile/run
12/17/08 Linux – src download/compile/run Git clone and check out the source Checkout buildroot source git clone git://blackfin.uclinux.org/git/buildroot cd buildroot git checkout -b 2012R1 remotes/origin/2012R1 Checkout Linux kernel and test suite submodule source git submodule update --init (password anonymous) cd linux/linux-2.6.x/ cd ../../ cd testsuites Compile the buildroot make bf609-ezkit_defconfig make Run the uImage cp output/images/uImage /tftpboot/ power on the board 24 24
25
Linux terms and Concepts
12/17/08 Linux terms and Concepts Linux – the kernel / operating system MMU – memory management unit VM – Virtual Memory support Blackfin lacks this today MPU – Memory Protection Unit Blackfin has this today via CPLBs Operating mode Supervisor – privileged mode Userspace – unprivileged mode Device Driver Generic term – any code that manages a device Character Device Data is handled as a stream – think arrays or buffers Block Device Data is handled in blocks – think sectors or pages Network Device The socket programming interface
26
Operating Modes – Big Picture
12/17/08 Operating Modes – Big Picture Userspace Application (Customer) Opensource Library C Library (uClibc) Linux Kernel (supervisor) Device Driver Device Driver Framework B / Hardware
27
Existing Blackfin Drivers
12/17/08 Existing Blackfin Drivers For many peripherals, Blackfin driver is OK SPI bus master MMC/SD bus I2C/TWI bus UART driver USB bus Storage subsystems: NAND / NOR / ATAPI Watchdog RTC Ethernet MAC CAN OTP Rotary Encoder
28
Reuse Existing Blackfin Drivers
12/17/08 Reuse Existing Blackfin Drivers For busses, we handle the bus layer You implement client driver SPI / I2C client Some devices hook into existing frameworks Input: Rotary encoder, GPIO push buttons RTC / Watchdog: Common Linux interface for userspace Storage: higher block layers are all common For non-standard peripherals, you must manage peripheral- specific MMRs yourself (does not mean SIC/portmux MMRs) PPI / EPPI Pixel Composilator SPORT We provide examples of existing usage SPORT: audio codecs and bfin_sport char driver PPI: LCDs and cameras
29
SRAM Allocator Linux manages the regions
12/17/08 SRAM Allocator Linux manages the regions Dynamically ask for chunks of on-chip memory, just like malloc() and free() void *sram_alloc (size_t size, unsigned long flags) L1 Data Bank A Bank B L1 Inst L1 Scratch L2 Also use GCC attributes to selectively mark certain functions and/or variables to be stored in specific regions To put application code into L1 SRAM, adding the following option to gcc when compiling : -fno-jump-tables and adding the following options to gcc when linking -pie -Wl,--sep-code -Wl,--code-in-l1 -Wl,-z,now - shared-libgcc To put shared library code into L1 SRAM, adding the following option to gcc when compiling :-fno-jump-tables and adding the following options to gcc when linking -Wl,--sep-code -Wl,--code-in-l1 -Wl,-z,now - shared-libgcc To put application/shared library data into L1 SRAM, adding this options to gcc when linking: -Wl,--data-in-l1 Space is automatically reserved and things loaded Can be used in both kernel and user space
30
Resource Frameworks GPIO Framework: #include <linux/gpio.h>
12/17/08 Resource Frameworks GPIO Framework: #include <linux/gpio.h> gpio_request(GPIO_PF8, “my driver”); gpio_direction_output(GPIO_PF8, 1); gpio_free(GPIO_PF8); Peripheral Framework: #include <asm/portmux.h> peripheral_request(P_TMR6, “another driver”); peripheral_free(P_TMR6); IRQ Framework request_irq(IRQ_PG10, irq_handler, IRQF_FLAGS, “my irq”, data); free_irq(IRQ_PG10, data); DMA Framework Bus addresses: vs Physical address issue of cache coherency: dma_alloc_coherent() arch/blackfin/kernel/bfin_dma_5xx.c Example code using DMA
31
Existing Apps and Libs Apps Libs alsa-utils bluez-utils boa dhcpcd
e2fsprogs whetstone wireless_tools strace more ... Libs ffmpeg bluez-libs libjpeg sqlite qt-embedded
32
Porting Linux to your board
12/17/08 Porting Linux to your board places in the Linux kernel which you will need to customize for your specific board. arch/blackfin/mach-CPU/boards/Kconfig arch/blackfin/mach-CPU/boards/Makefile arch/blackfin/mach-CPU/boards/BOARD.c arch/blackfin/configs/BOARD_defconfig
33
Porting Linux to your board -- continued
Kconfig to make the board appear in the kernel configuration menu, update the arch/blackfin/mach-bf537/boards/Kconfig Makefile The kernel needs to know what source files to include when compiling the kernel, in arch/blackfin/mach-bf537/boards/Makefile, add a line: obj-$(CONFIG_BFIN537_FOOBER) += foober.o
34
Porting Linux to your board -- continued
Board Resources in arch/blackfin/mach-bf537/boards/foober.c bfin_board_name - a short string describing the board board_devices - an array of platform_devices char *bfin_board_name = "foober"; /* peripheral resources; see specific peripheral documents */ static struct platform_device *board_devices[] __initdata = { /* pointers to peripheral structures */ }; static int __init board_init(void) { platform_add_devices(board_devices, ARRAY_SIZE(board_devices)); return 0; } arch_initcall(board_init);
35
Porting Linux to your board – your device driver
Always using the existing frameworks Including more than one Ethernet port Add eth devices with proper resources static struct platform_device bfin_eth_device = { .name = "stmmaceth", .id = 0, .num_resources = 2, .resource = (struct resource[]) { { .start = EMAC0_MACCFG, .end = EMAC0_MACCFG + 0x1274, .flags = IORESOURCE_MEM, }, .name = "macirq", .start = IRQ_EMAC0_STAT, .end = IRQ_EMAC0_STAT, .flags = IORESOURCE_IRQ, .dev = { .power.can_wakeup = 1, .platform_data = ð_private_data, } };
36
Porting Linux to your board – your device driver
Adding a SPI device Add SPI board info #if defined(CONFIG_TOUCHSCREEN_AD7877) || defined(CONFIG_TOUCHSCREEN_AD7877_MODULE) { .modalias = "ad7877", .platform_data = &bfin_ad7877_ts_info, .irq = IRQ_PD9, .max_speed_hz = , /* max spi clock (SCK) speed in HZ */ .bus_num = 0, .chip_select = 4, }, #endif Create your own SPI protocol driver example: drivers/input/touchscreen/ad7877.c Using the common method for data transaction spi_message_init spi_message_add_tail spi_sync
37
Porting Linux to your board – your device driver
Using a different Flash Add MTD partition table static struct mtd_partition partition_info[] = { { .name = "bootloader(nand)", .offset = 0, .size = 0x80000, }, { .name = "linux kernel(nand)", .offset = MTDPART_OFS_APPEND, .size = 4 * 1024 * 1024, }, .name = "file system(nand)", .size = MTDPART_SIZ_FULL, }; Add your Flash ID entity in drivers/mtd/nand/nand_ids.c struct nand_flash_dev nand_flash_ids[] = { {"NAND 4MiB 5V 8-bit", x6b, 512, 4, 0x2000, 0}, {"NAND 1MiB 3,3V 8-bit", xe8, 256, 1, 0x1000, 0}, {"NAND 1MiB 3,3V 8-bit", xec, 256, 1, 0x1000, 0}, ……
38
Application porting and development
API difference Use vfork instead of fork, and _exit instead of exit A fork produces a parent and child. Each have individual task control structures and each can be scheduled independently by the kernel. When we have an MMU the parent and child eventually occupy different physical memory spaces. The MMU maps different physical memory addresses to identical virtual memory addresses and copies the data from parent to child Using thread APIs Memory allocation Because there is no virtual memory map, an uClinux application should try not to allocate and free dynamic memory continually, to avoid fragmenting memory. Application are recommended to malloc all memory at start up or manage allocation by itself, nedmalloc is one option for memory pool. Fixed stack size default stack size for FLAT binaries is 4k (0x1000) bytes default stack size for FDPIC ELF binaries is 128k (0x20000) bytes Stacksize can be modified with flthdr like “flthdr -s 8192 application” or in Makefile
39
Add user application create a new directory in …/uClinux-dist/user/ to store the source files for the new application Edit uClinux-dist/user/Makefile, add a line like below dir_$(CONFIG_USER_MYPROG_MYPROG) += myprog Edit uClinux-dist/user/Kconfig.local, for selection on the menu Edit the Makefile for your application uClinux-dist/user/myprog/Makefile
40
Debug the kernel printk gdbproxy notice: gdbproxy: connected
Connect to the board with gnICE bfin-gdbproxy bfin Bfin-uclinux-gdb (gdb) target remote :2000 notice: gdbproxy: connected The Blackfin will now halt and you can: Set software breakpoints with 'b' Set hardware breakpoints with 'hb‘ Print core register values 'print $r0' or 'info registers' etc. Continue program operation with 'c' And more…..
41
Linux on Blackfin – 2012 Release
12/17/08 Linux on Blackfin – 2012 Release
42
2012 Release ADSP-BF60x , new generation Blackfin dual-core processor
Move from Blackfin distribution to buildroot 3 packages: 2012R1-RC6-BF60X buildroot Linux distribution, buildroot , kernel 3.3.0 2012R1-RC2 GNU toolchain: GCC 4.3 2012R1-RC4-BF60X Das U-boot: Most user packages and libs in Bfin Linux distribution are included More release notes: rc1-bf60x
43
609 features Port DMA, EMAC, RSI/SD, UART, I2C/TWI, USB, SPI flash, NOR flash, CAN, Rotary, watchdog and GP timer Linux drivers to BF609 Develop new Linux drivers for BF609 EZ-Kit, such as SEC, SPI, CRC, link port, etc. Add ieee1588 hardware time stamp support in BF609 EMAC driver. Support IEEE1588 v2 protocol in new PTPd2 server with average 500ns time offset. MCAPI library and ICC driver is implemented to support inter core communication between Linux on BF60x core 0 and CrossCore® Embedded Studio application on core 1. GNU bare metal MCAPI support for core 1 is also available.
44
609 features Develop new ADV7842 and ADV7511 HDMI V4L2 video out and video in drivers for BF60x-Ezkit video extenders. Video format 720P at 50/60Hz is supported. VS6624 V4L2 camera driver are enabled via BF609 style EPPI controller. ad1761 ASOC sound drivers are enabled on top of new BF609 SPORT controller. USB video camera driver for NOMMU architecture is validated on BF609 EZ-Kit Enable Linux power management and CPU frequency features for BF609. New wake up sources are supported Das U-boot support 4 boot modes for BF609, SPI master boot, NOR flash boot, UART boot and SD boot.
45
Buildroot introduction
12/17/08 Buildroot introduction based on the buildroot mainline release, made up of many configure scripts, make files and directories, allows you to easily add configuration options, documentation, dependencies, and integrate into Makefiles Tree overview board/ — board specific kernel configuration files; not used for blackfin boot/ — boot loader config scripts and make files; not used for blackfin config/ — the buildroot default configuration for different boards dl/ — the source tarballs that are downloaded during building process docs/ — how to configure and customize buildroot fs/ — config scripts and make files to build different kinds of root file system image. linux/ — config scripts, make files to build Linux kernel linux/linux-kernel/ — the Linux kernel source linux/patch/ — Patches to apply to the proper version of Linux kernel source output/ — All building output files are put under this folder output/build/ — Contain binaries of all software packages output/images/ — Contain file system images and kernel booting up images. output/staging/ — locally installed (“staged”) target libraries; they may be linked with target applications later output/target/ — the compiled root file system image packages/ — config scripts and make files to download and build libraries and applications testsuites/ — scripts for testing various boards/packages/kernels/etc... scripts/ — misc buildroot compile helper scripts target/ — vendor-specific configuration files and build instructions toolchain/ — GNU toolchain and GDB config scripts and make files 45 45
46
Adding packages to buildroot
Create a Config.in, and add entries in uper layer Config.in config BR2_PACKAGE_LIBFOO bool "libfoo" help This is a comment that explains what libfoo is. Different ways of writing the makefile according to the package organization type automake style package 01: ############################################################ 02: # 03: # libfoo 04: # 05: ############################################################# 06: LIBFOO_VERSION = 1.0 07: LIBFOO_SOURCE = libfoo-$(LIBFOO_VERSION).tar.gz 08: LIBFOO_SITE = 09: LIBFOO_INSTALL_STAGING = YES 10: LIBFOO_INSTALL_TARGET = YES 11: LIBFOO_CONF_OPT = --enable-shared 12: LIBFOO_DEPENDENCIES = libglib2 host-pkg-config 13: 14: $(eval $(autotools-package))
47
MCAPI and ICC in Bfin Linux-- big picture
48
MCAPI in Bfin Linux -- How system works
Physically Data transaction by shared memory Event notification between Core A and B via inter-core interrupt Work flow Linux Boot on core A from normal routine Core B ICC common facility(server) loaded to RAM by core B loader running on core A Core A issue an interrupt to core B and core B begin to run the ICC server Core B user app running on ICC server loaded to RAM by core B loader Core A ICC user app runs in Linux to communicate with user app on core B
49
MCAPI in Bfin Linux -- Code structure
lib/libmcapi facilities for core A MCAPI Libs for core A libmcapi/libmcapi-2.0/tests: test code example, customer application will also be here user/blkfin-apps/icc_utils/ facilities for core B icc_utils/libmcapi_coreb: MCAPI libs for core B icc_utils/icc_core: ICC protocol on core B icc_utils/example/task: example user app code on core B icc_utils/icc_loader: core B loader program, but running on core A linux-2.6.x/drivers/staging/icc ICC protocol on core A
50
MCAPI in Bfin Linux -- Run the test
Compile the dist Either configure the dist following the wiki document Or use the test scripts: ./build_mcapi_kernel.exp BF609-EZKIT Load and run the ICC server and user app on core B cd /bin ./icc_loader -l ./icc ./icc_loader -e mcapi_msg1 Run user app on core A telnet msg1 Check the results on log Useful links:
51
MCAPI/ICC between Linux and CCES
In the previous section, described how to create coreB beare-metal task in Linux environment, and communicate with core A Linux by MCAPI. However, we also support compile, load and run core B bear-metal task in CCES, independently with Linux environment, and enable the MCAPI communication after both core boots. Compile coreB beare-metal in CCES import coreB project add sdram cplb entries to startup_ldr/app_cplbtab.c /* SDRAM Memory */ {0x0, (ENUM_DCPLB_DATA_64MB | CPLB_DNOCACHE)}, {0x , (ENUM_DCPLB_DATA_64MB | CPLB_DNOCACHE)}, Then config like following and build Config like following:
52
MCAPI/ICC between Linux and CCES
Load by Linux icc_loader -l BF609_MCAPI_coreB_task.dxe Load by bootrom Blackfin bootrom allows to load 1 LDR image into memory and run on both cores after reset. You can pack core1 MCAPI dxe binary and core 0 uboot elf binary into one LDR image by bfin-elf-ldr utility and run MCAPI application on core1 at the very begining of uboot init Build the latest bfin-elf-ldr on 2012R1 toolchain branch head to enable this Build u-boot on 2012R1 branch head with CONFIG_CORE1_RUN option defined in config file Pack the dxe file of CCES core1 MCAPI test application and uboot ELF file into one LDR image by command: bfin-elf-ldr -T bf c DualCoreTest_uboot.ldr u-boot BF609_MCAPI_coreB_task.dxe --bmode PARA --use-vmas --initcode arch/blackfin/cpu/initcode.o -J --punchit $((0x8000)):$((0x8000)):env-ldr.o Flash generated LDR image into Norflash Switch the bootmode rotary to norflash mode and reset
53
MCAPI/ICC – How to debug
Recommend to verify the coreB bear-metal algorithm/function code standalone first, coreA and coreB work together to debug only the MCAPI communication Linux App DGB debug is always available, kernel gdb debug depends on the following: CoreB task compiled in Blackfin Linux buildroot CoreA Linux: JTAG, GDB to tace the C source code print CoreB bear-metal: coreb_debug print agent JTAG to observe the assemble CoreB task compiled in CCES, using Linux JTAG tool If JTAG to observe the assemble code on core B CoreB task compiled in CCES, using CCES JTAG tool JTAG, GDB to observe the assemble code If JTAG to trace the C code on core B
54
Linux on Blackfin – Misc Demos
12/17/08 Linux on Blackfin – Misc Demos
55
Video capture/play on BF609
BF609 EZ-BRD HD video player ADV7842 HDMI decoder board for capture ADV7511 HDMI encoder board for display HD Display
56
Video capture Kernel config User app config
Blackfin Processor Options ---> Uncached DMA region (Enable 4M DMA region) ---> Device Drivers ---> <M> I2C support ---> I2C Hardware Bus support ---> <M> Blackfin TWI I2C support (100) Blackfin TWI I2C clock (kHz) <M> Multimedia support ---> [*] Media Controller API (EXPERIMENTAL) <M> Video For Linux [*] Video capture adapters ---> Encoders, decoders, sensors and other helper chips ---> <M> Analog Devices ADV7183 decoder <M> Analog Devices ADV7842 decoder <M> ST VS6624 sensor support [*] V4L platform devices ---> <M> Blackfin Video Capture Driver User app config Package Selection for the target ---> Miscellaneous ---> [*] V4L2 video test program Run the capture test v4l2_video_capture -I 4 -F /adv7842.yuv On the host, run: rcp board_IP:/adv7842.yuv .
57
Video Play Kernel config User app config
Blackfin Processor Options ---> Uncached DMA region (Enable 32M DMA region) ---> Device Drivers ---> <M> I2C support ---> I2C Hardware Bus support ---> <M> Blackfin TWI I2C support (100) Blackfin TWI I2C clock (kHz) <M> Multimedia support ---> [*] Media Controller API (EXPERIMENTAL) <M> Video For Linux [*] Video capture adapters ---> Encoders, decoders, sensors and other helper chips ---> <M> Analog Devices ADV7511 HDMI transmitter [*] V4L platform devices ---> <M> Blackfin Video Display Driver User app config Package Selection for the target ---> Miscellaneous ---> [*] V4L2 video test program Run the capture test tftp –g –r adv7842.yuv host_IP v4l2_video_display -D /dev/video1 -F /adv7842.yuv
58
PTP/IEEE1588 on BF609 Two or more EZ-BRDs Ethernet switch
59
PTP/IEEE1588 on BF609 Design and implementation
PTP daemon (PTPd) running in the user space implements the Precision Time protocol (PTP) as defined by the relevant IEEE 1588 standard, to provide very precise time coordination of LAN connected boards. Support PTPd V2 Linux driver for the Blackfin IEEE 1588 PTP engine is in charge of the timestamp handling in the Ethernet MAC driver, very close to the low-level hardware, to exclude the time delay in software stack and guarantee the high precision Sample code drivers/net/bfin_mac.c #define CONFIG_BFIN_MAC_USE_HWSTAMP
60
PTP/IEEE1588 on BF609 Device Drivers ->
Configure the kernel Device Drivers -> Network device support (NETDEVICES [=y]) -> Ethernet (10 or 100Mbit) (NET_ETHERNET [=y]) -> Blackfin on-chip MAC support (BFIN_MAC [=y]) -> Use IEEE 1588 hwstamp (BFIN_MAC_USE_HWSTAMP [=y]) -> Configure the application Network Applications ---> [*] ptpd Run PTP Two Blackfin boards running Linux connected by a switch On the master board root:/> date -s :30 root:/> ptpd2 -d -f log.master On the slave board root:/> date Tue Jun 5 05:07:07 UTC 2035 root:/> ptpd2 -d -g -f log.slave root:/> date Tue Mar 16 15:32:37 UTC 2010 Test result root:/> cat log.slave (ptpd debug)--Offset Correction– (ptpd debug)Raw offset from master: 0s 323ns (ptpd debug)--Offset and Delay filtered– (ptpd debug)offset from master: 0s 402ns (ptpd debug)observed drift: 13704 (ptpd debug)Raw offset from master: 0s 340ns (ptpd debug)--Offset and Delay filtered– (ptpd debug)offset from master: 0s 331ns (ptpd debug)Raw offset from master: 0s 516ns (ptpd debug)--Offset and Delay filtered– (ptpd debug)offset from master: 0s 428ns
61
Bluetooth over USB Almost any Bluetooth USB dongle is supported
To operate Bluetooth Devices/Interfaces bluez tools are required Kernel config [*] Networking support Networking options ---> [ ] Amateur Radio support ---> < > IrDA (infrared) subsystem support ---> <*> Bluetooth subsystem support ---> < > Generic IEEE Networking Stack --- Bluetooth subsystem support <*> L2CAP protocol support < > SCO links support <*> RFCOMM protocol support [*] RFCOMM TTY support <*> BNEP protocol support [*] Multicast filter support [*] Protocol filter support <*> HIDP protocol support Bluetooth device drivers ---> <*> HCI USB driver [ ] SCO (voice) support < > HCI UART driver (NEW) < > HCI BCM203x USB driver (NEW)
62
Bluetooth over USB Test procedure Plug in USB BT dongle
usb 1-1: new full speed USB device using sl811-hcd and address 4 usb 1-1: Product: Sitecom USB bluetooth2.0 class 2 dongle CN-512 root:/utils/exec/sbin> ./hciconfig hci0 up root:/utils/exec/sbin> ./hciconfig hci0: Type: USB BD Address: 00:10:60:D0:8C:41 ACL MTU: 384:8 SCO MTU: 64:8 root:/utils/exec/bin> ./hcitool -i hci0 dev Devices: hci0 00:10:60:D0:8C:41 root:/utils/exec/bin> ./hcitool -i hci0 scan Scanning :0C:78:50:4F:77 ANYCOM BT (MHENNER-L01) 00:0F:DE:32:FB:C3 T :10:C6:62:C0:25 JKOHLSC-L02 root:/utils/exec/bin> l2ping -i hci0 -f 00:0C:78:50:4F:77 Ping: 00:0C:78:50:4F:77 from 00:10:60:D0:8C:41 (data size 44) bytes from :0C:78:50:4F:77 id 0 time 17.79ms
63
Power management Power modes in Linux Wake up source Wake up time
Full on Blackfin full on mode Standby Blackfin Sleep Blackfin Deep sleep echo standby > /sys/power/state Mem Blackfin hibernate suspend to RAM echo mem > /sys/power/state Wake up source GPIOs RTC CAN More…. Wake up time
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.