am335x,GPIO学习
- 格式:doc
- 大小:109.50 KB
- 文档页数:3
AM335x 学习笔记1 硬件及其开发环境篇1.1 开发环境的搭建1.1.1 路由器方式的 NFS 启动1) 通过路由器的方式来启动 NFS 文件系统 设置路由器局域网的网关:192.168.1.1,然后将开发板和 PC 都连接在路由器的 LAN 端口,并且采用 DCHP 的 方式来实现 tftp 和 nfs。
2) uEnv.txtserverip=192.168.1.27 rootpath=/opt/ti-sdk-am335x-evm/targetNFS bootfile=uImage-am335x-evm.bin ip_method=dhcp tftp_nfs_boot=echo Booting from network...; dhcp ${loadaddr} ${bootfile}; run net_args; bootm ${loadaddr} uenvcmd=run tftp_nfs_boot1.1.2 Root 用户登陆#sudo passwd root #****** #****** #sudo –s –H 切换到 root 用户 然后就可以重启虚拟机,以用户 root 来登陆1.1.3 中文字库问题#locale –a 查看 是否有 zh_CN,zh_CN.gb18030,zh_CN.gb2312 等 #vim /var/lib/locales/supported.d/local#dpkg-reconfigure locales #locale-gen zh_CN.GB18030 #locale-gen zh_CN.GB2312 #locale-gen zh_CN.GBK1.1.4 环境变量设置路径#vim /etc/envinoment 常用的 3 个永久设置路径 #vim /etc/envirnoment #vim /etc/profile #vim ~/.bashrc (/root/.bashrc)1.1.5 设置 ubuntu 的上网 ip设置为 bridge 连接方式,设定静态 IP 地址.1.1.6 更改 sh 工具#rm /bin/sh # ln –s /bin/bash /bin/sh #apt-get install fakeroot1.1.7 安装必须的工具#apt-get install vim #apt-get install build-essential #apt-get install libtool #apt-get install bsion(干什么用的还不清楚) GNU autotools 主要包括三个工具 autoconf, automake,libtool1.1.8 虚拟机开发工具的安装$ sudo apt-get install build-essential libncurses-dev flex bison autoconf automake libmpfr-dev texinfo nfs-kernel-server tftpd-hpa libcloog-ppl1.2 AM335x BeagleBone 的 NFS 启动Sd 卡的识别:在/media/下面显示内容 在/dev/sd* 下显示分区 卸载:#unmount /dev/sdb1 这个是在 AM335X-LINUX-PSP-04.06.00.03 里面找的 1) 制作 sd 启动盘 MLO+uboot.img+uImage+rootfs#!/bin/bash if [[ -z $1 || -z $2 || -z $3 || -z $4 ]] then echo "mksd-am335x Usage:" echo " echo " exit fi if ! [[ -e $2 ]] then echo "Incorrect MLO location!" exit fi if ! [[ -e $3 ]] then echo "Incorrect u-boot.img location!" exit fi if ! [[ -e $4 ]] then echo "Incorrect uImage location!" exit fi if ! [[ -e $5 ]] then echo "Incorrect rootfs location!" exit fi echo "All data on "$1" now will be destroyed! Continue? [y/n]" read ans if ! [ $ans == 'y' ] then exit fi echo "[Partitioning $1...]" DRIVE=$1 dd if=/dev/zero of=$DRIVE bs=1024 count=1024 SIZE=`fdisk -l $DRIVE | grep Disk | awk '{print $5}'` echo DISK SIZE - $SIZE bytes CYLINDERS=`echo $SIZE/255/63/512 | bc` echo CYLINDERS - $CYLINDERS mksd-am335x <device> <MLO> <u-boot.img> <uImage> <rootfs tar.gz >" Example: mksd-am335x /dev/sdc MLO u-boot.img uImage nfs.tar.gz"{ echo ,9,0x0C,* echo ,,,} | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVE echo "[Making filesystems...]" mkfs.vfat -F 32 -n boot "$1"1 &> /dev/null mkfs.ext3 -L rootfs "$1"2 &> /dev/null echo "[Copying files...]" mount "$1"1 /mnt cp $2 /mnt/MLO cp $3 /mnt/u-boot.img cp $4 /mnt/uImage umount "$1"1 mount "$1"2 /mnt tar zxvf $5 -C /mnt &> /dev/null chmod 755 /mnt umount "$1"2 echo "[Done]"2) 建立 uEnv.txt (我是将 tf 卡放入读卡器,在虚拟机下面 vim 编写的。
深圳市海天雄电子有限公司Shenzhen Haitianxiong Electronic Co., Ltd. CES-AM335X产品手册TI系列开发平台Rev. V1.0Date:2016-08-03平台简介CES-AM335X开发平台是海天雄研发的一款工业级开发平台,基于TI公司Sitara系列的ARM处理器AM335X,在设计上采用高集成度的系统模块形式的核心板,核心板上集成了容量512MB的DDR3颗粒,容量1GB的SLC NandFlash 和电源管理芯片。
CES-AM335X开发平台由核心板、底板、显示驱动板、开发辅助工具组成,核心板采用AM3354,是产品定位最清晰的一个工业控制MCU,最高运行频率可达800MHz,集成了基于ARM Cortex-A8的微处理器单元、两路MAC控制器和POWERVR SGXTM图形加速器,在图像、图形处理、外设方面进行了增强,保证系统在低功耗运行的同时拥有高性能,核心板可直接用于目标产品,从而节省开发时间和开发成本;底板由各功能单元和扩展模块组成,功能单元包括常用的UART 串行数据口、USB主/从设备通用串行数据口、以太网接口、I2C通信接口、CAN通信接口、RS485通信接口、MMC/SDIO 接口、McASP接口、ADC接口、AUIAO、LVDS和RGB双路显示控制接口、GPIO输入输出功能及其他功能。
CES-AM335X开发平台可选7英寸电阻触摸液晶显示屏和10.1英寸电容触摸液晶显示屏,提供配套的开发工具包和软件程序包。
丰富的资源、优化的软硬件,完全满足大多数产品的应用,适用于工业控制、医疗电子、节能环保、智能交通、能源节能、电力系统、通讯系统、数控行业、汽车电子、工业触摸屏控制系统、机器人视觉、媒体处理无线应用、数字家电、车载设备、通信设备、网络终端等环境恶劣场合。
平台特点◆TI Cortex-A8 AM3354处理器;◆搭载512MB DDR3内存和1GB SLC NandFlash;◆支持7英寸RGB 24位电阻触摸显示屏(800*480)及10.1英寸LVDS(1024*600)显示屏;◆支持双路千兆以太网接口,包含RS485、CAN总线、USB等,满足工业应用;◆支持Linux3.2、Android4.2操作系统;功能接口核心板硬件参数软件参数——Linux 3.2软件参数——Android 4.2USB 摄像头驱动 支持USB 摄像头的预览和拍照功能 CAN 驱动 支持CAN 通讯 RS485驱动 支持RS485通讯 SPI 驱动支持SPI 通讯产品配置清单开发平台(扩展板+核心板)用户光盘串口线触摸笔网线10.1英寸电容触摸显示屏USB 线7英寸RGB 电阻显示屏(选配)电源适配器SD 卡(选配)服务支持技术支持联系方式:电话:*************86325376邮箱:************************技术支持服务时间:周一至周五:9:00~12:00,13:30~18:00免责声明本手册信息仅供用户参考使用,对于所作修改,恕不另行通知。
Board Porting\Bring up using Processor SDK RTOS for AM335xProcessor SDK RTOS component known as board library consolidates all the board-specific information so that all the modifications made when moving to a new custom platform using the SOC can be made in the source of this library.There are three different components in PRSDK that help in porting and bring up of a custom board:∙Board library updatesa.PLL Clocking and PRCMb.Pin mux Updatec.DDR Configurationd.Peripheral instances updates∙Diagnostics tests∙Boot loader updatesBoard Library Updates in Processor SDK RTOS:PLL ClockingThere are two places where the device PLL configurations are performed when using Processor SDK RTOS and CCS.Debug environment:Debug environment refers to development setup where code is debugged using JTAG emulator on the SOC. The PRSDK software relies on the GEL file that is part of the target configuration to setup the clocks and the DDR for the device. The CCS GEL file for AM335x platforms is located in the CCS package at the location ccsv7\ccs_base\emulation\boards\<boardName>For example for beagle bone black, the files can be found atccsv7\ccs_base\emulation\boards\beaglebone\gelThe GEL is the first piece of software that should be brought up on a custom board.Production environment:Production environment refers to the setup when the base application is booted from a boot media like a flash memory or host interface. In this environment, the bootloader sets performs all the SOC and board initialization and copies the application from flash memory to the device memory.The clock setup in the bootloader code can be located atpdk_am335x_x_x_x\packages\ti\starterware\bootloader\src\am335xUsers can choose to use the platform clocking similar to one of TI reference platforms or can modify them as per their application requirements. By default the PLL settings are setup for OPP_NOM settings (MPU= 600 MHz.)TI provides Clock Tree tool to allow users to simulate the clocking on the SOC. For quick reference of the multiplier and divider settings to change the PLL setting is provided in the spreadsheetAM335x_DPLL_CALCv3.xlsx.After modifying the clocking in the bootloader, users need to rebuild the bootloader using instructions provided in Processor_SDK_RTOS_BOOT_AM335x/AM437xPRCM Modules Enable:PRCM Module Enable is required to turn on the power domain and the clocking to each of the modules on the SOC. The PRCM Enable calls to enable each module are made from the functionBoard_moduleClockInit which is found in the location.pdk_am335x_1_0_9\packages\ti\board\src\bbbAM335x\bbbAM335x.cCheck every instance and peripheral required in the application platform and enable the module in the board library.For example to use three UARTs 0, 1 and 4, ensure that you have the following code as part of the board library setup:/* UART */status = PRCMModuleEnable(CHIPDB_MOD_ID_UART, 0U, 0U);status = PRCMModuleEnable(CHIPDB_MOD_ID_UART, 1U, 0U);status = PRCMModuleEnable(CHIPDB_MOD_ID_UART, 4U, 0U);Note: PRCMEnable function is defined in pdk_am335x_1_0_9\packages\ti\starterware\soc\am335x Pinmux updates in the Board library:Generating a New PinMux Configuration Using the PinMux Utility: This procedure uses the cloud-based pinmux utilityNavigate to ${PDK_INSTALL_DIR}\packages\ti\starterware\tools\pinmux_config\am335x and Load beaglebone_black_configAdd and remove peripheral instances and select the appropriate use cases required for development based on the application platform requirements and resolve all conflicts.Refer Pin_Mux_Utility_for_ARM_MPU_ProcessorsPost Processing steps:1.Change the Category filter to starterware and download the pinmux files am335x_pimnmux.hand am335x_pinmux_data.c2.At the bottom of am335x_pinmux.h change extern pinmuxBoardCfg_t gAM335xPinmuxData[];to extern pinmuxBoardCfg_t gBbbPinmuxData[];3.Change am335x_pinmux_data.c to am335x_beagleboneblack_pinmux_data.c.4.Change gAM335xPinmuxData to gBbbPinmuxData at the end of the file in file5.am335x_beagleboneblack_pinmux_data.c.Replace the existing files with the new files and rebuild the board library using the instructions in the section Rebuilding board Library in Processor SDK RTOS:Updating DDR settings:Similar to clock and PLL settings, DDR initialization is configured in the Debug environment through GEL files and in production environment using bootloader source files.TI provides AM335x_EMIF_Configuration_tips which contains a spreadsheet to enter the timing from the DDR datasheet to compute the EMIF timing number required to initialize DDR.We strongly recommend changing the value and testing using GEL files before using them in the bootloader software. For Sanity test, you can perform read/write tests using CCS Memory Browser or run the diagnostic memory read/write test that we provide in diagnostics package here:PDK_INSTALL_PATH\packages\ti\board\diag\memOnce the DDR timings have been confirmed, you can use the settings in the file:PDK_INSTALL_PATH \packages\ti\starterware\bootloader\src\am335x\sbl_am335x_platform_ddr.c Peripheral initialization:The board library is responsible for most of the SOC initialization but it also setup some board level components such as ethernet PHY and debug UART and I2C for reading board ID from EEPROM. All of the other peripheral instances and initialization needs to be done from the application level.For example for beagleboneblack, the peripheral initialization are performed from the source filepdk_am335x_1_0_9\packages\ti\board\src\bbbAM335x\bbbAM335x_lld_init.cThe debug UART instance, I2C Addresses are set using the file board_cfg.h found under:pdk_am335x_1_0_9\packages\ti\board\src\bbbAM335x\includeDefault UART instance is set to 0 in the board library. The Board initialization will configure the UART instance 0 to send binary log data to serial console using the Board_UARTInit function. If you wish to use more UART instances then we recommend linking in the UART driver in the application and using UART_open() and UART_stdioInit API calls from the application.Each peripheral driver in the Processor SDK RTOS has a SOC configuration that provides the interrupt numbers, base address, EDMA channels which can be updated using the file <peripheral>_soc.c file. This is used as default setup for initializing the driver instance. It can be overridden from the application using peripheral_getSOCInitCfg() and peripheral_setSOCInitCfg()For Example: All instances of UART for AM335x have been mapped in the filepdk_am335x_1_0_9\packages\ti\drv\uart\soc\am335x\UART_soc.cSystem integrators need to ensure that no interrupt numbers and EDMA resource conflicts exist in the SOC configuration for all drivers used in the system.To exercise three UARTs in the system, users can use the following code://Setup Debug UARTboardCfg = BOARD_INIT_PINMUX_CONFIG |BOARD_INIT_MODULE_CLOCK |BOARD_INIT_UART_STDIO;Board_init(boardCfg);// Open Additional UART Instances:/* UART SoC init configuration */UART_initConfig(false);/* Initialize the default configuration params. */UART_Params_init(&uartParams);// Open UART Instance 1uartTestInstance =1;uart1 = UART_open(uartTestInstance, &uartParams);//Open UART Instance 4uartTestInstance = 4;uart4 = UART_open(uartTestInstance, &uartParams);BoardID Detect:TI supports multiple evaluation and reference platforms for AM335x hence the hardware platforms are populated with an EEPROM which contains information that identifies the hardware and its revision. The board library and software components read the boardID and initialize the platform based on the boardID. The BoardID_detect function can be found in the source in the file bbbAM335x_info.c in the board library and board_am335x.c in the bootloader source at:<PDK_INSTALL_PATH>\packages\ti\starterware\board\am335xRebuilding board Library in Processor SDK RTOS:While Creating a new folder for the custom board is an option users can explore, TI recommends that users make there changes in existing board package using either bbbAM335x, evmAM335x oriceAM335x folder to avoid spending additional effort to modify the build files for including the customBord.Once all the update to the board library are completed, the board library can be updated using the following instructions.Instructions to rebuild board library:Setup Processor SDK build environment before following steps provided below.cd pdk_am335x_1_0_9\packagesgmake board_libFor a specific board users are required to provide the LIMIT_BOARDS argument.LIMIT_BOARDS : evmAM335x icev2AM335x iceAMIC110 bbbAM335x skAM335xFor Example for beagleboneblack, users can use the following build option:gmake board_lib LIMIT_BOARDS=bbbAM335xDiagnostics:After the board library is built, we highly recommend that you create a diagnostics package similar to one provided in board library to test different interfaces functionally during board bring up.The diagnostics package can be located at pdk_am335x_1_0_9\packages\ti\board\diag. These are simple bare-metal tests that use peripheral drivers to help functionally validate the pins and interfaces.Documentation for all available diagnostic tests is provided here:/index.php/Processor_SDK_RTOS_DIAGBootloader in Processor SDK RTOS:As part of the production flow, users are required to develop/port flashing and booting utilities so the application can be launched on the custom board with JTAG. TI provides a bootloader mechanism where the ROM bootloader loads a secondary bootloader on the onchip memory that initializes the SOC and DDR and then copies the application into DDR memory.The boot process and flashing tools have been described in detail in the following article that is part of processor SDK RTOS Software developer`s guide:/index.php/Processor_SDK_RTOS_BOOT_AM335x/AM437x#Building_the_B ootloader。
盈鹏飞嵌入式_AM335XGPMC使用总结AM335X GPMC使用比较灵活,可以配置为● 8-bit 同步或者异步并行总线 (非burst)● 16-bit 同步或者异步并行中线● 16-bit 非复用的NOR Flash● 16-bit 数据和地址总线复用的NOR Flash● 8-bit 和 16-bit NAND Flash● 16-bit pSRAM.下面以EVB335X扩展EXAR ST16C554为例,讲解如何配置GPMC。
1. 配置GPMC引脚static struct pinmux_config gpmc_pin_mux[] = {/********* 8-bit data bus **************/{"gpmc_ad0.gpmc_ad0", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},{"gpmc_ad1.gpmc_ad1", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},{"gpmc_ad2.gpmc_ad2", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},{"gpmc_ad3.gpmc_ad3", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},{"gpmc_ad4.gpmc_ad4", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},{"gpmc_ad5.gpmc_ad5", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},{"gpmc_ad6.gpmc_ad6", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},{"gpmc_ad7.gpmc_ad7", OMAP_MUX_MODE0 |AM33XX_PIN_INPUT_PULLUP},/**************** 8-bit address bus ****************/{"gpmc_a0.gpmc_a0", OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},{"gpmc_a1.gpmc_a1", OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},{"gpmc_a2.gpmc_a2", OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},{"gpmc_a3.gpmc_a3", OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},{"gpmc_a4.gpmc_a4", OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},{"gpmc_a5.gpmc_a5", OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},{"gpmc_a6.gpmc_a6", OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},{"gpmc_a7.gpmc_a7", OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},{"gpmc_csn2.gpmc_csn2", OMAP_MUX_MODE0 | AM33XX_PULL_DISA},{"gpmc_oen_ren.gpmc_oen_ren", OMAP_MUX_MODE0 | AM33XX_PULL_DISA},{"gpmc_wen.gpmc_wen", OMAP_MUX_MODE0 | AM33XX_PULL_DISA},{NULL, 0},};setup_pin_mux(gpmc_pin_mux);2. 申请GPMC内存unsigned long serial_gpmc_mem_base_phys;int cs = 2; /* EVB335X评估板中ST16C554接在CS2上 */gpmc_cs_request(cs, SZ_16M, &serial_gpmc_mem_base_phys)此时serial_gpmc_mem_base_phys存放的是该CS上多对应的物理起始地址。
AM335XGPIO详解1、配置GPIO1的时钟CM_PER RegistersCM_PER_GPIO1_CLKCTRL该寄存器管理GPIO1时钟。
OPTFCLKEN_GPIO_1_GDBCLK 可选功能时钟控制0X0 = FCLK_DIS :可选功能的时钟被禁止0x1 = FCLK_EN :可选功能时钟使能IDLEST 模块为空闲状态0X0 =函数功能:模块功能齐全,包括OCP0x1 =反:模块进行转换:唤醒或休眠,或睡眠流产0X2 =空闲:模块处于空闲模式(仅OCP部分)。
它是功能,如果使用独立的时钟功能0x3的=禁止:禁止模块,不能访问CM_PER_L4LS_CLKSTCTRL该寄存器使能域功率状态转换。
它控制着SW监督时钟域状态ON- PER和ON- INPER状态之间的转换。
它也认为每个时钟输入1个状态位域。
CLKACTIVITY_GPIO_1_GDBCLK 该字段表示在该GPIO1_GDBCLK时钟的状态域。
0X0 = INACT :对应的时钟门控0x1 =ACT:通讯时钟有效2、配置GPIO端口功能CONTROL_MODULE Registersconf_gpmc_a0-a11 设置内部上拉和管脚传输速率:快或慢3、重启GPIO模块GPIO_SYSCONFIG 寄存器1 SOFTRESET R/W Software reset.This bit is automatically reset by the hardware. During reads, it always returns 0.0x0 = Normal mode0x1 = The module is rese软件复位。
该位由硬件自动复位。
在读取时,它总是返回0 。
0X0 =普通模式为0x1 =该模块复位4、设置GPIO方向GPIO_OE[0-31] 寄存器输出数据使能0X0 =相应的GPIO端口被配置为输出。
0x1 =相应的GPIO端口配置为输入。
AM335X平台开发日记2014-11-24至2014-11-29进行核心板原理图设计2014-12-1至2014-12-10进行PCB设计。
2014-12-5开始学习AM335X软件部分的知识。
安装了vmware虚拟机,10.0.1版本的。
安装了ubunt12.04版本。
安装vmware-tools,创建共享文件夹。
在root(需执行sudo su)下执行mount -t vmhgfs .host:/ /mnt/hgfs在windows共享文件夹存放TI安装包ti-sdk-am335x-evm-06.00.00.00-Linux-x86-Install.bin。
在终端里面执行安装。
安装目录为/usr/local/ti-sdk-am335x-evm#,一般会自动加入环境变量,如果没有,在/etc/environment增加环境变量:(注意:6.0的安装包不支持ubunt14.04版本,只支持12.04以下的版本)PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/l ocal/ti-sdk-am335x-evm/linux-devkit/sysroots/i686-arago-linux/usr/bin:"输入命令arm-linux-gnueabihf-gcc –v即可查询版本执行setup.sh配置linux环境,例如安装包更新,NFS,TFTP,minicom等。
下载了Uniflash V3,准备选择USB或者ETH接口进行FLASH编程。
执行命令make CROSS_COMPILE=arm-linux-gnueabihf- O=am335x ARCH=armam335x_evm编译u-boot,生成MLO(spl)和u-boot.imgNandflash程序分区:1.0-0x1ffff 为SPL2.0x20000-0x3ffff为SPL backup13.0x40000-0x5ffff为SPL backup24.0x60000-0x7ffff为SPL backup35.0x80000-0x25ffff为uboot6.0x260000 -0x27ffff为env7.0x280000-0x77ffff为linux kernel8.0x780000- 为file system9.下载uboot软件并进行修改适应新设计的核心板,并把uboot下载到板子里调试运行。
[A8] am335x_starterware—GPIO demo学习本例程实现功能比较简单,实现LED灯的闪烁。
1、主流程图1-1 GPIO程序主流程像常见LED闪烁程序一样,都是先配置,然后采取:置高-延时-拉低-延时-置高-延时……的方式,实现闪烁。
2、各子函数说明2.1 GPIO1ModuleClkConfig()配置GPIO1寄存器CM_PER_GPIO1_CLKCTRL(或上0x00000002),使能该GPIO1模块。
等待配置完毕。
P1049。
配置GPIO1寄存器CM_PER_GPIO1_CLKCTRL(或上0x00040000),使能GPIO1模块时钟。
等待配置完毕。
P1049。
检测GPIO1是否处于闲置状态CM_PER_GPIO1_CLKCTRL[17-16],若处于非fully functional状态,则等待。
P1049。
检测L4的CM_PER_L4LS_CLKSTCTRL的[19]位,查看GPIO1_GDBCLK时钟是否激活。
若未激活(Inact)则等待。
P1020。
2.2 GPIO1Pin23PinMuxSetup()GPIO1Pin23PinMuxSetup()配置GPMC_A7(GPIO1_23)引脚,配置为高速、下拉并使能。
Register=0x00000007。
p1278。
功能服用配置位为该寄存器[2:0],配置为111b,还未搞清楚。
2.3 GPIOModuleEnable()GPIOModuleEnable(GPIO_INSTANCE_ADDRESS)配置GPIO1时钟使能,GPIO_CTRL。
GPIO_CTRL[0]=0,使能GPIO1模块。
P4524。
2.4 GPIOModuleReset()GPIOModuleReset(GPIO_INSTANCE_ADDRESS)复位GPIO1各端口。
GPIO_SYSCONFIG。
GPIO_SYSCONFIG[1]=1,软件写1复位,复位GPIO1各端口。
AM335x通用EVM硬件用户指南本文档介绍了AM335x评估模块(EVM)(TMDXEVM3358)这是基于德州仪器AM335x处理器的硬件体系结构。
该EVM通常也被称为AM335x通用(GP)EVM。
AM335x通用EVM是一个独立的测试,开发和评估模块系统,它使开发人员能够编写周围的AM335x处理器子系统的软件和硬件开发。
已经可用的EVM板的基础上,为开发人员提供了所需的基本资源最通用的类型的项目,包括作为主处理器的AM335x AM335x子系统的主要内容。
此外,额外的,“典型的”外围设备内置的的EVM如存储器,传感器,LCD,以太网PHY等,使未来的系统可以模拟快速显着的额外的硬件资源。
以下各节提供有关EVM的更多细节。
AM335x通用EVM的系统视图是由底板,子板,液晶显示板叠放在一起,通过标准的通孔连接器连接。
请参阅下面的图片的EVM。
图1:AM335x通用EVM 图2:的AM335x底板底查看AM335x完整的通用EVM被划分在三个不同的电路板的模块化。
GP EVM包括基板(处理器和主电源),子板(外围设备)和液晶显示板(LCD和触摸屏)。
图3:AM335x的EVM系统板图处理器TMXAM3359ZCZ处理器是此EVM的中央处理器。
在黑板上的所有资源环绕TMXAM3359处理器提供的硬件和软件开发能力。
请参阅的TMXAM3359数据表和TRM的处理器的详细信息。
有系统的配置信号,SYSBOOT,也可以设置在EVM上AM335x处理器定义一些启动参数。
有关详细信息,请参阅“配置/设置”一节。
EVM有几个时钟,支持AM3359处理器。
为处理器的主时钟是来自从24MHz晶体。
片上振荡器的AM3359产生基准时钟,后续的模块需要在AM3359处理器的时钟。
一个32kHz的时钟RTC的AM3359是来自一个32kHz的晶体在黑板上。
SYS_RESETn是运行多个外设和的AM335x其中执行这些外围设备的复位信号。
gpio操作实验原理-回复GPIO操作实验原理GPIO(General Purpose Input Output)是通用输入输出引脚,它是计算机系统与外部设备交互的一种重要方式。
在本文中,我们将探讨GPIO 操作实验的原理,包括什么是GPIO、GPIO操作的基本原理、GPIO的引脚模式以及如何进行GPIO实验等内容。
一、什么是GPIO?GPIO是指通用输入输出引脚,它是一种用于与计算机系统或单片机交互的接口。
它既可以作为输入端口,接收外部设备(例如传感器)的信号;又可以作为输出端口,控制外部设备(例如LED灯)的状态。
在计算机系统中,GPIO常见的接口类型有电平接口和串行接口。
电平接口通过高低电平的变化来传递信息,例如电平为高表示1,电平为低表示0;而串行接口则通过一系列的位来传递信息,例如通过SPI(串行外设接口)或I2C(串行总线)。
二、GPIO操作的基本原理GPIO操作的基本原理是通过对GPIO引脚的输入输出控制来实现与外部设备的交互。
具体而言,通过设置引脚的输入模式或输出模式,以及设置引脚的高低电平,来实现对外部设备的读取或控制。
1. GPIO引脚的模式GPIO引脚有两种基本模式:输入模式和输出模式。
输入模式:当GPIO引脚设置为输入模式时,它可以接收来自外部设备的信号。
在输入模式下,引脚可以通过读取电平(高或低)来获取外部设备的状态信息。
输出模式:当GPIO引脚设置为输出模式时,它可以控制外部设备的状态。
在输出模式下,引脚可以通过写入电平(高或低)来改变外部设备的状态。
2. 设置引脚模式在实际的GPIO操作中,我们需要调用相应的库函数或底层驱动来设置GPIO引脚的模式。
这些库函数或底层驱动会将对应的寄存器进行配置,以确定引脚是输入还是输出,并启用相应的电平逻辑。
3. 设定引脚电平在GPIO操作中,我们可以通过相应的库函数或底层驱动来设定引脚的电平(高或低)。
设定引脚的电平可以通过改变GPIO引脚上的电气信号来控制与其连接的外部设备。
1、AM335X 裸机下,配置TIMER4输出PWM,输出IO为GPIO_19,即XDMA_EVENT_INTR0,主要配置代码如下:#include"consoleUtils.h"#include"soc_AM335x.h"#include"evmskAM335x.h"#include"interrupt.h"#include"dmtimer.h"#include"cache.h"#include"error.h"#include"mmu.h"#include"gpio_v2.h"#include"pin_mux.h"/******************************************************************************** INTERNAL MACRO DEFINITIONS*******************************************************************************/#define DMTIMER_INSTANCE (SOC_DMTIMER_4_REGS)#define TIMER_INITIAL_COUNT (0xFFFFC000)#define TIMER_RLD_COUNT (0xFFFFC000)#define TIMER_DUTY_COUNT (0xFFFFE000)int main(void){/*将A15(即XDMA_EVENT_INTR0)引脚配置成 MODE2,即为TIMER4的PWM输出模式*/HWREG(SOC_CONTROL_REGS + CONTROL_CONF_XDMA_EVENT_INTR(0)) = ((0x00000020u) + CONTROL_CONF_MUXMODE(2));/* This function will enable clocks for the DMTimer2 instance */DMTimer4ModuleClkConfig();/* Perform the necessary configurations for DMTimer */DMTimerSetUp();/* Start the DMTimer */DMTimerEnable(DMTIMER_INSTANCE);while(1);}/*** Setup the timer for one-shot and compare mode.*/static void DMTimerSetUp(void){/* Load the counter with the initial count value */DMTimerCounterSet(DMTIMER_INSTANCE, TIMER_INITIAL_COUNT);/* Load the load register with the reload count value */DMTimerReloadSet(DMTIMER_INSTANCE, TIMER_RLD_COUNT);/*Set the match register with the compare value */DMTimerCompareSet(DMTIMER_INSTANCE, TIMER_DUTY_COUNT);/* Configure the DMTimer for Auto-reload and compare mode */DMTimerModeConfigure(DMTIMER_INSTANCE,0x000018C2);//DMTIMER_AUTORLD_NOCMP_E NABLE);}在dmtimer.c中修改的地方void DMTimerModeConfigure(unsigned int baseAdd, unsigned int timerMode){/* Wait for previous write to complete */DMTimerWaitForWrite(DMTIMER_WRITE_POST_TCLR, baseAdd);/* Clear the AR and CE field of TCLR */HWREG(baseAdd + DMTIMER_TCLR) &= ~(DMTIMER_TCLR_AR | DMTIMER_TCLR_CE | DMTIMER_TCLR_TRG);// ~(DMTIMER_TCLR_AR | DMTIMER_TCLR_CE);/* Wait for previous write to complete */DMTimerWaitForWrite(DMTIMER_WRITE_POST_TCLR, baseAdd);/* Set the timer mode in TCLR register */HWREG(baseAdd + DMTIMER_TCLR) |= timerMode;//(timerMode & (DMTIMER_TCLR_AR |// DMTIMER_TCLR_CE |// DMTIMER_TCLR_TRG));}2、需要注意的地方XDMA_EVENT_INTR0在MODE2模式下为TIMER4的PWM输出,配置方式HWREG(SOC_CONTROL_REGS + CONTROL_CONF_XDMA_EVENT_INTR(0)) = ((0x00000020u) + CONTROL_CONF_MUXMODE(2));3、计数方式需要注意#define TIMER_INITIAL_COUNT (0xFFFFC000)#define TIMER_RLD_COUNT (0xFFFFC000)#define TIMER_DUTY_COUNT (0xFFFFE000)计数从0xFFFFC000开始,当计数到0xFFFFE000时,产生边沿跳变,计数到0xFFFFFFFF 时,重新装载计数初始值。
GPIO用法及应用流程GPIO(General Purpose Input/Output)是一种通用输入/输出接口,用于连接嵌入式系统的外部设备和传感器。
它可以通过编程来控制和读取外部设备的状态,并在嵌入式系统中实现各种应用功能。
下面将详细介绍GPIO的用法及应用流程。
一、GPIO的用法:1.引脚模式设置:GPIO的引脚可以设置为输入模式(用于读取外部设备的状态)或输出模式(用于控制外部设备的状态)。
2.引脚方向设置:输入模式的引脚可以设置为上拉电阻或下拉电阻,以防止悬浮状态产生误判;输出模式的引脚可以设置为高电平或低电平。
3.引脚状态读取与控制:可以通过读取引脚的电平状态来获取外部设备的状态信息;也可以通过控制引脚的电平状态来控制外部设备的行为。
4.中断与事件:可以在引脚电平变化时产生中断或触发事件,以便及时响应引脚的状态变化。
5.管理多个引脚:可以同时管理多个GPIO引脚,实现更复杂的应用功能。
二、GPIO的应用流程:1.引脚初始化:在使用GPIO之前,需要将相关引脚初始化为输入或输出模式,并设置正确的引脚方向、上拉/下拉电阻等属性。
2.读取引脚状态:通过读取引脚的电平状态来获取外部设备的状态信息。
可以使用轮询方式或中断方式进行读取。
3.控制引脚状态:通过控制引脚的电平状态来控制外部设备的行为。
可以将引脚设置为高电平或低电平,或者使用PWM(脉冲宽度调制)方式进行精确控制。
4.处理引脚中断/事件:当引脚发生电平变化时,可以通过中断或事件的方式及时响应引脚的状态变化,进而执行相应的处理任务。
5.循环读取/控制:通常情况下,GPIO的读取和控制操作需要在一个循环中进行,以不断更新外部设备的状态或响应外部变化。
三、GPIO的应用示例:1.LED控制:将GPIO引脚设置为输出模式,通过控制引脚的电平状态来控制LED的亮灭。
2.按钮读取:将GPIO引脚设置为输入模式,读取按钮的电平状态来判断按钮是否被按下。
MYD-AM335X-J Linux 开发手册版本V1.12014/10/23版本记录目录第1章概述及软件资源介绍 (1)1.1 概述 (1)1.2 软件资源 (1)第2章Linux开发环境搭建 (3)2.1 建立工作目录 (3)2.2 设置交叉编译工具 (3)2.3 安装工具 (3)第3章Linux系统编译 (4)3.1 编译Bootloader (4)3.2 编译Linux内核 (5)3.3 制作文件系统 (5)第4章Linux 系统烧写 (6)4.1 TF卡系统映像更新 (6)4.2 NAND Flash更新/恢复 (7)第5章Linux应用程序 (10)5.1 GPIO (10)5.2 NET (10)5.3 RTC (11)5.4 LCD (11)5.5 Audio (12)5.6 I2C总线测试 (12)5.7 串口 (12)5.8 RS485 (12)5.9 CAN (13)5.10 引脚功能切换 (13)5.10.1 RS485_1跟UART5_RTSCTS 切换145.10.2 RS485_2和UART3切换及CAN1和UART4切换15第6章Qt开发 (17)6.1 使用光盘提供的Qt SDK (17)6.2 交叉编译Qt开发环境 (17)6.3 移植Qt到开发板 (18)6.4 交叉编译Qt应用程序 (19)第1章概述及软件资源介绍1.1 概述MYD-AM335X-J提供了丰富的系统资源和软件资源,本手册将从环境搭建开始,一步步介绍如何进行MYD-AM335X-J Linux开发。
本手册中开发主机上的命令以Ubuntu为例进行教授。
1.2 软件资源表1-1第2章Linux开发环境搭建2.1 建立工作目录拷贝MYD-AM335X-J光盘中的资料到主机中:$ mkdir -p <WORKDIR>$ cp -a <DVDROM>/05-Linux_Source/* <WORKDIR>2.2 设置交叉编译工具$ cd <WORKDIR>/Toolchain$ tar -xvjf \gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux.tar.bz2$ export PATH=$PATH:<WORKDIR>/Toolchain/\gcc-linaro-arm-linux-gnueabihf-4.7-2013.03-20130313_linux/bin$ export CROSS_COMPILE=arm-linux-gnueabihf-执行完“export”命令后输入arm按Tab键来检查是否设置成功,该设置只对当前终端有效,如需永久修改,请修改用户配置文件。
本文主要描述在EVB335X-II以Device Tree的方式移植新TI官网AM335X系列最新的linux-3.14.43版本内核以及移植Debian文件系统的过程及遇到的一些问题。
整个Device Tree牵涉面比较广,即增加了新的用于描述设备硬件信息的文本格式(即.dts文件),又增加了编译这一文本的工具,同时Bootloader也需要支持将编译后的Device Tree传递给Linux内核。
以下是修改步骤:一、修改uboot,支持Device TreeEVB335X-II在linux-3.2版本内核移植的时候已经有uboot,因此只需在该uboot上增加Device Tree支持即可,以下是修改步骤:1、修改include/configs/com335x.h文件,增加支持DT的宏定义:/* Flattened Device Tree */#define CONFIG_OF_LIBFDT2、修改uboot启动参数,增加dtb文件的加载和启动(由于目前只是移植EMMC版本的EVB335X-II,因此只需修改EMMC的启动参数即可,大概在405行),修改如下:#elif defined(CONFIG_EMMC_BOOT)#define CONFIG_BOOTCOMMAND \"run mmcboot;"#define CONFIG_EXTRA_ENV_SETTINGS \"lcdtype=AUO_AT070TN94\0" \"console=ttyO0,115200n8\0" \"mmcroot=/dev/mmcblk0p2 rw\0" \"mmcrootfstype=ext4 rootwait\0" \"mmcargs=setenv bootargs console=${console} noinitrd root=${mmcroot} rootfstype=${mmcrootfstype} lcdtype=${lcdtype} consoleblank=0\0" \"mmcdev=" MMCDEV "\0" \"loadaddr=0x81000000\0" \"dtbfile=evb335x-ii-emmc.dtb\0" \"bootenv=uEnv.txt\0" \"bootpart=" BOOTPART "\0" \"loadbootenv=load mmc ${mmcdev} ${loadaddr} ${bootenv}\0" \"importbootenv=echo Importing environment from mmc ...; " \"env import -t $loadaddr ${filesize}\0" \"loadaddr-dtb=0x82000000\0" \"loadimage=load mmc ${bootpart} ${loadaddr} uImage\0" \"loaddtb=load mmc ${bootpart} ${loadaddr-dtb} ${dtbfile}\0" \"mmcboot=mmc dev ${mmcdev}; " \"if mmc rescan; then " \"echo SD/MMC found on device ${mmcdev};" \"if run loadbootenv; then " \"echo Loaded environment from ${bootenv};" \"run importbootenv;" \"fi;" \"run mmcargs;" \"if run loadimage; then " \"run loaddtb;" \"bootm ${loadaddr} - ${loadaddr-dtb};" \"fi;" \"fi; \0"#endif以上,红色为修改部分。
GPIO模式详解GPIO(General-Purpose Input/Output)即通用输入输出口,是一种通用的数字输入输出接口。
在嵌入式系统中,GPIO被广泛应用于控制外围设备和传感器,如LED灯、按钮、蜂鸣器等。
GPIO具有灵活性强、适用范围广的特点,可以通过软件对其进行编程配置,从而实现各种功能。
GPIO的模式主要分为输入模式和输出模式两种。
1.输入模式:在输入模式下,GPIO被配置为接收外部信号的输入。
GPIO的输入信号可以是高电平(1)或低电平(0),也可以是无效信号(high impedance)。
在输入模式下,GPIO可以检测外部信号的变化,并将其转换为数字信号供处理器使用。
输入模式常见的应用场景:-按钮输入:将按钮连接到GPIO引脚,通过检测按钮的按下和释放事件来触发相应操作。
-传感器输入:将各种传感器连接到GPIO引脚,通过读取传感器的输出信号来获取环境信息。
-外部设备状态检测:连接到外部设备的引脚,通过读取外部设备的状态信号来判断设备是否工作正常。
2.输出模式:在输出模式下,GPIO被配置为向外部设备输出信号。
GPIO的输出信号可以是高电平(1)或低电平(0),也可以是高阻抗状态(高阻抗状态即断开与外部设备的连接)。
输出模式下,GPIO通过改变电平来控制外部设备的状态。
输出模式常见的应用场景:-LED控制:将LED连接到GPIO引脚,通过控制GPIO的电平来打开或关闭LED。
-舵机控制:将舵机连接到GPIO引脚,通过控制GPIO的电平来控制舵机的转动方向和角度。
-蜂鸣器控制:将蜂鸣器连接到GPIO引脚,通过控制GPIO的电平来触发蜂鸣器的鸣叫。
GPIO的模式配置需要通过软件编程实现,不同的平台和操作系统有不同的配置方法。
1.引脚选择:选择要配置的GPIO引脚,通常通过引脚编号或名称进行选择。
2.模式选择:选择要配置的模式,即输入模式还是输出模式。
3.状态设置:根据选择的模式,设置相应的状态,如输入模式下的上拉/下拉,输出模式下的高电平/低电平。
gpio读写操作GPIO(General Purpose Input/Output)是嵌入式系统中常见的一种输入/输出接口。
它不仅可以用于与其他模块进行通信,还可以与外部设备连接,实现数据的输入和输出。
本文将介绍如何进行GPIO的读写操作。
首先,我们需要了解一些基本概念。
在嵌入式系统中,GPIO被视为一组寄存器或寄存器组,用于控制特定的硬件引脚。
每个引脚都有一个唯一的数字标识符,用于在软件中进行控制。
GPIO的读写操作可以分为以下步骤:1. 引入相关的库和头文件:在进行GPIO操作之前,需要引入相应的库和头文件。
一般来说,使用C或C++编程语言,可以引入相应的GPIO库和头文件,如wiringPi、bcm2835等。
2. 初始化GPIO:在进行GPIO操作之前,需要对GPIO进行初始化。
初始化过程中,需要设置GPIO的模式,即输入或输出。
可以使用相应的函数或语句进行初始化,如`pinMode()`函数。
3. 读取GPIO:读取GPIO引脚的状态是一个常见的操作。
可以使用相应的函数或语句来读取GPIO的状态,如`digitalRead()`函数。
函数的返回值通常是高电平(High)或低电平(Low),分别对应1和0。
4. 写入GPIO:写入GPIO引脚的状态是另一个常见的操作。
可以使用相应的函数或语句来写入GPIO的状态,如`digitalWrite()`函数。
函数的参数通常是高电平(High)或低电平(Low),分别对应1和0。
在进行GPIO读写操作时,需要注意以下几点:1. 引脚模式:在初始化GPIO时,需要设置引脚的模式。
一般来说,引脚可以设置为输入模式(Input)或输出模式(Output)。
不同的模式会对读写操作产生影响。
2. 引脚编号:每个GPIO引脚都有一个唯一的数字标识符,用于在软件中进行控制。
在进行读写操作时,需要指定相应的引脚编号。
3. 电平状态:GPIO的读写操作通常涉及引脚的电平状态。
OK335X-Linux用户手册第一章OK335X简介OK335X开发板基于TI AM335X处理器,运行主频最高720M,支持Linux,WinCE,Android三大操作系统,可用于工业产品设计。
OK335X有核心板和底板组成,核心板主要芯片有:CPU,NandFlash,Memory,PowerManage。
使用我们的核心板,只需要根据您的业务需求开发自己的底板,这样可加速您的产品上市时间,让您从平台搭建的复杂环境中脱离。
下面我们具体描述OK335X核心板和底板资源。
OK335X产品图片如下所示:核心板硬件资源:1CPU主频:720M(支持AM3352,AM3354,AM3356,AM3357,AM3358,AM3359)2NandFlash:256M(Micro SLC)3Memory:265M(Micro DDR2)4PowerManage IC:TPS65217B(TI AM335X专用电源IC)底板资源:14路串口(2个232电平,2个TTL电平,232电平已经使用DB9座子引出,其中COM0作为调试串口使用,注意:OK335X-V1底板中UART4暂时不能使用,下一硬件版本将修正这个问题)。
21路100M网口3音频接口(1路Phone输出,1路Line-in输入)41个SD卡接口56个用户按键63路I2C接口71个LCD接口(支持RGB888模式,支持电阻触摸和电容触摸。
默认标配7寸电阻屏)81路PWM接口,用于蜂鸣器测试。
91路Can接口101路SDIO接口11多路用户IO接口12四路USB2.0接口,一路USB2.0OTG(目前板子为一路USB Host接口,后续会增加到四路USB HUB)131路SPI接口148路AD(其中4路用于电阻触摸,1路用于滑动变阻器AD测试,其余3路通过插针引出,另外滑动变阻器端有跳线设置,通过跳线可以设置这路AD用于插针引出,还是用于可调电阻测试)15引出总线接口(缺省未焊接底座)161个RESET按钮,用于系统复位。
Linux下AM335X的GPIO控制作者:chenzhufly QQ:36886052 ( 转载请注明出处)一路走来,熟悉硬件系统,搭建软件开发环境,编译Linux系统等等,现在也该到对硬件做一些事情了,这是我这几天的研究心得,与君共享。
1. GPIO的char型驱动,这里主要就是点个灯,感受一下驱动的设计和硬件的控制驱动程序:static int major =251;//定义主设备号/*******************************************/void led_on(void){gpio_set_value(GPIO_TO_PIN(1,22), 1);}void led_off(void){gpio_set_value(GPIO_TO_PIN(1,22), 0);}void led_init(void){int result;/* Allocating GPIOs and setting direction */result = gpio_request(GPIO_TO_PIN(1,22), \"Leds\");//usr1if (result != 0)printk(\"gpio_request(1_22) failed!\n\");result = gpio_direction_output(GPIO_TO_PIN(1,22), 1);if (result != 0)printk(\"gpio_direction(1_22) failed!\n\");}struct light_dev{struct cdev cdev;unsigned char value;};struct light_dev *light_devp;MODULE_AUTHOR(\"chenzhufly\");MODULE_LICENSE(\"Dual BSD/GPL\");// 打开和关闭函数int light_open(struct inode *inode,struct file *filp){struct light_dev *dev;// 获得设备结构体指针dev = container_of(inode->i_cdev,struct light_dev,cdev);// 让设备结构体作为设备的私有信息filp->private_data = dev;return 0;}int light_release(struct inode *inode,struct file *filp) {return 0;}// ioctlint light_ioctl(struct file *filp,unsigned int cmd, unsigned long arg){struct light_dev *dev = filp->private_data;switch(cmd){case 0:dev->value = 0;led_off();break;case 1:dev->value = 1;led_on();break;default:return -ENOTTY;// break;}return 0;}struct file_operations light_fops ={.owner = THIS_MODULE,.unlocked_ioctl = light_ioctl,应用程序:Makefile文件:leds.sh脚本2. 使用echo命令,这个我在前面也说过3. 做个应用程序实现流水灯功能吧复制内容到剪贴板代码:#include <stdio.h> #include <unistd.h>#include <sys/types.h>#include <sys/ipc.h>#include <sys/ioctl.h>#include <fcntl.h>#define LED1 \"/sys/class/leds/beaglebone::usr1/brightness\" // usr1 led #define LED2 \"/sys/class/leds/beaglebone::usr2/brightness\" // usr2 led #define LED3 \"/sys/class/leds/beaglebone::usr3/brightness\" // usr3 ledint main(void){int f_led1 = open(LED1, O_RDWR);int f_led2 = open(LED2, O_RDWR);int f_led3 = open(LED3, O_RDWR);unsigned char dat1, dat2, dat3;unsigned char i = 0;if (f_led1 < 0){printf(\"error in open %s\",LED1);return -1;}if (f_led2 < 0){printf(\"error in open %s\",LED2);return -1;}if (f_led3 < 0){printf(\"error in open %s\",LED3);return -1;}//add 10 timesfor(i=1; i<30; i++){dat1 = ((i%3) == 1) ? '1' : '0';dat2 = ((i%3) == 2) ? '1' : '0';dat3 = ((i%3) == 0) ? '1' : '0'; write(f_led1, &dat1, sizeof(dat1)); write(f_led2, &dat2, sizeof(dat2)); write(f_led3, &dat3, sizeof(dat3)); usleep(300000);}// all the bright{dat1 = '1';dat2 = '1';dat3 = '1';write(f_led1, &dat1, sizeof(dat1)); write(f_led2, &dat2, sizeof(dat2)); write(f_led3, &dat3, sizeof(dat3)); }}。
AM335x 学习笔记1硬件及其开发环境篇1.1开发环境的搭建1.1.1路由器方式的NFS启动1)通过路由器的方式来启动NFS文件系统设置路由器局域网的网关:192.168.1.1,然后将开发板和PC都连接在路由器的LAN端口,并且采用DCHP的方式来实现tftp和nfs。
2)uEnv.txtserverip=192.168.1.27rootpath=/opt/ti-sdk-am335x-evm/targetNFSbootfile=uImage-am335x-evm.binip_method=dhcptftp_nfs_boot=echo Booting from network...; dhcp ${loadaddr} ${bootfile}; run net_args; bootm ${loadaddr} uenvcmd=run tftp_nfs_boot1.1.2Root用户登陆#sudo passwd root#******#******#sudo –s –H 切换到root用户然后就可以重启虚拟机,以用户root来登陆1.1.3中文字库问题#locale –a 查看是否有zh_CN,zh_CN.gb18030,zh_CN.gb2312等#vim /var/lib/locales/supported.d/local#dpkg-reconfigure locales#locale-gen zh_CN.GB18030#locale-gen zh_CN.GB2312#locale-gen zh_CN.GBK1.1.4环境变量设置路径#vim /etc/envinoment常用的3个永久设置路径●#vim /etc/envirnoment●#vim /etc/profile●#vim ~/.bashrc (/root/.bashrc)1.1.5设置ubuntu的上网ip设置为bridge连接方式,设定静态IP地址.1.1.6更改sh工具#rm /bin/sh# ln –s /bin/bash /bin/sh#apt-get install fakeroot1.1.7安装必须的工具#apt-get install vim#apt-get install build-essential#apt-get install libtool#apt-get install bsion(干什么用的还不清楚)GNU autotools主要包括三个工具autoconf, automake,libtool1.1.8虚拟机开发工具的安装$ sudo apt-get install build-essential libncurses-dev flex bison autoconf automake libmpfr-dev texinfo nfs-kernel-server tftpd-hpa libcloog-ppl1.2AM335x BeagleBone 的NFS启动Sd卡的识别:在/media/下面显示内容在/dev/sd* 下显示分区卸载:#unmount /dev/sdb1这个是在AM335X-LINUX-PSP-04.06.00.03里面找的1)制作sd启动盘MLO+uboot.img+uImage+rootfs#!/bin/bashif [[ -z $1 || -z $2 || -z $3 || -z $4 ]]thenecho "mksd-am335x Usage:"echo "mksd-am335x <device> <MLO> <u-boot.img> <uImage> <rootfs tar.gz >"echo "Example: mksd-am335x /dev/sdc MLO u-boot.img uImage nfs.tar.gz"exitfiif ! [[ -e $2 ]]thenecho "Incorrect MLO location!"exitfiif ! [[ -e $3 ]]thenecho "Incorrect u-boot.img location!"exitfiif ! [[ -e $4 ]]thenecho "Incorrect uImage location!"exitfiif ! [[ -e $5 ]]thenecho "Incorrect rootfs location!"exitfiecho "All data on "$1" now will be destroyed! Continue? [y/n]"read ansif ! [ $ans == 'y' ]thenexitfiecho "[Partitioning $1...]"DRIVE=$1dd if=/dev/zero of=$DRIVE bs=1024 count=1024SIZE=`fdisk -l $DRIVE | grep Disk | awk '{print $5}'`echo DISK SIZE - $SIZE bytesCYLINDERS=`echo $SIZE/255/63/512 | bc`echo CYLINDERS - $CYLINDERS{echo ,9,0x0C,*echo ,,,-} | sfdisk -D -H 255 -S 63 -C $CYLINDERS $DRIVEecho "[Making filesystems...]"mkfs.vfat -F 32 -n boot "$1"1 &> /dev/nullmkfs.ext3 -L rootfs "$1"2 &> /dev/nullecho "[Copying files...]"mount "$1"1 /mntcp $2 /mnt/MLOcp $3 /mnt/u-boot.imgcp $4 /mnt/uImageumount "$1"1mount "$1"2 /mnttar zxvf $5 -C /mnt &> /dev/nullchmod 755 /mntumount "$1"2echo "[Done]"2)建立uEnv.txt(我是将tf卡放入读卡器,在虚拟机下面vim编写的。
[A8] am335x_starterware
—GPIO demo学习本例程实现功能比较简单,实现LED灯的闪烁。
1、主流程
图1-1 GPIO程序主流程
像常见LED闪烁程序一样,都是先配置,然后采取:置高-延时-拉低-延时-置高-延时……的方式,实现闪烁。
2、各子函数说明
2.1 GPIO1ModuleClkConfig()
配置GPIO1寄存器CM_PER_GPIO1_CLKCTRL(或上0x00000002),使能该GPIO1模块。
等待配置完毕。
P1049。
配置GPIO1寄存器CM_PER_GPIO1_CLKCTRL(或上0x00040000),使能GPIO1模块时钟。
等待配置完毕。
P1049。
检测GPIO1是否处于闲置状态CM_PER_GPIO1_CLKCTRL[17-16],若处于非fully functional状态,则等待。
P1049。
检测L4的CM_PER_L4LS_CLKSTCTRL的[19]位,查看GPIO1_GDBCLK时钟是否激活。
若未激活(Inact)则等待。
P1020。
2.2 GPIO1Pin23PinMuxSetup()
GPIO1Pin23PinMuxSetup()
配置GPMC_A7(GPIO1_23)引脚,配置为高速、下拉并使能。
Register=0x00000007。
p1278。
功能服用配置位为该寄存器[2:0],配置为111b,还未搞清楚。
2.3 GPIOModuleEnable()
GPIOModuleEnable(GPIO_INSTANCE_ADDRESS)
配置GPIO1时钟使能,GPIO_CTRL。
GPIO_CTRL[0]=0,使能GPIO1模块。
P4524。
2.4 GPIOModuleReset()
GPIOModuleReset(GPIO_INSTANCE_ADDRESS)
复位GPIO1各端口。
GPIO_SYSCONFIG。
GPIO_SYSCONFIG[1]=1,软件写1复位,复位GPIO1各端口。
P4519。
2.5 void GPIODirModeSet()
void GPIODirModeSet(unsigned int baseAdd,
unsigned int pinNumber,
unsigned int pinDirection)
配置相应GPIO,相应引脚的输入输出方向位:
baseAdd:GPIOn首地址;
pinNumber:GPIO待配置端口号;
pinValue:GPIO相应端口的输入输出方向状态;
调用:GPIODirModeSet( GPIO_INSTANCE_ADDRESS,
GPIO_INSTANCE_PIN_NUMBER,
GPIO_DIR_OUTPUT);
配置GPIO1_23输入输出方向位。
GPIO_OE。
GPIO_OE[23]=0,将GPIO1_23置为输出。
P4524。
2.6 void GPIOPinWrite()
void GPIOPinWrite(unsigned int baseAdd,
unsigned int pinNumber,
unsigned int pinValue)
配置GPIO相应管脚的高低电平状态。
baseAdd:GPIOn首地址;
pinNumber:GPIO待配置端口号;
pinValue:GPIO相应端口的高低电平状态;
调用:GPIOPinWrite(GPIO_INSTANCE_ADDRESS,
GPIO_INSTANCE_PIN_NUMBER,
GPIO_PIN_HIGH);
置位:向GPIO_SETDATAOUT对应位写1;P4529;
清零:向GPIO_CLEARDA TAOUT对应位写1;P4529;
2.7 注意
在am335x_starterware程序包中,上述同名函数原型可能不止一个。
阅读时注意选beaglbebone目录下的函数。