Initial commit

This commit is contained in:
Julian Mutter 2021-04-26 17:27:16 +02:00
commit be3ecf3e6e
12 changed files with 261 additions and 0 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "rodos"]
path = rodos
url = https://gitlab.com/rodos/rodos

7
CMakeLists.txt Normal file
View File

@ -0,0 +1,7 @@
project(my-rodos-app)
cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 17)
add_subdirectory(rodos)
add_rodos_executable(my-rodos-app blinky.cpp)

43
README.md Normal file
View File

@ -0,0 +1,43 @@
# Julians Rodos Template
## Steps to make it work
### Compiling Rodos
Compiling rodos for discovery / stm32f4:
```shell script
$ cd build
$ cmake -DCMAKE_TOOLCHAIN_FILE=../rodos/cmake/port/discovery.cmake -DEXECUTABLE=ON ..
```
### Openocd installation
To make it work you need to install openocd on your system (e.g. via package manager).
The installation should create one of these folders:
- _/usr/share/openocd_
- _/usr/local/share/openocd_
There you can find the files referenced in *openocd/openocd_debug.cfg* and *openocd/openocd_flash.cfg*.
Since I did not find *stm32f4x_stlink.cfg* there, I changed it in the config file to *stm32f4x.cfg*.
### Edit Eclipse launch configs
Eclipse needs to find the folder *eclipse_launch_cfgs*.
For me it worked to create a new launch configuration and go to **Common** and select the folder unter **Shared files**.
You should also edit all three configurations through the Eclipse run configurations window to update your project name and binary name.
Sometimes *debug_stm32f4.launch* is not recognized by the big launch configuration window in Eclipse (top left). Just use the small bug icon on the top right of the toolbar instead.
### Run stm32f4-load
Make *openocd/stm32f4-load* executable and run it once as sudo. This will add some files to */etc/udev/rules.d/* so you wont have to use sudo in the future.
### Edit CMakeLists.txt
Edit *CMakeLists.txt* to add all your cpp files etc.
## How to run it
### Flashing
To flash your program just run the external tool configuration *flash_stm32f4* in Eclipse.
### Debugging
To debug first run the external tool configuration *connect_stm32f4.launch* in Eclipse once.
Then to really start debugging run the debug configuration *debug_stm32f4* in Eclipse. This should compile your code, open debug mode and run it.

38
blinky.cpp Normal file
View File

@ -0,0 +1,38 @@
/*
* TestBlinky.cpp
*
*/
#include "rodos.h"
#include "hal_gpio.h"
HAL_GPIO green(GPIO_060);
class Test:public Thread
{
public:
void init()
{
green.init(1,1,1);
}
void run()
{
green.setPins(0);
}
};
Test t;

0
build/.gitkeep Normal file
View File

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.ui.externaltools.launchGroup"/>
</listAttribute>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LAUNCH_CONFIGURATION_BUILD_SCOPE" value="${none}"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="/usr/bin/openocd"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-f ${workspace_loc:/LRL_ex1/openocd/openocd_debug.cfg}"/>
</launchConfiguration>

View File

@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.cdt.debug.gdbjtag.launchConfigurationType">
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.connection" value="gdb:localhost:3333#"/>
<intAttribute key="org.eclipse.cdt.debug.gdbjtag.core.delay" value="3"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doHalt" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.doReset" value="false"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageFileName" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.imageOffset" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.initCommands" value="monitor reset halt"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDevice" value="Generic TCP/IP"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.jtagDeviceId" value="org.eclipse.cdt.debug.gdbjtag.core.jtagdevice.genericDevice"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadImage" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.loadSymbols" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.pcRegister" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.runCommands" value=""/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setPcRegister" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setResume" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.setStopAt" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.stopAt" value="main"/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsFileName" value=""/>
<stringAttribute key="org.eclipse.cdt.debug.gdbjtag.core.symbolsOffset" value=""/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForImage" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useFileForSymbols" value="false"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForImage" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useProjBinaryForSymbols" value="true"/>
<booleanAttribute key="org.eclipse.cdt.debug.gdbjtag.core.useRemoteTarget" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.mi.core.DEBUG_NAME" value="arm-none-eabi-gdb"/>
<stringAttribute key="org.eclipse.cdt.debug.mi.core.commandFactory" value="Standard (Linux)"/>
<stringAttribute key="org.eclipse.cdt.debug.mi.core.protocol" value="mi"/>
<booleanAttribute key="org.eclipse.cdt.debug.mi.core.verboseMode" value="false"/>
<stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="arm-none-eabi-gdb"/>
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.REMOTE_TIMEOUT_ENABLED" value="false"/>
<stringAttribute key="org.eclipse.cdt.dsf.gdb.REMOTE_TIMEOUT_VALUE" value=""/>
<booleanAttribute key="org.eclipse.cdt.dsf.gdb.UPDATE_THREADLIST_ON_SUSPEND" value="false"/>
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
<stringAttribute key="org.eclipse.cdt.launch.COREFILE_PATH" value=""/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value=""/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="remote"/>
<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;contentList&gt;&lt;content id=&quot;cpsr-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;fps-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;f7-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;f6-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;f5-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;f4-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;f3-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;f2-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;f1-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;f0-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;pc-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;lr-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;sp-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;r12-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;r11-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;r10-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;r9-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;r8-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;r7-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;r6-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;r5-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;r4-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;r3-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;r2-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;r1-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;r0-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;nextBeat-Thread-null-UART::putchar-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;nextBeat-Thread-null-main-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;suspendedUntil-Thread-null-NVIC_SetPriority-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;null-SystemInit-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;FPCCR-null-SystemInit-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;MVFR0-null-SystemInit-(format)&quot; val=&quot;4&quot;/&gt;&lt;content id=&quot;MVFR1-null-SystemInit-(format)&quot; val=&quot;4&quot;/&gt;&lt;/contentList&gt;"/>
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;globalVariableList/&gt;&#10;"/>
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;memoryBlockExpressionList&gt;&#10;&lt;memoryBlockExpressionItem&gt;&#10;&lt;expression text=&quot;0x20000000&quot;/&gt;&#10;&lt;/memoryBlockExpressionItem&gt;&#10;&lt;memoryBlockExpressionItem&gt;&#10;&lt;expression text=&quot;0x2001fa00&quot;/&gt;&#10;&lt;/memoryBlockExpressionItem&gt;&#10;&lt;memoryBlockExpressionItem&gt;&#10;&lt;expression text=&quot;0x8000000&quot;/&gt;&#10;&lt;/memoryBlockExpressionItem&gt;&#10;&lt;/memoryBlockExpressionList&gt;&#10;"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="build/my-rodos-app"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="LRL_ex1"/>
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="true"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="cdt.managedbuild.config.gnu.cross.exe.debug.1708449299"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/LRL_ex1"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<mapAttribute key="org.eclipse.debug.core.preferred_launchers">
<mapEntry key="[debug]" value="org.eclipse.cdt.debug.gdbjtag.core.cdiLaunchDelegate"/>
</mapAttribute>
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.cdt.debug.core.sourceLocator"/>
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;sourceLookupDirector&gt;&#10; &lt;sourceContainers duplicates=&quot;false&quot;&gt;&#10; &lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;project name=&amp;quot;rodos&amp;quot; referencedProjects=&amp;quot;false&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.debug.core.containerType.project&quot;/&gt;&#10; &lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;default/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.debug.core.containerType.default&quot;/&gt;&#10; &lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;mapping backend_enabled=&amp;quot;false&amp;quot; name=&amp;quot;Found Mappings&amp;quot;&amp;gt;&amp;#10; &amp;lt;mapEntry memento=&amp;quot;&amp;amp;lt;?xml version=&amp;amp;quot;1.0&amp;amp;quot; encoding=&amp;amp;quot;UTF-8&amp;amp;quot; standalone=&amp;amp;quot;no&amp;amp;quot;?&amp;amp;gt;&amp;amp;#10;&amp;amp;lt;mapEntry backendPath=&amp;amp;quot;../src/independent&amp;amp;quot; localPath=&amp;amp;quot;/home/miru/programming/embedded/rodos_info8/rodos/src/independent&amp;amp;quot;/&amp;amp;gt;&amp;amp;#10;&amp;quot;/&amp;gt;&amp;#10;&amp;lt;/mapping&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.cdt.debug.core.containerType.mapping&quot;/&gt;&#10; &lt;/sourceContainers&gt;&#10;&lt;/sourceLookupDirector&gt;&#10;"/>
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
</listAttribute>
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&lt;memoryBlockExpressionList context=&quot;reserved-for-future-use&quot;/&gt;"/>
<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory"/>
<stringAttribute key="saved_expressions&lt;seperator&gt;Unknown" value="20002800,0x20002800,0x2001ffa4,0x20002588,0x0800c4d4,0x20002924,0x2001ffff,0x2001fffe,0x2001fffc,0x20002538,0x800c534,0x2000258c,0x200028c8,0x2000116c,0x200010fc"/>
</launchConfiguration>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramLaunchConfigurationType">
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
<listEntry value="org.eclipse.ui.externaltools.launchGroup"/>
</listAttribute>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LAUNCH_CONFIGURATION_BUILD_SCOPE" value="${project}"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/LRL_ex1/openocd/stm32f4-load}"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="${workspace_loc:/LRL_ex1/build/my-rodos-app}"/>
</launchConfiguration>

2
openocd/openocd_debug.cfg Executable file
View File

@ -0,0 +1,2 @@
source [find interface/stlink-v2.cfg]
source [find target/stm32f4x.cfg]

View File

@ -0,0 +1,8 @@
source [find interface/stlink-v2.cfg]
source [find target/stm32f4x.cfg]
init
reset halt
flash write_image erase stm32f4.hex 0 ihex
reset run
shutdown

78
openocd/stm32f4-load Executable file
View File

@ -0,0 +1,78 @@
#! /bin/bash
#if [ -z $RODOS_ROOT ]; then
# source `dirname $0`/print_no_envs_warning
#fi
#source ${RODOS_MAKES}/stm32f4-set-vars
FLASH_TOOL=openocd
FLASH_TOOL_PATH=/usr/bin
OBJCOPY=arm-none-eabi-objcopy
OBJCOPY_PATH=
ELF_NAME=$1
if [ -x ${FLASH_TOOL_PATH}/${FLASH_TOOL} ]; then
echo "${FLASH_TOOL}: installed"
FLASH_TOOL=${FLASH_TOOL_PATH}/${FLASH_TOOL}
else
# look for flash tool in default path
command -v ${FLASH_TOOL} >/dev/null 2>&1 || { echo "${FLASH_TOOL}: NOT installed" >&2; exit 1; }
echo "${FLASH_TOOL}: installed "
FLASH_TOOL="$(command -v ${FLASH_TOOL})"
fi
if [ -x $OBJCOPY_PATH/$OBJCOPY ]; then
echo "$OBJCOPY: installed"
OBJCOPY=${OBJCOPY_PATH}/${OBJCOPY}
else
# look for objcopy in default path
command -v ${OBJCOPY} >/dev/null 2>&1 || { echo "${OBJCOPY}: NOT installed" >&2; exit 1; }
echo "${OBJCOPY}: installed"
OBJCOPY="$(command -v ${OBJCOPY})"
fi
#if [ -f ./${ARCH}.elf ]; then
# echo "${ARCH}.elf: OK"
rm stm32f4.hex &> /dev/null
$OBJCOPY -O ihex ${ELF_NAME} stm32f4.hex
#else
# echo "${ARCH}.elf: FAIL"
# exit 1;
#fi
#if [ -f ./${ELF_NAME}.hex ]; then
# echo "${ARCH}.hex: OK"
#else
# echo "${ARCH}.hex: FAIL"
# exit 1;
#fi
if [ ! -f /etc/udev/rules.d/49-stlinkv1.rules -o ! -f /etc/udev/rules.d/49-stlinkv2.rules ]
then
echo "superuser password needed to access USB-Port"
# mount rule for stlink1
echo "SUBSYSTEMS==\"usb\", ATTRS{idVendor}==\"0483\", ATTRS{idProduct}==\"3744\", MODE:=\"0666\", SYMLINK+=\"stlinkv1_%n\"" > 49-stlinkv1.rules
# mount rule for stlink2
echo "SUBSYSTEMS==\"usb\", ATTRS{idVendor}==\"0483\", ATTRS{idProduct}==\"3748\", MODE:=\"0666\", SYMLINK+=\"stlinkv2_%n\"" > 49-stlinkv2.rules
sudo mv 49-stlinkv1.rules /etc/udev/rules.d/
sudo mv 49-stlinkv2.rules /etc/udev/rules.d/
sudo udevadm trigger
sudo udevadm control --reload-rules
sleep 1s
fi
echo "flashing ..."
${FLASH_TOOL} -f $(dirname "$0")/openocd_flash.cfg

1
rodos Submodule

@ -0,0 +1 @@
Subproject commit 2c500a8d5af14e94c25e861dbcda2b3abde950e5