Monday, October 7, 2013

Olimex Challenge #27 Angry Birds

Last weekend, I participated in Olimex Weekend Programming Challenge #27. The problem is finding a trajectory with given parameters such as gravity and .... stuff. I challenged myself writing a code with Racket ( its syntax is similar to  lisp and scheme ). The language is strange but very intriguing. You can check out my solution at here. Mine is solution #3.

Challenge yourself, and have FUN( )

Sunday, October 6, 2013

Develop ARM Cortex-M on Mac OSX (3)

  If you have followed my previous posts, you have arm gcc and appropriate project setups. Unfortunately, my eclipse is not working. So, I will be using Netbeans.

Today's procedure:
  1. Install Netbeans
  2. Setup Netbeans for arm gcc
  3. Compile ChibiOS
Okay, let's start!

1. Install Netbeans on Mac OSX. This part is easy. Download the binary package of C++ IDE from netbeans.org then install it. move the extracted folder to "/Applications" folder.

   2. Setup netbeans so that it can use arm gcc. Just like you do in eclipse, netbeans also needs PATH. 
Open preference by cliking Netbeans->Preference or press "[command] [,]"
Select C/C++->Build Tools

Your screen should look like this.



 Press [Add...] button


Press [Browse] button, then locate the bin folder.
Path: /Users/richpk21/Developer/Yagarto/yagarto-4.7.2/bin


Name the tool collection as "yagarto".
I already have a name "yagarto", thus I'm using a name "yagarto_2" for this tutorial.
Click [OK] button to finish adding a tool collection.


Set c, c++, as compiler path which are in the yagarto bin folder.
/Users/richpk21/Developer/Yagarto/yagarto-4.7.2/bin/arm-none-eabi-gcc
/Users/richpk21/Developer/Yagarto/yagarto-4.7.2/bin/arm-none-eabi-c++
/Users/richpk21/Developer/Yagarto/yagarto-4.7.2/bin/arm-none-eabi-as



Click [OK] button to finish setting tool name.



Next, we will set PATH for arm gcc.
Navigate to:
/Applications/NetBeans/NetBeans 7.3.1.app/Contents/Resources/NetBeans/etc 

Use
 sudo vim netbeans.conf

Add this to a new line:
PATH=/bin:/usr/bin:/usr/local/bin:/Users/richpk21/Developer/Yagarto/yagarto-4.7.2/bin

Save it by typing this in command mode:
:wq

Now, quit the Netbeans and relaunch it.




   3. Now, it is time to load the project and compile it.
Just like my last post, relocate project folder and chibios folder. If you have not done it, here is how:


copy  ~/workspace/ChibiOS/demos/ARMCM3-STM32F103
to       ~/workspace/ARMCM3-STM32F103
and then
copy  ~/workspace/ChibiOS
to       ~/workspace/ARMCM3-STM32F103/ChibiOS



After the project folder modification, create a new project.


 Select C/C++ -> C/C++ Project with Existing Source


Click the [Browser] button


Select the project folder that we modified. (ARMCM3-STM32F103)


Select yagarto tools that you added.


Use Automatic, unless you want to see what other options it offers chose Custom.








  Now, the arm gcc and the project is set. Build the project by clicking the hammer icon or hammer-and-broom icon. The ChibiOS should be compiled without errors. Start developing real-time os or applications with arm gcc and Netbeans.

Oh, and don't forget to have FUN( )

Saturday, October 5, 2013

Develop ARM Cortex-M on Mac OSX (2)


  Alright, last time I did a tutorial of how to install arm cortex-m compiler on Mac OSX. But, having just a compiler is not enough. A developer needs a good IDE.
Right?

  I have been searching for arm cortex-m tools on OSX for a very long time. There is one I know. It is eclipse based LPCxpressoIDE from Red-Code-Technologies. However, it works only for NXP chips (at least for downloading a firmware onto a chip). So, why not use normal eclipse? I found a tutorial using normal eclipse to compile a project. You can visit ChibiOS website to see how to setup eclipse so that a project can be compiled. I was able to compile and blink the on-board led on maple-mini with some modification on main.c file. Here is my test project for blinking led on maple-mini: GIT.

  I have encountered two problems with eclipse:

  1. The source file is full of errors and warnings, yet, it compiles just fine.
  2. Eclipse GUI is unstable
Let's talk about errors and warnings first. Most of the errors and warnings are from missing symbols and undefined variables. This is because eclipse cannot see outside of the project folder, while the folder is inside the ChibiOS folder. 
  Take a look at "here->Working with Projects->Preparing your Workspace->#2":
"Navigate the left tree into “C/C++→Code Analysis” and disable everything, without doing this you will see a lot of Errors and Warnings from the static analyzer mixed to the errors found by the compiler and that is very confusing."
Seriously... WHAT!?

Here is a quick fix for this. Reposition project folder (in my case "ARMCM3-STM32F103").
copy  ~/workspace/ChibiOS/demos/ARMCM3-STM32F103
to       ~/workspace/ARMCM3-STM32F103
and then
copy  ~/workspace/ChibiOS
to       ~/workspace/ARMCM3-STM32F103/ChibiOS
Now, import the project folder (in my case "ARMCM3-STM32F103") to eclipse then compile it. The errors should be gone by now :)


  When I followed the tutorial, eclipse 4.3.1 (kepler) was used. After a few days later, I captured this screenshot.

 Hmmm...

I don't know what to say but this is just a total failure. I tried removing eclipse and reinstall again several times and it showed exact same screen :(

Right now, I can't use eclipse. Thus, I will use Netbeans for now.

Friday, October 4, 2013

Develop ARM Cortex-M on Mac OSX

  I have a Maple-MINI, but I couldn't download a sketch to the board. I found a way to compile codes and flash the binary file onto STM32F103 micro-controller. All I needed were two things: gcc and maple-mini-bootloader source code.

Okay... I didn't plan on making a tutorial, but here it is.

If you are using other venders' arm cortex-m, you can follow my tutorial from step1 to step3.

Here is my procedure:

  1. First, install binary gcc                                        (Yagarto or arm-none-eabi)[*]
  2. Hold on a minute.                                               (edit .bash_profile)
  3. Now, it is time to compile some serious stuff      (maple-mini-bootloader)
  4. Wire it!                                                                (ftdi chip)
  5. Flash it!                                                               (stm32load.py)
[*] I think Yagarto and arm-none-eabi are the same :b




1. First, install binary gcc
  If you want to use Yagarto then go to here and click "YAGARTO GNU ARM toolchain" on the download section. Click resent folder (at the time: 20121222). Download the .dmg file. It took about 1 to 2 minutes for me. Next, open the .dmg file. Read and agree whatever on the screen. You will see yagarto app. Copy this file to desired location. In my case: $(HOME)/Developer/Yagarto/. Double click to install binary gcc in that folder. If you look inside the folder, you will find arm-none-eabi toolchain. Now you have arm gcc.

"But wait, I can't use arm-none-eabi-gcc!"

2. Hold on a minute. 
  PATH must be added, otherwise absolute path must be used.
Edit "~/.bash_profile". This file is similar to "~/.bashrc" in linx. Add this to new line:
export PATH=$PATH:"$HOME/Developer/Yagarto/yagarto-4.7.2/bin"

3. Now, it is time to compile some serious stuff.
  Download mini-bootloader (zip file can be downloaded from lower right hand side of the page).
Unzip to desired location. Open up a new terminal then go to the directory. Simply, type:
make

4. Wire it!
  UART is used in this process. This means you will need something like ftdi chip.
here is how wiring is done:

maple-miniftdi
vcc3v3
gndGND
boot1GND
rx1TXO
tx1RXI

Press two buttons, then release reset button. The maple-mini is in boot mode, now.
Oh, you can release the other button, too ;)


5. Flash it!
  The loader is in the "flash" folder in the project. Type like this on terminal(replace [xxx]):
python flash/stm32loader.py -evw -p /dev/tty.usb[xxx] build/maple_boot.bin
Press the reset button on the button to start your program.


Well?
Get crazy, and have FUN( )

Monday, September 30, 2013

My First Blog Post

This is my first post!