= Beagle Board Support = [[TOC(Boards/Beagle Board, depth=4)]] The page details how to run RTEMS on a [http://beagleboard.org/ Beagle Board] family of boards. The Beagle Boards are supported by [http://www.denx.de/wiki/U-Boot U-Boot] and [http://www.denx.de/wiki/U-Boot U-Boot] can boot RTEMS. Please refer to the U-Boot documentation and the internet for documentation and example on using U-Boot. This page provide details on updating a Beaglebone Black board. Please update and support for other Beagle Boards. = Consoles = RTEMS uses the console for a booting and as the primary interface. These are UARTs on the Beagle Boards. We recommend you have a working console and the default Linux images from the Beagle Board project use the UART consoles when booting and initialising. == Beagleboard-MX Console == The Beagleboard-MX has a standard female DB9 RS-232 connector. You will need an RS-232 to USB converter. == Beagle Bone Console == The Beaglebone Black supports the standard 6pin inline UART TTL connector. You can purchase a TTL to USB cable that plugs onto this header. Please refer to the board's user manual for the details of the cable and how to connect it. = Boot Loader = U-Boot is the boot loader for the Beagle Board family. The following is for each board in the family. == Beaglebone Black == The Beaglebone Black has a TI Sitara AM3358BZCZ100 processor and it configured to boot from eMMC memory. The factory ships the board with U-Boot, Linux kernel, and a full file system in the eMMC memory. You need to update the eMMC image to latest for the best results. To control the boot we need a recent U-Boot and a suitable `uEnv.txt` file on the SD card. The following procedure will create a suitable SD card image with a current U-Boot and `uEnv.txt` file. To boot using TFTP the `uEnv.txt` contents is: {{{ bootfile=bbb/rtems.img loadaddr=0x82000000 uenvcmd=echo Booting RTEMS BBB from net; set autoload no; dhcp; set serverip 10.10.5.2; tftpboot bbb/rtems.img; bootm; reset; }}} The server IP address is the host machine running the `rtems-test` command. === Updating the eMMC === We recommend you upgrade this software to the latest. These are found here https://rcn-ee.net/rootfs/bb.org/testing/. The last know and tested version is https://rcn-ee.net/rootfs/bb.org/testing/2017-09-24/stretch-lxqt-2gb/. At the time of writing this the latest 2G image is [https://rcn-ee.net/rootfs/bb.org/testing/2017-09-24/stretch-lxqt-2gb/BBB-blank-debian-9.1-lxqt-2gb-armhf-2017-09-24-2gb.img.xz 2G Beaglebone Black Debian 9.1 2017-09-24]. Make sure you get a 2G image as this is the size of the eMMC on the a RevB Beaglebone Black. You need to use a 2G or great SD card. If the link here is broken please find a link under https://rcn-ee.net/rootfs/bb.org/testing/ that works and please let us know. {{{ $ xz -d bone-debian-9.1-lxqt-2gb-armhf-2017-09-24-2gb.img.xz $ dd if=bone-debian-9.1-lxqt-2gb-armhf-2017-09-24-2gb.img of=/dev/da0 bs=1m 1700+0 records in 1700+0 records out 1782579200 bytes transferred in 180.028664 secs (9901641 bytes/sec) }}} Place the SD card into the Beaglebone Black board and hold the Boot switch and turn the power on. The Boot switch is `S2` and is located at the same end of the board as the SD card, HDMI and USB master connectors. Hold the Boot button on until the leds all turn on. This takes a few seconds. If booting from the SD card the console will start showing something like: {{{ U-Boot SPL 2017.09-00003-g11d92ba68a (Sep 21 2017 - 10:40:17) Trying to boot from MMC1 U-Boot 2017.09-00003-g11d92ba68a (Sep 21 2017 - 10:40:17 -0500), Build: jenkins-github_Bootloader-Builder-602 CPU : AM335X-GP rev 2.1 I2C: ready DRAM: 512 MiB No match for driver 'omap_hsmmc' No match for driver 'omap_hsmmc' Some drivers were not found Reset Source: Power-on reset has occurred. MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1 Using default environment Board: BeagleBone Black }}} Once the system has booted you will have a Beagebone Black login: {{{ Debian GNU/Linux 9 beaglebone ttyS0 BeagleBoard.org Debian Image 2017-09-24 Support/FAQ: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian default username:password is [debian:temppwd] beaglebone login: }}} Login as the default user using the provided password and then change to the `/boot` directory and open as root using `sudo` the u-Boot's user environment file (`uEnv.txt`) to edit, in this case using `vi`: {{{ debian@beaglebone:~$ cd /boot debian@beaglebone:/boot$ sudo vi uEnv.txt }}} At the end of the file is the Generic eMMC Flasher support. Uncomment the line to have: {{{ ##enable Generic eMMC Flasher: ##make sure, these tools are installed: dosfstools rsync cmdline=init=/opt/scripts/tools/eMMC/init-eMMC-flasher-v3.sh }}} Save the file and shutdown: {{{ debian@beaglebone:/boot$ sudo shutdown -h now [ 529.915200] reboot: Power down }}} Remove the power from the board and again apply power while pressing the Boot switch as you did before. This time the console will show the eMMC flasher procedure: {{{ ************************************************************ ==> Loaded ---------------------------------------- ================================================================================ Writing bootloader to [/dev/mmcblk1] ---------------------------------------- ==> Figuring out options for SPL U-Boot copy ... ===> Will use : count=1 seek=1 conv=notrunc bs=128k ==> Figuring out options for U-Boot copy ... ===> Will use : count=2 seek=1 conv=notrunc bs=384k ==> Copying SPL U-Boot with dd if=/opt/backup/uboot/MLO of=/dev/mmcblk1 count=1 seek=1 conv=notrunc bs=128k ------------------------------------------------------------ 0+1 records in 0+1 records out 75080 bytes (75 kB, 73 KiB) copied, 0.0239506 s, 3.1 MB/s ------------------------------------------------------------ ==> Copying U-Boot with dd if=/opt/backup/uboot/u-boot.img of=/dev/mmcblk1 count=2 seek=1 conv=notrunc bs=384k ------------------------------------------------------------ 1+1 records in 1+1 records out 397640 bytes (398 kB, 388 KiB) copied, 0.188179 s, 2.1 MB/s ------------------------------------------------------------ Writing bootloader completed ================================================================================ ================================================================================ Partitionning /dev/mmcblk1 ---------------------------------------- sfdisk: [2.26.x or greater] ==> sfdisk parameters: sfdisk: [sfdisk from util-linux 2.29.2] sfdisk: [sfdisk --force /dev/mmcblk1] sfdisk: [4M,,L,*] ==> Partitionning ------------------------------------------------------------ Checking that no-one is using this disk right now ... OK Disk /dev/mmcblk1: 1.8 GiB, 1920991232 bytes, 3751936 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes >>> Created a new DOS disklabel with disk identifier 0xb759f922. /dev/mmcblk1p1: Created a new partition 1 of type 'Linux' and of size 1.8 GiB. /dev/mmcblk1p2: Done. New situation: Device Boot Start End Sectors Size Id Type /dev/mmcblk1p1 * 8192 3751935 3743744 1.8G 8[ 63.419843] mmcblk1: p1 3 Linux The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks. ------------------------------------------------------------ ==> Partitionning Completed ==> Generated Partitions: ------------------------------------------------------------ Disk /dev/mmcblk1: 1.8 GiB, 1920991232 bytes, 3751936 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xb759f922 Device Boot Start End Sectors Size Id Type /dev/mmcblk1p1 * 8192 3751935 3743744 1.8G 83 Linux ------------------------------------------------------------ ================================================================================ ================================================================================ Preparing future rootfs to receive files ---------------------------------------- ==> Formatting rootfs with mkfs.ext4 -O ^metadata_csum,^64bit /dev/mmcblk1p1 -L rootfs -------------------------------------------------------------------------------- mke2fs 1.43.4 (31-Jan-2017) Discarding device blocks: done Creating filesystem with 467968 4k blocks and 117120 inodes Filesystem UUID: 1aa2f1b9-7a7c-4dbc-9d36-c7e01ce19540 Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912 Allocating group tables: done Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done -------------------------------------------------------------------------------- ==> Formatting rootfs: /dev/mmcblk1p1 complete ==> Creating temporary rootfs directory (/tmp/rootfs) ==> Mounting /dev/mmcblk1p1 to /tmp/rootfs [ 77.717437] EXT4-fs (mmcblk1p1): mounted filesystem with ordered data mode. Opts: (null) ================================================================================ ================================================================================ Copying: Current rootfs to /dev/mmcblk1p1 ---------------------------------------- ==> rsync: / -> /tmp/rootfs ---------------------------------------- }}} The leds show activity. Once the procedure has finished remove the power and remove the SD card: {{{ [ 513.490441] reboot: Power down [ 513.493962] System will go to power_off state in approx. 1 second }}} Apply power and watch the board boot from the updated eMMC memory. = JTAG Debugging = This is covered the various JTAG debugging solutions RTEMS users are using. == Beaglebone Black JTAG using OpenOCD == This is covered in the [wiki:Debugging/OpenOCD OpenOCD Debugger] section of the wiki in the [wiki:Debugging/OpenOCD/BeagleBoneBlack BeagleBone Black JTAG debugging] page. == Beaglebone Black JTAG using Segger J-Link == This describes how to set up a debugger using the [https://www.segger.com/products/debug-probes/j-link/ Segger J-Link] or [https://www.segger.com/products/debug-probes/j-link/models/j-link-edu/ Segger J-Link EDU] on a Linux host. Note that you need a mechanical adapter for connecting the BBB. === J-Link gdb Server === Install the J-Link software either from the Segger home page or from your distributions repository. On Arch Linux, the [https://aur.archlinux.org/packages/jlink/ AUR jlink] package can be used. Start the gdb-server with the following command: {{{ JLinkGDBServer -device AM3358 -if JTAG -speed 16000 }}} Note that this will start a server in the foreground. So do it on it's own console or in some screen or tmux session. === GDB === Create a gdb-script `start.gdb` with the following content: {{{ define reset echo -- Reset target and wait for U-Boot to start kernel.\n monitor reset # RTEMS U-Boot starts at this address. tbreak *0x80000000 # Linux starts here. tbreak *0x82000000 continue echo -- Disable watchdog.\n set *(uint32_t*)0x44e35048=0xAAAA while (*(uint32_t*)0x44e35034 != 0) end set *(uint32_t*)0x44e35048=0x5555 while (*(uint32_t*)0x44e35034 != 0) end echo -- Overwrite kernel with application to debug.\n load end target remote :2331 }}} Start your gdb with a line like follows: {{{ arm-rtems4.12-gdb -x start.gdb app.elf }}} The gdb script assumes that the Beagle has some system that it can boot. So put for example a Debian Linux or some RTEMS image on a SD card or on the eMMC of the BBB before starting the gdb. The script will interrupt the boot process during the jump to the "normal" application and load your given elf file instead. Execute the command `reset` (defined by the gdb script) in the gdb shell to start or restart the application.