The purpose of this tutorial is to build our first “hello world” program for the MB1136 evaluation kit. In this tutorial, we are going to set up a simplest demonstration program. We download a simple “hello.c” program based on Hyperpanel OS. We will compile this simple app and make a binary of hyperpanel OS including this app.
- A STMicroelectronics evaluation board with STM32L152RU Cortex-M3 MCU, order code NUCLEO-L152RE (name on PCB: MB1136).
- USB 2.0 male to micro USB cable (supplied with evaluation kit).
- A full installation of an Hyperpanel OS release on a linux based PC including tools for flashing and debugging. This tutorial requires release V30.03.01 for MB1136 or higher. Hyperpanel OS releases are available for free in the Download section of the website.
- A Lunix PC with ARM gcc compiler, ARM gdb debugger and minicom installed.
- A text editor to edit or modify source codes (We are using vi in our demo).
hypv300301 for MB1136 or higher
Binary file
– On www.tutorial.hyperpanel.com, select Download from the main menu.
– Download “Hyperpanel OS V30.03.01 for MB1136” or higher release for the MB1136 kit. (hypv300301.zip).
– On your PC Linux, copy and unzip the zip file in your root directory, for example:
cp hypv300301.zip /home/hyperpanel cd /home/hyperpanel unzip hypv300301.zip
– With a text editor, update hhome environment variable in the stm32m3 file:
cd ~/hypv300301/shells vi stm32m3
Update the first line, according to your root directory:
export hhome=/home/hyperpanel/hypv300301
– Save this file and an execute the command:
source stm32m3
– From this tutorial, use the button “Binary file” to download the zip file containing the binary. Unzip this file:
unzip hpos-tuto510-bin.zip
– Copy this binary file in HyperPanelOS release:
cp hello.bin ~/hypv300301/boards/stm32m3/exe
– Connect the MB1136 board to a USB port on your Linux PC using the USB cable supplied with the board. Wait for a window to appear, then close it.
– Open a Terminal window and run minicom to get access to application menu:
minicom -D /dev/ttyACM0 -b 115200
– Open another Terminal window on your computer and enter the following commands:
cd ~/hypv300301/shells source stm32m3 exe
– Upload software to the board:
hgdb romload stm32m3 hello
You should see messages similar to these:
Open On-Chip Debugger 0.10.0+dev-00001-g0ecee83-dirty (2017-02-10-06:53) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html 0x08005634 in ?? () target halted due to debug-request, current mode: Thread xPSR: 0x01000000 pc: 0x080052e4 msp: 0x20002000 auto erase enabled Ignoring packet error, continuing... target halted due to breakpoint, current mode: Thread xPSR: 0x61000000 pc: 0x20000046 msp: 0x20002000 wrote 524288 bytes from file hello.bin in 10.224703s (50.075 KiB/s) Cannot access memory at address 0xffffffff hello.elf: No such file or directory.
Wait until the flashing operation is complete (approx. 30 seconds). The last message (hello.elf: No such file or directory) is normal.
– You can now press on the reset button (black button) of the MB1136. Hyperpanel OS will start, and a “Hello World” message sent every second on the serial output.
To go further
If you want to edit the source code, write modifications, compile, link, etc., here’s how to do it:
- From this tutorial, use the button “Source code” to download the zip file containing the source file. Unzip this file:
unzip hpos-tuto10-source.zip
- Copy this source code in HyperPanelOS release:
cp hello.c ~/hypv300301/user/stm32app
- Copy the link file in Hyperpanel release:
cp hello.lst ~/hypv300301/boards/stm32m3/exe
- You can edit and make any modifications you want in the source file. For example, you can modify the time between two successive displays of “Hello World”. To do this, simply modify the value (in milliseconds) of the second parameter of the “set_uto()” procedure.
cd ~/hypv300301/user/stm32app vi hello.c
- Save the source file.
- Compile the source file:
cd ~/hypv300301/user/stm32app cmm hello
- Make a link edit to create a new executable:
exe lhypos hello
- You can now upload this new binary to the board, in the same way as in the previous Installation chapter.
Links
Serial output on console
Code
hypos-tuto-510-source
/* ** hello.c - Sample code for HyperpanelOS ================================ ** ** ** ** This simple code is located into the Application Container, it is run ** ** by the VMK sub-operating system. On the other hand, the I/O container ** ** runs all the drivers that are VMIO Finite State machines. ** ** ** ** The goal of this small aplication is to write a single message ** ** "Hello World" each second to serial port ASY0 ** ** ** ** ======================================================================= ** */ /* Includes files and external references ...................................*/ #include <hypos.h> // Hyperpanel OS basic interfaces #include <drv_asy.h> // Prototype of "asy_write" /* Internal defines of this module ------------------------------------------*/ #define TICK 10000 // Code for tick event /* Internal global variables of this module ---------------------------------*/ int dbg_test = 0 ; unsigned int idto ; // Timer identifier /* Prototypes --------------------------------------------------------------*/ static int wait_evt(void) ; // Prototype /* Beginning of the code ---------------------------------------------------- loop_app_tsk Entry point for create_task - Main event loop */ /* Procedure loop_app_tsk ---------------------------------------------------- Purpose : This is our task main loop. */ int loop_app_tsk (void *param) { int ev ; // Our event int cpt = 0 ; // Counter of messages char mess[80] ; // Message to be sent /***************************************************************************** * Step 1 : We start a timer that will send us an event every 1 second so * * ------ that we can update the time. * *****************************************************************************/ set_uto(CLOCK , // Timer mode: clock 1000 , // Duration in milliseconds TICK , // Event code 0 , // Event reserve field &idto ) ; // Timer identifier /***************************************************************************** * Step 2 : Here is our main event loop. For each loop, we do as follows : * * ------- - First we wait for an event. * * - Then if the event code is TICK we print "Hello World" * *****************************************************************************/ wait_ev : // Beginning of loop label ev = wait_evt() ; // Unschedule until an event is // received if ( ev == TICK ) // If the event is the tick event { // hsprintf(mess , // We build in "mess" the message "%6d Hello Worldrn", // to be sent cpt ++ ) ; // asy_write(0 , // We send on ASY0 (unsigned char*)mess , // the "mess" message strlen(mess) ) ; // Count of bytes to be sent } goto wait_ev ; // Wait for the next event return 0 ; } /* Procedure wait_evt ------------------------------------------------------*/ /* Purpose : Unschedule until the next event is received, whatever it is. */ static int wait_evt (void) { unsigned int waitlist[1][3] ; // Parameter of "waitevt_task" /***************************************************************************** * Step 1 : Build a list with one WAIT_CODEINT entry that will accept all * * ------ the event codes ranging from 0 to 20000. Then call * * "waitevt_task", we will be unscheduled until the next event will * * be received * *****************************************************************************/ dbg_test++ ; waitlist[0][0] = WAIT_CODEINT ; // All events with waitlist[0][1] = 0 ; // a code between 0 waitlist[0][2] = 20000 ; // and 20000 waitevt_task(waitlist , // Address of waiting list 1 , // Size of "waitlist[]" 0 , // maximum waiting time = no 0 ) ; // Do not purge previous events /***************************************************************************** * Step 2 : Here we are scheduled again. The VMK has written into its * * ------ global variable "task_evt" a copy of the event that has * * scheduled us again. * *****************************************************************************/ return task_evt.code ; // Return event code }
Terminal
0 Hello World 1 Hello World 2 Hello World 3 Hello World 4 Hello World 5 Hello World 6 Hello World 7 Hello World 8 Hello World 9 Hello World 10 Hello World 11 Hello World 12 Hello World 13 Hello World 14 Hello World 15 Hello World 16 Hello World 17 Hello World 18 Hello World 19 Hello World 20 Hello World 21 Hello World 22 Hello World 23 Hello World 24 Hello World 25 Hello World