Published On: March, 29, 2018 By: Eshtaartha Basu | Updated: July 18, 2018 by Cathleen Wicks
Be it for performance, complexity or ability to audit, at times embedded developers will find themselves in a situation where running a bare metal application directly on OSD335x without Linux is needed. One common scenario for this is in time sensitive or real-time applications when better control is needed over every aspect of program execution. Another scenario would be if an application developer felt the need to eliminate the OS on the processor and of any overhead associated with it. However, Linux does provide a number of benefits that can aid in program development, so careful evaluation should be completed when determining whether to create a bare metal application. Regardless, the OSD335x Family of devices can run bare metal applications easily. This application note will show you how to load an application from an external SD Card (or eMMC or TFTP) to the DDR3 of the OSD335x and run it.
For this application note, you will need a Host Computer running Ubuntu and an OSD335x Family based development or prototype board, such as the Beagleboard.org® BeagleBone® Black Wireless, PocketBeagle® or OSD3358-SM-RED board. This development board should be running a Debian BeagleBone® image (http://beagleboard.org/latest-images) in order to leverage the U-Boot bootloader to load your bare metal application (the Linux portion of the image will not be used and may be removed).
1.Introduction
2.Revision History
3.Installing StarterWare for AM335x
4.Installing Linaro GCC Compiler
5.Building StarterWare Example
6.Running Demo Application on OSD335x using SD Card or eMMC
7.Running Demo Application on OSD335x using TFTP
8.Booting Bare Metal Applications
9.References
A PDF version of this App Note can be found here.
Revision Number | Revision Date | Changes | Author |
---|---|---|---|
1 | 3/26/2018 | Initial Release | E. Basu |
First, we will need to install the development environment for creating and building a bare metal application on the AM335x, StarterWare.
NOTE: All instructions given in this article were tested using a host machine running Ubuntu 16.04 and the OSD3358-SM-RED Reference, Evaluation, Development Board for the OSD335x-SM SiP Products running BeagleBone Debian 9.3 (U-Boot version: U-Boot 2017.01-00006-gb2bbabfe41)
You can download StarterWare installer for AM335x (v2.00.xx.xx) and BeagleBone Black patch (Starterware_BBB_support) from http://www.ti.com/tool/starterware-sitara. You will be asked to create a TI account and enter contact details to download all the files.
1 | $ mkdir ~/bareMetal |
1 | $ mv ~/Downloads/AM335x_Starterware_02_00_01_01_Setup.bin ~/bareMetal |
1 2 | $ cd ~/bareMetal $ chmod +x AM335X_StarterWare_02_00_01_01_Setup.bin |
1 2 | $ sudo apt-get update $ sudo apt-get install zlib1g-dev libncurses5-dev |
1 | $ ./AM335X_StarterWare_02_00_01_01_Setup.bin |
1 2 3 | $ mv ~/Downloads/StarterWare_BBB_support.tar.gz ~/bareMetal/AM335X_StarterWare_02_00_01_01 $ cd ~/bareMetal/AM335X_StarterWare_02_00_01_01 $ tar xvfz StarterWare_BBB_support.tar.gz |
Next, we need to install a cross compiler that will allow us to build AM335x applications on our host Ubuntu system.
Download the Linux Installation Tarball (version: 4.7-2012q4) from https://launchpad.net/gcc-arm-embedded/4.7/4.7-2012-q4-major There are always improvements being made to GCC, so while a specific version is reference and tested in this app note, this procedure should be similar for future versions of the compiler.
1 2 | $ mkdir ~/bareMetal/linaro-gcc $ mv ~/Downloads/gcc-arm-none-eabi-4_7-2012q4-20121208-linux.tar.bz2 ~/bareMetal/linaro-gcc |
1 2 | $ cd ~/bareMetal/linaro-gcc $ tar xvfj gcc-arm-none-eabi-4_7-2012q4-20121208-linux.tar.bz2 |
1 | $ gedit ~/bareMetal/AM335X_StarterWare_02_00_01_01/build/armv7a/gcc/makedefs |
1 2 3 | ifndef PREFIX PREFIX=${LIB_PATH}/bin/arm-none-eabi- endif |
1 | $ export LIB_PATH=${HOME}/bareMetal/linaro-gcc/gcc-arm-none-eabi-4_7-2012q4 |
Now, we will use the tools from Sections 3 and 4 to build a StarterWare application.
For the StarterWare examples, we will disable the MMU, instruction and data caches, and some exception handling in the initialization assembly file (init.S for gcc) to avoid any unexpected behavior. Depending on your application, you may need to enable some or all of these features. If you do, then please update the initialization file appropriately.
1 | $ gedit ~/bareMetal/AM335X_StarterWare_02_00_01_01/system_config/armv7a/gcc/init.S |
1 2 | SUB r0, r0, r0 MCR p15, 0, r0, c1, c0, 0 |
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0344h/BCGFFBFD.html
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0344f/Bgbciiaf.html?
1 2 | $ cd ~/bareMetal/AM335X_StarterWare_02_00_01_01/build/armv7a/gcc/am335x/beaglebone $ make |
1 | $ ls -lA ~/bareMetal/AM335X_StarterWare_02_00_01_01/binary/armv7a/gcc/am335x/beaglebone/gpio/Release |
At this point, you now have a binary application file that can be loaded into the DDR memory of the OSD335x / OSD335x-SM device and run. For your bare metal application, you should copy and extend the structure and build process defined in StarterWare. The build process outlined above should be similar for your application.
Next, we need to run the binary application that was built in Section 5 to the OSD335x / OSD335x-SM device. One method to do this is to use non-volatile storage such as an SD Card or eMMC attached to the OSD335x / OSD335x-SM to store the binary application so that it can be loaded from U-Boot.
NOTE: For simplicities sake, we are leveraging the fact that the SD card / eMMC has a valid Linux image with a file system that we can use to read and write our binary image. In a production scenario where you want to leverage the size savings of using bare metal, you will need the MLO and U-Boot portions of the image and then will need a file system to store the binary application.
First, we need to transfer the image to the OSD335x / OSD335x-SM development board.
1 | $ sudo ssh 192.168.7.2 -l debian |
1 2 | $ cd ~/bareMetal/AM335X_StarterWare_02_00_01_01/binary/armv7a/gcc/am335x/beaglebone/gpio/Release $ sudo scp gpioLedBlink.bin debian@192.168.7.2:/home/debian |
NOTE: For instructional purposes, we are demonstrating the interactive way to load and boot the bare metal application. In a production scenario, you would need to modify the “bootcmd” variable within the U-Boot environment to automatically load and boot the bare metal application.
Once Linux Boot is interrupted, U-Boot command line prompt can be seen as shown in Figure 1
To load and run the bare metal application from either the SD Card or eMMC, we need to understand the correct device and partition where the bare metal application is stored. In the OSD3358-SM-RED development board, the SD Card is on MMC0 and the eMMC is on MMC1 and in the default BeagleBone image, the Linux filesystem is on partition 1.
1 2 | load mmc 0:1 0x80000000 <path to your .bin file; e.g. /home/Debian/gpioLedBlink.bin> go 0x80000000 |
1 2 | load mmc 1:1 0x80000000 <path to your .bin file; e.g. /home/Debian/gpioLedBlink.bin> go 0x80000000 |
Another way, we can load and run the binary application that was built in Section 5 on the OSD335x / OSD335x-SM device is to use TFTP to transfer the image directly to U-Boot so that it can load and run the application.
Before we can use TFTP with U-Boot, you’ll have to configure the host Ubuntu machine with a TFTP server.
1 | $ sudo apt-get install tftpd-hpa |
1 | $ sudo apt-get install tftp |
1 | $ sudo gedit /etc/default/tftpd-hpa |
1 2 3 4 | TFTP_USERNAME="tftp" TFTP_ADDRESS="0.0.0.0:69" TFTP_OPTIONS="--create --listen --verbose /home/userName/cmpt433/public" RUN_DAEMON="yes" |
1 | $ netstat -a | grep tftp |
1 | $ sudo service tftpd-hpa restart |
1 2 | $ mkdir ~/bareMetal/TFTP $ echo ‘Testing TFTP successful’ > ~/bareMetal/TFTP/testTFTP.txt |
1 2 3 4 5 | $ tftp tftp> connect 127.0.0.1 tftp> get home/ubuntu/bareMetal/TFTP/testTFTP.txt Received 17 bytes in 0.0 seconds tftp> quit |
1 2 | $ cat test_tftp.txt Testing TFTP successful |
NOTE: Again, the steps shown below are how to interactively load and run the bare metal application. In a production scenario, the U-Boot environment will need to be modified to automatically load and run the application.
1 | => setenv ipaddr <board ip>;setenv loadaddr 0x80000000; setenv serverip <server ip>;setenv tftproot /home/userNameOfHostMachine/bareMetal/TFTP;setenv bootfile ${tftproot}/gpioLedBlink.bin;tftp ${loadaddr} ${bootfile};echo -----Booting and loading BareMetal App through TFTP-----;go ${loadaddr}; |
At this point, you are now able to create, compile, load and run bare metal applications on the OSD335x Family of devices using either non-volatile storage such as an SD Card or eMMC, or over the network using TFPT. If you get any errors, please check that all the paths are configured correctly. Also, you can post questions or comments on our forums.
For more information, please refer to the following links:
Octavo Systems LLC all rights reserved
OCTAVO is registered in the U.S. Patent and Trademark Office. OSD, C-SiP, and the Octavo Logo are trademarks of Octavo Systems LLC.
"*" indicates required fields
"*" indicates required fields
"*" indicates required fields
"*" indicates required fields