Sunday, July 17, 2016

RTOS - FreeRTOS - first look - ARMFLY tutorial

Real time operating system has been a crucial task scheduler in large scale microcontroller project.  It allows the development of project to be divided into smaller part and each part is independently develop maintain.

Furthermore, the price of microcontroller is becoming cheaper and equipped with better processing power, RTOS is an additional good feature to be implemented in microcontroller. 

The low cost development kits have ease the learning process of embedded system. For example, the STMicroelectronic series development kits are cheapest in the market (currently), the microcontroller attached with development board is equipped with a lot of peripherals like ADC, DAC, PWM, timer, usb, can, serial communication, etc. It also come with on board debugger/programmer which is helpful in debug the program. Above all, it has large memory footprint (way more that enough).

Why let the RAM and flash go wasted, when you can waste it on RTOS. (Additional RAM is required to allocate stack size for task.)

There are a lot of free RTOS in the market. Previously I have tried OSA rtos for it's low memory footprint and suitability for PIC18f. In fact, I have written three OSA learning tutorials - 1, 2 and 3.

Freertos is an another alternative for microcontroller.

It is widely used in the commercial products, but not much company acknowledge it (freertos forum). One of the notable product that had been using it and publicly acknowledge the usage of freertos is pebble watch.

The vast user base has proven the stability of freertos, but freertos has it learning curve. The source code of freertos is readily available and well organised. Despite that, the source code has low level readability and the official document requires certain fee.

Simple starting guide is desirable to get started with freertos. The best tutorial is always the official website to learn about the function of freertos.

After some googling and baidu, I found one comprehensive tutorial written in Chinese by one China company "ARMFLY" 安富莱电子.

ARMFLY is making ARM development kit particularly on STM32. the good thing about their development kits is they provide tutorial and support in forum. It is also worth mentioning, ARMFLY is selling their boards at taobao.

Beside freertos, ARMFLY had provides tutorials in UCOS, embos, USB, Lwip, and RTX.

The ARMFLY freertos tutorial has 145 examples (project files is available for download) and 1200 pages documents. Link

ARMFLY has provides 145 examples for three of it's developments board which are
STM32F429,
STM32F407 and
STM32F103.

The good thing about this tutorial is step by step guidance provided with image to show the reader exact step instead of reading line by line. ARMFLY is using IAR and MDK compiler in their tutorial, so it is the best to get started with these two compilers.

The downside of this tutorial is written in Chinese. So it is an added advantageous to the reader who know Chinese.

It is worth mentioning that tutorial given is not tied to their development boards. You can apply the example given to any STM32 development boards as long as long the microcontroller core is supported by freertos. Else you have to do the porting yourself.

For the project source code given, maybe you need to change the IO port configuration to make the project workable.

Although there are some English tutorials on web, but there are basically not even one tutorial that provides spoon feed guidance. So this Chinese version is crucial for self learner and people who has no prior experience on RTOS.

Now, let have a look at the ARMFLY board, STM32-V5
The specification also quit amazing:
MCU:
STM32F407IGT6, 1M Flash, 192KRAM
Crystal:
25MHz for main clock, 32768 for RTC
Additional Memory:
2M SRAM, 16M Nor Flash, 128M NADN Flash, 16KEEPROM,8M Flash (No idea for what purpose)
Connectors:
1 Micro SD, 2 CAN2.0, 1 RS232, 1 RS485, 1 USB device, 1 USB host, 2 LAN, Audio, PS 2
ICs:
CODEC (WM8978), AM/FM (Si4730), accelerometer and MEMS gyro (MPU6050), Magnetometer (HMC5883L), Light sensor (BH1750FVI), Barometer (BMP085)
Additional:
Infrared transmitter, Infrared receiver, 1 CR1220 battery, 4.3 inches TFT display

It also reserved some pin for modules, guess you just have to buy it. Basically, the on board ICs and connectors have provided a good learning environment as you do not need to scout for additional components and do your own wiring. Best of all, after sales technical support is available at their forum.

Download link for tutorials:
STM32F429: tutorial, source code
password:bs5g

STM32F407: tutorial, source code
password:8fi7

STM32F103: tutorial, source code
password: sy7f

password is required for download the source code.

Friday, July 8, 2016

Linux learning - References and some notes

Recently I just started the learning journey of Linux. I am a window person, and have been pampered by the user friendliness of window 7, window xp. Getting started in Linux - Ubuntu has been quit a challenge for me. Although Ubuntu come with GUI, but the settings and software installation must be done in command window.

Knowing some useful commands is crucial in Linux survival kits.

As always I like to take note the essential and almost important functions.
1. cd - always take note of your working directory. ~ is home. / is top level directory. .. is back on top one level.
2. ls - list out all the files.
3. sudo - work as administrator. If you have a command, that you are pretty sure it is working, but you see error. Add sudo in front of command.
4. esc - press esc to go to command part in editor.
5. :q - quit the editor.
6. :q! - quit the editor without saving any changes.
7. :x, :wq - save and exit editor.
8. tab - press tab to auto complete your folder/file name.
9. shift + insert - paste your sentences in ssh.
10. highlight - copy, double click to highlight sentences in command window.
11. mouse right click - paste your sentences in ssh.
12. mv - move the folder or change name.
13. cp - copy


Useful software:
1. tmux - terminal multiplexer, useful when ssh is in used.
2. samba - ssh with gui.
3. putty - ssh client.
4. mtputty - simpler and more convenient package of putty.

tmux tips:
- to enter tmux: tmux
- to attach a tmux session: tmux a -t 0, 0 is the tmux session
- to see tmux session: enter tmux first, then only type "tmux ls"
- to detached a tmux session: ctrl + a + d
- to split screen horizontally: (1) tmux selectp -t 0, (2) tmux splitw -h -p 50
- to split screen vertically: (1) tmux selectp -t 0, (2) tmux splitw -v -p 50

Useful links:
1. Vim Commands Cheat Sheet - Easy to understand description.
2. Unix/Linux Command Reference - List of commands printable version.
3. Linux function description -  Good explanation.